struct _GstVaapiDisplayPrivate {
GStaticMutex mutex;
VADisplay display;
+ guint width;
+ guint height;
gboolean create_display;
GArray *profiles;
GArray *image_formats;
enum {
PROP_0,
- PROP_DISPLAY
+ PROP_DISPLAY,
+ PROP_WIDTH,
+ PROP_HEIGHT
};
/* Append GstVaapiImageFormat to formats array */
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;
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;
"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
display->priv = priv;
priv->display = NULL;
+ priv->width = 0;
+ priv->height = 0;
priv->create_display = TRUE;
priv->profiles = NULL;
priv->image_formats = NULL;
}
/**
+ * 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
* @profile: a #VAProfile
* @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.
*/
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
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);
gboolean create_display;
gchar *display_name;
Display *x11_display;
+ int x11_screen;
VADisplay *va_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;
}
}
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)
{
GObjectClass * const object_class = G_OBJECT_CLASS(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:
display->priv = priv;
priv->create_display = TRUE;
priv->x11_display = NULL;
+ priv->x11_screen = 0;
priv->display_name = NULL;
}