srtobject: obey "wait-for-connection" in caller mode
authorJakub Adam <jakub.adam@collabora.com>
Mon, 23 Nov 2020 15:12:39 +0000 (16:12 +0100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 6 Jan 2021 18:55:37 +0000 (18:55 +0000)
The pipeline now gets stuck in gst_srt_object_write_one() until the
receiver comes online, which may or may not be desired based on the use
case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1836>

ext/srt/gstsrtobject.c

index 3439f31..ed411ed 100644 (file)
@@ -1602,8 +1602,10 @@ gst_srt_object_write_one (GstSRTObject * srtobject,
   gint poll_timeout;
   const guint8 *msg = mapinfo->data;
   gint payload_size, optlen = 1;
+  gboolean wait_for_connection;
 
   GST_OBJECT_LOCK (srtobject->element);
+  wait_for_connection = srtobject->wait_for_connection;
   if (!gst_structure_get_int (srtobject->parameters, "poll-timeout",
           &poll_timeout)) {
     poll_timeout = GST_SRT_DEFAULT_POLL_TIMEOUT;
@@ -1629,6 +1631,13 @@ gst_srt_object_write_one (GstSRTObject * srtobject,
       break;
     }
 
+    if (!wait_for_connection &&
+        srt_getsockstate (srtobject->sock) == SRTS_CONNECTING) {
+      GST_LOG_OBJECT (srtobject->element,
+          "Not connected yet. Dropping the buffer.");
+      break;
+    }
+
     if (srt_epoll_wait (srtobject->poll_id, 0, 0, &wsock,
             &wsocklen, poll_timeout, NULL, 0, NULL, 0) < 0) {
       continue;