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

Commit dd6c17fb authored by Robert Shih's avatar Robert Shih
Browse files

NuMediaExtractor: add sample size API

Bug: 63934228
Change-Id: I3229cc9ca6abba06367de3ac0797a5e1255bba77
parent b2eb24b6
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -660,6 +660,28 @@ status_t NuMediaExtractor::readSampleData(const sp<ABuffer> &buffer) {
    return err;
}

status_t NuMediaExtractor::getSampleSize(size_t *sampleSize) {
    Mutex::Autolock autoLock(mLock);

    ssize_t minIndex = fetchAllTrackSamples();

    if (minIndex < 0) {
        return ERROR_END_OF_STREAM;
    }

    TrackInfo *info = &mSelectedTracks.editItemAt(minIndex);
    auto it = info->mSamples.begin();
    *sampleSize = it->mBuffer->range_length();

    if (info->mTrackFlags & kIsVorbis) {
        // Each sample's data is suffixed by the number of page samples
        // or -1 if not available.
        *sampleSize += sizeof(int32_t);
    }

    return OK;
}

status_t NuMediaExtractor::getSampleTrackIndex(size_t *trackIndex) {
    Mutex::Autolock autoLock(mLock);

+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ struct NuMediaExtractor : public RefBase {
    // readSampleData() reads the sample with the lowest timestamp.
    status_t readSampleData(const sp<ABuffer> &buffer);

    status_t getSampleSize(size_t *sampleSize);
    status_t getSampleTrackIndex(size_t *trackIndex);
    status_t getSampleTime(int64_t *sampleTimeUs);
    status_t getSampleMeta(sp<MetaData> *sampleMeta);