1 /* Generic video aggregator plugin
2 * Copyright (C) 2008 Wim Taymans <wim@fluendo.com>
3 * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef __GST_VIDEO_AGGREGATOR_H__
22 #define __GST_VIDEO_AGGREGATOR_H__
24 #include <gst/video/video.h>
25 #include <gst/base/gstaggregator.h>
29 typedef struct _GstVideoAggregator GstVideoAggregator;
30 typedef struct _GstVideoAggregatorClass GstVideoAggregatorClass;
31 typedef struct _GstVideoAggregatorPrivate GstVideoAggregatorPrivate;
33 /*************************
34 * GstVideoAggregatorPad *
35 *************************/
37 #define GST_TYPE_VIDEO_AGGREGATOR_PAD (gst_video_aggregator_pad_get_type())
38 #define GST_VIDEO_AGGREGATOR_PAD(obj) \
39 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR_PAD, GstVideoAggregatorPad))
40 #define GST_VIDEO_AGGREGATOR_PAD_CAST(obj) ((GstVideoAggregatorPad *)(obj))
41 #define GST_VIDEO_AGGREGATOR_PAD_CLASS(klass) \
42 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_AGGREGATOR_PAD, GstVideoAggregatorPadClass))
43 #define GST_IS_VIDEO_AGGREGATOR_PAD(obj) \
44 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_AGGREGATOR_PAD))
45 #define GST_IS_VIDEO_AGGREGATOR_PAD_CLASS(klass) \
46 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_AGGREGATOR_PAD))
47 #define GST_VIDEO_AGGREGATOR_PAD_GET_CLASS(obj) \
48 (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VIDEO_AGGREGATOR_PAD,GstVideoAggregatorPadClass))
50 typedef struct _GstVideoAggregatorPad GstVideoAggregatorPad;
51 typedef struct _GstVideoAggregatorPadClass GstVideoAggregatorPadClass;
52 typedef struct _GstVideoAggregatorPadPrivate GstVideoAggregatorPadPrivate;
55 * GstVideoAggregatorPad:
56 * @info: The #GstVideoInfo currently set on the pad
60 struct _GstVideoAggregatorPad
62 GstAggregatorPad parent;
65 /* read-only, with OBJECT_LOCK */
69 GstVideoAggregatorPadPrivate *priv;
71 gpointer _gst_reserved[GST_PADDING];
75 * GstVideoAggregatorPadClass:
76 * @update_conversion_info: Called when either the input or output formats
78 * @prepare_frame: Prepare the frame from the pad buffer and sets it to prepared_frame.
79 * Implementations should always return TRUE. Returning FALSE will cease
80 * iteration over subsequent pads.
81 * @clean_frame: clean the frame previously prepared in prepare_frame
86 * GstVideoAggregatorPadClass::prepare_frame_start:
87 * @pad: the #GstVideoAggregatorPad
88 * @videoaggregator: the parent #GstVideoAggregator
89 * @buffer: the input #GstBuffer to prepare
90 * @prepared_frame: the #GstVideoFrame to prepare into
92 * Begin preparing the frame from the pad buffer and sets it to prepared_frame.
94 * If overriden, `prepare_frame_finish` must also be overriden.
99 * GstVideoAggregatorPadClass::prepare_frame_finish:
100 * @pad: the #GstVideoAggregatorPad
101 * @videoaggregator: the parent #GstVideoAggregator
102 * @prepared_frame: the #GstVideoFrame to prepare into
104 * Finish preparing @prepared_frame.
106 * If overriden, `prepare_frame_start` must also be overriden.
110 struct _GstVideoAggregatorPadClass
112 GstAggregatorPadClass parent_class;
113 void (*update_conversion_info) (GstVideoAggregatorPad * pad);
115 gboolean (*prepare_frame) (GstVideoAggregatorPad * pad,
116 GstVideoAggregator * videoaggregator,
118 GstVideoFrame * prepared_frame);
120 void (*clean_frame) (GstVideoAggregatorPad * pad,
121 GstVideoAggregator * videoaggregator,
122 GstVideoFrame * prepared_frame);
124 void (*prepare_frame_start) (GstVideoAggregatorPad * pad,
125 GstVideoAggregator * videoaggregator,
127 GstVideoFrame * prepared_frame);
129 void (*prepare_frame_finish) (GstVideoAggregatorPad * pad,
130 GstVideoAggregator * videoaggregator,
131 GstVideoFrame * prepared_frame);
133 gpointer _gst_reserved[GST_PADDING_LARGE-2];
137 GType gst_video_aggregator_pad_get_type (void);
140 gboolean gst_video_aggregator_pad_has_current_buffer (GstVideoAggregatorPad *pad);
143 GstBuffer * gst_video_aggregator_pad_get_current_buffer (GstVideoAggregatorPad *pad);
146 GstVideoFrame * gst_video_aggregator_pad_get_prepared_frame (GstVideoAggregatorPad *pad);
149 void gst_video_aggregator_pad_set_needs_alpha (GstVideoAggregatorPad *pad, gboolean needs_alpha);
151 /********************************
152 * GstVideoAggregatorConvertPad *
153 *******************************/
155 #define GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD (gst_video_aggregator_convert_pad_get_type())
156 #define GST_VIDEO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD, GstVideoAggregatorConvertPad))
157 #define GST_VIDEO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD, GstVideoAggregatorConvertPadClass))
158 #define GST_VIDEO_AGGREGATOR_CONVERT_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD, GstVideoAggregatorConvertPadClass))
159 #define GST_IS_VIDEO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD))
160 #define GST_IS_VIDEO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD))
162 typedef struct _GstVideoAggregatorConvertPad GstVideoAggregatorConvertPad;
163 typedef struct _GstVideoAggregatorConvertPadClass GstVideoAggregatorConvertPadClass;
164 typedef struct _GstVideoAggregatorConvertPadPrivate GstVideoAggregatorConvertPadPrivate;
167 * GstVideoAggregatorConvertPad:
169 * An implementation of GstPad that can be used with #GstVideoAggregator.
171 * See #GstVideoAggregator for more details.
175 struct _GstVideoAggregatorConvertPad
178 GstVideoAggregatorPad parent;
180 GstVideoAggregatorConvertPadPrivate *priv;
182 gpointer _gst_reserved[GST_PADDING];
186 * GstVideoAggregatorConvertPadClass:
190 struct _GstVideoAggregatorConvertPadClass
192 GstVideoAggregatorPadClass parent_class;
194 void (*create_conversion_info) (GstVideoAggregatorConvertPad *pad, GstVideoAggregator *agg, GstVideoInfo *conversion_info);
197 gpointer _gst_reserved[GST_PADDING];
201 GType gst_video_aggregator_convert_pad_get_type (void);
204 void gst_video_aggregator_convert_pad_update_conversion_info (GstVideoAggregatorConvertPad * pad);
206 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoAggregatorConvertPad, gst_object_unref);
208 /****************************************
209 * GstVideoAggregatorParallelConvertPad *
210 ****************************************/
212 #define GST_TYPE_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD (gst_video_aggregator_parallel_convert_pad_get_type())
214 G_DECLARE_DERIVABLE_TYPE (GstVideoAggregatorParallelConvertPad, gst_video_aggregator_parallel_convert_pad, GST, VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD, GstVideoAggregatorConvertPad);
216 #define GST_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD, GstVideoAggregatorParallelConvertPad))
217 #define GST_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD, GstVideoAggregatorConvertPadClass))
218 #define GST_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD, GstVideoAggregatorConvertPadClass))
219 #define GST_IS_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD))
220 #define GST_IS_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_AGGREGATOR_PARALLEL_CONVERT_PAD))
223 * GstVideoAggregatorParallelConvertPad:
225 * An implementation of GstPad that can be used with #GstVideoAggregator.
227 * See #GstVideoAggregator for more details.
233 * GstVideoAggregatorParallelConvertPadClass:
237 struct _GstVideoAggregatorParallelConvertPadClass
239 GstVideoAggregatorConvertPadClass parent_class;
242 gpointer _gst_reserved[GST_PADDING];
245 /**********************
246 * GstVideoAggregator *
247 *********************/
249 #define GST_TYPE_VIDEO_AGGREGATOR (gst_video_aggregator_get_type())
250 #define GST_VIDEO_AGGREGATOR(obj) \
251 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR, GstVideoAggregator))
252 #define GST_VIDEO_AGGREGATOR_CAST(obj) ((GstVideoAggregator *)(obj))
253 #define GST_VIDEO_AGGREGATOR_CLASS(klass) \
254 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_AGGREGATOR, GstVideoAggregatorClass))
255 #define GST_IS_VIDEO_AGGREGATOR(obj) \
256 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_AGGREGATOR))
257 #define GST_IS_VIDEO_AGGREGATOR_CLASS(klass) \
258 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_AGGREGATOR))
259 #define GST_VIDEO_AGGREGATOR_GET_CLASS(obj) \
260 (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VIDEO_AGGREGATOR,GstVideoAggregatorClass))
263 * GstVideoAggregator:
264 * @info: The #GstVideoInfo representing the currently set
269 struct _GstVideoAggregator
271 GstAggregator aggregator;
278 GstVideoAggregatorPrivate *priv;
279 gpointer _gst_reserved[GST_PADDING_LARGE];
283 * GstVideoAggregatorClass:
284 * @update_caps: Optional.
285 * Lets subclasses update the #GstCaps representing
286 * the src pad caps before usage. Return %NULL to indicate failure.
287 * @aggregate_frames: Lets subclasses aggregate frames that are ready. Subclasses
288 * should iterate the GstElement.sinkpads and use the already
289 * mapped #GstVideoFrame from gst_video_aggregator_pad_get_prepared_frame()
290 * or directly use the #GstBuffer from gst_video_aggregator_pad_get_current_buffer()
291 * if it needs to map the buffer in a special way. The result of the
292 * aggregation should land in @outbuffer.
293 * @create_output_buffer: Optional.
294 * Lets subclasses provide a #GstBuffer to be used as @outbuffer of
295 * the #aggregate_frames vmethod.
296 * @find_best_format: Optional.
297 * Lets subclasses decide of the best common format to use.
301 struct _GstVideoAggregatorClass
304 GstAggregatorClass parent_class;
307 GstCaps * (*update_caps) (GstVideoAggregator * videoaggregator,
309 GstFlowReturn (*aggregate_frames) (GstVideoAggregator * videoaggregator,
310 GstBuffer * outbuffer);
311 GstFlowReturn (*create_output_buffer) (GstVideoAggregator * videoaggregator,
312 GstBuffer ** outbuffer);
313 void (*find_best_format) (GstVideoAggregator * vagg,
314 GstCaps * downstream_caps,
315 GstVideoInfo * best_info,
316 gboolean * at_least_one_alpha);
319 gpointer _gst_reserved[GST_PADDING_LARGE];
323 GType gst_video_aggregator_get_type (void);
326 GstTaskPool * gst_video_aggregator_get_execution_task_pool (GstVideoAggregator * vagg);
328 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoAggregator, gst_object_unref)
329 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoAggregatorPad, gst_object_unref)
332 #endif /* __GST_VIDEO_AGGREGATOR_H__ */