summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2010-06-02 13:31:46 -0700
committerDavid Schleef <ds@schleef.org>2010-06-02 19:28:16 -0700
commit13848cc93b785b1f206ec0d62f5657db386bddeb (patch)
tree07c27d6a62714f2a52b6200e1f96b2c0391529c2 /gst-libs
parent99a88edcc1f0d2cfd51350d2697dd7c1fec57587 (diff)
downloadgstreamer-plugins-bad-13848cc93b785b1f206ec0d62f5657db386bddeb.tar.gz
basevideodecoder: create new segments if missing
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/video/gstbasevideodecoder.c24
-rw-r--r--gst-libs/gst/video/gstbasevideodecoder.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/gst-libs/gst/video/gstbasevideodecoder.c b/gst-libs/gst/video/gstbasevideodecoder.c
index 9bdee8b8b..0ddf6fb5c 100644
--- a/gst-libs/gst/video/gstbasevideodecoder.c
+++ b/gst-libs/gst/video/gstbasevideodecoder.c
@@ -262,6 +262,7 @@ gst_base_video_decoder_sink_event (GstPad * pad, GstEvent * event)
gst_segment_set_newsegment_full (segment,
update, rate, applied_rate, format, start, stop, position);
+ base_video_decoder->have_segment = TRUE;
GST_WARNING ("new segment: format %d rate %g start %" GST_TIME_FORMAT
" stop %" GST_TIME_FORMAT
@@ -791,6 +792,29 @@ gst_base_video_decoder_chain (GstPad * pad, GstBuffer * buf)
GST_DEBUG_OBJECT (base_video_decoder, "chain");
+ if (!base_video_decoder->have_segment) {
+ GstEvent *event;
+ GstFlowReturn ret;
+
+ GST_WARNING
+ ("Received buffer without a new-segment. Assuming timestamps start from 0.");
+
+ gst_segment_set_newsegment_full (&base_video_decoder->segment,
+ FALSE, 1.0, 1.0, GST_FORMAT_TIME, 0, GST_CLOCK_TIME_NONE, 0);
+ base_video_decoder->have_segment = TRUE;
+
+ event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0,
+ GST_CLOCK_TIME_NONE, 0);
+
+ ret =
+ gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder),
+ event);
+ if (!ret) {
+ GST_ERROR ("new segment event ret=%d", ret);
+ return GST_FLOW_ERROR;
+ }
+ }
+
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT))) {
GST_DEBUG_OBJECT (base_video_decoder, "received DISCONT buffer");
gst_base_video_decoder_reset (base_video_decoder);
diff --git a/gst-libs/gst/video/gstbasevideodecoder.h b/gst-libs/gst/video/gstbasevideodecoder.h
index 20d6f0a7a..02f1fd3a7 100644
--- a/gst-libs/gst/video/gstbasevideodecoder.h
+++ b/gst-libs/gst/video/gstbasevideodecoder.h
@@ -116,6 +116,7 @@ struct _GstBaseVideoDecoder
gboolean packetized;
GList *timestamps;
+ gboolean have_segment;
};
struct _GstBaseVideoDecoderClass