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

Commit a768b4f8 authored by ztenghui's avatar ztenghui Committed by Android Git Automerger
Browse files

am 8f1efee1: Merge "MediaMuxer prefer not to use the MPEG4Writer in real time...

am 8f1efee1: Merge "MediaMuxer prefer not to use the MPEG4Writer in real time recording mode." into jb-mr2-dev

* commit '8f1efee1':
  MediaMuxer prefer not to use the MPEG4Writer in real time recording mode.
parents da69f1c2 8f1efee1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -523,7 +523,7 @@ static void writeSourcesToMP4(
    }

    sp<MetaData> params = new MetaData;
    params->setInt32(kKeyNotRealTime, true);
    params->setInt32(kKeyRealTimeRecording, false);
    CHECK_EQ(writer->start(params.get()), (status_t)OK);

    while (!writer->reachedEOS()) {
+8 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ private:

    int  mFd;
    status_t mInitCheck;
    bool mIsRealTimeRecording;
    bool mUse4ByteNalLength;
    bool mUse32BitOffset;
    bool mIsFileSizeLimitExplicitlyRequested;
@@ -168,6 +169,13 @@ private:
    // Only makes sense for H.264/AVC
    bool useNalLengthFour();

    // Return whether the writer is used for real time recording.
    // In real time recording mode, new samples will be allowed to buffered into
    // chunks in higher priority thread, even though the file writer has not
    // drained the chunks yet.
    // By default, real time recording is on.
    bool isRealTimeRecording() const;

    void lock();
    void unlock();

+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ enum {
    // kKeyTrackTimeStatus is used to track progress in elapsed time
    kKeyTrackTimeStatus   = 'tktm',  // int64_t

    kKeyNotRealTime       = 'ntrt',  // bool (int32_t)
    kKeyRealTimeRecording = 'rtrc',  // bool (int32_t)
    kKeyNumBuffers        = 'nbbf',  // int32_t

    // Ogg files can be tagged to be automatically looping...
+2 −2
Original line number Diff line number Diff line
@@ -189,8 +189,8 @@ void displayMetaData(const sp<MetaData> meta) {
    if (meta->findInt64(kKeyTrackTimeStatus, &int64Data)) {
        LOG1("displayMetaData kKeyTrackTimeStatus %lld", int64Data);
    }
    if (meta->findInt32(kKeyNotRealTime, &int32Data)) {
        LOG1("displayMetaData kKeyNotRealTime %d", int32Data);
    if (meta->findInt32(kKeyRealTimeRecording, &int32Data)) {
        LOG1("displayMetaData kKeyRealTimeRecording %d", int32Data);
    }
}

+27 −16
Original line number Diff line number Diff line
@@ -212,7 +212,6 @@ private:
    int64_t mTrackDurationUs;
    int64_t mMaxChunkDurationUs;

    bool mIsRealTimeRecording;
    int64_t mEstimatedTrackSizeBytes;
    int64_t mMdatSizeBytes;
    int32_t mTimeScale;
@@ -335,6 +334,7 @@ private:
MPEG4Writer::MPEG4Writer(const char *filename)
    : mFd(-1),
      mInitCheck(NO_INIT),
      mIsRealTimeRecording(true),
      mUse4ByteNalLength(true),
      mUse32BitOffset(true),
      mIsFileSizeLimitExplicitlyRequested(false),
@@ -359,6 +359,7 @@ MPEG4Writer::MPEG4Writer(const char *filename)
MPEG4Writer::MPEG4Writer(int fd)
    : mFd(dup(fd)),
      mInitCheck(mFd < 0? NO_INIT: OK),
      mIsRealTimeRecording(true),
      mUse4ByteNalLength(true),
      mUse32BitOffset(true),
      mIsFileSizeLimitExplicitlyRequested(false),
@@ -596,6 +597,11 @@ status_t MPEG4Writer::start(MetaData *param) {
        mUse4ByteNalLength = false;
    }

    int32_t isRealTimeRecording;
    if (param && param->findInt32(kKeyRealTimeRecording, &isRealTimeRecording)) {
        mIsRealTimeRecording = isRealTimeRecording;
    }

    mStartTimestampUs = -1;

    if (mStarted) {
@@ -1640,14 +1646,20 @@ void MPEG4Writer::threadFunc() {
            mChunkReadyCondition.wait(mLock);
        }

        // Actual write without holding the lock in order to
        // reduce the blocking time for media track threads.
        // In real time recording mode, write without holding the lock in order
        // to reduce the blocking time for media track threads.
        // Otherwise, hold the lock until the existing chunks get written to the
        // file.
        if (chunkFound) {
            if (mIsRealTimeRecording) {
                mLock.unlock();
            }
            writeChunkToFile(&chunk);
            if (mIsRealTimeRecording) {
                mLock.lock();
            }
        }
    }

    writeAllChunks();
}
@@ -1695,18 +1707,10 @@ status_t MPEG4Writer::Track::start(MetaData *params) {
        mRotation = rotationDegrees;
    }

    mIsRealTimeRecording = true;
    {
        int32_t isNotRealTime;
        if (params && params->findInt32(kKeyNotRealTime, &isNotRealTime)) {
            mIsRealTimeRecording = (isNotRealTime == 0);
        }
    }

    initTrackingProgressStatus(params);

    sp<MetaData> meta = new MetaData;
    if (mIsRealTimeRecording && mOwner->numTracks() > 1) {
    if (mOwner->isRealTimeRecording() && mOwner->numTracks() > 1) {
        /*
         * This extra delay of accepting incoming audio/video signals
         * helps to align a/v start time at the beginning of a recording
@@ -2084,7 +2088,10 @@ status_t MPEG4Writer::Track::threadEntry() {
    } else {
        prctl(PR_SET_NAME, (unsigned long)"VideoTrackEncoding", 0, 0, 0);
    }

    if (mOwner->isRealTimeRecording()) {
        androidSetThreadPriority(0, ANDROID_PRIORITY_AUDIO);
    }

    sp<MetaData> meta_data;

@@ -2245,7 +2252,7 @@ status_t MPEG4Writer::Track::threadEntry() {

        }

        if (mIsRealTimeRecording) {
        if (mOwner->isRealTimeRecording()) {
            if (mIsAudio) {
                updateDriftTime(meta_data);
            }
@@ -2531,6 +2538,10 @@ int64_t MPEG4Writer::getDriftTimeUs() {
    return mDriftTimeUs;
}

bool MPEG4Writer::isRealTimeRecording() const {
    return mIsRealTimeRecording;
}

bool MPEG4Writer::useNalLengthFour() {
    return mUse4ByteNalLength;
}
Loading