Integrating an audio codec (OpenSL ES)

Hi ,

I need to make an audio codec library OpenSL ES compliant. Upon going through the specification of OpenSL ES, I have come to an understanding that it is an application layer similar to the OpenMAX AL . Could you kindly explain how i would be able to integrate the audio codec library (in the absence of an integration layer).

Simi

Hi Simi,

I am assuming that you are looking to expose an audio codec library through OpenSL ES which is currently not listed as part of the specification. You can do this by creating a vendor specific extension. If you only need to let the application know that the codec library exists, you can extend the “SL_AUDIOCODEC” macros:

#define SL_AUDIOCODEC_MYCODECNAME   ((SLuint32)  0x80000001)

Then, when your application calls Engine:SLAudioDecoderCapabilities:GetAudioDecoders() the implementation can return SL_AUDIOCODEC_MYCODECNAME in the list of supported codecs.

The application can find out if your vendor extension exists by calling Engine:SLEngineItf:IsExtensionSupported(). If you need to pass information to the codec, you can do so through the SLConfigExtensionsItf interface.

If this is not what you are trying to do, please post additional information so we can try to assist you in your issue.

Best,

Erik

Thank you Erik .

I have a few more queries.

I need to design the API’s for an audio codec such that they are compliant to OpenSL ES. Could you tell me which API’s i should be using to do functions like memory allocation for the library,input/output audio data handling for the audio codec library. Is there any sample implementation of the OpenSL ES (handling an audio codec)available? I am currently referring the OpenSL_ES_Specification_1.1 pdf. Are there any other supporting docs for the implementation of API.

Simi

Hi Simi,

When you design the APIs for your audio codec, you need to take into account the implementation which will be using it. OpenSL ES does not expose the codec API, nor does it expose the input/output audio data handling of the codec. These APIs would be dependent on the specific implementation of OpenSL ES. Because of this, it is not possible for a codec to be “OpenSL ES compliant”. Unfortunately, there is currently no sample implementation of OpenSL ES available.

You may consider looking at the OpenMAX IL 1.1 specification (OpenMAX Overview - The Khronos Group Inc). OpenMAX IL defines component interfaces for the integration layer of a media chain. From your description it sounds as if that is what you are looking to do. There is an OpenMAX IL open source project available at http://omxil.sourceforge.net/.

Best,

Erik

Hi Erik

I need to plug in the audio codec library into the OpenSL implementation of Android 2.3. So How will i do that. And is it the same procedure if what i am trying to plug in is an codec like an mp3 or a post-processing module ?

Regards
Simi

For questions specific to Android, please post to an appropriate Android-centric forum.

android-ndk is for native (C / C++) application programming, including audio:
http://groups.google.com/group/android-ndk

android-porting is for implementing Android on a hardware device, including audio codecs and post-processing:
http://groups.google.com/group/android-porting

In the case of audio effects, there was a recent post on that subject in android-porting here:
http://groups.google.com/group/android- … e624bdf3c6

Hi Simi,

For your Android specific questions, I think you are better off trying the Android forums gkasten suggested. Good luck with your codec library.

Best,

Erik

Thank you Erik and gkasten for your feedbacks.

Simi

Hi

I have a few more doubts regarding OpenSL. I hope you could provide some feedback to that.

I have integrated audio codecs via the OpenMax IL. In OpenMax implementation, we used the IL API’s OMX_FillThisBuffer() & OMX_EmptyThisBuffer() to invoke our codec API’s. In OpenSL ES,
(a) Is there any similar type of APIs available to call our codec APIs?
(b) or else Could you please tell us from which OpenSL ES API we can call the codec APIs?
© Or Do we just write our API’s as done for OpenMax IL and it can be invoked from OpenSL ES.

Thanks,
Simi

Hi Simi,

OpenMAX IL was designed for connection and control of individual components, and OpenSL ES (and OpenMAX AL - they have a common object model) were designed for ease of application access to the functionality. We did design OpenSL ES to allow it to be built on top of OpenMAX IL, but the complexity of the IL chain is not something that most application developers need. There is therefore no mapping of the calls between OpenMAX IL and OpenSL ES even though they cover the same functionality, so the answer to your question is ©. When you request OpenSL ES to play a data source, the implementation will set up the underlying media chain and invoke your codec.

If you want to submit buffers from the application to your codec through OpenSL ES for testing purposes, I suggest you take a look at section 8.14 SLBufferQueueItf and example B.1.1 Buffer Queue in the specification. If your implementation supports it, the buffer queue mechanism allows you to submit buffers from the application for processing by the underlying media engine.

Best,

Erik