From 226a371e3f11ac5c825d862ae80f4f6787ca9159 Mon Sep 17 00:00:00 2001 From: Haakon Sporsheim Date: Mon, 22 Jun 2020 21:36:02 +0300 Subject: [PATCH] videodecoder: Add max-errors property The number of consecutive decode errors that should be tolerated before returning flow error should be up to the application, not the element. Hence max-error should be exposed as a property. Part-of: --- gst-libs/gst/video/gstvideodecoder.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 57d0ff0..2610f56 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -289,11 +289,13 @@ GST_DEBUG_CATEGORY (videodecoder_debug); /* properties */ #define DEFAULT_QOS TRUE +#define DEFAULT_MAX_ERRORS GST_VIDEO_DECODER_MAX_ERRORS enum { PROP_0, PROP_QOS, + PROP_MAX_ERRORS, }; struct _GstVideoDecoderPrivate @@ -573,6 +575,20 @@ gst_video_decoder_class_init (GstVideoDecoderClass * klass) g_param_spec_boolean ("qos", "Quality of Service", "Handle Quality-of-Service events from downstream", DEFAULT_QOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + /** + * GstVideoDecoder:max-errors: + * + * Maximum number of tolerated consecutive decode errors. See + * gst_video_decoder_set_max_errors() for more details. + * + * Since: 1.18 + */ + g_object_class_install_property (gobject_class, PROP_MAX_ERRORS, + g_param_spec_int ("max-errors", "Max errors", + "Max consecutive decoder errors before returning flow error", + -1, G_MAXINT, DEFAULT_MAX_ERRORS, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); } static void @@ -831,12 +847,16 @@ static void gst_video_decoder_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - GstVideoDecoderPrivate *priv = GST_VIDEO_DECODER (object)->priv; + GstVideoDecoder *dec = GST_VIDEO_DECODER (object); + GstVideoDecoderPrivate *priv = dec->priv; switch (property_id) { case PROP_QOS: g_value_set_boolean (value, priv->do_qos); break; + case PROP_MAX_ERRORS: + g_value_set_int (value, gst_video_decoder_get_max_errors (dec)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -847,12 +867,16 @@ static void gst_video_decoder_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { - GstVideoDecoderPrivate *priv = GST_VIDEO_DECODER (object)->priv; + GstVideoDecoder *dec = GST_VIDEO_DECODER (object); + GstVideoDecoderPrivate *priv = dec->priv; switch (property_id) { case PROP_QOS: priv->do_qos = g_value_get_boolean (value); break; + case PROP_MAX_ERRORS: + gst_video_decoder_set_max_errors (dec, g_value_get_int (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; -- 2.7.4