mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-01 03:52:25 +00:00
adaptivedemux2: Move stream_seek() to the Stream class
Move the last stream specific vfunc from the demux class to the stream class. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3314>
This commit is contained in:
parent
2fe641353d
commit
565f47b4f3
7 changed files with 46 additions and 39 deletions
|
@ -477,6 +477,7 @@ gst_dash_demux_stream_class_init (GstDashDemux2StreamClass * klass)
|
|||
gst_dash_demux_stream_update_fragment_info;
|
||||
adaptivedemux2stream_class->has_next_fragment =
|
||||
gst_dash_demux_stream_has_next_fragment;
|
||||
adaptivedemux2stream_class->stream_seek = gst_dash_demux_stream_seek;
|
||||
adaptivedemux2stream_class->advance_fragment =
|
||||
gst_dash_demux_stream_advance_fragment;
|
||||
adaptivedemux2stream_class->get_fragment_waiting_time =
|
||||
|
@ -656,7 +657,6 @@ gst_dash_demux2_class_init (GstDashDemux2Class * klass)
|
|||
gstadaptivedemux_class->has_next_period = gst_dash_demux_has_next_period;
|
||||
gstadaptivedemux_class->advance_period = gst_dash_demux_advance_period;
|
||||
|
||||
gstadaptivedemux_class->stream_seek = gst_dash_demux_stream_seek;
|
||||
gstadaptivedemux_class->get_live_seek_range =
|
||||
gst_dash_demux_get_live_seek_range;
|
||||
gstadaptivedemux_class->get_period_start_time =
|
||||
|
|
|
@ -183,8 +183,8 @@ void gst_adaptive_demux2_stream_on_manifest_update (GstAdaptiveDemux2Stream * st
|
|||
void gst_adaptive_demux2_stream_on_output_space_available (GstAdaptiveDemux2Stream *stream);
|
||||
|
||||
gboolean gst_adaptive_demux2_stream_has_next_fragment (GstAdaptiveDemux2Stream * stream);
|
||||
GstFlowReturn gst_adaptive_demux2_stream_seek (GstAdaptiveDemux * demux,
|
||||
GstAdaptiveDemux2Stream * stream, gboolean forward, GstSeekFlags flags,
|
||||
GstFlowReturn gst_adaptive_demux2_stream_seek (GstAdaptiveDemux2Stream * stream,
|
||||
gboolean forward, GstSeekFlags flags,
|
||||
GstClockTimeDiff ts, GstClockTimeDiff * final_ts);
|
||||
gboolean gst_adaptive_demux_get_live_seek_range (GstAdaptiveDemux * demux,
|
||||
gint64 * range_start, gint64 * range_stop);
|
||||
|
|
|
@ -1941,7 +1941,7 @@ gst_adaptive_demux2_stream_next_download (GstAdaptiveDemux2Stream * stream)
|
|||
|
||||
if (GST_CLOCK_STIME_IS_VALID (stream_time)) {
|
||||
/* TODO check return */
|
||||
gst_adaptive_demux2_stream_seek (demux, stream, demux->segment.rate >= 0,
|
||||
gst_adaptive_demux2_stream_seek (stream, demux->segment.rate >= 0,
|
||||
0, stream_time, &stream_time);
|
||||
stream->current_position = stream->start_position;
|
||||
|
||||
|
@ -2197,6 +2197,20 @@ gst_adaptive_demux2_stream_has_next_fragment (GstAdaptiveDemux2Stream * stream)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* must be called from the scheduler */
|
||||
GstFlowReturn
|
||||
gst_adaptive_demux2_stream_seek (GstAdaptiveDemux2Stream * stream,
|
||||
gboolean forward, GstSeekFlags flags,
|
||||
GstClockTimeDiff ts, GstClockTimeDiff * final_ts)
|
||||
{
|
||||
GstAdaptiveDemux2StreamClass *klass =
|
||||
GST_ADAPTIVE_DEMUX2_STREAM_GET_CLASS (stream);
|
||||
|
||||
if (klass->stream_seek)
|
||||
return klass->stream_seek (stream, forward, flags, ts, final_ts);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_adaptive_demux2_stream_select_bitrate (GstAdaptiveDemux *
|
||||
demux, GstAdaptiveDemux2Stream * stream, guint64 bitrate)
|
||||
|
|
|
@ -131,6 +131,12 @@ struct _GstAdaptiveDemux2StreamClass
|
|||
gboolean (*has_next_fragment) (GstAdaptiveDemux2Stream * stream);
|
||||
GstFlowReturn (*advance_fragment) (GstAdaptiveDemux2Stream * stream);
|
||||
|
||||
GstFlowReturn (*stream_seek) (GstAdaptiveDemux2Stream * stream,
|
||||
gboolean forward,
|
||||
GstSeekFlags flags,
|
||||
GstClockTimeDiff target_ts,
|
||||
GstClockTimeDiff * final_ts);
|
||||
|
||||
/**
|
||||
* can_start:
|
||||
* @stream: a #GstAdaptiveDemux2Stream
|
||||
|
|
|
@ -2206,15 +2206,24 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
|||
* different positions, so just pick one and align all others to that
|
||||
* position.
|
||||
*/
|
||||
if (IS_SNAP_SEEK (flags) && demux_class->stream_seek) {
|
||||
GstAdaptiveDemux2Stream *stream = NULL;
|
||||
|
||||
GstAdaptiveDemux2Stream *stream = NULL;
|
||||
GList *iter;
|
||||
/* Pick a random active stream on which to do the stream seek */
|
||||
for (iter = demux->output_period->streams; iter; iter = iter->next) {
|
||||
GstAdaptiveDemux2Stream *cand = iter->data;
|
||||
if (gst_adaptive_demux2_stream_is_selected_locked (cand)) {
|
||||
stream = cand;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (stream && IS_SNAP_SEEK (flags)) {
|
||||
GstClockTimeDiff ts;
|
||||
GstSeekFlags stream_seek_flags = flags;
|
||||
GList *iter;
|
||||
|
||||
/* snap-seek on the stream that received the event and then
|
||||
/* snap-seek on the chosen stream and then
|
||||
* use the resulting position to seek on all streams */
|
||||
|
||||
if (rate >= 0) {
|
||||
if (start_type != GST_SEEK_TYPE_NONE)
|
||||
ts = start;
|
||||
|
@ -2233,16 +2242,13 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux,
|
|||
}
|
||||
}
|
||||
|
||||
/* Pick a random active stream on which to do the stream seek */
|
||||
for (iter = demux->output_period->streams; iter; iter = iter->next) {
|
||||
GstAdaptiveDemux2Stream *cand = iter->data;
|
||||
if (gst_adaptive_demux2_stream_is_selected_locked (cand)) {
|
||||
stream = cand;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stream) {
|
||||
demux_class->stream_seek (stream, rate >= 0, stream_seek_flags, ts, &ts);
|
||||
if (gst_adaptive_demux2_stream_seek (stream, rate >= 0, stream_seek_flags,
|
||||
ts, &ts) != GST_FLOW_OK) {
|
||||
GST_ADAPTIVE_SCHEDULER_UNLOCK (demux);
|
||||
|
||||
GST_API_UNLOCK (demux);
|
||||
gst_event_unref (event);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* replace event with a new one without snapping to seek on all streams */
|
||||
|
@ -3567,19 +3573,6 @@ gst_adaptive_demux_is_live (GstAdaptiveDemux * demux)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* must be called from the scheduler */
|
||||
GstFlowReturn
|
||||
gst_adaptive_demux2_stream_seek (GstAdaptiveDemux * demux,
|
||||
GstAdaptiveDemux2Stream * stream, gboolean forward, GstSeekFlags flags,
|
||||
GstClockTimeDiff ts, GstClockTimeDiff * final_ts)
|
||||
{
|
||||
GstAdaptiveDemuxClass *klass = GST_ADAPTIVE_DEMUX_GET_CLASS (demux);
|
||||
|
||||
if (klass->stream_seek)
|
||||
return klass->stream_seek (stream, forward, flags, ts, final_ts);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_manifest_download_complete (DownloadRequest * request,
|
||||
DownloadRequestState state, GstAdaptiveDemux * demux)
|
||||
|
|
|
@ -400,12 +400,6 @@ struct _GstAdaptiveDemuxClass
|
|||
*/
|
||||
void (*advance_period) (GstAdaptiveDemux * demux);
|
||||
|
||||
GstFlowReturn (*stream_seek) (GstAdaptiveDemux2Stream * stream,
|
||||
gboolean forward,
|
||||
GstSeekFlags flags,
|
||||
GstClockTimeDiff target_ts,
|
||||
GstClockTimeDiff * final_ts);
|
||||
|
||||
/**
|
||||
* get_live_seek_range:
|
||||
* @demux: #GstAdaptiveDemux
|
||||
|
|
|
@ -166,6 +166,7 @@ gst_hls_demux_stream_class_init (GstHLSDemuxStreamClass * klass)
|
|||
gst_hls_demux_stream_update_fragment_info;
|
||||
adaptivedemux2stream_class->has_next_fragment =
|
||||
gst_hls_demux_stream_has_next_fragment;
|
||||
adaptivedemux2stream_class->stream_seek = gst_hls_demux_stream_seek;
|
||||
adaptivedemux2stream_class->advance_fragment =
|
||||
gst_hls_demux_stream_advance_fragment;
|
||||
adaptivedemux2stream_class->select_bitrate =
|
||||
|
@ -295,7 +296,6 @@ gst_hls_demux2_class_init (GstHLSDemux2Class * klass)
|
|||
adaptivedemux_class->update_manifest = gst_hls_demux_update_manifest;
|
||||
adaptivedemux_class->reset = gst_hls_demux_reset;
|
||||
adaptivedemux_class->seek = gst_hls_demux_seek;
|
||||
adaptivedemux_class->stream_seek = gst_hls_demux_stream_seek;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue