mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
Add display size accessors.
This commit is contained in:
parent
cc1c61e917
commit
01cc10fe51
4 changed files with 123 additions and 1 deletions
|
@ -43,6 +43,8 @@ G_DEFINE_TYPE(GstVaapiDisplay, gst_vaapi_display, G_TYPE_OBJECT);
|
|||
struct _GstVaapiDisplayPrivate {
|
||||
GStaticMutex mutex;
|
||||
VADisplay display;
|
||||
guint width;
|
||||
guint height;
|
||||
gboolean create_display;
|
||||
GArray *profiles;
|
||||
GArray *image_formats;
|
||||
|
@ -52,7 +54,9 @@ struct _GstVaapiDisplayPrivate {
|
|||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_DISPLAY
|
||||
PROP_DISPLAY,
|
||||
PROP_WIDTH,
|
||||
PROP_HEIGHT
|
||||
};
|
||||
|
||||
/* Append GstVaapiImageFormat to formats array */
|
||||
|
@ -230,6 +234,8 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
|
|||
return FALSE;
|
||||
if (klass->get_display)
|
||||
priv->display = klass->get_display(display);
|
||||
if (klass->get_size)
|
||||
klass->get_size(display, &priv->width, &priv->height);
|
||||
}
|
||||
if (!priv->display)
|
||||
return FALSE;
|
||||
|
@ -360,6 +366,12 @@ gst_vaapi_display_get_property(
|
|||
case PROP_DISPLAY:
|
||||
g_value_set_pointer(value, gst_vaapi_display_get_display(display));
|
||||
break;
|
||||
case PROP_WIDTH:
|
||||
g_value_set_uint(value, gst_vaapi_display_get_width(display));
|
||||
break;
|
||||
case PROP_HEIGHT:
|
||||
g_value_set_uint(value, gst_vaapi_display_get_height(display));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -405,6 +417,24 @@ gst_vaapi_display_class_init(GstVaapiDisplayClass *klass)
|
|||
"VA display",
|
||||
"VA display",
|
||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_WIDTH,
|
||||
g_param_spec_uint("width",
|
||||
"Width",
|
||||
"The display width",
|
||||
1, G_MAXUINT32, 1,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_HEIGHT,
|
||||
g_param_spec_uint("height",
|
||||
"height",
|
||||
"The display height",
|
||||
1, G_MAXUINT32, 1,
|
||||
G_PARAM_READABLE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -414,6 +444,8 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
|
|||
|
||||
display->priv = priv;
|
||||
priv->display = NULL;
|
||||
priv->width = 0;
|
||||
priv->height = 0;
|
||||
priv->create_display = TRUE;
|
||||
priv->profiles = NULL;
|
||||
priv->image_formats = NULL;
|
||||
|
@ -495,6 +527,58 @@ gst_vaapi_display_get_display(GstVaapiDisplay *display)
|
|||
return display->priv->display;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_display_get_width:
|
||||
* @display: a #GstVaapiDisplay
|
||||
*
|
||||
* Retrieves the width of a #GstVaapiDisplay.
|
||||
*
|
||||
* Return value: the width of the @display, in pixels
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_display_get_width(GstVaapiDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 0);
|
||||
|
||||
return display->priv->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_display_get_height:
|
||||
* @display: a #GstVaapiDisplay
|
||||
*
|
||||
* Retrieves the height of a #GstVaapiDisplay
|
||||
*
|
||||
* Return value: the height of the @display, in pixels
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_display_get_height(GstVaapiDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 0);
|
||||
|
||||
return display->priv->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_display_get_size:
|
||||
* @display: a #GstVaapiDisplay
|
||||
* @pwidth: (out) (allow-none): return location for the width, or %NULL
|
||||
* @pheight: (out) (allow-none): return location for the height, or %NULL
|
||||
*
|
||||
* Retrieves the dimensions of a #GstVaapiDisplay.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_display_get_size(GstVaapiDisplay *display, guint *pwidth, guint *pheight)
|
||||
{
|
||||
g_return_if_fail(GST_VAAPI_DISPLAY(display));
|
||||
|
||||
if (pwidth)
|
||||
*pwidth = display->priv->width;
|
||||
|
||||
if (pheight)
|
||||
*pheight = display->priv->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_display_has_profile:
|
||||
* @display: a #GstVaapiDisplay
|
||||
|
|
|
@ -101,6 +101,7 @@ struct _GstVaapiDisplay {
|
|||
* @lock_display: virtual function to lock a display
|
||||
* @unlock_display: virtual function to unlock a display
|
||||
* @get_display: virtual function to retrieve the #VADisplay
|
||||
* @get_size: virtual function to retrieve the display dimensions
|
||||
*
|
||||
* Base class for VA displays.
|
||||
*/
|
||||
|
@ -114,6 +115,7 @@ struct _GstVaapiDisplayClass {
|
|||
void (*lock_display) (GstVaapiDisplay *display);
|
||||
void (*unlock_display)(GstVaapiDisplay *display);
|
||||
VADisplay (*get_display) (GstVaapiDisplay *display);
|
||||
void (*get_size) (GstVaapiDisplay *display, guint *pw, guint *ph);
|
||||
};
|
||||
|
||||
GType
|
||||
|
@ -131,6 +133,15 @@ gst_vaapi_display_unlock(GstVaapiDisplay *display);
|
|||
VADisplay
|
||||
gst_vaapi_display_get_display(GstVaapiDisplay *display);
|
||||
|
||||
guint
|
||||
gst_vaapi_display_get_width(GstVaapiDisplay *display);
|
||||
|
||||
guint
|
||||
gst_vaapi_display_get_height(GstVaapiDisplay *display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_get_size(GstVaapiDisplay *display, guint *pwidth, guint *pheight);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile);
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ struct _GstVaapiDisplayX11Private {
|
|||
gboolean create_display;
|
||||
gchar *display_name;
|
||||
Display *x11_display;
|
||||
int x11_screen;
|
||||
VADisplay *va_display;
|
||||
};
|
||||
|
||||
|
@ -147,6 +148,7 @@ gst_vaapi_display_x11_open_display(GstVaapiDisplay *display)
|
|||
if (!priv->x11_display)
|
||||
return FALSE;
|
||||
|
||||
priv->x11_screen = DefaultScreen(priv->x11_display);
|
||||
priv->va_display = vaGetDisplay(priv->x11_display);
|
||||
return priv->va_display != NULL;
|
||||
}
|
||||
|
@ -177,6 +179,25 @@ gst_vaapi_display_x11_get_va_display(GstVaapiDisplay *display)
|
|||
return GST_VAAPI_DISPLAY_X11(display)->priv->va_display;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_x11_get_size(
|
||||
GstVaapiDisplay *display,
|
||||
guint *pwidth,
|
||||
guint *pheight
|
||||
)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv = GST_VAAPI_DISPLAY_X11(display)->priv;
|
||||
|
||||
if (!priv->x11_display)
|
||||
return;
|
||||
|
||||
if (pwidth)
|
||||
*pwidth = DisplayWidth(priv->x11_display, priv->x11_screen);
|
||||
|
||||
if (pheight)
|
||||
*pheight = DisplayHeight(priv->x11_display, priv->x11_screen);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
|
||||
{
|
||||
|
@ -193,6 +214,7 @@ gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
|
|||
dpy_class->open_display = gst_vaapi_display_x11_open_display;
|
||||
dpy_class->close_display = gst_vaapi_display_x11_close_display;
|
||||
dpy_class->get_display = gst_vaapi_display_x11_get_va_display;
|
||||
dpy_class->get_size = gst_vaapi_display_x11_get_size;
|
||||
|
||||
/**
|
||||
* GstVaapiDisplayX11:x11-display:
|
||||
|
@ -231,6 +253,7 @@ gst_vaapi_display_x11_init(GstVaapiDisplayX11 *display)
|
|||
display->priv = priv;
|
||||
priv->create_display = TRUE;
|
||||
priv->x11_display = NULL;
|
||||
priv->x11_screen = 0;
|
||||
priv->display_name = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ main(int argc, char *argv[])
|
|||
Display *x11_display;
|
||||
VADisplay va_display;
|
||||
GstVaapiDisplay *display;
|
||||
guint width, height;
|
||||
|
||||
gst_init(&argc, &argv);
|
||||
|
||||
|
@ -105,6 +106,9 @@ main(int argc, char *argv[])
|
|||
if (!display)
|
||||
g_error("could not create Gst/VA display");
|
||||
|
||||
gst_vaapi_display_get_size(display, &width, &height);
|
||||
g_print("Display size: %ux%u\n", width, height);
|
||||
|
||||
dump_caps(display);
|
||||
g_object_unref(display);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue