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_x11.h>
27 # include <gst/vaapi/gstvaapiwindow_x11.h>
30 # include <gst/vaapi/gstvaapidisplay_glx.h>
31 # include <gst/vaapi/gstvaapiwindow_glx.h>
35 static const VideoOutputInfo *g_video_output;
36 static const VideoOutputInfo g_video_outputs[] = {
37 /* Video outputs are sorted in test order for automatic characterisation */
40 gst_vaapi_display_x11_new,
41 gst_vaapi_window_x11_new
46 gst_vaapi_display_glx_new,
47 gst_vaapi_window_glx_new
53 static gchar *g_output_name;
54 static gboolean g_list_outputs = FALSE;
56 static GOptionEntry g_options[] = {
59 G_OPTION_ARG_NONE, &g_list_outputs,
60 "list video outputs", NULL },
63 G_OPTION_ARG_STRING, &g_output_name,
64 "video output name", NULL },
71 const VideoOutputInfo *o;
73 g_print("Video outputs:");
74 for (o = g_video_outputs; o->name != NULL; o++)
75 g_print(" %s", o->name);
80 video_output_init(int *argc, char *argv[], GOptionEntry *options)
85 #if !GLIB_CHECK_VERSION(2,31,0)
86 if (!g_thread_supported())
90 ctx = g_option_context_new("- test options");
94 g_option_context_add_group(ctx, gst_init_get_option_group());
95 g_option_context_add_main_entries(ctx, g_options, NULL);
97 g_option_context_add_main_entries(ctx, options, NULL);
98 success = g_option_context_parse(ctx, argc, &argv, NULL);
99 g_option_context_free(ctx);
101 if (g_list_outputs) {
109 video_output_exit(void)
111 g_free(g_output_name);
115 const VideoOutputInfo *
116 video_output_lookup(const gchar *output_name)
118 const VideoOutputInfo *o;
123 for (o = g_video_outputs; o->name != NULL; o++) {
124 if (g_ascii_strcasecmp(o->name, output_name) == 0)
131 video_output_create_display(const gchar *display_name)
133 const VideoOutputInfo *o = g_video_output;
134 GstVaapiDisplay *display = NULL;
138 o = video_output_lookup(g_output_name);
140 for (o = g_video_outputs; o->name != NULL; o++) {
141 display = o->create_display(display_name);
143 if (gst_vaapi_display_get_display(display))
145 g_object_unref(display);
152 g_print("Using %s video output\n", o->name);
157 display = o->create_display(display_name);
162 video_output_create_window(GstVaapiDisplay *display, guint width, guint height)
166 return g_video_output->create_window(display, width, height);