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

Commit 801ca774 authored by Girish Shetty's avatar Girish Shetty Committed by Android (Google) Code Review
Browse files

Merge "Revert "libstagefright: fix heap use after free issue""

parents ea163918 9548796d
Loading
Loading
Loading
Loading
+59 −35
Original line number Diff line number Diff line
@@ -72,17 +72,31 @@ NuMediaExtractor::~NuMediaExtractor() {
    }
}

status_t NuMediaExtractor::initMediaExtractor(const sp<DataSource>& dataSource) {
    status_t err = OK;
status_t NuMediaExtractor::setDataSource(
        const sp<MediaHTTPService> &httpService,
        const char *path,
        const KeyedVector<String8, String8> *headers) {
    Mutex::Autolock autoLock(mLock);

    if (mImpl != NULL || path == NULL) {
        return -EINVAL;
    }

    sp<DataSource> dataSource =
        DataSourceFactory::getInstance()->CreateFromURI(httpService, path, headers);

    if (dataSource == NULL) {
        return -ENOENT;
    }

    mImpl = MediaExtractorFactory::Create(dataSource);

    if (mImpl == NULL) {
        ALOGE("%s: failed to create MediaExtractor", __FUNCTION__);
        return ERROR_UNSUPPORTED;
    }

    setEntryPointToRemoteMediaExtractor();

    status_t err = OK;
    if (!mCasToken.empty()) {
        err = mImpl->setMediaCas(mCasToken);
        if (err != OK) {
@@ -91,10 +105,6 @@ status_t NuMediaExtractor::initMediaExtractor(const sp<DataSource>& dataSource)
        }
    }

    // Get the name of the implementation.
    mName = mImpl->name();

    // Update the duration and bitrate
    err = updateDurationAndBitrate();
    if (err == OK) {
        mDataSource = dataSource;
@@ -103,28 +113,6 @@ status_t NuMediaExtractor::initMediaExtractor(const sp<DataSource>& dataSource)
    return OK;
}

status_t NuMediaExtractor::setDataSource(
        const sp<MediaHTTPService> &httpService,
        const char *path,
        const KeyedVector<String8, String8> *headers) {
    Mutex::Autolock autoLock(mLock);

    if (mImpl != NULL || path == NULL) {
        return -EINVAL;
    }

    sp<DataSource> dataSource =
        DataSourceFactory::getInstance()->CreateFromURI(httpService, path, headers);

    if (dataSource == NULL) {
        return -ENOENT;
    }

    // Initialize MediaExtractor using the data source
    initMediaExtractor(dataSource);
    return OK;
}

status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {

    ALOGV("setDataSource fd=%d (%s), offset=%lld, length=%lld",
@@ -143,8 +131,26 @@ status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {
        return err;
    }

    // Initialize MediaExtractor using the file source
    initMediaExtractor(fileSource);
    mImpl = MediaExtractorFactory::Create(fileSource);

    if (mImpl == NULL) {
        return ERROR_UNSUPPORTED;
    }
    setEntryPointToRemoteMediaExtractor();

    if (!mCasToken.empty()) {
        err = mImpl->setMediaCas(mCasToken);
        if (err != OK) {
            ALOGE("%s: failed to setMediaCas (%d)", __FUNCTION__, err);
            return err;
        }
    }

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

    return OK;
}

@@ -160,14 +166,32 @@ status_t NuMediaExtractor::setDataSource(const sp<DataSource> &source) {
        return err;
    }

    // Initialize MediaExtractor using the given data source
    initMediaExtractor(source);
    mImpl = MediaExtractorFactory::Create(source);

    if (mImpl == NULL) {
        return ERROR_UNSUPPORTED;
    }
    setEntryPointToRemoteMediaExtractor();

    if (!mCasToken.empty()) {
        err = mImpl->setMediaCas(mCasToken);
        if (err != OK) {
            ALOGE("%s: failed to setMediaCas (%d)", __FUNCTION__, err);
            return err;
        }
    }

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

    return err;
}

const char* NuMediaExtractor::getName() const {
    Mutex::Autolock autoLock(mLock);
    return mImpl == nullptr ? nullptr : mName.string();
    return mImpl == nullptr ? nullptr : mImpl->name().string();
}

static String8 arrayToString(const std::vector<uint8_t> &array) {
+0 −2
Original line number Diff line number Diff line
@@ -146,7 +146,6 @@ private:
    Vector<TrackInfo> mSelectedTracks;
    int64_t mTotalBitrate;  // in bits/sec
    int64_t mDurationUs;
    String8 mName;

    void setEntryPointToRemoteMediaExtractor();

@@ -166,7 +165,6 @@ private:
    bool getTotalBitrate(int64_t *bitRate) const;
    status_t updateDurationAndBitrate();
    status_t appendVorbisNumPageSamples(MediaBufferBase *mbuf, const sp<ABuffer> &buffer);
    status_t initMediaExtractor(const sp<DataSource>& dataSource);

    DISALLOW_EVIL_CONSTRUCTORS(NuMediaExtractor);
};