2 * Copyright (C) 2014 Collabora
3 * Author: Olivier Crete <olivier.crete@collabora.com>
5 * gstaudioaggregator.h:
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_AUDIO_AGGREGATOR_H__
24 #define __GST_AUDIO_AGGREGATOR_H__
26 #ifndef GST_USE_UNSTABLE_API
27 #warning "The Base library from gst-plugins-bad is unstable API and may change in future."
28 #warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
32 #include <gst/base/gstaggregator.h>
33 #include <gst/audio/audio.h>
37 /*******************************
38 * GstAudioAggregator Structs *
39 *******************************/
41 typedef struct _GstAudioAggregator GstAudioAggregator;
42 typedef struct _GstAudioAggregatorPrivate GstAudioAggregatorPrivate;
43 typedef struct _GstAudioAggregatorClass GstAudioAggregatorClass;
46 /************************
47 * GstAudioAggregatorPad API *
48 ***********************/
50 #define GST_TYPE_AUDIO_AGGREGATOR_PAD (gst_audio_aggregator_pad_get_type())
51 #define GST_AUDIO_AGGREGATOR_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPad))
52 #define GST_AUDIO_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPadClass))
53 #define GST_AUDIO_AGGREGATOR_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPadClass))
54 #define GST_IS_AUDIO_AGGREGATOR_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD))
55 #define GST_IS_AUDIO_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_PAD))
57 /****************************
58 * GstAudioAggregatorPad Structs *
59 ***************************/
61 typedef struct _GstAudioAggregatorPad GstAudioAggregatorPad;
62 typedef struct _GstAudioAggregatorPadClass GstAudioAggregatorPadClass;
63 typedef struct _GstAudioAggregatorPadPrivate GstAudioAggregatorPadPrivate;
66 * GstAudioAggregatorPad:
67 * @parent: The parent #GstAggregatorPad
68 * @info: The audio info for this pad set from the incoming caps
70 * The default implementation of GstPad used with #GstAudioAggregator
72 struct _GstAudioAggregatorPad
74 GstAggregatorPad parent;
79 GstAudioAggregatorPadPrivate * priv;
81 gpointer _gst_reserved[GST_PADDING];
85 * GstAudioAggregatorPadClass:
88 struct _GstAudioAggregatorPadClass
90 GstAggregatorPadClass parent_class;
93 gpointer _gst_reserved[GST_PADDING_LARGE];
97 GType gst_audio_aggregator_pad_get_type (void);
99 #define GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD (gst_audio_aggregator_convert_pad_get_type())
100 #define GST_AUDIO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPad))
101 #define GST_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass))
102 #define GST_AUDIO_AGGREGATOR_CONVERT_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass))
103 #define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD))
104 #define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD))
106 /****************************
107 * GstAudioAggregatorPad Structs *
108 ***************************/
110 typedef struct _GstAudioAggregatorConvertPad GstAudioAggregatorConvertPad;
111 typedef struct _GstAudioAggregatorConvertPadClass GstAudioAggregatorConvertPadClass;
112 typedef struct _GstAudioAggregatorConvertPadPrivate GstAudioAggregatorConvertPadPrivate;
115 * GstAudioAggregatorConvertPad:
116 * @parent: The parent #GstAudioAggregatorPad
118 * An implementation of GstPad that can be used with #GstAudioAggregator.
120 * See #GstAudioAggregator for more details.
122 struct _GstAudioAggregatorConvertPad
124 GstAudioAggregatorPad parent;
127 GstAudioAggregatorConvertPadPrivate * priv;
129 gpointer _gst_reserved[GST_PADDING];
133 * GstAudioAggregatorConvertPadClass:
136 struct _GstAudioAggregatorConvertPadClass
138 GstAudioAggregatorPadClass parent_class;
141 gpointer _gst_reserved[GST_PADDING];
145 GType gst_audio_aggregator_convert_pad_get_type (void);
147 /**************************
148 * GstAudioAggregator API *
149 **************************/
151 #define GST_TYPE_AUDIO_AGGREGATOR (gst_audio_aggregator_get_type())
152 #define GST_AUDIO_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregator))
153 #define GST_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass))
154 #define GST_AUDIO_AGGREGATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass))
155 #define GST_IS_AUDIO_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR))
156 #define GST_IS_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR))
159 * GstAudioAggregator:
160 * @parent: The parent #GstAggregator
161 * @info: The information parsed from the current caps
162 * @current_caps: The caps set by the subclass
164 * GstAudioAggregator object
166 struct _GstAudioAggregator
168 GstAggregator parent;
170 /* All member are read only for subclasses, must hold OBJECT lock */
173 GstCaps *current_caps;
176 GstAudioAggregatorPrivate *priv;
178 gpointer _gst_reserved[GST_PADDING];
182 * GstAudioAggregatorClass:
183 * @create_output_buffer: Create a new output buffer contains num_frames frames.
184 * @aggregate_one_buffer: Aggregates one input buffer to the output
185 * buffer. The in_offset and out_offset are in "frames", which is
186 * the size of a sample times the number of channels. Returns TRUE if
187 * any non-silence was added to the buffer
188 * @convert_buffer: Convert a buffer from one format to another. The pad
189 * is either a sinkpad, when converting an input buffer, or the source pad,
190 * when converting the output buffer after a downstream format change is
193 struct _GstAudioAggregatorClass {
194 GstAggregatorClass parent_class;
196 GstBuffer * (* create_output_buffer) (GstAudioAggregator * aagg,
198 gboolean (* aggregate_one_buffer) (GstAudioAggregator * aagg,
199 GstAudioAggregatorPad * pad, GstBuffer * inbuf, guint in_offset,
200 GstBuffer * outbuf, guint out_offset, guint num_frames);
201 GstBuffer * (* convert_buffer) (GstAudioAggregator *aagg,
203 GstAudioInfo *in_info,
204 GstAudioInfo *out_info,
208 gpointer _gst_reserved[GST_PADDING_LARGE];
211 /*************************
212 * GstAggregator methods *
213 ************************/
216 GType gst_audio_aggregator_get_type(void);
219 void gst_audio_aggregator_set_sink_caps (GstAudioAggregator * aagg,
220 GstAudioAggregatorPad * pad,
224 void gst_audio_aggregator_class_perform_conversion (GstAudioAggregatorClass * klass);
228 #endif /* __GST_AUDIO_AGGREGATOR_H__ */