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.
This commit is contained in:
William Manley 2015-03-13 16:19:28 +00:00 committed by Wim Taymans
parent e63e023e30
commit 8328eab2de

View file

@ -49,6 +49,7 @@
#endif
#include <gst/gst-i18n-plugin.h>
#include <gst/net/gstnetcontrolmessagemeta.h>
#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,