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>
31 static const VideoOutputInfo *g_video_output;
32 static const VideoOutputInfo g_video_outputs[] = {
33 /* Video outputs are sorted in test order for automatic characterisation */
36 gst_vaapi_display_x11_new,
37 gst_vaapi_window_x11_new
43 static gchar *g_output_name;
44 static gboolean g_list_outputs = FALSE;
46 static GOptionEntry g_options[] = {
49 G_OPTION_ARG_NONE, &g_list_outputs,
50 "list video outputs", NULL },
53 G_OPTION_ARG_STRING, &g_output_name,
54 "video output name", NULL },
61 const VideoOutputInfo *o;
63 g_print("Video outputs:");
64 for (o = g_video_outputs; o->name != NULL; o++)
65 g_print(" %s", o->name);
70 video_output_init(int *argc, char *argv[], GOptionEntry *options)
75 #if !GLIB_CHECK_VERSION(2,31,0)
76 if (!g_thread_supported())
80 ctx = g_option_context_new("- test options");
84 g_option_context_add_group(ctx, gst_init_get_option_group());
85 g_option_context_add_main_entries(ctx, g_options, NULL);
87 g_option_context_add_main_entries(ctx, options, NULL);
88 success = g_option_context_parse(ctx, argc, &argv, NULL);
89 g_option_context_free(ctx);
99 video_output_exit(void)
101 g_free(g_output_name);
105 const VideoOutputInfo *
106 video_output_lookup(const gchar *output_name)
108 const VideoOutputInfo *o;
113 for (o = g_video_outputs; o->name != NULL; o++) {
114 if (g_ascii_strcasecmp(o->name, output_name) == 0)
121 video_output_create_display(const gchar *display_name)
123 const VideoOutputInfo *o = g_video_output;
124 GstVaapiDisplay *display = NULL;
128 o = video_output_lookup(g_output_name);
130 for (o = g_video_outputs; o->name != NULL; o++) {
131 display = o->create_display(display_name);
133 if (gst_vaapi_display_get_display(display))
135 g_object_unref(display);
142 g_print("Using %s video output\n", o->name);
147 display = o->create_display(display_name);
152 video_output_create_window(GstVaapiDisplay *display, guint width, guint height)
156 return g_video_output->create_window(display, width, height);