2 * test-textures.c - Test GstVaapiTexture
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/vaapi/gstvaapidisplay_glx.h>
22 #include <gst/vaapi/gstvaapiwindow_glx.h>
24 static inline void pause(void)
26 g_print("Press any key to continue...\n");
31 print_caps(GstCaps *caps, const gchar *name)
33 guint i, n_caps = gst_caps_get_size(caps);
35 g_print("%u %s caps\n", n_caps, name);
37 for (i = 0; i < gst_caps_get_size(caps); i++) {
38 GstStructure * const structure = gst_caps_get_structure(caps, i);
40 g_error("could not get caps structure %d", i);
42 g_print(" %s:", gst_structure_get_name(structure));
44 if (gst_structure_has_name(structure, "video/x-raw-yuv")) {
47 gst_structure_get_fourcc(structure, "format", &fourcc);
49 g_print(" fourcc '%c%c%c%c'",
52 (fourcc >> 16) & 0xff,
53 (fourcc >> 24) & 0xff);
56 gint bpp, endian, rmask, gmask, bmask, amask;
59 gst_structure_get_int(structure, "bpp", &bpp);
60 gst_structure_get_int(structure, "endianness", &endian);
61 gst_structure_get_int(structure, "red_mask", &rmask);
62 gst_structure_get_int(structure, "blue_mask", &bmask);
63 gst_structure_get_int(structure, "green_mask", &gmask);
64 has_alpha = gst_structure_get_int(structure, "alpha_mask", &amask);
66 g_print(" %d bits per pixel, %s endian,",
67 bpp, endian == G_BIG_ENDIAN ? "big" : "little");
68 g_print(" %s masks", has_alpha ? "rgba" : "rgb");
69 g_print(" 0x%08x 0x%08x 0x%08x", rmask, gmask, bmask);
71 g_print(" 0x%08x", amask);
78 dump_caps(GstVaapiDisplay *display)
82 caps = gst_vaapi_display_get_image_caps(display);
84 g_error("could not get VA image caps");
86 print_caps(caps, "image");
89 caps = gst_vaapi_display_get_subpicture_caps(display);
91 g_error("could not get VA subpicture caps");
93 print_caps(caps, "subpicture");
98 main(int argc, char *argv[])
100 GstVaapiDisplay *display;
101 GstVaapiWindow *window;
102 GstVaapiWindowGLX *glx_window;
103 GLXContext glx_context;
104 Display *x11_display;
107 static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
108 static const guint width = 320;
109 static const guint height = 240;
110 static const guint win_width = 640;
111 static const guint win_height = 480;
113 gst_init(&argc, &argv);
115 display = gst_vaapi_display_glx_new(NULL);
117 g_error("could not create Gst/VA display");
121 window = gst_vaapi_window_glx_new(display, win_width, win_height);
123 g_error("could not create window");
125 gst_vaapi_window_show(window);
127 glx_window = GST_VAAPI_WINDOW_GLX(window);
128 glx_context = gst_vaapi_window_glx_get_context(glx_window);
129 x11_display = gst_vaapi_display_x11_get_display(GST_VAAPI_DISPLAY_X11(display));
130 x11_window = gst_vaapi_object_get_id(GST_VAAPI_OBJECT(window));
132 if (!glXMakeCurrent(x11_display, x11_window, glx_context))
133 g_error("could not make VA/GLX window context current");
137 g_object_unref(window);
138 g_object_unref(display);