diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2009-03-31 16:07:46 +0200 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2009-03-31 16:18:00 +0200 |
commit | ad2c7bffe7d94c79184904b14101cbc93eeb9ebd (patch) | |
tree | 85462ced72694644022f71ac3d2daaa8f4483532 /gst/aacparse | |
parent | d2f954636997b16343b40dfefd3ffb0fb00895a1 (diff) | |
download | gst-plugins-bad-ad2c7bffe7d94c79184904b14101cbc93eeb9ebd.tar.gz gst-plugins-bad-ad2c7bffe7d94c79184904b14101cbc93eeb9ebd.tar.bz2 gst-plugins-bad-ad2c7bffe7d94c79184904b14101cbc93eeb9ebd.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) { |