display: add utility function to check for OpenGL rendering.

Add gst_vaapi_display_has_opengl() helper function to help determining
whether the display can support OpenGL context to be bound to it, i.e.
if the class is of type GST_VAAPI_DISPLAY_TYPE_GLX.
This commit is contained in:
Gwenole Beauchesne 2014-12-03 11:39:24 +01:00
parent 7d5d3e8640
commit 807c4e8248
4 changed files with 29 additions and 1 deletions

View file

@ -2115,3 +2115,26 @@ gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display)
return NULL; return NULL;
return display->priv.vendor_string; return display->priv.vendor_string;
} }
/**
* gst_vaapi_display_has_opengl:
* @display: a #GstVaapiDisplay
*
* Returns wether the @display that was created does support OpenGL
* context to be attached.
*
* This function is thread safe.
*
* Return value: %TRUE if the @display supports OpenGL context, %FALSE
* otherwise
*/
gboolean
gst_vaapi_display_has_opengl (GstVaapiDisplay * display)
{
GstVaapiDisplayClass *klass;
g_return_val_if_fail (display != NULL, NULL);
klass = GST_VAAPI_DISPLAY_GET_CLASS (display);
return (klass->display_type == GST_VAAPI_DISPLAY_TYPE_GLX);
}

View file

@ -252,6 +252,9 @@ gst_vaapi_display_set_rotation (GstVaapiDisplay * display,
const gchar * const gchar *
gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display); gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display);
gboolean
gst_vaapi_display_has_opengl (GstVaapiDisplay * display);
G_END_DECLS G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_H */ #endif /* GST_VAAPI_DISPLAY_H */

View file

@ -106,6 +106,7 @@ gst_vaapi_texture_new (GstVaapiDisplay * display, guint target, guint format,
GstVaapiDisplayClass *dpy_class; GstVaapiDisplayClass *dpy_class;
g_return_val_if_fail (display != NULL, NULL); g_return_val_if_fail (display != NULL, NULL);
g_return_val_if_fail (gst_vaapi_display_has_opengl (display), NULL);
dpy_class = GST_VAAPI_DISPLAY_GET_CLASS (display); dpy_class = GST_VAAPI_DISPLAY_GET_CLASS (display);
if (G_UNLIKELY (!dpy_class->create_texture)) if (G_UNLIKELY (!dpy_class->create_texture))
@ -144,6 +145,7 @@ gst_vaapi_texture_new_wrapped (GstVaapiDisplay * display, guint id,
GstVaapiDisplayClass *dpy_class; GstVaapiDisplayClass *dpy_class;
g_return_val_if_fail (display != NULL, NULL); g_return_val_if_fail (display != NULL, NULL);
g_return_val_if_fail (gst_vaapi_display_has_opengl (display), NULL);
dpy_class = GST_VAAPI_DISPLAY_GET_CLASS (display); dpy_class = GST_VAAPI_DISPLAY_GET_CLASS (display);
if (G_UNLIKELY (!dpy_class->create_texture)) if (G_UNLIKELY (!dpy_class->create_texture))

View file

@ -90,7 +90,7 @@ gst_vaapi_texture_upload (GstVideoGLTextureUploadMeta * meta,
GstVaapiSurface *const surface = gst_vaapi_surface_proxy_get_surface (proxy); GstVaapiSurface *const surface = gst_vaapi_surface_proxy_get_surface (proxy);
GstVaapiDisplay *const dpy = GST_VAAPI_OBJECT_DISPLAY (surface); GstVaapiDisplay *const dpy = GST_VAAPI_OBJECT_DISPLAY (surface);
if (gst_vaapi_display_get_class_type (dpy) != GST_VAAPI_DISPLAY_TYPE_GLX) if (!gst_vaapi_display_has_opengl (dpy))
return FALSE; return FALSE;
if (!meta_texture->texture || if (!meta_texture->texture ||