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

Commit 5c9350b5 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [2474311, 2474176, 2474345, 2474362, 2474329, 2474274,...

Merge cherrypicks of [2474311, 2474176, 2474345, 2474362, 2474329, 2474274, 2474293, 2474219, 2474346, 2474330, 2474200, 2474363, 2474347, 2474348] into oc-dr1-release

Change-Id: I62e003886fdb0405e29d2ce9930428fe78ed9fc8
parents 99cdc0bc 8ccd288f
Loading
Loading
Loading
Loading
+55 −21
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ public:
    int64_t getDurationUs() const;
    int64_t getEstimatedTrackSizeBytes() const;
    void writeTrackHeader(bool use32BitOffset = true);
    int64_t getMinCttsOffsetTimeUs();
    void bufferChunk(int64_t timestampUs);
    bool isAvc() const { return mIsAvc; }
    bool isHevc() const { return mIsHevc; }
@@ -307,7 +308,8 @@ private:
    ListTableEntries<uint32_t, 2> *mCttsTableEntries;

    int64_t mMinCttsOffsetTimeUs;
    int64_t mMaxCttsOffsetTimeUs;
    int64_t mMinCttsOffsetTicks;
    int64_t mMaxCttsOffsetTicks;

    // Save the last 10 frames' timestamp for debug.
    std::list<std::pair<int64_t, int64_t>> mTimestampDebugHelper;
@@ -343,7 +345,7 @@ private:

    void dumpTimeStamps();

    int64_t getStartTimeOffsetScaledTimeUs() const;
    int64_t getStartTimeOffsetTimeUs() const;
    int32_t getStartTimeOffsetScaledTime() const;

    static void *ThreadWrapper(void *me);
@@ -1134,9 +1136,20 @@ void MPEG4Writer::writeMoovBox(int64_t durationUs) {
        writeUdtaBox();
    }
    writeMetaBox();
    int32_t id = 1;
    // Loop through all the tracks to get the global time offset if there is
    // any ctts table appears in a video track.
    int64_t minCttsOffsetTimeUs = kMaxCttsOffsetTimeUs;
    for (List<Track *>::iterator it = mTracks.begin();
        it != mTracks.end(); ++it, ++id) {
        it != mTracks.end(); ++it) {
        minCttsOffsetTimeUs =
            std::min(minCttsOffsetTimeUs, (*it)->getMinCttsOffsetTimeUs());
    }

    // Adjust the global start time.
    mStartTimestampUs += minCttsOffsetTimeUs - kMaxCttsOffsetTimeUs;

    for (List<Track *>::iterator it = mTracks.begin();
        it != mTracks.end(); ++it) {
        (*it)->writeTrackHeader(mUse32BitOffset);
    }
    endBox();  // moov
@@ -1626,6 +1639,9 @@ MPEG4Writer::Track::Track(
      mStssTableEntries(new ListTableEntries<uint32_t, 1>(1000)),
      mSttsTableEntries(new ListTableEntries<uint32_t, 2>(1000)),
      mCttsTableEntries(new ListTableEntries<uint32_t, 2>(1000)),
      mMinCttsOffsetTimeUs(0),
      mMinCttsOffsetTicks(0),
      mMaxCttsOffsetTicks(0),
      mCodecSpecificData(NULL),
      mCodecSpecificDataSize(0),
      mGotAllCodecSpecificData(false),
@@ -2814,16 +2830,16 @@ status_t MPEG4Writer::Track::threadEntry() {

            // Update ctts time offset range
            if (mStszTableEntries->count() == 0) {
                mMinCttsOffsetTimeUs = currCttsOffsetTimeTicks;
                mMaxCttsOffsetTimeUs = currCttsOffsetTimeTicks;
                mMinCttsOffsetTicks = currCttsOffsetTimeTicks;
                mMaxCttsOffsetTicks = currCttsOffsetTimeTicks;
            } else {
                if (currCttsOffsetTimeTicks > mMaxCttsOffsetTimeUs) {
                    mMaxCttsOffsetTimeUs = currCttsOffsetTimeTicks;
                } else if (currCttsOffsetTimeTicks < mMinCttsOffsetTimeUs) {
                    mMinCttsOffsetTimeUs = currCttsOffsetTimeTicks;
                if (currCttsOffsetTimeTicks > mMaxCttsOffsetTicks) {
                    mMaxCttsOffsetTicks = currCttsOffsetTimeTicks;
                } else if (currCttsOffsetTimeTicks < mMinCttsOffsetTicks) {
                    mMinCttsOffsetTicks = currCttsOffsetTimeTicks;
                    mMinCttsOffsetTimeUs = cttsOffsetTimeUs;
                }
            }

        }

        if (mOwner->isRealTimeRecording()) {
@@ -3164,7 +3180,7 @@ void MPEG4Writer::Track::bufferChunk(int64_t timestampUs) {
}

int64_t MPEG4Writer::Track::getDurationUs() const {
    return mTrackDurationUs + getStartTimeOffsetScaledTimeUs();
    return mTrackDurationUs + getStartTimeOffsetTimeUs();
}

int64_t MPEG4Writer::Track::getEstimatedTrackSizeBytes() const {
@@ -3219,6 +3235,16 @@ void MPEG4Writer::Track::writeTrackHeader(bool use32BitOffset) {
    mOwner->endBox();  // trak
}

int64_t MPEG4Writer::Track::getMinCttsOffsetTimeUs() {
    // For video tracks with ctts table, this should return the minimum ctts
    // offset in the table. For non-video tracks or video tracks without ctts
    // table, this will return kMaxCttsOffsetTimeUs.
    if (mMinCttsOffsetTicks == mMaxCttsOffsetTicks) {
        return kMaxCttsOffsetTimeUs;
    }
    return mMinCttsOffsetTimeUs;
}

void MPEG4Writer::Track::writeStblBox(bool use32BitOffset) {
    mOwner->beginBox("stbl");
    mOwner->beginBox("stsd");
@@ -3648,7 +3674,7 @@ void MPEG4Writer::Track::writePaspBox() {
    mOwner->endBox();  // pasp
}

int64_t MPEG4Writer::Track::getStartTimeOffsetScaledTimeUs() const {
int64_t MPEG4Writer::Track::getStartTimeOffsetTimeUs() const {
    int64_t trackStartTimeOffsetUs = 0;
    int64_t moovStartTimeUs = mOwner->getStartTimestampUs();
    if (mStartTimestampUs != -1 && mStartTimestampUs != moovStartTimeUs) {
@@ -3659,23 +3685,30 @@ int64_t MPEG4Writer::Track::getStartTimeOffsetScaledTimeUs() const {
}

int32_t MPEG4Writer::Track::getStartTimeOffsetScaledTime() const {
    return (getStartTimeOffsetScaledTimeUs() *  mTimeScale + 500000LL) / 1000000LL;
    return (getStartTimeOffsetTimeUs() * mTimeScale + 500000LL) / 1000000LL;
}

void MPEG4Writer::Track::writeSttsBox() {
    mOwner->beginBox("stts");
    mOwner->writeInt32(0);  // version=0, flags=0
    if (mMinCttsOffsetTicks == mMaxCttsOffsetTicks) {
        // For non-vdeio tracks or video tracks without ctts table,
        // adjust duration of first sample for tracks to account for
        // first sample not starting at the media start time.
        // TODO: consider signaling this using some offset
        // as this is not quite correct.
        uint32_t duration;
        CHECK(mSttsTableEntries->get(duration, 1));
        duration = htonl(duration);  // Back to host byte order
        mSttsTableEntries->set(htonl(duration + getStartTimeOffsetScaledTime()), 1);
    }
    mSttsTableEntries->write(mOwner);
    mOwner->endBox();  // stts
}

void MPEG4Writer::Track::writeCttsBox() {
    // There is no B frame at all
    if (mMinCttsOffsetTimeUs == mMaxCttsOffsetTimeUs) {
    if (mMinCttsOffsetTicks == mMaxCttsOffsetTicks) {
        return;
    }

@@ -3685,11 +3718,12 @@ void MPEG4Writer::Track::writeCttsBox() {
    }

    ALOGV("ctts box has %d entries with range [%" PRId64 ", %" PRId64 "]",
            mCttsTableEntries->count(), mMinCttsOffsetTimeUs, mMaxCttsOffsetTimeUs);
            mCttsTableEntries->count(), mMinCttsOffsetTicks, mMaxCttsOffsetTicks);

    mOwner->beginBox("ctts");
    mOwner->writeInt32(0);  // version=0, flags=0
    int64_t delta = mMinCttsOffsetTimeUs - getStartTimeOffsetScaledTime();
    int64_t deltaTimeUs = kMaxCttsOffsetTimeUs - getStartTimeOffsetTimeUs();
    int64_t delta = (deltaTimeUs * mTimeScale + 500000LL) / 1000000LL;
    mCttsTableEntries->adjustEntries([delta](size_t /* ix */, uint32_t (&value)[2]) {
        // entries are <count, ctts> pairs; adjust only ctts
        uint32_t duration = htonl(value[1]); // back to host byte order
+4 −0
Original line number Diff line number Diff line
@@ -83,6 +83,10 @@ private:
        kWhatSwitch                          = 'swch',
    };

    enum {
        kMaxCttsOffsetTimeUs = 1000000LL,  // 1 second
    };

    int  mFd;
    int mNextFd;
    sp<MetaData> mStartMeta;
+19 −15
Original line number Diff line number Diff line
@@ -231,14 +231,17 @@ status_t CameraService::enumerateProviders() {

    for (auto& cameraId : mCameraProviderManager->getCameraDeviceIds()) {
        String8 id8 = String8(cameraId.c_str());
        bool cameraFound = false;
        {

            Mutex::Autolock lock(mCameraStatesLock);
            auto iter = mCameraStates.find(id8);
            if (iter != mCameraStates.end()) {
                continue;
                cameraFound = true;
            }
        }

        if (!cameraFound) {
            hardware::camera::common::V1_0::CameraResourceCost cost;
            res = mCameraProviderManager->getResourceCost(cameraId, &cost);
            if (res != OK) {
@@ -255,6 +258,7 @@ status_t CameraService::enumerateProviders() {
                mCameraStates.emplace(id8,
                    std::make_shared<CameraState>(id8, cost.resourceCost, conflicting));
            }
        }

        onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);