diff options
author | Dave Robillard <dave@drobilla.net> | 2009-07-22 14:36:14 -0400 |
---|---|---|
committer | Dave Robillard <dave@drobilla.net> | 2009-07-22 14:36:14 -0400 |
commit | adadf06b0a9e26005ba9363aa0049dc0b740c94d (patch) | |
tree | b61e688d7ed775acff14763d0453102f80cc6c09 /gst/mpegdemux/gstmpegdemux.c | |
parent | 23ef5d4ac3487345c1c91db57c76554363e6c0f5 (diff) | |
parent | 5d9d4a7b518c42bda88c7f6c87ce7c3c01233562 (diff) | |
download | gst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.tar.gz gst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.tar.bz2 gst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.zip |
Merge branch 'fdo' into lv2
Diffstat (limited to 'gst/mpegdemux/gstmpegdemux.c')
-rw-r--r-- | gst/mpegdemux/gstmpegdemux.c | 73 |
1 files changed, 66 insertions, 7 deletions
diff --git a/gst/mpegdemux/gstmpegdemux.c b/gst/mpegdemux/gstmpegdemux.c index ce1d0978..75d5960f 100644 --- a/gst/mpegdemux/gstmpegdemux.c +++ b/gst/mpegdemux/gstmpegdemux.c @@ -845,6 +845,7 @@ gst_flups_demux_close_segment (GstFluPSDemux * demux) { gint id; GstEvent *event = NULL; + guint64 base_time; #if POST_10_10 GST_INFO_OBJECT (demux, "closing running segment %" GST_SEGMENT_FORMAT, @@ -855,14 +856,17 @@ gst_flups_demux_close_segment (GstFluPSDemux * demux) * last_seg_start != clock_time_none, as that indicates a sparse-stream * event was sent there */ + if ((base_time = demux->base_time) == (guint64) - 1) + base_time = 0; + + /* Close the current segment for a linear playback */ if (demux->src_segment.rate >= 0) { /* for forward playback, we played from start to last_stop */ event = gst_event_new_new_segment (TRUE, demux->src_segment.rate, demux->src_segment.format, - demux->src_segment.start + demux->base_time, - demux->src_segment.last_stop + demux->base_time, - demux->src_segment.time); + demux->src_segment.start + base_time, + demux->src_segment.last_stop + base_time, demux->src_segment.time); } else { gint64 stop; @@ -872,8 +876,8 @@ gst_flups_demux_close_segment (GstFluPSDemux * demux) /* for reverse playback, we played from stop to last_stop. */ event = gst_event_new_new_segment (TRUE, demux->src_segment.rate, demux->src_segment.format, - demux->src_segment.last_stop + demux->base_time, - stop + demux->base_time, demux->src_segment.last_stop); + demux->src_segment.last_stop + base_time, + stop + base_time, demux->src_segment.last_stop); } if (event) { @@ -1383,11 +1387,66 @@ gst_flups_demux_src_query (GstPad * pad, GstQuery * query) res = TRUE; break; } + case GST_QUERY_SEEKING:{ + GstFormat fmt; + + gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL); + + res = TRUE; + if (demux->random_access) { + /* In pull mode we can seek in TIME format if we have the SCR */ + if (fmt != GST_FORMAT_TIME || demux->scr_rate_n == G_MAXUINT64 + || demux->scr_rate_d == G_MAXUINT64) + gst_query_set_seeking (query, fmt, FALSE, -1, -1); + else + gst_query_set_seeking (query, fmt, TRUE, 0, -1); + } else { + if (fmt == GST_FORMAT_BYTES) { + /* Seeking in BYTES format not supported at all */ + gst_query_set_seeking (query, fmt, FALSE, -1, -1); + } else { + GstQuery *peerquery; + gboolean seekable; + + /* Then ask upstream */ + res = gst_pad_peer_query (demux->sinkpad, query); + if (res) { + /* If upstream can handle seeks we're done, if it + * can't we still have our TIME->BYTES conversion seek + */ + gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL); + if (seekable || fmt != GST_FORMAT_TIME) + goto beach; + } + + /* We can seek if upstream supports BYTES seeks and we + * have the SCR + */ + peerquery = gst_query_new_seeking (GST_FORMAT_BYTES); + res = gst_pad_peer_query (demux->sinkpad, query); + if (!res || demux->scr_rate_n == G_MAXUINT64 + || demux->scr_rate_d == G_MAXUINT64) { + gst_query_set_seeking (query, fmt, FALSE, -1, -1); + } else { + gst_query_parse_seeking (peerquery, NULL, &seekable, NULL, NULL); + if (seekable) + gst_query_set_seeking (query, GST_FORMAT_TIME, TRUE, 0, -1); + else + gst_query_set_seeking (query, fmt, FALSE, -1, -1); + } + + gst_query_unref (peerquery); + res = TRUE; + } + } + break; + } default: res = gst_pad_query_default (pad, query); break; } +beach: gst_object_unref (demux); return res; @@ -2540,7 +2599,7 @@ gst_flups_demux_loop (GstPad * pad) { GstFluPSDemux *demux; GstFlowReturn ret = GST_FLOW_OK; - guint offset = 0; + guint64 offset = 0; demux = GST_FLUPS_DEMUX (gst_pad_get_parent (pad)); @@ -2579,7 +2638,7 @@ gst_flups_demux_loop (GstPad * pad) goto pause; } } else { /* Reverse playback */ - guint size = MIN (offset, BLOCK_SZ); + guint64 size = MIN (offset, BLOCK_SZ); /* pull in data */ ret = gst_flups_demux_pull_block (pad, demux, offset - size, size); |