webrtcbin: Enforce direction on request sink pad with a specific name
authorOlivier Crête <olivier.crete@collabora.com>
Sat, 27 Mar 2021 01:09:04 +0000 (21:09 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Mon, 12 Apr 2021 21:55:07 +0000 (17:55 -0400)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>

ext/webrtc/gstwebrtcbin.c

index b21faa4..88cdc5d 100644 (file)
@@ -6302,6 +6302,7 @@ sink_pad_block (GstPad * pad, GstPadProbeInfo * info, gpointer unused)
   return GST_PAD_PROBE_OK;
 }
 
+
 static GstPad *
 gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
     const gchar * name, const GstCaps * caps)
@@ -6338,7 +6339,20 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
     trans = _find_transceiver_for_mline (webrtc, serial);
 
     if (trans) {
-      /* Ignore transceivers that already have a pad allocated */
+      /* Reject transceivers that are only for receiving ... */
+      if (trans->direction == GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY ||
+          trans->direction == GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_INACTIVE) {
+        gchar *direction =
+            g_enum_to_string (GST_TYPE_WEBRTC_RTP_TRANSCEIVER_DIRECTION,
+            trans->direction);
+        GST_ERROR_OBJECT (element, "Tried to request a new sink pad %s for"
+            " existing m-line %d, but the transceiver's direction is %s",
+            name, serial, direction);
+        g_free (direction);
+        return NULL;
+      }
+
+      /* Reject transceivers that already have a pad allocated */
       pad2 = _find_pad_for_transceiver (webrtc, GST_PAD_SINK, trans);
       if (pad2) {
         GST_ERROR_OBJECT (element, "Trying to request pad %s for m-line %d, "