Commit e63e023e authored by William Manley's avatar William Manley Committed by Wim Taymans

multisocketsink: Add support for GstNetControlMessageMeta

multisocketsink now understands the new GstNetControlMessageMeta to allow
sending control messages (ancillary data) with data when writing to Unix
domain sockets.

A later commit will introduce a new socketsrc element which will similarly
understand `GstNetControlMessageMeta`.  This, when used with a
`GSocketControlMessage` of type `GUnixFDMessage` will allow GStreamer to
send and receive file-descriptions in ancillary data, the first step to
using memfds to implement zero-copy video IPC.

Thanks to glib's `GSocketControlMessage` abstraction the code introduced
in this commit is entirely portable and doesn't introduce and additional
dependencies or conditionally compiled code, even if it is unlikely to be
of much use on non-UNIX systems.
parent a297b054
......@@ -255,6 +255,7 @@ ORC_CHECK([0.4.23])
dnl checks for gstreamer
dnl uninstalled is selected preferentially -- see pkg-config(1)
AG_GST_CHECK_GST($GST_API_VERSION, [$GST_REQ], yes)
AG_GST_CHECK_GST_NET($GST_API_VERSION, [$GST_REQ], yes)
AG_GST_CHECK_GST_BASE($GST_API_VERSION, [$GST_REQ], yes)
AG_GST_CHECK_GST_CONTROLLER($GST_API_VERSION, [$GST_REQ], yes)
AG_GST_CHECK_GST_CHECK($GST_API_VERSION, [$GST_REQ], no)
......
......@@ -103,6 +103,7 @@
#endif
#include <gst/gst-i18n-plugin.h>
#include <gst/net/gstnetcontrolmessagemeta.h>
#include <string.h>
......@@ -672,6 +673,25 @@ unmap_n_memorys (GstMapInfo * mapinfo, int num_mappings)
gst_memory_unmap (mapinfo[i].memory, &mapinfo[i]);
}
static gsize
gst_buffer_get_cmsg_list (GstBuffer * buf, GSocketControlMessage ** msgs,
gsize msg_space)
{
gpointer iter_state = NULL;
GstMeta *meta;
gsize msg_count = 0;
while ((meta = gst_buffer_iterate_meta (buf, &iter_state)) != NULL
&& msg_count < msg_space) {
if (meta->info->api == GST_NET_CONTROL_MESSAGE_META_API_TYPE)
msgs[msg_count++] = ((GstNetControlMessageMeta *) meta)->message;
}
return msg_count;
}
#define CMSG_MAX 255
static gssize
gst_multi_socket_sink_write (GstMultiSocketSink * sink,
GSocket * sock, GstBuffer * buffer, gsize bufoffset,
......@@ -681,19 +701,20 @@ gst_multi_socket_sink_write (GstMultiSocketSink * sink,
GOutputVector vec[8];
guint mems_mapped;
gssize wrote;
GSocketControlMessage *cmsgs[CMSG_MAX];
gsize msg_count;
mems_mapped = map_n_memory_output_vector (buffer, bufoffset, vec, maps, 8);
msg_count = gst_buffer_get_cmsg_list (buffer, cmsgs, CMSG_MAX);
wrote =
g_socket_send_message (sock, NULL, vec, mems_mapped, NULL, 0, 0,
g_socket_send_message (sock, NULL, vec, mems_mapped, cmsgs, msg_count, 0,
cancellable, err);
unmap_n_memorys (maps, mems_mapped);
return wrote;
}
/* Handle a write on a client,
* which indicates a read request from a client.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment