From 1f4f338d85420c0d61d686af738c7eabd2e7388d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 20 Dec 2022 13:03:15 +0200 Subject: [PATCH] examples: webrtc: Add handling of the LATENCY messages to the C examples Without this the configured latency on the pipeline will be wrong. Part-of: --- .../webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c | 7 ++++++- .../gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c | 7 ++++++- .../webrtc/sendonly/webrtc-unidirectional-h264.c | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c b/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c index 81d56b575c..a184e19ff7 100644 --- a/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c +++ b/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c @@ -122,6 +122,8 @@ get_string_from_json_object (JsonObject * object) static gboolean bus_watch_cb (GstBus * bus, GstMessage * message, gpointer user_data) { + GstPipeline *pipeline = user_data; + switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: { @@ -145,6 +147,9 @@ bus_watch_cb (GstBus * bus, GstMessage * message, gpointer user_data) g_free (debug); break; } + case GST_MESSAGE_LATENCY: + gst_bin_recalculate_latency (GST_BIN (pipeline)); + break; default: break; } @@ -463,7 +468,7 @@ start_pipeline (void) } bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_watch (bus, bus_watch_cb, NULL); + gst_bus_add_watch (bus, bus_watch_cb, pipeline); gst_object_unref (bus); gst_print ("Starting pipeline, not transmitting yet\n"); diff --git a/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c b/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c index bac3a3a036..0533f083de 100644 --- a/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c +++ b/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c @@ -273,6 +273,8 @@ on_incoming_stream (GstElement * webrtc, GstPad * pad, static gboolean bus_watch_cb (GstBus * bus, GstMessage * message, gpointer user_data) { + GstPipeline *pipeline = user_data; + switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: { @@ -296,6 +298,9 @@ bus_watch_cb (GstBus * bus, GstMessage * message, gpointer user_data) g_free (debug); break; } + case GST_MESSAGE_LATENCY: + gst_bin_recalculate_latency (GST_BIN (pipeline)); + break; default: break; } @@ -365,7 +370,7 @@ create_receiver_entry (SoupWebsocketConnection * connection) G_CALLBACK (on_ice_candidate_cb), (gpointer) receiver_entry); bus = gst_pipeline_get_bus (GST_PIPELINE (receiver_entry->pipeline)); - gst_bus_add_watch (bus, bus_watch_cb, NULL); + gst_bus_add_watch (bus, bus_watch_cb, receiver_entry->pipeline); gst_object_unref (bus); if (gst_element_set_state (receiver_entry->pipeline, GST_STATE_PLAYING) == diff --git a/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c b/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c index ef52f416bb..4717b6abb1 100644 --- a/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c +++ b/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c @@ -169,6 +169,8 @@ const gchar *html_source = " \n \ static gboolean bus_watch_cb (GstBus * bus, GstMessage * message, gpointer user_data) { + GstPipeline *pipeline = user_data; + switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: { @@ -192,6 +194,9 @@ bus_watch_cb (GstBus * bus, GstMessage * message, gpointer user_data) g_free (debug); break; } + case GST_MESSAGE_LATENCY: + gst_bin_recalculate_latency (GST_BIN (pipeline)); + break; default: break; } @@ -297,7 +302,7 @@ create_receiver_entry (SoupWebsocketConnection * connection) G_CALLBACK (on_ice_candidate_cb), (gpointer) receiver_entry); bus = gst_pipeline_get_bus (GST_PIPELINE (receiver_entry->pipeline)); - gst_bus_add_watch (bus, bus_watch_cb, NULL); + gst_bus_add_watch (bus, bus_watch_cb, receiver_entry->pipeline); gst_object_unref (bus); if (gst_element_set_state (receiver_entry->pipeline, GST_STATE_PLAYING) ==