1 /* GStreamer Video Overlay Composition
2 * Copyright (C) 2011 Intel Corporation
3 * Copyright (C) 2011 Collabora Ltd.
4 * Copyright (C) 2011 Tim-Philipp Müller <tim centricular net>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 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 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #ifndef __GST_VIDEO_OVERLAY_COMPOSITION_H__
23 #define __GST_VIDEO_OVERLAY_COMPOSITION_H__
26 #include <gst/video/video.h>
31 * GstVideoOverlayRectangle:
33 * An opaque video overlay rectangle object. A rectangle contains a single
34 * overlay rectangle which can be added to a composition.
36 #define GST_TYPE_VIDEO_OVERLAY_RECTANGLE \
37 (gst_video_overlay_rectangle_get_type ())
38 #define GST_VIDEO_OVERLAY_RECTANGLE_CAST(obj) \
39 ((GstVideoOverlayRectangle *)(obj)
40 #define GST_VIDEO_OVERLAY_RECTANGLE(obj) \
41 (GST_VIDEO_OVERLAY_RECTANGLE_CAST(obj))
42 #define GST_IS_VIDEO_OVERLAY_RECTANGLE(obj) \
43 (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_VIDEO_OVERLAY_RECTANGLE))
45 typedef struct _GstVideoOverlayRectangle GstVideoOverlayRectangle;
48 * gst_video_overlay_rectangle_ref:
49 * @comp: a a #GstVideoOverlayRectangle.
51 * Increases the refcount of the given rectangle by one.
53 * Note that the refcount affects the writeability
54 * of @comp, use gst_video_overlay_rectangle_copy() to ensure a rectangle can
55 * be modified (there is no gst_video_overlay_rectangle_make_writable() because
56 * it is unlikely that someone will hold the single reference to the rectangle
57 * and not know that that's the case).
59 * Returns: (transfer full): @comp
62 G_INLINE_FUNC GstVideoOverlayRectangle *
63 gst_video_overlay_rectangle_ref (GstVideoOverlayRectangle * comp);
66 static inline GstVideoOverlayRectangle *
67 gst_video_overlay_rectangle_ref (GstVideoOverlayRectangle * comp)
69 return (GstVideoOverlayRectangle *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (comp));
73 * gst_video_overlay_rectangle_unref:
74 * @comp: (transfer full): a #GstVideoOverlayRectangle.
76 * Decreases the refcount of the rectangle. If the refcount reaches 0, the
77 * rectangle will be freed.
81 gst_video_overlay_rectangle_unref (GstVideoOverlayRectangle * comp);
85 gst_video_overlay_rectangle_unref (GstVideoOverlayRectangle * comp)
87 gst_mini_object_unref (GST_MINI_OBJECT_CAST (comp));
91 * GstVideoOverlayFormatFlags:
92 * @GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE: no flags
93 * @GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA: RGB are premultiplied by A/255.
94 * @GST_VIDEO_OVERLAY_FORMAT_FLAG_GLOBAL_ALPHA: a global-alpha value != 1 is set.
96 * Overlay format flags.
99 GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE = 0,
100 GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA = 1,
101 GST_VIDEO_OVERLAY_FORMAT_FLAG_GLOBAL_ALPHA = 2
102 } GstVideoOverlayFormatFlags;
105 * GST_VIDEO_OVERLAY_COMPOSITION_FORMAT_RGB:
107 * Supported RGB overlay video format.
109 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
110 #define GST_VIDEO_OVERLAY_COMPOSITION_FORMAT_RGB GST_VIDEO_FORMAT_BGRA
112 #define GST_VIDEO_OVERLAY_COMPOSITION_FORMAT_RGB GST_VIDEO_FORMAT_ARGB
116 * GST_VIDEO_OVERLAY_COMPOSITION_FORMAT_YUV:
118 * Supported YUV overlay video format.
120 #define GST_VIDEO_OVERLAY_COMPOSITION_FORMAT_YUV GST_VIDEO_FORMAT_AYUV
122 GType gst_video_overlay_rectangle_get_type (void);
124 GstVideoOverlayRectangle * gst_video_overlay_rectangle_new_raw (GstBuffer * pixels,
125 gint render_x, gint render_y,
126 guint render_width, guint render_height,
127 GstVideoOverlayFormatFlags flags);
129 GstVideoOverlayRectangle * gst_video_overlay_rectangle_copy (GstVideoOverlayRectangle * rectangle);
131 guint gst_video_overlay_rectangle_get_seqnum (GstVideoOverlayRectangle * rectangle);
133 void gst_video_overlay_rectangle_set_render_rectangle (GstVideoOverlayRectangle * rectangle,
137 guint render_height);
139 gboolean gst_video_overlay_rectangle_get_render_rectangle (GstVideoOverlayRectangle * rectangle,
142 guint * render_width,
143 guint * render_height);
145 GstBuffer * gst_video_overlay_rectangle_get_pixels_raw (GstVideoOverlayRectangle * rectangle,
146 GstVideoOverlayFormatFlags flags);
148 GstBuffer * gst_video_overlay_rectangle_get_pixels_argb (GstVideoOverlayRectangle * rectangle,
149 GstVideoOverlayFormatFlags flags);
151 GstBuffer * gst_video_overlay_rectangle_get_pixels_ayuv (GstVideoOverlayRectangle * rectangle,
152 GstVideoOverlayFormatFlags flags);
154 GstBuffer * gst_video_overlay_rectangle_get_pixels_unscaled_raw (GstVideoOverlayRectangle * rectangle,
155 GstVideoOverlayFormatFlags flags);
157 GstBuffer * gst_video_overlay_rectangle_get_pixels_unscaled_argb (GstVideoOverlayRectangle * rectangle,
158 GstVideoOverlayFormatFlags flags);
160 GstBuffer * gst_video_overlay_rectangle_get_pixels_unscaled_ayuv (GstVideoOverlayRectangle * rectangle,
161 GstVideoOverlayFormatFlags flags);
163 GstVideoOverlayFormatFlags gst_video_overlay_rectangle_get_flags (GstVideoOverlayRectangle * rectangle);
165 gfloat gst_video_overlay_rectangle_get_global_alpha (GstVideoOverlayRectangle * rectangle);
166 void gst_video_overlay_rectangle_set_global_alpha (GstVideoOverlayRectangle * rectangle,
167 gfloat global_alpha);
170 * GstVideoOverlayComposition:
172 * An opaque video overlay composition object. A composition contains
173 * multiple overlay rectangles.
175 #define GST_TYPE_VIDEO_OVERLAY_COMPOSITION \
176 (gst_video_overlay_composition_get_type ())
177 #define GST_VIDEO_OVERLAY_COMPOSITION_CAST(obj) \
178 ((GstVideoOverlayComposition *)(obj)
179 #define GST_VIDEO_OVERLAY_COMPOSITION(obj) \
180 (GST_VIDEO_OVERLAY_COMPOSITION_CAST(obj))
181 #define GST_IS_VIDEO_OVERLAY_COMPOSITION(obj) \
182 (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_VIDEO_OVERLAY_COMPOSITION))
184 typedef struct _GstVideoOverlayComposition GstVideoOverlayComposition;
187 * gst_video_overlay_composition_ref:
188 * @comp: a a #GstVideoOverlayComposition.
190 * Increases the refcount of the given composition by one.
192 * Note that the refcount affects the writeability
193 * of @comp, use gst_video_overlay_composition_make_writable() to ensure
194 * a composition and its rectangles can be modified.
196 * Returns: (transfer full): @comp
198 #ifdef _FOOL_GTK_DOC_
199 G_INLINE_FUNC GstVideoOverlayComposition *
200 gst_video_overlay_composition_ref (GstVideoOverlayComposition * comp);
203 static inline GstVideoOverlayComposition *
204 gst_video_overlay_composition_ref (GstVideoOverlayComposition * comp)
206 return (GstVideoOverlayComposition *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (comp));
210 * gst_video_overlay_composition_unref:
211 * @comp: (transfer full): a #GstVideoOverlayComposition.
213 * Decreases the refcount of the composition. If the refcount reaches 0, the
214 * composition will be freed.
216 #ifdef _FOOL_GTK_DOC_
218 gst_video_overlay_composition_unref (GstVideoOverlayComposition * comp);
222 gst_video_overlay_composition_unref (GstVideoOverlayComposition * comp)
224 gst_mini_object_unref (GST_MINI_OBJECT_CAST (comp));
227 GType gst_video_overlay_composition_get_type (void);
229 GstVideoOverlayComposition * gst_video_overlay_composition_copy (GstVideoOverlayComposition * comp);
231 GstVideoOverlayComposition * gst_video_overlay_composition_make_writable (GstVideoOverlayComposition * comp);
233 GstVideoOverlayComposition * gst_video_overlay_composition_new (GstVideoOverlayRectangle * rectangle);
235 void gst_video_overlay_composition_add_rectangle (GstVideoOverlayComposition * comp,
236 GstVideoOverlayRectangle * rectangle);
238 guint gst_video_overlay_composition_n_rectangles (GstVideoOverlayComposition * comp);
240 GstVideoOverlayRectangle * gst_video_overlay_composition_get_rectangle (GstVideoOverlayComposition * comp, guint n);
242 guint gst_video_overlay_composition_get_seqnum (GstVideoOverlayComposition * comp);
244 /* blend composition onto raw video buffer */
246 gboolean gst_video_overlay_composition_blend (GstVideoOverlayComposition * comp,
247 GstVideoFrame * video_buf);
249 /* attach/retrieve composition from buffers */
251 #define GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE \
252 (gst_video_overlay_composition_meta_api_get_type())
253 #define GST_VIDEO_OVERLAY_COMPOSITION_META_INFO \
254 (gst_video_overlay_composition_meta_get_info())
256 typedef struct _GstVideoOverlayCompositionMeta GstVideoOverlayCompositionMeta;
259 * GstVideoOverlayCompositionMeta:
260 * @meta: parent #GstMeta
261 * @overlay: the attached #GstVideoOverlayComposition
263 * Extra buffer metadata describing image overlay data.
265 struct _GstVideoOverlayCompositionMeta
269 GstVideoOverlayComposition *overlay;
272 GType gst_video_overlay_composition_meta_api_get_type (void);
273 const GstMetaInfo *gst_video_overlay_composition_meta_get_info (void);
275 GstVideoOverlayCompositionMeta * gst_buffer_add_video_overlay_composition_meta (GstBuffer * buf,
276 GstVideoOverlayComposition * comp);
278 #define gst_buffer_get_video_overlay_composition_meta(b) \
279 ((GstVideoOverlayCompositionMeta*)gst_buffer_get_meta((b),GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE))
280 #define gst_buffer_remove_video_overlay_composition_meta(b,m) \
281 gst_buffer_remove_meta((b),((GstMeta *) m))
285 #endif /* __GST_VIDEO_OVERLAY_COMPOSITION_H__ */