gst/playback/: Some playbin cleanups mostly refcounting sloppyness.

Original commit message from CVS:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (try_to_link_1), (get_our_ghost_pad),
(remove_element_chain), (no_more_pads), (unlinked), (close_link),
(type_found):
* gst/playback/gstplaybasebin.c: (gst_play_base_bin_dispose),
(group_destroy), (group_commit), (queue_overrun),
(gen_preroll_element), (no_more_pads), (preroll_unlinked),
(mute_stream), (new_decoded_pad), (setup_substreams),
(setup_source), (mute_group_type), (set_active_source),
(gst_play_base_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_dispose),
(gen_video_element), (gen_text_element), (gen_audio_element),
(gen_vis_element), (remove_sinks), (add_sink), (setup_sinks):
* gst/playback/gststreaminfo.c: (gst_stream_info_new),
(gst_stream_info_dispose), (gst_stream_info_set_mute):
* gst/playback/gststreamselector.c: (gst_stream_selector_chain):
Some playbin cleanups mostly refcounting sloppyness.
This commit is contained in:
Wim Taymans 2005-05-25 19:47:52 +00:00
parent 6e057d28f8
commit b48b315b81
6 changed files with 246 additions and 166 deletions

View file

@ -1,3 +1,23 @@
2005-05-25 Wim Taymans <wim@fluendo.com>
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (try_to_link_1), (get_our_ghost_pad),
(remove_element_chain), (no_more_pads), (unlinked), (close_link),
(type_found):
* gst/playback/gstplaybasebin.c: (gst_play_base_bin_dispose),
(group_destroy), (group_commit), (queue_overrun),
(gen_preroll_element), (no_more_pads), (preroll_unlinked),
(mute_stream), (new_decoded_pad), (setup_substreams),
(setup_source), (mute_group_type), (set_active_source),
(gst_play_base_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_dispose),
(gen_video_element), (gen_text_element), (gen_audio_element),
(gen_vis_element), (remove_sinks), (add_sink), (setup_sinks):
* gst/playback/gststreaminfo.c: (gst_stream_info_new),
(gst_stream_info_dispose), (gst_stream_info_set_mute):
* gst/playback/gststreamselector.c: (gst_stream_selector_chain):
Some playbin cleanups mostly refcounting sloppyness.
2005-05-25 Ronald S. Bultje <rbultje@ronald.bitfreak.net> 2005-05-25 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet): * ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet):

View file

