webrtcbin: Match unassociated transceiver by kind too
authorOlivier Crête <olivier.crete@collabora.com>
Wed, 31 Mar 2021 15:30:16 +0000 (11:30 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Mon, 12 Apr 2021 22:37:27 +0000 (18:37 -0400)
When a new m-line comes in that doesn't have a transceiver, only match
existing transceivers of the same kind.

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

ext/webrtc/gstwebrtcbin.c

index 1658600..cc4ad55 100644 (file)
@@ -4527,12 +4527,16 @@ static gboolean
 _find_compatible_unassociated_transceiver (GstWebRTCRTPTransceiver * p1,
     gconstpointer data)
 {
+  GstWebRTCKind kind = GPOINTER_TO_INT (data);
+
   if (p1->mid)
     return FALSE;
   if (p1->mline != -1)
     return FALSE;
   if (p1->stopped)
     return FALSE;
+  if (p1->kind != GST_WEBRTC_KIND_UNKNOWN && p1->kind != kind)
+    return FALSE;
 
   return TRUE;
 }
@@ -4659,7 +4663,14 @@ _update_transceivers_from_sdp (GstWebRTCBin * webrtc, SDPSource source,
           g_strcmp0 (gst_sdp_media_get_media (media), "video") == 0) {
         /* No existing transceiver, find an unused one */
         if (!trans) {
-          trans = _find_transceiver (webrtc, NULL,
+          GstWebRTCKind kind;
+
+          if (g_strcmp0 (gst_sdp_media_get_media (media), "audio") == 0)
+            kind = GST_WEBRTC_KIND_AUDIO;
+          else
+            kind = GST_WEBRTC_KIND_VIDEO;
+
+          trans = _find_transceiver (webrtc, GINT_TO_POINTER (kind),
               (FindTransceiverFunc) _find_compatible_unassociated_transceiver);
         }