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

Commit 116913ac authored by Gopalakrishnan Nallasamy's avatar Gopalakrishnan Nallasamy
Browse files

MPEG4Writer:Ignore sample table of malformed track

1. Don't write sample table box for malformed tracks.
   Return error to the client about malformed track.
   MOOV atom would be finalized with other well-formed tracks.
2. Throw relevant track id and recorder-error on error while making
   codec specific data from input buffers for AVC, HEIC, HEVC and MPEG4.
3. Capture and log errors returned by system calls.
4. Bubble up other relevant errors.
5. Good to release internal buffer and stop source before notifying client.
6. Don't need to update filesize for every preallocation.
   Use fallocate in FALLOC_FL_KEEP_SIZE mode.
7. Added some important logs
8. Added and corrected some comments.
9. Added TrackId subclass to validate track ids for MediaRecorder and
   MediaMuxer.

Bug: 153923798
Bug: 156657952

Test: atest android.media.cts.MediaMuxerTest
      atest android.media.cts.MediaRecorderTest
      atest android.mediav2.cts.MuxerTest

Change-Id: I87f9b8cc9cbd23789f7fb69490e8a6f81469907a
parent fd267eb2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2011,6 +2011,7 @@ void StagefrightRecorder::setupMPEG4orWEBMMetaData(sp<MetaData> *meta) {
    }
    if (mOutputFormat == OUTPUT_FORMAT_MPEG_4 || mOutputFormat == OUTPUT_FORMAT_THREE_GPP) {
        (*meta)->setInt32(kKeyEmptyTrackMalFormed, true);
        (*meta)->setInt32(kKey4BitTrackIds, true);
    }
}

+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ status_t HevcParameterSets::addNalUnit(const uint8_t* data, size_t size) {
    }

    if (err != OK) {
        ALOGE("error parsing VPS or SPS or PPS");
        return err;
    }

+146 −61

File changed.

Preview size limit exceeded, changes collapsed.

+4 −1
Original line number Diff line number Diff line
@@ -171,7 +171,10 @@ status_t MediaMuxer::stop() {
        if (err != OK || mError != OK) {
            ALOGE("stop err: %d, mError:%d", err, mError);
        }
        // Prioritize mError over err.
        /* Prioritize mError over err as writer would have got stopped on any
         * internal error and notified muxer already.  Clients might issue
         * stop again later, and mWriter->stop() would return success.
         */
        if (mError != OK) {
            err = mError;
        }
+7 −6
Original line number Diff line number Diff line
@@ -86,8 +86,8 @@ private:

    enum {
        kWhatSwitch                  = 'swch',
        kWhatHandleIOError                   = 'ioer',
        kWhatHandleFallocateError            = 'faer'
        kWhatIOError                 = 'ioer',
        kWhatFallocateError          = 'faer'
    };

    int  mFd;
@@ -287,7 +287,8 @@ private:
    bool exceedsFileDurationLimit();
    bool approachingFileSizeLimit();
    bool isFileStreamable() const;
    void trackProgressStatus(size_t trackId, int64_t timeUs, status_t err = OK);
    void trackProgressStatus(uint32_t trackId, int64_t timeUs, status_t err = OK);
    status_t validateAllTracksId(bool akKey4BitTrackIds);
    void writeCompositionMatrix(int32_t degrees);
    void writeMvhdBox(int64_t durationUs);
    void writeMoovBox(int64_t durationUs);
@@ -327,7 +328,7 @@ private:
    void writeFileLevelMetaBox();

    void sendSessionSummary();
    void release();
    status_t release();
    status_t switchFd();
    status_t reset(bool stopSource = true);

Loading