webrtcbin: silence spurious warning when creating answer transceiver
authorMatthew Waters <matthew@centricular.com>
Wed, 21 Jul 2021 07:39:11 +0000 (17:39 +1000)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 29 Mar 2022 23:55:40 +0000 (23:55 +0000)
When creating a transceiver when creating an answer, the media kind of the
transceiver was never set correctly initially.  This would lead to a
GST_WARNING being produced about changin a transceiver's media kind.

Fix by retrieving the GstSDPMedia kind from the offer instead as the answer
GstSDPMedia has not been set as the answer caps have not been chosen yet.

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

subprojects/gst-plugins-bad/tests/check/elements/webrtcbin.c

index ecb5567..946c584 100644 (file)
@@ -1022,6 +1022,16 @@ create_audio_test (void)
   return t;
 }
 
+static void
+on_new_transceiver_expected_kind (GstWebRTCBin * webrtc,
+    GstWebRTCRTPTransceiver * trans, gpointer user_data)
+{
+  GstWebRTCKind kind, expected = GPOINTER_TO_UINT (user_data);
+
+  g_object_get (trans, "kind", &kind, NULL);
+  fail_unless_equals_int (kind, expected);
+}
+
 GST_START_TEST (test_audio)
 {
   struct test_webrtc *t = create_audio_test ();
@@ -1043,10 +1053,18 @@ GST_START_TEST (test_audio)
   const gchar *expected_answer_direction[] = { "recvonly", };
   VAL_SDP_INIT (answer, on_sdp_media_direction, expected_answer_direction,
       &answer_setup);
+  GstWebRTCKind expected_kind = GST_WEBRTC_KIND_AUDIO;
 
   /* check that a single stream connection creates the associated number
    * of media sections */
 
+  g_signal_connect (t->webrtc1, "on-new-transceiver",
+      G_CALLBACK (on_new_transceiver_expected_kind),
+      GUINT_TO_POINTER (expected_kind));
+  g_signal_connect (t->webrtc2, "on-new-transceiver",
+      G_CALLBACK (on_new_transceiver_expected_kind),
+      GUINT_TO_POINTER (expected_kind));
+
   test_validate_sdp (t, &offer, &answer);
   test_webrtc_free (t);
 }