From 5d0628ff52ca3194a870fdf6af771fce61924984 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 24 Dec 2016 16:44:26 +0900 Subject: [PATCH] urisourcebin: Use GList for typefind elements We need typefind elements per source element's srcpad https://bugzilla.gnome.org/show_bug.cgi?id=776458 --- gst/playback/gsturisourcebin.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/gst/playback/gsturisourcebin.c b/gst/playback/gsturisourcebin.c index c5883eaf3c..955af93815 100644 --- a/gst/playback/gsturisourcebin.c +++ b/gst/playback/gsturisourcebin.c @@ -122,7 +122,7 @@ struct _GstURISourceBin gboolean use_buffering; GstElement *source; - GstElement *typefind; + GList *typefinds; /* list of typefind element */ GstElement *demuxer; /* Adaptive demuxer if any */ GSList *out_slots; @@ -1986,12 +1986,11 @@ setup_streaming (GstURISourceBin * urisrc) if (!gst_element_link_pads (urisrc->source, NULL, typefind, "sink")) goto could_not_link; - urisrc->typefind = typefind; + urisrc->typefinds = g_list_append (urisrc->typefinds, typefind); /* connect a signal to find out when the typefind element found * a type */ - g_signal_connect (urisrc->typefind, "have-type", - G_CALLBACK (type_found), urisrc); + g_signal_connect (typefind, "have-type", G_CALLBACK (type_found), urisrc); return TRUE; @@ -2068,11 +2067,19 @@ remove_source (GstURISourceBin * urisrc) gst_bin_remove (GST_BIN_CAST (urisrc), source); urisrc->source = NULL; } - if (urisrc->typefind) { + if (urisrc->typefinds) { + GList *iter, *next; GST_DEBUG_OBJECT (urisrc, "removing old typefind element"); - gst_element_set_state (urisrc->typefind, GST_STATE_NULL); - gst_bin_remove (GST_BIN_CAST (urisrc), urisrc->typefind); - urisrc->typefind = NULL; + for (iter = urisrc->typefinds; iter; iter = next) { + GstElement *typefind = iter->data; + + next = g_list_next (iter); + + gst_element_set_state (typefind, GST_STATE_NULL); + gst_bin_remove (GST_BIN_CAST (urisrc), typefind); + } + + urisrc->typefinds = NULL; } GST_URI_SOURCE_BIN_LOCK (urisrc); @@ -2805,8 +2812,15 @@ gst_uri_source_bin_change_state (GstElement * element, /* And now sync the states of everything we added */ g_slist_foreach (urisrc->out_slots, (GFunc) sync_slot_queue, NULL); - if (urisrc->typefind) - ret = gst_element_set_state (urisrc->typefind, GST_STATE_PAUSED); + if (urisrc->typefinds) { + GList *iter; + for (iter = urisrc->typefinds; iter; iter = iter->next) { + GstElement *typefind = iter->data; + ret = gst_element_set_state (typefind, GST_STATE_PAUSED); + if (ret == GST_STATE_CHANGE_FAILURE) + goto setup_failed; + } + } if (ret == GST_STATE_CHANGE_FAILURE) goto setup_failed; if (urisrc->source)