1 /*
2  *  gstvaapiobject_priv.h - Base VA object (private definitions)
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2012-2013 Intel Corporation
7  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation; either version 2.1
12  *  of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free
21  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA 02110-1301 USA
23  */
24 
25 #ifndef GST_VAAPI_OBJECT_PRIV_H
26 #define GST_VAAPI_OBJECT_PRIV_H
27 
28 #include <gst/vaapi/gstvaapiobject.h>
29 #include "gstvaapiminiobject.h"
30 #include "gstvaapidisplay_priv.h"
31 
32 G_BEGIN_DECLS
33 
34 #define GST_VAAPI_OBJECT_CLASS(klass) \
35   ((GstVaapiObjectClass *) (klass))
36 #define GST_VAAPI_IS_OBJECT_CLASS(klass) \
37   ((klass) != NULL)
38 #define GST_VAAPI_OBJECT_GET_CLASS(object) \
39   GST_VAAPI_OBJECT_CLASS (GST_VAAPI_MINI_OBJECT_GET_CLASS (object))
40 
41 typedef struct _GstVaapiObjectClass GstVaapiObjectClass;
42 typedef void (*GstVaapiObjectInitFunc) (GstVaapiObject * object);
43 typedef void (*GstVaapiObjectFinalizeFunc) (GstVaapiObject * object);
44 
45 #define GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(TN, t_n, code)  \
46 static inline const GstVaapiObjectClass *                       \
47 G_PASTE(t_n,_class) (void)                                      \
48 {                                                               \
49     static G_PASTE(TN,Class) g_class;                           \
50     static gsize g_class_init = FALSE;                          \
51                                                                 \
52     if (g_once_init_enter (&g_class_init)) {                    \
53         GstVaapiObjectClass * const klass =                     \
54             GST_VAAPI_OBJECT_CLASS (&g_class);                  \
55         gst_vaapi_object_class_init (klass, sizeof(TN));        \
56         code;                                                   \
57         klass->finalize = (GstVaapiObjectFinalizeFunc)          \
58             G_PASTE(t_n,_finalize);                             \
59         g_once_init_leave (&g_class_init, TRUE);                \
60     }                                                           \
61     return GST_VAAPI_OBJECT_CLASS (&g_class);                   \
62 }
63 
64 #define GST_VAAPI_OBJECT_DEFINE_CLASS(TN, t_n) \
65   GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (TN, t_n, /**/)
66 
67 /**
68  * GST_VAAPI_OBJECT_ID:
69  * @object: a #GstVaapiObject
70  *
71  * Macro that evaluates to the #GstVaapiID contained in @object.
72  * This is an internal macro that does not do any run-time type checks.
73  */
74 #define GST_VAAPI_OBJECT_ID(object) \
75   (GST_VAAPI_OBJECT (object)->object_id)
76 
77 /**
78  * GST_VAAPI_OBJECT_DISPLAY:
79  * @object: a #GstVaapiObject
80  *
81  * Macro that evaluates to the #GstVaapiDisplay the @object is bound to.
82  * This is an internal macro that does not do any run-time type check.
83  */
84 #define GST_VAAPI_OBJECT_DISPLAY(object) \
85   (GST_VAAPI_OBJECT (object)->display)
86 
87 /**
88  * GST_VAAPI_OBJECT_DISPLAY_X11:
89  * @object: a #GstVaapiObject
90  *
91  * Macro that evaluates to the #GstVaapiDisplayX11 the @object is bound to.
92  * This is an internal macro that does not do any run-time type check
93  * and requires #include "gstvaapidisplay_x11_priv.h"
94  */
95 #define GST_VAAPI_OBJECT_DISPLAY_X11(object) \
96   GST_VAAPI_DISPLAY_X11_CAST (GST_VAAPI_OBJECT_DISPLAY (object))
97 
98 /**
99  * GST_VAAPI_OBJECT_DISPLAY_GLX:
100  * @object: a #GstVaapiObject
101  *
102  * Macro that evaluates to the #GstVaapiDisplayGLX the @object is bound to.
103  * This is an internal macro that does not do any run-time type check
104  * and requires #include "gstvaapidisplay_glx_priv.h".
105  */
106 #define GST_VAAPI_OBJECT_DISPLAY_GLX(object) \
107   GST_VAAPI_DISPLAY_GLX_CAST (GST_VAAPI_OBJECT_DISPLAY (object))
108 
109 /**
110  * GST_VAAPI_OBJECT_DISPLAY_WAYLAND:
111  * @object: a #GstVaapiObject
112  *
113  * Macro that evaluates to the #GstVaapiDisplayWayland the @object is
114  * bound to.  This is an internal macro that does not do any run-time
115  * type check and requires #include "gstvaapidisplay_wayland_priv.h"
116  */
117 #define GST_VAAPI_OBJECT_DISPLAY_WAYLAND(object) \
118   GST_VAAPI_DISPLAY_WAYLAND_CAST (GST_VAAPI_OBJECT_DISPLAY (object))
119 
120 /**
121  * GST_VAAPI_OBJECT_VADISPLAY:
122  * @object: a #GstVaapiObject
123  *
124  * Macro that evaluates to the #VADisplay of @display.
125  * This is an internal macro that does not do any run-time type check
126  * and requires #include "gstvaapidisplay_priv.h".
127  */
128 #define GST_VAAPI_OBJECT_VADISPLAY(object) \
129   GST_VAAPI_DISPLAY_VADISPLAY (GST_VAAPI_OBJECT_DISPLAY (object))
130 
131 /**
132  * GST_VAAPI_OBJECT_NATIVE_DISPLAY:
133  * @object: a #GstVaapiObject
134  *
135  * Macro that evaluates to the underlying native @display object.
136  * This is an internal macro that does not do any run-time type check.
137  */
138 #define GST_VAAPI_OBJECT_NATIVE_DISPLAY(object) \
139   GST_VAAPI_DISPLAY_NATIVE (GST_VAAPI_OBJECT_DISPLAY (object))
140 
141 /**
142  * GST_VAAPI_OBJECT_LOCK_DISPLAY:
143  * @object: a #GstVaapiObject
144  *
145  * Macro that locks the #GstVaapiDisplay contained in the @object.
146  * This is an internal macro that does not do any run-time type check.
147  */
148 #define GST_VAAPI_OBJECT_LOCK_DISPLAY(object) \
149   GST_VAAPI_DISPLAY_LOCK (GST_VAAPI_OBJECT_DISPLAY (object))
150 
151 /**
152  * GST_VAAPI_OBJECT_UNLOCK_DISPLAY:
153  * @object: a #GstVaapiObject
154  *
155  * Macro that unlocks the #GstVaapiDisplay contained in the @object.
156  * This is an internal macro that does not do any run-time type check.
157  */
158 #define GST_VAAPI_OBJECT_UNLOCK_DISPLAY(object) \
159   GST_VAAPI_DISPLAY_UNLOCK (GST_VAAPI_OBJECT_DISPLAY (object))
160 
161 /**
162  * GstVaapiObject:
163  *
164  * VA object base.
165  */
166 struct _GstVaapiObject
167 {
168   /*< private >*/
169   GstVaapiMiniObject parent_instance;
170 
171   GstVaapiDisplay *display;
172   GstVaapiID object_id;
173 };
174 
175 /**
176  * GstVaapiObjectClass:
177  *
178  * VA object base class.
179  */
180 struct _GstVaapiObjectClass
181 {
182   /*< private >*/
183   GstVaapiMiniObjectClass parent_class;
184 
185   GstVaapiObjectInitFunc init;
186   GstVaapiObjectFinalizeFunc finalize;
187 };
188 
189 void
190 gst_vaapi_object_class_init (GstVaapiObjectClass * klass, guint size);
191 
192 gpointer
193 gst_vaapi_object_new (const GstVaapiObjectClass * klass,
194     GstVaapiDisplay * display);
195 
196 G_END_DECLS
197 
198 #endif /* GST_VAAPI_OBJECT_PRIV_H */
199