mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
display: re-indent all GstVaapiDisplay related source code.
This commit is contained in:
parent
a6fe7698bc
commit
ff0642efad
17 changed files with 2295 additions and 2405 deletions
File diff suppressed because it is too large
Load diff
|
@ -47,22 +47,23 @@ typedef struct _GstVaapiDisplay GstVaapiDisplay;
|
|||
* @GST_VAAPI_DISPLAY_TYPE_WAYLAND: VA/Wayland display.
|
||||
* @GST_VAAPI_DISPLAY_TYPE_DRM: VA/DRM display.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY = 0,
|
||||
GST_VAAPI_DISPLAY_TYPE_X11,
|
||||
GST_VAAPI_DISPLAY_TYPE_GLX,
|
||||
GST_VAAPI_DISPLAY_TYPE_WAYLAND,
|
||||
GST_VAAPI_DISPLAY_TYPE_DRM,
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY = 0,
|
||||
GST_VAAPI_DISPLAY_TYPE_X11,
|
||||
GST_VAAPI_DISPLAY_TYPE_GLX,
|
||||
GST_VAAPI_DISPLAY_TYPE_WAYLAND,
|
||||
GST_VAAPI_DISPLAY_TYPE_DRM,
|
||||
} GstVaapiDisplayType;
|
||||
|
||||
#define GST_VAAPI_TYPE_DISPLAY_TYPE \
|
||||
(gst_vaapi_display_type_get_type())
|
||||
|
||||
GType
|
||||
gst_vaapi_display_type_get_type(void) G_GNUC_CONST;
|
||||
gst_vaapi_display_type_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_type_is_compatible(GstVaapiDisplayType type1,
|
||||
gst_vaapi_display_type_is_compatible (GstVaapiDisplayType type1,
|
||||
GstVaapiDisplayType type2);
|
||||
|
||||
/**
|
||||
|
@ -70,12 +71,13 @@ gst_vaapi_display_type_is_compatible(GstVaapiDisplayType type1,
|
|||
*
|
||||
* Generic class to retrieve VA display info
|
||||
*/
|
||||
struct _GstVaapiDisplayInfo {
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiDisplayType display_type;
|
||||
gchar *display_name;
|
||||
VADisplay va_display;
|
||||
gpointer native_display;
|
||||
struct _GstVaapiDisplayInfo
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiDisplayType display_type;
|
||||
gchar *display_name;
|
||||
VADisplay va_display;
|
||||
gpointer native_display;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -95,122 +97,103 @@ struct _GstVaapiDisplayInfo {
|
|||
#define GST_VAAPI_DISPLAY_PROP_CONTRAST "contrast"
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_new_with_display(VADisplay va_display);
|
||||
gst_vaapi_display_new_with_display (VADisplay va_display);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_ref(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_ref (GstVaapiDisplay * display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_unref(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_unref (GstVaapiDisplay * display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_replace(GstVaapiDisplay **old_display_ptr,
|
||||
GstVaapiDisplay *new_display);
|
||||
gst_vaapi_display_replace (GstVaapiDisplay ** old_display_ptr,
|
||||
GstVaapiDisplay * new_display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_lock(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_lock (GstVaapiDisplay * display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_unlock(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_unlock (GstVaapiDisplay * display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_sync(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_sync (GstVaapiDisplay * display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_flush(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_flush (GstVaapiDisplay * display);
|
||||
|
||||
GstVaapiDisplayType
|
||||
gst_vaapi_display_get_display_type(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_display_type (GstVaapiDisplay * display);
|
||||
|
||||
VADisplay
|
||||
gst_vaapi_display_get_display(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_display (GstVaapiDisplay * display);
|
||||
|
||||
guint
|
||||
gst_vaapi_display_get_width(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_width (GstVaapiDisplay * display);
|
||||
|
||||
guint
|
||||
gst_vaapi_display_get_height(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_height (GstVaapiDisplay * display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_get_size(GstVaapiDisplay *display, guint *pwidth, guint *pheight);
|
||||
gst_vaapi_display_get_size (GstVaapiDisplay * display, guint * pwidth,
|
||||
guint * pheight);
|
||||
|
||||
void
|
||||
gst_vaapi_display_get_pixel_aspect_ratio(
|
||||
GstVaapiDisplay *display,
|
||||
guint *par_n,
|
||||
guint *par_d
|
||||
);
|
||||
gst_vaapi_display_get_pixel_aspect_ratio (GstVaapiDisplay * display,
|
||||
guint * par_n, guint * par_d);
|
||||
|
||||
GstCaps *
|
||||
gst_vaapi_display_get_decode_caps(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_decode_caps (GstVaapiDisplay * display);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_has_decoder(
|
||||
GstVaapiDisplay *display,
|
||||
GstVaapiProfile profile,
|
||||
GstVaapiEntrypoint entrypoint
|
||||
);
|
||||
gst_vaapi_display_has_decoder (GstVaapiDisplay * display,
|
||||
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint);
|
||||
|
||||
GstCaps *
|
||||
gst_vaapi_display_get_encode_caps(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_encode_caps (GstVaapiDisplay * display);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_has_encoder(
|
||||
GstVaapiDisplay *display,
|
||||
GstVaapiProfile profile,
|
||||
GstVaapiEntrypoint entrypoint
|
||||
);
|
||||
gst_vaapi_display_has_encoder (GstVaapiDisplay * display,
|
||||
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint);
|
||||
|
||||
GstCaps *
|
||||
gst_vaapi_display_get_image_caps(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_image_caps (GstVaapiDisplay * display);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_has_image_format(
|
||||
GstVaapiDisplay *display,
|
||||
GstVideoFormat format
|
||||
);
|
||||
gst_vaapi_display_has_image_format (GstVaapiDisplay * display,
|
||||
GstVideoFormat format);
|
||||
|
||||
GstCaps *
|
||||
gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_subpicture_caps (GstVaapiDisplay * display);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_has_subpicture_format(
|
||||
GstVaapiDisplay *display,
|
||||
GstVideoFormat format,
|
||||
guint *flags_ptr
|
||||
);
|
||||
gst_vaapi_display_has_subpicture_format (GstVaapiDisplay * display,
|
||||
GstVideoFormat format, guint * flags_ptr);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_has_property(GstVaapiDisplay *display, const gchar *name);
|
||||
gst_vaapi_display_has_property (GstVaapiDisplay * display, const gchar * name);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_get_property(GstVaapiDisplay *display, const gchar *name,
|
||||
GValue *out_value);
|
||||
gst_vaapi_display_get_property (GstVaapiDisplay * display, const gchar * name,
|
||||
GValue * out_value);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_set_property(GstVaapiDisplay *display, const gchar *name,
|
||||
const GValue *value);
|
||||
gst_vaapi_display_set_property (GstVaapiDisplay * display, const gchar * name,
|
||||
const GValue * value);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_get_render_mode(
|
||||
GstVaapiDisplay *display,
|
||||
GstVaapiRenderMode *pmode
|
||||
);
|
||||
gst_vaapi_display_get_render_mode (GstVaapiDisplay * display,
|
||||
GstVaapiRenderMode * pmode);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_set_render_mode(
|
||||
GstVaapiDisplay *display,
|
||||
GstVaapiRenderMode mode
|
||||
);
|
||||
gst_vaapi_display_set_render_mode (GstVaapiDisplay * display,
|
||||
GstVaapiRenderMode mode);
|
||||
|
||||
GstVaapiRotation
|
||||
gst_vaapi_display_get_rotation(GstVaapiDisplay *display);
|
||||
gst_vaapi_display_get_rotation (GstVaapiDisplay * display);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_display_set_rotation(
|
||||
GstVaapiDisplay *display,
|
||||
GstVaapiRotation rotation
|
||||
);
|
||||
gst_vaapi_display_set_rotation (GstVaapiDisplay * display,
|
||||
GstVaapiRotation rotation);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -44,298 +44,298 @@ static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_DRM;
|
|||
|
||||
/* Get default device path. Actually, the first match in the DRM subsystem */
|
||||
static const gchar *
|
||||
get_default_device_path(GstVaapiDisplay *display)
|
||||
get_default_device_path (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
const gchar *syspath, *devpath;
|
||||
struct udev *udev = NULL;
|
||||
struct udev_device *device, *parent;
|
||||
struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *l;
|
||||
int fd;
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
const gchar *syspath, *devpath;
|
||||
struct udev *udev = NULL;
|
||||
struct udev_device *device, *parent;
|
||||
struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *l;
|
||||
int fd;
|
||||
|
||||
if (!priv->device_path_default) {
|
||||
udev = udev_new();
|
||||
if (!udev)
|
||||
goto end;
|
||||
if (!priv->device_path_default) {
|
||||
udev = udev_new ();
|
||||
if (!udev)
|
||||
goto end;
|
||||
|
||||
e = udev_enumerate_new(udev);
|
||||
if (!e)
|
||||
goto end;
|
||||
e = udev_enumerate_new (udev);
|
||||
if (!e)
|
||||
goto end;
|
||||
|
||||
udev_enumerate_add_match_subsystem(e, "drm");
|
||||
udev_enumerate_scan_devices(e);
|
||||
udev_list_entry_foreach(l, udev_enumerate_get_list_entry(e)) {
|
||||
syspath = udev_list_entry_get_name(l);
|
||||
device = udev_device_new_from_syspath(udev, syspath);
|
||||
parent = udev_device_get_parent(device);
|
||||
if (strcmp(udev_device_get_subsystem(parent), "pci") != 0) {
|
||||
udev_device_unref(device);
|
||||
continue;
|
||||
}
|
||||
udev_enumerate_add_match_subsystem (e, "drm");
|
||||
udev_enumerate_scan_devices (e);
|
||||
udev_list_entry_foreach (l, udev_enumerate_get_list_entry (e)) {
|
||||
syspath = udev_list_entry_get_name (l);
|
||||
device = udev_device_new_from_syspath (udev, syspath);
|
||||
parent = udev_device_get_parent (device);
|
||||
if (strcmp (udev_device_get_subsystem (parent), "pci") != 0) {
|
||||
udev_device_unref (device);
|
||||
continue;
|
||||
}
|
||||
|
||||
devpath = udev_device_get_devnode(device);
|
||||
fd = open(devpath, O_RDWR|O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
udev_device_unref(device);
|
||||
continue;
|
||||
}
|
||||
devpath = udev_device_get_devnode (device);
|
||||
fd = open (devpath, O_RDWR | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
udev_device_unref (device);
|
||||
continue;
|
||||
}
|
||||
|
||||
priv->device_path_default = g_strdup(devpath);
|
||||
close(fd);
|
||||
udev_device_unref(device);
|
||||
break;
|
||||
}
|
||||
|
||||
end:
|
||||
if (e)
|
||||
udev_enumerate_unref(e);
|
||||
if (udev)
|
||||
udev_unref(udev);
|
||||
priv->device_path_default = g_strdup (devpath);
|
||||
close (fd);
|
||||
udev_device_unref (device);
|
||||
break;
|
||||
}
|
||||
return priv->device_path_default;
|
||||
|
||||
end:
|
||||
if (e)
|
||||
udev_enumerate_unref (e);
|
||||
if (udev)
|
||||
udev_unref (udev);
|
||||
}
|
||||
return priv->device_path_default;
|
||||
}
|
||||
|
||||
/* Reconstruct a device path without our prefix */
|
||||
static const gchar *
|
||||
get_device_path(GstVaapiDisplay *display)
|
||||
get_device_path (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
const gchar *device_path = priv->device_path;
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
const gchar *device_path = priv->device_path;
|
||||
|
||||
if (!device_path || *device_path == '\0')
|
||||
return NULL;
|
||||
return device_path;
|
||||
if (!device_path || *device_path == '\0')
|
||||
return NULL;
|
||||
return device_path;
|
||||
}
|
||||
|
||||
/* Mangle device path with our prefix */
|
||||
static gboolean
|
||||
set_device_path(GstVaapiDisplay *display, const gchar *device_path)
|
||||
set_device_path (GstVaapiDisplay * display, const gchar * device_path)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
|
||||
g_free(priv->device_path);
|
||||
priv->device_path = NULL;
|
||||
g_free (priv->device_path);
|
||||
priv->device_path = NULL;
|
||||
|
||||
if (!device_path) {
|
||||
device_path = get_default_device_path(display);
|
||||
if (!device_path)
|
||||
return FALSE;
|
||||
}
|
||||
priv->device_path = g_strdup(device_path);
|
||||
return priv->device_path != NULL;
|
||||
if (!device_path) {
|
||||
device_path = get_default_device_path (display);
|
||||
if (!device_path)
|
||||
return FALSE;
|
||||
}
|
||||
priv->device_path = g_strdup (device_path);
|
||||
return priv->device_path != NULL;
|
||||
}
|
||||
|
||||
/* Set device path from file descriptor */
|
||||
static gboolean
|
||||
set_device_path_from_fd(GstVaapiDisplay *display, gint drm_device)
|
||||
set_device_path_from_fd (GstVaapiDisplay * display, gint drm_device)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
const gchar *busid, *path, *str;
|
||||
gsize busid_length, path_length;
|
||||
struct udev *udev = NULL;
|
||||
struct udev_device *device;
|
||||
struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *l;
|
||||
gboolean success = FALSE;
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
const gchar *busid, *path, *str;
|
||||
gsize busid_length, path_length;
|
||||
struct udev *udev = NULL;
|
||||
struct udev_device *device;
|
||||
struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *l;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_free(priv->device_path);
|
||||
priv->device_path = NULL;
|
||||
g_free (priv->device_path);
|
||||
priv->device_path = NULL;
|
||||
|
||||
if (drm_device < 0)
|
||||
goto end;
|
||||
if (drm_device < 0)
|
||||
goto end;
|
||||
|
||||
busid = drmGetBusid(drm_device);
|
||||
if (!busid)
|
||||
goto end;
|
||||
if (strncmp(busid, "pci:", 4) != 0)
|
||||
goto end;
|
||||
busid += 4;
|
||||
busid_length = strlen(busid);
|
||||
busid = drmGetBusid (drm_device);
|
||||
if (!busid)
|
||||
goto end;
|
||||
if (strncmp (busid, "pci:", 4) != 0)
|
||||
goto end;
|
||||
busid += 4;
|
||||
busid_length = strlen (busid);
|
||||
|
||||
udev = udev_new();
|
||||
if (!udev)
|
||||
goto end;
|
||||
udev = udev_new ();
|
||||
if (!udev)
|
||||
goto end;
|
||||
|
||||
e = udev_enumerate_new(udev);
|
||||
if (!e)
|
||||
goto end;
|
||||
e = udev_enumerate_new (udev);
|
||||
if (!e)
|
||||
goto end;
|
||||
|
||||
udev_enumerate_add_match_subsystem(e, "drm");
|
||||
udev_enumerate_scan_devices(e);
|
||||
udev_list_entry_foreach(l, udev_enumerate_get_list_entry(e)) {
|
||||
path = udev_list_entry_get_name(l);
|
||||
str = strstr(path, busid);
|
||||
if (!str || str <= path || str[-1] != '/')
|
||||
continue;
|
||||
udev_enumerate_add_match_subsystem (e, "drm");
|
||||
udev_enumerate_scan_devices (e);
|
||||
udev_list_entry_foreach (l, udev_enumerate_get_list_entry (e)) {
|
||||
path = udev_list_entry_get_name (l);
|
||||
str = strstr (path, busid);
|
||||
if (!str || str <= path || str[-1] != '/')
|
||||
continue;
|
||||
|
||||
path_length = strlen(path);
|
||||
if (str + busid_length >= path + path_length)
|
||||
continue;
|
||||
if (strncmp(&str[busid_length], "/drm/card", 9) != 0)
|
||||
continue;
|
||||
path_length = strlen (path);
|
||||
if (str + busid_length >= path + path_length)
|
||||
continue;
|
||||
if (strncmp (&str[busid_length], "/drm/card", 9) != 0)
|
||||
continue;
|
||||
|
||||
device = udev_device_new_from_syspath(udev, path);
|
||||
if (!device)
|
||||
continue;
|
||||
device = udev_device_new_from_syspath (udev, path);
|
||||
if (!device)
|
||||
continue;
|
||||
|
||||
path = udev_device_get_devnode(device);
|
||||
priv->device_path = g_strdup(path);
|
||||
udev_device_unref(device);
|
||||
break;
|
||||
}
|
||||
success = TRUE;
|
||||
path = udev_device_get_devnode (device);
|
||||
priv->device_path = g_strdup (path);
|
||||
udev_device_unref (device);
|
||||
break;
|
||||
}
|
||||
success = TRUE;
|
||||
|
||||
end:
|
||||
if (e)
|
||||
udev_enumerate_unref(e);
|
||||
if (udev)
|
||||
udev_unref(udev);
|
||||
return success;
|
||||
if (e)
|
||||
udev_enumerate_unref (e);
|
||||
if (udev)
|
||||
udev_unref (udev);
|
||||
return success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_drm_bind_display(GstVaapiDisplay *display,
|
||||
gst_vaapi_display_drm_bind_display (GstVaapiDisplay * display,
|
||||
gpointer native_display)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
|
||||
priv->drm_device = GPOINTER_TO_INT(native_display);
|
||||
priv->drm_device = GPOINTER_TO_INT (native_display);
|
||||
priv->use_foreign_display = TRUE;
|
||||
|
||||
if (!set_device_path_from_fd (display, priv->drm_device))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_drm_open_display (GstVaapiDisplay * display,
|
||||
const gchar * name)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *info;
|
||||
|
||||
cache = gst_vaapi_display_get_cache ();
|
||||
g_return_val_if_fail (cache != NULL, FALSE);
|
||||
|
||||
if (!set_device_path (display, name))
|
||||
return FALSE;
|
||||
|
||||
info = gst_vaapi_display_cache_lookup_by_name (cache, priv->device_path,
|
||||
GST_VAAPI_DISPLAY_TYPES (display));
|
||||
if (info) {
|
||||
priv->drm_device = GPOINTER_TO_INT (info->native_display);
|
||||
priv->use_foreign_display = TRUE;
|
||||
|
||||
if (!set_device_path_from_fd(display, priv->drm_device))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_drm_open_display(GstVaapiDisplay *display, const gchar *name)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *info;
|
||||
|
||||
cache = gst_vaapi_display_get_cache();
|
||||
g_return_val_if_fail(cache != NULL, FALSE);
|
||||
|
||||
if (!set_device_path(display, name))
|
||||
return FALSE;
|
||||
|
||||
info = gst_vaapi_display_cache_lookup_by_name(cache, priv->device_path,
|
||||
GST_VAAPI_DISPLAY_TYPES(display));
|
||||
if (info) {
|
||||
priv->drm_device = GPOINTER_TO_INT(info->native_display);
|
||||
priv->use_foreign_display = TRUE;
|
||||
}
|
||||
else {
|
||||
priv->drm_device = open(get_device_path(display), O_RDWR|O_CLOEXEC);
|
||||
if (priv->drm_device < 0)
|
||||
return FALSE;
|
||||
priv->use_foreign_display = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
priv->drm_device = open (get_device_path (display), O_RDWR | O_CLOEXEC);
|
||||
if (priv->drm_device < 0)
|
||||
return FALSE;
|
||||
priv->use_foreign_display = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_drm_close_display(GstVaapiDisplay *display)
|
||||
gst_vaapi_display_drm_close_display (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
|
||||
if (priv->drm_device >= 0) {
|
||||
if (!priv->use_foreign_display)
|
||||
close(priv->drm_device);
|
||||
priv->drm_device = -1;
|
||||
}
|
||||
|
||||
if (priv->device_path) {
|
||||
g_free(priv->device_path);
|
||||
priv->device_path = NULL;
|
||||
}
|
||||
|
||||
if (priv->device_path_default) {
|
||||
g_free(priv->device_path_default);
|
||||
priv->device_path_default = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_drm_get_display_info(GstVaapiDisplay *display,
|
||||
GstVaapiDisplayInfo *info)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *cached_info;
|
||||
|
||||
/* Return any cached info even if child has its own VA display */
|
||||
cache = gst_vaapi_display_get_cache();
|
||||
if (!cache)
|
||||
return FALSE;
|
||||
cached_info = gst_vaapi_display_cache_lookup_by_native_display(
|
||||
cache, GINT_TO_POINTER(priv->drm_device),
|
||||
GST_VAAPI_DISPLAY_TYPES(display));
|
||||
if (cached_info) {
|
||||
*info = *cached_info;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Otherwise, create VA display if there is none already */
|
||||
info->native_display = GINT_TO_POINTER(priv->drm_device);
|
||||
info->display_name = priv->device_path;
|
||||
if (!info->va_display) {
|
||||
info->va_display = vaGetDisplayDRM(priv->drm_device);
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_DRM;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_drm_init(GstVaapiDisplay *display)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display);
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
|
||||
if (priv->drm_device >= 0) {
|
||||
if (!priv->use_foreign_display)
|
||||
close (priv->drm_device);
|
||||
priv->drm_device = -1;
|
||||
}
|
||||
|
||||
if (priv->device_path) {
|
||||
g_free (priv->device_path);
|
||||
priv->device_path = NULL;
|
||||
}
|
||||
|
||||
if (priv->device_path_default) {
|
||||
g_free (priv->device_path_default);
|
||||
priv->device_path_default = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_drm_get_display_info (GstVaapiDisplay * display,
|
||||
GstVaapiDisplayInfo * info)
|
||||
{
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *cached_info;
|
||||
|
||||
/* Return any cached info even if child has its own VA display */
|
||||
cache = gst_vaapi_display_get_cache ();
|
||||
if (!cache)
|
||||
return FALSE;
|
||||
cached_info =
|
||||
gst_vaapi_display_cache_lookup_by_native_display (cache,
|
||||
GINT_TO_POINTER (priv->drm_device), GST_VAAPI_DISPLAY_TYPES (display));
|
||||
if (cached_info) {
|
||||
*info = *cached_info;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Otherwise, create VA display if there is none already */
|
||||
info->native_display = GINT_TO_POINTER (priv->drm_device);
|
||||
info->display_name = priv->device_path;
|
||||
if (!info->va_display) {
|
||||
info->va_display = vaGetDisplayDRM (priv->drm_device);
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_DRM;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_drm_class_init(GstVaapiDisplayDRMClass *klass)
|
||||
gst_vaapi_display_drm_init (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiMiniObjectClass * const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS(klass);
|
||||
GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);
|
||||
GstVaapiDisplayDRMPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
||||
|
||||
gst_vaapi_display_class_init(&klass->parent_class);
|
||||
priv->drm_device = -1;
|
||||
}
|
||||
|
||||
object_class->size = sizeof(GstVaapiDisplayDRM);
|
||||
dpy_class->display_types = g_display_types;
|
||||
dpy_class->init = gst_vaapi_display_drm_init;
|
||||
dpy_class->bind_display = gst_vaapi_display_drm_bind_display;
|
||||
dpy_class->open_display = gst_vaapi_display_drm_open_display;
|
||||
dpy_class->close_display = gst_vaapi_display_drm_close_display;
|
||||
dpy_class->get_display = gst_vaapi_display_drm_get_display_info;
|
||||
static void
|
||||
gst_vaapi_display_drm_class_init (GstVaapiDisplayDRMClass * klass)
|
||||
{
|
||||
GstVaapiMiniObjectClass *const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS (klass);
|
||||
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
|
||||
|
||||
gst_vaapi_display_class_init (&klass->parent_class);
|
||||
|
||||
object_class->size = sizeof (GstVaapiDisplayDRM);
|
||||
dpy_class->display_types = g_display_types;
|
||||
dpy_class->init = gst_vaapi_display_drm_init;
|
||||
dpy_class->bind_display = gst_vaapi_display_drm_bind_display;
|
||||
dpy_class->open_display = gst_vaapi_display_drm_open_display;
|
||||
dpy_class->close_display = gst_vaapi_display_drm_close_display;
|
||||
dpy_class->get_display = gst_vaapi_display_drm_get_display_info;
|
||||
}
|
||||
|
||||
static inline const GstVaapiDisplayClass *
|
||||
gst_vaapi_display_drm_class(void)
|
||||
gst_vaapi_display_drm_class (void)
|
||||
{
|
||||
static GstVaapiDisplayDRMClass g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
static GstVaapiDisplayDRMClass g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
|
||||
if (g_once_init_enter(&g_class_init)) {
|
||||
gst_vaapi_display_drm_class_init(&g_class);
|
||||
g_once_init_leave(&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DISPLAY_CLASS(&g_class);
|
||||
if (g_once_init_enter (&g_class_init)) {
|
||||
gst_vaapi_display_drm_class_init (&g_class);
|
||||
g_once_init_leave (&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DISPLAY_CLASS (&g_class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -353,10 +353,10 @@ gst_vaapi_display_drm_class(void)
|
|||
* Return value: a newly allocated #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_drm_new(const gchar *device_path)
|
||||
gst_vaapi_display_drm_new (const gchar * device_path)
|
||||
{
|
||||
return gst_vaapi_display_new(gst_vaapi_display_drm_class(),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer)device_path);
|
||||
return gst_vaapi_display_new (gst_vaapi_display_drm_class (),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) device_path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,12 +371,12 @@ gst_vaapi_display_drm_new(const gchar *device_path)
|
|||
* Return value: a newly allocated #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_drm_new_with_device(gint device)
|
||||
gst_vaapi_display_drm_new_with_device (gint device)
|
||||
{
|
||||
g_return_val_if_fail(device >= 0, NULL);
|
||||
g_return_val_if_fail (device >= 0, NULL);
|
||||
|
||||
return gst_vaapi_display_new(gst_vaapi_display_drm_class(),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, GINT_TO_POINTER(device));
|
||||
return gst_vaapi_display_new (gst_vaapi_display_drm_class (),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, GINT_TO_POINTER (device));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,11 +390,11 @@ gst_vaapi_display_drm_new_with_device(gint device)
|
|||
* Return value: the DRM file descriptor attached to @display
|
||||
*/
|
||||
gint
|
||||
gst_vaapi_display_drm_get_device(GstVaapiDisplayDRM *display)
|
||||
gst_vaapi_display_drm_get_device (GstVaapiDisplayDRM * display)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_DRM(display), -1);
|
||||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_DRM (display), -1);
|
||||
|
||||
return GST_VAAPI_DISPLAY_DRM_DEVICE(display);
|
||||
return GST_VAAPI_DISPLAY_DRM_DEVICE (display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -411,9 +411,9 @@ gst_vaapi_display_drm_get_device(GstVaapiDisplayDRM *display)
|
|||
* Return value: the DRM device path name attached to @display
|
||||
*/
|
||||
const gchar *
|
||||
gst_vaapi_display_drm_get_device_path(GstVaapiDisplayDRM *display)
|
||||
gst_vaapi_display_drm_get_device_path (GstVaapiDisplayDRM * display)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_DRM(display), NULL);
|
||||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_DRM (display), NULL);
|
||||
|
||||
return get_device_path(GST_VAAPI_DISPLAY_CAST(display));
|
||||
return get_device_path (GST_VAAPI_DISPLAY_CAST (display));
|
||||
}
|
||||
|
|
|
@ -33,16 +33,17 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstVaapiDisplayDRM GstVaapiDisplayDRM;
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_drm_new(const gchar *device_path);
|
||||
gst_vaapi_display_drm_new (const gchar * device_path);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_drm_new_with_device(gint device);
|
||||
gst_vaapi_display_drm_new_with_device (gint device);
|
||||
|
||||
gint
|
||||
gst_vaapi_display_drm_get_device(GstVaapiDisplayDRM *display);
|
||||
gst_vaapi_display_drm_get_device (GstVaapiDisplayDRM * display);
|
||||
|
||||
const gchar *
|
||||
gst_vaapi_display_drm_get_device_path(GstVaapiDisplayDRM *display);
|
||||
gst_vaapi_display_drm_get_device_path (GstVaapiDisplayDRM *
|
||||
display);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -51,11 +51,12 @@ typedef struct _GstVaapiDisplayDRMClass GstVaapiDisplayDRMClass;
|
|||
#define GST_VAAPI_DISPLAY_DRM_DEVICE(display) \
|
||||
GST_VAAPI_DISPLAY_DRM_PRIVATE(display)->drm_device
|
||||
|
||||
struct _GstVaapiDisplayDRMPrivate {
|
||||
gchar *device_path_default;
|
||||
gchar *device_path;
|
||||
gint drm_device;
|
||||
guint use_foreign_display : 1; // Foreign native_display?
|
||||
struct _GstVaapiDisplayDRMPrivate
|
||||
{
|
||||
gchar *device_path_default;
|
||||
gchar *device_path;
|
||||
gint drm_device;
|
||||
guint use_foreign_display:1; // Foreign native_display?
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -63,11 +64,12 @@ struct _GstVaapiDisplayDRMPrivate {
|
|||
*
|
||||
* VA/DRM display wrapper.
|
||||
*/
|
||||
struct _GstVaapiDisplayDRM {
|
||||
/*< private >*/
|
||||
GstVaapiDisplay parent_instance;
|
||||
struct _GstVaapiDisplayDRM
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiDisplay parent_instance;
|
||||
|
||||
GstVaapiDisplayDRMPrivate priv;
|
||||
GstVaapiDisplayDRMPrivate priv;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -75,9 +77,10 @@ struct _GstVaapiDisplayDRM {
|
|||
*
|
||||
* VA/DRM display wrapper clas.
|
||||
*/
|
||||
struct _GstVaapiDisplayDRMClass {
|
||||
/*< private >*/
|
||||
GstVaapiDisplayClass parent_class;
|
||||
struct _GstVaapiDisplayDRMClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiDisplayClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -42,47 +42,45 @@
|
|||
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_GLX;
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_glx_get_display_info(
|
||||
GstVaapiDisplay *display,
|
||||
GstVaapiDisplayInfo *info
|
||||
)
|
||||
gst_vaapi_display_glx_get_display_info (GstVaapiDisplay * display,
|
||||
GstVaapiDisplayInfo * info)
|
||||
{
|
||||
const GstVaapiDisplayGLXClass * const klass =
|
||||
GST_VAAPI_DISPLAY_GLX_GET_CLASS(display);
|
||||
const GstVaapiDisplayGLXClass *const klass =
|
||||
GST_VAAPI_DISPLAY_GLX_GET_CLASS (display);
|
||||
|
||||
info->va_display = vaGetDisplayGLX(GST_VAAPI_DISPLAY_XDISPLAY(display));
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_GLX;
|
||||
return klass->parent_get_display(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 klass->parent_get_display (display, info);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_glx_class_init(GstVaapiDisplayGLXClass *klass)
|
||||
gst_vaapi_display_glx_class_init (GstVaapiDisplayGLXClass * klass)
|
||||
{
|
||||
GstVaapiMiniObjectClass * const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS(klass);
|
||||
GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);
|
||||
GstVaapiMiniObjectClass *const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS (klass);
|
||||
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
|
||||
|
||||
gst_vaapi_display_x11_class_init(&klass->parent_class);
|
||||
gst_vaapi_display_x11_class_init (&klass->parent_class);
|
||||
|
||||
object_class->size = sizeof(GstVaapiDisplayGLX);
|
||||
klass->parent_get_display = dpy_class->get_display;
|
||||
dpy_class->display_types = g_display_types;
|
||||
dpy_class->get_display = gst_vaapi_display_glx_get_display_info;
|
||||
object_class->size = sizeof (GstVaapiDisplayGLX);
|
||||
klass->parent_get_display = dpy_class->get_display;
|
||||
dpy_class->display_types = g_display_types;
|
||||
dpy_class->get_display = gst_vaapi_display_glx_get_display_info;
|
||||
}
|
||||
|
||||
static inline const GstVaapiDisplayClass *
|
||||
gst_vaapi_display_glx_class(void)
|
||||
gst_vaapi_display_glx_class (void)
|
||||
{
|
||||
static GstVaapiDisplayGLXClass g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
static GstVaapiDisplayGLXClass g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
|
||||
if (g_once_init_enter(&g_class_init)) {
|
||||
gst_vaapi_display_glx_class_init(&g_class);
|
||||
g_once_init_leave(&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DISPLAY_CLASS(&g_class);
|
||||
if (g_once_init_enter (&g_class_init)) {
|
||||
gst_vaapi_display_glx_class_init (&g_class);
|
||||
g_once_init_leave (&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DISPLAY_CLASS (&g_class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,10 +94,10 @@ gst_vaapi_display_glx_class(void)
|
|||
* Return value: a newly allocated #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_glx_new(const gchar *display_name)
|
||||
gst_vaapi_display_glx_new (const gchar * display_name)
|
||||
{
|
||||
return gst_vaapi_display_new(gst_vaapi_display_glx_class(),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer)display_name);
|
||||
return gst_vaapi_display_new (gst_vaapi_display_glx_class (),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,10 +112,10 @@ gst_vaapi_display_glx_new(const gchar *display_name)
|
|||
* Return value: a newly allocated #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_glx_new_with_display(Display *x11_display)
|
||||
gst_vaapi_display_glx_new_with_display (Display * x11_display)
|
||||
{
|
||||
g_return_val_if_fail(x11_display != NULL, NULL);
|
||||
g_return_val_if_fail (x11_display != NULL, NULL);
|
||||
|
||||
return gst_vaapi_display_new(gst_vaapi_display_glx_class(),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
|
||||
return gst_vaapi_display_new (gst_vaapi_display_glx_class (),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstVaapiDisplayGLX GstVaapiDisplayGLX;
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_glx_new(const gchar *display_name);
|
||||
gst_vaapi_display_glx_new (const gchar * display_name);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_glx_new_with_display(Display *x11_display);
|
||||
gst_vaapi_display_glx_new_with_display (Display * x11_display);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -49,9 +49,10 @@ typedef struct _GstVaapiDisplayGLXClass GstVaapiDisplayGLXClass;
|
|||
*
|
||||
* VA/GLX display wrapper.
|
||||
*/
|
||||
struct _GstVaapiDisplayGLX {
|
||||
/*< private >*/
|
||||
GstVaapiDisplayX11 parent_instance;
|
||||
struct _GstVaapiDisplayGLX
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiDisplayX11 parent_instance;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -59,11 +60,12 @@ struct _GstVaapiDisplayGLX {
|
|||
*
|
||||
* VA/GLX display wrapper clas.
|
||||
*/
|
||||
struct _GstVaapiDisplayGLXClass {
|
||||
/*< private >*/
|
||||
GstVaapiDisplayX11Class parent_class;
|
||||
struct _GstVaapiDisplayGLXClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiDisplayX11Class parent_class;
|
||||
|
||||
GstVaapiDisplayGetInfoFunc parent_get_display;
|
||||
GstVaapiDisplayGetInfoFunc parent_get_display;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -50,22 +50,22 @@ typedef struct _GstVaapiDisplayPrivate GstVaapiDisplayPrivate;
|
|||
typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass;
|
||||
typedef enum _GstVaapiDisplayInitType GstVaapiDisplayInitType;
|
||||
|
||||
typedef void (*GstVaapiDisplayInitFunc) (GstVaapiDisplay *display);
|
||||
typedef gboolean (*GstVaapiDisplayBindFunc) (GstVaapiDisplay *display,
|
||||
typedef void (*GstVaapiDisplayInitFunc) (GstVaapiDisplay * display);
|
||||
typedef gboolean (*GstVaapiDisplayBindFunc) (GstVaapiDisplay * display,
|
||||
gpointer native_dpy);
|
||||
typedef gboolean (*GstVaapiDisplayOpenFunc) (GstVaapiDisplay *display,
|
||||
const gchar *name);
|
||||
typedef void (*GstVaapiDisplayCloseFunc) (GstVaapiDisplay *display);
|
||||
typedef void (*GstVaapiDisplayLockFunc) (GstVaapiDisplay *display);
|
||||
typedef void (*GstVaapiDisplayUnlockFunc) (GstVaapiDisplay *display);
|
||||
typedef void (*GstVaapiDisplaySyncFunc) (GstVaapiDisplay *display);
|
||||
typedef void (*GstVaapiDisplayFlushFunc) (GstVaapiDisplay *display);
|
||||
typedef gboolean (*GstVaapiDisplayGetInfoFunc) (GstVaapiDisplay *display,
|
||||
GstVaapiDisplayInfo *info);
|
||||
typedef void (*GstVaapiDisplayGetSizeFunc) (GstVaapiDisplay *display,
|
||||
guint *pwidth, guint *pheight);
|
||||
typedef void (*GstVaapiDisplayGetSizeMFunc)(GstVaapiDisplay *display,
|
||||
guint *pwidth, guint *pheight);
|
||||
typedef gboolean (*GstVaapiDisplayOpenFunc) (GstVaapiDisplay * display,
|
||||
const gchar * name);
|
||||
typedef void (*GstVaapiDisplayCloseFunc) (GstVaapiDisplay * display);
|
||||
typedef void (*GstVaapiDisplayLockFunc) (GstVaapiDisplay * display);
|
||||
typedef void (*GstVaapiDisplayUnlockFunc) (GstVaapiDisplay * display);
|
||||
typedef void (*GstVaapiDisplaySyncFunc) (GstVaapiDisplay * display);
|
||||
typedef void (*GstVaapiDisplayFlushFunc) (GstVaapiDisplay * display);
|
||||
typedef gboolean (*GstVaapiDisplayGetInfoFunc) (GstVaapiDisplay * display,
|
||||
GstVaapiDisplayInfo * info);
|
||||
typedef void (*GstVaapiDisplayGetSizeFunc) (GstVaapiDisplay * display,
|
||||
guint * pwidth, guint * pheight);
|
||||
typedef void (*GstVaapiDisplayGetSizeMFunc) (GstVaapiDisplay * display,
|
||||
guint * pwidth, guint * pheight);
|
||||
|
||||
/**
|
||||
* GST_VAAPI_DISPLAY_VADISPLAY:
|
||||
|
@ -128,24 +128,25 @@ typedef void (*GstVaapiDisplayGetSizeMFunc)(GstVaapiDisplay *display,
|
|||
#define GST_VAAPI_DISPLAY_HAS_VPP(display) \
|
||||
(GST_VAAPI_DISPLAY_GET_PRIVATE(display)->has_vpp)
|
||||
|
||||
struct _GstVaapiDisplayPrivate {
|
||||
GstVaapiDisplay *parent;
|
||||
GRecMutex mutex;
|
||||
GstVaapiDisplayType display_type;
|
||||
VADisplay display;
|
||||
guint width;
|
||||
guint height;
|
||||
guint width_mm;
|
||||
guint height_mm;
|
||||
guint par_n;
|
||||
guint par_d;
|
||||
GArray *decoders;
|
||||
GArray *encoders;
|
||||
GArray *image_formats;
|
||||
GArray *subpicture_formats;
|
||||
GArray *properties;
|
||||
guint use_foreign_display : 1;
|
||||
guint has_vpp : 1;
|
||||
struct _GstVaapiDisplayPrivate
|
||||
{
|
||||
GstVaapiDisplay *parent;
|
||||
GRecMutex mutex;
|
||||
GstVaapiDisplayType display_type;
|
||||
VADisplay display;
|
||||
guint width;
|
||||
guint height;
|
||||
guint width_mm;
|
||||
guint height_mm;
|
||||
guint par_n;
|
||||
guint par_d;
|
||||
GArray *decoders;
|
||||
GArray *encoders;
|
||||
GArray *image_formats;
|
||||
GArray *subpicture_formats;
|
||||
GArray *properties;
|
||||
guint use_foreign_display:1;
|
||||
guint has_vpp:1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -153,11 +154,12 @@ struct _GstVaapiDisplayPrivate {
|
|||
*
|
||||
* Base class for VA displays.
|
||||
*/
|
||||
struct _GstVaapiDisplay {
|
||||
/*< private >*/
|
||||
GstVaapiMiniObject parent_instance;
|
||||
struct _GstVaapiDisplay
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiMiniObject parent_instance;
|
||||
|
||||
GstVaapiDisplayPrivate priv;
|
||||
GstVaapiDisplayPrivate priv;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -174,51 +176,53 @@ struct _GstVaapiDisplay {
|
|||
*
|
||||
* Base class for VA displays.
|
||||
*/
|
||||
struct _GstVaapiDisplayClass {
|
||||
/*< private >*/
|
||||
GstVaapiMiniObjectClass parent_class;
|
||||
struct _GstVaapiDisplayClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiMiniObjectClass parent_class;
|
||||
|
||||
/*< protected >*/
|
||||
guint display_types;
|
||||
/*< protected >*/
|
||||
guint display_types;
|
||||
|
||||
/*< public >*/
|
||||
GstVaapiDisplayInitFunc init;
|
||||
GstVaapiDisplayBindFunc bind_display;
|
||||
GstVaapiDisplayOpenFunc open_display;
|
||||
GstVaapiDisplayCloseFunc close_display;
|
||||
GstVaapiDisplayLockFunc lock;
|
||||
GstVaapiDisplayUnlockFunc unlock;
|
||||
GstVaapiDisplaySyncFunc sync;
|
||||
GstVaapiDisplayFlushFunc flush;
|
||||
GstVaapiDisplayGetInfoFunc get_display;
|
||||
GstVaapiDisplayGetSizeFunc get_size;
|
||||
GstVaapiDisplayGetSizeMFunc get_size_mm;
|
||||
/*< public >*/
|
||||
GstVaapiDisplayInitFunc init;
|
||||
GstVaapiDisplayBindFunc bind_display;
|
||||
GstVaapiDisplayOpenFunc open_display;
|
||||
GstVaapiDisplayCloseFunc close_display;
|
||||
GstVaapiDisplayLockFunc lock;
|
||||
GstVaapiDisplayUnlockFunc unlock;
|
||||
GstVaapiDisplaySyncFunc sync;
|
||||
GstVaapiDisplayFlushFunc flush;
|
||||
GstVaapiDisplayGetInfoFunc get_display;
|
||||
GstVaapiDisplayGetSizeFunc get_size;
|
||||
GstVaapiDisplayGetSizeMFunc get_size_mm;
|
||||
};
|
||||
|
||||
/* Initialization types */
|
||||
enum _GstVaapiDisplayInitType {
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME = 1,
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY,
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY
|
||||
enum _GstVaapiDisplayInitType
|
||||
{
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME = 1,
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY,
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY
|
||||
};
|
||||
|
||||
void
|
||||
gst_vaapi_display_class_init(GstVaapiDisplayClass *klass);
|
||||
gst_vaapi_display_class_init (GstVaapiDisplayClass * klass);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_new(const GstVaapiDisplayClass *klass,
|
||||
gst_vaapi_display_new (const GstVaapiDisplayClass * klass,
|
||||
GstVaapiDisplayInitType init_type, gpointer init_value);
|
||||
|
||||
GstVaapiDisplayCache *
|
||||
gst_vaapi_display_get_cache(void);
|
||||
gst_vaapi_display_get_cache (void);
|
||||
|
||||
static inline guint
|
||||
gst_vaapi_display_get_display_types(GstVaapiDisplay *display)
|
||||
gst_vaapi_display_get_display_types (GstVaapiDisplay * display)
|
||||
{
|
||||
const GstVaapiDisplayClass * const dpy_class =
|
||||
GST_VAAPI_DISPLAY_GET_CLASS(display);
|
||||
const GstVaapiDisplayClass *const dpy_class =
|
||||
GST_VAAPI_DISPLAY_GET_CLASS (display);
|
||||
|
||||
return dpy_class->display_types;
|
||||
return dpy_class->display_types;
|
||||
}
|
||||
|
||||
/* Inline reference counting for core libgstvaapi library */
|
||||
|
|
|
@ -38,348 +38,334 @@
|
|||
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_WAYLAND;
|
||||
|
||||
static inline const gchar *
|
||||
get_default_display_name(void)
|
||||
get_default_display_name (void)
|
||||
{
|
||||
static const gchar *g_display_name;
|
||||
static const gchar *g_display_name;
|
||||
|
||||
if (!g_display_name)
|
||||
g_display_name = getenv("WAYLAND_DISPLAY");
|
||||
return g_display_name;
|
||||
if (!g_display_name)
|
||||
g_display_name = getenv ("WAYLAND_DISPLAY");
|
||||
return g_display_name;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
get_display_name_length(const gchar *display_name)
|
||||
get_display_name_length (const gchar * display_name)
|
||||
{
|
||||
const gchar *str;
|
||||
const gchar *str;
|
||||
|
||||
str = strchr(display_name, '-');
|
||||
if (str)
|
||||
return str - display_name;
|
||||
return strlen(display_name);
|
||||
str = strchr (display_name, '-');
|
||||
if (str)
|
||||
return str - display_name;
|
||||
return strlen (display_name);
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_display_name(gconstpointer a, gconstpointer b)
|
||||
compare_display_name (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const GstVaapiDisplayInfo * const info = a;
|
||||
const gchar *cached_name = info->display_name;
|
||||
const gchar *tested_name = b;
|
||||
guint cached_name_length, tested_name_length;
|
||||
const GstVaapiDisplayInfo *const info = a;
|
||||
const gchar *cached_name = info->display_name;
|
||||
const gchar *tested_name = b;
|
||||
guint cached_name_length, tested_name_length;
|
||||
|
||||
g_return_val_if_fail(cached_name, FALSE);
|
||||
g_return_val_if_fail(tested_name, FALSE);
|
||||
g_return_val_if_fail (cached_name, FALSE);
|
||||
g_return_val_if_fail (tested_name, FALSE);
|
||||
|
||||
cached_name_length = get_display_name_length(cached_name);
|
||||
tested_name_length = get_display_name_length(tested_name);
|
||||
cached_name_length = get_display_name_length (cached_name);
|
||||
tested_name_length = get_display_name_length (tested_name);
|
||||
|
||||
/* XXX: handle screen number and default WAYLAND_DISPLAY name */
|
||||
if (cached_name_length != tested_name_length)
|
||||
return FALSE;
|
||||
if (strncmp(cached_name, tested_name, cached_name_length) != 0)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
/* XXX: handle screen number and default WAYLAND_DISPLAY name */
|
||||
if (cached_name_length != tested_name_length)
|
||||
return FALSE;
|
||||
if (strncmp (cached_name, tested_name, cached_name_length) != 0)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Mangle display name with our prefix */
|
||||
static gboolean
|
||||
set_display_name(GstVaapiDisplay *display, const gchar *display_name)
|
||||
set_display_name (GstVaapiDisplay * display, const gchar * display_name)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
|
||||
g_free(priv->display_name);
|
||||
g_free (priv->display_name);
|
||||
|
||||
if (!display_name) {
|
||||
display_name = get_default_display_name();
|
||||
if (!display_name)
|
||||
display_name = "";
|
||||
}
|
||||
priv->display_name = g_strdup(display_name);
|
||||
return priv->display_name != NULL;
|
||||
if (!display_name) {
|
||||
display_name = get_default_display_name ();
|
||||
if (!display_name)
|
||||
display_name = "";
|
||||
}
|
||||
priv->display_name = g_strdup (display_name);
|
||||
return priv->display_name != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
output_handle_geometry(void *data, struct wl_output *output,
|
||||
int x, int y, int physical_width, int physical_height,
|
||||
int subpixel, const char *make, const char *model,
|
||||
int transform)
|
||||
output_handle_geometry (void *data, struct wl_output *output,
|
||||
int x, int y, int physical_width, int physical_height,
|
||||
int subpixel, const char *make, const char *model, int transform)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv = data;
|
||||
GstVaapiDisplayWaylandPrivate *const priv = data;
|
||||
|
||||
priv->phys_width = physical_width;
|
||||
priv->phys_height = physical_height;
|
||||
priv->phys_width = physical_width;
|
||||
priv->phys_height = physical_height;
|
||||
}
|
||||
|
||||
static void
|
||||
output_handle_mode(void *data, struct wl_output *wl_output,
|
||||
uint32_t flags, int width, int height, int refresh)
|
||||
output_handle_mode (void *data, struct wl_output *wl_output,
|
||||
uint32_t flags, int width, int height, int refresh)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv = data;
|
||||
GstVaapiDisplayWaylandPrivate *const priv = data;
|
||||
|
||||
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
||||
priv->width = width;
|
||||
priv->height = height;
|
||||
}
|
||||
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
||||
priv->width = width;
|
||||
priv->height = height;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_output_listener output_listener = {
|
||||
output_handle_geometry,
|
||||
output_handle_mode,
|
||||
output_handle_geometry,
|
||||
output_handle_mode,
|
||||
};
|
||||
|
||||
static void
|
||||
registry_handle_global(
|
||||
void *data,
|
||||
registry_handle_global (void *data,
|
||||
struct wl_registry *registry,
|
||||
uint32_t id,
|
||||
const char *interface,
|
||||
uint32_t version
|
||||
)
|
||||
uint32_t id, const char *interface, uint32_t version)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv = data;
|
||||
GstVaapiDisplayWaylandPrivate *const priv = data;
|
||||
|
||||
if (strcmp(interface, "wl_compositor") == 0)
|
||||
priv->compositor =
|
||||
wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
||||
else if (strcmp(interface, "wl_shell") == 0)
|
||||
priv->shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
|
||||
else if (strcmp(interface, "wl_output") == 0) {
|
||||
priv->output = wl_registry_bind(registry, id, &wl_output_interface, 1);
|
||||
wl_output_add_listener(priv->output, &output_listener, priv);
|
||||
}
|
||||
if (strcmp (interface, "wl_compositor") == 0)
|
||||
priv->compositor =
|
||||
wl_registry_bind (registry, id, &wl_compositor_interface, 1);
|
||||
else if (strcmp (interface, "wl_shell") == 0)
|
||||
priv->shell = wl_registry_bind (registry, id, &wl_shell_interface, 1);
|
||||
else if (strcmp (interface, "wl_output") == 0) {
|
||||
priv->output = wl_registry_bind (registry, id, &wl_output_interface, 1);
|
||||
wl_output_add_listener (priv->output, &output_listener, priv);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_registry_listener registry_listener = {
|
||||
registry_handle_global,
|
||||
NULL,
|
||||
registry_handle_global,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_wayland_setup(GstVaapiDisplay *display)
|
||||
gst_vaapi_display_wayland_setup (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
|
||||
wl_display_set_user_data(priv->wl_display, priv);
|
||||
priv->registry = wl_display_get_registry(priv->wl_display);
|
||||
wl_registry_add_listener(priv->registry, ®istry_listener, priv);
|
||||
priv->event_fd = wl_display_get_fd(priv->wl_display);
|
||||
wl_display_roundtrip(priv->wl_display);
|
||||
wl_display_set_user_data (priv->wl_display, priv);
|
||||
priv->registry = wl_display_get_registry (priv->wl_display);
|
||||
wl_registry_add_listener (priv->registry, ®istry_listener, priv);
|
||||
priv->event_fd = wl_display_get_fd (priv->wl_display);
|
||||
wl_display_roundtrip (priv->wl_display);
|
||||
|
||||
if (!priv->width || !priv->height) {
|
||||
wl_display_roundtrip (priv->wl_display);
|
||||
if (!priv->width || !priv->height) {
|
||||
wl_display_roundtrip(priv->wl_display);
|
||||
if (!priv->width || !priv->height) {
|
||||
GST_ERROR("failed to determine the display size");
|
||||
return FALSE;
|
||||
}
|
||||
GST_ERROR ("failed to determine the display size");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!priv->compositor) {
|
||||
GST_ERROR("failed to bind compositor interface");
|
||||
return FALSE;
|
||||
}
|
||||
if (!priv->compositor) {
|
||||
GST_ERROR ("failed to bind compositor interface");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!priv->shell) {
|
||||
GST_ERROR("failed to bind shell interface");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
if (!priv->shell) {
|
||||
GST_ERROR ("failed to bind shell interface");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_wayland_bind_display(GstVaapiDisplay *display,
|
||||
gst_vaapi_display_wayland_bind_display (GstVaapiDisplay * display,
|
||||
gpointer native_display)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
|
||||
priv->wl_display = native_display;
|
||||
priv->wl_display = native_display;
|
||||
priv->use_foreign_display = TRUE;
|
||||
|
||||
/* XXX: how to get socket/display name? */
|
||||
GST_WARNING ("wayland: get display name");
|
||||
set_display_name (display, NULL);
|
||||
|
||||
return gst_vaapi_display_wayland_setup (display);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_wayland_open_display (GstVaapiDisplay * display,
|
||||
const gchar * name)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *info;
|
||||
|
||||
cache = gst_vaapi_display_get_cache ();
|
||||
g_return_val_if_fail (cache != NULL, FALSE);
|
||||
|
||||
if (!set_display_name (display, name))
|
||||
return FALSE;
|
||||
|
||||
info = gst_vaapi_display_cache_lookup_custom (cache, compare_display_name,
|
||||
priv->display_name, GST_VAAPI_DISPLAY_TYPES (display));
|
||||
if (info) {
|
||||
priv->wl_display = info->native_display;
|
||||
priv->use_foreign_display = TRUE;
|
||||
|
||||
/* XXX: how to get socket/display name? */
|
||||
GST_WARNING("wayland: get display name");
|
||||
set_display_name(display, NULL);
|
||||
|
||||
return gst_vaapi_display_wayland_setup(display);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_wayland_open_display(GstVaapiDisplay *display,
|
||||
const gchar *name)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *info;
|
||||
|
||||
cache = gst_vaapi_display_get_cache();
|
||||
g_return_val_if_fail(cache != NULL, FALSE);
|
||||
|
||||
if (!set_display_name(display, name))
|
||||
return FALSE;
|
||||
|
||||
info = gst_vaapi_display_cache_lookup_custom(cache, compare_display_name,
|
||||
priv->display_name, GST_VAAPI_DISPLAY_TYPES(display));
|
||||
if (info) {
|
||||
priv->wl_display = info->native_display;
|
||||
priv->use_foreign_display = TRUE;
|
||||
}
|
||||
else {
|
||||
priv->wl_display = wl_display_connect(name);
|
||||
if (!priv->wl_display)
|
||||
return FALSE;
|
||||
priv->use_foreign_display = FALSE;
|
||||
}
|
||||
return gst_vaapi_display_wayland_setup(display);
|
||||
} else {
|
||||
priv->wl_display = wl_display_connect (name);
|
||||
if (!priv->wl_display)
|
||||
return FALSE;
|
||||
priv->use_foreign_display = FALSE;
|
||||
}
|
||||
return gst_vaapi_display_wayland_setup (display);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_wayland_close_display(GstVaapiDisplay * display)
|
||||
gst_vaapi_display_wayland_close_display (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
|
||||
if (priv->output) {
|
||||
wl_output_destroy(priv->output);
|
||||
priv->output = NULL;
|
||||
}
|
||||
if (priv->output) {
|
||||
wl_output_destroy (priv->output);
|
||||
priv->output = NULL;
|
||||
}
|
||||
|
||||
if (priv->shell) {
|
||||
wl_shell_destroy(priv->shell);
|
||||
priv->shell = NULL;
|
||||
}
|
||||
if (priv->shell) {
|
||||
wl_shell_destroy (priv->shell);
|
||||
priv->shell = NULL;
|
||||
}
|
||||
|
||||
if (priv->compositor) {
|
||||
wl_compositor_destroy(priv->compositor);
|
||||
priv->compositor = NULL;
|
||||
}
|
||||
if (priv->compositor) {
|
||||
wl_compositor_destroy (priv->compositor);
|
||||
priv->compositor = NULL;
|
||||
}
|
||||
|
||||
if (priv->wl_display) {
|
||||
if (!priv->use_foreign_display)
|
||||
wl_display_disconnect(priv->wl_display);
|
||||
priv->wl_display = NULL;
|
||||
}
|
||||
if (priv->wl_display) {
|
||||
if (!priv->use_foreign_display)
|
||||
wl_display_disconnect (priv->wl_display);
|
||||
priv->wl_display = NULL;
|
||||
}
|
||||
|
||||
if (priv->display_name) {
|
||||
g_free(priv->display_name);
|
||||
priv->display_name = NULL;
|
||||
}
|
||||
if (priv->display_name) {
|
||||
g_free (priv->display_name);
|
||||
priv->display_name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_wayland_get_display_info(
|
||||
GstVaapiDisplay *display,
|
||||
GstVaapiDisplayInfo *info
|
||||
)
|
||||
gst_vaapi_display_wayland_get_display_info (GstVaapiDisplay * display,
|
||||
GstVaapiDisplayInfo * info)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *cached_info;
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *cached_info;
|
||||
|
||||
/* Return any cached info even if child has its own VA display */
|
||||
cache = gst_vaapi_display_get_cache();
|
||||
if (!cache)
|
||||
return FALSE;
|
||||
cached_info = gst_vaapi_display_cache_lookup_by_native_display(cache,
|
||||
priv->wl_display, GST_VAAPI_DISPLAY_TYPES(display));
|
||||
if (cached_info) {
|
||||
*info = *cached_info;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Otherwise, create VA display if there is none already */
|
||||
info->native_display = priv->wl_display;
|
||||
info->display_name = priv->display_name;
|
||||
if (!info->va_display) {
|
||||
info->va_display = vaGetDisplayWl(priv->wl_display);
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND;
|
||||
}
|
||||
/* Return any cached info even if child has its own VA display */
|
||||
cache = gst_vaapi_display_get_cache ();
|
||||
if (!cache)
|
||||
return FALSE;
|
||||
cached_info = gst_vaapi_display_cache_lookup_by_native_display (cache,
|
||||
priv->wl_display, GST_VAAPI_DISPLAY_TYPES (display));
|
||||
if (cached_info) {
|
||||
*info = *cached_info;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Otherwise, create VA display if there is none already */
|
||||
info->native_display = priv->wl_display;
|
||||
info->display_name = priv->display_name;
|
||||
if (!info->va_display) {
|
||||
info->va_display = vaGetDisplayWl (priv->wl_display);
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_wayland_get_size(
|
||||
GstVaapiDisplay *display,
|
||||
guint *pwidth,
|
||||
guint *pheight
|
||||
)
|
||||
gst_vaapi_display_wayland_get_size (GstVaapiDisplay * display,
|
||||
guint * pwidth, guint * pheight)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
|
||||
if (!priv->output)
|
||||
return;
|
||||
if (!priv->output)
|
||||
return;
|
||||
|
||||
if (pwidth)
|
||||
*pwidth = priv->width;
|
||||
if (pwidth)
|
||||
*pwidth = priv->width;
|
||||
|
||||
if (pheight)
|
||||
*pheight = priv->height;
|
||||
if (pheight)
|
||||
*pheight = priv->height;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_wayland_get_size_mm(
|
||||
GstVaapiDisplay *display,
|
||||
guint *pwidth,
|
||||
guint *pheight
|
||||
)
|
||||
gst_vaapi_display_wayland_get_size_mm (GstVaapiDisplay * display,
|
||||
guint * pwidth, guint * pheight)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
|
||||
if (!priv->output)
|
||||
return;
|
||||
if (!priv->output)
|
||||
return;
|
||||
|
||||
if (pwidth)
|
||||
*pwidth = priv->phys_width;
|
||||
if (pwidth)
|
||||
*pwidth = priv->phys_width;
|
||||
|
||||
if (pheight)
|
||||
*pheight = priv->phys_height;
|
||||
if (pheight)
|
||||
*pheight = priv->phys_height;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_wayland_init(GstVaapiDisplay *display)
|
||||
gst_vaapi_display_wayland_init (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiDisplayWaylandPrivate * const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display);
|
||||
GstVaapiDisplayWaylandPrivate *const priv =
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
||||
|
||||
priv->event_fd = -1;
|
||||
priv->event_fd = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_wayland_class_init(GstVaapiDisplayWaylandClass * klass)
|
||||
gst_vaapi_display_wayland_class_init (GstVaapiDisplayWaylandClass * klass)
|
||||
{
|
||||
GstVaapiMiniObjectClass * const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS(klass);
|
||||
GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);
|
||||
GstVaapiMiniObjectClass *const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS (klass);
|
||||
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
|
||||
|
||||
gst_vaapi_display_class_init(&klass->parent_class);
|
||||
gst_vaapi_display_class_init (&klass->parent_class);
|
||||
|
||||
object_class->size = sizeof(GstVaapiDisplayWayland);
|
||||
dpy_class->display_types = g_display_types;
|
||||
dpy_class->init = gst_vaapi_display_wayland_init;
|
||||
dpy_class->bind_display = gst_vaapi_display_wayland_bind_display;
|
||||
dpy_class->open_display = gst_vaapi_display_wayland_open_display;
|
||||
dpy_class->close_display = gst_vaapi_display_wayland_close_display;
|
||||
dpy_class->get_display = gst_vaapi_display_wayland_get_display_info;
|
||||
dpy_class->get_size = gst_vaapi_display_wayland_get_size;
|
||||
dpy_class->get_size_mm = gst_vaapi_display_wayland_get_size_mm;
|
||||
object_class->size = sizeof (GstVaapiDisplayWayland);
|
||||
dpy_class->display_types = g_display_types;
|
||||
dpy_class->init = gst_vaapi_display_wayland_init;
|
||||
dpy_class->bind_display = gst_vaapi_display_wayland_bind_display;
|
||||
dpy_class->open_display = gst_vaapi_display_wayland_open_display;
|
||||
dpy_class->close_display = gst_vaapi_display_wayland_close_display;
|
||||
dpy_class->get_display = gst_vaapi_display_wayland_get_display_info;
|
||||
dpy_class->get_size = gst_vaapi_display_wayland_get_size;
|
||||
dpy_class->get_size_mm = gst_vaapi_display_wayland_get_size_mm;
|
||||
}
|
||||
|
||||
static inline const GstVaapiDisplayClass *
|
||||
gst_vaapi_display_wayland_class(void)
|
||||
gst_vaapi_display_wayland_class (void)
|
||||
{
|
||||
static GstVaapiDisplayWaylandClass g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
static GstVaapiDisplayWaylandClass g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
|
||||
if (g_once_init_enter(&g_class_init)) {
|
||||
gst_vaapi_display_wayland_class_init(&g_class);
|
||||
g_once_init_leave(&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DISPLAY_CLASS(&g_class);
|
||||
if (g_once_init_enter (&g_class_init)) {
|
||||
gst_vaapi_display_wayland_class_init (&g_class);
|
||||
g_once_init_leave (&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DISPLAY_CLASS (&g_class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,10 +379,10 @@ gst_vaapi_display_wayland_class(void)
|
|||
* Return value: a newly allocated #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_wayland_new(const gchar *display_name)
|
||||
gst_vaapi_display_wayland_new (const gchar * display_name)
|
||||
{
|
||||
return gst_vaapi_display_new(gst_vaapi_display_wayland_class(),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer)display_name);
|
||||
return gst_vaapi_display_new (gst_vaapi_display_wayland_class (),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -411,12 +397,12 @@ gst_vaapi_display_wayland_new(const gchar *display_name)
|
|||
* Return value: a newly allocated #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_wayland_new_with_display(struct wl_display *wl_display)
|
||||
gst_vaapi_display_wayland_new_with_display (struct wl_display * wl_display)
|
||||
{
|
||||
g_return_val_if_fail(wl_display, NULL);
|
||||
g_return_val_if_fail (wl_display, NULL);
|
||||
|
||||
return gst_vaapi_display_new(gst_vaapi_display_wayland_class(),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, wl_display);
|
||||
return gst_vaapi_display_new (gst_vaapi_display_wayland_class (),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, wl_display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -430,9 +416,9 @@ gst_vaapi_display_wayland_new_with_display(struct wl_display *wl_display)
|
|||
* Return value: the Wayland #wl_display attached to @display
|
||||
*/
|
||||
struct wl_display *
|
||||
gst_vaapi_display_wayland_get_display(GstVaapiDisplayWayland *display)
|
||||
gst_vaapi_display_wayland_get_display (GstVaapiDisplayWayland * display)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_WAYLAND(display), NULL);
|
||||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_WAYLAND (display), NULL);
|
||||
|
||||
return GST_VAAPI_DISPLAY_WL_DISPLAY(display);
|
||||
return GST_VAAPI_DISPLAY_WL_DISPLAY (display);
|
||||
}
|
||||
|
|
|
@ -35,13 +35,13 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstVaapiDisplayWayland GstVaapiDisplayWayland;
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_wayland_new(const gchar *display_name);
|
||||
gst_vaapi_display_wayland_new (const gchar * display_name);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_wayland_new_with_display(struct wl_display *wl_display);
|
||||
gst_vaapi_display_wayland_new_with_display (struct wl_display * wl_display);
|
||||
|
||||
struct wl_display *
|
||||
gst_vaapi_display_wayland_get_display(GstVaapiDisplayWayland *display);
|
||||
gst_vaapi_display_wayland_get_display (GstVaapiDisplayWayland * display);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -53,19 +53,20 @@ typedef struct _GstVaapiDisplayWaylandClass GstVaapiDisplayWaylandClass;
|
|||
#define GST_VAAPI_DISPLAY_WL_DISPLAY(display) \
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display)->wl_display
|
||||
|
||||
struct _GstVaapiDisplayWaylandPrivate {
|
||||
gchar *display_name;
|
||||
struct wl_display *wl_display;
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shell *shell;
|
||||
struct wl_output *output;
|
||||
struct wl_registry *registry;
|
||||
guint width;
|
||||
guint height;
|
||||
guint phys_width;
|
||||
guint phys_height;
|
||||
gint event_fd;
|
||||
guint use_foreign_display : 1;
|
||||
struct _GstVaapiDisplayWaylandPrivate
|
||||
{
|
||||
gchar *display_name;
|
||||
struct wl_display *wl_display;
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shell *shell;
|
||||
struct wl_output *output;
|
||||
struct wl_registry *registry;
|
||||
guint width;
|
||||
guint height;
|
||||
guint phys_width;
|
||||
guint phys_height;
|
||||
gint event_fd;
|
||||
guint use_foreign_display:1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -73,11 +74,12 @@ struct _GstVaapiDisplayWaylandPrivate {
|
|||
*
|
||||
* VA/Wayland display wrapper.
|
||||
*/
|
||||
struct _GstVaapiDisplayWayland {
|
||||
/*< private >*/
|
||||
GstVaapiDisplay parent_instance;
|
||||
struct _GstVaapiDisplayWayland
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiDisplay parent_instance;
|
||||
|
||||
GstVaapiDisplayWaylandPrivate priv;
|
||||
GstVaapiDisplayWaylandPrivate priv;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -85,9 +87,10 @@ struct _GstVaapiDisplayWayland {
|
|||
*
|
||||
* VA/Wayland display wrapper clas.
|
||||
*/
|
||||
struct _GstVaapiDisplayWaylandClass {
|
||||
/*< private >*/
|
||||
GstVaapiDisplayClass parent_class;
|
||||
struct _GstVaapiDisplayWaylandClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiDisplayClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -46,359 +46,348 @@
|
|||
#include "gstvaapidebug.h"
|
||||
|
||||
static const guint g_display_types =
|
||||
(1U << GST_VAAPI_DISPLAY_TYPE_X11) |
|
||||
(1U << GST_VAAPI_DISPLAY_TYPE_GLX);
|
||||
(1U << GST_VAAPI_DISPLAY_TYPE_X11) | (1U << GST_VAAPI_DISPLAY_TYPE_GLX);
|
||||
|
||||
static inline const gchar *
|
||||
get_default_display_name(void)
|
||||
get_default_display_name (void)
|
||||
{
|
||||
static const gchar *g_display_name;
|
||||
static const gchar *g_display_name;
|
||||
|
||||
if (!g_display_name)
|
||||
g_display_name = getenv("DISPLAY");
|
||||
return g_display_name;
|
||||
if (!g_display_name)
|
||||
g_display_name = getenv ("DISPLAY");
|
||||
return g_display_name;
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_display_name(gconstpointer a, gconstpointer b)
|
||||
compare_display_name (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const GstVaapiDisplayInfo * const info = a;
|
||||
const gchar *cached_name = info->display_name, *cached_name_end;
|
||||
const gchar *tested_name = b, *tested_name_end;
|
||||
guint cached_name_length, tested_name_length;
|
||||
const GstVaapiDisplayInfo *const info = a;
|
||||
const gchar *cached_name = info->display_name, *cached_name_end;
|
||||
const gchar *tested_name = b, *tested_name_end;
|
||||
guint cached_name_length, tested_name_length;
|
||||
|
||||
g_return_val_if_fail(cached_name, FALSE);
|
||||
g_return_val_if_fail(tested_name, FALSE);
|
||||
g_return_val_if_fail (cached_name, FALSE);
|
||||
g_return_val_if_fail (tested_name, FALSE);
|
||||
|
||||
cached_name_end = strchr(cached_name, ':');
|
||||
if (cached_name_end)
|
||||
cached_name_length = cached_name_end - cached_name;
|
||||
else
|
||||
cached_name_length = strlen(cached_name);
|
||||
cached_name_end = strchr (cached_name, ':');
|
||||
if (cached_name_end)
|
||||
cached_name_length = cached_name_end - cached_name;
|
||||
else
|
||||
cached_name_length = strlen (cached_name);
|
||||
|
||||
tested_name_end = strchr(tested_name, ':');
|
||||
if (tested_name_end)
|
||||
tested_name_length = tested_name_end - tested_name;
|
||||
else
|
||||
tested_name_length = strlen(tested_name);
|
||||
tested_name_end = strchr (tested_name, ':');
|
||||
if (tested_name_end)
|
||||
tested_name_length = tested_name_end - tested_name;
|
||||
else
|
||||
tested_name_length = strlen (tested_name);
|
||||
|
||||
if (cached_name_length != tested_name_length)
|
||||
return FALSE;
|
||||
if (strncmp(cached_name, tested_name, cached_name_length) != 0)
|
||||
return FALSE;
|
||||
if (cached_name_length != tested_name_length)
|
||||
return FALSE;
|
||||
if (strncmp (cached_name, tested_name, cached_name_length) != 0)
|
||||
return FALSE;
|
||||
|
||||
/* XXX: handle screen number? */
|
||||
return TRUE;
|
||||
/* XXX: handle screen number? */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Reconstruct a display name without our prefix */
|
||||
static const gchar *
|
||||
get_display_name(GstVaapiDisplayX11 *display)
|
||||
get_display_name (GstVaapiDisplayX11 * display)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv = &display->priv;
|
||||
const gchar *display_name = priv->display_name;
|
||||
GstVaapiDisplayX11Private *const priv = &display->priv;
|
||||
const gchar *display_name = priv->display_name;
|
||||
|
||||
if (!display_name || *display_name == '\0')
|
||||
return NULL;
|
||||
return display_name;
|
||||
if (!display_name || *display_name == '\0')
|
||||
return NULL;
|
||||
return display_name;
|
||||
}
|
||||
|
||||
/* Mangle display name with our prefix */
|
||||
static gboolean
|
||||
set_display_name(GstVaapiDisplayX11 *display, const gchar *display_name)
|
||||
set_display_name (GstVaapiDisplayX11 * display, const gchar * display_name)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv = &display->priv;
|
||||
GstVaapiDisplayX11Private *const priv = &display->priv;
|
||||
|
||||
g_free(priv->display_name);
|
||||
g_free (priv->display_name);
|
||||
|
||||
if (!display_name) {
|
||||
display_name = get_default_display_name();
|
||||
if (!display_name)
|
||||
display_name = "";
|
||||
}
|
||||
priv->display_name = g_strdup(display_name);
|
||||
return priv->display_name != NULL;
|
||||
if (!display_name) {
|
||||
display_name = get_default_display_name ();
|
||||
if (!display_name)
|
||||
display_name = "";
|
||||
}
|
||||
priv->display_name = g_strdup (display_name);
|
||||
return priv->display_name != NULL;
|
||||
}
|
||||
|
||||
/* Set synchronous behavious on the underlying X11 display */
|
||||
static void
|
||||
set_synchronous(GstVaapiDisplayX11 *display, gboolean synchronous)
|
||||
set_synchronous (GstVaapiDisplayX11 * display, gboolean synchronous)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv = &display->priv;
|
||||
GstVaapiDisplayX11Private *const priv = &display->priv;
|
||||
|
||||
if (priv->synchronous != synchronous) {
|
||||
priv->synchronous = synchronous;
|
||||
if (priv->x11_display) {
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
XSynchronize(priv->x11_display, synchronous);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
}
|
||||
if (priv->synchronous != synchronous) {
|
||||
priv->synchronous = synchronous;
|
||||
if (priv->x11_display) {
|
||||
GST_VAAPI_DISPLAY_LOCK (display);
|
||||
XSynchronize (priv->x11_display, synchronous);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for display server extensions */
|
||||
static void
|
||||
check_extensions(GstVaapiDisplayX11 *display)
|
||||
check_extensions (GstVaapiDisplayX11 * display)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
int evt_base, err_base;
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
int evt_base, err_base;
|
||||
|
||||
#ifdef HAVE_XRANDR
|
||||
priv->use_xrandr = XRRQueryExtension(priv->x11_display,
|
||||
&evt_base, &err_base);
|
||||
priv->use_xrandr = XRRQueryExtension (priv->x11_display,
|
||||
&evt_base, &err_base);
|
||||
#endif
|
||||
#ifdef HAVE_XRENDER
|
||||
priv->has_xrender = XRenderQueryExtension(priv->x11_display,
|
||||
&evt_base, &err_base);
|
||||
priv->has_xrender = XRenderQueryExtension (priv->x11_display,
|
||||
&evt_base, &err_base);
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_x11_bind_display(GstVaapiDisplay *base_display,
|
||||
gst_vaapi_display_x11_bind_display (GstVaapiDisplay * base_display,
|
||||
gpointer native_display)
|
||||
{
|
||||
GstVaapiDisplayX11 * const display =
|
||||
GST_VAAPI_DISPLAY_X11_CAST(base_display);
|
||||
GstVaapiDisplayX11Private * const priv = &display->priv;
|
||||
GstVaapiDisplayX11 *const display = GST_VAAPI_DISPLAY_X11_CAST (base_display);
|
||||
GstVaapiDisplayX11Private *const priv = &display->priv;
|
||||
|
||||
priv->x11_display = native_display;
|
||||
priv->x11_screen = DefaultScreen(native_display);
|
||||
priv->x11_display = native_display;
|
||||
priv->x11_screen = DefaultScreen (native_display);
|
||||
priv->use_foreign_display = TRUE;
|
||||
|
||||
check_extensions (display);
|
||||
|
||||
if (!set_display_name (display, XDisplayString (priv->x11_display)))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_x11_open_display (GstVaapiDisplay * base_display,
|
||||
const gchar * name)
|
||||
{
|
||||
GstVaapiDisplayX11 *const display = GST_VAAPI_DISPLAY_X11_CAST (base_display);
|
||||
GstVaapiDisplayX11Private *const priv = &display->priv;
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *info;
|
||||
|
||||
cache = gst_vaapi_display_get_cache ();
|
||||
g_return_val_if_fail (cache != NULL, FALSE);
|
||||
|
||||
if (!set_display_name (display, name))
|
||||
return FALSE;
|
||||
|
||||
info = gst_vaapi_display_cache_lookup_custom (cache, compare_display_name,
|
||||
priv->display_name, GST_VAAPI_DISPLAY_TYPES (display));
|
||||
if (info) {
|
||||
priv->x11_display = info->native_display;
|
||||
priv->use_foreign_display = TRUE;
|
||||
} else {
|
||||
priv->x11_display = XOpenDisplay (get_display_name (display));
|
||||
if (!priv->x11_display)
|
||||
return FALSE;
|
||||
priv->use_foreign_display = FALSE;
|
||||
}
|
||||
priv->x11_screen = DefaultScreen (priv->x11_display);
|
||||
|
||||
check_extensions(display);
|
||||
check_extensions (display);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!set_display_name(display, XDisplayString(priv->x11_display)))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
static void
|
||||
gst_vaapi_display_x11_close_display (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
|
||||
if (priv->pixmap_formats) {
|
||||
g_array_free (priv->pixmap_formats, TRUE);
|
||||
priv->pixmap_formats = NULL;
|
||||
}
|
||||
|
||||
if (priv->x11_display) {
|
||||
if (!priv->use_foreign_display)
|
||||
XCloseDisplay (priv->x11_display);
|
||||
priv->x11_display = NULL;
|
||||
}
|
||||
|
||||
if (priv->display_name) {
|
||||
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_PRIVATE (display);
|
||||
|
||||
if (priv->x11_display) {
|
||||
GST_VAAPI_DISPLAY_LOCK (display);
|
||||
XSync (priv->x11_display, False);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_x11_flush (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
|
||||
if (priv->x11_display) {
|
||||
GST_VAAPI_DISPLAY_LOCK (display);
|
||||
XFlush (priv->x11_display);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_x11_open_display(GstVaapiDisplay *base_display,
|
||||
const gchar *name)
|
||||
gst_vaapi_display_x11_get_display_info (GstVaapiDisplay * display,
|
||||
GstVaapiDisplayInfo * info)
|
||||
{
|
||||
GstVaapiDisplayX11 * const display =
|
||||
GST_VAAPI_DISPLAY_X11_CAST(base_display);
|
||||
GstVaapiDisplayX11Private * const priv = &display->priv;
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *info;
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *cached_info;
|
||||
|
||||
cache = gst_vaapi_display_get_cache();
|
||||
g_return_val_if_fail(cache != NULL, FALSE);
|
||||
|
||||
if (!set_display_name(display, name))
|
||||
return FALSE;
|
||||
|
||||
info = gst_vaapi_display_cache_lookup_custom(cache, compare_display_name,
|
||||
priv->display_name, GST_VAAPI_DISPLAY_TYPES(display));
|
||||
if (info) {
|
||||
priv->x11_display = info->native_display;
|
||||
priv->use_foreign_display = TRUE;
|
||||
}
|
||||
else {
|
||||
priv->x11_display = XOpenDisplay(get_display_name(display));
|
||||
if (!priv->x11_display)
|
||||
return FALSE;
|
||||
priv->use_foreign_display = FALSE;
|
||||
}
|
||||
priv->x11_screen = DefaultScreen(priv->x11_display);
|
||||
|
||||
check_extensions(display);
|
||||
/* Return any cached info even if child has its own VA display */
|
||||
cache = gst_vaapi_display_get_cache ();
|
||||
if (!cache)
|
||||
return FALSE;
|
||||
cached_info =
|
||||
gst_vaapi_display_cache_lookup_by_native_display (cache,
|
||||
priv->x11_display, GST_VAAPI_DISPLAY_TYPES (display));
|
||||
if (cached_info) {
|
||||
*info = *cached_info;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Otherwise, create VA display if there is none already */
|
||||
info->native_display = priv->x11_display;
|
||||
info->display_name = priv->display_name;
|
||||
if (!info->va_display) {
|
||||
info->va_display = vaGetDisplay (priv->x11_display);
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_X11;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_x11_close_display(GstVaapiDisplay *display)
|
||||
gst_vaapi_display_x11_get_size (GstVaapiDisplay * display,
|
||||
guint * pwidth, guint * pheight)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
|
||||
if (priv->pixmap_formats) {
|
||||
g_array_free(priv->pixmap_formats, TRUE);
|
||||
priv->pixmap_formats = NULL;
|
||||
}
|
||||
if (!priv->x11_display)
|
||||
return;
|
||||
|
||||
if (priv->x11_display) {
|
||||
if (!priv->use_foreign_display)
|
||||
XCloseDisplay(priv->x11_display);
|
||||
priv->x11_display = NULL;
|
||||
}
|
||||
if (pwidth)
|
||||
*pwidth = DisplayWidth (priv->x11_display, priv->x11_screen);
|
||||
|
||||
if (priv->display_name) {
|
||||
g_free(priv->display_name);
|
||||
priv->display_name = NULL;
|
||||
}
|
||||
if (pheight)
|
||||
*pheight = DisplayHeight (priv->x11_display, priv->x11_screen);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_x11_sync(GstVaapiDisplay *display)
|
||||
gst_vaapi_display_x11_get_size_mm (GstVaapiDisplay * display,
|
||||
guint * pwidth, guint * pheight)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
guint width_mm, height_mm;
|
||||
|
||||
if (priv->x11_display) {
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
XSync(priv->x11_display, False);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
}
|
||||
}
|
||||
if (!priv->x11_display)
|
||||
return;
|
||||
|
||||
static void
|
||||
gst_vaapi_display_x11_flush(GstVaapiDisplay *display)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
|
||||
if (priv->x11_display) {
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
XFlush(priv->x11_display);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_display_x11_get_display_info(
|
||||
GstVaapiDisplay *display,
|
||||
GstVaapiDisplayInfo *info
|
||||
)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
GstVaapiDisplayCache *cache;
|
||||
const GstVaapiDisplayInfo *cached_info;
|
||||
|
||||
/* Return any cached info even if child has its own VA display */
|
||||
cache = gst_vaapi_display_get_cache();
|
||||
if (!cache)
|
||||
return FALSE;
|
||||
cached_info = gst_vaapi_display_cache_lookup_by_native_display(
|
||||
cache, priv->x11_display, GST_VAAPI_DISPLAY_TYPES(display));
|
||||
if (cached_info) {
|
||||
*info = *cached_info;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Otherwise, create VA display if there is none already */
|
||||
info->native_display = priv->x11_display;
|
||||
info->display_name = priv->display_name;
|
||||
if (!info->va_display) {
|
||||
info->va_display = vaGetDisplay(priv->x11_display);
|
||||
if (!info->va_display)
|
||||
return FALSE;
|
||||
info->display_type = GST_VAAPI_DISPLAY_TYPE_X11;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_x11_get_size(
|
||||
GstVaapiDisplay *display,
|
||||
guint *pwidth,
|
||||
guint *pheight
|
||||
)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
|
||||
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_PRIVATE(display);
|
||||
guint width_mm, height_mm;
|
||||
|
||||
if (!priv->x11_display)
|
||||
return;
|
||||
|
||||
width_mm = DisplayWidthMM(priv->x11_display, priv->x11_screen);
|
||||
height_mm = DisplayHeightMM(priv->x11_display, priv->x11_screen);
|
||||
width_mm = DisplayWidthMM (priv->x11_display, priv->x11_screen);
|
||||
height_mm = DisplayHeightMM (priv->x11_display, priv->x11_screen);
|
||||
|
||||
#ifdef HAVE_XRANDR
|
||||
/* XXX: fix up physical size if the display is rotated */
|
||||
if (priv->use_xrandr) {
|
||||
XRRScreenConfiguration *xrr_config = NULL;
|
||||
XRRScreenSize *xrr_sizes;
|
||||
Window win;
|
||||
int num_xrr_sizes, size_id, screen;
|
||||
Rotation rotation;
|
||||
/* XXX: fix up physical size if the display is rotated */
|
||||
if (priv->use_xrandr) {
|
||||
XRRScreenConfiguration *xrr_config = NULL;
|
||||
XRRScreenSize *xrr_sizes;
|
||||
Window win;
|
||||
int num_xrr_sizes, size_id, screen;
|
||||
Rotation rotation;
|
||||
|
||||
do {
|
||||
win = DefaultRootWindow(priv->x11_display);
|
||||
screen = XRRRootToScreen(priv->x11_display, win);
|
||||
do {
|
||||
win = DefaultRootWindow (priv->x11_display);
|
||||
screen = XRRRootToScreen (priv->x11_display, win);
|
||||
|
||||
xrr_config = XRRGetScreenInfo(priv->x11_display, win);
|
||||
if (!xrr_config)
|
||||
break;
|
||||
xrr_config = XRRGetScreenInfo (priv->x11_display, win);
|
||||
if (!xrr_config)
|
||||
break;
|
||||
|
||||
size_id = XRRConfigCurrentConfiguration(xrr_config, &rotation);
|
||||
if (rotation == RR_Rotate_0 || rotation == RR_Rotate_180)
|
||||
break;
|
||||
size_id = XRRConfigCurrentConfiguration (xrr_config, &rotation);
|
||||
if (rotation == RR_Rotate_0 || rotation == RR_Rotate_180)
|
||||
break;
|
||||
|
||||
xrr_sizes = XRRSizes(priv->x11_display, screen, &num_xrr_sizes);
|
||||
if (!xrr_sizes || size_id >= num_xrr_sizes)
|
||||
break;
|
||||
xrr_sizes = XRRSizes (priv->x11_display, screen, &num_xrr_sizes);
|
||||
if (!xrr_sizes || size_id >= num_xrr_sizes)
|
||||
break;
|
||||
|
||||
width_mm = xrr_sizes[size_id].mheight;
|
||||
height_mm = xrr_sizes[size_id].mwidth;
|
||||
} while (0);
|
||||
if (xrr_config)
|
||||
XRRFreeScreenConfigInfo(xrr_config);
|
||||
}
|
||||
width_mm = xrr_sizes[size_id].mheight;
|
||||
height_mm = xrr_sizes[size_id].mwidth;
|
||||
} while (0);
|
||||
if (xrr_config)
|
||||
XRRFreeScreenConfigInfo (xrr_config);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pwidth)
|
||||
*pwidth = width_mm;
|
||||
if (pwidth)
|
||||
*pwidth = width_mm;
|
||||
|
||||
if (pheight)
|
||||
*pheight = height_mm;
|
||||
if (pheight)
|
||||
*pheight = height_mm;
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
|
||||
gst_vaapi_display_x11_class_init (GstVaapiDisplayX11Class * klass)
|
||||
{
|
||||
GstVaapiMiniObjectClass * const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS(klass);
|
||||
GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);
|
||||
GstVaapiMiniObjectClass *const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS (klass);
|
||||
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
|
||||
|
||||
gst_vaapi_display_class_init(&klass->parent_class);
|
||||
gst_vaapi_display_class_init (&klass->parent_class);
|
||||
|
||||
object_class->size = sizeof(GstVaapiDisplayX11);
|
||||
dpy_class->display_types = g_display_types;
|
||||
dpy_class->bind_display = gst_vaapi_display_x11_bind_display;
|
||||
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_display_info;
|
||||
dpy_class->get_size = gst_vaapi_display_x11_get_size;
|
||||
dpy_class->get_size_mm = gst_vaapi_display_x11_get_size_mm;
|
||||
object_class->size = sizeof (GstVaapiDisplayX11);
|
||||
dpy_class->display_types = g_display_types;
|
||||
dpy_class->bind_display = gst_vaapi_display_x11_bind_display;
|
||||
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_display_info;
|
||||
dpy_class->get_size = gst_vaapi_display_x11_get_size;
|
||||
dpy_class->get_size_mm = gst_vaapi_display_x11_get_size_mm;
|
||||
}
|
||||
|
||||
static inline const GstVaapiDisplayClass *
|
||||
gst_vaapi_display_x11_class(void)
|
||||
gst_vaapi_display_x11_class (void)
|
||||
{
|
||||
static GstVaapiDisplayX11Class g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
static GstVaapiDisplayX11Class g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
|
||||
if (g_once_init_enter(&g_class_init)) {
|
||||
gst_vaapi_display_x11_class_init(&g_class);
|
||||
g_once_init_leave(&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DISPLAY_CLASS(&g_class);
|
||||
if (g_once_init_enter (&g_class_init)) {
|
||||
gst_vaapi_display_x11_class_init (&g_class);
|
||||
g_once_init_leave (&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DISPLAY_CLASS (&g_class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -412,10 +401,10 @@ gst_vaapi_display_x11_class(void)
|
|||
* Return value: a newly allocated #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_x11_new(const gchar *display_name)
|
||||
gst_vaapi_display_x11_new (const gchar * display_name)
|
||||
{
|
||||
return gst_vaapi_display_new(gst_vaapi_display_x11_class(),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer)display_name);
|
||||
return gst_vaapi_display_new (gst_vaapi_display_x11_class (),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -430,12 +419,12 @@ gst_vaapi_display_x11_new(const gchar *display_name)
|
|||
* Return value: a newly allocated #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_x11_new_with_display(Display *x11_display)
|
||||
gst_vaapi_display_x11_new_with_display (Display * x11_display)
|
||||
{
|
||||
g_return_val_if_fail(x11_display, NULL);
|
||||
g_return_val_if_fail (x11_display, NULL);
|
||||
|
||||
return gst_vaapi_display_new(gst_vaapi_display_x11_class(),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
|
||||
return gst_vaapi_display_new (gst_vaapi_display_x11_class (),
|
||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -449,11 +438,11 @@ gst_vaapi_display_x11_new_with_display(Display *x11_display)
|
|||
* Return value: the X11 #Display attached to @display
|
||||
*/
|
||||
Display *
|
||||
gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display)
|
||||
gst_vaapi_display_x11_get_display (GstVaapiDisplayX11 * display)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), NULL);
|
||||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
|
||||
|
||||
return GST_VAAPI_DISPLAY_XDISPLAY(display);
|
||||
return GST_VAAPI_DISPLAY_XDISPLAY (display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -467,11 +456,11 @@ gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display)
|
|||
* Return value: the X11 #Display attached to @display
|
||||
*/
|
||||
int
|
||||
gst_vaapi_display_x11_get_screen(GstVaapiDisplayX11 *display)
|
||||
gst_vaapi_display_x11_get_screen (GstVaapiDisplayX11 * display)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), -1);
|
||||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), -1);
|
||||
|
||||
return GST_VAAPI_DISPLAY_XSCREEN(display);
|
||||
return GST_VAAPI_DISPLAY_XSCREEN (display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -486,120 +475,121 @@ gst_vaapi_display_x11_get_screen(GstVaapiDisplayX11 *display)
|
|||
* @synchronous is %FALSE.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_display_x11_set_synchronous(GstVaapiDisplayX11 *display,
|
||||
gst_vaapi_display_x11_set_synchronous (GstVaapiDisplayX11 * display,
|
||||
gboolean synchronous)
|
||||
{
|
||||
g_return_if_fail(GST_VAAPI_IS_DISPLAY_X11(display));
|
||||
g_return_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display));
|
||||
|
||||
set_synchronous(display, synchronous);
|
||||
set_synchronous (display, synchronous);
|
||||
}
|
||||
|
||||
typedef struct _GstVaapiPixmapFormatX11 GstVaapiPixmapFormatX11;
|
||||
struct _GstVaapiPixmapFormatX11 {
|
||||
GstVideoFormat format;
|
||||
gint depth;
|
||||
gint bpp;
|
||||
struct _GstVaapiPixmapFormatX11
|
||||
{
|
||||
GstVideoFormat format;
|
||||
gint depth;
|
||||
gint bpp;
|
||||
};
|
||||
|
||||
static GstVideoFormat
|
||||
pix_fmt_to_video_format(gint depth, gint bpp)
|
||||
pix_fmt_to_video_format (gint depth, gint bpp)
|
||||
{
|
||||
GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
|
||||
GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
|
||||
|
||||
switch (bpp) {
|
||||
switch (bpp) {
|
||||
case 16:
|
||||
if (depth == 15)
|
||||
format = GST_VIDEO_FORMAT_RGB15;
|
||||
else if (depth == 16)
|
||||
format = GST_VIDEO_FORMAT_RGB16;
|
||||
break;
|
||||
if (depth == 15)
|
||||
format = GST_VIDEO_FORMAT_RGB15;
|
||||
else if (depth == 16)
|
||||
format = GST_VIDEO_FORMAT_RGB16;
|
||||
break;
|
||||
case 24:
|
||||
if (depth == 24)
|
||||
format = GST_VIDEO_FORMAT_RGB;
|
||||
break;
|
||||
if (depth == 24)
|
||||
format = GST_VIDEO_FORMAT_RGB;
|
||||
break;
|
||||
case 32:
|
||||
if (depth == 24 || depth == 32)
|
||||
format = GST_VIDEO_FORMAT_xRGB;
|
||||
break;
|
||||
}
|
||||
return format;
|
||||
if (depth == 24 || depth == 32)
|
||||
format = GST_VIDEO_FORMAT_xRGB;
|
||||
break;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ensure_pix_fmts(GstVaapiDisplayX11 *display)
|
||||
ensure_pix_fmts (GstVaapiDisplayX11 * display)
|
||||
{
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
XPixmapFormatValues *pix_fmts;
|
||||
int i, n, num_pix_fmts;
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
XPixmapFormatValues *pix_fmts;
|
||||
int i, n, num_pix_fmts;
|
||||
|
||||
if (priv->pixmap_formats)
|
||||
return TRUE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
pix_fmts = XListPixmapFormats(GST_VAAPI_DISPLAY_XDISPLAY(display),
|
||||
&num_pix_fmts);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!pix_fmts)
|
||||
return FALSE;
|
||||
|
||||
priv->pixmap_formats = g_array_sized_new(FALSE, FALSE,
|
||||
sizeof(GstVaapiPixmapFormatX11), num_pix_fmts);
|
||||
if (!priv->pixmap_formats) {
|
||||
XFree(pix_fmts);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0, n = 0; i < num_pix_fmts; i++) {
|
||||
GstVaapiPixmapFormatX11 * const pix_fmt =
|
||||
&g_array_index(priv->pixmap_formats, GstVaapiPixmapFormatX11, n);
|
||||
|
||||
pix_fmt->depth = pix_fmts[i].depth;
|
||||
pix_fmt->bpp = pix_fmts[i].bits_per_pixel;
|
||||
pix_fmt->format = pix_fmt_to_video_format(pix_fmt->depth, pix_fmt->bpp);
|
||||
if (pix_fmt->format != GST_VIDEO_FORMAT_UNKNOWN)
|
||||
n++;
|
||||
}
|
||||
priv->pixmap_formats->len = n;
|
||||
if (priv->pixmap_formats)
|
||||
return TRUE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK (display);
|
||||
pix_fmts = XListPixmapFormats (GST_VAAPI_DISPLAY_XDISPLAY (display),
|
||||
&num_pix_fmts);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||
if (!pix_fmts)
|
||||
return FALSE;
|
||||
|
||||
priv->pixmap_formats = g_array_sized_new (FALSE, FALSE,
|
||||
sizeof (GstVaapiPixmapFormatX11), num_pix_fmts);
|
||||
if (!priv->pixmap_formats) {
|
||||
XFree (pix_fmts);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0, n = 0; i < num_pix_fmts; i++) {
|
||||
GstVaapiPixmapFormatX11 *const pix_fmt =
|
||||
&g_array_index (priv->pixmap_formats, GstVaapiPixmapFormatX11, n);
|
||||
|
||||
pix_fmt->depth = pix_fmts[i].depth;
|
||||
pix_fmt->bpp = pix_fmts[i].bits_per_pixel;
|
||||
pix_fmt->format = pix_fmt_to_video_format (pix_fmt->depth, pix_fmt->bpp);
|
||||
if (pix_fmt->format != GST_VIDEO_FORMAT_UNKNOWN)
|
||||
n++;
|
||||
}
|
||||
priv->pixmap_formats->len = n;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Determine the GstVideoFormat based on a supported Pixmap depth */
|
||||
GstVideoFormat
|
||||
gst_vaapi_display_x11_get_pixmap_format(GstVaapiDisplayX11 *display,
|
||||
gst_vaapi_display_x11_get_pixmap_format (GstVaapiDisplayX11 * display,
|
||||
guint depth)
|
||||
{
|
||||
if (ensure_pix_fmts(display)) {
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
guint i;
|
||||
if (ensure_pix_fmts (display)) {
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->pixmap_formats->len; i++) {
|
||||
GstVaapiPixmapFormatX11 * const pix_fmt = &g_array_index(
|
||||
priv->pixmap_formats, GstVaapiPixmapFormatX11, i);
|
||||
if (pix_fmt->depth == depth)
|
||||
return pix_fmt->format;
|
||||
}
|
||||
for (i = 0; i < priv->pixmap_formats->len; i++) {
|
||||
GstVaapiPixmapFormatX11 *const pix_fmt =
|
||||
&g_array_index (priv->pixmap_formats, GstVaapiPixmapFormatX11, i);
|
||||
if (pix_fmt->depth == depth)
|
||||
return pix_fmt->format;
|
||||
}
|
||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
}
|
||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Determine the Pixmap depth based on a GstVideoFormat */
|
||||
guint
|
||||
gst_vaapi_display_x11_get_pixmap_depth(GstVaapiDisplayX11 *display,
|
||||
gst_vaapi_display_x11_get_pixmap_depth (GstVaapiDisplayX11 * display,
|
||||
GstVideoFormat format)
|
||||
{
|
||||
if (ensure_pix_fmts(display)) {
|
||||
GstVaapiDisplayX11Private * const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
|
||||
guint i;
|
||||
if (ensure_pix_fmts (display)) {
|
||||
GstVaapiDisplayX11Private *const priv =
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < priv->pixmap_formats->len; i++) {
|
||||
GstVaapiPixmapFormatX11 * const pix_fmt = &g_array_index(
|
||||
priv->pixmap_formats, GstVaapiPixmapFormatX11, i);
|
||||
if (pix_fmt->format == format)
|
||||
return pix_fmt->depth;
|
||||
}
|
||||
for (i = 0; i < priv->pixmap_formats->len; i++) {
|
||||
GstVaapiPixmapFormatX11 *const pix_fmt =
|
||||
&g_array_index (priv->pixmap_formats, GstVaapiPixmapFormatX11, i);
|
||||
if (pix_fmt->format == format)
|
||||
return pix_fmt->depth;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -36,19 +36,19 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstVaapiDisplayX11 GstVaapiDisplayX11;
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_x11_new(const gchar *display_name);
|
||||
gst_vaapi_display_x11_new (const gchar * display_name);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_x11_new_with_display(Display *x11_display);
|
||||
gst_vaapi_display_x11_new_with_display (Display * x11_display);
|
||||
|
||||
Display *
|
||||
gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display);
|
||||
gst_vaapi_display_x11_get_display (GstVaapiDisplayX11 * display);
|
||||
|
||||
int
|
||||
gst_vaapi_display_x11_get_screen(GstVaapiDisplayX11 *display);
|
||||
gst_vaapi_display_x11_get_screen (GstVaapiDisplayX11 * display);
|
||||
|
||||
void
|
||||
gst_vaapi_display_x11_set_synchronous(GstVaapiDisplayX11 *display,
|
||||
gst_vaapi_display_x11_set_synchronous (GstVaapiDisplayX11 * display,
|
||||
gboolean synchronous);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -76,15 +76,16 @@ typedef struct _GstVaapiDisplayX11Class GstVaapiDisplayX11Class;
|
|||
#define GST_VAAPI_DISPLAY_HAS_XRENDER(display) \
|
||||
(GST_VAAPI_DISPLAY_X11_PRIVATE(display)->has_xrender)
|
||||
|
||||
struct _GstVaapiDisplayX11Private {
|
||||
gchar *display_name;
|
||||
Display *x11_display;
|
||||
int x11_screen;
|
||||
GArray *pixmap_formats;
|
||||
guint use_foreign_display : 1; // Foreign native_display?
|
||||
guint use_xrandr : 1;
|
||||
guint has_xrender : 1; // Has XRender extension?
|
||||
guint synchronous : 1;
|
||||
struct _GstVaapiDisplayX11Private
|
||||
{
|
||||
gchar *display_name;
|
||||
Display *x11_display;
|
||||
int x11_screen;
|
||||
GArray *pixmap_formats;
|
||||
guint use_foreign_display:1; // Foreign native_display?
|
||||
guint use_xrandr:1;
|
||||
guint has_xrender:1; // Has XRender extension?
|
||||
guint synchronous:1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -92,11 +93,12 @@ struct _GstVaapiDisplayX11Private {
|
|||
*
|
||||
* VA/X11 display wrapper.
|
||||
*/
|
||||
struct _GstVaapiDisplayX11 {
|
||||
/*< private >*/
|
||||
GstVaapiDisplay parent_instance;
|
||||
struct _GstVaapiDisplayX11
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiDisplay parent_instance;
|
||||
|
||||
GstVaapiDisplayX11Private priv;
|
||||
GstVaapiDisplayX11Private priv;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -104,22 +106,23 @@ struct _GstVaapiDisplayX11 {
|
|||
*
|
||||
* VA/X11 display wrapper clas.
|
||||
*/
|
||||
struct _GstVaapiDisplayX11Class {
|
||||
/*< private >*/
|
||||
GstVaapiDisplayClass parent_class;
|
||||
struct _GstVaapiDisplayX11Class
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiDisplayClass parent_class;
|
||||
};
|
||||
|
||||
void
|
||||
gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass);
|
||||
gst_vaapi_display_x11_class_init (GstVaapiDisplayX11Class * klass);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GstVideoFormat
|
||||
gst_vaapi_display_x11_get_pixmap_format(GstVaapiDisplayX11 *display,
|
||||
gst_vaapi_display_x11_get_pixmap_format (GstVaapiDisplayX11 * display,
|
||||
guint depth);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
gst_vaapi_display_x11_get_pixmap_depth(GstVaapiDisplayX11 *display,
|
||||
gst_vaapi_display_x11_get_pixmap_depth (GstVaapiDisplayX11 * display,
|
||||
GstVideoFormat format);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -29,134 +29,136 @@
|
|||
#include "gstvaapidebug.h"
|
||||
|
||||
typedef struct _CacheEntry CacheEntry;
|
||||
struct _CacheEntry {
|
||||
GstVaapiDisplayInfo info;
|
||||
struct _CacheEntry
|
||||
{
|
||||
GstVaapiDisplayInfo info;
|
||||
};
|
||||
|
||||
struct _GstVaapiDisplayCache {
|
||||
GMutex mutex;
|
||||
GList *list;
|
||||
struct _GstVaapiDisplayCache
|
||||
{
|
||||
GMutex mutex;
|
||||
GList *list;
|
||||
};
|
||||
|
||||
static void
|
||||
cache_entry_free(CacheEntry *entry)
|
||||
cache_entry_free (CacheEntry * entry)
|
||||
{
|
||||
GstVaapiDisplayInfo *info;
|
||||
GstVaapiDisplayInfo *info;
|
||||
|
||||
if (!entry)
|
||||
return;
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
info = &entry->info;
|
||||
info = &entry->info;
|
||||
|
||||
if (info->display_name) {
|
||||
g_free(info->display_name);
|
||||
info->display_name = NULL;
|
||||
}
|
||||
g_slice_free(CacheEntry, entry);
|
||||
if (info->display_name) {
|
||||
g_free (info->display_name);
|
||||
info->display_name = NULL;
|
||||
}
|
||||
g_slice_free (CacheEntry, entry);
|
||||
}
|
||||
|
||||
static CacheEntry *
|
||||
cache_entry_new(const GstVaapiDisplayInfo *di)
|
||||
cache_entry_new (const GstVaapiDisplayInfo * di)
|
||||
{
|
||||
GstVaapiDisplayInfo *info;
|
||||
CacheEntry *entry;
|
||||
GstVaapiDisplayInfo *info;
|
||||
CacheEntry *entry;
|
||||
|
||||
entry = g_slice_new(CacheEntry);
|
||||
if (!entry)
|
||||
return NULL;
|
||||
entry = g_slice_new (CacheEntry);
|
||||
if (!entry)
|
||||
return NULL;
|
||||
|
||||
info = &entry->info;
|
||||
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;
|
||||
info = &entry->info;
|
||||
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) {
|
||||
info->display_name = g_strdup(di->display_name);
|
||||
if (!info->display_name)
|
||||
goto error;
|
||||
}
|
||||
return entry;
|
||||
if (di->display_name) {
|
||||
info->display_name = g_strdup (di->display_name);
|
||||
if (!info->display_name)
|
||||
goto error;
|
||||
}
|
||||
return entry;
|
||||
|
||||
error:
|
||||
cache_entry_free(entry);
|
||||
return NULL;
|
||||
cache_entry_free (entry);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_compatible_display_type(const GstVaapiDisplayType display_type,
|
||||
is_compatible_display_type (const GstVaapiDisplayType display_type,
|
||||
guint display_types)
|
||||
{
|
||||
if (display_type == GST_VAAPI_DISPLAY_TYPE_ANY)
|
||||
return TRUE;
|
||||
if (display_types == GST_VAAPI_DISPLAY_TYPE_ANY)
|
||||
return TRUE;
|
||||
return ((1U << display_type) & display_types) != 0;
|
||||
if (display_type == GST_VAAPI_DISPLAY_TYPE_ANY)
|
||||
return TRUE;
|
||||
if (display_types == GST_VAAPI_DISPLAY_TYPE_ANY)
|
||||
return TRUE;
|
||||
return ((1U << display_type) & display_types) != 0;
|
||||
}
|
||||
|
||||
static GList *
|
||||
cache_lookup_1(GstVaapiDisplayCache *cache, GCompareFunc func,
|
||||
cache_lookup_1 (GstVaapiDisplayCache * cache, GCompareFunc func,
|
||||
gconstpointer data, guint display_types)
|
||||
{
|
||||
GList *l;
|
||||
GList *l;
|
||||
|
||||
g_mutex_lock(&cache->mutex);
|
||||
for (l = cache->list; l != NULL; l = l->next) {
|
||||
GstVaapiDisplayInfo * const info = &((CacheEntry *)l->data)->info;
|
||||
if (!is_compatible_display_type(info->display_type, display_types))
|
||||
continue;
|
||||
if (func(info, data))
|
||||
break;
|
||||
}
|
||||
g_mutex_unlock(&cache->mutex);
|
||||
return l;
|
||||
g_mutex_lock (&cache->mutex);
|
||||
for (l = cache->list; l != NULL; l = l->next) {
|
||||
GstVaapiDisplayInfo *const info = &((CacheEntry *) l->data)->info;
|
||||
if (!is_compatible_display_type (info->display_type, display_types))
|
||||
continue;
|
||||
if (func (info, data))
|
||||
break;
|
||||
}
|
||||
g_mutex_unlock (&cache->mutex);
|
||||
return l;
|
||||
}
|
||||
|
||||
static inline const GstVaapiDisplayInfo *
|
||||
cache_lookup(GstVaapiDisplayCache *cache, GCompareFunc func,
|
||||
cache_lookup (GstVaapiDisplayCache * cache, GCompareFunc func,
|
||||
gconstpointer data, guint display_types)
|
||||
{
|
||||
GList * const m = cache_lookup_1(cache, func, data, display_types);
|
||||
GList *const m = cache_lookup_1 (cache, func, data, display_types);
|
||||
|
||||
return m ? &((CacheEntry *)m->data)->info : NULL;
|
||||
return m ? &((CacheEntry *) m->data)->info : NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_display(gconstpointer a, gconstpointer display)
|
||||
compare_display (gconstpointer a, gconstpointer display)
|
||||
{
|
||||
const GstVaapiDisplayInfo * const info = a;
|
||||
const GstVaapiDisplayInfo *const info = a;
|
||||
|
||||
return info->display == display;
|
||||
return info->display == display;
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_va_display(gconstpointer a, gconstpointer va_display)
|
||||
compare_va_display (gconstpointer a, gconstpointer va_display)
|
||||
{
|
||||
const GstVaapiDisplayInfo * const info = a;
|
||||
const GstVaapiDisplayInfo *const info = a;
|
||||
|
||||
return info->va_display == va_display;
|
||||
return info->va_display == va_display;
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_native_display(gconstpointer a, gconstpointer native_display)
|
||||
compare_native_display (gconstpointer a, gconstpointer native_display)
|
||||
{
|
||||
const GstVaapiDisplayInfo * const info = a;
|
||||
const GstVaapiDisplayInfo *const info = a;
|
||||
|
||||
return info->native_display == native_display;
|
||||
return info->native_display == native_display;
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_display_name(gconstpointer a, gconstpointer b)
|
||||
compare_display_name (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const GstVaapiDisplayInfo * const info = a;
|
||||
const gchar * const display_name = b;
|
||||
const GstVaapiDisplayInfo *const info = a;
|
||||
const gchar *const display_name = b;
|
||||
|
||||
if (info->display_name == NULL && display_name == NULL)
|
||||
return TRUE;
|
||||
if (!info->display_name || !display_name)
|
||||
return FALSE;
|
||||
return strcmp(info->display_name, display_name) == 0;
|
||||
if (info->display_name == NULL && display_name == NULL)
|
||||
return TRUE;
|
||||
if (!info->display_name || !display_name)
|
||||
return FALSE;
|
||||
return strcmp (info->display_name, display_name) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,16 +169,16 @@ compare_display_name(gconstpointer a, gconstpointer b)
|
|||
* Return value: the newly created #GstVaapiDisplayCache object
|
||||
*/
|
||||
GstVaapiDisplayCache *
|
||||
gst_vaapi_display_cache_new(void)
|
||||
gst_vaapi_display_cache_new (void)
|
||||
{
|
||||
GstVaapiDisplayCache *cache;
|
||||
GstVaapiDisplayCache *cache;
|
||||
|
||||
cache = g_slice_new0(GstVaapiDisplayCache);
|
||||
if (!cache)
|
||||
return NULL;
|
||||
cache = g_slice_new0 (GstVaapiDisplayCache);
|
||||
if (!cache)
|
||||
return NULL;
|
||||
|
||||
g_mutex_init(&cache->mutex);
|
||||
return cache;
|
||||
g_mutex_init (&cache->mutex);
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,21 +188,21 @@ gst_vaapi_display_cache_new(void)
|
|||
* Destroys a VA display cache.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_display_cache_free(GstVaapiDisplayCache *cache)
|
||||
gst_vaapi_display_cache_free (GstVaapiDisplayCache * cache)
|
||||
{
|
||||
GList *l;
|
||||
GList *l;
|
||||
|
||||
if (!cache)
|
||||
return;
|
||||
if (!cache)
|
||||
return;
|
||||
|
||||
if (cache->list) {
|
||||
for (l = cache->list; l != NULL; l = l->next)
|
||||
cache_entry_free(l->data);
|
||||
g_list_free(cache->list);
|
||||
cache->list = NULL;
|
||||
}
|
||||
g_mutex_clear(&cache->mutex);
|
||||
g_slice_free(GstVaapiDisplayCache, cache);
|
||||
if (cache->list) {
|
||||
for (l = cache->list; l != NULL; l = l->next)
|
||||
cache_entry_free (l->data);
|
||||
g_list_free (cache->list);
|
||||
cache->list = NULL;
|
||||
}
|
||||
g_mutex_clear (&cache->mutex);
|
||||
g_slice_free (GstVaapiDisplayCache, cache);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,16 +214,16 @@ gst_vaapi_display_cache_free(GstVaapiDisplayCache *cache)
|
|||
* Return value: the size of the display cache
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_display_cache_get_size(GstVaapiDisplayCache *cache)
|
||||
gst_vaapi_display_cache_get_size (GstVaapiDisplayCache * cache)
|
||||
{
|
||||
guint size;
|
||||
guint size;
|
||||
|
||||
g_return_val_if_fail(cache != NULL, 0);
|
||||
g_return_val_if_fail (cache != NULL, 0);
|
||||
|
||||
g_mutex_lock(&cache->mutex);
|
||||
size = g_list_length(cache->list);
|
||||
g_mutex_unlock(&cache->mutex);
|
||||
return size;
|
||||
g_mutex_lock (&cache->mutex);
|
||||
size = g_list_length (cache->list);
|
||||
g_mutex_unlock (&cache->mutex);
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,24 +237,22 @@ gst_vaapi_display_cache_get_size(GstVaapiDisplayCache *cache)
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_display_cache_add(
|
||||
GstVaapiDisplayCache *cache,
|
||||
GstVaapiDisplayInfo *info
|
||||
)
|
||||
gst_vaapi_display_cache_add (GstVaapiDisplayCache * cache,
|
||||
GstVaapiDisplayInfo * info)
|
||||
{
|
||||
CacheEntry *entry;
|
||||
CacheEntry *entry;
|
||||
|
||||
g_return_val_if_fail(cache != NULL, FALSE);
|
||||
g_return_val_if_fail(info != NULL, FALSE);
|
||||
g_return_val_if_fail (cache != NULL, FALSE);
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
|
||||
entry = cache_entry_new(info);
|
||||
if (!entry)
|
||||
return FALSE;
|
||||
entry = cache_entry_new (info);
|
||||
if (!entry)
|
||||
return FALSE;
|
||||
|
||||
g_mutex_lock(&cache->mutex);
|
||||
cache->list = g_list_prepend(cache->list, entry);
|
||||
g_mutex_unlock(&cache->mutex);
|
||||
return TRUE;
|
||||
g_mutex_lock (&cache->mutex);
|
||||
cache->list = g_list_prepend (cache->list, entry);
|
||||
g_mutex_unlock (&cache->mutex);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,22 +263,20 @@ gst_vaapi_display_cache_add(
|
|||
* Removes any cache entry that matches the specified #GstVaapiDisplay.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_display_cache_remove(
|
||||
GstVaapiDisplayCache *cache,
|
||||
GstVaapiDisplay *display
|
||||
)
|
||||
gst_vaapi_display_cache_remove (GstVaapiDisplayCache * cache,
|
||||
GstVaapiDisplay * display)
|
||||
{
|
||||
GList *m;
|
||||
GList *m;
|
||||
|
||||
m = cache_lookup_1(cache, compare_display, display,
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY);
|
||||
if (!m)
|
||||
return;
|
||||
m = cache_lookup_1 (cache, compare_display, display,
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY);
|
||||
if (!m)
|
||||
return;
|
||||
|
||||
cache_entry_free(m->data);
|
||||
g_mutex_lock(&cache->mutex);
|
||||
cache->list = g_list_delete_link(cache->list, m);
|
||||
g_mutex_unlock(&cache->mutex);
|
||||
cache_entry_free (m->data);
|
||||
g_mutex_lock (&cache->mutex);
|
||||
cache->list = g_list_delete_link (cache->list, m);
|
||||
g_mutex_unlock (&cache->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -292,16 +290,14 @@ gst_vaapi_display_cache_remove(
|
|||
* none was found
|
||||
*/
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup(
|
||||
GstVaapiDisplayCache *cache,
|
||||
GstVaapiDisplay *display
|
||||
)
|
||||
gst_vaapi_display_cache_lookup (GstVaapiDisplayCache * cache,
|
||||
GstVaapiDisplay * display)
|
||||
{
|
||||
g_return_val_if_fail(cache != NULL, NULL);
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail (cache != NULL, NULL);
|
||||
g_return_val_if_fail (display != NULL, NULL);
|
||||
|
||||
return cache_lookup(cache, compare_display, display,
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY);
|
||||
return cache_lookup (cache, compare_display, display,
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -324,17 +320,13 @@ gst_vaapi_display_cache_lookup(
|
|||
* (i.e. returning %TRUE), or %NULL if none was found
|
||||
*/
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup_custom(
|
||||
GstVaapiDisplayCache *cache,
|
||||
GCompareFunc func,
|
||||
gconstpointer data,
|
||||
guint display_types
|
||||
)
|
||||
gst_vaapi_display_cache_lookup_custom (GstVaapiDisplayCache * cache,
|
||||
GCompareFunc func, gconstpointer data, guint display_types)
|
||||
{
|
||||
g_return_val_if_fail(cache != NULL, NULL);
|
||||
g_return_val_if_fail(func != NULL, NULL);
|
||||
g_return_val_if_fail (cache != NULL, NULL);
|
||||
g_return_val_if_fail (func != NULL, NULL);
|
||||
|
||||
return cache_lookup(cache, func, data, display_types);
|
||||
return cache_lookup (cache, func, data, display_types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -348,16 +340,14 @@ gst_vaapi_display_cache_lookup_custom(
|
|||
* if none was found
|
||||
*/
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup_by_va_display(
|
||||
GstVaapiDisplayCache *cache,
|
||||
VADisplay va_display
|
||||
)
|
||||
gst_vaapi_display_cache_lookup_by_va_display (GstVaapiDisplayCache * cache,
|
||||
VADisplay va_display)
|
||||
{
|
||||
g_return_val_if_fail(cache != NULL, NULL);
|
||||
g_return_val_if_fail(va_display != NULL, NULL);
|
||||
g_return_val_if_fail (cache != NULL, NULL);
|
||||
g_return_val_if_fail (va_display != NULL, NULL);
|
||||
|
||||
return cache_lookup(cache, compare_va_display, va_display,
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY);
|
||||
return cache_lookup (cache, compare_va_display, va_display,
|
||||
GST_VAAPI_DISPLAY_TYPE_ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,17 +361,14 @@ gst_vaapi_display_cache_lookup_by_va_display(
|
|||
* %NULL if none was found
|
||||
*/
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup_by_native_display(
|
||||
GstVaapiDisplayCache *cache,
|
||||
gpointer native_display,
|
||||
guint display_types
|
||||
)
|
||||
gst_vaapi_display_cache_lookup_by_native_display (GstVaapiDisplayCache * cache,
|
||||
gpointer native_display, guint display_types)
|
||||
{
|
||||
g_return_val_if_fail(cache != NULL, NULL);
|
||||
g_return_val_if_fail(native_display != NULL, NULL);
|
||||
g_return_val_if_fail (cache != NULL, NULL);
|
||||
g_return_val_if_fail (native_display != NULL, NULL);
|
||||
|
||||
return cache_lookup(cache, compare_native_display, native_display,
|
||||
display_types);
|
||||
return cache_lookup (cache, compare_native_display, native_display,
|
||||
display_types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,14 +382,11 @@ gst_vaapi_display_cache_lookup_by_native_display(
|
|||
* %NULL if none was found
|
||||
*/
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup_by_name(
|
||||
GstVaapiDisplayCache *cache,
|
||||
const gchar *display_name,
|
||||
guint display_types
|
||||
)
|
||||
gst_vaapi_display_cache_lookup_by_name (GstVaapiDisplayCache * cache,
|
||||
const gchar * display_name, guint display_types)
|
||||
{
|
||||
g_return_val_if_fail(cache != NULL, NULL);
|
||||
g_return_val_if_fail (cache != NULL, NULL);
|
||||
|
||||
return cache_lookup(cache, compare_display_name, display_name,
|
||||
display_types);
|
||||
return cache_lookup (cache, compare_display_name, display_name,
|
||||
display_types);
|
||||
}
|
||||
|
|
|
@ -25,66 +25,48 @@
|
|||
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
|
||||
typedef struct _GstVaapiDisplayCache GstVaapiDisplayCache;
|
||||
typedef struct _GstVaapiDisplayCache GstVaapiDisplayCache;
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GstVaapiDisplayCache *
|
||||
gst_vaapi_display_cache_new(void);
|
||||
gst_vaapi_display_cache_new (void);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gst_vaapi_display_cache_free(GstVaapiDisplayCache *cache);
|
||||
gst_vaapi_display_cache_free (GstVaapiDisplayCache * cache);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
gst_vaapi_display_cache_get_size(GstVaapiDisplayCache *cache);
|
||||
gst_vaapi_display_cache_get_size (GstVaapiDisplayCache * cache);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gst_vaapi_display_cache_add(
|
||||
GstVaapiDisplayCache *cache,
|
||||
GstVaapiDisplayInfo *info
|
||||
);
|
||||
gst_vaapi_display_cache_add (GstVaapiDisplayCache * cache,
|
||||
GstVaapiDisplayInfo * info);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gst_vaapi_display_cache_remove(
|
||||
GstVaapiDisplayCache *cache,
|
||||
GstVaapiDisplay *display
|
||||
);
|
||||
gst_vaapi_display_cache_remove (GstVaapiDisplayCache * cache,
|
||||
GstVaapiDisplay * display);
|
||||
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup(
|
||||
GstVaapiDisplayCache *cache,
|
||||
GstVaapiDisplay *display
|
||||
);
|
||||
gst_vaapi_display_cache_lookup (GstVaapiDisplayCache
|
||||
* cache, GstVaapiDisplay * display);
|
||||
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup_custom(
|
||||
GstVaapiDisplayCache *cache,
|
||||
GCompareFunc func,
|
||||
gconstpointer data,
|
||||
guint display_types
|
||||
);
|
||||
gst_vaapi_display_cache_lookup_custom (GstVaapiDisplayCache * cache,
|
||||
GCompareFunc func, gconstpointer data, guint display_types);
|
||||
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup_by_va_display(
|
||||
GstVaapiDisplayCache *cache,
|
||||
VADisplay va_display
|
||||
);
|
||||
gst_vaapi_display_cache_lookup_by_va_display (GstVaapiDisplayCache * cache,
|
||||
VADisplay va_display);
|
||||
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup_by_native_display(
|
||||
GstVaapiDisplayCache *cache,
|
||||
gpointer native_display,
|
||||
guint display_types
|
||||
);
|
||||
gst_vaapi_display_cache_lookup_by_native_display (GstVaapiDisplayCache *
|
||||
cache, gpointer native_display, guint display_types);
|
||||
|
||||
const GstVaapiDisplayInfo *
|
||||
gst_vaapi_display_cache_lookup_by_name(
|
||||
GstVaapiDisplayCache *cache,
|
||||
const gchar *display_name,
|
||||
guint display_types
|
||||
);
|
||||
gst_vaapi_display_cache_lookup_by_name (GstVaapiDisplayCache * cache,
|
||||
const gchar * display_name, guint display_types);
|
||||
|
||||
#endif /* GSTVAAPIDISPLAYCACHE_H */
|
||||
|
|
Loading…
Reference in a new issue