mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
display: add display types.
Move display types from gstvaapipluginutil.* to gstvaapidisplay.* so that we could simplify characterization of a GstVaapiDisplay. Also rename "auto" type to "any", and add a "display-type" attribute.
This commit is contained in:
parent
411b970f8a
commit
437bc925f6
9 changed files with 93 additions and 46 deletions
|
@ -49,6 +49,7 @@ enum {
|
|||
PROP_0,
|
||||
|
||||
PROP_DISPLAY,
|
||||
PROP_DISPLAY_TYPE,
|
||||
PROP_WIDTH,
|
||||
PROP_HEIGHT
|
||||
};
|
||||
|
@ -80,6 +81,29 @@ free_display_cache(void)
|
|||
g_display_cache = NULL;
|
||||
}
|
||||
|
||||
/* GstVaapiDisplayType enumerations */
|
||||
GType
|
||||
gst_vaapi_display_type_get_type(void)
|
||||
{
|
||||
static GType g_type = 0;
|
||||
|
||||
static const GEnumValue display_types[] = {
|
||||
{ GST_VAAPI_DISPLAY_TYPE_ANY,
|
||||
"Auto detection", "any" },
|
||||
{ GST_VAAPI_DISPLAY_TYPE_X11,
|
||||
"VA/X11 display", "x11" },
|
||||
#if USE_GLX
|
||||
{ GST_VAAPI_DISPLAY_TYPE_GLX,
|
||||
"VA/GLX display", "glx" },
|
||||
#endif
|
||||
{ 0, NULL, NULL },
|
||||
};
|
||||
|
||||
if (!g_type)
|
||||
g_type = g_enum_register_static("GstVaapiDisplayType", display_types);
|
||||
return g_type;
|
||||
}
|
||||
|
||||
/* Append GstVaapiImageFormat to formats array */
|
||||
static inline void
|
||||
append_format(GArray *formats, GstVaapiImageFormat format)
|
||||
|
@ -378,6 +402,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
|
|||
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.display = display;
|
||||
info.display_type = priv->display_type;
|
||||
|
||||
if (priv->display)
|
||||
info.va_display = priv->display;
|
||||
|
@ -388,6 +413,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
|
|||
if (!klass->get_display || !klass->get_display(display, &info))
|
||||
return FALSE;
|
||||
priv->display = info.va_display;
|
||||
priv->display_type = info.display_type;
|
||||
if (klass->get_size)
|
||||
klass->get_size(display, &priv->width, &priv->height);
|
||||
if (klass->get_size_mm)
|
||||
|
@ -407,6 +433,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
|
|||
if (cached_info) {
|
||||
g_clear_object(&priv->parent);
|
||||
priv->parent = g_object_ref(cached_info->display);
|
||||
priv->display_type = cached_info->display_type;
|
||||
}
|
||||
|
||||
if (!priv->parent) {
|
||||
|
@ -567,6 +594,9 @@ gst_vaapi_display_set_property(
|
|||
case PROP_DISPLAY:
|
||||
display->priv->display = g_value_get_pointer(value);
|
||||
break;
|
||||
case PROP_DISPLAY_TYPE:
|
||||
display->priv->display_type = g_value_get_enum(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -587,6 +617,9 @@ gst_vaapi_display_get_property(
|
|||
case PROP_DISPLAY:
|
||||
g_value_set_pointer(value, gst_vaapi_display_get_display(display));
|
||||
break;
|
||||
case PROP_DISPLAY_TYPE:
|
||||
g_value_set_enum(value, gst_vaapi_display_get_display_type(display));
|
||||
break;
|
||||
case PROP_WIDTH:
|
||||
g_value_set_uint(value, gst_vaapi_display_get_width(display));
|
||||
break;
|
||||
|
@ -640,6 +673,16 @@ gst_vaapi_display_class_init(GstVaapiDisplayClass *klass)
|
|||
"VA display",
|
||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_DISPLAY_TYPE,
|
||||
g_param_spec_enum("display-type",
|
||||
"VA display type",
|
||||
"VA display type",
|
||||
GST_VAAPI_TYPE_DISPLAY_TYPE,
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY,
|
||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_WIDTH,
|
||||
|
@ -666,6 +709,7 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
|
|||
|
||||
display->priv = priv;
|
||||
priv->parent = NULL;
|
||||
priv->display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
|
||||
priv->display = NULL;
|
||||
priv->width = 0;
|
||||
priv->height = 0;
|
||||
|
@ -795,6 +839,23 @@ gst_vaapi_display_flush(GstVaapiDisplay *display)
|
|||
klass->flush(display);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_display_get_display:
|
||||
* @display: a #GstVaapiDisplay
|
||||
*
|
||||
* Returns the #GstVaapiDisplayType bound to @display.
|
||||
*
|
||||
* Return value: the #GstVaapiDisplayType
|
||||
*/
|
||||
GstVaapiDisplayType
|
||||
gst_vaapi_display_get_display_type(GstVaapiDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display),
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY);
|
||||
|
||||
return display->priv->display_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_display_get_display:
|
||||
* @display: a #GstVaapiDisplay
|
||||
|
|
|
@ -54,11 +54,30 @@ G_BEGIN_DECLS
|
|||
GST_VAAPI_TYPE_DISPLAY, \
|
||||
GstVaapiDisplayClass))
|
||||
|
||||
typedef enum _GstVaapiDisplayType GstVaapiDisplayType;
|
||||
typedef struct _GstVaapiDisplayInfo GstVaapiDisplayInfo;
|
||||
typedef struct _GstVaapiDisplay GstVaapiDisplay;
|
||||
typedef struct _GstVaapiDisplayPrivate GstVaapiDisplayPrivate;
|
||||
typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass;
|
||||
|
||||
/**
|
||||
* GstVaapiDisplayType:
|
||||
* @GST_VAAPI_DISPLAY_TYPE_ANY: Automatic detection of the display type.
|
||||
* @GST_VAAPI_DISPLAY_TYPE_X11: VA/X11 display.
|
||||
* @GST_VAAPI_DISPLAY_TYPE_GLX: VA/GLX display.
|
||||
*/
|
||||
enum _GstVaapiDisplayType {
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY = 0,
|
||||
GST_VAAPI_DISPLAY_TYPE_X11,
|
||||
GST_VAAPI_DISPLAY_TYPE_GLX,
|
||||
};
|
||||
|
||||
#define GST_VAAPI_TYPE_DISPLAY_TYPE \
|
||||
(gst_vaapi_display_type_get_type())
|
||||
|
||||
GType
|
||||
gst_vaapi_display_type_get_type(void) G_GNUC_CONST;
|
||||
|
||||
/**
|
||||
* GstVaapiDisplayInfo:
|
||||
*
|
||||
|
@ -66,6 +85,7 @@ typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass;
|
|||
*/
|
||||
struct _GstVaapiDisplayInfo {
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiDisplayType display_type;
|
||||
gchar *display_name;
|
||||
VADisplay va_display;
|
||||
gpointer native_display;
|
||||
|
@ -134,6 +154,9 @@ gst_vaapi_display_sync(GstVaapiDisplay *display);
|
|||
void
|
||||
gst_vaapi_display_flush(GstVaapiDisplay *display);
|
||||
|
||||
GstVaapiDisplayType
|
||||
gst_vaapi_display_get_display_type(GstVaapiDisplay *display);
|
||||
|
||||
VADisplay
|
||||
gst_vaapi_display_get_display(GstVaapiDisplay *display);
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ gst_vaapi_display_glx_get_display_info(
|
|||
info->va_display = vaGetDisplayGLX(GST_VAAPI_DISPLAY_XDISPLAY(display));
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_GLX;
|
||||
return dpy_class->get_display(display, info);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ G_BEGIN_DECLS
|
|||
struct _GstVaapiDisplayPrivate {
|
||||
GstVaapiDisplay *parent;
|
||||
GStaticRecMutex mutex;
|
||||
GstVaapiDisplayType display_type;
|
||||
VADisplay display;
|
||||
guint width;
|
||||
guint height;
|
||||
|
|
|
@ -341,6 +341,7 @@ gst_vaapi_display_x11_get_display_info(
|
|||
info->va_display = vaGetDisplay(priv->x11_display);
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_X11;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ cache_entry_new(const GstVaapiDisplayInfo *di)
|
|||
info->display = di->display;
|
||||
info->va_display = di->va_display;
|
||||
info->native_display = di->native_display;
|
||||
info->display_type = di->display_type;
|
||||
info->display_name = NULL;
|
||||
|
||||
if (di->display_name) {
|
||||
|
|
|
@ -71,7 +71,7 @@ gst_vaapi_ensure_display(
|
|||
)
|
||||
{
|
||||
GstVaapiDisplayType display_type =
|
||||
display_type_ptr ? *display_type_ptr : GST_VAAPI_DISPLAY_TYPE_AUTO;
|
||||
display_type_ptr ? *display_type_ptr : GST_VAAPI_DISPLAY_TYPE_ANY;
|
||||
GstVaapiDisplay *display;
|
||||
GstVideoContext *context;
|
||||
const DisplayMap *m;
|
||||
|
@ -89,7 +89,7 @@ gst_vaapi_ensure_display(
|
|||
|
||||
/* If no neighboor, or application not interested, use system default */
|
||||
for (m = g_display_map; m->type_str != NULL; m++) {
|
||||
if (display_type != GST_VAAPI_DISPLAY_TYPE_AUTO &&
|
||||
if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY &&
|
||||
display_type != m->type)
|
||||
continue;
|
||||
|
||||
|
@ -104,7 +104,7 @@ gst_vaapi_ensure_display(
|
|||
display = NULL;
|
||||
}
|
||||
|
||||
if (display_type != GST_VAAPI_DISPLAY_TYPE_AUTO)
|
||||
if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -232,25 +232,3 @@ gst_vaapi_append_surface_caps(GstCaps *out_caps, GstCaps *in_caps)
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_vaapi_display_type_get_type(void)
|
||||
{
|
||||
static GType g_type = 0;
|
||||
|
||||
static const GEnumValue display_types[] = {
|
||||
{ GST_VAAPI_DISPLAY_TYPE_AUTO,
|
||||
"Auto detection", "auto" },
|
||||
{ GST_VAAPI_DISPLAY_TYPE_X11,
|
||||
"VA/X11 display", "x11" },
|
||||
#if USE_GLX
|
||||
{ GST_VAAPI_DISPLAY_TYPE_GLX,
|
||||
"VA/GLX display", "glx" },
|
||||
#endif
|
||||
{ 0, NULL, NULL },
|
||||
};
|
||||
|
||||
if (!g_type)
|
||||
g_type = g_enum_register_static("GstVaapiDisplayType", display_types);
|
||||
return g_type;
|
||||
}
|
||||
|
|
|
@ -26,25 +26,6 @@
|
|||
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
|
||||
/**
|
||||
* GstVaapiDisplayType:
|
||||
* @GST_VAAPI_DISPLAY_TYPE_AUTO: Automatic detection of the display type.
|
||||
* @GST_VAAPI_DISPLAY_TYPE_X11: VA/X11 display.
|
||||
* @GST_VAAPI_DISPLAY_TYPE_GLX: VA/GLX display.
|
||||
*/
|
||||
typedef enum _GstVaapiDisplayType GstVaapiDisplayType;
|
||||
enum _GstVaapiDisplayType {
|
||||
GST_VAAPI_DISPLAY_TYPE_AUTO = 0,
|
||||
GST_VAAPI_DISPLAY_TYPE_X11,
|
||||
GST_VAAPI_DISPLAY_TYPE_GLX,
|
||||
};
|
||||
|
||||
#define GST_VAAPI_TYPE_DISPLAY_TYPE \
|
||||
gst_vaapi_display_type_get_type()
|
||||
|
||||
GType
|
||||
gst_vaapi_display_type_get_type(void) G_GNUC_CONST;
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gst_vaapi_ensure_display(
|
||||
|
|
|
@ -99,7 +99,7 @@ enum {
|
|||
PROP_USE_REFLECTION
|
||||
};
|
||||
|
||||
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_AUTO
|
||||
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY
|
||||
|
||||
/* GstImplementsInterface interface */
|
||||
|
||||
|
@ -818,7 +818,7 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
|||
"display type",
|
||||
"display type to use",
|
||||
GST_VAAPI_TYPE_DISPLAY_TYPE,
|
||||
GST_VAAPI_DISPLAY_TYPE_AUTO,
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
#if USE_GLX
|
||||
|
|
Loading…
Reference in a new issue