From 96ac9bee8ecae2532ff9a53d0a6f3015adc63ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 9 Mar 2016 18:41:49 +0100 Subject: vaapidecode: register decoder with internal GType Don't expose the the vaapidecode GType, instead expose a function which will register element. This is the first step to split the decoder by codecs. https://bugzilla.gnome.org/show_bug.cgi?id=734093 --- gst/vaapi/gstvaapi.c | 4 ++-- gst/vaapi/gstvaapidecode.c | 45 ++++++++++++++++++++++++++++++++++----------- gst/vaapi/gstvaapidecode.h | 3 +-- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/gst/vaapi/gstvaapi.c b/gst/vaapi/gstvaapi.c index dc972609..aabddc35 100644 --- a/gst/vaapi/gstvaapi.c +++ b/gst/vaapi/gstvaapi.c @@ -53,8 +53,8 @@ static gboolean plugin_init (GstPlugin * plugin) { - gst_element_register (plugin, "vaapidecode", - GST_RANK_PRIMARY + 1, GST_TYPE_VAAPIDECODE); + gst_vaapidecode_register (plugin); + gst_element_register (plugin, "vaapipostproc", GST_RANK_PRIMARY, GST_TYPE_VAAPIPOSTPROC); gst_element_register (plugin, "vaapisink", diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index aeb97c36..3c219ec0 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -120,14 +120,10 @@ static GstStaticPadTemplate gst_vaapidecode_src_factory = GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS(gst_vaapidecode_src_caps_str)); - -G_DEFINE_TYPE_WITH_CODE( - GstVaapiDecode, - gst_vaapidecode, - GST_TYPE_VIDEO_DECODER, - GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES) /* *INDENT-ON* */ +static GstElementClass *parent_class = NULL; + static gboolean gst_vaapidecode_update_sink_caps (GstVaapiDecode * decode, GstCaps * caps); static gboolean gst_vaapi_decode_input_state_replace (GstVaapiDecode * decode, @@ -815,7 +811,7 @@ gst_vaapidecode_finalize (GObject * object) g_mutex_clear (&decode->surface_ready_mutex); gst_vaapi_plugin_base_finalize (GST_VAAPI_PLUGIN_BASE (object)); - G_OBJECT_CLASS (gst_vaapidecode_parent_class)->finalize (object); + G_OBJECT_CLASS (parent_class)->finalize (object); } static gboolean @@ -1036,8 +1032,7 @@ gst_vaapidecode_sink_query (GstVideoDecoder * vdec, GstQuery * query) break; } default:{ - ret = GST_VIDEO_DECODER_CLASS (gst_vaapidecode_parent_class)->sink_query - (vdec, query); + ret = GST_VIDEO_DECODER_CLASS (parent_class)->sink_query (vdec, query); break; } } @@ -1075,8 +1070,7 @@ gst_vaapidecode_src_query (GstVideoDecoder * vdec, GstQuery * query) break; } default:{ - ret = GST_VIDEO_DECODER_CLASS (gst_vaapidecode_parent_class)->src_query - (vdec, query); + ret = GST_VIDEO_DECODER_CLASS (parent_class)->src_query (vdec, query); break; } } @@ -1095,6 +1089,8 @@ gst_vaapidecode_class_init (GstVaapiDecodeClass * klass) GST_DEBUG_CATEGORY_INIT (gst_debug_vaapidecode, GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC); + parent_class = g_type_class_peek_parent (klass); + gst_vaapi_plugin_base_class_init (GST_VAAPI_PLUGIN_BASE_CLASS (klass)); object_class->finalize = gst_vaapidecode_finalize; @@ -1147,3 +1143,30 @@ gst_vaapidecode_init (GstVaapiDecode * decode) gst_video_decoder_set_packetized (vdec, FALSE); } + +gboolean +gst_vaapidecode_register (GstPlugin * plugin) +{ + GType type; + GTypeInfo typeinfo = { + sizeof (GstVaapiDecodeClass), + NULL, + NULL, + (GClassInitFunc) gst_vaapidecode_class_init, + NULL, + NULL, + sizeof (GstVaapiDecode), + 0, + (GInstanceInitFunc) gst_vaapidecode_init, + }; + + type = g_type_from_name ("GstVaapiDecode"); + if (!type) { + type = g_type_register_static (GST_TYPE_VIDEO_DECODER, "GstVaapiDecode", + &typeinfo, 0); + gst_vaapi_plugin_base_init_interfaces (type); + } + + return + gst_element_register (plugin, "vaapidecode", GST_RANK_PRIMARY + 1, type); +} diff --git a/gst/vaapi/gstvaapidecode.h b/gst/vaapi/gstvaapidecode.h index 13c57bc0..55d4b36d 100644 --- a/gst/vaapi/gstvaapidecode.h +++ b/gst/vaapi/gstvaapidecode.h @@ -81,8 +81,7 @@ struct _GstVaapiDecodeClass { GstVaapiPluginBaseClass parent_class; }; -GType -gst_vaapidecode_get_type(void) G_GNUC_CONST; +gboolean gst_vaapidecode_register (GstPlugin * plugin); G_END_DECLS -- cgit v1.2.1