2 * output.c - Video output helpers
4 * Copyright (C) 2012-2013 Intel Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
22 #include "gst/vaapi/sysdeps.h"
26 # include <gst/vaapi/gstvaapidisplay_drm.h>
27 # include <gst/vaapi/gstvaapiwindow_drm.h>
30 # include <gst/vaapi/gstvaapidisplay_x11.h>
31 # include <gst/vaapi/gstvaapiwindow_x11.h>
32 # include <gst/vaapi/gstvaapipixmap_x11.h>
35 # include <gst/vaapi/gstvaapidisplay_glx.h>
36 # include <gst/vaapi/gstvaapiwindow_glx.h>
39 # include <gst/vaapi/gstvaapidisplay_wayland.h>
40 # include <gst/vaapi/gstvaapiwindow_wayland.h>
44 static const VideoOutputInfo *g_video_output;
45 static const VideoOutputInfo g_video_outputs[] = {
46 /* Video outputs are sorted in test order for automatic characterisation */
49 gst_vaapi_display_wayland_new,
50 gst_vaapi_window_wayland_new
55 gst_vaapi_display_x11_new,
56 gst_vaapi_window_x11_new,
57 gst_vaapi_pixmap_x11_new
62 gst_vaapi_display_glx_new,
63 gst_vaapi_window_glx_new,
64 gst_vaapi_pixmap_x11_new
69 gst_vaapi_display_drm_new,
70 gst_vaapi_window_drm_new
76 static gchar *g_output_name;
77 static gboolean g_list_outputs = FALSE;
78 static gboolean g_fullscreen = FALSE;
80 static GOptionEntry g_options[] = {
83 G_OPTION_ARG_NONE, &g_list_outputs,
84 "list video outputs", NULL },
87 G_OPTION_ARG_STRING, &g_output_name,
88 "video output name", NULL },
91 G_OPTION_ARG_NONE, &g_fullscreen,
92 "fullscreen mode", NULL },
99 const VideoOutputInfo *o;
101 g_print("Video outputs:");
102 for (o = g_video_outputs; o->name != NULL; o++)
103 g_print(" %s", o->name);
108 video_output_init(int *argc, char *argv[], GOptionEntry *options)
113 #if !GLIB_CHECK_VERSION(2,31,0)
114 if (!g_thread_supported())
118 ctx = g_option_context_new("- test options");
122 g_option_context_add_group(ctx, gst_init_get_option_group());
123 g_option_context_add_main_entries(ctx, g_options, NULL);
125 g_option_context_add_main_entries(ctx, options, NULL);
126 success = g_option_context_parse(ctx, argc, &argv, NULL);
127 g_option_context_free(ctx);
129 if (g_list_outputs) {
137 video_output_exit(void)
139 g_free(g_output_name);
143 const VideoOutputInfo *
144 video_output_lookup(const gchar *output_name)
146 const VideoOutputInfo *o;
151 for (o = g_video_outputs; o->name != NULL; o++) {
152 if (g_ascii_strcasecmp(o->name, output_name) == 0)
159 video_output_create_display(const gchar *display_name)
161 const VideoOutputInfo *o = g_video_output;
162 GstVaapiDisplay *display = NULL;
166 o = video_output_lookup(g_output_name);
168 for (o = g_video_outputs; o->name != NULL; o++) {
169 display = o->create_display(display_name);
171 if (gst_vaapi_display_get_display(display))
173 gst_vaapi_display_unref(display);
180 g_print("Using %s video output\n", o->name);
185 display = o->create_display(display_name);
190 video_output_create_window(GstVaapiDisplay *display, guint width, guint height)
192 GstVaapiWindow *window;
197 window = g_video_output->create_window(display, width, height);
201 /* Force fullscreen mode, should this be requested by the user */
203 gst_vaapi_window_set_fullscreen(window, TRUE);
208 video_output_create_pixmap(GstVaapiDisplay *display, GstVideoFormat format,
209 guint width, guint height)
211 if (!g_video_output || !g_video_output->create_pixmap)
213 return g_video_output->create_pixmap(display, format, width, height);