matroskademux: Start support for upstream segments in TIME format

So we can use matroskademux for dash webm dash streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3159>
This commit is contained in:
Thibault Saunier 2022-09-21 15:01:39 -03:00 committed by GStreamer Marge Bot
parent 2125dbbd0b
commit 8c7579e129
2 changed files with 24 additions and 4 deletions

View file

@ -351,6 +351,7 @@ gst_matroska_demux_reset (GstElement * element)
demux->index_offset = 0; demux->index_offset = 0;
demux->seekable = FALSE; demux->seekable = FALSE;
demux->need_segment = FALSE; demux->need_segment = FALSE;
demux->upstream_format_is_time = FALSE;
demux->segment_seqnum = 0; demux->segment_seqnum = 0;
demux->requested_seek_time = GST_CLOCK_TIME_NONE; demux->requested_seek_time = GST_CLOCK_TIME_NONE;
demux->seek_offset = -1; demux->seek_offset = -1;
@ -4683,10 +4684,14 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
GST_TIME_ARGS (demux->common.segment.position)); GST_TIME_ARGS (demux->common.segment.position));
clace_time = demux->common.segment.position; clace_time = demux->common.segment.position;
} }
/* We shouldn't modify upstream driven TIME FORMAT segment */
if (!demux->upstream_format_is_time) {
segment->start = clace_time; segment->start = clace_time;
segment->stop = demux->common.segment.stop; segment->stop = demux->common.segment.stop;
segment->time = segment->start - demux->stream_start_time; segment->time = segment->start - demux->stream_start_time;
segment->position = segment->start - demux->stream_start_time; segment->position = segment->start - demux->stream_start_time;
}
GST_DEBUG_OBJECT (demux, GST_DEBUG_OBJECT (demux,
"generated segment starting at %" GST_TIME_FORMAT ": %" "generated segment starting at %" GST_TIME_FORMAT ": %"
GST_SEGMENT_FORMAT, GST_TIME_ARGS (lace_time), segment); GST_SEGMENT_FORMAT, GST_TIME_ARGS (lace_time), segment);
@ -6219,6 +6224,17 @@ gst_matroska_demux_handle_sink_event (GstPad * pad, GstObject * parent,
goto exit; goto exit;
} }
if (segment->format == GST_FORMAT_TIME) {
demux->upstream_format_is_time = TRUE;
demux->segment_seqnum = gst_event_get_seqnum (event);
gst_segment_copy_into (segment, &demux->common.segment);
GST_DEBUG_OBJECT (demux, "Got segment in TIME format: %" GST_PTR_FORMAT,
event);
goto exit;
}
demux->upstream_format_is_time = FALSE;
/* we only expect a BYTE segment, e.g. following a seek */ /* we only expect a BYTE segment, e.g. following a seek */
if (segment->format != GST_FORMAT_BYTES) { if (segment->format != GST_FORMAT_BYTES) {
GST_DEBUG_OBJECT (demux, "unsupported segment format, ignoring"); GST_DEBUG_OBJECT (demux, "unsupported segment format, ignoring");

View file

@ -107,6 +107,10 @@ typedef struct _GstMatroskaDemux {
GstPad *deferred_seek_pad; GstPad *deferred_seek_pad;
gboolean need_segment; gboolean need_segment;
guint32 segment_seqnum; guint32 segment_seqnum;
/* If TRUE, matroskamux received upstream newsegment in TIME format
* which likely means that upstream is driving the pipeline (such as
* adaptive demuxers) */
gboolean upstream_format_is_time;
/* reverse playback */ /* reverse playback */
GArray *seek_index; GArray *seek_index;