videodecoder: Add max-errors property
authorHaakon Sporsheim <haakon@pexip.com>
Mon, 22 Jun 2020 18:36:02 +0000 (21:36 +0300)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 23 Jun 2020 07:17:00 +0000 (07:17 +0000)
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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/720>

gst-libs/gst/video/gstvideodecoder.c

index 57d0ff0..2610f56 100644 (file)
@@ -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;