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

Commit d64f592e authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9121707 from 00f1aedf to tm-qpr1-release

Change-Id: I1dabf2d2e54fd50c19de243da0d490e481f5bcea
parents e926fc2e 00f1aedf
Loading
Loading
Loading
Loading
+34 −61
Original line number Diff line number Diff line
@@ -72,31 +72,17 @@ NuMediaExtractor::~NuMediaExtractor() {
    }
}

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;
    }
status_t NuMediaExtractor::initMediaExtractor(const sp<DataSource>& dataSource) {
    status_t err = OK;

    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) {
@@ -105,6 +91,10 @@ status_t NuMediaExtractor::setDataSource(
        }
    }

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

    // Update the duration and bitrate
    err = updateDurationAndBitrate();
    if (err == OK) {
        mDataSource = dataSource;
@@ -113,6 +103,27 @@ status_t NuMediaExtractor::setDataSource(
    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
    return initMediaExtractor(dataSource);
}

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

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

    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;
    // Initialize MediaExtractor using the file source
    return initMediaExtractor(fileSource);
}

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

    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;
    // Initialize MediaExtractor using the given data source
    return initMediaExtractor(source);
}

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

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

    void setEntryPointToRemoteMediaExtractor();

@@ -165,6 +166,7 @@ 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);
};
+10 −4
Original line number Diff line number Diff line
@@ -1410,18 +1410,24 @@ void Camera3OutputStream::returnPrefetchedBuffersLocked() {
}

nsecs_t Camera3OutputStream::syncTimestampToDisplayLocked(nsecs_t t) {
    nsecs_t currentTime = systemTime();
    if (!mFixedFps) {
        mLastCaptureTime = t;
        mLastPresentTime = currentTime;
        return t;
    }

    ParcelableVsyncEventData parcelableVsyncEventData;
    auto res = mDisplayEventReceiver.getLatestVsyncEventData(&parcelableVsyncEventData);
    if (res != OK) {
        ALOGE("%s: Stream %d: Error getting latest vsync event data: %s (%d)",
                __FUNCTION__, mId, strerror(-res), res);
        mLastCaptureTime = t;
        mLastPresentTime = t;
        mLastPresentTime = currentTime;
        return t;
    }

    const VsyncEventData& vsyncEventData = parcelableVsyncEventData.vsync;
    nsecs_t currentTime = systemTime();
    nsecs_t minPresentT = mLastPresentTime + vsyncEventData.frameInterval / 2;

    // Find the best presentation time without worrying about previous frame's
@@ -1526,8 +1532,8 @@ nsecs_t Camera3OutputStream::syncTimestampToDisplayLocked(nsecs_t t) {
        }
    }

    if (expectedPresentT == mLastPresentTime && expectedPresentT <=
            vsyncEventData.frameTimelines[maxTimelines].expectedPresentationTime) {
    if (expectedPresentT == mLastPresentTime && expectedPresentT <
            vsyncEventData.frameTimelines[maxTimelines-1].expectedPresentationTime) {
        // Couldn't find a reasonable presentation time. Using last frame's
        // presentation time would cause a frame drop. The best option now
        // is to use the next VSync as long as the last presentation time
+1 −1
Original line number Diff line number Diff line
@@ -432,7 +432,7 @@ class Camera3OutputStream :
    static constexpr nsecs_t kSpacingResetIntervalNs = 50000000LL; // 50 millisecond
    static constexpr nsecs_t kTimelineThresholdNs = 1000000LL; // 1 millisecond
    static constexpr float kMaxIntervalRatioDeviation = 0.05f;
    static constexpr int kMaxTimelines = 3;
    static constexpr int kMaxTimelines = 2;
    nsecs_t syncTimestampToDisplayLocked(nsecs_t t);

    // Re-space frames by delaying queueBuffer so that frame delivery has
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ bool PreviewFrameSpacer::threadLoop() {
        return true;
    }

    // Cache the frame to match readout time interval, for up to 33ms
    // Cache the frame to match readout time interval, for up to kMaxFrameWaitTime
    nsecs_t expectedQueueTime = mLastCameraPresentTime + readoutInterval;
    nsecs_t frameWaitTime = std::min(kMaxFrameWaitTime, expectedQueueTime - currentTime);
    if (frameWaitTime > 0 && mPendingBuffers.size() < 2) {
Loading