From f39b7e97cec9ca3006b26f0b88b161628529c29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 14 Jun 2017 18:31:18 +0200 Subject: [PATCH] vaapidecode_props: h264: add low latency property Adding support for private data. https://bugzilla.gnome.org/show_bug.cgi?id=783588 --- gst/vaapi/gstvaapidecode_props.c | 49 ++++++++++++++++++++++++++++++++ gst/vaapi/gstvaapidecode_props.h | 10 +++++++ 2 files changed, 59 insertions(+) diff --git a/gst/vaapi/gstvaapidecode_props.c b/gst/vaapi/gstvaapidecode_props.c index 895a55e638..b93f06c4bf 100644 --- a/gst/vaapi/gstvaapidecode_props.c +++ b/gst/vaapi/gstvaapidecode_props.c @@ -23,21 +23,70 @@ #include "gstvaapidecode_props.h" +enum +{ + GST_VAAPI_DECODER_H264_PROP_FORCE_LOW_LATENCY = 1, +}; + +static gint h264_private_offset; + static void gst_vaapi_decode_h264_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { + GstVaapiDecodeH264Private *priv; + + priv = gst_vaapi_decode_h264_get_instance_private (object); + + switch (prop_id) { + case GST_VAAPI_DECODER_H264_PROP_FORCE_LOW_LATENCY: + g_value_set_boolean (value, priv->is_low_latency); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } static void gst_vaapi_decode_h264_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { + GstVaapiDecodeH264Private *priv; + + priv = gst_vaapi_decode_h264_get_instance_private (object); + + switch (prop_id) { + case GST_VAAPI_DECODER_H264_PROP_FORCE_LOW_LATENCY: + priv->is_low_latency = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } void gst_vaapi_decode_h264_install_properties (GObjectClass * klass) { + h264_private_offset = sizeof (GstVaapiDecodeH264Private); + g_type_class_adjust_private_offset (klass, &h264_private_offset); + klass->get_property = gst_vaapi_decode_h264_get_property; klass->set_property = gst_vaapi_decode_h264_set_property; + + g_object_class_install_property (klass, + GST_VAAPI_DECODER_H264_PROP_FORCE_LOW_LATENCY, + g_param_spec_boolean ("low-latency", "Force low latency mode", + "When enabled, frames will be pushed as soon as they are available. " + "It might violate the H.264 spec.", FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); +} + +GstVaapiDecodeH264Private * +gst_vaapi_decode_h264_get_instance_private (gpointer self) +{ + if (h264_private_offset == 0) + return NULL; + return (G_STRUCT_MEMBER_P (self, h264_private_offset)); } diff --git a/gst/vaapi/gstvaapidecode_props.h b/gst/vaapi/gstvaapidecode_props.h index 3865c7791d..877754f7ad 100644 --- a/gst/vaapi/gstvaapidecode_props.h +++ b/gst/vaapi/gstvaapidecode_props.h @@ -28,9 +28,19 @@ G_BEGIN_DECLS +typedef struct _GstVaapiDecodeH264Private GstVaapiDecodeH264Private; + +struct _GstVaapiDecodeH264Private +{ + gboolean is_low_latency; +}; + void gst_vaapi_decode_h264_install_properties (GObjectClass * klass); +GstVaapiDecodeH264Private * +gst_vaapi_decode_h264_get_instance_private (gpointer self); + G_END_DECLS #endif /* GST_VAAPI_DECODE_PROPS_H */