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 | #include <gst/gst.h> |
27 | #include <gst/base/gstaggregator.h> |
28 | #include <gst/audio/audio.h> |
29 | |
30 | G_BEGIN_DECLS |
31 | |
32 | /******************************* |
33 | * GstAudioAggregator Structs * |
34 | *******************************/ |
35 | |
36 | typedef struct _GstAudioAggregator GstAudioAggregator; |
37 | typedef struct _GstAudioAggregatorPrivate GstAudioAggregatorPrivate; |
38 | typedef struct _GstAudioAggregatorClass GstAudioAggregatorClass; |
39 | |
40 | |
41 | /************************ |
42 | * GstAudioAggregatorPad API * |
43 | ***********************/ |
44 | |
45 | #define GST_TYPE_AUDIO_AGGREGATOR_PAD (gst_audio_aggregator_pad_get_type()) |
46 | #define GST_AUDIO_AGGREGATOR_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPad)) |
47 | #define GST_AUDIO_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPadClass)) |
48 | #define GST_AUDIO_AGGREGATOR_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPadClass)) |
49 | #define GST_IS_AUDIO_AGGREGATOR_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD)) |
50 | #define GST_IS_AUDIO_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_PAD)) |
51 | |
52 | /**************************** |
53 | * GstAudioAggregatorPad Structs * |
54 | ***************************/ |
55 | |
56 | typedef struct _GstAudioAggregatorPad GstAudioAggregatorPad; |
57 | typedef struct _GstAudioAggregatorPadClass GstAudioAggregatorPadClass; |
58 | typedef struct _GstAudioAggregatorPadPrivate GstAudioAggregatorPadPrivate; |
59 | |
60 | /** |
61 | * GstAudioAggregatorPad: |
62 | * @info: The audio info for this pad set from the incoming caps |
63 | * |
64 | * The default implementation of GstPad used with #GstAudioAggregator |
65 | * |
66 | * Since: 1.14 |
67 | */ |
68 | struct _GstAudioAggregatorPad |
69 | { |
70 | GstAggregatorPad parent; |
71 | |
72 | /*< public >*/ |
73 | /* read-only, with OBJECT_LOCK */ |
74 | GstAudioInfo info; |
75 | |
76 | /*< private >*/ |
77 | GstAudioAggregatorPadPrivate *priv; |
78 | |
79 | gpointer _gst_reserved[GST_PADDING]; |
80 | }; |
81 | |
82 | /** |
83 | * GstAudioAggregatorPadClass: |
84 | * @convert_buffer: Convert a buffer from one format to another. |
85 | * @update_conversion_info: Called when either the input or output |
86 | * formats have changed. |
87 | * |
88 | * Since: 1.14 |
89 | */ |
90 | struct _GstAudioAggregatorPadClass |
91 | { |
92 | GstAggregatorPadClass parent_class; |
93 | |
94 | GstBuffer * (* convert_buffer) (GstAudioAggregatorPad * pad, |
95 | GstAudioInfo *in_info, |
96 | GstAudioInfo *out_info, |
97 | GstBuffer * buffer); |
98 | |
99 | void (* update_conversion_info) (GstAudioAggregatorPad *pad); |
100 | |
101 | /*< private >*/ |
102 | gpointer _gst_reserved[GST_PADDING_LARGE]; |
103 | }; |
104 | |
105 | GST_AUDIO_API |
106 | GType gst_audio_aggregator_pad_get_type (void); |
107 | |
108 | #define GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD (gst_audio_aggregator_convert_pad_get_type()) |
109 | #define GST_AUDIO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPad)) |
110 | #define GST_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass)) |
111 | #define GST_AUDIO_AGGREGATOR_CONVERT_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass)) |
112 | #define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD)) |
113 | #define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD)) |
114 | |
115 | /**************************** |
116 | * GstAudioAggregatorPad Structs * |
117 | ***************************/ |
118 | |
119 | typedef struct _GstAudioAggregatorConvertPad GstAudioAggregatorConvertPad; |
120 | typedef struct _GstAudioAggregatorConvertPadClass GstAudioAggregatorConvertPadClass; |
121 | typedef struct _GstAudioAggregatorConvertPadPrivate GstAudioAggregatorConvertPadPrivate; |
122 | |
123 | /** |
124 | * GstAudioAggregatorConvertPad: |
125 | * |
126 | * An implementation of GstPad that can be used with #GstAudioAggregator. |
127 | * |
128 | * See #GstAudioAggregator for more details. |
129 | * |
130 | * Since: 1.14 |
131 | */ |
132 | struct _GstAudioAggregatorConvertPad |
133 | { |
134 | /*< private >*/ |
135 | GstAudioAggregatorPad parent; |
136 | |
137 | GstAudioAggregatorConvertPadPrivate *priv; |
138 | |
139 | gpointer _gst_reserved[GST_PADDING]; |
140 | }; |
141 | |
142 | /** |
143 | * GstAudioAggregatorConvertPadClass: |
144 | * |
145 | * Since: 1.14 |
146 | */ |
147 | struct _GstAudioAggregatorConvertPadClass |
148 | { |
149 | GstAudioAggregatorPadClass parent_class; |
150 | |
151 | /*< private >*/ |
152 | gpointer _gst_reserved[GST_PADDING]; |
153 | }; |
154 | |
155 | GST_AUDIO_API |
156 | GType gst_audio_aggregator_convert_pad_get_type (void); |
157 | |
158 | /************************** |
159 | * GstAudioAggregator API * |
160 | **************************/ |
161 | |
162 | #define GST_TYPE_AUDIO_AGGREGATOR (gst_audio_aggregator_get_type()) |
163 | #define GST_AUDIO_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregator)) |
164 | #define GST_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass)) |
165 | #define GST_AUDIO_AGGREGATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass)) |
166 | #define GST_IS_AUDIO_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR)) |
167 | #define GST_IS_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR)) |
168 | |
169 | /** |
170 | * GstAudioAggregator: |
171 | * @current_caps: The caps set by the subclass |
172 | * |
173 | * GstAudioAggregator object |
174 | * |
175 | * Since: 1.14 |
176 | */ |
177 | struct _GstAudioAggregator |
178 | { |
179 | GstAggregator parent; |
180 | |
181 | /*< public >*/ |
182 | GstCaps *current_caps; |
183 | |
184 | /*< private >*/ |
185 | GstAudioAggregatorPrivate *priv; |
186 | |
187 | gpointer _gst_reserved[GST_PADDING]; |
188 | }; |
189 | |
190 | /** |
191 | * GstAudioAggregatorClass: |
192 | * @create_output_buffer: Create a new output buffer contains num_frames frames. |
193 | * @aggregate_one_buffer: Aggregates one input buffer to the output |
194 | * buffer. The in_offset and out_offset are in "frames", which is |
195 | * the size of a sample times the number of channels. Returns TRUE if |
196 | * any non-silence was added to the buffer |
197 | * |
198 | * Since: 1.14 |
199 | */ |
200 | struct _GstAudioAggregatorClass { |
201 | GstAggregatorClass parent_class; |
202 | |
203 | /*< public >*/ |
204 | GstBuffer * (* create_output_buffer) (GstAudioAggregator * aagg, |
205 | guint num_frames); |
206 | gboolean (* aggregate_one_buffer) (GstAudioAggregator * aagg, |
207 | GstAudioAggregatorPad * pad, GstBuffer * inbuf, guint in_offset, |
208 | GstBuffer * outbuf, guint out_offset, guint num_frames); |
209 | |
210 | /*< private >*/ |
211 | gpointer _gst_reserved[GST_PADDING_LARGE]; |
212 | }; |
213 | |
214 | /************************* |
215 | * GstAggregator methods * |
216 | ************************/ |
217 | |
218 | GST_AUDIO_API |
219 | GType gst_audio_aggregator_get_type(void); |
220 | |
221 | GST_AUDIO_API |
222 | void gst_audio_aggregator_set_sink_caps (GstAudioAggregator * aagg, |
223 | GstAudioAggregatorPad * pad, |
224 | GstCaps * caps); |
225 | |
226 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioAggregator, gst_object_unref) |
227 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioAggregatorPad, gst_object_unref) |
228 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioAggregatorConvertPad, gst_object_unref) |
229 | |
230 | G_END_DECLS |
231 | |
232 | #endif /* __GST_AUDIO_AGGREGATOR_H__ */ |
233 | |