mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 19:21:06 +00:00
examples: webrtc: mp-sendrecv: add bus handler
Without this bus handler, messages posted to the bus will keep a ref to their source elements, preventing them from being disposed. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3219>
This commit is contained in:
parent
93ed51cbb2
commit
094b251901
1 changed files with 38 additions and 0 deletions
|
@ -119,6 +119,39 @@ get_string_from_json_object (JsonObject * object)
|
|||
return text;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
bus_watch_cb (GstBus * bus, GstMessage * message, gpointer user_data)
|
||||
{
|
||||
switch (GST_MESSAGE_TYPE (message)) {
|
||||
case GST_MESSAGE_ERROR:
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *debug = NULL;
|
||||
|
||||
gst_message_parse_error (message, &error, &debug);
|
||||
g_error ("Error on bus: %s (debug: %s)", error->message, debug);
|
||||
g_error_free (error);
|
||||
g_free (debug);
|
||||
break;
|
||||
}
|
||||
case GST_MESSAGE_WARNING:
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *debug = NULL;
|
||||
|
||||
gst_message_parse_warning (message, &error, &debug);
|
||||
g_warning ("Warning on bus: %s (debug: %s)", error->message, debug);
|
||||
g_error_free (error);
|
||||
g_free (debug);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_media_stream (GstPad * pad, GstElement * pipe, const char *convert_name,
|
||||
const char *sink_name)
|
||||
|
@ -413,6 +446,7 @@ start_pipeline (void)
|
|||
{
|
||||
GstStateChangeReturn ret;
|
||||
GError *error = NULL;
|
||||
GstBus *bus = NULL;
|
||||
|
||||
/* NOTE: webrtcbin currently does not support dynamic addition/removal of
|
||||
* streams, so we use a separate webrtcbin for each peer, but all of them are
|
||||
|
@ -428,6 +462,10 @@ start_pipeline (void)
|
|||
goto err;
|
||||
}
|
||||
|
||||
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||
gst_bus_add_watch (bus, bus_watch_cb, NULL);
|
||||
gst_object_unref (bus);
|
||||
|
||||
gst_print ("Starting pipeline, not transmitting yet\n");
|
||||
ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
||||
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||
|
|
Loading…
Reference in a new issue