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"
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>
34 # include <gst/vaapi/gstvaapidisplay_glx.h>
35 # include <gst/vaapi/gstvaapiwindow_glx.h>
38 # include <gst/vaapi/gstvaapidisplay_egl.h>
39 # include <gst/vaapi/gstvaapiwindow_egl.h>
42 # include <gst/vaapi/gstvaapidisplay_wayland.h>
43 # include <gst/vaapi/gstvaapiwindow_wayland.h>
47 static const VideoOutputInfo *g_video_output;
48 static const VideoOutputInfo g_video_outputs[] = {
49 /* Video outputs are sorted in test order for automatic characterisation */
52 gst_vaapi_display_wayland_new,
53 gst_vaapi_window_wayland_new},
57 gst_vaapi_display_x11_new,
58 gst_vaapi_window_x11_new},
62 gst_vaapi_display_glx_new,
63 gst_vaapi_window_glx_new},
67 gst_vaapi_display_drm_new,
68 gst_vaapi_window_drm_new},
73 static gchar *g_output_name;
74 static gboolean g_list_outputs = FALSE;
75 static gboolean g_fullscreen = FALSE;
77 static gboolean g_egl_mode = FALSE;
78 static guint g_gles_version;
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},
95 G_OPTION_ARG_NONE, &g_egl_mode,
96 "enable EGL rendering", NULL},
99 G_OPTION_ARG_INT, &g_gles_version,
100 "OpenGL|ES version (in --egl mode)", NULL},
107 const VideoOutputInfo *o;
109 g_print ("Video outputs:");
110 for (o = g_video_outputs; o->name != NULL; o++)
111 g_print (" %s", o->name);
116 video_output_init (int *argc, char *argv[], GOptionEntry * options)
121 ctx = g_option_context_new ("- test options");
125 g_option_context_add_group (ctx, gst_init_get_option_group ());
126 g_option_context_add_main_entries (ctx, g_options, NULL);
128 g_option_context_add_main_entries (ctx, options, NULL);
129 success = g_option_context_parse (ctx, argc, &argv, NULL);
130 g_option_context_free (ctx);
132 if (g_list_outputs) {
140 video_output_exit (void)
142 g_free (g_output_name);
146 const VideoOutputInfo *
147 video_output_lookup (const gchar * output_name)
149 const VideoOutputInfo *o;
154 for (o = g_video_outputs; o->name != NULL; o++) {
155 if (g_ascii_strcasecmp (o->name, output_name) == 0)
162 video_output_create_display (const gchar * display_name)
164 const VideoOutputInfo *o = g_video_output;
165 GstVaapiDisplay *egl_display, *display = NULL;
169 o = video_output_lookup (g_output_name);
171 for (o = g_video_outputs; o->name != NULL; o++) {
172 display = o->create_display (display_name);
174 if (gst_vaapi_display_get_display (display))
176 gst_object_unref (display);
183 g_print ("Using %s video output\n", o->name);
188 display = o->create_display (display_name);
192 egl_display = gst_vaapi_display_egl_new (display, g_gles_version);
195 g_print ("error: unsupported EGL renderering mode\n");
197 gst_object_unref (display);
200 display = egl_display;
206 video_output_create_window (GstVaapiDisplay * display, guint width,
209 GstVaapiWindow *window;
216 window = gst_vaapi_window_egl_new (display, width, height);
219 window = g_video_output->create_window (display, width, height);
223 /* Force fullscreen mode, should this be requested by the user */
225 gst_vaapi_window_set_fullscreen (window, TRUE);