hlsdemux2: Add llhls-enabled property to streams

Tidying: Make the llhls-enabled setting configurable through a stream property
instead of set manually after construction.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
Jan Schmidt 2022-12-24 01:37:40 +11:00 committed by GStreamer Marge Bot
parent d5edd48f13
commit 7b3a1bac0a
2 changed files with 51 additions and 6 deletions

View file

@ -43,6 +43,15 @@
GST_DEBUG_CATEGORY_EXTERN (gst_hls_demux2_debug);
#define GST_CAT_DEFAULT gst_hls_demux2_debug
enum
{
PROP_0,
PROP_LLHLS_ENABLED,
};
#define DEFAULT_LLHLS_ENABLED TRUE
/* Maximum values for mpeg-ts DTS values */
#define MPEG_TS_MAX_PTS (((((guint64)1) << 33) * (guint64)100000) / 9)
@ -87,6 +96,38 @@ static void gst_hls_demux_stream_finalize (GObject * object);
G_DEFINE_TYPE (GstHLSDemuxStream, gst_hls_demux_stream,
GST_TYPE_ADAPTIVE_DEMUX2_STREAM);
static void
gst_hls_demux_stream_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstHLSDemuxStream *stream = GST_HLS_DEMUX_STREAM (object);
switch (prop_id) {
case PROP_LLHLS_ENABLED:
stream->llhls_enabled = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_hls_demux_stream_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstHLSDemuxStream *stream = GST_HLS_DEMUX_STREAM (object);
switch (prop_id) {
case PROP_LLHLS_ENABLED:
g_value_set_boolean (value, stream->llhls_enabled);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_hls_demux_stream_class_init (GstHLSDemuxStreamClass * klass)
{
@ -94,6 +135,8 @@ gst_hls_demux_stream_class_init (GstHLSDemuxStreamClass * klass)
GstAdaptiveDemux2StreamClass *adaptivedemux2stream_class =
GST_ADAPTIVE_DEMUX2_STREAM_CLASS (klass);
gobject_class->set_property = gst_hls_demux_stream_set_property;
gobject_class->get_property = gst_hls_demux_stream_get_property;
gobject_class->finalize = gst_hls_demux_stream_finalize;
adaptivedemux2stream_class->update_fragment_info =
@ -120,6 +163,11 @@ gst_hls_demux_stream_class_init (GstHLSDemuxStreamClass * klass)
gst_hls_demux_stream_data_received;
adaptivedemux2stream_class->get_presentation_offset =
gst_hls_demux_stream_get_presentation_offset;
g_object_class_install_property (gobject_class, PROP_LLHLS_ENABLED,
g_param_spec_boolean ("llhls-enabled", "Enable LL-HLS support",
"Enable support for LL-HLS (Low Latency HLS) downloads",
DEFAULT_LLHLS_ENABLED, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
@ -130,6 +178,7 @@ gst_hls_demux_stream_init (GstHLSDemuxStream * stream)
stream->reset_pts = TRUE;
stream->presentation_offset = 60 * GST_SECOND;
stream->pdt_tag_sent = FALSE;
stream->llhls_enabled = DEFAULT_LLHLS_ENABLED;
}
void

View file

@ -74,9 +74,6 @@ enum
#define DEFAULT_START_BITRATE 0
#define DEFAULT_LLHLS_ENABLED TRUE
/* Maximum values for mpeg-ts DTS values */
#define MPEG_TS_MAX_PTS (((((guint64)1) << 33) * (guint64)100000) / 9)
/* GObject */
static void gst_hls_demux_finalize (GObject * obj);
@ -171,7 +168,6 @@ gst_hls_demux_get_property (GObject * object, guint prop_id,
}
}
static void
gst_hls_demux2_class_init (GstHLSDemux2Class * klass)
{
@ -408,8 +404,8 @@ create_common_hls_stream (GstHLSDemux * demux, const gchar * name)
{
GstAdaptiveDemux2Stream *stream;
stream = g_object_new (GST_TYPE_HLS_DEMUX_STREAM, "name", name, NULL);
GST_HLS_DEMUX_STREAM (stream)->llhls_enabled = demux->llhls_enabled;
stream = g_object_new (GST_TYPE_HLS_DEMUX_STREAM, "name", name,
"llhls-enabled", demux->llhls_enabled, NULL);
gst_adaptive_demux2_add_stream ((GstAdaptiveDemux *) demux, stream);