2 * Copyright (C) 2014 Mathieu Duponchelle <mathieu.duponchelle@oencreed.com>
3 * Copyright (C) 2014 Thibault Saunier <tsaunier@gnome.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
23 #ifndef __GST_AGGREGATOR_H__
24 #define __GST_AGGREGATOR_H__
30 /**************************
31 * GstAggregator Structs *
32 *************************/
34 typedef struct _GstAggregator GstAggregator;
35 typedef struct _GstAggregatorPrivate GstAggregatorPrivate;
36 typedef struct _GstAggregatorClass GstAggregatorClass;
38 /************************
39 * GstAggregatorPad API *
40 ***********************/
42 #define GST_TYPE_AGGREGATOR_PAD (gst_aggregator_pad_get_type())
43 #define GST_AGGREGATOR_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AGGREGATOR_PAD, GstAggregatorPad))
44 #define GST_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AGGREGATOR_PAD, GstAggregatorPadClass))
45 #define GST_AGGREGATOR_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AGGREGATOR_PAD, GstAggregatorPadClass))
46 #define GST_IS_AGGREGATOR_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AGGREGATOR_PAD))
47 #define GST_IS_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AGGREGATOR_PAD))
49 /****************************
50 * GstAggregatorPad Structs *
51 ***************************/
53 typedef struct _GstAggregatorPad GstAggregatorPad;
54 typedef struct _GstAggregatorPadClass GstAggregatorPadClass;
55 typedef struct _GstAggregatorPadPrivate GstAggregatorPadPrivate;
59 * @buffer: currently queued buffer.
60 * @segment: last segment received.
62 * The implementation the GstPad to use with #GstAggregator
64 struct _GstAggregatorPad
73 GstAggregatorPadPrivate * priv;
75 gpointer _gst_reserved[GST_PADDING];
79 * GstAggregatorPadClass:
81 * Called when the pad has received a flush stop, this is the place
82 * to flush any information specific to the pad, it allows for individual
83 * pads to be flushed while others might not be.
86 struct _GstAggregatorPadClass
88 GstPadClass parent_class;
90 GstFlowReturn (*flush) (GstAggregatorPad * aggpad, GstAggregator * aggregator);
93 gpointer _gst_reserved[GST_PADDING];
96 GType gst_aggregator_pad_get_type (void);
98 /****************************
99 * GstAggregatorPad methods *
100 ***************************/
102 GstBuffer * gst_aggregator_pad_steal_buffer (GstAggregatorPad * pad);
103 GstBuffer * gst_aggregator_pad_get_buffer (GstAggregatorPad * pad);
105 /*********************
106 * GstAggregator API *
107 ********************/
109 #define GST_TYPE_AGGREGATOR (gst_aggregator_get_type())
110 #define GST_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AGGREGATOR,GstAggregator))
111 #define GST_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AGGREGATOR,GstAggregatorClass))
112 #define GST_AGGREGATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AGGREGATOR,GstAggregatorClass))
113 #define GST_IS_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AGGREGATOR))
114 #define GST_IS_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AGGREGATOR))
116 #define GST_FLOW_CUSTOM_SUCCESS GST_FLOW_NOT_HANDLED
120 * @aggregator_pads: #GList of #GstAggregatorPad managed by this #GstAggregator.
122 * Collectpads object.
124 struct _GstAggregator
133 GstAggregatorPrivate * priv;
135 gpointer _gst_reserved[GST_PADDING];
139 * GstAggregatorClass:
140 * @sinkpads_type: Optional.
141 * The type of the pads that should be created when
142 * GstElement.request_new_pad is called.
144 * Called after a succesful flushing seek, once all the flush
145 * stops have been received. Flush pad-specific data in
146 * #GstAggregatorPad->flush.
148 * Called when a buffer is received on a sink pad, the task
149 * of clipping it and translating it to the current segment
150 * falls on the subclass.
151 * @sink_event: Optional.
152 * Called when an event is received on a sink pad, the subclass
153 * should always chain up.
154 * @sink_query: Optional.
155 * Called when a query is received on a sink pad, the subclass
156 * should always chain up.
157 * @src_event: Optional.
158 * Called when an event is received on the src pad, the subclass
159 * should always chain up.
160 * @src_query: Optional.
161 * Called when a query is received on the src pad, the subclass
162 * should always chain up.
163 * @src_activate: Optional.
164 * Called when the src pad is activated, it will start/stop its
165 * pad task right after that call.
166 * @aggregate: Mandatory.
167 * Called when buffers are queued on all sinkpads. Classes
168 * should iterate the GstElement->sinkpads and peek or steal
169 * buffers from the #GstAggregatorPads. If the subclass returns
170 * GST_FLOW_EOS, sending of the eos event will be taken care
171 * of. Once / if a buffer has been constructed from the
172 * aggregated buffers, the subclass should call _finish_buffer.
174 * Should be linked up first. Called when the
175 * element goes from PAUSED to READY. The subclass should free
176 * all resources and reset its state.
178 * Should be linked up first. Called when the element goes from
179 * READY to PAUSED. The subclass should get ready to process
180 * aggregated buffers.
182 * The aggregator base class will handle in a thread-safe way all manners of
183 * concurrent flushes, seeks, pad additions and removals, leaving to the
184 * subclass the responsibility of clipping buffers, and aggregating buffers in
185 * the way the implementor sees fit.
187 * It will also take care of event ordering (stream-start, segment, eos).
189 * Basically, a basic implementation will override @aggregate, and call
190 * _finish_buffer from inside that function.
192 struct _GstAggregatorClass {
193 GstElementClass parent_class;
197 GstFlowReturn (*flush) (GstAggregator * aggregator);
199 GstFlowReturn (*clip) (GstAggregator * agg,
200 GstAggregatorPad * bpad,
202 GstBuffer ** outbuf);
204 /* sinkpads virtual methods */
205 gboolean (*sink_event) (GstAggregator * aggregate,
206 GstAggregatorPad * bpad,
209 gboolean (*sink_query) (GstAggregator * aggregate,
210 GstAggregatorPad * bpad,
213 /* srcpad virtual methods */
214 gboolean (*src_event) (GstAggregator * aggregate,
217 gboolean (*src_query) (GstAggregator * aggregate,
220 gboolean (*src_activate) (GstAggregator * aggregator,
224 GstFlowReturn (*aggregate) (GstAggregator * aggregator);
226 gboolean (*stop) (GstAggregator * aggregator);
228 gboolean (*start) (GstAggregator * aggregator);
231 gpointer _gst_reserved[GST_PADDING];
234 /*************************
235 * GstAggregator methods *
236 ************************/
238 GstFlowReturn gst_aggregator_finish_buffer (GstAggregator * agg,
240 void gst_aggregator_set_src_caps (GstAggregator * agg,
243 GType gst_aggregator_get_type(void);
245 /* API that should eventually land in GstElement itself*/
246 typedef gboolean (*GstAggregatorPadForeachFunc) (GstAggregator * self,
249 gboolean gst_aggregator_iterate_sinkpads (GstAggregator * self,
250 GstAggregatorPadForeachFunc func,
256 #endif /* __GST_AGGREGATOR_H__ */