From 8328eab2dea1bdf5e6180f668aed2b83d203f1c4 Mon Sep 17 00:00:00 2001 From: William Manley Date: Fri, 13 Mar 2015 16:19:28 +0000 Subject: [PATCH] socketsrc: 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. 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. --- gst/tcp/gstsocketsrc.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gst/tcp/gstsocketsrc.c b/gst/tcp/gstsocketsrc.c index 219f6530a0..81eef0a5e2 100644 --- a/gst/tcp/gstsocketsrc.c +++ b/gst/tcp/gstsocketsrc.c @@ -49,6 +49,7 @@ #endif #include +#include #include "gstsocketsrc.h" #include "gsttcp.h" @@ -167,6 +168,11 @@ gst_socket_src_fill (GstPushSrc * psrc, GstBuffer * outbuf) GError *err = NULL; GstMapInfo map; GSocket *socket = NULL; + GSocketControlMessage **messages = NULL; + gint num_messages = 0; + gint i; + GInputVector ivec; + gint flags = 0; src = GST_SOCKET_SRC (psrc); @@ -184,10 +190,20 @@ gst_socket_src_fill (GstPushSrc * psrc, GstBuffer * outbuf) retry: gst_buffer_map (outbuf, &map, GST_MAP_READWRITE); - rret = g_socket_receive_with_blocking (socket, (gchar *) map.data, - map.size, TRUE, src->cancellable, &err); + ivec.buffer = map.data; + ivec.size = map.size; + rret = + g_socket_receive_message (socket, NULL, &ivec, 1, &messages, + &num_messages, &flags, src->cancellable, &err); gst_buffer_unmap (outbuf, &map); + for (i = 0; i < num_messages; i++) { + gst_buffer_add_net_control_message_meta (outbuf, messages[i]); + g_object_unref (messages[i]); + messages[i] = NULL; + } + g_free (messages); + if (rret == 0) { GSocket *tmp = NULL; GST_DEBUG_OBJECT (src, "Received EOS on socket %p fd %i", socket,