webrtcbin: Simplify answer_caps intersection code a little
authorOlivier Crête <olivier.crete@collabora.com>
Mon, 12 Apr 2021 21:54:31 +0000 (17:54 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Mon, 12 Apr 2021 22:37:27 +0000 (18:37 -0400)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>

ext/webrtc/gstwebrtcbin.c

index 3525d1b..107d4dc 100644 (file)
@@ -3540,25 +3540,19 @@ _create_answer_task (GstWebRTCBin * webrtc, const GstStructure * options,
            * that we cannot actually support */
           if (trans_caps) {
             answer_caps = gst_caps_intersect (offer_caps, trans_caps);
-            if (answer_caps && !gst_caps_is_empty (answer_caps)) {
-              GST_LOG_OBJECT (webrtc,
-                  "found compatible transceiver %" GST_PTR_FORMAT
-                  " for offer media %u", rtp_trans, i);
-              if (trans_caps)
-                gst_caps_unref (trans_caps);
-              break;
-            } else {
-              if (answer_caps) {
-                gst_caps_unref (answer_caps);
-                answer_caps = NULL;
+            gst_caps_unref (trans_caps);
+            if (answer_caps) {
+              if (!gst_caps_is_empty (answer_caps)) {
+                GST_LOG_OBJECT (webrtc,
+                    "found compatible transceiver %" GST_PTR_FORMAT
+                    " for offer media %u", rtp_trans, i);
+                break;
               }
-              if (trans_caps)
-                gst_caps_unref (trans_caps);
-              rtp_trans = NULL;
+              gst_caps_unref (answer_caps);
+              answer_caps = NULL;
             }
-          } else {
-            rtp_trans = NULL;
           }
+          rtp_trans = NULL;
         }
       }