webrtc test: Add explicit test clock
authorOlivier Crête <olivier.crete@collabora.com>
Wed, 14 Apr 2021 23:46:56 +0000 (19:46 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Thu, 13 May 2021 19:05:00 +0000 (15:05 -0400)
This way the test clock is not linked to the multiple harnesses

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

tests/check/elements/webrtcbin.c

index 2f6747f..a883fee 100644 (file)
@@ -62,6 +62,7 @@ struct test_webrtc;
 struct test_webrtc
 {
   GList *harnesses;
+  GstTestClock *test_clock;
   GThread *thread;
   GMainLoop *loop;
   GstBus *bus1;
@@ -538,6 +539,8 @@ test_webrtc_new (void)
   g_mutex_init (&ret->lock);
   g_cond_init (&ret->cond);
 
+  ret->test_clock = GST_TEST_CLOCK (gst_test_clock_new ());
+
   ret->thread = g_thread_new ("test-webrtc", (GThreadFunc) _bus_thread, ret);
 
   g_mutex_lock (&ret->lock);
@@ -553,6 +556,9 @@ test_webrtc_new (void)
   ret->webrtc2 = gst_element_factory_make ("webrtcbin", NULL);
   fail_unless (ret->webrtc1 != NULL && ret->webrtc2 != NULL);
 
+  gst_element_set_clock (ret->webrtc1, GST_CLOCK (ret->test_clock));
+  gst_element_set_clock (ret->webrtc2, GST_CLOCK (ret->test_clock));
+
   gst_element_set_bus (ret->webrtc1, ret->bus1);
   gst_element_set_bus (ret->webrtc2, ret->bus2);
 
@@ -617,6 +623,8 @@ test_webrtc_free (struct test_webrtc *t)
 
   g_thread_join (t->thread);
 
+  g_object_unref (t->test_clock);
+
   gst_bus_remove_watch (t->bus1);
   gst_bus_remove_watch (t->bus2);