2010-01-25 16:15:01 +00:00
|
|
|
/*
|
|
|
|
* test-display.c - Test GstVaapiDisplayX11
|
|
|
|
*
|
2012-01-16 09:41:10 +00:00
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
2013-11-22 05:37:12 +00:00
|
|
|
* Copyright (C) 2012-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2010-01-25 16:15:01 +00:00
|
|
|
*
|
2011-10-18 07:18:20 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
2010-01-25 16:15:01 +00:00
|
|
|
*
|
2011-10-18 07:18:20 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-01-25 16:15:01 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-10-18 07:18:20 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-01-25 16:15:01 +00:00
|
|
|
*
|
2011-10-18 07:18:20 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
2013-03-20 10:57:57 +00:00
|
|
|
*/
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2013-03-20 10:50:15 +00:00
|
|
|
#include "gst/vaapi/sysdeps.h"
|
2010-03-10 12:25:38 +00:00
|
|
|
#include <gst/video/video.h>
|
2012-08-01 13:44:49 +00:00
|
|
|
#if USE_DRM
|
|
|
|
# include <gst/vaapi/gstvaapidisplay_drm.h>
|
|
|
|
# include <va/va_drm.h>
|
|
|
|
# include <fcntl.h>
|
|
|
|
# include <unistd.h>
|
|
|
|
# ifndef DRM_DEVICE_PATH
|
|
|
|
# define DRM_DEVICE_PATH "/dev/dri/card0"
|
|
|
|
# endif
|
|
|
|
#endif
|
2012-07-20 14:37:01 +00:00
|
|
|
#if USE_X11
|
2012-07-23 10:56:33 +00:00
|
|
|
# include <gst/vaapi/gstvaapidisplay_x11.h>
|
2010-03-26 08:10:23 +00:00
|
|
|
#endif
|
2012-07-20 14:37:01 +00:00
|
|
|
#if USE_GLX
|
2012-07-23 10:56:33 +00:00
|
|
|
# include <gst/vaapi/gstvaapidisplay_glx.h>
|
|
|
|
#endif
|
|
|
|
#if USE_WAYLAND
|
|
|
|
# include <gst/vaapi/gstvaapidisplay_wayland.h>
|
2010-03-26 08:10:23 +00:00
|
|
|
#endif
|
2015-07-02 09:29:32 +00:00
|
|
|
#if USE_EGL
|
|
|
|
# include <gst/vaapi/gstvaapidisplay_egl.h>
|
|
|
|
#endif
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2012-07-23 14:15:38 +00:00
|
|
|
#ifdef HAVE_VA_VA_GLX_H
|
2010-03-30 13:01:34 +00:00
|
|
|
# include <va/va_glx.h>
|
|
|
|
#endif
|
|
|
|
|
2013-05-24 13:05:45 +00:00
|
|
|
/* Set to 1 to check display cache works (shared VA display) */
|
|
|
|
#define CHECK_DISPLAY_CACHE 1
|
|
|
|
|
2012-08-28 14:08:34 +00:00
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
print_value (const GValue * value, const gchar * name)
|
2012-08-28 14:08:34 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
gchar *value_string;
|
2012-08-28 14:08:34 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
value_string = g_strdup_value_contents (value);
|
|
|
|
if (!value_string)
|
|
|
|
return;
|
|
|
|
g_print (" %s: %s\n", name, value_string);
|
|
|
|
g_free (value_string);
|
2012-08-28 14:08:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-10 12:25:38 +00:00
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
print_profiles (GArray * profiles, const gchar * name)
|
2010-04-20 13:36:04 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
GstVaapiCodec codec;
|
|
|
|
const gchar *codec_name, *profile_name;
|
|
|
|
guint i;
|
2013-12-20 14:31:14 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("%u %s caps\n", profiles->len, name);
|
2013-12-20 14:31:14 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
for (i = 0; i < profiles->len; i++) {
|
|
|
|
const GstVaapiProfile profile =
|
|
|
|
g_array_index (profiles, GstVaapiProfile, i);
|
2013-12-20 14:31:14 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
codec = gst_vaapi_profile_get_codec (profile);
|
|
|
|
if (!codec)
|
|
|
|
continue;
|
2013-12-20 14:31:14 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
codec_name = gst_vaapi_codec_get_name (codec);
|
|
|
|
if (!codec_name)
|
|
|
|
continue;
|
2013-12-20 14:31:14 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
profile_name = gst_vaapi_profile_get_name (profile);
|
|
|
|
if (!profile_name)
|
|
|
|
continue;
|
2013-12-20 14:31:14 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print (" %s: %s profile\n", codec_name, profile_name);
|
|
|
|
}
|
2010-04-20 13:36:04 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 10:53:59 +00:00
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
print_format_yuv (const VAImageFormat * va_format)
|
2013-03-20 10:53:59 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
const guint32 fourcc = va_format->fourcc;
|
2013-03-20 10:53:59 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print (" fourcc '%c%c%c%c'",
|
|
|
|
fourcc & 0xff,
|
|
|
|
(fourcc >> 8) & 0xff, (fourcc >> 16) & 0xff, (fourcc >> 24) & 0xff);
|
2013-03-20 10:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
print_format_rgb (const VAImageFormat * va_format)
|
2013-03-20 10:53:59 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print (" %d bits per pixel, %s endian,",
|
|
|
|
va_format->bits_per_pixel,
|
|
|
|
va_format->byte_order == VA_MSB_FIRST ? "big" : "little");
|
|
|
|
g_print (" %s masks", va_format->alpha_mask ? "rgba" : "rgb");
|
|
|
|
g_print (" 0x%08x 0x%08x 0x%08x",
|
|
|
|
va_format->red_mask, va_format->green_mask, va_format->blue_mask);
|
|
|
|
if (va_format->alpha_mask)
|
|
|
|
g_print (" 0x%08x", va_format->alpha_mask);
|
2013-03-20 10:53:59 +00:00
|
|
|
}
|
|
|
|
|
2010-04-20 13:36:04 +00:00
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
print_formats (GArray * formats, const gchar * name)
|
2010-03-10 12:25:38 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
guint i;
|
2010-03-10 12:25:38 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("%u %s caps\n", formats->len, name);
|
2010-03-10 12:25:38 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
for (i = 0; i < formats->len; i++) {
|
|
|
|
const GstVideoFormat format = g_array_index (formats, GstVideoFormat, i);
|
|
|
|
const VAImageFormat *va_format;
|
2013-03-20 10:53:59 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print (" %s:", gst_vaapi_video_format_to_string (format));
|
2013-03-20 10:53:59 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
va_format = gst_vaapi_video_format_to_va_format (format);
|
|
|
|
if (!va_format)
|
|
|
|
g_error ("could not determine VA format");
|
2013-03-20 10:53:59 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
if (gst_vaapi_video_format_is_yuv (format))
|
|
|
|
print_format_yuv (va_format);
|
|
|
|
else
|
|
|
|
print_format_rgb (va_format);
|
|
|
|
g_print ("\n");
|
|
|
|
}
|
2010-03-10 12:25:38 +00:00
|
|
|
}
|
|
|
|
|
2012-08-28 14:08:34 +00:00
|
|
|
typedef struct _GstVaapiDisplayProperty GstVaapiDisplayProperty;
|
2016-04-29 10:48:44 +00:00
|
|
|
struct _GstVaapiDisplayProperty
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
GValue value;
|
2012-08-28 14:08:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_property_free (GstVaapiDisplayProperty * prop)
|
2012-08-28 14:08:34 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
if (!prop)
|
|
|
|
return;
|
|
|
|
g_value_unset (&prop->value);
|
|
|
|
g_slice_free (GstVaapiDisplayProperty, prop);
|
2012-08-28 14:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstVaapiDisplayProperty *
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_property_new (const gchar * name)
|
2012-08-28 14:08:34 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
GstVaapiDisplayProperty *prop;
|
2012-08-28 14:08:34 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
prop = g_slice_new0 (GstVaapiDisplayProperty);
|
|
|
|
if (!prop)
|
|
|
|
return NULL;
|
|
|
|
prop->name = name;
|
|
|
|
return prop;
|
2012-08-28 14:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
free_property_cb (gpointer data, gpointer user_data)
|
2012-08-28 14:08:34 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_property_free (data);
|
2012-08-28 14:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
dump_properties (GstVaapiDisplay * display)
|
2012-08-28 14:08:34 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
GstVaapiDisplayProperty *prop;
|
|
|
|
GPtrArray *properties;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
static const gchar *g_properties[] = {
|
|
|
|
GST_VAAPI_DISPLAY_PROP_RENDER_MODE,
|
|
|
|
GST_VAAPI_DISPLAY_PROP_ROTATION,
|
|
|
|
GST_VAAPI_DISPLAY_PROP_HUE,
|
|
|
|
GST_VAAPI_DISPLAY_PROP_SATURATION,
|
|
|
|
GST_VAAPI_DISPLAY_PROP_BRIGHTNESS,
|
|
|
|
GST_VAAPI_DISPLAY_PROP_CONTRAST,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
properties = g_ptr_array_new ();
|
|
|
|
if (!properties)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; g_properties[i] != NULL; i++) {
|
|
|
|
const gchar *const name = g_properties[i];
|
|
|
|
|
|
|
|
if (!gst_vaapi_display_has_property (display, name))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
prop = gst_vaapi_display_property_new (name);
|
|
|
|
if (!prop) {
|
|
|
|
GST_ERROR ("failed to allocate GstVaapiDisplayProperty");
|
|
|
|
goto end;
|
2012-08-28 14:08:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
if (!gst_vaapi_display_get_property (display, name, &prop->value)) {
|
|
|
|
GST_ERROR ("failed to get property '%s'", name);
|
|
|
|
goto end;
|
2012-08-28 14:08:34 +00:00
|
|
|
}
|
2016-04-29 10:48:44 +00:00
|
|
|
g_ptr_array_add (properties, prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_print ("%u properties\n", properties->len);
|
|
|
|
for (i = 0; i < properties->len; i++) {
|
|
|
|
prop = g_ptr_array_index (properties, i);
|
|
|
|
print_value (&prop->value, prop->name);
|
|
|
|
}
|
2012-08-28 14:08:34 +00:00
|
|
|
|
|
|
|
end:
|
2016-04-29 10:48:44 +00:00
|
|
|
if (properties) {
|
|
|
|
g_ptr_array_foreach (properties, free_property_cb, NULL);
|
|
|
|
g_ptr_array_free (properties, TRUE);
|
|
|
|
}
|
2012-08-28 14:08:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-11 15:21:43 +00:00
|
|
|
static void
|
2016-04-29 10:48:44 +00:00
|
|
|
dump_info (GstVaapiDisplay * display)
|
2010-01-25 16:15:01 +00:00
|
|
|
{
|
2016-04-29 10:48:44 +00:00
|
|
|
GArray *profiles, *formats;
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
profiles = gst_vaapi_display_get_decode_profiles (display);
|
|
|
|
if (!profiles)
|
|
|
|
g_error ("could not get VA decode profiles");
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
print_profiles (profiles, "decoders");
|
|
|
|
g_array_unref (profiles);
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
profiles = gst_vaapi_display_get_encode_profiles (display);
|
|
|
|
if (!profiles)
|
|
|
|
g_error ("could not get VA encode profiles");
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
print_profiles (profiles, "encoders");
|
|
|
|
g_array_unref (profiles);
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
formats = gst_vaapi_display_get_image_formats (display);
|
|
|
|
if (!formats)
|
|
|
|
g_error ("could not get VA image formats");
|
2010-03-10 12:25:38 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
print_formats (formats, "image");
|
|
|
|
g_array_unref (formats);
|
2010-03-10 12:25:38 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
formats = gst_vaapi_display_get_subpicture_formats (display);
|
|
|
|
if (!formats)
|
|
|
|
g_error ("could not get VA subpicture formats");
|
2010-03-10 12:25:38 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
print_formats (formats, "subpicture");
|
|
|
|
g_array_unref (formats);
|
2012-08-28 14:08:34 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
dump_properties (display);
|
2010-03-11 15:21:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2016-04-29 10:48:44 +00:00
|
|
|
main (int argc, char *argv[])
|
2010-03-11 15:21:43 +00:00
|
|
|
{
|
2016-04-29 10:53:06 +00:00
|
|
|
GstVaapiDisplay *display;
|
|
|
|
#if USE_X11
|
|
|
|
GstVaapiDisplay *display2;
|
|
|
|
#endif
|
|
|
|
#if USE_X11 || USE_WAYLAND
|
|
|
|
guint width, height;
|
|
|
|
guint par_n, par_d;
|
|
|
|
#endif
|
2010-03-11 15:21:43 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_init (&argc, &argv);
|
2010-03-11 15:21:43 +00:00
|
|
|
|
2012-08-01 13:44:49 +00:00
|
|
|
#if USE_DRM
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("#\n");
|
|
|
|
g_print ("# Create display with gst_vaapi_display_drm_new()\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
display = gst_vaapi_display_drm_new (NULL);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
|
|
|
|
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
|
|
|
|
|
|
|
g_print ("#\n");
|
|
|
|
g_print ("# Create display with gst_vaapi_display_drm_new_with_device()\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
int drm_device;
|
|
|
|
|
|
|
|
drm_device = open (DRM_DEVICE_PATH, O_RDWR | O_CLOEXEC);
|
|
|
|
if (drm_device < 0)
|
|
|
|
g_error ("could not open DRM device");
|
|
|
|
|
|
|
|
display = gst_vaapi_display_drm_new_with_device (drm_device);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
|
|
|
|
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
close (drm_device);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
|
|
|
|
|
|
|
g_print ("#\n");
|
|
|
|
g_print
|
|
|
|
("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayDRM()]\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
int drm_device;
|
|
|
|
VADisplay va_display;
|
|
|
|
|
|
|
|
drm_device = open (DRM_DEVICE_PATH, O_RDWR | O_CLOEXEC);
|
|
|
|
if (drm_device < 0)
|
|
|
|
g_error ("could not open DRM device");
|
|
|
|
|
|
|
|
va_display = vaGetDisplayDRM (drm_device);
|
|
|
|
if (!va_display)
|
|
|
|
g_error ("could not create VA display");
|
|
|
|
|
|
|
|
display = gst_vaapi_display_new_with_display (va_display);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
|
|
|
|
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
close (drm_device);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
2012-08-01 13:44:49 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-20 14:37:01 +00:00
|
|
|
#if USE_X11
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("#\n");
|
|
|
|
g_print ("# Create display with gst_vaapi_display_x11_new()\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
display = gst_vaapi_display_x11_new (NULL);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
2010-03-11 15:21:43 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
if (CHECK_DISPLAY_CACHE) {
|
|
|
|
display2 = gst_vaapi_display_x11_new (NULL);
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for the same X11 display */
|
|
|
|
g_assert (gst_vaapi_display_x11_get_display (GST_VAAPI_DISPLAY_X11
|
|
|
|
(display)) ==
|
|
|
|
gst_vaapi_display_x11_get_display (GST_VAAPI_DISPLAY_X11 (display2)));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for the same VA display */
|
|
|
|
g_assert (gst_vaapi_display_get_display (display) ==
|
|
|
|
gst_vaapi_display_get_display (display2));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_unref (display2);
|
2013-05-24 13:05:45 +00:00
|
|
|
|
|
|
|
#if USE_GLX
|
2016-04-29 10:48:44 +00:00
|
|
|
display2 = gst_vaapi_display_glx_new (NULL);
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for the different X11 display */
|
|
|
|
/* XXX: it is also desired to cache underlying X11 displays */
|
|
|
|
g_assert (gst_vaapi_display_x11_get_display (GST_VAAPI_DISPLAY_X11
|
|
|
|
(display)) !=
|
|
|
|
gst_vaapi_display_x11_get_display (GST_VAAPI_DISPLAY_X11 (display2)));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for different VA display */
|
|
|
|
g_assert (gst_vaapi_display_get_display (display) !=
|
|
|
|
gst_vaapi_display_get_display (display2));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_unref (display2);
|
2013-05-24 13:05:45 +00:00
|
|
|
#endif
|
2016-04-29 10:48:44 +00:00
|
|
|
}
|
2010-03-22 08:44:38 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_get_size (display, &width, &height);
|
|
|
|
g_print ("Display size: %ux%u\n", width, height);
|
2010-03-22 09:32:01 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_get_pixel_aspect_ratio (display, &par_n, &par_d);
|
|
|
|
g_print ("Pixel aspect ratio: %u/%u\n", par_n, par_d);
|
2010-03-11 15:21:43 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
2012-07-23 10:56:33 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("#\n");
|
|
|
|
g_print ("# Create display with gst_vaapi_display_x11_new_with_display()\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
Display *x11_display;
|
2010-03-11 15:21:43 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
x11_display = XOpenDisplay (NULL);
|
|
|
|
if (!x11_display)
|
|
|
|
g_error ("could not create X11 display");
|
2010-03-11 15:21:43 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
display = gst_vaapi_display_x11_new_with_display (x11_display);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
if (CHECK_DISPLAY_CACHE) {
|
|
|
|
display2 = gst_vaapi_display_x11_new_with_display (x11_display);
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for the same VA display */
|
|
|
|
g_assert (gst_vaapi_display_get_display (display) ==
|
|
|
|
gst_vaapi_display_get_display (display2));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_unref (display2);
|
2010-03-11 15:21:43 +00:00
|
|
|
}
|
2016-04-29 10:48:44 +00:00
|
|
|
|
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
XCloseDisplay (x11_display);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
|
|
|
|
|
|
|
g_print ("#\n");
|
|
|
|
g_print
|
|
|
|
("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplay()]\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
Display *x11_display;
|
|
|
|
VADisplay va_display;
|
|
|
|
|
|
|
|
x11_display = XOpenDisplay (NULL);
|
|
|
|
if (!x11_display)
|
|
|
|
g_error ("could not create X11 display");
|
|
|
|
|
|
|
|
va_display = vaGetDisplay (x11_display);
|
|
|
|
if (!va_display)
|
|
|
|
g_error ("could not create VA display");
|
|
|
|
|
|
|
|
display = gst_vaapi_display_new_with_display (va_display);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
|
|
|
|
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
XCloseDisplay (x11_display);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
2010-03-26 08:10:23 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-20 14:37:01 +00:00
|
|
|
#if USE_GLX
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("#\n");
|
|
|
|
g_print ("# Create display with gst_vaapi_display_glx_new()\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
display = gst_vaapi_display_glx_new (NULL);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
2010-03-26 08:10:23 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
if (CHECK_DISPLAY_CACHE) {
|
|
|
|
display2 = gst_vaapi_display_glx_new (NULL);
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for the same X11 display */
|
|
|
|
g_assert (gst_vaapi_display_x11_get_display (GST_VAAPI_DISPLAY_X11
|
|
|
|
(display)) ==
|
|
|
|
gst_vaapi_display_x11_get_display (GST_VAAPI_DISPLAY_X11 (display2)));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for the same VA display */
|
|
|
|
g_assert (gst_vaapi_display_get_display (display) ==
|
|
|
|
gst_vaapi_display_get_display (display2));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_unref (display2);
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
display2 = gst_vaapi_display_x11_new (NULL);
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for the same X11 display */
|
|
|
|
g_assert (gst_vaapi_display_x11_get_display (GST_VAAPI_DISPLAY_X11
|
|
|
|
(display)) ==
|
|
|
|
gst_vaapi_display_x11_get_display (GST_VAAPI_DISPLAY_X11 (display2)));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
/* Check for the same VA display */
|
|
|
|
g_assert (gst_vaapi_display_get_display (display) ==
|
|
|
|
gst_vaapi_display_get_display (display2));
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_unref (display2);
|
|
|
|
}
|
2013-05-24 13:05:45 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_get_size (display, &width, &height);
|
|
|
|
g_print ("Display size: %ux%u\n", width, height);
|
2010-03-26 08:10:23 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_vaapi_display_get_pixel_aspect_ratio (display, &par_n, &par_d);
|
|
|
|
g_print ("Pixel aspect ratio: %u/%u\n", par_n, par_d);
|
2010-03-26 08:10:23 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
2010-03-26 08:10:23 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("#\n");
|
|
|
|
g_print ("# Create display with gst_vaapi_display_glx_new_with_display()\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
Display *x11_display;
|
2012-07-23 10:56:33 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
x11_display = XOpenDisplay (NULL);
|
|
|
|
if (!x11_display)
|
|
|
|
g_error ("could not create X11 display");
|
2010-03-26 08:10:23 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
display = gst_vaapi_display_glx_new_with_display (x11_display);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
2010-03-26 08:10:23 +00:00
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
XCloseDisplay (x11_display);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
2010-03-26 08:10:23 +00:00
|
|
|
|
2012-07-23 14:15:38 +00:00
|
|
|
#ifdef HAVE_VA_VA_GLX_H
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("#\n");
|
|
|
|
g_print
|
|
|
|
("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayGLX()]\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
Display *x11_display;
|
|
|
|
VADisplay va_display;
|
|
|
|
|
|
|
|
x11_display = XOpenDisplay (NULL);
|
|
|
|
if (!x11_display)
|
|
|
|
g_error ("could not create X11 display");
|
|
|
|
|
|
|
|
va_display = vaGetDisplayGLX (x11_display);
|
|
|
|
if (!va_display)
|
|
|
|
g_error ("could not create VA display");
|
|
|
|
|
|
|
|
display = gst_vaapi_display_new_with_display (va_display);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
|
|
|
|
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
XCloseDisplay (x11_display);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
2012-07-23 14:15:38 +00:00
|
|
|
#endif
|
2010-03-26 08:10:23 +00:00
|
|
|
#endif
|
2010-03-10 12:25:38 +00:00
|
|
|
|
2012-07-23 10:56:33 +00:00
|
|
|
#if USE_WAYLAND
|
2016-04-29 10:48:44 +00:00
|
|
|
g_print ("#\n");
|
|
|
|
g_print ("# Create display with gst_vaapi_display_wayland_new()\n");
|
|
|
|
g_print ("#\n");
|
|
|
|
{
|
|
|
|
display = gst_vaapi_display_wayland_new (NULL);
|
|
|
|
if (!display)
|
|
|
|
g_error ("could not create Gst/VA display");
|
|
|
|
|
|
|
|
gst_vaapi_display_get_size (display, &width, &height);
|
|
|
|
g_print ("Display size: %ux%u\n", width, height);
|
|
|
|
|
|
|
|
gst_vaapi_display_get_pixel_aspect_ratio (display, &par_n, &par_d);
|
|
|
|
g_print ("Pixel aspect ratio: %u/%u\n", par_n, par_d);
|
|
|
|
|
|
|
|
dump_info (display);
|
|
|
|
gst_vaapi_display_unref (display);
|
|
|
|
}
|
|
|
|
g_print ("\n");
|
2012-07-23 10:56:33 +00:00
|
|
|
#endif
|
|
|
|
|
2016-04-29 10:48:44 +00:00
|
|
|
gst_deinit ();
|
|
|
|
return 0;
|
2010-01-25 16:15:01 +00:00
|
|
|
}
|