summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Manley <will@williammanley.net>2014-10-30 17:53:15 (GMT)
committerWim Taymans <wtaymans@redhat.com>2015-03-14 12:23:20 (GMT)
commite63e023e300fd8ab778758dad6a28fa5cea154d2 (patch)
tree45ab12a699e88e0ec06b7308e9e2e1694bd34031
parenta297b0545f664c82351bbae1fd3f943d068b5031 (diff)
downloadgst-plugins-base-e63e023e300fd8ab778758dad6a28fa5cea154d2.tar.gz
gst-plugins-base-e63e023e300fd8ab778758dad6a28fa5cea154d2.tar.xz
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.
-rw-r--r--configure.ac1
-rw-r--r--gst/tcp/gstmultisocketsink.c29
2 files changed, 26 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index ab79e72..f60dc0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
diff --git a/gst/tcp/gstmultisocketsink.c b/gst/tcp/gstmultisocketsink.c
index fa4eee5..22a7e33 100644
--- a/gst/tcp/gstmultisocketsink.c
+++ b/gst/tcp/gstmultisocketsink.c
@@ -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.
*