From acfabb356166b3a2be3bf5427951c19c615a9fe2 Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Fri, 15 Sep 2017 15:38:18 +0900 Subject: [PATCH] libs: encoder: allow to set bitrate on runtime In case of streaming, controlling bitrate dynamically for encoder might be important to manage quality of the streaming. This patch is to support such a scenario. https://bugzilla.gnome.org/show_bug.cgi?id=786321 --- gst-libs/gst/vaapi/gstvaapiencoder.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index 8befeee..46d40cf 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -1122,18 +1122,14 @@ gst_vaapi_encoder_set_bitrate (GstVaapiEncoder * encoder, guint bitrate) { g_return_val_if_fail (encoder != NULL, 0); - if (encoder->bitrate != bitrate && encoder->num_codedbuf_queued > 0) - goto error_operation_failed; + if (encoder->bitrate != bitrate && encoder->num_codedbuf_queued > 0) { + GST_INFO ("Bitrate is changed to %d on runtime", bitrate); + encoder->bitrate = bitrate; + return gst_vaapi_encoder_reconfigure_internal (encoder); + } encoder->bitrate = bitrate; return GST_VAAPI_ENCODER_STATUS_SUCCESS; - - /* ERRORS */ -error_operation_failed: - { - GST_ERROR ("could not change bitrate value after encoding started"); - return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED; - } } /** -- 2.7.4