webrtcbin: fix picking available payload types
authorMathieu Duponchelle <mathieu@centricular.com>
Tue, 6 Sep 2022 16:49:02 +0000 (18:49 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 7 Sep 2022 03:22:34 +0000 (03:22 +0000)
When picking an available payload type, we need to pick one that is
available across all media.

The previous code, when multiple media were present, looked at the first one,
noticed it had pt 96 as the media pt, then simply looked at the next media,
noticed it didn't, and decided 96 was available.

Instead, check if the pt is used by any of the media, if it is, decide
it is not available and go to the next pt. I'm fairly sure that was the
original intent.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2984>

subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c

index b10a4bd..ea33864 100644 (file)
@@ -2734,23 +2734,22 @@ _pick_available_pt (GArray * media_mapping, guint * ret)
   int i;
 
   for (i = 96; i <= 127; i++) {
+    gboolean available = TRUE;
     int j;
 
     for (j = 0; j < media_mapping->len; j++) {
       struct media_payload_map_item *item;
 
       item = &g_array_index (media_mapping, struct media_payload_map_item, j);
-      if (item->media_pt == i)
-        continue;
-      if (item->red_pt == i)
-        continue;
-      if (item->rtx_pt == i)
-        continue;
-      if (item->ulpfec_pt == i)
-        continue;
-      if (item->red_rtx_pt == i)
-        continue;
 
+      if (item->media_pt == i || item->red_pt == i || item->rtx_pt == i
+          || item->ulpfec_pt == i || item->red_rtx_pt == i) {
+        available = FALSE;
+        break;
+      }
+    }
+
+    if (available) {
       *ret = i;
       return TRUE;
     }