* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
+/**
+ * SECTION:gstvaapidisplay_x11
+ * @short_description: VA/X11 display abstraction
+ */
+
#include "config.h"
-#include "vaapi_utils.h"
+#include "gstvaapiutils.h"
#include "gstvaapidisplay_x11.h"
#define DEBUG 1
-#include "vaapi_debug.h"
+#include "gstvaapidebug.h"
G_DEFINE_TYPE(GstVaapiDisplayX11,
gst_vaapi_display_x11,
GstVaapiDisplayX11Private))
struct _GstVaapiDisplayX11Private {
- gboolean create_display;
gchar *display_name;
Display *x11_display;
- VADisplay *va_display;
+ int x11_screen;
+ guint create_display : 1;
+ guint synchronous : 1;
};
enum {
PROP_0,
+ PROP_SYNCHRONOUS,
PROP_DISPLAY_NAME,
PROP_X11_DISPLAY
};
}
static void
+set_synchronous(GstVaapiDisplayX11 *display, gboolean synchronous)
+{
+ GstVaapiDisplayX11Private * const priv = display->priv;
+
+ if (priv->synchronous != synchronous) {
+ priv->synchronous = synchronous;
+ if (priv->x11_display)
+ XSynchronize(priv->x11_display, synchronous);
+ }
+}
+
+static void
gst_vaapi_display_x11_set_property(
GObject *object,
guint prop_id,
GstVaapiDisplayX11 * const display = GST_VAAPI_DISPLAY_X11(object);
switch (prop_id) {
+ case PROP_SYNCHRONOUS:
+ set_synchronous(display, g_value_get_boolean(value));
+ break;
case PROP_DISPLAY_NAME:
set_display_name(display, g_value_get_string(value));
break;
GstVaapiDisplayX11 * const display = GST_VAAPI_DISPLAY_X11(object);
switch (prop_id) {
+ case PROP_SYNCHRONOUS:
+ g_value_set_boolean(value, display->priv->synchronous);
+ break;
case PROP_DISPLAY_NAME:
g_value_set_string(value, display->priv->display_name);
break;
display->priv->create_display = display->priv->x11_display == NULL;
+ /* Reset display-name if the user provided his own X11 display */
+ if (!display->priv->create_display)
+ set_display_name(display, XDisplayString(display->priv->x11_display));
+
parent_class = G_OBJECT_CLASS(gst_vaapi_display_x11_parent_class);
if (parent_class->constructed)
parent_class->constructed(object);
if (!priv->x11_display)
return FALSE;
- priv->va_display = vaGetDisplay(priv->x11_display);
- return priv->va_display != NULL;
+ if (priv->synchronous)
+ XSynchronize(priv->x11_display, True);
+
+ priv->x11_screen = DefaultScreen(priv->x11_display);
+ return TRUE;
}
static void
g_free(priv->display_name);
priv->display_name = NULL;
}
+}
+
+static void
+gst_vaapi_display_x11_sync(GstVaapiDisplay *display)
+{
+ GstVaapiDisplayX11Private * const priv =
+ GST_VAAPI_DISPLAY_X11(display)->priv;
- priv->va_display = NULL;
+ if (priv->x11_display)
+ XSync(priv->x11_display, False);
+}
+
+static void
+gst_vaapi_display_x11_flush(GstVaapiDisplay *display)
+{
+ GstVaapiDisplayX11Private * const priv =
+ GST_VAAPI_DISPLAY_X11(display)->priv;
+
+ if (priv->x11_display)
+ XFlush(priv->x11_display);
}
static VADisplay
gst_vaapi_display_x11_get_va_display(GstVaapiDisplay *display)
{
- return GST_VAAPI_DISPLAY_X11(display)->priv->va_display;
+ return vaGetDisplay(GST_VAAPI_DISPLAY_XDISPLAY(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_get_size_mm(
+ GstVaapiDisplay *display,
+ guint *pwidth,
+ guint *pheight
+)
+{
+ GstVaapiDisplayX11Private * const priv =
+ GST_VAAPI_DISPLAY_X11(display)->priv;
+
+ if (!priv->x11_display)
+ return;
+
+ if (pwidth)
+ *pwidth = DisplayWidthMM(priv->x11_display, priv->x11_screen);
+
+ if (pheight)
+ *pheight = DisplayHeightMM(priv->x11_display, priv->x11_screen);
}
static void
dpy_class->open_display = gst_vaapi_display_x11_open_display;
dpy_class->close_display = gst_vaapi_display_x11_close_display;
+ dpy_class->sync = gst_vaapi_display_x11_sync;
+ dpy_class->flush = gst_vaapi_display_x11_flush;
dpy_class->get_display = gst_vaapi_display_x11_get_va_display;
-
+ dpy_class->get_size = gst_vaapi_display_x11_get_size;
+ dpy_class->get_size_mm = gst_vaapi_display_x11_get_size_mm;
+
+ /**
+ * GstVaapiDisplayX11:synchronous:
+ *
+ * When enabled, runs the X display in synchronous mode. Note that
+ * this is used only for debugging.
+ */
+ g_object_class_install_property
+ (object_class,
+ PROP_SYNCHRONOUS,
+ g_param_spec_boolean("synchronous",
+ "Synchronous mode",
+ "Toggles X display synchronous mode",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ /**
+ * GstVaapiDisplayX11:x11-display:
+ *
+ * The X11 #Display that was created by gst_vaapi_display_x11_new()
+ * or that was bound from gst_vaapi_display_x11_new_with_display().
+ */
g_object_class_install_property
(object_class,
PROP_X11_DISPLAY,
"X11 display",
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+ /**
+ * GstVaapiDisplayX11:display-name:
+ *
+ * The X11 display name.
+ */
g_object_class_install_property
(object_class,
PROP_DISPLAY_NAME,
display->priv = priv;
priv->create_display = TRUE;
priv->x11_display = NULL;
+ priv->x11_screen = 0;
priv->display_name = NULL;
}
+/**
+ * gst_vaapi_display_x11_new:
+ * @display_name: the X11 display name
+ *
+ * Opens an X11 #Display using @display_name and returns a newly
+ * allocated #GstVaapiDisplay object. The X11 display will be cloed
+ * when the reference count of the object reaches zero.
+ *
+ * Return value: a newly allocated #GstVaapiDisplay object
+ */
GstVaapiDisplay *
gst_vaapi_display_x11_new(const gchar *display_name)
{
NULL);
}
+/**
+ * gst_vaapi_display_x11_new_with_display:
+ * @x11_display: an X11 #Display
+ *
+ * Creates a #GstVaapiDisplay based on the X11 @x11_display
+ * display. The caller still owns the display and must call
+ * XCloseDisplay() when all #GstVaapiDisplay references are
+ * released. Doing so too early can yield undefined behaviour.
+ *
+ * Return value: a newly allocated #GstVaapiDisplay object
+ */
GstVaapiDisplay *
gst_vaapi_display_x11_new_with_display(Display *x11_display)
{
NULL);
}
+/**
+ * gst_vaapi_display_x11_get_display:
+ * @display: a #GstVaapiDisplayX11
+ *
+ * Returns the underlying X11 #Display that was created by
+ * gst_vaapi_display_x11_new() or that was bound from
+ * gst_vaapi_display_x11_new_with_display().
+ *
+ * Return value: the X11 #Display attached to @display
+ */
Display *
gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display)
{