summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2016-06-28 17:14:06 +0200
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2016-07-22 17:23:23 +0200
commita9e7eac10834b32ca3bdf4402f8b3ffdcedda6bb (patch)
tree3f3b930bf2b130b00d21e38fcc8fd32bd5db8e84
parente070d3ebede3415699e6e72a5c953f304b951279 (diff)
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
-rw-r--r--gst/vaapi/gstvaapipluginbase.c30
-rw-r--r--gst/vaapi/gstvaapipluginutil.c48
-rw-r--r--gst/vaapi/gstvaapipluginutil.h4
3 files changed, 53 insertions, 29 deletions
diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c
index b74dbf4c..b9c57993 100644
--- a/gst/vaapi/gstvaapipluginbase.c
+++ b/gst/vaapi/gstvaapipluginbase.c
@@ -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
diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c
index a88aeba9..de32521d 100644
--- a/gst/vaapi/gstvaapipluginutil.c
+++ b/gst/vaapi/gstvaapipluginutil.c
@@ -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;
+ }
+}
diff --git a/gst/vaapi/gstvaapipluginutil.h b/gst/vaapi/gstvaapipluginutil.h
index 84da876c..5d01ff60 100644
--- a/gst/vaapi/gstvaapipluginutil.h
+++ b/gst/vaapi/gstvaapipluginutil.h
@@ -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 */