Tizen 2.0 Release
[framework/multimedia/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapisurface.h
1 /*
2  *  gstvaapisurface.h - VA surface abstraction
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *  Copyright (C) 2011 Intel Corporation
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Lesser General Public License
9  *  as published by the Free Software Foundation; either version 2.1
10  *  of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public
18  *  License along with this library; if not, write to the Free
19  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  *  Boston, MA 02110-1301 USA
21  */
22
23 #ifndef GST_VAAPI_SURFACE_H
24 #define GST_VAAPI_SURFACE_H
25
26 #include <gst/vaapi/gstvaapiobject.h>
27 #include <gst/vaapi/gstvaapidisplay.h>
28 #include <gst/vaapi/gstvaapiimage.h>
29 #include <gst/vaapi/gstvaapisubpicture.h>
30 #include <gst/video/gstsurfacebuffer.h>
31 #include <gst/video/video-overlay-composition.h>
32
33 G_BEGIN_DECLS
34
35 typedef enum _GstVaapiChromaType                GstVaapiChromaType;
36 typedef enum _GstVaapiSurfaceStatus             GstVaapiSurfaceStatus;
37 typedef enum _GstVaapiSurfaceRenderFlags        GstVaapiSurfaceRenderFlags;
38
39 /**
40  * GST_VAAPI_SURFACE_CAPS_NAME:
41  *
42  * Generic caps type for VA surfaces.
43  */
44 #define GST_VAAPI_SURFACE_CAPS_NAME GST_VIDEO_CAPS_SURFACE
45
46 /**
47  * GST_VAAPI_SURFACE_CAPS:
48  *
49  * Generic caps for VA surfaces.
50  */
51 #define GST_VAAPI_SURFACE_CAPS                  \
52     GST_VAAPI_SURFACE_CAPS_NAME ", "            \
53     "type = vaapi, "                            \
54     "opengl = (boolean) { true, false }, "      \
55     "width  = (int) [ 1, MAX ], "               \
56     "height = (int) [ 1, MAX ], "               \
57     "framerate = (fraction) [ 0, MAX ]"
58
59 #define GST_VAAPI_BUFFER_SHARING_CAPS_NAME "video/x-vaapi-sharing"
60
61 #define GST_VAAPI_BUFFER_SHARING_CAPS           \
62     GST_VAAPI_BUFFER_SHARING_CAPS_NAME ", "     \
63     "type = vaapi, "                            \
64     "width  = (int) [ 1, MAX ], "               \
65     "height = (int) [ 1, MAX ], "               \
66     "framerate = (fraction) [ 0, MAX ]"
67
68 /**
69  * GstVaapiChromaType:
70  * @GST_VAAPI_CHROMA_TYPE_YUV420: 4:2:0 chroma format
71  * @GST_VAAPI_CHROMA_TYPE_YUV422: 4:2:2 chroma format
72  * @GST_VAAPI_CHROMA_TYPE_YUV444: 4:4:4 chroma format
73  *
74  * The set of all chroma types for #GstVaapiSurface.
75  */
76 enum _GstVaapiChromaType {
77     GST_VAAPI_CHROMA_TYPE_YUV420 = 1,
78     GST_VAAPI_CHROMA_TYPE_YUV422,
79     GST_VAAPI_CHROMA_TYPE_YUV444
80 };
81
82 /**
83  * GstVaapiSurfaceStatus:
84  * @GST_VAAPI_SURFACE_STATUS_IDLE:
85  *   the surface is not being rendered or displayed
86  * @GST_VAAPI_SURFACE_STATUS_RENDERING:
87  *   the surface is used for rendering (decoding to the surface in progress)
88  * @GST_VAAPI_SURFACE_STATUS_DISPLAYING:
89  *   the surface is being displayed to screen
90  * @GST_VAAPI_SURFACE_STATUS_SKIPPED:
91  *   indicates a skipped frame during encode
92  *
93  * The set of all surface status for #GstVaapiSurface.
94  */
95 enum _GstVaapiSurfaceStatus {
96     GST_VAAPI_SURFACE_STATUS_IDLE       = 1 << 0,
97     GST_VAAPI_SURFACE_STATUS_RENDERING  = 1 << 1,
98     GST_VAAPI_SURFACE_STATUS_DISPLAYING = 1 << 2,
99     GST_VAAPI_SURFACE_STATUS_SKIPPED    = 1 << 3
100 };
101
102 /**
103  * GstVaapiSurfaceRenderFlags
104  * @GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD:
105  *   selects the top field of the surface
106  * @GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD:
107  *   selects the bottom field of the surface
108  * @GST_VAAPI_PICTURE_STRUCTURE_FRAME:
109  *   selects the entire surface
110  * @GST_VAAPI_COLOR_STANDARD_ITUR_BT_601:
111  *   uses ITU-R BT.601 standard for color space conversion
112  * @GST_VAAPI_COLOR_STANDARD_ITUR_BT_709:
113  *   uses ITU-R BT.709 standard for color space conversion
114  *
115  * The set of all render flags for gst_vaapi_window_put_surface().
116  */
117 enum _GstVaapiSurfaceRenderFlags {
118     GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD       = 1 << 0,
119     GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD    = 1 << 1,
120     GST_VAAPI_PICTURE_STRUCTURE_FRAME           =
121     (
122         GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD |
123         GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD
124     ),
125     GST_VAAPI_COLOR_STANDARD_ITUR_BT_601        = 1 << 2,
126     GST_VAAPI_COLOR_STANDARD_ITUR_BT_709        = 1 << 3,
127 };
128
129 #define GST_VAAPI_TYPE_SURFACE \
130     (gst_vaapi_surface_get_type())
131
132 #define GST_VAAPI_SURFACE(obj)                          \
133     (G_TYPE_CHECK_INSTANCE_CAST((obj),                  \
134                                 GST_VAAPI_TYPE_SURFACE, \
135                                 GstVaapiSurface))
136
137 #define GST_VAAPI_SURFACE_CLASS(klass)                  \
138     (G_TYPE_CHECK_CLASS_CAST((klass),                   \
139                              GST_VAAPI_TYPE_SURFACE,    \
140                              GstVaapiSurfaceClass))
141
142 #define GST_VAAPI_IS_SURFACE(obj) \
143     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_SURFACE))
144
145 #define GST_VAAPI_IS_SURFACE_CLASS(klass) \
146     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_SURFACE))
147
148 #define GST_VAAPI_SURFACE_GET_CLASS(obj)                \
149     (G_TYPE_INSTANCE_GET_CLASS((obj),                   \
150                                GST_VAAPI_TYPE_SURFACE,  \
151                                GstVaapiSurfaceClass))
152
153 typedef struct _GstVaapiSurface                 GstVaapiSurface;
154 typedef struct _GstVaapiSurfacePrivate          GstVaapiSurfacePrivate;
155 typedef struct _GstVaapiSurfaceClass            GstVaapiSurfaceClass;
156
157 /**
158  * GstVaapiSurface:
159  *
160  * A VA surface wrapper.
161  */
162 struct _GstVaapiSurface {
163     /*< private >*/
164     GstVaapiObject parent_instance;
165
166     GstVaapiSurfacePrivate *priv;
167 };
168
169 /**
170  * GstVaapiSurfaceClass:
171  *
172  * A VA surface wrapper class.
173  */
174 struct _GstVaapiSurfaceClass {
175     /*< private >*/
176     GstVaapiObjectClass parent_class;
177
178     gboolean  (*create)(GstVaapiSurface *surface);
179 };
180
181 GType
182 gst_vaapi_surface_get_type(void) G_GNUC_CONST;
183
184 GstVaapiSurface *
185 gst_vaapi_surface_new(
186     GstVaapiDisplay    *display,
187     GstVaapiChromaType  chroma_type,
188     guint               width,
189     guint               height
190 );
191
192 GstVaapiID
193 gst_vaapi_surface_get_id(GstVaapiSurface *surface);
194
195 GstVaapiChromaType
196 gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface);
197
198 guint
199 gst_vaapi_surface_get_width(GstVaapiSurface *surface);
200
201 guint
202 gst_vaapi_surface_get_height(GstVaapiSurface *surface);
203
204 void
205 gst_vaapi_surface_get_size(
206     GstVaapiSurface *surface,
207     guint           *pwidth,
208     guint           *pheight
209 );
210
211 GstVaapiImage *
212 gst_vaapi_surface_derive_image(GstVaapiSurface *surface);
213
214 gboolean
215 gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image);
216
217 gboolean
218 gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image);
219
220 gboolean
221 gst_vaapi_surface_associate_subpicture(
222     GstVaapiSurface         *surface,
223     GstVaapiSubpicture      *subpicture,
224     const GstVaapiRectangle *src_rect,
225     const GstVaapiRectangle *dst_rect
226 );
227
228 gboolean
229 gst_vaapi_surface_deassociate_subpicture(
230     GstVaapiSurface         *surface,
231     GstVaapiSubpicture      *subpicture
232 );
233
234 gboolean
235 gst_vaapi_surface_sync(GstVaapiSurface *surface);
236
237 gboolean
238 gst_vaapi_surface_query_status(
239     GstVaapiSurface       *surface,
240     GstVaapiSurfaceStatus *pstatus
241 );
242
243 gboolean
244 gst_vaapi_surface_set_subpictures_from_composition(
245     GstVaapiSurface            *surface,
246     GstVideoOverlayComposition *composition,
247     gboolean                    propagate_context
248 );
249
250 G_END_DECLS
251
252 #endif /* GST_VAAPI_SURFACE_H */