• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef OPENSL_ES_ANDROID_H_
18 #define OPENSL_ES_ANDROID_H_
19 
20 #include "OpenSLES_AndroidConfiguration.h"
21 #include "OpenSLES_AndroidMetadata.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*---------------------------------------------------------------------------*/
28 /* Android common types                                                      */
29 /*---------------------------------------------------------------------------*/
30 
31 typedef sl_int64_t             SLAint64;          /* 64 bit signed integer   */
32 
33 typedef sl_uint64_t            SLAuint64;         /* 64 bit unsigned integer */
34 
35 /*---------------------------------------------------------------------------*/
36 /* Android PCM Data Format                                                   */
37 /*---------------------------------------------------------------------------*/
38 
39 /* The following pcm representations and data formats map to those in OpenSLES 1.1 */
40 #define SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT       ((SLuint32) 0x00000001)
41 #define SL_ANDROID_PCM_REPRESENTATION_UNSIGNED_INT     ((SLuint32) 0x00000002)
42 #define SL_ANDROID_PCM_REPRESENTATION_FLOAT            ((SLuint32) 0x00000003)
43 
44 #define SL_ANDROID_DATAFORMAT_PCM_EX    ((SLuint32) 0x00000004)
45 
46 typedef struct SLAndroidDataFormat_PCM_EX_ {
47     SLuint32         formatType;
48     SLuint32         numChannels;
49     SLuint32         sampleRate;
50     SLuint32         bitsPerSample;
51     SLuint32         containerSize;
52     SLuint32         channelMask;
53     SLuint32         endianness;
54     SLuint32         representation;
55 } SLAndroidDataFormat_PCM_EX;
56 
57 /*---------------------------------------------------------------------------*/
58 /* Android Effect interface                                                  */
59 /*---------------------------------------------------------------------------*/
60 
61 extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECT;
62 
63 /** Android Effect interface methods */
64 
65 struct SLAndroidEffectItf_;
66 typedef const struct SLAndroidEffectItf_ * const * SLAndroidEffectItf;
67 
68 struct SLAndroidEffectItf_ {
69 
70     SLresult (*CreateEffect) (SLAndroidEffectItf self,
71             SLInterfaceID effectImplementationId);
72 
73     SLresult (*ReleaseEffect) (SLAndroidEffectItf self,
74             SLInterfaceID effectImplementationId);
75 
76     SLresult (*SetEnabled) (SLAndroidEffectItf self,
77             SLInterfaceID effectImplementationId,
78             SLboolean enabled);
79 
80     SLresult (*IsEnabled) (SLAndroidEffectItf self,
81             SLInterfaceID effectImplementationId,
82             SLboolean *pEnabled);
83 
84     SLresult (*SendCommand) (SLAndroidEffectItf self,
85             SLInterfaceID effectImplementationId,
86             SLuint32 command,
87             SLuint32 commandSize,
88             void *pCommandData,
89             SLuint32 *replySize,
90             void *pReplyData);
91 };
92 
93 
94 /*---------------------------------------------------------------------------*/
95 /* Android Effect Send interface                                             */
96 /*---------------------------------------------------------------------------*/
97 
98 extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTSEND;
99 
100 /** Android Effect Send interface methods */
101 
102 struct SLAndroidEffectSendItf_;
103 typedef const struct SLAndroidEffectSendItf_ * const * SLAndroidEffectSendItf;
104 
105 struct SLAndroidEffectSendItf_ {
106     SLresult (*EnableEffectSend) (
107         SLAndroidEffectSendItf self,
108         SLInterfaceID effectImplementationId,
109         SLboolean enable,
110         SLmillibel initialLevel
111     );
112     SLresult (*IsEnabled) (
113         SLAndroidEffectSendItf self,
114         SLInterfaceID effectImplementationId,
115         SLboolean *pEnable
116     );
117     SLresult (*SetDirectLevel) (
118         SLAndroidEffectSendItf self,
119         SLmillibel directLevel
120     );
121     SLresult (*GetDirectLevel) (
122         SLAndroidEffectSendItf self,
123         SLmillibel *pDirectLevel
124     );
125     SLresult (*SetSendLevel) (
126         SLAndroidEffectSendItf self,
127         SLInterfaceID effectImplementationId,
128         SLmillibel sendLevel
129     );
130     SLresult (*GetSendLevel)(
131         SLAndroidEffectSendItf self,
132         SLInterfaceID effectImplementationId,
133         SLmillibel *pSendLevel
134     );
135 };
136 
137 
138 /*---------------------------------------------------------------------------*/
139 /* Android Effect Capabilities interface                                     */
140 /*---------------------------------------------------------------------------*/
141 
142 extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTCAPABILITIES;
143 
144 /** Android Effect Capabilities interface methods */
145 
146 struct SLAndroidEffectCapabilitiesItf_;
147 typedef const struct SLAndroidEffectCapabilitiesItf_ * const * SLAndroidEffectCapabilitiesItf;
148 
149 struct SLAndroidEffectCapabilitiesItf_ {
150 
151     SLresult (*QueryNumEffects) (SLAndroidEffectCapabilitiesItf self,
152             SLuint32 *pNumSupportedEffects);
153 
154 
155     SLresult (*QueryEffect) (SLAndroidEffectCapabilitiesItf self,
156             SLuint32 index,
157             SLInterfaceID *pEffectType,
158             SLInterfaceID *pEffectImplementation,
159             SLchar *pName,
160             SLuint16 *pNameSize);
161 };
162 
163 
164 /*---------------------------------------------------------------------------*/
165 /* Android Configuration interface                                           */
166 /*---------------------------------------------------------------------------*/
167 extern SL_API const SLInterfaceID SL_IID_ANDROIDCONFIGURATION;
168 
169 /** Android Configuration interface methods */
170 
171 struct SLAndroidConfigurationItf_;
172 typedef const struct SLAndroidConfigurationItf_ * const * SLAndroidConfigurationItf;
173 
174 struct SLAndroidConfigurationItf_ {
175 
176     SLresult (*SetConfiguration) (SLAndroidConfigurationItf self,
177             const SLchar *configKey,
178             const void *pConfigValue,
179             SLuint32 valueSize);
180 
181     SLresult (*GetConfiguration) (SLAndroidConfigurationItf self,
182            const SLchar *configKey,
183            SLuint32 *pValueSize,
184            void *pConfigValue
185        );
186 };
187 
188 
189 /*---------------------------------------------------------------------------*/
190 /* Android Simple Buffer Queue Interface                                     */
191 /*---------------------------------------------------------------------------*/
192 
193 extern SL_API const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
194 
195 struct SLAndroidSimpleBufferQueueItf_;
196 typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf;
197 
198 typedef void (SLAPIENTRY *slAndroidSimpleBufferQueueCallback)(
199 	SLAndroidSimpleBufferQueueItf caller,
200 	void *pContext
201 );
202 
203 /** Android simple buffer queue state **/
204 
205 typedef struct SLAndroidSimpleBufferQueueState_ {
206 	SLuint32	count;
207 	SLuint32	index;
208 } SLAndroidSimpleBufferQueueState;
209 
210 
211 struct SLAndroidSimpleBufferQueueItf_ {
212 	SLresult (*Enqueue) (
213 		SLAndroidSimpleBufferQueueItf self,
214 		const void *pBuffer,
215 		SLuint32 size
216 	);
217 	SLresult (*Clear) (
218 		SLAndroidSimpleBufferQueueItf self
219 	);
220 	SLresult (*GetState) (
221 		SLAndroidSimpleBufferQueueItf self,
222 		SLAndroidSimpleBufferQueueState *pState
223 	);
224 	SLresult (*RegisterCallback) (
225 		SLAndroidSimpleBufferQueueItf self,
226 		slAndroidSimpleBufferQueueCallback callback,
227 		void* pContext
228 	);
229 };
230 
231 
232 /*---------------------------------------------------------------------------*/
233 /* Android Buffer Queue Interface                                            */
234 /*---------------------------------------------------------------------------*/
235 
236 extern SL_API const SLInterfaceID SL_IID_ANDROIDBUFFERQUEUESOURCE;
237 
238 struct SLAndroidBufferQueueItf_;
239 typedef const struct SLAndroidBufferQueueItf_ * const * SLAndroidBufferQueueItf;
240 
241 #define SL_ANDROID_ITEMKEY_NONE             ((SLuint32) 0x00000000)
242 #define SL_ANDROID_ITEMKEY_EOS              ((SLuint32) 0x00000001)
243 #define SL_ANDROID_ITEMKEY_DISCONTINUITY    ((SLuint32) 0x00000002)
244 #define SL_ANDROID_ITEMKEY_BUFFERQUEUEEVENT ((SLuint32) 0x00000003)
245 #define SL_ANDROID_ITEMKEY_FORMAT_CHANGE    ((SLuint32) 0x00000004)
246 
247 #define SL_ANDROIDBUFFERQUEUEEVENT_NONE        ((SLuint32) 0x00000000)
248 #define SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED   ((SLuint32) 0x00000001)
249 #if 0   // reserved for future use
250 #define SL_ANDROIDBUFFERQUEUEEVENT_UNREALIZED  ((SLuint32) 0x00000002)
251 #define SL_ANDROIDBUFFERQUEUEEVENT_CLEARED     ((SLuint32) 0x00000004)
252 #define SL_ANDROIDBUFFERQUEUEEVENT_STOPPED     ((SLuint32) 0x00000008)
253 #define SL_ANDROIDBUFFERQUEUEEVENT_ERROR       ((SLuint32) 0x00000010)
254 #define SL_ANDROIDBUFFERQUEUEEVENT_CONTENT_END ((SLuint32) 0x00000020)
255 #endif
256 
257 typedef struct SLAndroidBufferItem_ {
258     SLuint32 itemKey;  // identifies the item
259     SLuint32 itemSize;
260     SLuint8  itemData[0];
261 } SLAndroidBufferItem;
262 
263 typedef SLresult (SLAPIENTRY *slAndroidBufferQueueCallback)(
264     SLAndroidBufferQueueItf caller,/* input */
265     void *pCallbackContext,        /* input */
266     void *pBufferContext,          /* input */
267     void *pBufferData,             /* input */
268     SLuint32 dataSize,             /* input */
269     SLuint32 dataUsed,             /* input */
270     const SLAndroidBufferItem *pItems,/* input */
271     SLuint32 itemsLength           /* input */
272 );
273 
274 typedef struct SLAndroidBufferQueueState_ {
275     SLuint32    count;
276     SLuint32    index;
277 } SLAndroidBufferQueueState;
278 
279 struct SLAndroidBufferQueueItf_ {
280     SLresult (*RegisterCallback) (
281         SLAndroidBufferQueueItf self,
282         slAndroidBufferQueueCallback callback,
283         void* pCallbackContext
284     );
285 
286     SLresult (*Clear) (
287         SLAndroidBufferQueueItf self
288     );
289 
290     SLresult (*Enqueue) (
291         SLAndroidBufferQueueItf self,
292         void *pBufferContext,
293         void *pData,
294         SLuint32 dataLength,
295         const SLAndroidBufferItem *pItems,
296         SLuint32 itemsLength
297     );
298 
299     SLresult (*GetState) (
300         SLAndroidBufferQueueItf self,
301         SLAndroidBufferQueueState *pState
302     );
303 
304     SLresult (*SetCallbackEventsMask) (
305             SLAndroidBufferQueueItf self,
306             SLuint32 eventFlags
307     );
308 
309     SLresult (*GetCallbackEventsMask) (
310             SLAndroidBufferQueueItf self,
311             SLuint32 *pEventFlags
312     );
313 };
314 
315 
316 /*---------------------------------------------------------------------------*/
317 /* Android File Descriptor Data Locator                                      */
318 /*---------------------------------------------------------------------------*/
319 
320 /** Addendum to Data locator macros  */
321 #define SL_DATALOCATOR_ANDROIDFD                ((SLuint32) 0x800007BC)
322 
323 #define SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((SLAint64) 0xFFFFFFFFFFFFFFFFll)
324 
325 /** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */
326 typedef struct SLDataLocator_AndroidFD_ {
327     SLuint32        locatorType;
328     SLint32         fd;
329     SLAint64        offset;
330     SLAint64        length;
331 } SLDataLocator_AndroidFD;
332 
333 
334 /*---------------------------------------------------------------------------*/
335 /* Android Android Simple Buffer Queue Data Locator                          */
336 /*---------------------------------------------------------------------------*/
337 
338 /** Addendum to Data locator macros  */
339 #define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD)
340 
341 /** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE*/
342 typedef struct SLDataLocator_AndroidSimpleBufferQueue {
343 	SLuint32	locatorType;
344 	SLuint32	numBuffers;
345 } SLDataLocator_AndroidSimpleBufferQueue;
346 
347 
348 /*---------------------------------------------------------------------------*/
349 /* Android Buffer Queue Data Locator                                         */
350 /*---------------------------------------------------------------------------*/
351 
352 /** Addendum to Data locator macros  */
353 #define SL_DATALOCATOR_ANDROIDBUFFERQUEUE       ((SLuint32) 0x800007BE)
354 
355 /** Android Buffer Queue-based data locator definition,
356  *  locatorType must be SL_DATALOCATOR_ANDROIDBUFFERQUEUE */
357 typedef struct SLDataLocator_AndroidBufferQueue_ {
358     SLuint32    locatorType;
359     SLuint32    numBuffers;
360 } SLDataLocator_AndroidBufferQueue;
361 
362 /**
363  * MIME types required for data in Android Buffer Queues
364  */
365 #define SL_ANDROID_MIME_AACADTS            ((SLchar *) "audio/vnd.android.aac-adts")
366 
367 /*---------------------------------------------------------------------------*/
368 /* Acoustic Echo Cancellation (AEC) Interface                                */
369 /* --------------------------------------------------------------------------*/
370 extern SL_API const SLInterfaceID SL_IID_ANDROIDACOUSTICECHOCANCELLATION;
371 
372 struct SLAndroidAcousticEchoCancellationItf_;
373 typedef const struct SLAndroidAcousticEchoCancellationItf_ * const *
374         SLAndroidAcousticEchoCancellationItf;
375 
376 struct SLAndroidAcousticEchoCancellationItf_ {
377     SLresult (*SetEnabled)(
378         SLAndroidAcousticEchoCancellationItf self,
379         SLboolean enabled
380     );
381     SLresult (*IsEnabled)(
382         SLAndroidAcousticEchoCancellationItf self,
383         SLboolean *pEnabled
384     );
385     SLresult (*IsAvailable)(
386         SLAndroidAcousticEchoCancellationItf self,
387         SLboolean *pEnabled
388     );
389 };
390 
391 /*---------------------------------------------------------------------------*/
392 /* Automatic Gain Control (ACC) Interface                                    */
393 /* --------------------------------------------------------------------------*/
394 extern SL_API const SLInterfaceID SL_IID_ANDROIDAUTOMATICGAINCONTROL;
395 
396 struct SLAndroidAutomaticGainControlItf_;
397 typedef const struct SLAndroidAutomaticGainControlItf_ * const * SLAndroidAutomaticGainControlItf;
398 
399 struct SLAndroidAutomaticGainControlItf_ {
400     SLresult (*SetEnabled)(
401         SLAndroidAutomaticGainControlItf self,
402         SLboolean enabled
403     );
404     SLresult (*IsEnabled)(
405         SLAndroidAutomaticGainControlItf self,
406         SLboolean *pEnabled
407     );
408     SLresult (*IsAvailable)(
409         SLAndroidAutomaticGainControlItf self,
410         SLboolean *pEnabled
411     );
412 };
413 
414 /*---------------------------------------------------------------------------*/
415 /* Noise Suppression Interface                                               */
416 /* --------------------------------------------------------------------------*/
417 extern SL_API const SLInterfaceID SL_IID_ANDROIDNOISESUPPRESSION;
418 
419 struct SLAndroidNoiseSuppressionItf_;
420 typedef const struct SLAndroidNoiseSuppressionItf_ * const * SLAndroidNoiseSuppressionItf;
421 
422 struct SLAndroidNoiseSuppressionItf_ {
423     SLresult (*SetEnabled)(
424         SLAndroidNoiseSuppressionItf self,
425         SLboolean enabled
426     );
427     SLresult (*IsEnabled)(
428         SLAndroidNoiseSuppressionItf self,
429         SLboolean *pEnabled
430     );
431     SLresult (*IsAvailable)(
432         SLAndroidNoiseSuppressionItf self,
433         SLboolean *pEnabled
434     );
435 };
436 
437 #ifdef __cplusplus
438 }
439 #endif /* __cplusplus */
440 
441 #endif /* OPENSL_ES_ANDROID_H_ */
442