OpenSLES_Android.h revision 43bde29538bf33d444d41a0b9cc0d60793fb20fa
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 PCM Data Format */ 37/*---------------------------------------------------------------------------*/ 38#define SL_ANDROID_PCMSAMPLEFORMAT ((SLuint16) 0x8000) 39#define SL_ANDROID_PCMSAMPLEFORMAT_FLT ((SLuint16) 0x4000) 40#define SL_ANDROID_PCMSAMPLEFORMAT_24_PACKED (SL_ANDROID_PCMSAMPLEFORMAT | ((SLuint16) 0x0018)) 41#define SL_ANDROID_PCMSAMPLEFORMAT_FLOAT (SL_ANDROID_PCMSAMPLEFORMAT | \ 42 SL_ANDROID_PCMSAMPLEFORMAT_FLT | ((SLuint16) 0x0020)) 43 44/*---------------------------------------------------------------------------*/ 45/* Android Effect interface */ 46/*---------------------------------------------------------------------------*/ 47 48extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECT; 49 50/** Android Effect interface methods */ 51 52struct SLAndroidEffectItf_; 53typedef const struct SLAndroidEffectItf_ * const * SLAndroidEffectItf; 54 55struct SLAndroidEffectItf_ { 56 57 SLresult (*CreateEffect) (SLAndroidEffectItf self, 58 SLInterfaceID effectImplementationId); 59 60 SLresult (*ReleaseEffect) (SLAndroidEffectItf self, 61 SLInterfaceID effectImplementationId); 62 63 SLresult (*SetEnabled) (SLAndroidEffectItf self, 64 SLInterfaceID effectImplementationId, 65 SLboolean enabled); 66 67 SLresult (*IsEnabled) (SLAndroidEffectItf self, 68 SLInterfaceID effectImplementationId, 69 SLboolean *pEnabled); 70 71 SLresult (*SendCommand) (SLAndroidEffectItf self, 72 SLInterfaceID effectImplementationId, 73 SLuint32 command, 74 SLuint32 commandSize, 75 void *pCommandData, 76 SLuint32 *replySize, 77 void *pReplyData); 78}; 79 80 81/*---------------------------------------------------------------------------*/ 82/* Android Effect Send interface */ 83/*---------------------------------------------------------------------------*/ 84 85extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTSEND; 86 87/** Android Effect Send interface methods */ 88 89struct SLAndroidEffectSendItf_; 90typedef const struct SLAndroidEffectSendItf_ * const * SLAndroidEffectSendItf; 91 92struct SLAndroidEffectSendItf_ { 93 SLresult (*EnableEffectSend) ( 94 SLAndroidEffectSendItf self, 95 SLInterfaceID effectImplementationId, 96 SLboolean enable, 97 SLmillibel initialLevel 98 ); 99 SLresult (*IsEnabled) ( 100 SLAndroidEffectSendItf self, 101 SLInterfaceID effectImplementationId, 102 SLboolean *pEnable 103 ); 104 SLresult (*SetDirectLevel) ( 105 SLAndroidEffectSendItf self, 106 SLmillibel directLevel 107 ); 108 SLresult (*GetDirectLevel) ( 109 SLAndroidEffectSendItf self, 110 SLmillibel *pDirectLevel 111 ); 112 SLresult (*SetSendLevel) ( 113 SLAndroidEffectSendItf self, 114 SLInterfaceID effectImplementationId, 115 SLmillibel sendLevel 116 ); 117 SLresult (*GetSendLevel)( 118 SLAndroidEffectSendItf self, 119 SLInterfaceID effectImplementationId, 120 SLmillibel *pSendLevel 121 ); 122}; 123 124 125/*---------------------------------------------------------------------------*/ 126/* Android Effect Capabilities interface */ 127/*---------------------------------------------------------------------------*/ 128 129extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTCAPABILITIES; 130 131/** Android Effect Capabilities interface methods */ 132 133struct SLAndroidEffectCapabilitiesItf_; 134typedef const struct SLAndroidEffectCapabilitiesItf_ * const * SLAndroidEffectCapabilitiesItf; 135 136struct SLAndroidEffectCapabilitiesItf_ { 137 138 SLresult (*QueryNumEffects) (SLAndroidEffectCapabilitiesItf self, 139 SLuint32 *pNumSupportedEffects); 140 141 142 SLresult (*QueryEffect) (SLAndroidEffectCapabilitiesItf self, 143 SLuint32 index, 144 SLInterfaceID *pEffectType, 145 SLInterfaceID *pEffectImplementation, 146 SLchar *pName, 147 SLuint16 *pNameSize); 148}; 149 150 151/*---------------------------------------------------------------------------*/ 152/* Android Configuration interface */ 153/*---------------------------------------------------------------------------*/ 154extern SL_API const SLInterfaceID SL_IID_ANDROIDCONFIGURATION; 155 156/** Android Configuration interface methods */ 157 158struct SLAndroidConfigurationItf_; 159typedef const struct SLAndroidConfigurationItf_ * const * SLAndroidConfigurationItf; 160 161struct SLAndroidConfigurationItf_ { 162 163 SLresult (*SetConfiguration) (SLAndroidConfigurationItf self, 164 const SLchar *configKey, 165 const void *pConfigValue, 166 SLuint32 valueSize); 167 168 SLresult (*GetConfiguration) (SLAndroidConfigurationItf self, 169 const SLchar *configKey, 170 SLuint32 *pValueSize, 171 void *pConfigValue 172 ); 173}; 174 175 176/*---------------------------------------------------------------------------*/ 177/* Android Simple Buffer Queue Interface */ 178/*---------------------------------------------------------------------------*/ 179 180extern SL_API const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE; 181 182struct SLAndroidSimpleBufferQueueItf_; 183typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf; 184 185typedef void (SLAPIENTRY *slAndroidSimpleBufferQueueCallback)( 186 SLAndroidSimpleBufferQueueItf caller, 187 void *pContext 188); 189 190/** Android simple buffer queue state **/ 191 192typedef struct SLAndroidSimpleBufferQueueState_ { 193 SLuint32 count; 194 SLuint32 index; 195} SLAndroidSimpleBufferQueueState; 196 197 198struct SLAndroidSimpleBufferQueueItf_ { 199 SLresult (*Enqueue) ( 200 SLAndroidSimpleBufferQueueItf self, 201 const void *pBuffer, 202 SLuint32 size 203 ); 204 SLresult (*Clear) ( 205 SLAndroidSimpleBufferQueueItf self 206 ); 207 SLresult (*GetState) ( 208 SLAndroidSimpleBufferQueueItf self, 209 SLAndroidSimpleBufferQueueState *pState 210 ); 211 SLresult (*RegisterCallback) ( 212 SLAndroidSimpleBufferQueueItf self, 213 slAndroidSimpleBufferQueueCallback callback, 214 void* pContext 215 ); 216}; 217 218 219/*---------------------------------------------------------------------------*/ 220/* Android Buffer Queue Interface */ 221/*---------------------------------------------------------------------------*/ 222 223extern SL_API const SLInterfaceID SL_IID_ANDROIDBUFFERQUEUESOURCE; 224 225struct SLAndroidBufferQueueItf_; 226typedef const struct SLAndroidBufferQueueItf_ * const * SLAndroidBufferQueueItf; 227 228#define SL_ANDROID_ITEMKEY_NONE ((SLuint32) 0x00000000) 229#define SL_ANDROID_ITEMKEY_EOS ((SLuint32) 0x00000001) 230#define SL_ANDROID_ITEMKEY_DISCONTINUITY ((SLuint32) 0x00000002) 231#define SL_ANDROID_ITEMKEY_BUFFERQUEUEEVENT ((SLuint32) 0x00000003) 232#define SL_ANDROID_ITEMKEY_FORMAT_CHANGE ((SLuint32) 0x00000004) 233 234#define SL_ANDROIDBUFFERQUEUEEVENT_NONE ((SLuint32) 0x00000000) 235#define SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED ((SLuint32) 0x00000001) 236#if 0 // reserved for future use 237#define SL_ANDROIDBUFFERQUEUEEVENT_UNREALIZED ((SLuint32) 0x00000002) 238#define SL_ANDROIDBUFFERQUEUEEVENT_CLEARED ((SLuint32) 0x00000004) 239#define SL_ANDROIDBUFFERQUEUEEVENT_STOPPED ((SLuint32) 0x00000008) 240#define SL_ANDROIDBUFFERQUEUEEVENT_ERROR ((SLuint32) 0x00000010) 241#define SL_ANDROIDBUFFERQUEUEEVENT_CONTENT_END ((SLuint32) 0x00000020) 242#endif 243 244typedef struct SLAndroidBufferItem_ { 245 SLuint32 itemKey; // identifies the item 246 SLuint32 itemSize; 247 SLuint8 itemData[0]; 248} SLAndroidBufferItem; 249 250typedef SLresult (SLAPIENTRY *slAndroidBufferQueueCallback)( 251 SLAndroidBufferQueueItf caller,/* input */ 252 void *pCallbackContext, /* input */ 253 void *pBufferContext, /* input */ 254 void *pBufferData, /* input */ 255 SLuint32 dataSize, /* input */ 256 SLuint32 dataUsed, /* input */ 257 const SLAndroidBufferItem *pItems,/* input */ 258 SLuint32 itemsLength /* input */ 259); 260 261typedef struct SLAndroidBufferQueueState_ { 262 SLuint32 count; 263 SLuint32 index; 264} SLAndroidBufferQueueState; 265 266struct SLAndroidBufferQueueItf_ { 267 SLresult (*RegisterCallback) ( 268 SLAndroidBufferQueueItf self, 269 slAndroidBufferQueueCallback callback, 270 void* pCallbackContext 271 ); 272 273 SLresult (*Clear) ( 274 SLAndroidBufferQueueItf self 275 ); 276 277 SLresult (*Enqueue) ( 278 SLAndroidBufferQueueItf self, 279 void *pBufferContext, 280 void *pData, 281 SLuint32 dataLength, 282 const SLAndroidBufferItem *pItems, 283 SLuint32 itemsLength 284 ); 285 286 SLresult (*GetState) ( 287 SLAndroidBufferQueueItf self, 288 SLAndroidBufferQueueState *pState 289 ); 290 291 SLresult (*SetCallbackEventsMask) ( 292 SLAndroidBufferQueueItf self, 293 SLuint32 eventFlags 294 ); 295 296 SLresult (*GetCallbackEventsMask) ( 297 SLAndroidBufferQueueItf self, 298 SLuint32 *pEventFlags 299 ); 300}; 301 302 303/*---------------------------------------------------------------------------*/ 304/* Android File Descriptor Data Locator */ 305/*---------------------------------------------------------------------------*/ 306 307/** Addendum to Data locator macros */ 308#define SL_DATALOCATOR_ANDROIDFD ((SLuint32) 0x800007BC) 309 310#define SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((SLAint64) 0xFFFFFFFFFFFFFFFFll) 311 312/** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */ 313typedef struct SLDataLocator_AndroidFD_ { 314 SLuint32 locatorType; 315 SLint32 fd; 316 SLAint64 offset; 317 SLAint64 length; 318} SLDataLocator_AndroidFD; 319 320 321/*---------------------------------------------------------------------------*/ 322/* Android Android Simple Buffer Queue Data Locator */ 323/*---------------------------------------------------------------------------*/ 324 325/** Addendum to Data locator macros */ 326#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD) 327 328/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE*/ 329typedef struct SLDataLocator_AndroidSimpleBufferQueue { 330 SLuint32 locatorType; 331 SLuint32 numBuffers; 332} SLDataLocator_AndroidSimpleBufferQueue; 333 334 335/*---------------------------------------------------------------------------*/ 336/* Android Buffer Queue Data Locator */ 337/*---------------------------------------------------------------------------*/ 338 339/** Addendum to Data locator macros */ 340#define SL_DATALOCATOR_ANDROIDBUFFERQUEUE ((SLuint32) 0x800007BE) 341 342/** Android Buffer Queue-based data locator definition, 343 * locatorType must be SL_DATALOCATOR_ANDROIDBUFFERQUEUE */ 344typedef struct SLDataLocator_AndroidBufferQueue_ { 345 SLuint32 locatorType; 346 SLuint32 numBuffers; 347} SLDataLocator_AndroidBufferQueue; 348 349/** 350 * MIME types required for data in Android Buffer Queues 351 */ 352#define SL_ANDROID_MIME_AACADTS ((SLchar *) "audio/vnd.android.aac-adts") 353 354/*---------------------------------------------------------------------------*/ 355/* Acoustic Echo Cancellation (AEC) Interface */ 356/* --------------------------------------------------------------------------*/ 357extern SL_API const SLInterfaceID SL_IID_ANDROIDACOUSTICECHOCANCELLATION; 358 359struct SLAndroidAcousticEchoCancellationItf_; 360typedef const struct SLAndroidAcousticEchoCancellationItf_ * const * 361 SLAndroidAcousticEchoCancellationItf; 362 363struct SLAndroidAcousticEchoCancellationItf_ { 364 SLresult (*SetEnabled)( 365 SLAndroidAcousticEchoCancellationItf self, 366 SLboolean enabled 367 ); 368 SLresult (*IsEnabled)( 369 SLAndroidAcousticEchoCancellationItf self, 370 SLboolean *pEnabled 371 ); 372 SLresult (*IsAvailable)( 373 SLAndroidAcousticEchoCancellationItf self, 374 SLboolean *pEnabled 375 ); 376}; 377 378/*---------------------------------------------------------------------------*/ 379/* Automatic Gain Control (ACC) Interface */ 380/* --------------------------------------------------------------------------*/ 381extern SL_API const SLInterfaceID SL_IID_ANDROIDAUTOMATICGAINCONTROL; 382 383struct SLAndroidAutomaticGainControlItf_; 384typedef const struct SLAndroidAutomaticGainControlItf_ * const * SLAndroidAutomaticGainControlItf; 385 386struct SLAndroidAutomaticGainControlItf_ { 387 SLresult (*SetEnabled)( 388 SLAndroidAutomaticGainControlItf self, 389 SLboolean enabled 390 ); 391 SLresult (*IsEnabled)( 392 SLAndroidAutomaticGainControlItf self, 393 SLboolean *pEnabled 394 ); 395 SLresult (*IsAvailable)( 396 SLAndroidAutomaticGainControlItf self, 397 SLboolean *pEnabled 398 ); 399}; 400 401/*---------------------------------------------------------------------------*/ 402/* Noise Suppression Interface */ 403/* --------------------------------------------------------------------------*/ 404extern SL_API const SLInterfaceID SL_IID_ANDROIDNOISESUPPRESSION; 405 406struct SLAndroidNoiseSuppressionItf_; 407typedef const struct SLAndroidNoiseSuppressionItf_ * const * SLAndroidNoiseSuppressionItf; 408 409struct SLAndroidNoiseSuppressionItf_ { 410 SLresult (*SetEnabled)( 411 SLAndroidNoiseSuppressionItf self, 412 SLboolean enabled 413 ); 414 SLresult (*IsEnabled)( 415 SLAndroidNoiseSuppressionItf self, 416 SLboolean *pEnabled 417 ); 418 SLresult (*IsAvailable)( 419 SLAndroidNoiseSuppressionItf self, 420 SLboolean *pEnabled 421 ); 422}; 423 424#ifdef __cplusplus 425} 426#endif /* __cplusplus */ 427 428#endif /* OPENSL_ES_ANDROID_H_ */ 429