OpenSLES_Android.h revision bb74f23cd3dc877c7eaf4db2132f724d11aeeb8f
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
24extern "C" {
25#endif
26
27/*---------------------------------------------------------------------------*/
28/* Android common types                                                      */
29/*---------------------------------------------------------------------------*/
30
31typedef sl_int64_t             SLAint64;          /* 64 bit signed integer   */
32
33typedef sl_uint64_t            SLAuint64;         /* 64 bit unsigned integer */
34
35/*---------------------------------------------------------------------------*/
36/* Android composite channel masks                                           */
37/*---------------------------------------------------------------------------*/
38//#define SL_ANDROID_SPEAKER_QUAD (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT \
39// | SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT)
40
41//#define SL_ANDROID_SPEAKER_5DOT1 (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT \
42// | SL_SPEAKER_FRONT_CENTER  | SL_SPEAKER_LOW_FREQUENCY| SL_SPEAKER_BACK_LEFT \
43// | SL_SPEAKER_BACK_RIGHT)
44//
45//#define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT \
46// |SL_SPEAKER_SIDE_RIGHT)
47
48/*---------------------------------------------------------------------------*/
49/* Android PCM Data Format                                                   */
50/*---------------------------------------------------------------------------*/
51#define SL_ANDROID_PCMSAMPLEFORMAT  ((SLuint16) 0x8000)
52#define SL_ANDROID_PCMSAMPLEFORMAT_FLT  ((SLuint16) 0x4000)
53#define SL_ANDROID_PCMSAMPLEFORMAT_24_PACKED (SL_ANDROID_PCMSAMPLEFORMAT | ((SLuint16) 0x0018))
54#define SL_ANDROID_PCMSAMPLEFORMAT_FLOAT (SL_ANDROID_PCMSAMPLEFORMAT | \
55                                          SL_ANDROID_PCMSAMPLEFORMAT_FLT | ((SLuint16) 0x0020))
56
57/*---------------------------------------------------------------------------*/
58/* Android Effect interface                                                  */
59/*---------------------------------------------------------------------------*/
60
61extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECT;
62
63/** Android Effect interface methods */
64
65struct SLAndroidEffectItf_;
66typedef const struct SLAndroidEffectItf_ * const * SLAndroidEffectItf;
67
68struct 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
98extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTSEND;
99
100/** Android Effect Send interface methods */
101
102struct SLAndroidEffectSendItf_;
103typedef const struct SLAndroidEffectSendItf_ * const * SLAndroidEffectSendItf;
104
105struct 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
142extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTCAPABILITIES;
143
144/** Android Effect Capabilities interface methods */
145
146struct SLAndroidEffectCapabilitiesItf_;
147typedef const struct SLAndroidEffectCapabilitiesItf_ * const * SLAndroidEffectCapabilitiesItf;
148
149struct 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/*---------------------------------------------------------------------------*/
167extern SL_API const SLInterfaceID SL_IID_ANDROIDCONFIGURATION;
168
169/** Android Configuration interface methods */
170
171struct SLAndroidConfigurationItf_;
172typedef const struct SLAndroidConfigurationItf_ * const * SLAndroidConfigurationItf;
173
174struct 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
193extern SL_API const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
194
195struct SLAndroidSimpleBufferQueueItf_;
196typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf;
197
198typedef void (SLAPIENTRY *slAndroidSimpleBufferQueueCallback)(
199	SLAndroidSimpleBufferQueueItf caller,
200	void *pContext
201);
202
203/** Android simple buffer queue state **/
204
205typedef struct SLAndroidSimpleBufferQueueState_ {
206	SLuint32	count;
207	SLuint32	index;
208} SLAndroidSimpleBufferQueueState;
209
210
211struct 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
236extern SL_API const SLInterfaceID SL_IID_ANDROIDBUFFERQUEUESOURCE;
237
238struct SLAndroidBufferQueueItf_;
239typedef 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
257typedef struct SLAndroidBufferItem_ {
258    SLuint32 itemKey;  // identifies the item
259    SLuint32 itemSize;
260    SLuint8  itemData[0];
261} SLAndroidBufferItem;
262
263typedef 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
274typedef struct SLAndroidBufferQueueState_ {
275    SLuint32    count;
276    SLuint32    index;
277} SLAndroidBufferQueueState;
278
279struct 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 */
326typedef 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*/
342typedef 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 */
357typedef 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#ifdef __cplusplus
368}
369#endif /* __cplusplus */
370
371#endif /* OPENSL_ES_ANDROID_H_ */
372