Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce3d8b31 authored by James Dong's avatar James Dong Committed by Android Git Automerger
Browse files

am d95266c6: Merge "Detect and handle premature termination of a recording session" into kraken

parents 9efc829e d95266c6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
};

// ----------------------------------------------------------------------------
+1 −6
Original line number Diff line number Diff line
@@ -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);
+13 −0
Original line number Diff line number Diff line
@@ -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;
}

+3 −1
Original line number Diff line number Diff line
@@ -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()) {