diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2009-03-31 16:07:46 +0200 |
---|---|---|
committer | Dave Robillard <dave@drobilla.net> | 2009-05-03 12:03:13 -0400 |
commit | c6ca9781affed8dcec987f409a65a903f2663958 (patch) | |
tree | ffb191c875c77cee9aca472a92567eeff2630dc0 /gst/aacparse | |
parent | 89fe9fcc9d1b726c520c5d39b18b5f718e5d5d15 (diff) | |
download | gst-plugins-bad-c6ca9781affed8dcec987f409a65a903f2663958.tar.gz gst-plugins-bad-c6ca9781affed8dcec987f409a65a903f2663958.tar.bz2 gst-plugins-bad-c6ca9781affed8dcec987f409a65a903f2663958.zip |
baseparse: Delay newsegment as long as possible.
If newsegment is sent (too) early, caps may not yet be fixed/set,
and downstream may not have been linked.
Diffstat (limited to 'gst/aacparse')
-rw-r--r-- | gst/aacparse/gstbaseparse.c | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/gst/aacparse/gstbaseparse.c b/gst/aacparse/gstbaseparse.c index 6d0e7f8d..4940a8e4 100644 --- a/gst/aacparse/gstbaseparse.c +++ b/gst/aacparse/gstbaseparse.c @@ -748,8 +748,42 @@ gst_base_parse_handle_and_push_buffer (GstBaseParse * parse, if (last_stop != GST_CLOCK_TIME_NONE && GST_BUFFER_DURATION_IS_VALID (buffer)) last_stop += GST_BUFFER_DURATION (buffer); + /* should have caps by now */ + g_return_val_if_fail (GST_PAD_CAPS (parse->srcpad), GST_FLOW_ERROR); + gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad)); + /* and should then also be linked downstream, so safe to send some events */ + if (parse->priv->pad_mode == GST_ACTIVATE_PULL) { + if (G_UNLIKELY (parse->close_segment)) { + GST_DEBUG_OBJECT (parse, "loop sending close segment"); + gst_pad_push_event (parse->srcpad, parse->close_segment); + parse->close_segment = NULL; + } + + if (G_UNLIKELY (parse->pending_segment)) { + GST_DEBUG_OBJECT (parse, "loop push pending segment"); + gst_pad_push_event (parse->srcpad, parse->pending_segment); + parse->pending_segment = NULL; + } + } else { + if (G_UNLIKELY (parse->pending_segment)) { + GST_DEBUG_OBJECT (parse, "chain pushing a pending segment"); + gst_pad_push_event (parse->srcpad, parse->pending_segment); + parse->pending_segment = NULL; + } + } + + if (G_UNLIKELY (parse->priv->pending_events)) { + GList *l; + + for (l = parse->priv->pending_events; l != NULL; l = l->next) { + gst_pad_push_event (parse->srcpad, GST_EVENT (l->data)); + } + g_list_free (parse->priv->pending_events); + parse->priv->pending_events = NULL; + } + /* TODO: Add to seek table */ if (ret == GST_FLOW_OK) { @@ -839,9 +873,6 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer) bclass = GST_BASE_PARSE_GET_CLASS (parse); if (G_UNLIKELY (parse->pending_segment)) { - GST_DEBUG_OBJECT (parse, "chain pushing a pending segment"); - gst_pad_push_event (parse->srcpad, parse->pending_segment); - parse->pending_segment = NULL; parse->priv->offset = parse->priv->pending_offset; /* Make sure that adapter doesn't have any old data after @@ -854,16 +885,6 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer) gst_adapter_clear (parse->adapter); } - if (G_UNLIKELY (parse->priv->pending_events)) { - GList *l; - - for (l = parse->priv->pending_events; l != NULL; l = l->next) { - gst_pad_push_event (parse->srcpad, GST_EVENT (l->data)); - } - g_list_free (parse->priv->pending_events); - parse->priv->pending_events = NULL; - } - if (G_LIKELY (buffer)) { GST_LOG_OBJECT (parse, "buffer size: %d, offset = %lld", GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer)); @@ -1051,18 +1072,6 @@ gst_base_parse_loop (GstPad * pad) parse = GST_BASE_PARSE (gst_pad_get_parent (pad)); klass = GST_BASE_PARSE_GET_CLASS (parse); - if (parse->close_segment) { - GST_DEBUG_OBJECT (parse, "loop sending close segment"); - gst_pad_push_event (parse->srcpad, parse->close_segment); - parse->close_segment = NULL; - } - - if (parse->pending_segment) { - GST_DEBUG_OBJECT (parse, "loop push pending segment"); - gst_pad_push_event (parse->srcpad, parse->pending_segment); - parse->pending_segment = NULL; - } - /* TODO: Check if we reach segment stop limit */ while (TRUE) { |