vaapidecode: register only the available decoders

In order to register only the available decoders, this patch queries the
created test VA display, which uses the currently used back-end (X11, Wayland,
DRM, …) on the used display device.

https://bugzilla.gnome.org/show_bug.cgi?id=724352
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-07-12 23:47:41 +02:00
parent eb621c970e
commit 5beccf5fa0
3 changed files with 25 additions and 3 deletions

View File

@ -101,6 +101,20 @@ profiles_get_codecs (GArray * profiles)
return codecs;
}
static GArray *
display_get_decoder_codecs (GstVaapiDisplay * display)
{
GArray *profiles, *codecs;
profiles = gst_vaapi_display_get_decode_profiles (display);
if (!profiles)
return NULL;
codecs = profiles_get_codecs (profiles);
g_array_unref (profiles);
return codecs;
}
#if USE_ENCODERS
static GArray *
display_get_encoder_codecs (GstVaapiDisplay * display)
@ -180,6 +194,7 @@ static gboolean
plugin_init (GstPlugin * plugin)
{
GstVaapiDisplay *display;
GArray *decoders;
plugin_add_dependencies (plugin);
@ -189,7 +204,11 @@ plugin_init (GstPlugin * plugin)
if (!gst_vaapi_driver_is_whitelisted (display))
goto unsupported_driver;
gst_vaapidecode_register (plugin);
decoders = display_get_decoder_codecs (display);
if (decoders) {
gst_vaapidecode_register (plugin, decoders);
g_array_unref (decoders);
}
if (gst_vaapi_display_has_video_processing (display)) {
gst_element_register (plugin, "vaapipostproc",

View File

@ -1370,7 +1370,7 @@ gst_vaapidecode_init (GstVaapiDecode * decode)
}
gboolean
gst_vaapidecode_register (GstPlugin * plugin)
gst_vaapidecode_register (GstPlugin * plugin, GArray * decoders)
{
gboolean ret = FALSE;
guint i, codec, rank;
@ -1394,6 +1394,9 @@ gst_vaapidecode_register (GstPlugin * plugin)
rank = vaapi_decode_map[i].rank;
name = vaapi_decode_map[i].name;
if (codec && !gst_vaapi_codecs_has_codec (decoders, codec))
continue;
if (codec) {
type_name = g_strdup_printf ("GstVaapiDecode_%s", name);
element_name = g_strdup_printf ("vaapi%sdec", name);

View File

@ -62,7 +62,7 @@ struct _GstVaapiDecodeClass {
GstVaapiPluginBaseClass parent_class;
};
gboolean gst_vaapidecode_register (GstPlugin * plugin);
gboolean gst_vaapidecode_register (GstPlugin * plugin, GArray * decoders);
G_END_DECLS