1 /* GStreamer
2 * Copyright (C) 2020 Igalia, S.L.
3 * Author: Víctor Jáquez <vjaquez@igalia.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 /**
22 * SECTION:gstvadisplaywrapped
23 * @title: GstVaDisplayWrapped
24 * @short_description: User's custom VADisplay
25 * @sources:
26 * - gstvadisplay_wrapped.h
27 *
28 * This is a #GstVaDisplay instantiaton subclass for custom created
29 * VADisplay, such as X11 or Wayland, wrapping it.
30 */
31
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35
36 #include "gstvadisplay_wrapped.h"
37
38 /**
39 * GstVaDisplayWrapped:
40 * @parent: parent #GstVaDisplay
41 *
42 * Since: 1.20
43 */
44 struct _GstVaDisplayWrapped
45 {
46 GstVaDisplay parent;
47 };
48
49 /**
50 * GstVaDisplayWrappedClass:
51 * @parent_class: parent #GstVaDisplayClass
52 *
53 * Since: 1.20
54 */
55 struct _GstVaDisplayWrappedClass
56 {
57 GstVaDisplayClass parent_class;
58 };
59
60 #define gst_va_display_wrapped_parent_class parent_class
61 G_DEFINE_TYPE (GstVaDisplayWrapped, gst_va_display_wrapped,
62 GST_TYPE_VA_DISPLAY);
63
64 static void
gst_va_display_wrapped_class_init(GstVaDisplayWrappedClass * klass)65 gst_va_display_wrapped_class_init (GstVaDisplayWrappedClass * klass)
66 {
67 }
68
69 static void
gst_va_display_wrapped_init(GstVaDisplayWrapped * self)70 gst_va_display_wrapped_init (GstVaDisplayWrapped * self)
71 {
72 }
73
74 /**
75 * gst_va_display_wrapped_new:
76 * @handle: a VADisplay to wrap
77 *
78 * Creates a #GstVaDisplay wrapping an already created and initialized
79 * VADisplay.
80 *
81 * The lifetime of @handle must be hold by the provider while the
82 * pipeline is instantiated. Do not call vaTerminate on it while the
83 * pipeline is not in NULL state.
84 *
85 * Returns: (transfer full): a new #GstVaDisplay if @handle is valid,
86 * Otherwise %NULL.
87 *
88 * Since: 1.20
89 **/
90 GstVaDisplay *
gst_va_display_wrapped_new(gpointer handle)91 gst_va_display_wrapped_new (gpointer handle)
92 {
93 GstVaDisplay *dpy;
94
95 g_return_val_if_fail (handle, NULL);
96
97 dpy = g_object_new (GST_TYPE_VA_DISPLAY_WRAPPED, "va-display", handle, NULL);
98 if (!gst_va_display_initialize (dpy)) {
99 gst_object_unref (dpy);
100 return NULL;
101 }
102
103 return gst_object_ref_sink (dpy);
104 }
105