@ -309,11 +309,18 @@ gst_decode_bin_init (GstDecodeBin * decode_bin)
if (!decode_bin->typefind) { if (!decode_bin->typefind) {
g_warning ("can't find typefind element, decodebin will not work"); g_warning ("can't find typefind element, decodebin will not work");
} else { } else {
GstPad *pad;
/* add the typefind element */ /* add the typefind element */
gst_bin_add (GST_BIN (decode_bin), decode_bin->typefind); gst_bin_add (GST_BIN (decode_bin), decode_bin->typefind);
/* get the sinkpad */
pad = gst_element_get_pad (decode_bin->typefind, "sink");
/* ghost the sink pad to ourself */ /* ghost the sink pad to ourself */
gst_element_add_ghost_pad (GST_ELEMENT (decode_bin), gst_element_add_ghost_pad (GST_ELEMENT (decode_bin), pad, "sink");
gst_element_get_pad (decode_bin->typefind, "sink"), "sink");
gst_object_unref (GST_OBJECT_CAST (pad));
/* connect a signal to find out when the typefind element found /* connect a signal to find out when the typefind element found
* a type */ * a type */
@ -326,6 +333,8 @@ gst_decode_bin_init (GstDecodeBin * decode_bin)
decode_bin->dynamics = NULL; decode_bin->dynamics = NULL;
} }
static void dynamic_free (GstDynamic * dyn);
static void static void
gst_decode_bin_dispose (GObject * object) gst_decode_bin_dispose (GObject * object)
{ {
@ -344,14 +353,12 @@ gst_decode_bin_dispose (GObject * object)
for (dyns = decode_bin->dynamics; dyns; dyns = g_list_next (dyns)) { for (dyns = decode_bin->dynamics; dyns; dyns = g_list_next (dyns)) {
GstDynamic *dynamic = (GstDynamic *) dyns->data; GstDynamic *dynamic = (GstDynamic *) dyns->data;
g_free (dynamic); dynamic_free (dynamic);
} }
g_list_free (decode_bin->dynamics); g_list_free (decode_bin->dynamics);
decode_bin->dynamics = NULL; decode_bin->dynamics = NULL;
if (G_OBJECT_CLASS (parent_class)->dispose) { G_OBJECT_CLASS (parent_class)->dispose (object);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
} }
static GstDynamic * static GstDynamic *
@ -553,27 +560,37 @@ static GstElement *
try_to_link_1 (GstDecodeBin * decode_bin, GstPad * pad, GList * factories) try_to_link_1 (GstDecodeBin * decode_bin, GstPad * pad, GList * factories)
{ {
GList *walk; GList *walk;
GstElement *result = NULL;
/* loop over the factories */ /* loop over the factories */
for (walk = factories; walk; walk = g_list_next (walk)) { for (walk = factories; walk; walk = g_list_next (walk)) {
GstElementFactory *factory = GST_ELEMENT_FACTORY (walk->data); GstElementFactory *factory = GST_ELEMENT_FACTORY (walk->data);
GstElement *element; GstElement *element;
GstPadLinkReturn ret; GstPadLinkReturn ret;
GstPad *sinkpad;
GST_DEBUG_OBJECT (decode_bin, "trying to link %s", GST_DEBUG_OBJECT (decode_bin, "trying to link %s",
gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
/* make an element from the factory first */ /* make an element from the factory first */
element = gst_element_factory_create (factory, NULL); if ((element = gst_element_factory_create (factory, NULL)) == NULL) {
if (element == NULL) {
/* hmm, strange. Like with all things in live, let's move on.. */ /* hmm, strange. Like with all things in live, let's move on.. */
GST_WARNING_OBJECT (decode_bin, "could not create an element from %s", GST_WARNING_OBJECT (decode_bin, "could not create an element from %s",
gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
continue; continue;
} }
/* try to link the given pad to a sinkpad */
/* FIXME, find the sinkpad by looping over the pads instead of
* looking it up by name */
if ((sinkpad = gst_element_get_pad (element, "sink")) == NULL) {
/* if no pad is found we can't do anything */
GST_WARNING_OBJECT (decode_bin, "could not find sinkpad in element");
continue;
}
/* now add the element to the bin first */ /* now add the element to the bin first */
GST_DEBUG_OBJECT (decode_bin, "adding %s", gst_element_get_name (element)); GST_DEBUG_OBJECT (decode_bin, "adding %s", GST_OBJECT_NAME (element));
gst_bin_add (GST_BIN (decode_bin), element); gst_bin_add (GST_BIN (decode_bin), element);
/* set to ready first so it is ready */ /* set to ready first so it is ready */
@ -582,11 +599,15 @@ try_to_link_1 (GstDecodeBin * decode_bin, GstPad * pad, GList * factories)
/* keep our own list of elements */ /* keep our own list of elements */
decode_bin->elements = g_list_prepend (decode_bin->elements, element); decode_bin->elements = g_list_prepend (decode_bin->elements, element);
/* try to link the given pad to a sinkpad */ if ((ret = gst_pad_link (pad, sinkpad)) != GST_PAD_LINK_OK) {
/* FIXME, find the sinkpad by looping over the pads instead of GST_DEBUG_OBJECT (decode_bin, "link failed on pad %s:%s, reason %d",
* looking it up by name */ GST_DEBUG_PAD_NAME (pad), ret);
ret = gst_pad_link (pad, gst_element_get_pad (element, "sink")); /* get rid of the sinkpad */
if (ret == GST_PAD_LINK_OK) { gst_object_unref (GST_OBJECT_CAST (sinkpad));
/* this element did not work, remove it again and continue trying
* other elements, the element will be disposed. */
gst_bin_remove (GST_BIN (decode_bin), element);
} else {
const gchar *klass; const gchar *klass;
GstElementFactory *factory; GstElementFactory *factory;
guint sig; guint sig;
@ -597,6 +618,7 @@ try_to_link_1 (GstDecodeBin * decode_bin, GstPad * pad, GList * factories)
/* The link worked, now figure out what it was that we connected */ /* The link worked, now figure out what it was that we connected */
factory = gst_element_get_factory (element); factory = gst_element_get_factory (element);
klass = gst_element_factory_get_klass (factory); klass = gst_element_factory_get_klass (factory);
/* check if we can use threads */ /* check if we can use threads */
if (decode_bin->threaded) { if (decode_bin->threaded) {
if (strstr (klass, "Demux") != NULL) { if (strstr (klass, "Demux") != NULL) {
@ -608,8 +630,9 @@ try_to_link_1 (GstDecodeBin * decode_bin, GstPad * pad, GList * factories)
} }
/* make sure we catch unlink signals */ /* make sure we catch unlink signals */
sig = g_signal_connect (G_OBJECT (GST_PAD_REALIZE (pad)), "unlinked", sig = g_signal_connect (G_OBJECT (pad), "unlinked",
G_CALLBACK (unlinked), decode_bin); G_CALLBACK (unlinked), decode_bin);
/* keep a ref to the signal id so that we can disconnect the signal callback */ /* keep a ref to the signal id so that we can disconnect the signal callback */
g_object_set_data (G_OBJECT (pad), "unlinked_id", GINT_TO_POINTER (sig)); g_object_set_data (G_OBJECT (pad), "unlinked_id", GINT_TO_POINTER (sig));
@ -618,21 +641,24 @@ try_to_link_1 (GstDecodeBin * decode_bin, GstPad * pad, GList * factories)
close_link (element, decode_bin); close_link (element, decode_bin);
/* change the state of the element to that of the parent */ /* change the state of the element to that of the parent */
gst_element_set_state (element, GST_STATE_PAUSED); gst_element_set_state (element, GST_STATE_PAUSED);
return element;
} else { result = element;
GST_DEBUG_OBJECT (decode_bin, "link failed on pad %s:%s",
GST_DEBUG_PAD_NAME (pad)); /* get rid of the sinkpad now */
/* this element did not work, remove it again and continue trying gst_object_unref (GST_OBJECT_CAST (sinkpad));
* other elements */
gst_bin_remove (GST_BIN (decode_bin), element); /* and exit */
goto done;
} }
} }
return NULL; done:
return result;
} }
static GstPad * static GstPad *
get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad) get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad)
{ {
#if 0
GList *ghostpads; GList *ghostpads;
if (pad == NULL || !GST_PAD_IS_SRC (pad)) { if (pad == NULL || !GST_PAD_IS_SRC (pad)) {
@ -643,8 +669,7 @@ get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad)
if (GST_IS_GHOST_PAD (pad)) { if (GST_IS_GHOST_PAD (pad)) {
GstElement *parent = gst_pad_get_parent (pad); GstElement *parent = gst_pad_get_parent (pad);
GST_DEBUG_OBJECT (decode_bin, "pad parent %s", GST_DEBUG_OBJECT (decode_bin, "pad parent %s", GST_ELEMENT_NAME (parent));
gst_element_get_name (parent));
if (parent == GST_ELEMENT (decode_bin)) { if (parent == GST_ELEMENT (decode_bin)) {
GST_DEBUG_OBJECT (decode_bin, "pad is our ghostpad"); GST_DEBUG_OBJECT (decode_bin, "pad is our ghostpad");
@ -669,6 +694,7 @@ get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad)
ghostpads = g_list_next (ghostpads); ghostpads = g_list_next (ghostpads);
} }
GST_DEBUG_OBJECT (decode_bin, "done looping over ghostpads, nothing found"); GST_DEBUG_OBJECT (decode_bin, "done looping over ghostpads, nothing found");
#endif
return NULL; return NULL;
} }
@ -680,7 +706,7 @@ get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad)
static void static void
remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad) remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
{ {
GList *int_links; GList *int_links, *walk;
GstElement *elem = GST_ELEMENT (GST_OBJECT_PARENT (pad)); GstElement *elem = GST_ELEMENT (GST_OBJECT_PARENT (pad));
while (GST_OBJECT_PARENT (elem) && while (GST_OBJECT_PARENT (elem) &&
@ -688,16 +714,16 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
elem = GST_ELEMENT (GST_OBJECT_PARENT (elem)); elem = GST_ELEMENT (GST_OBJECT_PARENT (elem));
GST_DEBUG_OBJECT (decode_bin, "%s:%s", GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_OBJECT (decode_bin, "%s:%s", GST_DEBUG_PAD_NAME (pad));
int_links = gst_pad_get_internal_links (pad);
/* remove all elements linked to this pad up to the ghostpad /* remove all elements linked to this pad up to the ghostpad
* that we created for this stream */ * that we created for this stream */
for (int_links = gst_pad_get_internal_links (pad); for (walk = int_links; walk; walk = g_list_next (walk)) {
int_links; int_links = g_list_next (int_links)) {
GstPad *pad; GstPad *pad;
GstPad *ghostpad; GstPad *ghostpad;
GstPad *peer; GstPad *peer;
pad = GST_PAD (int_links->data); pad = GST_PAD (walk->data);
GST_DEBUG_OBJECT (decode_bin, "inspecting internal pad %s:%s", GST_DEBUG_OBJECT (decode_bin, "inspecting internal pad %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
@ -723,20 +749,24 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer)); GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer));
{ {
GstElement *parent = gst_pad_get_real_parent (peer); GstElement *parent = gst_pad_get_parent (peer);
if (parent != GST_ELEMENT (decode_bin)) { if (parent != GST_ELEMENT (decode_bin)) {
GST_DEBUG_OBJECT (decode_bin, "dead end pad %s:%s", GST_DEBUG_OBJECT (decode_bin, "dead end pad %s:%s",
GST_DEBUG_PAD_NAME (peer)); GST_DEBUG_PAD_NAME (peer));
} else { } else {
GST_DEBUG_OBJECT (decode_bin, "recursing element %s on pad %s:%s", GST_DEBUG_OBJECT (decode_bin, "recursing element %s on pad %s:%s",
gst_element_get_name (elem), GST_DEBUG_PAD_NAME (pad)); GST_ELEMENT_NAME (elem), GST_DEBUG_PAD_NAME (pad));
remove_element_chain (decode_bin, peer); remove_element_chain (decode_bin, peer);
} }
gst_object_unref (GST_OBJECT_CAST (parent)); gst_object_unref (GST_OBJECT_CAST (parent));
} }
gst_object_unref (GST_OBJECT_CAST (peer));
} }
GST_DEBUG_OBJECT (decode_bin, "removing %s", gst_element_get_name (elem)); GST_DEBUG_OBJECT (decode_bin, "removing %s", GST_ELEMENT_NAME (elem));
g_list_free (int_links);
gst_bin_remove (GST_BIN (decode_bin), elem); gst_bin_remove (GST_BIN (decode_bin), elem);
} }
@ -768,7 +798,7 @@ no_more_pads (GstElement * element, GstDynamic * dynamic)
GstDecodeBin *decode_bin = dynamic->decode_bin; GstDecodeBin *decode_bin = dynamic->decode_bin;
GST_DEBUG_OBJECT (decode_bin, "no more pads on element %s", GST_DEBUG_OBJECT (decode_bin, "no more pads on element %s",
gst_element_get_name (element)); GST_ELEMENT_NAME (element));
/* remove the element from the list of dynamic elements */ /* remove the element from the list of dynamic elements */
decode_bin->dynamics = g_list_remove (decode_bin->dynamics, dynamic); decode_bin->dynamics = g_list_remove (decode_bin->dynamics, dynamic);
@ -793,7 +823,7 @@ unlinked (GstPad * pad, GstPad * peerpad, GstDecodeBin * decode_bin)
GstElement *element; GstElement *element;
/* inactivate pad */ /* inactivate pad */
gst_pad_set_active (pad, FALSE); gst_pad_set_active (pad, GST_ACTIVATE_NONE);
/* remove all elements linked to the peerpad */ /* remove all elements linked to the peerpad */
remove_element_chain (decode_bin, peerpad); remove_element_chain (decode_bin, peerpad);
@ -825,7 +855,7 @@ close_link (GstElement * element, GstDecodeBin * decode_bin)
gboolean more; gboolean more;
GST_DEBUG_OBJECT (decode_bin, "closing links with element %s", GST_DEBUG_OBJECT (decode_bin, "closing links with element %s",
gst_element_get_name (element)); GST_ELEMENT_NAME (element));
/* loop over all the padtemplates */ /* loop over all the padtemplates */
for (pads = GST_ELEMENT_GET_CLASS (element)->padtemplates; pads; for (pads = GST_ELEMENT_GET_CLASS (element)->padtemplates; pads;
@ -905,7 +935,7 @@ close_link (GstElement * element, GstDecodeBin * decode_bin)
/* now loop over all the pads we need to connect */ /* now loop over all the pads we need to connect */
for (pads = to_connect; pads; pads = g_list_next (pads)) { for (pads = to_connect; pads; pads = g_list_next (pads)) {
GstPad *pad = GST_PAD (pads->data); GstPad *pad = GST_PAD_CAST (pads->data);
GstCaps *caps; GstCaps *caps;
/* we have more pads if we have more than 1 pad to connect or /* we have more pads if we have more than 1 pad to connect or
@ -915,15 +945,16 @@ close_link (GstElement * element, GstDecodeBin * decode_bin)
more |= gst_decode_bin_is_dynamic (decode_bin); more |= gst_decode_bin_is_dynamic (decode_bin);
GST_DEBUG_OBJECT (decode_bin, "closing pad link for %s", GST_DEBUG_OBJECT (decode_bin, "closing pad link for %s",
gst_pad_get_name (pad)); GST_OBJECT_NAME (pad));
/* continue autoplugging on the pads */ /* continue autoplugging on the pads */
caps = gst_pad_get_caps (pad); caps = gst_pad_get_caps (pad);
close_pad_link (element, pad, caps, decode_bin, more); close_pad_link (element, pad, caps, decode_bin, more);
if (caps) if (caps)
gst_caps_unref (caps); gst_caps_unref (caps);
}
gst_object_unref (GST_OBJECT_CAST (pad));
}
g_list_free (to_connect); g_list_free (to_connect);
} }
@ -941,7 +972,7 @@ type_found (GstElement * typefind, guint probability, GstCaps * caps,
/* autoplug the new pad with the caps that the signal gave us. */ /* autoplug the new pad with the caps that the signal gave us. */
pad = gst_element_get_pad (typefind, "src"); pad = gst_element_get_pad (typefind, "src");
close_pad_link (typefind, pad, caps, decode_bin, FALSE); close_pad_link (typefind, pad, caps, decode_bin, FALSE);
gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT_CAST (pad));
dynamic = gst_decode_bin_is_dynamic (decode_bin); dynamic = gst_decode_bin_is_dynamic (decode_bin);
if (dynamic == FALSE) { if (dynamic == FALSE) {

View file

@ -202,9 +202,7 @@ gst_play_base_bin_dispose (GObject * object)
g_free (play_base_bin->suburi); g_free (play_base_bin->suburi);
play_base_bin->suburi = NULL; play_base_bin->suburi = NULL;
if (G_OBJECT_CLASS (parent_class)->dispose) { G_OBJECT_CLASS (parent_class)->dispose (object);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
} }
static void static void
@ -312,8 +310,7 @@ group_destroy (GstPlayBaseGroup * group)
fakesrc = (GstElement *) g_object_get_data (G_OBJECT (pad), "fakesrc"); fakesrc = (GstElement *) g_object_get_data (G_OBJECT (pad), "fakesrc");
if (fakesrc != NULL) { if (fakesrc != NULL) {
GST_LOG ("removing fakesrc from %s:%s", GST_LOG ("removing fakesrc from %s:%s",
gst_pad_get_name (pad), GST_PAD_NAME (pad), GST_ELEMENT_NAME (gst_pad_get_parent (pad)));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)));
gst_bin_remove (GST_BIN (play_base_bin), fakesrc); gst_bin_remove (GST_BIN (play_base_bin), fakesrc);
} }
} }
@ -321,7 +318,7 @@ group_destroy (GstPlayBaseGroup * group)
/* if the group is currently being played, we have to remove the element /* if the group is currently being played, we have to remove the element
* from the thread */ * from the thread */
if (get_active_group (play_base_bin) == group) { if (get_active_group (play_base_bin) == group) {
GST_LOG ("removing preroll element %s", gst_element_get_name (element)); GST_LOG ("removing preroll element %s", GST_ELEMENT_NAME (element));
gst_bin_remove (group->type[n].bin, element); gst_bin_remove (group->type[n].bin, element);
gst_bin_remove (group->type[n].bin, group->type[n].selector); gst_bin_remove (group->type[n].bin, group->type[n].selector);
} else { } else {
@ -388,7 +385,7 @@ group_commit (GstPlayBaseBin * play_base_bin, gboolean fatal, gboolean subtitle)
sig_id = sig_id =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (element), "signal_id")); GPOINTER_TO_INT (g_object_get_data (G_OBJECT (element), "signal_id"));
GST_LOG ("removing preroll signal %s", gst_element_get_name (element)); GST_LOG ("removing preroll signal %s", GST_ELEMENT_NAME (element));
g_signal_handler_disconnect (G_OBJECT (element), sig_id); g_signal_handler_disconnect (G_OBJECT (element), sig_id);
} }
} }
@ -469,7 +466,7 @@ check_queue (GstProbe * probe, GstMiniObject ** data, gpointer user_data)
static void static void
queue_overrun (GstElement * element, GstPlayBaseBin * play_base_bin) queue_overrun (GstElement * element, GstPlayBaseBin * play_base_bin)
{ {
GST_DEBUG ("queue %s overrun", gst_element_get_name (element)); GST_DEBUG ("queue %s overrun", GST_ELEMENT_NAME (element));
group_commit (play_base_bin, FALSE, FALSE); group_commit (play_base_bin, FALSE, FALSE);
@ -550,7 +547,7 @@ gen_preroll_element (GstPlayBaseBin * play_base_bin,
GstStreamInfo * info) GstStreamInfo * info)
{ {
GstElement *selector, *preroll; GstElement *selector, *preroll;
gchar *name; gchar *name, *padname;
const gchar *prename; const gchar *prename;
guint sig; guint sig;
GstPad *preroll_pad; GstPad *preroll_pad;
@ -566,20 +563,26 @@ gen_preroll_element (GstPlayBaseBin * play_base_bin,
g_return_if_reached (); g_return_if_reached ();
/* create stream selector */ /* create stream selector */
name = g_strdup_printf ("selector_%s_%s", prename, gst_pad_get_name (pad)); padname = gst_pad_get_name (pad);
name = g_strdup_printf ("selector_%s_%s", prename, padname);
selector = g_object_new (GST_TYPE_STREAM_SELECTOR, NULL); selector = g_object_new (GST_TYPE_STREAM_SELECTOR, NULL);
gst_object_set_name (GST_OBJECT (selector), name); gst_object_set_name (GST_OBJECT (selector), name);
g_free (name); g_free (name);
/* create preroll queue */ /* create preroll queue */
name = g_strdup_printf ("preroll_%s_%s", prename, gst_pad_get_name (pad)); name = g_strdup_printf ("preroll_%s_%s", prename, padname);
preroll = gst_element_factory_make ("queue", name); preroll = gst_element_factory_make ("queue", name);
g_free (padname);
g_free (name);
g_object_set (G_OBJECT (preroll), g_object_set (G_OBJECT (preroll),
"max-size-buffers", 0, "max-size-bytes", "max-size-buffers", 0, "max-size-bytes",
((type == GST_STREAM_TYPE_VIDEO) ? 25 : 1) * 1024 * 1024, ((type == GST_STREAM_TYPE_VIDEO) ? 25 : 1) * 1024 * 1024,
"max-size-time", play_base_bin->queue_size, NULL); "max-size-time", play_base_bin->queue_size, NULL);
sig = g_signal_connect (G_OBJECT (preroll), "overrun", sig = g_signal_connect (G_OBJECT (preroll), "overrun",
G_CALLBACK (queue_overrun), play_base_bin); G_CALLBACK (queue_overrun), play_base_bin);
if (play_base_bin->is_stream && if (play_base_bin->is_stream &&
((type == GST_STREAM_TYPE_VIDEO && ((type == GST_STREAM_TYPE_VIDEO &&
group->type[GST_STREAM_TYPE_AUDIO - 1].npads == 0) || group->type[GST_STREAM_TYPE_AUDIO - 1].npads == 0) ||
@ -609,34 +612,32 @@ gen_preroll_element (GstPlayBaseBin * play_base_bin,
/* keep a ref to the signal id so that we can disconnect the signal callback /* keep a ref to the signal id so that we can disconnect the signal callback
* when we are done with the preroll */ * when we are done with the preroll */
g_object_set_data (G_OBJECT (preroll), "signal_id", GINT_TO_POINTER (sig)); g_object_set_data (G_OBJECT (preroll), "signal_id", GINT_TO_POINTER (sig));
g_free (name);
/* listen for EOS */ /* listen for EOS */
preroll_pad = gst_element_get_pad (preroll, "src"); preroll_pad = gst_element_get_pad (preroll, "src");
probe = gst_probe_new (FALSE, probe_triggered, info); probe = gst_probe_new (FALSE, probe_triggered, info);
/* have to REALIZE the pad as we cannot attach a padprobe to a ghostpad */ /* have to REALIZE the pad as we cannot attach a padprobe to a ghostpad */
gst_pad_add_probe (preroll_pad, probe); gst_pad_add_probe (preroll_pad, probe);
gst_object_unref (GST_OBJECT_CAST (preroll_pad));
/* add to group list */ /* add to group list */
gst_element_link (selector, preroll); /* FIXME refcount elements */
group->type[type - 1].selector = selector; group->type[type - 1].selector = selector;
group->type[type - 1].preroll = preroll; group->type[type - 1].preroll = preroll;
if (type == GST_STREAM_TYPE_TEXT && play_base_bin->subtitle) { if (type == GST_STREAM_TYPE_TEXT && play_base_bin->subtitle) {
group->type[type - 1].bin = GST_BIN (play_base_bin->subtitle); group->type[type - 1].bin = GST_BIN (play_base_bin->subtitle);
gst_bin_add (GST_BIN (play_base_bin->subtitle), selector); gst_bin_add (GST_BIN (play_base_bin->subtitle), selector);
gst_bin_add (GST_BIN (play_base_bin->subtitle), preroll); gst_bin_add (GST_BIN (play_base_bin->subtitle), preroll);
gst_element_set_state (selector,
GST_STATE (play_base_bin) == GST_STATE_PLAYING ?
GST_STATE_PLAYING : GST_STATE_PAUSED);
} else { } else {
group->type[type - 1].bin = GST_BIN (play_base_bin); group->type[type - 1].bin = GST_BIN (play_base_bin);
gst_bin_add (GST_BIN (play_base_bin), selector); gst_bin_add (GST_BIN (play_base_bin), selector);
gst_bin_add (GST_BIN (play_base_bin), preroll); gst_bin_add (GST_BIN (play_base_bin), preroll);
gst_element_set_state (selector,
GST_STATE (play_base_bin) == GST_STATE_PLAYING ?
GST_STATE_PLAYING : GST_STATE_PAUSED);
} }
gst_element_link (selector, preroll);
gst_element_set_state (selector,
GST_STATE (play_base_bin) == GST_STATE_PLAYING ?
GST_STATE_PLAYING : GST_STATE_PAUSED);
gst_element_set_state (preroll, gst_element_set_state (preroll,
GST_STATE (play_base_bin) == GST_STATE_PLAYING ? GST_STATE (play_base_bin) == GST_STATE_PLAYING ?
GST_STATE_PLAYING : GST_STATE_PAUSED); GST_STATE_PLAYING : GST_STATE_PAUSED);
@ -754,7 +755,7 @@ no_more_pads (GstElement * element, GstPlayBaseBin * play_base_bin)
/* we can commit this group for playback now */ /* we can commit this group for playback now */
group_commit (play_base_bin, play_base_bin->is_stream, group_commit (play_base_bin, play_base_bin->is_stream,
gst_object_get_parent (GST_OBJECT (element)) == GST_OBJECT_PARENT (GST_OBJECT_CAST (element)) ==
GST_OBJECT (play_base_bin->subtitle)); GST_OBJECT (play_base_bin->subtitle));
} }
@ -848,6 +849,7 @@ preroll_unlinked (GstPad * pad, GstPad * peerpad,
{ {
GstElement *fakesrc; GstElement *fakesrc;
guint sig_id; guint sig_id;
GstPad *srcpad;
/* make a fakesrc that will just emit one EOS */ /* make a fakesrc that will just emit one EOS */
fakesrc = gst_element_factory_make ("fakesrc", NULL); fakesrc = gst_element_factory_make ("fakesrc", NULL);
@ -855,8 +857,10 @@ preroll_unlinked (GstPad * pad, GstPad * peerpad,
GST_DEBUG ("patching unlinked pad %s:%s", GST_DEBUG_PAD_NAME (pad)); GST_DEBUG ("patching unlinked pad %s:%s", GST_DEBUG_PAD_NAME (pad));
gst_pad_link (gst_element_get_pad (fakesrc, "src"), pad); srcpad = gst_element_get_pad (fakesrc, "src");
gst_bin_add (GST_BIN (play_base_bin), fakesrc); gst_bin_add (GST_BIN (play_base_bin), fakesrc);
gst_pad_link (srcpad, pad);
gst_object_unref (GST_OBJECT_CAST (srcpad));
/* keep track of these patch elements */ /* keep track of these patch elements */
g_object_set_data (G_OBJECT (pad), "fakesrc", fakesrc); g_object_set_data (G_OBJECT (pad), "fakesrc", fakesrc);
@ -879,7 +883,7 @@ mute_stream (GstProbe * probe, GstMiniObject ** d, gpointer data)
if (GST_IS_BUFFER (*d)) { if (GST_IS_BUFFER (*d)) {
g_object_set (G_OBJECT (info), "mute", TRUE, NULL); g_object_set (G_OBJECT (info), "mute", TRUE, NULL);
gst_pad_remove_probe ((GstPad *) GST_PAD_REALIZE (info->object), probe); gst_pad_remove_probe (GST_PAD_CAST (info->object), probe);
gst_probe_destroy (probe); gst_probe_destroy (probe);
} }
@ -911,18 +915,14 @@ new_decoded_pad (GstElement * element, GstPad * pad, gboolean last,
GstPlayBaseGroup *group; GstPlayBaseGroup *group;
GstProbe *probe; GstProbe *probe;
guint sig; guint sig;
GstObject *parent;
GST_DEBUG ("play base: new decoded pad %d", last); GST_DEBUG ("play base: new decoded pad %d", last);
/* first see if this pad has interesting caps */ /* first see if this pad has interesting caps */
caps = gst_pad_get_caps (pad); caps = gst_pad_get_caps (pad);
if (caps == NULL || gst_caps_is_empty (caps) || gst_caps_is_any (caps)) { if (caps == NULL || gst_caps_is_empty (caps) || gst_caps_is_any (caps))
g_warning ("no type on pad %s:%s", goto no_type;
GST_DEBUG_PAD_NAME (GST_PAD_REALIZE (pad)));
if (caps)
gst_caps_unref (caps);
return;
}
/* get the mime type */ /* get the mime type */
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
@ -934,19 +934,19 @@ new_decoded_pad (GstElement * element, GstPad * pad, gboolean last,
group->nstreams++; group->nstreams++;
parent = gst_object_get_parent (GST_OBJECT (element));
if (g_str_has_prefix (mimetype, "audio/") && if (g_str_has_prefix (mimetype, "audio/") &&
gst_object_get_parent (GST_OBJECT (element)) != parent != GST_OBJECT_CAST (play_base_bin->subtitle)) {
GST_OBJECT (play_base_bin->subtitle)) {
type = GST_STREAM_TYPE_AUDIO; type = GST_STREAM_TYPE_AUDIO;
} else if (g_str_has_prefix (mimetype, "video/") && } else if (g_str_has_prefix (mimetype, "video/") &&
gst_object_get_parent (GST_OBJECT (element)) != parent != GST_OBJECT_CAST (play_base_bin->subtitle)) {
GST_OBJECT (play_base_bin->subtitle)) {
type = GST_STREAM_TYPE_VIDEO; type = GST_STREAM_TYPE_VIDEO;
} else if (g_str_has_prefix (mimetype, "text/")) { } else if (g_str_has_prefix (mimetype, "text/")) {
type = GST_STREAM_TYPE_TEXT; type = GST_STREAM_TYPE_TEXT;
} else { } else {
type = GST_STREAM_TYPE_UNKNOWN; type = GST_STREAM_TYPE_UNKNOWN;
} }
gst_object_unref (parent);
info = gst_stream_info_new (GST_OBJECT (pad), type, NULL, caps); info = gst_stream_info_new (GST_OBJECT (pad), type, NULL, caps);
if (type > 0 && type <= NUM_TYPES) { if (type > 0 && type <= NUM_TYPES) {
@ -974,7 +974,7 @@ new_decoded_pad (GstElement * element, GstPad * pad, gboolean last,
/* select 1st for now - we'll select a preferred one after preroll */ /* select 1st for now - we'll select a preferred one after preroll */
if (type == GST_STREAM_TYPE_UNKNOWN || group->type[type - 1].npads > 0) { if (type == GST_STREAM_TYPE_UNKNOWN || group->type[type - 1].npads > 0) {
probe = gst_probe_new (FALSE, silence_stream, info); probe = gst_probe_new (FALSE, silence_stream, info);
gst_pad_add_probe (GST_PAD_REALIZE (pad), probe); gst_pad_add_probe (GST_PAD_CAST (pad), probe);
g_object_set_data (G_OBJECT (pad), "eat_probe", probe); g_object_set_data (G_OBJECT (pad), "eat_probe", probe);
} }
@ -985,6 +985,16 @@ new_decoded_pad (GstElement * element, GstPad * pad, gboolean last,
/* signal the no more pads after adding the stream */ /* signal the no more pads after adding the stream */
if (last) if (last)
no_more_pads (element, play_base_bin); no_more_pads (element, play_base_bin);
return;
no_type:
{
g_warning ("no type on pad %s:%s", GST_DEBUG_PAD_NAME (pad));
if (caps)
gst_caps_unref (caps);
return;
}
} }
@ -1066,7 +1076,7 @@ setup_substreams (GstPlayBaseBin * play_base_bin)
probe = g_object_get_data (G_OBJECT (info->object), "eat_probe"); probe = g_object_get_data (G_OBJECT (info->object), "eat_probe");
if (probe) { if (probe) {
gst_pad_remove_probe (GST_PAD_REALIZE (info->object), probe); gst_pad_remove_probe (GST_PAD_CAST (info->object), probe);
gst_probe_destroy (probe); gst_probe_destroy (probe);
} }
@ -1075,7 +1085,7 @@ setup_substreams (GstPlayBaseBin * play_base_bin)
GstProbe *probe; GstProbe *probe;
probe = gst_probe_new (FALSE, mute_stream, info); probe = gst_probe_new (FALSE, mute_stream, info);
gst_pad_add_probe (GST_PAD_REALIZE (info->object), probe); gst_pad_add_probe (GST_PAD_CAST (info->object), probe);
} }
} }
@ -1115,24 +1125,12 @@ setup_source (GstPlayBaseBin * play_base_bin,
} }
/* create and configure an element that can handle the uri */ /* create and configure an element that can handle the uri */
play_base_bin->source = gen_source_element (play_base_bin, &subbin); if (!(play_base_bin->source = gen_source_element (play_base_bin, &subbin)))
if (!play_base_bin->source) { goto no_source;
gchar *prot;
/* whoops, could not create the source element */
prot = gst_uri_get_protocol (play_base_bin->uri);
if (prot) {
g_set_error (error, 0, 0, "No URI handler implemented for \"%s\"", prot);
g_free (prot);
} else {
g_set_error (error, 0, 0, "Invalid URI \"%s\"", play_base_bin->uri);
}
GST_WARNING ("don't know how to read %s", play_base_bin->uri);
return FALSE;
}
gst_bin_add (GST_BIN (play_base_bin), play_base_bin->source); gst_bin_add (GST_BIN (play_base_bin), play_base_bin->source);
g_object_notify (G_OBJECT (play_base_bin), "source"); g_object_notify (G_OBJECT (play_base_bin), "source");
/* state will be merged later - if file is not found, error will be /* state will be merged later - if file is not found, error will be
* handled by the application right after. */ * handled by the application right after. */
@ -1274,18 +1272,14 @@ setup_source (GstPlayBaseBin * play_base_bin,
} }
/* now create the decoder element */ /* now create the decoder element */
play_base_bin->decoder = gst_element_factory_make ("decodebin", "decoder"); if (!(play_base_bin->decoder =
if (!play_base_bin->decoder) { gst_element_factory_make ("decodebin", "decoder")))
g_set_error (error, 0, 0, "Could not create autoplugger element"); goto no_decodebin;
GST_WARNING ("can't find decoder element");
return FALSE;
}
gst_bin_add (GST_BIN (play_base_bin), play_base_bin->decoder); gst_bin_add (GST_BIN (play_base_bin), play_base_bin->decoder);
if (!gst_element_link (play_base_bin->source, play_base_bin->decoder)) {
g_set_error (error, 0, 0, "Could not link source and autoplugger"); if (!gst_element_link (play_base_bin->source, play_base_bin->decoder))
GST_WARNING ("can't link source to decoder element"); goto could_not_link;
return FALSE;
}
/* set up callbacks to create the links between decoded data /* set up callbacks to create the links between decoded data
* and video/audio/subtitle rendering/output. */ * and video/audio/subtitle rendering/output. */
@ -1299,6 +1293,35 @@ setup_source (GstPlayBaseBin * play_base_bin,
play_base_bin->need_rebuild = FALSE; play_base_bin->need_rebuild = FALSE;
return TRUE; return TRUE;
/* ERRORS */
no_source:
{
gchar *prot;
/* whoops, could not create the source element */
prot = gst_uri_get_protocol (play_base_bin->uri);
if (prot) {
g_set_error (error, 0, 0, "No URI handler implemented for \"%s\"", prot);
g_free (prot);
} else {
g_set_error (error, 0, 0, "Invalid URI \"%s\"", play_base_bin->uri);
}
GST_WARNING ("don't know how to read %s", play_base_bin->uri);
return FALSE;
}
no_decodebin:
{
g_set_error (error, 0, 0, "Could not create autoplugger element");
GST_WARNING ("can't find decoder element");
return FALSE;
}
could_not_link:
{
g_set_error (error, 0, 0, "Could not link source and autoplugger");
GST_WARNING ("can't link source to decoder element");
return FALSE;
}
} }
static void static void
@ -1408,13 +1431,17 @@ static void
mute_group_type (GstPlayBaseGroup * group, GstStreamType type, gboolean mute) mute_group_type (GstPlayBaseGroup * group, GstStreamType type, gboolean mute)
{ {
gboolean active = !mute; gboolean active = !mute;
GstPad *pad;
gst_pad_set_active (gst_element_get_pad (group->type[type - 1].preroll, pad = gst_element_get_pad (group->type[type - 1].preroll, "src");
"src"), active); gst_pad_set_active (pad, active);
gst_pad_set_active (gst_element_get_pad (group->type[type - 1].preroll, gst_object_unref (GST_OBJECT_CAST (pad));
"sink"), active); pad = gst_element_get_pad (group->type[type - 1].preroll, "sink");
gst_pad_set_active (gst_element_get_pad (group->type[type - 1].selector, gst_pad_set_active (pad, active);
"src"), active); gst_object_unref (GST_OBJECT_CAST (pad));
pad = gst_element_get_pad (group->type[type - 1].selector, "src");
gst_pad_set_active (pad, active);
gst_object_unref (GST_OBJECT_CAST (pad));
if (mute) { if (mute) {
g_signal_connect (group->type[type - 1].preroll, "state-change", g_signal_connect (group->type[type - 1].preroll, "state-change",
@ -1477,7 +1504,7 @@ set_active_source (GstPlayBaseBin * play_base_bin,
GstProbe *probe; GstProbe *probe;
probe = gst_probe_new (FALSE, mute_stream, info); probe = gst_probe_new (FALSE, mute_stream, info);
gst_pad_add_probe (GST_PAD_REALIZE (info->object), probe); gst_pad_add_probe (GST_PAD_CAST (info->object), probe);
} }
num++; num++;
} }
@ -1632,44 +1659,24 @@ gst_play_base_bin_get_property (GObject * object, guint prop_id, GValue * value,
static GstElementStateReturn static GstElementStateReturn
gst_play_base_bin_change_state (GstElement * element) gst_play_base_bin_change_state (GstElement * element)
{ {
GstElementStateReturn ret = GST_STATE_SUCCESS; GstElementStateReturn ret;
GstPlayBaseBin *play_base_bin; GstPlayBaseBin *play_base_bin;
gint transition = GST_STATE_TRANSITION (element); gint transition = GST_STATE_TRANSITION (element);
gchar *new_location = NULL; gchar *new_location = NULL;
GError *error = NULL;
play_base_bin = GST_PLAY_BASE_BIN (element); play_base_bin = GST_PLAY_BASE_BIN (element);
switch (transition) { switch (transition) {
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
{ if (!setup_source (play_base_bin, &new_location, &error) || error != NULL)
GError *error = NULL; goto source_failed;
if (!setup_source (play_base_bin, &new_location, &error) || error != NULL) {
if (!error) {
/* opening failed but no error - hellup */
GST_ELEMENT_ERROR (GST_ELEMENT (play_base_bin), STREAM,
NOT_IMPLEMENTED,
("cannot open file \"%s\"", play_base_bin->uri), (NULL));
} else {
/* just copy the cached error - type doesn't matter */
GST_ELEMENT_ERROR (play_base_bin, STREAM, TOO_LAZY,
(error->message), (NULL));
g_error_free (error);
}
ret = GST_STATE_FAILURE;
play_base_bin->need_rebuild = TRUE;
}
break; break;
}
default: default:
break; break;
} }
if (ret != GST_STATE_SUCCESS) { ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
return ret;
} else {
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
}
switch (transition) { switch (transition) {
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
@ -1688,8 +1695,26 @@ gst_play_base_bin_change_state (GstElement * element)
default: default:
break; break;
} }
return ret; return ret;
/* ERRORS */
source_failed:
{
if (!error) {
/* opening failed but no error - hellup */
GST_ELEMENT_ERROR (GST_ELEMENT (play_base_bin), STREAM,
NOT_IMPLEMENTED,
("cannot open file \"%s\"", play_base_bin->uri), (NULL));
} else {
/* just copy the cached error - type doesn't matter */
GST_ELEMENT_ERROR (play_base_bin, STREAM, TOO_LAZY,
(error->message), (NULL));
g_error_free (error);
}
play_base_bin->need_rebuild = TRUE;
return GST_STATE_FAILURE;
}
} }
const GList * const GList *

View file

@ -237,9 +237,7 @@ gst_play_bin_dispose (GObject * object)
g_free (play_bin->font_desc); g_free (play_bin->font_desc);
play_bin->font_desc = NULL; play_bin->font_desc = NULL;
if (G_OBJECT_CLASS (parent_class)->dispose) { G_OBJECT_CLASS (parent_class)->dispose (object);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
} }
@ -410,7 +408,7 @@ gen_video_element (GstPlayBin * play_bin)
pad = gst_element_get_pad (identity, "sink"); pad = gst_element_get_pad (identity, "sink");
gst_element_add_ghost_pad (element, pad, "sink"); gst_element_add_ghost_pad (element, pad, "sink");
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
gst_element_set_state (element, GST_STATE_READY); gst_element_set_state (element, GST_STATE_READY);
@ -460,11 +458,11 @@ gen_text_element (GstPlayBin * play_bin)
pad = gst_element_get_pad (overlay, "text_sink"); pad = gst_element_get_pad (overlay, "text_sink");
gst_element_add_ghost_pad (element, pad, "text_sink"); gst_element_add_ghost_pad (element, pad, "text_sink");
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
pad = gst_element_get_pad (csp, "sink"); pad = gst_element_get_pad (csp, "sink");
gst_element_add_ghost_pad (element, pad, "sink"); gst_element_add_ghost_pad (element, pad, "sink");
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
return element; return element;
} }
@ -525,7 +523,7 @@ gen_audio_element (GstPlayBin * play_bin)
pad = gst_element_get_pad (conv, "sink"); pad = gst_element_get_pad (conv, "sink");
gst_element_add_ghost_pad (element, pad, "sink"); gst_element_add_ghost_pad (element, pad, "sink");
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
gst_element_set_state (element, GST_STATE_READY); gst_element_set_state (element, GST_STATE_READY);
@ -606,19 +604,19 @@ gen_vis_element (GstPlayBin * play_bin)
pad = gst_element_get_pad (aqueue, "sink"); pad = gst_element_get_pad (aqueue, "sink");
rpad = gst_element_get_request_pad (tee, "src%d"); rpad = gst_element_get_request_pad (tee, "src%d");
gst_pad_link (rpad, pad); gst_pad_link (rpad, pad);
g_object_unref (G_OBJECT (rpad)); gst_object_unref (GST_OBJECT (rpad));
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
gst_element_link_pads (aqueue, "src", asink, "sink"); gst_element_link_pads (aqueue, "src", asink, "sink");
pad = gst_element_get_pad (conv, "sink"); pad = gst_element_get_pad (conv, "sink");
rpad = gst_element_get_request_pad (tee, "src%d"); rpad = gst_element_get_request_pad (tee, "src%d");
gst_pad_link (rpad, pad); gst_pad_link (rpad, pad);
g_object_unref (G_OBJECT (rpad)); gst_object_unref (GST_OBJECT (rpad));
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
pad = gst_element_get_pad (tee, "sink"); pad = gst_element_get_pad (tee, "sink");
gst_element_add_ghost_pad (element, pad, "sink"); gst_element_add_ghost_pad (element, pad, "sink");
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
return element; return element;
} }
@ -639,27 +637,37 @@ remove_sinks (GstPlayBin * play_bin)
/* we remove the element from the parent so that /* we remove the element from the parent so that
* there is no unwanted state change when the parent * there is no unwanted state change when the parent
* is disposed */ * is disposed */
play_bin->sinks = g_list_remove (play_bin->sinks, element);
gst_bin_remove (GST_BIN (parent), element); gst_bin_remove (GST_BIN (parent), element);
g_object_unref (G_OBJECT (parent)); gst_object_unref (GST_OBJECT (parent));
} }
} }
element = g_hash_table_lookup (play_bin->cache, "vbin"); element = g_hash_table_lookup (play_bin->cache, "vbin");
if (element != NULL) { if (element != NULL) {
parent = gst_element_get_parent (element); parent = gst_element_get_parent (element);
if (parent != NULL) { if (parent != NULL) {
play_bin->sinks = g_list_remove (play_bin->sinks, element);
gst_bin_remove (GST_BIN (parent), element); gst_bin_remove (GST_BIN (parent), element);
g_object_unref (G_OBJECT (parent)); gst_object_unref (GST_OBJECT (parent));
} }
} }
for (sinks = play_bin->sinks; sinks; sinks = g_list_next (sinks)) { for (sinks = play_bin->sinks; sinks; sinks = g_list_next (sinks)) {
GstElement *element = GST_ELEMENT (sinks->data); GstElement *element = GST_ELEMENT (sinks->data);
GstPad *pad = gst_element_get_pad (element, "sink"); GstPad *pad;
GstPad *peer;
pad = gst_element_get_pad (element, "sink");
GST_LOG ("removing sink %p", element); GST_LOG ("removing sink %p", element);
if (GST_PAD_PEER (pad))
gst_pad_unlink (GST_PAD_PEER (pad), pad); peer = gst_pad_get_peer (pad);
g_object_unref (G_OBJECT (pad)); if (peer) {
gst_pad_unlink (peer, pad);
gst_object_unref (GST_OBJECT (peer));
}
gst_object_unref (GST_OBJECT (pad));
gst_bin_remove (GST_BIN (play_bin), element); gst_bin_remove (GST_BIN (play_bin), element);
} }
g_list_free (play_bin->sinks); g_list_free (play_bin->sinks);
@ -694,12 +702,12 @@ add_sink (GstPlayBin * play_bin, GstElement * sink, GstPad * srcpad)
/* we found a sink for this stream, now try to install it */ /* we found a sink for this stream, now try to install it */
sinkpad = gst_element_get_pad (sink, "sink"); sinkpad = gst_element_get_pad (sink, "sink");
res = gst_pad_link (srcpad, sinkpad); res = gst_pad_link (srcpad, sinkpad);
g_object_unref (G_OBJECT (sinkpad)); gst_object_unref (GST_OBJECT (sinkpad));
parent = gst_pad_get_parent (srcpad); parent = gst_pad_get_parent (srcpad);
GST_DEBUG ("Adding sink with state %d (parent: %d, peer: %d)\n", GST_DEBUG ("Adding sink with state %d (parent: %d, peer: %d)\n",
GST_STATE (sink), GST_STATE (play_bin), GST_STATE (parent)); GST_STATE (sink), GST_STATE (play_bin), GST_STATE (parent));
g_object_unref (G_OBJECT (parent)); gst_object_unref (GST_OBJECT (parent));
/* try to link the pad of the sink to the stream */ /* try to link the pad of the sink to the stream */
if (res < 0) { if (res < 0) {
@ -770,7 +778,7 @@ setup_sinks (GstPlayBaseBin * play_base_bin, GstPlayBaseGroup * group)
pad = gst_element_get_pad (group->type[GST_STREAM_TYPE_AUDIO - 1].preroll, pad = gst_element_get_pad (group->type[GST_STREAM_TYPE_AUDIO - 1].preroll,
"src"); "src");
add_sink (play_bin, sink, pad); add_sink (play_bin, sink, pad);
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
} }
/* link video */ /* link video */
@ -783,15 +791,15 @@ setup_sinks (GstPlayBaseBin * play_base_bin, GstPlayBaseGroup * group)
gst_element_get_pad (group->type[GST_STREAM_TYPE_TEXT - 1].preroll, gst_element_get_pad (group->type[GST_STREAM_TYPE_TEXT - 1].preroll,
"src"); "src");
gst_pad_link (textsrcpad, textsinkpad); gst_pad_link (textsrcpad, textsinkpad);
g_object_unref (G_OBJECT (textsinkpad)); gst_object_unref (GST_OBJECT (textsinkpad));
g_object_unref (G_OBJECT (textsrcpad)); gst_object_unref (GST_OBJECT (textsrcpad));
} else { } else {
sink = gen_video_element (play_bin); sink = gen_video_element (play_bin);
} }
pad = gst_element_get_pad (group->type[GST_STREAM_TYPE_VIDEO - 1].preroll, pad = gst_element_get_pad (group->type[GST_STREAM_TYPE_VIDEO - 1].preroll,
"src"); "src");
add_sink (play_bin, sink, pad); add_sink (play_bin, sink, pad);
g_object_unref (G_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad));
} }
if (play_bin->fakesink) { if (play_bin->fakesink) {

View file

@ -219,7 +219,7 @@ gst_stream_info_new (GstObject * object,
GstProbe *probe; GstProbe *probe;
probe = gst_probe_new (FALSE, cb_probe, info); probe = gst_probe_new (FALSE, cb_probe, info);
gst_pad_add_probe (GST_PAD_REALIZE (object), probe); gst_pad_add_probe (GST_PAD_CAST (object), probe);
} }
info->object = object; info->object = object;
info->type = type; info->type = type;
@ -243,7 +243,7 @@ gst_stream_info_dispose (GObject * object)
GstElement *parent; GstElement *parent;
parent = gst_pad_get_parent ((GstPad *) parent = gst_pad_get_parent ((GstPad *)
GST_PAD_REALIZE (stream_info->object)); GST_PAD_CAST (stream_info->object));
if (parent != NULL) { if (parent != NULL) {
g_signal_handlers_disconnect_by_func (parent, g_signal_handlers_disconnect_by_func (parent,
G_CALLBACK (stream_info_change_state), stream_info); G_CALLBACK (stream_info_change_state), stream_info);
@ -301,11 +301,11 @@ gst_stream_info_set_mute (GstStreamInfo * stream_info, gboolean mute)
stream_info->mute = mute; stream_info->mute = mute;
//gst_pad_set_active_recursive ((GstPad *) //gst_pad_set_active_recursive ((GstPad *)
//GST_PAD_REALIZE (stream_info->object), !mute); //GST_PAD_CAST (stream_info->object), !mute);
g_warning ("FIXME"); g_warning ("FIXME");
element = gst_pad_get_parent ((GstPad *) element = gst_pad_get_parent ((GstPad *)
GST_PAD_REALIZE (stream_info->object)); GST_PAD_CAST (stream_info->object));
if (mute) { if (mute) {
g_signal_connect (element, "state-change", g_signal_connect (element, "state-change",
G_CALLBACK (stream_info_change_state), stream_info); G_CALLBACK (stream_info_change_state), stream_info);

View file

@ -238,8 +238,6 @@ gst_stream_selector_chain (GstPad * pad, GstBuffer * buf)
GstStreamSelector *sel = GST_STREAM_SELECTOR (gst_pad_get_parent (pad)); GstStreamSelector *sel = GST_STREAM_SELECTOR (gst_pad_get_parent (pad));
GstFlowReturn res; GstFlowReturn res;
GST_STREAM_LOCK (pad);
/* first, check if the active pad changed. If so, redo /* first, check if the active pad changed. If so, redo
* negotiation and fail if that fails. */ * negotiation and fail if that fails. */
if (pad != sel->last_active_sinkpad) { if (pad != sel->last_active_sinkpad) {
@ -255,7 +253,5 @@ gst_stream_selector_chain (GstPad * pad, GstBuffer * buf)
"buf", gst_pad_get_name (pad)); "buf", gst_pad_get_name (pad));
res = gst_pad_push (sel->srcpad, buf); res = gst_pad_push (sel->srcpad, buf);
GST_STREAM_UNLOCK (pad);
return res; return res;
} }