tizen 2.3 release
[framework/multimedia/gst-plugins-base0.10.git] / gst-libs / gst / video / video-overlay-composition.h
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>
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 #ifndef __GST_VIDEO_OVERLAY_COMPOSITION_H__
23 #define __GST_VIDEO_OVERLAY_COMPOSITION_H__
24
25 #include <gst/gst.h>
26 #include <gst/video/video.h>
27
28 G_BEGIN_DECLS
29
30 /**
31  * GstVideoOverlayRectangle:
32  *
33  * An opaque video overlay rectangle object. A rectangle contains a single
34  * overlay rectangle which can be added to a composition.
35  *
36  * Since: 0.10.36
37  */
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))
44
45 typedef struct _GstVideoOverlayRectangle      GstVideoOverlayRectangle;
46 typedef struct _GstVideoOverlayRectangleClass GstVideoOverlayRectangleClass;
47
48 /**
49  * gst_video_overlay_rectangle_ref:
50  * @comp: a a #GstVideoOverlayRectangle.
51  *
52  * Increases the refcount of the given rectangle by one.
53  *
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).
59  *
60  * Returns: (transfer full): @comp
61  *
62  * Since: 0.10.36
63  */
64 #ifdef _FOOL_GTK_DOC_
65 G_INLINE_FUNC GstVideoOverlayRectangle *
66 gst_video_overlay_rectangle_ref (GstVideoOverlayRectangle * comp);
67 #endif
68
69 static inline GstVideoOverlayRectangle *
70 gst_video_overlay_rectangle_ref (GstVideoOverlayRectangle * comp)
71 {
72   return (GstVideoOverlayRectangle *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (comp));
73 }
74
75 /**
76  * gst_video_overlay_rectangle_unref:
77  * @comp: (transfer full): a #GstVideoOverlayRectangle.
78  *
79  * Decreases the refcount of the rectangle. If the refcount reaches 0, the
80  * rectangle will be freed.
81  *
82  * Since: 0.10.36
83  */
84 #ifdef _FOOL_GTK_DOC_
85 G_INLINE_FUNC void
86 gst_video_overlay_rectangle_unref (GstVideoOverlayRectangle * comp);
87 #endif
88
89 static inline void
90 gst_video_overlay_rectangle_unref (GstVideoOverlayRectangle * comp)
91 {
92   gst_mini_object_unref (GST_MINI_OBJECT_CAST (comp));
93 }
94
95 /**
96  * GstVideoOverlayFormatFlags:
97  * @GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE: no flags
98  *
99  * Overlay format flags.
100  *
101  * Since: 0.10.36
102  */
103 typedef enum {
104   GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE = 0
105 } GstVideoOverlayFormatFlags;
106
107 GType                        gst_video_overlay_rectangle_get_type (void);
108
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);
114
115 GstVideoOverlayRectangle *   gst_video_overlay_rectangle_copy     (GstVideoOverlayRectangle * rectangle);
116
117 guint                        gst_video_overlay_rectangle_get_seqnum (GstVideoOverlayRectangle  * rectangle);
118
119 void                         gst_video_overlay_rectangle_set_render_rectangle     (GstVideoOverlayRectangle  * rectangle,
120                                                                                    gint                        render_x,
121                                                                                    gint                        render_y,
122                                                                                    guint                       render_width,
123                                                                                    guint                       render_height);
124
125 gboolean                     gst_video_overlay_rectangle_get_render_rectangle     (GstVideoOverlayRectangle  * rectangle,
126                                                                                    gint                      * render_x,
127                                                                                    gint                      * render_y,
128                                                                                    guint                     * render_width,
129                                                                                    guint                     * render_height);
130
131 GstBuffer *                  gst_video_overlay_rectangle_get_pixels_argb          (GstVideoOverlayRectangle  * rectangle,
132                                                                                    guint                     * stride,
133                                                                                    GstVideoOverlayFormatFlags  flags);
134
135 GstBuffer *                  gst_video_overlay_rectangle_get_pixels_unscaled_argb (GstVideoOverlayRectangle  * rectangle,
136                                                                                    guint                     * width,
137                                                                                    guint                     * height,
138                                                                                    guint                     * stride,
139                                                                                    GstVideoOverlayFormatFlags  flags);
140
141 /**
142  * GstVideoOverlayComposition:
143  *
144  * An opaque video overlay composition object. A composition contains
145  * multiple overlay rectangles.
146  *
147  * Since: 0.10.36
148  */
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))
155
156 typedef struct _GstVideoOverlayComposition      GstVideoOverlayComposition;
157 typedef struct _GstVideoOverlayCompositionClass GstVideoOverlayCompositionClass;
158
159 /**
160  * gst_video_overlay_composition_ref:
161  * @comp: a a #GstVideoOverlayComposition.
162  *
163  * Increases the refcount of the given composition by one.
164  *
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.
168  *
169  * Returns: (transfer full): @comp
170  *
171  * Since: 0.10.36
172  */
173 #ifdef _FOOL_GTK_DOC_
174 G_INLINE_FUNC GstVideoOverlayComposition *
175 gst_video_overlay_composition_ref (GstVideoOverlayComposition * comp);
176 #endif
177
178 static inline GstVideoOverlayComposition *
179 gst_video_overlay_composition_ref (GstVideoOverlayComposition * comp)
180 {
181   return (GstVideoOverlayComposition *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (comp));
182 }
183
184 /**
185  * gst_video_overlay_composition_unref:
186  * @comp: (transfer full): a #GstVideoOverlayComposition.
187  *
188  * Decreases the refcount of the composition. If the refcount reaches 0, the
189  * composition will be freed.
190  *
191  * Since: 0.10.36
192  */
193 #ifdef _FOOL_GTK_DOC_
194 G_INLINE_FUNC void
195 gst_video_overlay_composition_unref (GstVideoOverlayComposition * comp);
196 #endif
197
198 static inline void
199 gst_video_overlay_composition_unref (GstVideoOverlayComposition * comp)
200 {
201   gst_mini_object_unref (GST_MINI_OBJECT_CAST (comp));
202 }
203
204 GType                        gst_video_overlay_composition_get_type (void);
205
206 GstVideoOverlayComposition * gst_video_overlay_composition_copy          (GstVideoOverlayComposition * comp);
207
208 GstVideoOverlayComposition * gst_video_overlay_composition_make_writable (GstVideoOverlayComposition * comp);
209
210 GstVideoOverlayComposition * gst_video_overlay_composition_new           (GstVideoOverlayRectangle * rectangle);
211
212 void                         gst_video_overlay_composition_add_rectangle (GstVideoOverlayComposition * comp,
213                                                                           GstVideoOverlayRectangle   * rectangle);
214
215 guint                        gst_video_overlay_composition_n_rectangles  (GstVideoOverlayComposition * comp);
216
217 GstVideoOverlayRectangle *   gst_video_overlay_composition_get_rectangle (GstVideoOverlayComposition * comp, guint n);
218
219 guint                        gst_video_overlay_composition_get_seqnum    (GstVideoOverlayComposition * comp);
220
221 /* blend composition onto raw video buffer */
222
223 gboolean                     gst_video_overlay_composition_blend         (GstVideoOverlayComposition * comp,
224                                                                           GstBuffer                  * video_buf);
225
226 /* attach/retrieve composition from buffers */
227
228 void                         gst_video_buffer_set_overlay_composition (GstBuffer                  * buf,
229                                                                        GstVideoOverlayComposition * comp);
230
231 GstVideoOverlayComposition * gst_video_buffer_get_overlay_composition (GstBuffer * buf);
232
233 G_END_DECLS
234
235 #endif /* __GST_VIDEO_OVERLAY_COMPOSITION_H__ */