am d95266c6: Merge "Detect and handle premature termination of a recording session" into kraken
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user