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>
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_egl.h>
40 # include <gst/vaapi/gstvaapiwindow_egl.h>
43 # include <gst/vaapi/gstvaapidisplay_wayland.h>
44 # include <gst/vaapi/gstvaapiwindow_wayland.h>
48 static const VideoOutputInfo *g_video_output;
49 static const VideoOutputInfo g_video_outputs[] = {
50 /* Video outputs are sorted in test order for automatic characterisation */
53 gst_vaapi_display_wayland_new,
54 gst_vaapi_window_wayland_new},
58 gst_vaapi_display_x11_new,
59 gst_vaapi_window_x11_new,
60 gst_vaapi_pixmap_x11_new},
64 gst_vaapi_display_glx_new,
65 gst_vaapi_window_glx_new,
66 gst_vaapi_pixmap_x11_new},
70 gst_vaapi_display_drm_new,
71 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 gboolean g_egl_mode = FALSE;
81 static guint g_gles_version;
83 static GOptionEntry g_options[] = {
86 G_OPTION_ARG_NONE, &g_list_outputs,
87 "list video outputs", NULL},
90 G_OPTION_ARG_STRING, &g_output_name,
91 "video output name", NULL},
94 G_OPTION_ARG_NONE, &g_fullscreen,
95 "fullscreen mode", NULL},
98 G_OPTION_ARG_NONE, &g_egl_mode,
99 "enable EGL rendering", NULL},
102 G_OPTION_ARG_INT, &g_gles_version,
103 "OpenGL|ES version (in --egl mode)", NULL},
110 const VideoOutputInfo *o;
112 g_print ("Video outputs:");
113 for (o = g_video_outputs; o->name != NULL; o++)
114 g_print (" %s", o->name);
119 video_output_init (int *argc, char *argv[], GOptionEntry * options)
124 ctx = g_option_context_new ("- test options");
128 g_option_context_add_group (ctx, gst_init_get_option_group ());
129 g_option_context_add_main_entries (ctx, g_options, NULL);
131 g_option_context_add_main_entries (ctx, options, NULL);
132 success = g_option_context_parse (ctx, argc, &argv, NULL);
133 g_option_context_free (ctx);
135 if (g_list_outputs) {
143 video_output_exit (void)
145 g_free (g_output_name);
149 const VideoOutputInfo *
150 video_output_lookup (const gchar * output_name)
152 const VideoOutputInfo *o;
157 for (o = g_video_outputs; o->name != NULL; o++) {
158 if (g_ascii_strcasecmp (o->name, output_name) == 0)
165 video_output_create_display (const gchar * display_name)
167 const VideoOutputInfo *o = g_video_output;
168 GstVaapiDisplay *egl_display, *display = NULL;
172 o = video_output_lookup (g_output_name);
174 for (o = g_video_outputs; o->name != NULL; o++) {
175 display = o->create_display (display_name);
177 if (gst_vaapi_display_get_display (display))
179 gst_object_unref (display);
186 g_print ("Using %s video output\n", o->name);
191 display = o->create_display (display_name);
195 egl_display = gst_vaapi_display_egl_new (display, g_gles_version);
198 g_print ("error: unsupported EGL renderering mode\n");
200 gst_object_unref (display);
203 display = egl_display;
209 video_output_create_window (GstVaapiDisplay * display, guint width,
212 GstVaapiWindow *window;
219 window = gst_vaapi_window_egl_new (display, width, height);
222 window = g_video_output->create_window (display, width, height);
226 /* Force fullscreen mode, should this be requested by the user */
228 gst_vaapi_window_set_fullscreen (window, TRUE);
233 video_output_create_pixmap (GstVaapiDisplay * display, GstVideoFormat format,
234 guint width, guint height)
236 if (!g_video_output || !g_video_output->create_pixmap)
238 return g_video_output->create_pixmap (display, format, width, height);