playbin: Ensure that everything in a GstSourceGroup gets the same group-id

Including streams from external subtitle files. If not everything implements
the group-ids playbin invents its own.
This commit is contained in:
Sebastian Dröge 2013-07-23 12:40:57 +02:00
parent 94fc577dd5
commit f92da706fd

View file

@ -340,6 +340,9 @@ struct _GstSourceGroup
gint pending; gint pending;
gboolean sub_pending; gboolean sub_pending;
gboolean have_group_id;
guint group_id;
gulong pad_added_id; gulong pad_added_id;
gulong pad_removed_id; gulong pad_removed_id;
gulong no_more_pads_id; gulong no_more_pads_id;
@ -2844,31 +2847,72 @@ notify:
} }
static GstPadProbeReturn static GstPadProbeReturn
_suburidecodebin_event_probe (GstPad * pad, GstPadProbeInfo * info, _uridecodebin_event_probe (GstPad * pad, GstPadProbeInfo * info, gpointer udata)
gpointer udata)
{ {
GstPadProbeReturn ret = GST_PAD_PROBE_OK; GstPadProbeReturn ret = GST_PAD_PROBE_OK;
GstSourceGroup *group = udata; GstSourceGroup *group = udata;
GstEvent *event = GST_PAD_PROBE_INFO_DATA (info); GstEvent *event = GST_PAD_PROBE_INFO_DATA (info);
gboolean suburidecodebin = (GST_PAD_PARENT (pad) == group->suburidecodebin);
switch (GST_EVENT_TYPE (event)) { if (suburidecodebin) {
case GST_EVENT_FLUSH_START: /* Drop flushes that we caused from the suburidecodebin */
case GST_EVENT_FLUSH_STOP: switch (GST_EVENT_TYPE (event)) {
{ case GST_EVENT_FLUSH_START:
guint32 seqnum = gst_event_get_seqnum (event); case GST_EVENT_FLUSH_STOP:
GSList *item = g_slist_find (group->suburi_flushes_to_drop, {
GUINT_TO_POINTER (seqnum)); guint32 seqnum = gst_event_get_seqnum (event);
if (item) { GSList *item = g_slist_find (group->suburi_flushes_to_drop,
ret = GST_PAD_PROBE_DROP; /* this is from subtitle seek only, drop it */ GUINT_TO_POINTER (seqnum));
if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP) { if (item) {
group->suburi_flushes_to_drop = if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP) {
g_slist_delete_link (group->suburi_flushes_to_drop, item); group->suburi_flushes_to_drop =
g_slist_delete_link (group->suburi_flushes_to_drop, item);
}
} }
} }
default:
break;
}
}
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_STREAM_START:{
guint group_id;
GST_SOURCE_GROUP_LOCK (group);
if (gst_event_parse_group_id (event, &group_id)) {
if (group->have_group_id) {
if (group->group_id != group_id) {
event = gst_event_copy (event);
gst_event_set_group_id (event, group->group_id);
gst_event_replace ((GstEvent **) & info->data, event);
gst_event_unref (event);
}
} else {
group->group_id = group_id;
group->have_group_id = TRUE;
}
} else {
GST_FIXME_OBJECT (pad,
"Consider implementing group-id handling on stream-start event");
if (!group->have_group_id) {
group->group_id = gst_util_group_id_next ();
group->have_group_id = TRUE;
}
event = gst_event_copy (event);
gst_event_set_group_id (event, group->group_id);
gst_event_replace ((GstEvent **) & info->data, event);
gst_event_unref (event);
}
GST_SOURCE_GROUP_UNLOCK (group);
break;
} }
default: default:
break; break;
} }
return ret; return ret;
} }
@ -2942,6 +2986,7 @@ pad_added_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group)
gint i, pass; gint i, pass;
gboolean changed = FALSE; gboolean changed = FALSE;
GstElement *custom_combiner = NULL; GstElement *custom_combiner = NULL;
gulong group_id_probe_handler;
playbin = group->playbin; playbin = group->playbin;
@ -3116,12 +3161,11 @@ pad_added_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group)
} }
GST_SOURCE_GROUP_UNLOCK (group); GST_SOURCE_GROUP_UNLOCK (group);
if (decodebin == group->suburidecodebin) { group_id_probe_handler =
/* TODO store the probe id */ gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
/* to avoid propagating flushes from suburi specific seeks */ _uridecodebin_event_probe, group, NULL);
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, g_object_set_data (G_OBJECT (pad), "playbin.event_probe_id",
_suburidecodebin_event_probe, group, NULL); (gpointer) group_id_probe_handler);
}
if (changed) { if (changed) {
int signal; int signal;
@ -3193,6 +3237,7 @@ pad_removed_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group)
GstElement *combiner; GstElement *combiner;
GstSourceCombine *combine; GstSourceCombine *combine;
int signal = -1; int signal = -1;
gulong group_id_probe_handler;
playbin = group->playbin; playbin = group->playbin;
@ -3201,6 +3246,13 @@ pad_removed_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group)
GST_SOURCE_GROUP_LOCK (group); GST_SOURCE_GROUP_LOCK (group);
if ((group_id_probe_handler =
(guintptr) g_object_get_data (G_OBJECT (pad),
"playbin.event_probe_id"))) {
gst_pad_remove_probe (pad, group_id_probe_handler);
g_object_set_data (G_OBJECT (pad), "playbin.event_probe_id", 0);
}
if ((combine = g_object_get_data (G_OBJECT (pad), "playbin.combine"))) { if ((combine = g_object_get_data (G_OBJECT (pad), "playbin.combine"))) {
g_assert (combine->combiner == NULL); g_assert (combine->combiner == NULL);
g_assert (combine->srcpad == pad); g_assert (combine->srcpad == pad);
@ -5140,6 +5192,8 @@ deactivate_group (GstPlayBin * playbin, GstSourceGroup * group)
gst_bin_remove (GST_BIN_CAST (playbin), group->suburidecodebin); gst_bin_remove (GST_BIN_CAST (playbin), group->suburidecodebin);
} }
group->have_group_id = FALSE;
GST_SOURCE_GROUP_UNLOCK (group); GST_SOURCE_GROUP_UNLOCK (group);
return TRUE; return TRUE;