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

Commit 890710b1 authored by Lajos Molnar's avatar Lajos Molnar Committed by android-build-merger
Browse files

Merge "stagefright: expose track ID-s in track format" into nyc-dev

am: 63870faf

* commit '63870faf':
  stagefright: expose track ID-s in track format
parents 5d8d433e 63870faf
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -84,6 +84,10 @@ private:
        kIsVorbis       = 1,
    };

    enum {
        kMaxTrackCount = 16384,
    };

    struct TrackInfo {
        sp<IMediaSource> mSource;
        size_t mTrackIndex;
@@ -113,7 +117,7 @@ private:
    void releaseTrackSamples();

    bool getTotalBitrate(int64_t *bitRate) const;
    void updateDurationAndBitrate();
    status_t updateDurationAndBitrate();
    status_t appendVorbisNumPageSamples(TrackInfo *info, const sp<ABuffer> &buffer);

    DISALLOW_EVIL_CONSTRUCTORS(NuMediaExtractor);
+25 −11
Original line number Diff line number Diff line
@@ -121,9 +121,10 @@ status_t NuMediaExtractor::setDataSource(
        return ERROR_UNSUPPORTED;
    }

    status_t err = updateDurationAndBitrate();
    if (err == OK) {
        mDataSource = dataSource;

    updateDurationAndBitrate();
    }

    return OK;
}
@@ -152,9 +153,10 @@ status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {
        return ERROR_UNSUPPORTED;
    }

    err = updateDurationAndBitrate();
    if (err == OK) {
        mDataSource = fileSource;

    updateDurationAndBitrate();
    }

    return OK;
}
@@ -177,14 +179,19 @@ status_t NuMediaExtractor::setDataSource(const sp<DataSource> &source) {
        return ERROR_UNSUPPORTED;
    }

    err = updateDurationAndBitrate();
    if (err == OK) {
        mDataSource = source;
    }

    updateDurationAndBitrate();
    return err;
}

    return OK;
status_t NuMediaExtractor::updateDurationAndBitrate() {
    if (mImpl->countTracks() > kMaxTrackCount) {
        return ERROR_UNSUPPORTED;
    }

void NuMediaExtractor::updateDurationAndBitrate() {
    mTotalBitrate = 0ll;
    mDurationUs = -1ll;

@@ -212,6 +219,7 @@ void NuMediaExtractor::updateDurationAndBitrate() {
            mDurationUs = durationUs;
        }
    }
    return OK;
}

size_t NuMediaExtractor::countTracks() const {
@@ -235,6 +243,12 @@ status_t NuMediaExtractor::getTrackFormat(
    }

    sp<MetaData> meta = mImpl->getTrackMetaData(index);
    // Extractors either support trackID-s or not, so either all tracks have trackIDs or none.
    // Generate trackID if missing.
    int32_t trackID;
    if (meta != NULL && !meta->findInt32(kKeyTrackID, &trackID)) {
        meta->setInt32(kKeyTrackID, (int32_t)index + 1);
    }
    return convertMetaDataToMessage(meta, format);
}

+6 −0
Original line number Diff line number Diff line
@@ -167,6 +167,12 @@ status_t convertMetaDataToMessage(
        msg->setInt32("is-sync-frame", 1);
    }

    // this only needs to be translated from meta to message as it is an extractor key
    int32_t trackID;
    if (meta->findInt32(kKeyTrackID, &trackID)) {
        msg->setInt32("track-id", trackID);
    }

    if (!strncasecmp("video/", mime, 6)) {
        int32_t width, height;
        if (!meta->findInt32(kKeyWidth, &width)