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.
38 #define GST_TYPE_VIDEO_OVERLAY_RECTANGLE \
39 (gst_video_overlay_rectangle_get_type ())
40 #define GST_VIDEO_OVERLAY_RECTANGLE(obj) \
41 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_OVERLAY_RECTANGLE, GstVideoOverlayRectangle))
42 #define GST_IS_VIDEO_OVERLAY_RECTANGLE(obj) \
43 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_OVERLAY_RECTANGLE))
45 typedef struct _GstVideoOverlayRectangle GstVideoOverlayRectangle;
46 typedef struct _GstVideoOverlayRectangleClass GstVideoOverlayRectangleClass;
49 * gst_video_overlay_rectangle_ref:
50 * @comp: a a #GstVideoOverlayRectangle.
52 * Increases the refcount of the given rectangle by one.
54 * Note that the refcount affects the writeability
55 * of @comp, use gst_video_overlay_rectangle_copy() to ensure a rectangle can
56 * be modified (there is no gst_video_overlay_rectangle_make_writable() because
57 * it is unlikely that someone will hold the single reference to the rectangle
58 * and not know that that's the case).
60 * Returns: (transfer full): @comp
65 G_INLINE_FUNC GstVideoOverlayRectangle *
66 gst_video_overlay_rectangle_ref (GstVideoOverlayRectangle * comp);
69 static inline GstVideoOverlayRectangle *
70 gst_video_overlay_rectangle_ref (GstVideoOverlayRectangle * comp)
72 return (GstVideoOverlayRectangle *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (comp));
76 * gst_video_overlay_rectangle_unref:
77 * @comp: (transfer full): a #GstVideoOverlayRectangle.
79 * Decreases the refcount of the rectangle. If the refcount reaches 0, the
80 * rectangle will be freed.
86 gst_video_overlay_rectangle_unref (GstVideoOverlayRectangle * comp);
90 gst_video_overlay_rectangle_unref (GstVideoOverlayRectangle * comp)
92 gst_mini_object_unref (GST_MINI_OBJECT_CAST (comp));
96 * GstVideoOverlayFormatFlags:
97 * @GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE: no flags
99 * Overlay format flags.
104 GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE = 0
105 } GstVideoOverlayFormatFlags;
107 GType gst_video_overlay_rectangle_get_type (void);
109 GstVideoOverlayRectangle * gst_video_overlay_rectangle_new_argb (GstBuffer * pixels,
110 guint width, guint height, guint stride,
111 gint render_x, gint render_y,
112 guint render_width, guint render_height,
113 GstVideoOverlayFormatFlags flags);
115 GstVideoOverlayRectangle * gst_video_overlay_rectangle_copy (GstVideoOverlayRectangle * rectangle);
117 guint gst_video_overlay_rectangle_get_seqnum (GstVideoOverlayRectangle * rectangle);
119 void gst_video_overlay_rectangle_set_render_rectangle (GstVideoOverlayRectangle * rectangle,
123 guint render_height);
125 gboolean gst_video_overlay_rectangle_get_render_rectangle (GstVideoOverlayRectangle * rectangle,
128 guint * render_width,
129 guint * render_height);
131 GstBuffer * gst_video_overlay_rectangle_get_pixels_argb (GstVideoOverlayRectangle * rectangle,
133 GstVideoOverlayFormatFlags flags);
135 GstBuffer * gst_video_overlay_rectangle_get_pixels_unscaled_argb (GstVideoOverlayRectangle * rectangle,
139 GstVideoOverlayFormatFlags flags);
142 * GstVideoOverlayComposition:
144 * An opaque video overlay composition object. A composition contains
145 * multiple overlay rectangles.
149 #define GST_TYPE_VIDEO_OVERLAY_COMPOSITION \
150 (gst_video_overlay_composition_get_type ())
151 #define GST_VIDEO_OVERLAY_COMPOSITION(obj) \
152 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_OVERLAY_COMPOSITION, GstVideoOverlayComposition))
153 #define GST_IS_VIDEO_OVERLAY_COMPOSITION(obj) \
154 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_OVERLAY_COMPOSITION))
156 typedef struct _GstVideoOverlayComposition GstVideoOverlayComposition;
157 typedef struct _GstVideoOverlayCompositionClass GstVideoOverlayCompositionClass;
160 * gst_video_overlay_composition_ref:
161 * @comp: a a #GstVideoOverlayComposition.
163 * Increases the refcount of the given composition by one.
165 * Note that the refcount affects the writeability
166 * of @comp, use gst_video_overlay_composition_make_writable() to ensure
167 * a composition and its rectangles can be modified.
169 * Returns: (transfer full): @comp
173 #ifdef _FOOL_GTK_DOC_
174 G_INLINE_FUNC GstVideoOverlayComposition *
175 gst_video_overlay_composition_ref (GstVideoOverlayComposition * comp);
178 static inline GstVideoOverlayComposition *
179 gst_video_overlay_composition_ref (GstVideoOverlayComposition * comp)
181 return (GstVideoOverlayComposition *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (comp));
185 * gst_video_overlay_composition_unref:
186 * @comp: (transfer full): a #GstVideoOverlayComposition.
188 * Decreases the refcount of the composition. If the refcount reaches 0, the
189 * composition will be freed.
193 #ifdef _FOOL_GTK_DOC_
195 gst_video_overlay_composition_unref (GstVideoOverlayComposition * comp);
199 gst_video_overlay_composition_unref (GstVideoOverlayComposition * comp)
201 gst_mini_object_unref (GST_MINI_OBJECT_CAST (comp));
204 GType gst_video_overlay_composition_get_type (void);
206 GstVideoOverlayComposition * gst_video_overlay_composition_copy (GstVideoOverlayComposition * comp);
208 GstVideoOverlayComposition * gst_video_overlay_composition_make_writable (GstVideoOverlayComposition * comp);
210 GstVideoOverlayComposition * gst_video_overlay_composition_new (GstVideoOverlayRectangle * rectangle);
212 void gst_video_overlay_composition_add_rectangle (GstVideoOverlayComposition * comp,
213 GstVideoOverlayRectangle * rectangle);
215 guint gst_video_overlay_composition_n_rectangles (GstVideoOverlayComposition * comp);
217 GstVideoOverlayRectangle * gst_video_overlay_composition_get_rectangle (GstVideoOverlayComposition * comp, guint n);
219 guint gst_video_overlay_composition_get_seqnum (GstVideoOverlayComposition * comp);
221 /* blend composition onto raw video buffer */
223 gboolean gst_video_overlay_composition_blend (GstVideoOverlayComposition * comp,
224 GstBuffer * video_buf);
226 /* attach/retrieve composition from buffers */
228 void gst_video_buffer_set_overlay_composition (GstBuffer * buf,
229 GstVideoOverlayComposition * comp);
231 GstVideoOverlayComposition * gst_video_buffer_get_overlay_composition (GstBuffer * buf);
235 #endif /* __GST_VIDEO_OVERLAY_COMPOSITION_H__ */