2 * test-display.c - Test GstVaapiDisplayX11
4 * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <gst/video/video.h>
22 #include <gst/vaapi/gstvaapidisplay_x11.h>
25 print_caps(GstCaps *caps, const gchar *name)
27 guint i, n_caps = gst_caps_get_size(caps);
29 g_print("%u %s caps\n", n_caps, name);
31 for (i = 0; i < gst_caps_get_size(caps); i++) {
32 GstStructure * const structure = gst_caps_get_structure(caps, i);
34 g_error("could not get caps structure %d", i);
36 g_print(" %s:", gst_structure_get_name(structure));
38 if (gst_structure_has_name(structure, "video/x-raw-yuv")) {
41 gst_structure_get_fourcc(structure, "format", &fourcc);
43 g_print(" fourcc '%c%c%c%c'",
46 (fourcc >> 16) & 0xff,
47 (fourcc >> 24) & 0xff);
50 gint bpp, endian, rmask, gmask, bmask, amask;
53 gst_structure_get_int(structure, "bpp", &bpp);
54 gst_structure_get_int(structure, "endianness", &endian);
55 gst_structure_get_int(structure, "red_mask", &rmask);
56 gst_structure_get_int(structure, "blue_mask", &bmask);
57 gst_structure_get_int(structure, "green_mask", &gmask);
58 has_alpha = gst_structure_get_int(structure, "alpha_mask", &amask);
60 g_print(" %d bits per pixel, %s endian,",
61 bpp, endian == G_BIG_ENDIAN ? "big" : "little");
62 g_print(" %s masks", has_alpha ? "rgba" : "rgb");
63 g_print(" 0x%08x 0x%08x 0x%08x", rmask, gmask, bmask);
65 g_print(" 0x%08x", amask);
72 dump_caps(GstVaapiDisplay *display)
76 caps = gst_vaapi_display_get_image_caps(display);
78 g_error("could not get VA image caps");
80 print_caps(caps, "image");
83 caps = gst_vaapi_display_get_subpicture_caps(display);
85 g_error("could not get VA subpicture caps");
87 print_caps(caps, "subpicture");
92 main(int argc, char *argv[])
96 GstVaapiDisplay *display;
99 gst_init(&argc, &argv);
102 g_print("# Create display with gst_vaapi_display_x11_new()\n");
105 display = gst_vaapi_display_x11_new(NULL);
107 g_error("could not create Gst/VA display");
109 gst_vaapi_display_get_size(display, &width, &height);
110 g_print("Display size: %ux%u\n", width, height);
113 g_object_unref(display);
118 g_print("# Create display with gst_vaapi_display_x11_new_with_display()\n");
121 x11_display = XOpenDisplay(NULL);
123 g_error("could not create X11 display");
125 display = gst_vaapi_display_x11_new_with_display(x11_display);
127 g_error("could not create Gst/VA display");
130 g_object_unref(display);
131 XCloseDisplay(x11_display);
136 g_print("# Create display with gst_vaapi_display_new_with_display()\n");
139 x11_display = XOpenDisplay(NULL);
141 g_error("could not create X11 display");
143 va_display = vaGetDisplay(x11_display);
145 g_error("could not create VA display");
147 display = gst_vaapi_display_new_with_display(va_display);
149 g_error("could not create Gst/VA display");
152 g_object_unref(display);
153 XCloseDisplay(x11_display);