diff options
author | James Dong <jdong@google.com> | 2010-05-14 12:19:17 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-05-14 12:19:17 -0700 |
commit | d95266c6a8f059770b1799958530156a2f537468 (patch) | |
tree | 8db7bf2b3debc962f523ea27b7767ff518ced759 | |
parent | 4e544e81462cb47d237af916850983412c77975a (diff) | |
parent | 68510e60f9671ee08f3cc18bd93400cafb7703bb (diff) | |
download | frameworks_base-d95266c6a8f059770b1799958530156a2f537468.zip frameworks_base-d95266c6a8f059770b1799958530156a2f537468.tar.gz frameworks_base-d95266c6a8f059770b1799958530156a2f537468.tar.bz2 |
Merge "Detect and handle premature termination of a recording session" into kraken
-rw-r--r-- | include/media/mediarecorder.h | 3 | ||||
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 7 | ||||
-rw-r--r-- | media/libstagefright/AMRWriter.cpp | 13 | ||||
-rw-r--r-- | media/libstagefright/MPEG4Writer.cpp | 4 |
4 files changed, 19 insertions, 8 deletions
diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h index 9ea6c7b..eead166 100644 --- a/include/media/mediarecorder.h +++ b/include/media/mediarecorder.h @@ -135,7 +135,8 @@ enum media_recorder_error_type { enum media_recorder_info_type { MEDIA_RECORDER_INFO_UNKNOWN = 1, MEDIA_RECORDER_INFO_MAX_DURATION_REACHED = 800, - MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED = 801 + MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED = 801, + MEDIA_RECORDER_INFO_STOP_PREMATURELY = 802 }; // ---------------------------------------------------------------------------- diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index cb08100..8404779 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -269,7 +269,7 @@ status_t StagefrightRecorder::setParamVideoEncodingBitRate(int32_t bitRate) { status_t StagefrightRecorder::setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration) { - LOGV("setParamMaxDurationOrFileSize: limit (%d) for %s", + LOGV("setParamMaxDurationOrFileSize: limit (%lld) for %s", limit, limit_is_duration?"duration":"size"); if (limit_is_duration) { // limit is in ms if (limit <= 1000) { // XXX: 1 second @@ -563,11 +563,6 @@ status_t StagefrightRecorder::startMPEG4Recording() { || mVideoSource == VIDEO_SOURCE_CAMERA) { CHECK(mCamera != NULL); - if (mCamera == 0) { - mCamera = Camera::connect(0); - } - CHECK(mCamera != NULL); - // Set the actual video recording frame size CameraParameters params(mCamera->getParameters()); params.setPreviewSize(mVideoWidth, mVideoHeight); diff --git a/media/libstagefright/AMRWriter.cpp b/media/libstagefright/AMRWriter.cpp index 0d54235..aec7394 100644 --- a/media/libstagefright/AMRWriter.cpp +++ b/media/libstagefright/AMRWriter.cpp @@ -162,6 +162,7 @@ void *AMRWriter::ThreadWrapper(void *me) { void AMRWriter::threadFunc() { mEstimatedDurationUs = 0; mEstimatedSizeBytes = 0; + bool stoppedPrematurely = true; while (!mDone) { MediaBuffer *buffer; status_t err = mSource->read(&buffer); @@ -202,10 +203,22 @@ void AMRWriter::threadFunc() { break; } + // XXX: How to tell it is stopped prematurely? + if (stoppedPrematurely) { + stoppedPrematurely = false; + } + buffer->release(); buffer = NULL; } + if (stoppedPrematurely) { + notify(MEDIA_RECORDER_EVENT_INFO, MEDIA_RECORDER_INFO_STOP_PREMATURELY, 0); + } + + fflush(mFile); + fclose(mFile); + mFile = NULL; mReachedEOS = true; } diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index 788534d..5361f92 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -924,7 +924,9 @@ void MPEG4Writer::Track::threadEntry() { buffer = NULL; } - CHECK(!mSampleInfos.empty()); + if (mSampleInfos.empty()) { + mOwner->notify(MEDIA_RECORDER_EVENT_INFO, MEDIA_RECORDER_INFO_STOP_PREMATURELY, 0); + } // Last chunk if (!mChunkSamples.empty()) { |