From 83e546f935218754ec2d603cefaffacd613f53a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Wed, 31 Mar 2021 11:30:16 -0400 Subject: [PATCH] webrtcbin: Match unassociated transceiver by kind too When a new m-line comes in that doesn't have a transceiver, only match existing transceivers of the same kind. Part-of: --- ext/webrtc/gstwebrtcbin.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index 165860023e..cc4ad55da3 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -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); }