plugins: add gst_vaapi_driver_is_whitelisted()

Move some of the logic in gst_vaapi_plugin_base_driver_is_whitelisted() to a
new function gst_vaapi_driver_is_whitelisted(), in this way, it can be used
when registering the plugin's feature set with the test VA display.

https://bugzilla.gnome.org/show_bug.cgi?id=724352
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-06-28 17:14:06 +02:00
parent e070d3ebed
commit a9e7eac108
3 changed files with 53 additions and 29 deletions

View file

@ -34,9 +34,6 @@
/* Default debug category is from the subclass */
#define GST_CAT_DEFAULT (plugin->debug_category)
/* Environment variable for disable driver white-list */
#define GST_VAAPI_ALL_DRIVERS_ENV "GST_VAAPI_ALL_DRIVERS"
/* GstVideoContext interface */
static void
plugin_set_display (GstVaapiPluginBase * plugin, GstVaapiDisplay * display)
@ -89,32 +86,12 @@ gst_vaapi_plugin_base_set_context (GstVaapiPluginBase * plugin,
gboolean
gst_vaapi_plugin_base_driver_is_whitelisted (GstVaapiPluginBase * plugin)
{
const gchar *vendor;
guint i;
GstVaapiDisplay *display;
static const gchar *whitelist[] = {
"Intel i965 driver",
"mesa gallium vaapi",
NULL
};
if (g_getenv (GST_VAAPI_ALL_DRIVERS_ENV))
return TRUE;
display = GST_VAAPI_PLUGIN_BASE_DISPLAY (plugin);
if (!display)
goto no_display;
vendor = gst_vaapi_display_get_vendor_string (display);
if (!vendor)
goto no_vendor;
for (i = 0; whitelist[i]; i++) {
if (g_ascii_strncasecmp (vendor, whitelist[i], strlen (whitelist[i])) == 0)
return TRUE;
}
GST_ERROR ("Unsupported VA driver: %s. Export environment variable "
GST_VAAPI_ALL_DRIVERS_ENV " to bypass", vendor);
return FALSE;
return gst_vaapi_driver_is_whitelisted (display);
/* ERRORS */
no_display:
@ -122,11 +99,6 @@ no_display:
GST_WARNING_OBJECT (plugin, "no VA-API display available");
return FALSE;
}
no_vendor:
{
GST_WARNING_OBJECT (plugin, "no VA-API driver vendor description");
return FALSE;
}
}
void

View file

@ -42,6 +42,9 @@
#include "gstvaapipluginutil.h"
#include "gstvaapipluginbase.h"
/* Environment variable for disable driver white-list */
#define GST_VAAPI_ALL_DRIVERS_ENV "GST_VAAPI_ALL_DRIVERS"
typedef GstVaapiDisplay *(*GstVaapiDisplayCreateFunc) (const gchar *);
typedef GstVaapiDisplay *(*GstVaapiDisplayCreateFromHandleFunc) (gpointer);
@ -722,3 +725,48 @@ gst_vaapi_create_test_display (void)
{
return gst_vaapi_create_display (GST_VAAPI_DISPLAY_TYPE_ANY, NULL);
}
/**
* gst_vaapi_driver_is_whitelisted:
* @display: a #GstVaapiDisplay
*
* Looks the VA-API driver vendors in an internal white-list.
*
* Returns: %TRUE if driver is in the white-list, otherwise %FALSE
**/
gboolean
gst_vaapi_driver_is_whitelisted (GstVaapiDisplay * display)
{
const gchar *vendor;
guint i;
static const gchar *whitelist[] = {
"Intel i965 driver",
"mesa gallium vaapi",
NULL
};
g_return_val_if_fail (display, FALSE);
if (g_getenv (GST_VAAPI_ALL_DRIVERS_ENV))
return TRUE;
vendor = gst_vaapi_display_get_vendor_string (display);
if (!vendor)
goto no_vendor;
for (i = 0; whitelist[i]; i++) {
if (g_ascii_strncasecmp (vendor, whitelist[i], strlen (whitelist[i])) == 0)
return TRUE;
}
GST_ERROR ("Unsupported VA driver: %s. Export environment variable "
GST_VAAPI_ALL_DRIVERS_ENV " to bypass", vendor);
return FALSE;
/* ERRORS */
no_vendor:
{
GST_WARNING ("no VA-API driver vendor description");
return FALSE;
}
}

View file

@ -135,4 +135,8 @@ G_GNUC_INTERNAL
GstVaapiDisplay *
gst_vaapi_create_test_display (void);
G_GNUC_INTERNAL
gboolean
gst_vaapi_driver_is_whitelisted (GstVaapiDisplay * display);
#endif /* GST_VAAPI_PLUGIN_UTIL_H */