mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
adaptivedemux2: Add start/stop vfuncs
Remove the can_start() vfunc, in favour of vfuncs when the stream starts/stops, allowing the sub-class to do custom logic before (or preventing) the stream from starting and stopping. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
parent
fa0e9e2ec5
commit
0962908e62
3 changed files with 66 additions and 31 deletions
|
@ -53,6 +53,10 @@ static void gst_adaptive_demux2_stream_update_track_ids (GstAdaptiveDemux2Stream
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_adaptive_demux2_stream_submit_request_default (GstAdaptiveDemux2Stream *
|
gst_adaptive_demux2_stream_submit_request_default (GstAdaptiveDemux2Stream *
|
||||||
stream, DownloadRequest * download_req);
|
stream, DownloadRequest * download_req);
|
||||||
|
static void
|
||||||
|
gst_adaptive_demux2_stream_start_default (GstAdaptiveDemux2Stream * stream);
|
||||||
|
static void
|
||||||
|
gst_adaptive_demux2_stream_stop_default (GstAdaptiveDemux2Stream * stream);
|
||||||
|
|
||||||
#define gst_adaptive_demux2_stream_parent_class parent_class
|
#define gst_adaptive_demux2_stream_parent_class parent_class
|
||||||
G_DEFINE_ABSTRACT_TYPE (GstAdaptiveDemux2Stream, gst_adaptive_demux2_stream,
|
G_DEFINE_ABSTRACT_TYPE (GstAdaptiveDemux2Stream, gst_adaptive_demux2_stream,
|
||||||
|
@ -65,6 +69,8 @@ gst_adaptive_demux2_stream_class_init (GstAdaptiveDemux2StreamClass * klass)
|
||||||
|
|
||||||
gobject_class->finalize = gst_adaptive_demux2_stream_finalize;
|
gobject_class->finalize = gst_adaptive_demux2_stream_finalize;
|
||||||
|
|
||||||
|
klass->start = gst_adaptive_demux2_stream_start_default;
|
||||||
|
klass->stop = gst_adaptive_demux2_stream_stop_default;
|
||||||
klass->data_received = gst_adaptive_demux2_stream_data_received_default;
|
klass->data_received = gst_adaptive_demux2_stream_data_received_default;
|
||||||
klass->finish_fragment = gst_adaptive_demux2_stream_finish_fragment_default;
|
klass->finish_fragment = gst_adaptive_demux2_stream_finish_fragment_default;
|
||||||
klass->submit_request = gst_adaptive_demux2_stream_submit_request_default;
|
klass->submit_request = gst_adaptive_demux2_stream_submit_request_default;
|
||||||
|
@ -2066,46 +2072,36 @@ gst_adaptive_demux2_stream_next_download (GstAdaptiveDemux2Stream * stream)
|
||||||
return gst_adaptive_demux2_stream_load_a_fragment (stream);
|
return gst_adaptive_demux2_stream_load_a_fragment (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_adaptive_demux2_stream_can_start (GstAdaptiveDemux2Stream * stream)
|
|
||||||
{
|
|
||||||
GstAdaptiveDemux2StreamClass *klass =
|
|
||||||
GST_ADAPTIVE_DEMUX2_STREAM_GET_CLASS (stream);
|
|
||||||
|
|
||||||
if (!klass->can_start)
|
|
||||||
return TRUE;
|
|
||||||
return klass->can_start (stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_adaptive_demux2_stream_start:
|
* gst_adaptive_demux2_stream_start:
|
||||||
* @stream: a #GstAdaptiveDemux2Stream
|
* @stream: a #GstAdaptiveDemux2Stream
|
||||||
*
|
*
|
||||||
* Start the given @stream. Should be called by subclasses that previously
|
* Start the given @stream. Can be called by subclasses that previously
|
||||||
* returned %FALSE in `GstAdaptiveDemux::stream_can_start()`
|
* returned %FALSE in `GstAdaptiveDemux2Stream::start()`, or from
|
||||||
|
* the demuxer when a stream should start downloading.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_adaptive_demux2_stream_start (GstAdaptiveDemux2Stream * stream)
|
gst_adaptive_demux2_stream_start (GstAdaptiveDemux2Stream * stream)
|
||||||
{
|
{
|
||||||
GstAdaptiveDemux *demux;
|
|
||||||
|
|
||||||
g_return_if_fail (stream && stream->demux);
|
g_return_if_fail (stream && stream->demux);
|
||||||
|
|
||||||
demux = stream->demux;
|
|
||||||
|
|
||||||
if (stream->pending_cb_id != 0 || stream->download_active) {
|
if (stream->pending_cb_id != 0 || stream->download_active) {
|
||||||
/* There is already something active / pending on this stream */
|
/* There is already something active / pending on this stream */
|
||||||
GST_LOG_OBJECT (stream, "Stream already running");
|
GST_LOG_OBJECT (stream, "Stream already running");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some streams require a delayed start, i.e. they need more information
|
GstAdaptiveDemux2StreamClass *klass =
|
||||||
* before they can actually be started */
|
GST_ADAPTIVE_DEMUX2_STREAM_GET_CLASS (stream);
|
||||||
if (!gst_adaptive_demux2_stream_can_start (stream)) {
|
|
||||||
GST_LOG_OBJECT (stream, "Stream will be started asynchronously");
|
klass->start (stream);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_adaptive_demux2_stream_start_default (GstAdaptiveDemux2Stream * stream)
|
||||||
|
{
|
||||||
|
GstAdaptiveDemux *demux = stream->demux;
|
||||||
|
|
||||||
if (stream->state == GST_ADAPTIVE_DEMUX2_STREAM_STATE_EOS) {
|
if (stream->state == GST_ADAPTIVE_DEMUX2_STREAM_STATE_EOS) {
|
||||||
GST_LOG_OBJECT (stream, "Stream is EOS already");
|
GST_LOG_OBJECT (stream, "Stream is EOS already");
|
||||||
return;
|
return;
|
||||||
|
@ -2130,6 +2126,15 @@ gst_adaptive_demux2_stream_start (GstAdaptiveDemux2Stream * stream)
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_adaptive_demux2_stream_stop (GstAdaptiveDemux2Stream * stream)
|
gst_adaptive_demux2_stream_stop (GstAdaptiveDemux2Stream * stream)
|
||||||
|
{
|
||||||
|
GstAdaptiveDemux2StreamClass *klass =
|
||||||
|
GST_ADAPTIVE_DEMUX2_STREAM_GET_CLASS (stream);
|
||||||
|
|
||||||
|
klass->stop (stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_adaptive_demux2_stream_stop_default (GstAdaptiveDemux2Stream * stream)
|
||||||
{
|
{
|
||||||
GstAdaptiveDemux *demux = stream->demux;
|
GstAdaptiveDemux *demux = stream->demux;
|
||||||
|
|
||||||
|
|
|
@ -154,14 +154,26 @@ struct _GstAdaptiveDemux2StreamClass
|
||||||
GstClockTimeDiff * final_ts);
|
GstClockTimeDiff * final_ts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* can_start:
|
* start:
|
||||||
* @stream: a #GstAdaptiveDemux2Stream
|
* @stream: a #GstAdaptiveDemux2Stream
|
||||||
*
|
*
|
||||||
* Called before starting a @stream. sub-classes can return %FALSE if more
|
* Called to start downloading a @stream, sub-classes should chain up to the default
|
||||||
* information is required before it can be started. Sub-classes will have to
|
* implementation. Sub-classes can return %FALSE if more
|
||||||
* call gst_adaptive_demux2_stream_start() when the stream should be started.
|
* information is required before the stream can be started. In that case, sub-classes
|
||||||
|
* will have to call gst_adaptive_demux2_stream_start() again when the stream should
|
||||||
|
* be started.
|
||||||
*/
|
*/
|
||||||
gboolean (*can_start) (GstAdaptiveDemux2Stream *stream);
|
void (*start) (GstAdaptiveDemux2Stream *stream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stop:
|
||||||
|
* @stream: a #GstAdaptiveDemux2Stream
|
||||||
|
*
|
||||||
|
* Called to stop downloading a @stream, sub-classes should chain up to the default
|
||||||
|
* implementation.
|
||||||
|
*/
|
||||||
|
void (*stop) (GstAdaptiveDemux2Stream *stream);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create_tracks:
|
* create_tracks:
|
||||||
|
|
|
@ -72,8 +72,8 @@ gst_hls_demux_stream_update_fragment_info (GstAdaptiveDemux2Stream * stream);
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_hls_demux_stream_submit_request (GstAdaptiveDemux2Stream * stream,
|
gst_hls_demux_stream_submit_request (GstAdaptiveDemux2Stream * stream,
|
||||||
DownloadRequest * download_req);
|
DownloadRequest * download_req);
|
||||||
static gboolean gst_hls_demux_stream_can_start (GstAdaptiveDemux2Stream *
|
static void gst_hls_demux_stream_start (GstAdaptiveDemux2Stream * stream);
|
||||||
stream);
|
static void gst_hls_demux_stream_stop (GstAdaptiveDemux2Stream * stream);
|
||||||
static void gst_hls_demux_stream_create_tracks (GstAdaptiveDemux2Stream *
|
static void gst_hls_demux_stream_create_tracks (GstAdaptiveDemux2Stream *
|
||||||
stream);
|
stream);
|
||||||
static gboolean gst_hls_demux_stream_select_bitrate (GstAdaptiveDemux2Stream *
|
static gboolean gst_hls_demux_stream_select_bitrate (GstAdaptiveDemux2Stream *
|
||||||
|
@ -107,7 +107,8 @@ gst_hls_demux_stream_class_init (GstHLSDemuxStreamClass * klass)
|
||||||
gst_hls_demux_stream_advance_fragment;
|
gst_hls_demux_stream_advance_fragment;
|
||||||
adaptivedemux2stream_class->select_bitrate =
|
adaptivedemux2stream_class->select_bitrate =
|
||||||
gst_hls_demux_stream_select_bitrate;
|
gst_hls_demux_stream_select_bitrate;
|
||||||
adaptivedemux2stream_class->can_start = gst_hls_demux_stream_can_start;
|
adaptivedemux2stream_class->start = gst_hls_demux_stream_start;
|
||||||
|
adaptivedemux2stream_class->stop = gst_hls_demux_stream_stop;
|
||||||
adaptivedemux2stream_class->create_tracks =
|
adaptivedemux2stream_class->create_tracks =
|
||||||
gst_hls_demux_stream_create_tracks;
|
gst_hls_demux_stream_create_tracks;
|
||||||
|
|
||||||
|
@ -2007,6 +2008,23 @@ gst_hls_demux_stream_can_start (GstAdaptiveDemux2Stream * stream)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_hls_demux_stream_start (GstAdaptiveDemux2Stream * stream)
|
||||||
|
{
|
||||||
|
if (!gst_hls_demux_stream_can_start (stream))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Chain up, to start the downloading */
|
||||||
|
GST_ADAPTIVE_DEMUX2_STREAM_CLASS (stream_parent_class)->start (stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_hls_demux_stream_stop (GstAdaptiveDemux2Stream * stream)
|
||||||
|
{
|
||||||
|
/* Chain up, to stop the downloading */
|
||||||
|
GST_ADAPTIVE_DEMUX2_STREAM_CLASS (stream_parent_class)->stop (stream);
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns TRUE if the rendition stream switched group-id */
|
/* Returns TRUE if the rendition stream switched group-id */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_hls_demux_update_rendition_stream (GstHLSDemux * hlsdemux,
|
gst_hls_demux_update_rendition_stream (GstHLSDemux * hlsdemux,
|
||||||
|
|
Loading…
Reference in a new issue