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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3609>
This commit is contained in:
Sebastian Dröge 2022-12-20 13:03:15 +02:00
parent d10981f7b9
commit 1f4f338d85
3 changed files with 18 additions and 3 deletions

View file

@ -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");

View file

@ -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) ==

View file

@ -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) ==