2 * output.c - Video output helpers
4 * Copyright (C) 2012 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
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_wayland.h>
39 # include <gst/vaapi/gstvaapiwindow_wayland.h>
43 static const VideoOutputInfo *g_video_output;
44 static const VideoOutputInfo g_video_outputs[] = {
45 /* Video outputs are sorted in test order for automatic characterisation */
48 gst_vaapi_display_wayland_new,
49 gst_vaapi_window_wayland_new
54 gst_vaapi_display_x11_new,
55 gst_vaapi_window_x11_new
60 gst_vaapi_display_glx_new,
61 gst_vaapi_window_glx_new
66 gst_vaapi_display_drm_new,
67 gst_vaapi_window_drm_new
73 static gchar *g_output_name;
74 static gboolean g_list_outputs = FALSE;
76 static GOptionEntry g_options[] = {
79 G_OPTION_ARG_NONE, &g_list_outputs,
80 "list video outputs", NULL },
83 G_OPTION_ARG_STRING, &g_output_name,
84 "video output name", NULL },
91 const VideoOutputInfo *o;
93 g_print("Video outputs:");
94 for (o = g_video_outputs; o->name != NULL; o++)
95 g_print(" %s", o->name);
100 video_output_init(int *argc, char *argv[], GOptionEntry *options)
105 #if !GLIB_CHECK_VERSION(2,31,0)
106 if (!g_thread_supported())
110 ctx = g_option_context_new("- test options");
114 g_option_context_add_group(ctx, gst_init_get_option_group());
115 g_option_context_add_main_entries(ctx, g_options, NULL);
117 g_option_context_add_main_entries(ctx, options, NULL);
118 success = g_option_context_parse(ctx, argc, &argv, NULL);
119 g_option_context_free(ctx);
121 if (g_list_outputs) {
129 video_output_exit(void)
131 g_free(g_output_name);
135 const VideoOutputInfo *
136 video_output_lookup(const gchar *output_name)
138 const VideoOutputInfo *o;
143 for (o = g_video_outputs; o->name != NULL; o++) {
144 if (g_ascii_strcasecmp(o->name, output_name) == 0)
151 video_output_create_display(const gchar *display_name)
153 const VideoOutputInfo *o = g_video_output;
154 GstVaapiDisplay *display = NULL;
158 o = video_output_lookup(g_output_name);
160 for (o = g_video_outputs; o->name != NULL; o++) {
161 display = o->create_display(display_name);
163 if (gst_vaapi_display_get_display(display))
165 g_object_unref(display);
172 g_print("Using %s video output\n", o->name);
177 display = o->create_display(display_name);
182 video_output_create_window(GstVaapiDisplay *display, guint width, guint height)
186 return g_video_output->create_window(display, width, height);