1 | /* GStreamer |
2 | * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public |
15 | * License along with this library; if not, write to the |
16 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef __GST_VIDEO_META_H__ |
21 | #define __GST_VIDEO_META_H__ |
22 | |
23 | #include <gst/gst.h> |
24 | |
25 | #include <gst/video/video.h> |
26 | #include <gst/video/gstvideotimecode.h> |
27 | |
28 | G_BEGIN_DECLS |
29 | |
30 | #define GST_VIDEO_META_API_TYPE (gst_video_meta_api_get_type()) |
31 | #define GST_VIDEO_META_INFO (gst_video_meta_get_info()) |
32 | typedef struct _GstVideoMeta GstVideoMeta; |
33 | |
34 | #define GST_CAPS_FEATURE_META_GST_VIDEO_META "meta:GstVideoMeta" |
35 | |
36 | #define GST_VIDEO_CROP_META_API_TYPE (gst_video_crop_meta_api_get_type()) |
37 | #define GST_VIDEO_CROP_META_INFO (gst_video_crop_meta_get_info()) |
38 | typedef struct _GstVideoCropMeta GstVideoCropMeta; |
39 | |
40 | /** |
41 | * GstVideoMeta: |
42 | * @meta: parent #GstMeta |
43 | * @buffer: the buffer this metadata belongs to |
44 | * @flags: additional video flags |
45 | * @format: the video format |
46 | * @id: identifier of the frame |
47 | * @width: the video width |
48 | * @height: the video height |
49 | * @n_planes: the number of planes in the image |
50 | * @offset: array of offsets for the planes. This field might not always be |
51 | * valid, it is used by the default implementation of @map. |
52 | * @stride: array of strides for the planes. This field might not always be |
53 | * valid, it is used by the default implementation of @map. |
54 | * @map: map the memory of a plane |
55 | * @unmap: unmap the memory of a plane |
56 | * |
57 | * Extra buffer metadata describing image properties |
58 | */ |
59 | struct _GstVideoMeta { |
60 | GstMeta meta; |
61 | |
62 | GstBuffer *buffer; |
63 | |
64 | GstVideoFrameFlags flags; |
65 | GstVideoFormat format; |
66 | gint id; |
67 | guint width; |
68 | guint height; |
69 | |
70 | guint n_planes; |
71 | gsize offset[GST_VIDEO_MAX_PLANES]; |
72 | gint stride[GST_VIDEO_MAX_PLANES]; |
73 | |
74 | gboolean (*map) (GstVideoMeta *meta, guint plane, GstMapInfo *info, |
75 | gpointer *data, gint * stride, GstMapFlags flags); |
76 | gboolean (*unmap) (GstVideoMeta *meta, guint plane, GstMapInfo *info); |
77 | }; |
78 | |
79 | GST_VIDEO_API |
80 | GType gst_video_meta_api_get_type (void); |
81 | |
82 | GST_VIDEO_API |
83 | const GstMetaInfo * gst_video_meta_get_info (void); |
84 | |
85 | GST_VIDEO_API |
86 | GstVideoMeta * gst_buffer_get_video_meta (GstBuffer *buffer); |
87 | |
88 | GST_VIDEO_API |
89 | GstVideoMeta * gst_buffer_get_video_meta_id (GstBuffer *buffer, gint id); |
90 | |
91 | GST_VIDEO_API |
92 | GstVideoMeta * gst_buffer_add_video_meta (GstBuffer *buffer, GstVideoFrameFlags flags, |
93 | GstVideoFormat format, guint width, guint height); |
94 | |
95 | GST_VIDEO_API |
96 | GstVideoMeta * gst_buffer_add_video_meta_full (GstBuffer *buffer, GstVideoFrameFlags flags, |
97 | GstVideoFormat format, guint width, guint height, |
98 | guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES], |
99 | gint stride[GST_VIDEO_MAX_PLANES]); |
100 | |
101 | GST_VIDEO_API |
102 | gboolean gst_video_meta_map (GstVideoMeta *meta, guint plane, GstMapInfo *info, |
103 | gpointer *data, gint *stride, GstMapFlags flags); |
104 | |
105 | GST_VIDEO_API |
106 | gboolean gst_video_meta_unmap (GstVideoMeta *meta, guint plane, GstMapInfo *info); |
107 | |
108 | /** |
109 | * GstVideoCropMeta: |
110 | * @meta: parent #GstMeta |
111 | * @x: the horizontal offset |
112 | * @y: the vertical offset |
113 | * @width: the cropped width |
114 | * @height: the cropped height |
115 | * |
116 | * Extra buffer metadata describing image cropping. |
117 | */ |
118 | struct _GstVideoCropMeta { |
119 | GstMeta meta; |
120 | |
121 | guint x; |
122 | guint y; |
123 | guint width; |
124 | guint height; |
125 | }; |
126 | |
127 | GST_VIDEO_API |
128 | GType gst_video_crop_meta_api_get_type (void); |
129 | |
130 | GST_VIDEO_API |
131 | const GstMetaInfo * gst_video_crop_meta_get_info (void); |
132 | |
133 | #define gst_buffer_get_video_crop_meta(b) ((GstVideoCropMeta*)gst_buffer_get_meta((b),GST_VIDEO_CROP_META_API_TYPE)) |
134 | #define gst_buffer_add_video_crop_meta(b) ((GstVideoCropMeta*)gst_buffer_add_meta((b),GST_VIDEO_CROP_META_INFO, NULL)) |
135 | |
136 | /* video metadata transforms */ |
137 | |
138 | GST_VIDEO_API |
139 | GQuark gst_video_meta_transform_scale_get_quark (void); |
140 | /** |
141 | * gst_video_meta_transform_scale: |
142 | * |
143 | * GQuark for the video "gst-video-scale" transform. |
144 | */ |
145 | #define GST_VIDEO_META_TRANSFORM_IS_SCALE(type) ((type) == gst_video_meta_transform_scale_get_quark()) |
146 | |
147 | /** |
148 | * GstVideoMetaTransform: |
149 | * @in_info: the input #GstVideoInfo |
150 | * @out_info: the output #GstVideoInfo |
151 | * |
152 | * Extra data passed to a video transform #GstMetaTransformFunction such as: |
153 | * "gst-video-scale". |
154 | */ |
155 | typedef struct { |
156 | GstVideoInfo *in_info; |
157 | GstVideoInfo *out_info; |
158 | } GstVideoMetaTransform; |
159 | |
160 | /** |
161 | * GstVideoGLTextureType: |
162 | * @GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE: Luminance texture, GL_LUMINANCE |
163 | * @GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA: Luminance-alpha texture, GL_LUMINANCE_ALPHA |
164 | * @GST_VIDEO_GL_TEXTURE_TYPE_RGB16: RGB 565 texture, GL_RGB |
165 | * @GST_VIDEO_GL_TEXTURE_TYPE_RGB: RGB texture, GL_RGB |
166 | * @GST_VIDEO_GL_TEXTURE_TYPE_RGBA: RGBA texture, GL_RGBA |
167 | * @GST_VIDEO_GL_TEXTURE_TYPE_R: R texture, GL_RED_EXT |
168 | * @GST_VIDEO_GL_TEXTURE_TYPE_RG: RG texture, GL_RG_EXT |
169 | * |
170 | * The GL texture type. |
171 | */ |
172 | typedef enum |
173 | { |
174 | GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE, |
175 | GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA, |
176 | GST_VIDEO_GL_TEXTURE_TYPE_RGB16, |
177 | GST_VIDEO_GL_TEXTURE_TYPE_RGB, |
178 | GST_VIDEO_GL_TEXTURE_TYPE_RGBA, |
179 | GST_VIDEO_GL_TEXTURE_TYPE_R, |
180 | GST_VIDEO_GL_TEXTURE_TYPE_RG |
181 | } GstVideoGLTextureType; |
182 | |
183 | /** |
184 | * GstVideoGLTextureOrientation: |
185 | * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL: Top line first in memory, left row first |
186 | * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP: Bottom line first in memory, left row first |
187 | * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL: Top line first in memory, right row first |
188 | * @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP: Bottom line first in memory, right row first |
189 | * |
190 | * The orientation of the GL texture. |
191 | */ |
192 | typedef enum |
193 | { |
194 | GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL, |
195 | GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP, |
196 | GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL, |
197 | GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP |
198 | } GstVideoGLTextureOrientation; |
199 | |
200 | #define GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE (gst_video_gl_texture_upload_meta_api_get_type()) |
201 | #define GST_VIDEO_GL_TEXTURE_UPLOAD_META_INFO (gst_video_gl_texture_upload_meta_get_info()) |
202 | |
203 | typedef struct _GstVideoGLTextureUploadMeta GstVideoGLTextureUploadMeta; |
204 | typedef gboolean (*GstVideoGLTextureUpload) (GstVideoGLTextureUploadMeta *meta, guint texture_id[4]); |
205 | |
206 | #define GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META "meta:GstVideoGLTextureUploadMeta" |
207 | |
208 | /** |
209 | * GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META: |
210 | * |
211 | * An option that can be activated on a bufferpool to request gl texture upload |
212 | * meta on buffers from the pool. |
213 | * |
214 | * When this option is enabled on the bufferpool, |
215 | * @GST_BUFFER_POOL_OPTION_VIDEO_META should also be enabled. |
216 | * |
217 | * Since: 1.2.2 |
218 | */ |
219 | #define GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META "GstBufferPoolOptionVideoGLTextureUploadMeta" |
220 | |
221 | /** |
222 | * GstVideoGLTextureUploadMeta: |
223 | * @meta: parent #GstMeta |
224 | * @texture_orientation: Orientation of the textures |
225 | * @n_textures: Number of textures that are generated |
226 | * @texture_type: Type of each texture |
227 | * |
228 | * Extra buffer metadata for uploading a buffer to an OpenGL texture |
229 | * ID. The caller of gst_video_gl_texture_upload_meta_upload() must |
230 | * have OpenGL set up and call this from a thread where it is valid |
231 | * to upload something to an OpenGL texture. |
232 | */ |
233 | |
234 | struct _GstVideoGLTextureUploadMeta { |
235 | GstMeta meta; |
236 | |
237 | GstVideoGLTextureOrientation texture_orientation; |
238 | guint n_textures; |
239 | GstVideoGLTextureType texture_type[4]; |
240 | |
241 | /* <private> */ |
242 | GstBuffer *buffer; |
243 | GstVideoGLTextureUpload upload; |
244 | |
245 | gpointer user_data; |
246 | GBoxedCopyFunc user_data_copy; |
247 | GBoxedFreeFunc user_data_free; |
248 | }; |
249 | |
250 | GST_VIDEO_API |
251 | GType gst_video_gl_texture_upload_meta_api_get_type (void); |
252 | |
253 | GST_VIDEO_API |
254 | const GstMetaInfo * gst_video_gl_texture_upload_meta_get_info (void); |
255 | |
256 | #define gst_buffer_get_video_gl_texture_upload_meta(b) ((GstVideoGLTextureUploadMeta*)gst_buffer_get_meta((b),GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE)) |
257 | |
258 | GST_VIDEO_API |
259 | GstVideoGLTextureUploadMeta * |
260 | gst_buffer_add_video_gl_texture_upload_meta (GstBuffer *buffer, |
261 | GstVideoGLTextureOrientation texture_orientation, |
262 | guint n_textures, |
263 | GstVideoGLTextureType texture_type[4], |
264 | GstVideoGLTextureUpload upload, |
265 | gpointer user_data, |
266 | GBoxedCopyFunc user_data_copy, |
267 | GBoxedFreeFunc user_data_free); |
268 | |
269 | GST_VIDEO_API |
270 | gboolean gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta *meta, |
271 | guint texture_id[4]); |
272 | |
273 | |
274 | /** |
275 | * GstVideoRegionOfInterestMeta: |
276 | * @meta: parent #GstMeta |
277 | * @roi_type: GQuark describing the semantic of the Roi (f.i. a face, a pedestrian) |
278 | * @id: identifier of this particular ROI |
279 | * @parent_id: identifier of its parent ROI, used f.i. for ROI hierarchisation. |
280 | * @x: x component of upper-left corner |
281 | * @y: y component of upper-left corner |
282 | * @w: bounding box width |
283 | * @h: bounding box height |
284 | * @params: list of #GstStructure containing element-specific params for downstream, see gst_video_region_of_interest_meta_add_params(). (Since: 1.14) |
285 | * |
286 | * Extra buffer metadata describing an image region of interest |
287 | */ |
288 | typedef struct { |
289 | GstMeta meta; |
290 | |
291 | GQuark roi_type; |
292 | gint id; |
293 | gint parent_id; |
294 | |
295 | guint x; |
296 | guint y; |
297 | guint w; |
298 | guint h; |
299 | |
300 | GList *params; |
301 | } GstVideoRegionOfInterestMeta; |
302 | |
303 | GST_VIDEO_API |
304 | GType gst_video_region_of_interest_meta_api_get_type (void); |
305 | #define GST_VIDEO_REGION_OF_INTEREST_META_API_TYPE (gst_video_region_of_interest_meta_api_get_type()) |
306 | GST_VIDEO_API |
307 | const GstMetaInfo *gst_video_region_of_interest_meta_get_info (void); |
308 | #define GST_VIDEO_REGION_OF_INTEREST_META_INFO (gst_video_region_of_interest_meta_get_info()) |
309 | |
310 | #define gst_buffer_get_video_region_of_interest_meta(b) \ |
311 | ((GstVideoRegionOfInterestMeta*)gst_buffer_get_meta((b),GST_VIDEO_REGION_OF_INTEREST_META_API_TYPE)) |
312 | GST_VIDEO_API |
313 | GstVideoRegionOfInterestMeta *gst_buffer_get_video_region_of_interest_meta_id (GstBuffer * buffer, |
314 | gint id); |
315 | |
316 | GST_VIDEO_API |
317 | GstVideoRegionOfInterestMeta *gst_buffer_add_video_region_of_interest_meta (GstBuffer * buffer, |
318 | const gchar * roi_type, |
319 | guint x, |
320 | guint y, |
321 | guint w, |
322 | guint h); |
323 | |
324 | GST_VIDEO_API |
325 | GstVideoRegionOfInterestMeta *gst_buffer_add_video_region_of_interest_meta_id (GstBuffer * buffer, |
326 | GQuark roi_type, |
327 | guint x, |
328 | guint y, |
329 | guint w, |
330 | guint h); |
331 | GST_VIDEO_API |
332 | void gst_video_region_of_interest_meta_add_param (GstVideoRegionOfInterestMeta * meta, |
333 | GstStructure * s); |
334 | |
335 | GST_VIDEO_API |
336 | GstStructure *gst_video_region_of_interest_meta_get_param (GstVideoRegionOfInterestMeta * meta, |
337 | const gchar * name); |
338 | |
339 | /** |
340 | * GstVideoTimeCodeMeta: |
341 | * @meta: parent #GstMeta |
342 | * @tc: the GstVideoTimeCode to attach |
343 | * |
344 | * Extra buffer metadata describing the GstVideoTimeCode of the frame. |
345 | * |
346 | * Each frame is assumed to have its own timecode, i.e. they are not |
347 | * automatically incremented/interpolated. |
348 | * |
349 | * Since: 1.10 |
350 | */ |
351 | typedef struct { |
352 | GstMeta meta; |
353 | |
354 | GstVideoTimeCode tc; |
355 | } GstVideoTimeCodeMeta; |
356 | |
357 | GST_VIDEO_API |
358 | GType gst_video_time_code_meta_api_get_type (void); |
359 | #define GST_VIDEO_TIME_CODE_META_API_TYPE (gst_video_time_code_meta_api_get_type()) |
360 | |
361 | GST_VIDEO_API |
362 | const GstMetaInfo *gst_video_time_code_meta_get_info (void); |
363 | #define GST_VIDEO_TIME_CODE_META_INFO (gst_video_time_code_meta_get_info()) |
364 | |
365 | #define gst_buffer_get_video_time_code_meta(b) \ |
366 | ((GstVideoTimeCodeMeta*)gst_buffer_get_meta((b),GST_VIDEO_TIME_CODE_META_API_TYPE)) |
367 | |
368 | GST_VIDEO_API |
369 | GstVideoTimeCodeMeta *gst_buffer_add_video_time_code_meta (GstBuffer * buffer, |
370 | GstVideoTimeCode * tc); |
371 | |
372 | GST_VIDEO_API |
373 | GstVideoTimeCodeMeta * |
374 | gst_buffer_add_video_time_code_meta_full (GstBuffer * buffer, |
375 | guint fps_n, |
376 | guint fps_d, |
377 | GDateTime * latest_daily_jam, |
378 | GstVideoTimeCodeFlags flags, |
379 | guint hours, |
380 | guint minutes, |
381 | guint seconds, |
382 | guint frames, |
383 | guint field_count); |
384 | |
385 | G_END_DECLS |
386 | |
387 | #endif /* __GST_VIDEO_META_H__ */ |
388 | |