From 692a8191a881d0e57c1c14f460f4a81aefba4ced Mon Sep 17 00:00:00 2001 From: huang-xl Date: Tue, 19 Sep 2023 11:43:24 +0800 Subject: [PATCH] bitrate first switch Signed-off-by: huang-xl Signed-off-by: huang-xl Change-Id: I83e0175aceed878caba4dae2028c9bd699435a08 --- gstreamer/plugins/elements/gstmultiqueue.c | 11 ++++++++++- gstreamer/plugins/elements/gstmultiqueue.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gstreamer/plugins/elements/gstmultiqueue.c b/gstreamer/plugins/elements/gstmultiqueue.c index 6d22fdfd..31a5f0fc 100644 --- a/gstreamer/plugins/elements/gstmultiqueue.c +++ b/gstreamer/plugins/elements/gstmultiqueue.c @@ -933,6 +933,7 @@ gst_multi_queue_init (GstMultiQueue * mqueue) #ifdef OHOS_EXT_FUNC // ohos.ext.func.0043 Clear data in the multiqueue to speed up switching bitrate mqueue->prev_allow_bitrate = -1; + mqueue->first_bitrate = -1; mqueue->allow_bitrate = -1; mqueue->prev_position = GST_CLOCK_TIME_NONE; mqueue->position = GST_CLOCK_TIME_NONE; @@ -1075,7 +1076,11 @@ gst_multi_queue_set_property (GObject * object, guint prop_id, #ifdef OHOS_EXT_FUNC // ohos.ext.func.0043 Clear data in the multiqueue to speed up switching bitrate case PROP_ALLOW_BITRATE: - mq->prev_allow_bitrate = mq->allow_bitrate; + if (mq->allow_bitrate == -1) { + mq->prev_allow_bitrate = mq->first_bitrate; + } else { + mq->prev_allow_bitrate = mq->allow_bitrate; + } mq->allow_bitrate = g_value_get_int (value); GST_WARNING_OBJECT (mq, "allow_bitrate is %d", mq->allow_bitrate); break; @@ -2214,6 +2219,7 @@ gst_single_queue_push_one (GstMultiQueue * mq, GstSingleQueue * sq, } if (all_eos) { mq->prev_allow_bitrate = -1; + mq->first_bitrate = -1; mq->allow_bitrate = -1; mq->prev_position = GST_CLOCK_TIME_NONE; mq->position = GST_CLOCK_TIME_NONE; @@ -2392,6 +2398,9 @@ next: g_mutex_unlock (&mq->m3u8_lock); return; } + } else { + GST_WARNING_OBJECT (mq, "first bandwidth is %u", bandwidth); + mq->first_bitrate = bandwidth; } if (!sq->drop_mode) { if (mq->position != GST_CLOCK_TIME_NONE) { diff --git a/gstreamer/plugins/elements/gstmultiqueue.h b/gstreamer/plugins/elements/gstmultiqueue.h index 5c2b29ea..7a89ea88 100644 --- a/gstreamer/plugins/elements/gstmultiqueue.h +++ b/gstreamer/plugins/elements/gstmultiqueue.h @@ -99,6 +99,7 @@ struct _GstMultiQueue { #ifdef OHOS_EXT_FUNC // ohos.ext.func.0043 Clear data in the multiqueue to speed up switching bitrate gint prev_allow_bitrate; + gint first_bitrate; gint allow_bitrate; GMutex m3u8_lock; guint64 prev_position; -- Gitee