diff options
author | Andreas Huber <andih@google.com> | 2009-12-01 17:26:32 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-12-01 17:26:32 -0800 |
commit | 4612a9c53c00943d9a8c2c2b95f4bdfcea17a011 (patch) | |
tree | d6ad78cc98d385b63989cfd7aac043f76126526f /cmds | |
parent | fe124cffd84be0ca57d1357c541c1e81205df40a (diff) | |
parent | ae34cf92db9c54ba72fdcac33a8ba855a2215e4e (diff) | |
download | frameworks_base-4612a9c53c00943d9a8c2c2b95f4bdfcea17a011.zip frameworks_base-4612a9c53c00943d9a8c2c2b95f4bdfcea17a011.tar.gz frameworks_base-4612a9c53c00943d9a8c2c2b95f4bdfcea17a011.tar.bz2 |
am ae34cf92: am 781ac162: Merge change I8768f2cc into eclair-mr2
Merge commit 'ae34cf92db9c54ba72fdcac33a8ba855a2215e4e'
* commit 'ae34cf92db9c54ba72fdcac33a8ba855a2215e4e':
A small sample tool to encode pcm audio data to amr, decode it again and play it. Some changes to OMXCodec to properly configure the AMR decoder(s).
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/stagefright/Android.mk | 22 | ||||
-rw-r--r-- | cmds/stagefright/SineSource.cpp | 1 | ||||
-rw-r--r-- | cmds/stagefright/audioloop.cpp | 81 |
3 files changed, 104 insertions, 0 deletions
diff --git a/cmds/stagefright/Android.mk b/cmds/stagefright/Android.mk index 5b55252..100af89 100644 --- a/cmds/stagefright/Android.mk +++ b/cmds/stagefright/Android.mk @@ -43,4 +43,26 @@ LOCAL_MODULE:= record include $(BUILD_EXECUTABLE) +################################################################################ + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + SineSource.cpp \ + audioloop.cpp + +LOCAL_SHARED_LIBRARIES := \ + libstagefright + +LOCAL_C_INCLUDES:= \ + $(JNI_H_INCLUDE) \ + frameworks/base/media/libstagefright \ + $(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include + +LOCAL_CFLAGS += -Wno-multichar + +LOCAL_MODULE:= audioloop + +include $(BUILD_EXECUTABLE) + endif diff --git a/cmds/stagefright/SineSource.cpp b/cmds/stagefright/SineSource.cpp index e272a65..021f636 100644 --- a/cmds/stagefright/SineSource.cpp +++ b/cmds/stagefright/SineSource.cpp @@ -52,6 +52,7 @@ sp<MetaData> SineSource::getFormat() { meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW); meta->setInt32(kKeyChannelCount, mNumChannels); meta->setInt32(kKeySampleRate, mSampleRate); + meta->setInt32(kKeyMaxInputSize, kBufferSize); return meta; } diff --git a/cmds/stagefright/audioloop.cpp b/cmds/stagefright/audioloop.cpp new file mode 100644 index 0000000..70ab559 --- /dev/null +++ b/cmds/stagefright/audioloop.cpp @@ -0,0 +1,81 @@ +#include "SineSource.h" + +#include <binder/ProcessState.h> +#include <media/stagefright/AudioPlayer.h> +#include <media/stagefright/MediaDebug.h> +#include <media/stagefright/MediaDefs.h> +#include <media/stagefright/MetaData.h> +#include <media/stagefright/OMXClient.h> +#include <media/stagefright/OMXCodec.h> + +using namespace android; + +int main() { + // We only have an AMR-WB encoder on sholes... + static bool outputWBAMR = false; + static const int32_t kSampleRate = outputWBAMR ? 16000 : 8000; + static const int32_t kNumChannels = 1; + + android::ProcessState::self()->startThreadPool(); + + OMXClient client; + CHECK_EQ(client.connect(), OK); + + sp<MediaSource> source = new SineSource(kSampleRate, kNumChannels); + + sp<MetaData> meta = new MetaData; + + meta->setCString( + kKeyMIMEType, + outputWBAMR ? MEDIA_MIMETYPE_AUDIO_AMR_WB + : MEDIA_MIMETYPE_AUDIO_AMR_NB); + + meta->setInt32(kKeyChannelCount, kNumChannels); + meta->setInt32(kKeySampleRate, kSampleRate); + + int32_t maxInputSize; + if (source->getFormat()->findInt32(kKeyMaxInputSize, &maxInputSize)) { + meta->setInt32(kKeyMaxInputSize, maxInputSize); + } + + sp<OMXCodec> encoder = OMXCodec::Create( + client.interface(), + meta, true /* createEncoder */, + source); + + sp<OMXCodec> decoder = OMXCodec::Create( + client.interface(), + meta, false /* createEncoder */, + encoder); + +#if 1 + AudioPlayer *player = new AudioPlayer(NULL); + player->setSource(decoder); + + player->start(); + + sleep(10); + + player->stop(); + + delete player; + player = NULL; +#else + CHECK_EQ(decoder->start(), OK); + + MediaBuffer *buffer; + while (decoder->read(&buffer) == OK) { + // do something with buffer + + putchar('.'); + fflush(stdout); + + buffer->release(); + buffer = NULL; + } + + CHECK_EQ(decoder->stop(), OK); +#endif + + return 0; +} |