summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Manley <will@williammanley.net>2015-03-13 16:19:28 (GMT)
committerWim Taymans <wtaymans@redhat.com>2015-03-14 12:23:28 (GMT)
commit8328eab2dea1bdf5e6180f668aed2b83d203f1c4 (patch)
tree285ad318ad48c4be7359f092088dc1168a52bc12
parente63e023e300fd8ab778758dad6a28fa5cea154d2 (diff)
downloadgst-plugins-base-8328eab2dea1bdf5e6180f668aed2b83d203f1c4.tar.gz
gst-plugins-base-8328eab2dea1bdf5e6180f668aed2b83d203f1c4.tar.xz
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.
-rw-r--r--gst/tcp/gstsocketsrc.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/gst/tcp/gstsocketsrc.c b/gst/tcp/gstsocketsrc.c
index 219f653..81eef0a 100644
--- a/gst/tcp/gstsocketsrc.c
+++ b/gst/tcp/gstsocketsrc.c
@@ -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,