diff options
author | James Dong <jdong@google.com> | 2010-07-22 16:25:17 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-07-22 16:25:17 -0700 |
commit | 00fba4994e33d1b8384ff8bc2221c2de933f387e (patch) | |
tree | 2780e2456a9b540e245fa3e3c8e62d60c284b8dc /media/libstagefright/CameraSource.cpp | |
parent | 3922fe0860f1662f9066f553314b6955702d4956 (diff) | |
parent | 542db5d438988360d491a5add1040a2df9aa90c9 (diff) | |
download | frameworks_av-00fba4994e33d1b8384ff8bc2221c2de933f387e.zip frameworks_av-00fba4994e33d1b8384ff8bc2221c2de933f387e.tar.gz frameworks_av-00fba4994e33d1b8384ff8bc2221c2de933f387e.tar.bz2 |
am 53d4e0d5: Allows the authoring engine to skip frame.
Merge commit '53d4e0d58e2d5c18f6e026c705af833b9bdd7aba' into gingerbread-plus-aosp
* commit '53d4e0d58e2d5c18f6e026c705af833b9bdd7aba':
Allows the authoring engine to skip frame.
Diffstat (limited to 'media/libstagefright/CameraSource.cpp')
-rw-r--r-- | media/libstagefright/CameraSource.cpp | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index 4cc176a..9c48daf 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -277,23 +277,44 @@ status_t CameraSource::read( { Mutex::Autolock autoLock(mLock); - while (mStarted && mFramesReceived.empty()) { - mFrameAvailableCondition.wait(mLock); - } - if (!mStarted) { - return OK; - } - frame = *mFramesReceived.begin(); - mFramesReceived.erase(mFramesReceived.begin()); + while (mStarted) { + while(mFramesReceived.empty()) { + mFrameAvailableCondition.wait(mLock); + } + + if (!mStarted) { + return OK; + } - frameTime = *mFrameTimes.begin(); - mFrameTimes.erase(mFrameTimes.begin()); + frame = *mFramesReceived.begin(); + mFramesReceived.erase(mFramesReceived.begin()); - mFramesBeingEncoded.push_back(frame); - *buffer = new MediaBuffer(frame->pointer(), frame->size()); - (*buffer)->setObserver(this); - (*buffer)->add_ref(); - (*buffer)->meta_data()->setInt64(kKeyTime, frameTime); + frameTime = *mFrameTimes.begin(); + mFrameTimes.erase(mFrameTimes.begin()); + int64_t skipTimeUs; + if (!options || !options->getSkipFrame(&skipTimeUs)) { + skipTimeUs = frameTime; + } + if (skipTimeUs > frameTime) { + LOGV("skipTimeUs: %lld us > frameTime: %lld us", + skipTimeUs, frameTime); + releaseOneRecordingFrame(frame); + ++mNumFramesDropped; + // Safeguard against the abuse of the kSkipFrame_Option. + if (skipTimeUs - frameTime >= 1E6) { + LOGE("Frame skipping requested is way too long: %lld us", + skipTimeUs - frameTime); + return UNKNOWN_ERROR; + } + } else { + mFramesBeingEncoded.push_back(frame); + *buffer = new MediaBuffer(frame->pointer(), frame->size()); + (*buffer)->setObserver(this); + (*buffer)->add_ref(); + (*buffer)->meta_data()->setInt64(kKeyTime, frameTime); + return OK; + } + } } return OK; } |