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