diff options
author | Lajos Molnar <lajos@google.com> | 2015-04-24 17:10:07 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2015-04-30 16:56:10 -0700 |
commit | 3a474aa67fc31505740526dd249d96204c08bf79 (patch) | |
tree | 4db784ee57ffad037fa2ded86d0fd8b3a40173d5 /media/libstagefright/Utils.cpp | |
parent | a8df0b716bdfda1e10790e6f7297eeff83d2e52a (diff) | |
download | frameworks_av-3a474aa67fc31505740526dd249d96204c08bf79.zip frameworks_av-3a474aa67fc31505740526dd249d96204c08bf79.tar.gz frameworks_av-3a474aa67fc31505740526dd249d96204c08bf79.tar.bz2 |
stagefright: support setting/getting playback/sync config in MediaSync
Bug: 18249558
Bug: 19666434
Bug: 20057497
Change-Id: I5868b17423d7c20cfaf4a399f3eb67bfba440605
Diffstat (limited to 'media/libstagefright/Utils.cpp')
-rw-r--r-- | media/libstagefright/Utils.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp index 7b089b0..413628d 100644 --- a/media/libstagefright/Utils.cpp +++ b/media/libstagefright/Utils.cpp @@ -901,5 +901,39 @@ bool operator <(const HLSTime &t0, const HLSTime &t1) { || (t0.mSeq == t1.mSeq && t0.mTimeUs < t1.mTimeUs); } +void writeToAMessage(sp<AMessage> msg, const AudioPlaybackRate &rate) { + msg->setFloat("speed", rate.mSpeed); + msg->setFloat("pitch", rate.mPitch); + msg->setInt32("audio-fallback-mode", rate.mFallbackMode); + msg->setInt32("audio-stretch-mode", rate.mStretchMode); +} + +void readFromAMessage(const sp<AMessage> &msg, AudioPlaybackRate *rate /* nonnull */) { + *rate = AUDIO_PLAYBACK_RATE_DEFAULT; + CHECK(msg->findFloat("speed", &rate->mSpeed)); + CHECK(msg->findFloat("pitch", &rate->mPitch)); + CHECK(msg->findInt32("audio-fallback-mode", (int32_t *)&rate->mFallbackMode)); + CHECK(msg->findInt32("audio-stretch-mode", (int32_t *)&rate->mStretchMode)); +} + +void writeToAMessage(sp<AMessage> msg, const AVSyncSettings &sync, float videoFpsHint) { + msg->setInt32("sync-source", sync.mSource); + msg->setInt32("audio-adjust-mode", sync.mAudioAdjustMode); + msg->setFloat("tolerance", sync.mTolerance); + msg->setFloat("video-fps", videoFpsHint); +} + +void readFromAMessage( + const sp<AMessage> &msg, + AVSyncSettings *sync /* nonnull */, + float *videoFps /* nonnull */) { + AVSyncSettings settings; + CHECK(msg->findInt32("sync-source", (int32_t *)&settings.mSource)); + CHECK(msg->findInt32("audio-adjust-mode", (int32_t *)&settings.mAudioAdjustMode)); + CHECK(msg->findFloat("tolerance", &settings.mTolerance)); + CHECK(msg->findFloat("video-fps", videoFps)); + *sync = settings; +} + } // namespace android |