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

Commit 113cdc07 authored by Leena Winterrowd's avatar Leena Winterrowd Committed by Linux Build Service Account
Browse files

libstagefright: Use 3gp4 ftyp box when AMR audio is present

mp42 boxes do not support the 'damr' box type whereas 3gp4 boxes
explicitly support it. Using mp42 makes clips with AMR incompliant
with mpeg4 standards and unplayable by many media players. To
ensure interoperability, use a 3gp4 box if the recorded clip
contains AMR audio.

CRs-Fixed: 721883
Change-Id: I75e3558cd5088d05d36104abfb04a3c0c1d1a4e7
parent fb004083
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -181,6 +181,9 @@ private:
    // By default, real time recording is on.
    bool isRealTimeRecording() const;

    // To use 3gp4 box for clips with AMR audio
    bool mIsAudioAMR;

    void lock();
    void unlock();

+7 −3
Original line number Diff line number Diff line
@@ -385,7 +385,8 @@ MPEG4Writer::MPEG4Writer(int fd)
      mLongitudex10000(0),
      mAreGeoTagsAvailable(false),
      mStartTimeOffsetMs(-1),
      mMetaKeys(new AMessage()) {
      mMetaKeys(new AMessage()),
      mIsAudioAMR(false) {
    addDeviceMeta();

    // Verify mFd is seekable
@@ -492,6 +493,9 @@ status_t MPEG4Writer::addSource(const sp<MediaSource> &source) {
        ALOGE("Unsupported mime '%s'", mime);
        return ERROR_UNSUPPORTED;
    }
    mIsAudioAMR = isAudio && (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_NB, mime) ||
                              !strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_WB, mime));


    // At this point, we know the track to be added is either
    // video or audio. Thus, we only need to check whether it
@@ -1047,8 +1051,8 @@ void MPEG4Writer::writeFtypBox(MetaData *param) {
    beginBox("ftyp");

    int32_t fileType;
    if (param && param->findInt32(kKeyFileType, &fileType) &&
        fileType != OUTPUT_FORMAT_MPEG_4) {
    if (mIsAudioAMR || (param && param->findInt32(kKeyFileType, &fileType) &&
        fileType != OUTPUT_FORMAT_MPEG_4)) {
        writeFourcc("3gp4");
        writeInt32(0);
        writeFourcc("isom");