OpenSLES_Android.h revision ad887a253969ac2017a1dbe062d0b76d505594c0
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#ifdef __cplusplus
21extern "C" {
22#endif
23
24/*---------------------------------------------------------------------------*/
25/* Android common types                                                      */
26/*---------------------------------------------------------------------------*/
27
28typedef sl_int64_t             SLAint64;           /* 64 bit signed integer */
29
30typedef SLuint32               SLAstreamEvent;
31
32
33/*---------------------------------------------------------------------------*/
34/* Android Effect interface                                                  */
35/*---------------------------------------------------------------------------*/
36
37extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDEFFECT;
38
39/** Android Effect interface methods */
40
41struct SLAndroidEffectItf_;
42typedef const struct SLAndroidEffectItf_ * const * SLAndroidEffectItf;
43
44struct SLAndroidEffectItf_ {
45
46    SLresult (*CreateEffect) (SLAndroidEffectItf self,
47            SLInterfaceID effectImplementationId);
48
49    SLresult (*ReleaseEffect) (SLAndroidEffectItf self,
50            SLInterfaceID effectImplementationId);
51
52    SLresult (*SetEnabled) (SLAndroidEffectItf self,
53            SLInterfaceID effectImplementationId,
54            SLboolean enabled);
55
56    SLresult (*IsEnabled) (SLAndroidEffectItf self,
57            SLInterfaceID effectImplementationId,
58            SLboolean *pEnabled);
59
60    SLresult (*SendCommand) (SLAndroidEffectItf self,
61            SLInterfaceID effectImplementationId,
62            SLuint32 command,
63            SLuint32 commandSize,
64            void *pCommandData,
65            SLuint32 *replySize,
66            void *pReplyData);
67};
68
69
70/*---------------------------------------------------------------------------*/
71/* Android Effect Send interface                                             */
72/*---------------------------------------------------------------------------*/
73
74extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDEFFECTSEND;
75
76/** Android Effect Send interface methods */
77
78struct SLAndroidEffectSendItf_;
79typedef const struct SLAndroidEffectSendItf_ * const * SLAndroidEffectSendItf;
80
81struct SLAndroidEffectSendItf_ {
82    SLresult (*EnableEffectSend) (
83        SLAndroidEffectSendItf self,
84        SLInterfaceID effectImplementationId,
85        SLboolean enable,
86        SLmillibel initialLevel
87    );
88    SLresult (*IsEnabled) (
89        SLAndroidEffectSendItf self,
90        SLInterfaceID effectImplementationId,
91        SLboolean *pEnable
92    );
93    SLresult (*SetDirectLevel) (
94        SLAndroidEffectSendItf self,
95        SLmillibel directLevel
96    );
97    SLresult (*GetDirectLevel) (
98        SLAndroidEffectSendItf self,
99        SLmillibel *pDirectLevel
100    );
101    SLresult (*SetSendLevel) (
102        SLAndroidEffectSendItf self,
103        SLInterfaceID effectImplementationId,
104        SLmillibel sendLevel
105    );
106    SLresult (*GetSendLevel)(
107        SLAndroidEffectSendItf self,
108        SLInterfaceID effectImplementationId,
109        SLmillibel *pSendLevel
110    );
111};
112
113
114/*---------------------------------------------------------------------------*/
115/* Android Effect Capabilities interface                                     */
116/*---------------------------------------------------------------------------*/
117
118extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDEFFECTCAPABILITIES;
119
120/** Android Effect Capabilities interface methods */
121
122struct SLAndroidEffectCapabilitiesItf_;
123typedef const struct SLAndroidEffectCapabilitiesItf_ * const * SLAndroidEffectCapabilitiesItf;
124
125struct SLAndroidEffectCapabilitiesItf_ {
126
127    SLresult (*QueryNumEffects) (SLAndroidEffectCapabilitiesItf self,
128            SLuint32 *pNumSupportedEffects);
129
130
131    SLresult (*QueryEffect) (SLAndroidEffectCapabilitiesItf self,
132            SLuint32 index,
133            SLInterfaceID *pEffectType,
134            SLInterfaceID *pEffectImplementation,
135            SLchar *pName,
136            SLuint16 *pNameSize);
137};
138
139
140/*---------------------------------------------------------------------------*/
141/* Android Configuration interface                                           */
142/*---------------------------------------------------------------------------*/
143extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDCONFIGURATION;
144
145/** Android Configuration interface methods */
146
147struct SLAndroidConfigurationItf_;
148typedef const struct SLAndroidConfigurationItf_ * const * SLAndroidConfigurationItf;
149
150struct SLAndroidConfigurationItf_ {
151
152    SLresult (*SetConfiguration) (SLAndroidConfigurationItf self,
153            const SLchar *configKey,
154            const void *pConfigValue,
155            SLuint32 valueSize);
156
157    SLresult (*GetConfiguration) (SLAndroidConfigurationItf self,
158           const SLchar *configKey,
159           SLuint32 *pValueSize,
160           void *pConfigValue
161       );
162};
163
164
165/*---------------------------------------------------------------------------*/
166/* Android Simple Buffer Queue Interface                                     */
167/*---------------------------------------------------------------------------*/
168
169extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
170
171struct SLAndroidSimpleBufferQueueItf_;
172typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf;
173
174typedef void (/*SLAPIENTRY*/ *slAndroidSimpleBufferQueueCallback)(
175	SLAndroidSimpleBufferQueueItf caller,
176	void *pContext
177);
178
179/** Android simple buffer queue state **/
180
181typedef struct SLAndroidSimpleBufferQueueState_ {
182	SLuint32	count;
183	SLuint32	index;
184} SLAndroidSimpleBufferQueueState;
185
186
187struct SLAndroidSimpleBufferQueueItf_ {
188	SLresult (*Enqueue) (
189		SLAndroidSimpleBufferQueueItf self,
190		const void *pBuffer,
191		SLuint32 size
192	);
193	SLresult (*Clear) (
194		SLAndroidSimpleBufferQueueItf self
195	);
196	SLresult (*GetState) (
197		SLAndroidSimpleBufferQueueItf self,
198		SLAndroidSimpleBufferQueueState *pState
199	);
200	SLresult (*RegisterCallback) (
201		SLAndroidSimpleBufferQueueItf self,
202		slAndroidSimpleBufferQueueCallback callback,
203		void* pContext
204	);
205};
206
207
208/*---------------------------------------------------------------------------*/
209/* Android Stream Source Interface                                           */
210/*---------------------------------------------------------------------------*/
211
212extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDSTREAMSOURCE;
213
214struct SLAndroidStreamSourceItf_;
215typedef const struct SLAndroidStreamSourceItf_ * const * SLAndroidStreamSourceItf;
216
217#define SL_ANDROID_STREAMEVENT_NONE              ((SLuint32) 0x00000000)
218#define SL_ANDROID_STREAMEVENT_FLUSH             ((SLuint32) 0x00000001)
219
220typedef SLresult (/*SLAPIENTRY*/ *slAndroidStreamSourceCallback)(
221    SLAndroidStreamSourceItf caller,/* input */
222    void *pContext,                 /* input */
223    SLAint64 offset,                /* input */
224    SLAint64* pLength,              /* input, output */
225    SLAstreamEvent* pEvent,         /* output */
226    void *pData                     /* output */
227);
228
229struct SLAndroidStreamSourceItf_ {
230    SLresult (*RegisterCallback) (
231        SLAndroidStreamSourceItf self,
232        slAndroidStreamSourceCallback callback,
233        void* pContext
234    );
235};
236
237
238/*---------------------------------------------------------------------------*/
239/* Android File Descriptor Data Locator                                      */
240/*---------------------------------------------------------------------------*/
241
242/** Addendum to Data locator macros  */
243#define SL_DATALOCATOR_ANDROIDFD                ((SLuint32) 0x800007BC)
244
245#define SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((SLAint64) 0xFFFFFFFFFFFFFFFFll)
246
247/** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */
248typedef struct SLDataLocator_AndroidFD_ {
249    SLuint32        locatorType;
250    SLint32         fd;
251    SLAint64        offset;
252    SLAint64        length;
253} SLDataLocator_AndroidFD;
254
255
256/*---------------------------------------------------------------------------*/
257/* Android Android Simple Buffer Queue Data Locator                          */
258/*---------------------------------------------------------------------------*/
259
260/** Addendum to Data locator macros  */
261#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD)
262
263/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE*/
264typedef struct SLDataLocator_AndroidSimpleBufferQueue {
265	SLuint32	locatorType;
266	SLuint32	numBuffers;
267} SLDataLocator_AndroidSimpleBufferQueue;
268
269
270/*---------------------------------------------------------------------------*/
271/* Android Streamer Data Locator                                             */
272/*---------------------------------------------------------------------------*/
273
274/** Addendum to Data locator macros  */
275#define SL_DATALOCATOR_ANDROIDSTREAMER          ((SLuint32) 0x800007BE)
276
277#define SL_ANDROID_STREAMORIGIN_INVALID         ((SLuint32) 0x00000000)
278#define SL_ANDROID_STREAMORIGIN_FILE            ((SLuint32) 0x00000001)
279#define SL_ANDROID_STREAMORIGIN_TRANSPORTSTREAM ((SLuint32) 0x00000002)
280
281/** Streamer-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDSTREAMER */
282typedef struct SLDataLocator_AndroidStreamer_ {
283    SLuint32        locatorType;
284    SLchar *        URI;// FIXME temporary use of a URI field for testing
285    SLuint32        streamOrigin;
286    void*           pStreamer;
287} SLDataLocator_AndroidStreamer;
288
289#ifdef __cplusplus
290}
291#endif /* __cplusplus */
292
293#endif /* OPENSL_ES_ANDROID_H_ */
294