summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2016-12-09 17:55:39 +0200
committerSebastian Dröge <sebastian@centricular.com>2016-12-09 17:55:39 +0200
commit524e43e11802a4f8f21a8d99206f643eb0dff342 (patch)
treedc9aebc69108c5dee0a422014ed6cc992e8e556f
parenta08e72547dc1ec4d234f0be598a7c9c135188511 (diff)
downloadgstreamer-plugins-good-524e43e11802a4f8f21a8d99206f643eb0dff342.tar.gz
flxdec: Only send SEGMENT events after CAPS
I.e., don't just forward the event but delay it if we don't have caps on the srcpad yet.
-rw-r--r--gst/flx/gstflxdec.c32
-rw-r--r--gst/flx/gstflxdec.h5
2 files changed, 29 insertions, 8 deletions
diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
index 55aa55097..37d552aae 100644
--- a/gst/flx/gstflxdec.c
+++ b/gst/flx/gstflxdec.c
@@ -190,17 +190,27 @@ gst_flxdec_sink_event_handler (GstPad * pad, GstObject * parent,
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEGMENT:
{
- GstSegment segment;
-
- gst_event_copy_segment (event, &segment);
- if (segment.format != GST_FORMAT_TIME) {
+ gst_event_copy_segment (event, &flxdec->segment);
+ if (flxdec->segment.format != GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (flxdec, "generating TIME segment");
- gst_segment_init (&segment, GST_FORMAT_TIME);
+ gst_segment_init (&flxdec->segment, GST_FORMAT_TIME);
+ gst_event_unref (event);
+ event = gst_event_new_segment (&flxdec->segment);
+ }
+
+ if (gst_pad_has_current_caps (flxdec->srcpad)) {
+ ret = gst_pad_event_default (pad, parent, event);
+ } else {
+ flxdec->need_segment = TRUE;
gst_event_unref (event);
- event = gst_event_new_segment (&segment);
+ ret = TRUE;
}
- /* fall-through */
+ break;
}
+ case GST_EVENT_FLUSH_STOP:
+ gst_segment_init (&flxdec->segment, GST_FORMAT_UNDEFINED);
+ ret = gst_pad_event_default (pad, parent, event);
+ break;
default:
ret = gst_pad_event_default (pad, parent, event);
break;
@@ -784,6 +794,12 @@ gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
gst_pad_set_caps (flxdec->srcpad, caps);
gst_caps_unref (caps);
+ if (flxdec->need_segment) {
+ gst_pad_push_event (flxdec->srcpad,
+ gst_event_new_segment (&flxdec->segment));
+ flxdec->need_segment = FALSE;
+ }
+
/* zero means 8 */
if (flxh->depth == 0)
flxh->depth = 8;
@@ -932,6 +948,8 @@ gst_flxdec_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_READY_TO_PAUSED:
gst_adapter_clear (flxdec->adapter);
flxdec->state = GST_FLXDEC_READ_HEADER;
+ gst_segment_init (&flxdec->segment, GST_FORMAT_UNDEFINED);
+ flxdec->need_segment = TRUE;
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
diff --git a/gst/flx/gstflxdec.h b/gst/flx/gstflxdec.h
index 4fd8dfd0b..c6486a06b 100644
--- a/gst/flx/gstflxdec.h
+++ b/gst/flx/gstflxdec.h
@@ -41,7 +41,10 @@ typedef struct _GstFlxDec GstFlxDec;
struct _GstFlxDec {
GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
+
+ GstSegment segment;
+ gboolean need_segment;
gboolean active, new_meta;