[工作记录] Android OpenSL ES: references & AAC related

AAC V.S. MP3

http://en.wikipedia.org/wiki/Advanced_Audio_Coding#AAC.27s_improvements_over_MP3

AAC patent lisense FAQ:

http://www.vialicensing.com/licensing/aac-faq.aspx

you may need a license but usually no fees, exept that when end user products are(/contain?) encoders/decoders.

Overview:

$(NDK_ROOT)/docs/opensles/index.html

Decode audio to PCM

Note: this feature is available at API level 14 and higher.

A standard audio player plays back to an audio device, and the data sink is specified as an output mix. However, as an Android extension, an audio player instead acts as a decoder if the data source is specified as a URI or Android file descriptor data locator with MIME data format, and the data sink is an Android simple buffer queue data locator with PCM data format.

This feature is primarily intended for games to pre-load their audio assets when changing to a new game level, similar to android.media.SoundPool.

The application should initially enqueue a set of empty buffers to the Android simple buffer queue, which will be filled with PCM data. The Android simple buffer queue callback is invoked after each buffer is filled. The callback handler should process the PCM data, re-enqueue the now-empty buffer, and then return. The application is responsible for keeping track of decoded buffers; the callback parameter list does not include sufficient information to indicate which buffer was filled or which buffer to enqueue next.

The end of stream is determined implicitly by the data source. At the end of stream a SL_PLAYEVENT_HEADATEND event is delivered. The Android simple buffer queue callback will no longer be called after all consumed data is decoded.

The sink‘s PCM data format typically matches that of the encoded data source with respect to sample rate, channel count, and bit depth. However, the platform implementation is permitted to decode to a different sample rate, channel count, or bit depth. There is a provision to detect the actual PCM format; see section "Determining the format of decoded PCM data via metadata" below.

Decode to PCM supports pause and initial seek. Volume control, effects, looping, and playback rate are not supported.

Depending on the platform implementation, decoding may require resources that cannot be left idle. Therefore it is not recommended to starve the decoder by failing to provide a sufficient number of empty PCM buffers, e.g. by returning from the Android simple buffer queue callback without enqueueing another empty buffer. The result of decoder starvation is unspecified; the implementation may choose to either drop the decoded PCM data, pause the decoding process, or in severe cases terminate the decoder.

API docs:

$(NDK_ROOT)/docs/opensles/OpenSL_ES_Specification_1.0.1.pdf

Samples:

$(NDK_ROOT)/samples/NativeAudio

