b32630ee677eeba65da195f2772d00a643c874ea
[platform/upstream/gstreamer.git] / gst-libs / gst / audio / gstaudioaggregator.h
1 /* GStreamer
2  * Copyright (C) 2014 Collabora
3  *   Author: Olivier Crete <olivier.crete@collabora.com>
4  *
5  * gstaudioaggregator.h:
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 #ifndef __GST_AUDIO_AGGREGATOR_H__
24 #define __GST_AUDIO_AGGREGATOR_H__
25
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."
29 #endif
30
31 #include <gst/gst.h>
32 #include <gst/base/gstaggregator.h>
33 #include <gst/audio/audio.h>
34
35 G_BEGIN_DECLS
36
37 /*******************************
38  * GstAudioAggregator Structs  *
39  *******************************/
40
41 typedef struct _GstAudioAggregator GstAudioAggregator;
42 typedef struct _GstAudioAggregatorPrivate GstAudioAggregatorPrivate;
43 typedef struct _GstAudioAggregatorClass GstAudioAggregatorClass;
44
45
46 /************************
47  * GstAudioAggregatorPad API *
48  ***********************/
49
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))
56
57 /****************************
58  * GstAudioAggregatorPad Structs *
59  ***************************/
60
61 typedef struct _GstAudioAggregatorPad GstAudioAggregatorPad;
62 typedef struct _GstAudioAggregatorPadClass GstAudioAggregatorPadClass;
63 typedef struct _GstAudioAggregatorPadPrivate GstAudioAggregatorPadPrivate;
64
65 /**
66  * GstAudioAggregatorPad:
67  * @parent: The parent #GstAggregatorPad
68  * @info: The audio info for this pad set from the incoming caps
69  *
70  * The default implementation of GstPad used with #GstAudioAggregator
71  */
72 struct _GstAudioAggregatorPad
73 {
74   GstAggregatorPad                  parent;
75
76   GstAudioInfo                      info;
77
78   /*< private >*/
79   GstAudioAggregatorPadPrivate   *  priv;
80
81   gpointer _gst_reserved[GST_PADDING];
82 };
83
84 /**
85  * GstAudioAggregatorPadClass:
86  *
87  */
88 struct _GstAudioAggregatorPadClass
89   {
90   GstAggregatorPadClass   parent_class;
91
92   /*< private >*/
93   gpointer      _gst_reserved[GST_PADDING_LARGE];
94 };
95
96 GST_EXPORT
97 GType gst_audio_aggregator_pad_get_type           (void);
98
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))
105
106 /****************************
107  * GstAudioAggregatorPad Structs *
108  ***************************/
109
110 typedef struct _GstAudioAggregatorConvertPad GstAudioAggregatorConvertPad;
111 typedef struct _GstAudioAggregatorConvertPadClass GstAudioAggregatorConvertPadClass;
112 typedef struct _GstAudioAggregatorConvertPadPrivate GstAudioAggregatorConvertPadPrivate;
113
114 /**
115  * GstAudioAggregatorConvertPad:
116  * @parent: The parent #GstAudioAggregatorPad
117  *
118  * An implementation of GstPad that can be used with #GstAudioAggregator.
119  *
120  * See #GstAudioAggregator for more details.
121  */
122 struct _GstAudioAggregatorConvertPad
123 {
124   GstAudioAggregatorPad                  parent;
125
126   /*< private >*/
127   GstAudioAggregatorConvertPadPrivate   *  priv;
128
129   gpointer _gst_reserved[GST_PADDING];
130 };
131
132 /**
133  * GstAudioAggregatorConvertPadClass:
134  *
135  */
136 struct _GstAudioAggregatorConvertPadClass
137 {
138   GstAudioAggregatorPadClass   parent_class;
139
140   /*< private >*/
141   gpointer      _gst_reserved[GST_PADDING];
142 };
143
144 GST_EXPORT
145 GType gst_audio_aggregator_convert_pad_get_type           (void);
146
147 /**************************
148  * GstAudioAggregator API *
149  **************************/
150
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))
157
158 /**
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
163  *
164  * GstAudioAggregator object
165  */
166 struct _GstAudioAggregator
167 {
168   GstAggregator            parent;
169
170   /* All member are read only for subclasses, must hold OBJECT lock  */
171   GstAudioInfo    info;
172
173   GstCaps *current_caps;
174
175   /*< private >*/
176   GstAudioAggregatorPrivate *priv;
177
178   gpointer                 _gst_reserved[GST_PADDING];
179 };
180
181 /**
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
191  *  requested.
192  */
193 struct _GstAudioAggregatorClass {
194   GstAggregatorClass   parent_class;
195
196   GstBuffer * (* create_output_buffer) (GstAudioAggregator * aagg,
197       guint num_frames);
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,
202                                   GstPad * pad,
203                                   GstAudioInfo *in_info,
204                                   GstAudioInfo *out_info,
205                                   GstBuffer * buffer);
206
207   /*< private >*/
208   gpointer          _gst_reserved[GST_PADDING_LARGE];
209 };
210
211 /*************************
212  * GstAggregator methods *
213  ************************/
214
215 GST_EXPORT
216 GType gst_audio_aggregator_get_type(void);
217
218 GST_EXPORT
219 void  gst_audio_aggregator_set_sink_caps (GstAudioAggregator    * aagg,
220                                           GstAudioAggregatorPad * pad,
221                                           GstCaps               * caps);
222
223 GST_EXPORT
224 void gst_audio_aggregator_class_perform_conversion (GstAudioAggregatorClass * klass);
225
226 G_END_DECLS
227
228 #endif /* __GST_AUDIO_AGGREGATOR_H__ */