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 | struct _GstAudioAggregatorPad |
67 | { |
68 | GstAggregatorPad parent; |
69 | |
70 | /*< public >*/ |
71 | /* read-only, with OBJECT_LOCK */ |
72 | GstAudioInfo info; |
73 | |
74 | /*< private >*/ |
75 | GstAudioAggregatorPadPrivate *priv; |
76 | |
77 | gpointer _gst_reserved[GST_PADDING]; |
78 | }; |
79 | |
80 | /** |
81 | * GstAudioAggregatorPadClass: |
82 | * @convert_buffer: Convert a buffer from one format to another. |
83 | * @update_conversion_info: Called when either the input or output |
84 | * formats have changed. |
85 | */ |
86 | struct _GstAudioAggregatorPadClass |
87 | { |
88 | GstAggregatorPadClass parent_class; |
89 | |
90 | GstBuffer * (* convert_buffer) (GstAudioAggregatorPad * pad, |
91 | GstAudioInfo *in_info, |
92 | GstAudioInfo *out_info, |
93 | GstBuffer * buffer); |
94 | |
95 | void (* update_conversion_info) (GstAudioAggregatorPad *pad); |
96 | |
97 | /*< private >*/ |
98 | gpointer _gst_reserved[GST_PADDING_LARGE]; |
99 | }; |
100 | |
101 | GST_AUDIO_API |
102 | GType gst_audio_aggregator_pad_get_type (void); |
103 | |
104 | #define GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD (gst_audio_aggregator_convert_pad_get_type()) |
105 | #define GST_AUDIO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPad)) |
106 | #define GST_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass)) |
107 | #define GST_AUDIO_AGGREGATOR_CONVERT_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass)) |
108 | #define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD)) |
109 | #define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD)) |
110 | |
111 | /**************************** |
112 | * GstAudioAggregatorPad Structs * |
113 | ***************************/ |
114 | |
115 | typedef struct _GstAudioAggregatorConvertPad GstAudioAggregatorConvertPad; |
116 | typedef struct _GstAudioAggregatorConvertPadClass GstAudioAggregatorConvertPadClass; |
117 | typedef struct _GstAudioAggregatorConvertPadPrivate GstAudioAggregatorConvertPadPrivate; |
118 | |
119 | /** |
120 | * GstAudioAggregatorConvertPad: |
121 | * |
122 | * An implementation of GstPad that can be used with #GstAudioAggregator. |
123 | * |
124 | * See #GstAudioAggregator for more details. |
125 | */ |
126 | struct _GstAudioAggregatorConvertPad |
127 | { |
128 | /*< private >*/ |
129 | GstAudioAggregatorPad parent; |
130 | |
131 | GstAudioAggregatorConvertPadPrivate *priv; |
132 | |
133 | gpointer _gst_reserved[GST_PADDING]; |
134 | }; |
135 | |
136 | /** |
137 | * GstAudioAggregatorConvertPadClass: |
138 | * |
139 | */ |
140 | struct _GstAudioAggregatorConvertPadClass |
141 | { |
142 | GstAudioAggregatorPadClass parent_class; |
143 | |
144 | /*< private >*/ |
145 | gpointer _gst_reserved[GST_PADDING]; |
146 | }; |
147 | |
148 | GST_AUDIO_API |
149 | GType gst_audio_aggregator_convert_pad_get_type (void); |
150 | |
151 | /************************** |
152 | * GstAudioAggregator API * |
153 | **************************/ |
154 | |
155 | #define GST_TYPE_AUDIO_AGGREGATOR (gst_audio_aggregator_get_type()) |
156 | #define GST_AUDIO_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregator)) |
157 | #define GST_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass)) |
158 | #define GST_AUDIO_AGGREGATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass)) |
159 | #define GST_IS_AUDIO_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR)) |
160 | #define GST_IS_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR)) |
161 | |
162 | /** |
163 | * GstAudioAggregator: |
164 | * @current_caps: The caps set by the subclass |
165 | * |
166 | * GstAudioAggregator object |
167 | */ |
168 | struct _GstAudioAggregator |
169 | { |
170 | GstAggregator parent; |
171 | |
172 | /*< public >*/ |
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 | */ |
189 | struct _GstAudioAggregatorClass { |
190 | GstAggregatorClass parent_class; |
191 | |
192 | /*< public >*/ |
193 | GstBuffer * (* create_output_buffer) (GstAudioAggregator * aagg, |
194 | guint num_frames); |
195 | gboolean (* aggregate_one_buffer) (GstAudioAggregator * aagg, |
196 | GstAudioAggregatorPad * pad, GstBuffer * inbuf, guint in_offset, |
197 | GstBuffer * outbuf, guint out_offset, guint num_frames); |
198 | |
199 | /*< private >*/ |
200 | gpointer _gst_reserved[GST_PADDING_LARGE]; |
201 | }; |
202 | |
203 | /************************* |
204 | * GstAggregator methods * |
205 | ************************/ |
206 | |
207 | GST_AUDIO_API |
208 | GType gst_audio_aggregator_get_type(void); |
209 | |
210 | GST_AUDIO_API |
211 | void gst_audio_aggregator_set_sink_caps (GstAudioAggregator * aagg, |
212 | GstAudioAggregatorPad * pad, |
213 | GstCaps * caps); |
214 | |
215 | G_END_DECLS |
216 | |
217 | #endif /* __GST_AUDIO_AGGREGATOR_H__ */ |
218 | |