2 * output.c - Video output helpers
4 * Copyright (C) 2012-2013 Intel Corporation
5 * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1
10 * of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA
23 #include "gst/vaapi/sysdeps.h"
27 # include <gst/vaapi/gstvaapidisplay_drm.h>
28 # include <gst/vaapi/gstvaapiwindow_drm.h>
31 # include <gst/vaapi/gstvaapidisplay_x11.h>
32 # include <gst/vaapi/gstvaapiwindow_x11.h>
33 # include <gst/vaapi/gstvaapipixmap_x11.h>
36 # include <gst/vaapi/gstvaapidisplay_glx.h>
37 # include <gst/vaapi/gstvaapiwindow_glx.h>
40 # include <gst/vaapi/gstvaapidisplay_wayland.h>
41 # include <gst/vaapi/gstvaapiwindow_wayland.h>
45 static const VideoOutputInfo *g_video_output;
46 static const VideoOutputInfo g_video_outputs[] = {
47 /* Video outputs are sorted in test order for automatic characterisation */
50 gst_vaapi_display_wayland_new,
51 gst_vaapi_window_wayland_new
56 gst_vaapi_display_x11_new,
57 gst_vaapi_window_x11_new,
58 gst_vaapi_pixmap_x11_new
63 gst_vaapi_display_glx_new,
64 gst_vaapi_window_glx_new,
65 gst_vaapi_pixmap_x11_new
70 gst_vaapi_display_drm_new,
71 gst_vaapi_window_drm_new
77 static gchar *g_output_name;
78 static gboolean g_list_outputs = FALSE;
79 static gboolean g_fullscreen = FALSE;
81 static GOptionEntry g_options[] = {
84 G_OPTION_ARG_NONE, &g_list_outputs,
85 "list video outputs", NULL },
88 G_OPTION_ARG_STRING, &g_output_name,
89 "video output name", NULL },
92 G_OPTION_ARG_NONE, &g_fullscreen,
93 "fullscreen mode", NULL },
100 const VideoOutputInfo *o;
102 g_print("Video outputs:");
103 for (o = g_video_outputs; o->name != NULL; o++)
104 g_print(" %s", o->name);
109 video_output_init(int *argc, char *argv[], GOptionEntry *options)
114 #if !GLIB_CHECK_VERSION(2,31,0)
115 if (!g_thread_supported())
119 ctx = g_option_context_new("- test options");
123 g_option_context_add_group(ctx, gst_init_get_option_group());
124 g_option_context_add_main_entries(ctx, g_options, NULL);
126 g_option_context_add_main_entries(ctx, options, NULL);
127 success = g_option_context_parse(ctx, argc, &argv, NULL);
128 g_option_context_free(ctx);
130 if (g_list_outputs) {
138 video_output_exit(void)
140 g_free(g_output_name);
144 const VideoOutputInfo *
145 video_output_lookup(const gchar *output_name)
147 const VideoOutputInfo *o;
152 for (o = g_video_outputs; o->name != NULL; o++) {
153 if (g_ascii_strcasecmp(o->name, output_name) == 0)
160 video_output_create_display(const gchar *display_name)
162 const VideoOutputInfo *o = g_video_output;
163 GstVaapiDisplay *display = NULL;
167 o = video_output_lookup(g_output_name);
169 for (o = g_video_outputs; o->name != NULL; o++) {
170 display = o->create_display(display_name);
172 if (gst_vaapi_display_get_display(display))
174 gst_vaapi_display_unref(display);
181 g_print("Using %s video output\n", o->name);
186 display = o->create_display(display_name);
191 video_output_create_window(GstVaapiDisplay *display, guint width, guint height)
193 GstVaapiWindow *window;
198 window = g_video_output->create_window(display, width, height);
202 /* Force fullscreen mode, should this be requested by the user */
204 gst_vaapi_window_set_fullscreen(window, TRUE);
209 video_output_create_pixmap(GstVaapiDisplay *display, GstVideoFormat format,
210 guint width, guint height)
212 if (!g_video_output || !g_video_output->create_pixmap)
214 return g_video_output->create_pixmap(display, format, width, height);