ADTS header (http://wiki.multimedia.cx/index.php?title=ADTS):

Letter Length (bits) Description
A 12 syncword 0xFFF, all bits must be 1
B 1 MPEG Version: 0 for MPEG-4, 1 for MPEG-2
C 2 Layer: always 0
D 1 protection absent, Warning, set to 1 if there is no CRC and 0 if there is CRC
E 2 profile, the MPEG-4 Audio Object Type minus 1
F 4 MPEG-4 Sampling Frequency Index (15 is forbidden)
G 1 private stream, set to 0 when encoding, ignore when decoding
H 3 MPEG-4 Channel Configuration (in the case of 0, the channel configuration is sent via an inband PCE)
I 1 originality, set to 0 when encoding, ignore when decoding
J 1 home, set to 0 when encoding, ignore when decoding
K 1 copyrighted stream, set to 0 when encoding, ignore when decoding
L 1 copyright start, set to 0 when encoding, ignore when decoding
M 13 frame length, this value must include 7 or 9 bytes of header length: FrameLength = (ProtectionAbsent == 1 ? 7 : 9) + size(AACFrame)
O 11 Buffer fullness
P 2 Number of AAC frames (RDBs) in ADTS frame minus 1, for maximum compatibility always use 1 AAC frame per ADTS frame
Q 16 CRC if protection absent is 0 

AAC decoding test sample (decoding only):

https://android.googlesource.com/platform/frameworks/wilhelm/+/master/tests/examples/slesTestDecodeAac.cpp

AAC encoding (offline):

https://trac.ffmpeg.org/wiki/Encode/AAC

AAC profile suitable for streaming:

HE-AACv1(AAC+) / HE-AACv2( enhanced-AAC+)

http://en.wikipedia.org/wiki/High_Efficiency_Advanced_Audio_Coding

[工作记录] Android OpenSL ES: references & AAC related,布布扣,bubuko.com

时间: 2024-12-26 21:07:35

[工作记录] Android OpenSL ES: references & AAC related的相关文章

[工作记录] Android OpenGL ES: non-square texture - continue

previous: [工作记录] Android OpenGL ES 2.0: square texture not supported on some device recently I found that it is the mipmap of a non-square texture that cause the black texture problem: http://stackoverflow.com/questions/5052762/using-mipmaps-results-

[工作记录] Android OpenGL ES 2.0: square texture not supported on some device

npot texture: non-power-of-two texture.rectangle texture: non-square (height != wdith) 在测试Samsumg Galaxy S4的时候, 发现rectangle texture支持不好, 虽然创建成功, 但是绘制有问题. 不同的模块出现类似的情况: 纹理采样出的颜色是(0,0,0,1). 在排除了所有可能的runtime问题以后, 尝试性改了纹理格式无果, 又尝试性的改了下尺寸, 竟然好了. 我擦... 而Ga

Android音频开发(6):使用 OpenSL ES API(上)

前面几篇文章介绍了如何在 Java 层,利用 Android 提供的 AudioRecord 采集音频,利用 AudioTrack 播放音频,利用 MediaCodec 来编解码,这些 API 均是 Android 提供的 Java 层 API,无论是采集.播放还是编解码,这些 API 接口都需要将音频数据从 Java 拷贝到 native 层,或者从 native 层拷贝到 Java,如果希望减少拷贝,开发更加高效的 Android 音频应用,则建议使用 Android NDK 提供的 Ope

Android音频开发(7):使用 OpenSL ES API(下)

本文是我的<Android音频开发>系列的第七篇文章,上一篇文章总整体上介绍了 Android OpenSL ES API 的基本概况,告诉了大家这个框架有什么特性,可以做什么,不能做什么.本文则重点介绍 OpenSL ES 框架及其API接口的一些关键的设计和概念,只有理解了它们,你才能更好地读懂 OpenSL ES 的相关代码.示例代码则放到了文章的最后,相信大家理解了这些基本的概念后,就能很容易地读懂这些代码的细节了. 1. 面向对象的 C 语言接口 OpenSL ES 虽然是 C 语言

工作记录[续] android OBB

前两篇在这里: Android上使用native IO 最近工作中的问题笔记 最近遇到的问题是, java.io.IOException: FAT Full StackOverflow的结果: http://stackoverflow.com/questions/18906055/what-causes-jobb-tool-to-throw-fat-full-ioexception 提问者自己解释了原因, 原因是obb超过512M就出错了. 但是FAT16最大可以支持2G, 这个是jobb的bu

Android音视频学习第7章:使用OpenSL ES进行音频解码

/* * *这里使用了transcode-1.1.7对wav文件进行解码,然后使用opensl es进行播放 * */ //用到的变量和结构体 WAV wav; //wav文件指针 SLObjectItf engineObject; //引擎对象 SLEngineItf engineInterface; //引擎接口 SLObjectItf outputMixObject; //混音器 SLObjectItf audioPlayerObject; //播放器对象 SLAndroidSimpleB

【工作记录】android手势事件操作记录

/* 用户按下触摸屏.快速移动后松开 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { //参数解释: // e1:第1个ACTION_DOWN MotionEvent // e2:最后一个ACTION_MOVE MotionEvent // velocityX:X轴上的移动速度,像素/秒 // velocityY:Y轴上的移动速度,像素/秒 // 触发条件 : /

Android 音视频深入 十三 OpenSL ES 制作音乐播放器,能暂停和调整音量(附源码下载)

项目地址https://github.com/979451341/OpenSLAudio OpenSL ES 是基于NDK也就是c语言的底层开发音频的公开API,通过使用它能够做到标准化, 高性能,低响应时间的音频功能实现方法. 这次是使用OpenSL ES来做一个音乐播放器,它能够播放m4a.mp3文件,并能够暂停和调整音量 播放音乐需要做一些步骤1.创建声音引擎 首先创建声音引擎的对象接口 result = slCreateEngine(&engineObject, 0, NULL, 0,

Android 音视频深入 十四 FFmpeg与OpenSL ES 播放mp3音乐,能暂停(附源码

项目地址https://github.com/979451341/FFmpegOpenslES 这次说的是FFmpeg解码mp3,数据给OpenSL ES播放,并且能够暂停.1.创建引擎 slCreateEngine(&engineObject,0,NULL,0,NULL,NULL);//创建引擎 (*engineObject)->Realize(engineObject,SL_BOOLEAN_FALSE);//实现engineObject接口对象 (*engineObject)->G