mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 06:26:23 +00:00
display: validate display types.
This commit is contained in:
parent
b40cd3b382
commit
b1e5dfab96
13 changed files with 49 additions and 8 deletions
|
@ -391,7 +391,7 @@ gst_vaapi_display_drm_new_with_device(gint device)
|
|||
gint
|
||||
gst_vaapi_display_drm_get_device(GstVaapiDisplayDRM *display)
|
||||
{
|
||||
g_return_val_if_fail(display != NULL, -1);
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_DRM(display), -1);
|
||||
|
||||
return GST_VAAPI_DISPLAY_DRM_DEVICE(display);
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ gst_vaapi_display_drm_get_device(GstVaapiDisplayDRM *display)
|
|||
const gchar *
|
||||
gst_vaapi_display_drm_get_device_path(GstVaapiDisplayDRM *display)
|
||||
{
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_DRM(display), NULL);
|
||||
|
||||
return get_device_path(GST_VAAPI_DISPLAY_CAST(display));
|
||||
}
|
||||
|
|
|
@ -23,9 +23,14 @@
|
|||
#define GST_VAAPI_DISPLAY_DRM_PRIV_H
|
||||
|
||||
#include <gst/vaapi/gstvaapidisplay_drm.h>
|
||||
#include "gstvaapidisplay_priv.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_IS_DISPLAY_DRM(display) \
|
||||
((display) != NULL && \
|
||||
GST_VAAPI_DISPLAY_TYPE(display) == GST_VAAPI_DISPLAY_TYPE_DRM)
|
||||
|
||||
#define GST_VAAPI_DISPLAY_DRM_CAST(display) \
|
||||
((GstVaapiDisplayDRM *)(display))
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_IS_DISPLAY_GLX(display) \
|
||||
((display) != NULL && \
|
||||
GST_VAAPI_DISPLAY_TYPE(display) == GST_VAAPI_DISPLAY_TYPE_GLX)
|
||||
|
||||
#define GST_VAAPI_DISPLAY_GLX_CAST(display) \
|
||||
((GstVaapiDisplayGLX *)(display))
|
||||
|
||||
|
|
|
@ -96,6 +96,16 @@ typedef void (*GstVaapiDisplayGetSizeMFunc)(GstVaapiDisplay *display,
|
|||
#define GST_VAAPI_DISPLAY_UNLOCK(display) \
|
||||
gst_vaapi_display_unlock(GST_VAAPI_DISPLAY_CAST(display))
|
||||
|
||||
/**
|
||||
* GST_VAAPI_DISPLAY_TYPE:
|
||||
* @display: a #GstVaapiDisplay
|
||||
*
|
||||
* Returns the @display type
|
||||
*/
|
||||
#undef GST_VAAPI_DISPLAY_TYPE
|
||||
#define GST_VAAPI_DISPLAY_TYPE(display) \
|
||||
GST_VAAPI_DISPLAY_GET_PRIVATE(display)->display_type
|
||||
|
||||
/**
|
||||
* GST_VAAPI_DISPLAY_TYPES:
|
||||
* @display: a #GstVaapiDisplay
|
||||
|
|
|
@ -420,7 +420,7 @@ gst_vaapi_display_wayland_new_with_display(struct wl_display *wl_display)
|
|||
struct wl_display *
|
||||
gst_vaapi_display_wayland_get_display(GstVaapiDisplayWayland *display)
|
||||
{
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_WAYLAND(display), NULL);
|
||||
|
||||
return GST_VAAPI_DISPLAY_WL_DISPLAY(display);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_IS_DISPLAY_WAYLAND(display) \
|
||||
((display) != NULL && \
|
||||
GST_VAAPI_DISPLAY_TYPE(display) == GST_VAAPI_DISPLAY_TYPE_WAYLAND)
|
||||
|
||||
#define GST_VAAPI_DISPLAY_WAYLAND_CAST(display) \
|
||||
((GstVaapiDisplayWayland *)(display))
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ gst_vaapi_display_x11_new_with_display(Display *x11_display)
|
|||
Display *
|
||||
gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display)
|
||||
{
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), NULL);
|
||||
|
||||
return GST_VAAPI_DISPLAY_XDISPLAY(display);
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display)
|
|||
int
|
||||
gst_vaapi_display_x11_get_screen(GstVaapiDisplayX11 *display)
|
||||
{
|
||||
g_return_val_if_fail(display != NULL, -1);
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), -1);
|
||||
|
||||
return GST_VAAPI_DISPLAY_XSCREEN(display);
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ void
|
|||
gst_vaapi_display_x11_set_synchronous(GstVaapiDisplayX11 *display,
|
||||
gboolean synchronous)
|
||||
{
|
||||
g_return_if_fail(display != NULL);
|
||||
g_return_if_fail(GST_VAAPI_IS_DISPLAY_X11(display));
|
||||
|
||||
set_synchronous(display, synchronous);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,11 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_IS_DISPLAY_X11(display) \
|
||||
((display) != NULL && \
|
||||
(GST_VAAPI_DISPLAY_TYPE(display) == GST_VAAPI_DISPLAY_TYPE_X11 || \
|
||||
GST_VAAPI_DISPLAY_TYPE(display) == GST_VAAPI_DISPLAY_TYPE_GLX))
|
||||
|
||||
#define GST_VAAPI_DISPLAY_X11_CAST(display) \
|
||||
((GstVaapiDisplayX11 *)(display))
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "gstvaapiutils_glx.h"
|
||||
#include "gstvaapidisplay_glx.h"
|
||||
#include "gstvaapidisplay_x11_priv.h"
|
||||
#include "gstvaapidisplay_glx_priv.h"
|
||||
#include "gstvaapiobject_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
|
@ -245,7 +246,7 @@ gst_vaapi_texture_new(
|
|||
{
|
||||
GstVaapiTexture *texture;
|
||||
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_GLX(display), NULL);
|
||||
g_return_val_if_fail(target != GL_NONE, NULL);
|
||||
g_return_val_if_fail(format != GL_NONE, NULL);
|
||||
g_return_val_if_fail(width > 0, NULL);
|
||||
|
@ -297,7 +298,7 @@ gst_vaapi_texture_new_with_texture(
|
|||
GLTextureState ts;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_GLX(display), NULL);
|
||||
g_return_val_if_fail(target != GL_NONE, NULL);
|
||||
g_return_val_if_fail(format != GL_NONE, NULL);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "sysdeps.h"
|
||||
#include "gstvaapiwindow_drm.h"
|
||||
#include "gstvaapiwindow_priv.h"
|
||||
#include "gstvaapidisplay_drm_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
@ -147,6 +148,8 @@ gst_vaapi_window_drm_new(
|
|||
{
|
||||
GST_DEBUG("new window, size %ux%u", width, height);
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_DRM(display), NULL);
|
||||
|
||||
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
|
||||
gst_vaapi_window_drm_class()), display, width, height);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "gstvaapiwindow_x11_priv.h"
|
||||
#include "gstvaapidisplay_x11.h"
|
||||
#include "gstvaapidisplay_x11_priv.h"
|
||||
#include "gstvaapidisplay_glx_priv.h"
|
||||
#include "gstvaapiutils_x11.h"
|
||||
#include "gstvaapiutils_glx.h"
|
||||
|
||||
|
@ -362,6 +363,8 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
|||
GstVaapiWindow *
|
||||
gst_vaapi_window_glx_new(GstVaapiDisplay *display, guint width, guint height)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_GLX(display), NULL);
|
||||
|
||||
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
|
||||
gst_vaapi_window_glx_class()), display, width, height);
|
||||
}
|
||||
|
@ -383,6 +386,7 @@ gst_vaapi_window_glx_new_with_xid(GstVaapiDisplay *display, Window xid)
|
|||
{
|
||||
GST_DEBUG("new window from xid 0x%08x", xid);
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_GLX(display), NULL);
|
||||
g_return_val_if_fail(xid != None, NULL);
|
||||
|
||||
return gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS(
|
||||
|
|
|
@ -411,6 +411,8 @@ gst_vaapi_window_wayland_new(
|
|||
{
|
||||
GST_DEBUG("new window, size %ux%u", width, height);
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_WAYLAND(display), NULL);
|
||||
|
||||
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
|
||||
gst_vaapi_window_wayland_class()), display, width, height);
|
||||
}
|
||||
|
|
|
@ -479,6 +479,8 @@ gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height)
|
|||
{
|
||||
GST_DEBUG("new window, size %ux%u", width, height);
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), NULL);
|
||||
|
||||
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
|
||||
gst_vaapi_window_x11_class()), display, width, height);
|
||||
}
|
||||
|
@ -500,6 +502,7 @@ gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid)
|
|||
{
|
||||
GST_DEBUG("new window from xid 0x%08x", xid);
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), NULL);
|
||||
g_return_val_if_fail(xid != None, NULL);
|
||||
|
||||
return gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS(
|
||||
|
|
Loading…
Reference in a new issue