mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
tagdemux: also read tags if downstream activates us in pull mode right away
Fix reading of tags for the case filsrc ! footagdemux ! fooparse ! .. where we would not read the tags because we never start our own streaming thread. https://bugzilla.gnome.org/show_bug.cgi?id=673185
This commit is contained in:
parent
899a809330
commit
ec27f4e13c
1 changed files with 28 additions and 3 deletions
|
@ -1153,14 +1153,17 @@ gst_tag_demux_element_find (GstTagDemux * demux)
|
|||
demux->priv->strip_start + demux->priv->strip_end)
|
||||
goto no_data;
|
||||
|
||||
/* 2 - Do typefinding on data */
|
||||
/* 2 - Do typefinding on data, but not if downstream is in charge */
|
||||
if (GST_PAD_MODE (demux->priv->srcpad) == GST_PAD_MODE_PULL)
|
||||
goto skip_typefinding;
|
||||
|
||||
caps = gst_type_find_helper_get_range (GST_OBJECT (demux), NULL,
|
||||
(GstTypeFindHelperGetRangeFunction) gst_tag_demux_read_range,
|
||||
demux->priv->upstream_size
|
||||
- (demux->priv->strip_start + demux->priv->strip_end), NULL,
|
||||
&probability);
|
||||
|
||||
GST_DEBUG_OBJECT (demux, "Found type %" GST_PTR_FORMAT " with a "
|
||||
GST_INFO_OBJECT (demux, "Found type %" GST_PTR_FORMAT " with a "
|
||||
"probability of %u", caps, probability);
|
||||
|
||||
/* 3 - If we didn't find the caps, fail */
|
||||
|
@ -1175,6 +1178,11 @@ gst_tag_demux_element_find (GstTagDemux * demux)
|
|||
gst_tag_demux_set_src_caps (demux, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
skip_typefinding:
|
||||
|
||||
/* set it again, in case we skipped typefinding */
|
||||
demux->priv->state = GST_TAG_DEMUX_STREAMING;
|
||||
|
||||
return ret;
|
||||
|
||||
/* ERRORS */
|
||||
|
@ -1321,6 +1329,10 @@ gst_tag_demux_sink_activate_mode (GstPad * pad, GstObject * parent,
|
|||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (active)
|
||||
GST_TAG_DEMUX (parent)->priv->state = GST_TAG_DEMUX_READ_START_TAG;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1364,7 +1376,6 @@ activate_push:
|
|||
{
|
||||
GST_DEBUG_OBJECT (demux, "No pull mode. Changing to push, but won't be "
|
||||
"able to read end tags");
|
||||
demux->priv->state = GST_TAG_DEMUX_READ_START_TAG;
|
||||
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
|
||||
}
|
||||
}
|
||||
|
@ -1489,6 +1500,7 @@ gst_tag_demux_pad_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
gint64 result;
|
||||
gboolean res = TRUE;
|
||||
|
||||
/* FIXME: locking ? */
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_SCHEDULING:
|
||||
res = gst_pad_peer_query (demux->priv->sinkpad, query);
|
||||
|
@ -1512,7 +1524,20 @@ gst_tag_demux_pad_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
|
||||
gst_query_parse_duration (query, &format, &result);
|
||||
if (format == GST_FORMAT_BYTES) {
|
||||
/* if downstream activated us in pull mode right away, e.g. in case of
|
||||
* filesrc ! id3demux ! xyzparse ! .., read tags here, since we don't
|
||||
* have a streaming thread of our own to do that. We do it here and
|
||||
* not in get_range(), so we can return the right size in bytes.. */
|
||||
if (demux->priv->state == GST_TAG_DEMUX_READ_START_TAG &&
|
||||
GST_PAD_MODE (demux->priv->srcpad) == GST_PAD_MODE_PULL) {
|
||||
GstFlowReturn flow G_GNUC_UNUSED;
|
||||
|
||||
flow = gst_tag_demux_element_find (demux);
|
||||
GST_INFO_OBJECT (demux, "pulled tags: %s", gst_flow_get_name (flow));
|
||||
}
|
||||
result -= demux->priv->strip_start + demux->priv->strip_end;
|
||||
if (result < 0)
|
||||
result = 0;
|
||||
gst_query_set_duration (query, format, result);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue