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

Commit c82bb720 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "media: Support getStopTimeOffsetUs in GraphicBufferSource."

parents 71f4c630 f72cefdd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ struct LWGraphicBufferSource : public BnGraphicBufferSource {
    BnStatus setTimeLapseConfig(double fps, double captureFps) override;
    BnStatus setStartTimeUs(int64_t startTimeUs) override;
    BnStatus setStopTimeUs(int64_t stopTimeUs) override;
    BnStatus getStopTimeOffsetUs(int64_t *stopTimeOffsetUs) override;
    BnStatus setColorAspects(int32_t aspects) override;
    BnStatus setTimeOffsetUs(int64_t timeOffsetsUs) override;
    BnStatus signalEndOfInputStream() override;
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ interface IGraphicBufferSource {
    void setTimeLapseConfig(double fps, double captureFps);
    void setStartTimeUs(long startTimeUs);
    void setStopTimeUs(long stopTimeUs);
    long getStopTimeOffsetUs();
    void setColorAspects(int aspects);
    void setTimeOffsetUs(long timeOffsetsUs);
    void signalEndOfInputStream();
+8 −0
Original line number Diff line number Diff line
@@ -67,6 +67,14 @@ BnStatus LWGraphicBufferSource::setStopTimeUs(
    return toBinderStatus(mBase->setStopTimeUs(stopTimeUs));
}

BnStatus LWGraphicBufferSource::getStopTimeOffsetUs(
        int64_t *stopTimeOffsetUs) {
    return toBinderStatus(mBase->getStopTimeOffsetUs(
            [stopTimeOffsetUs](auto, auto offsetUs) {
                *stopTimeOffsetUs = offsetUs;
            }));
}

BnStatus LWGraphicBufferSource::setColorAspects(
        int32_t aspects) {
    return toBinderStatus(mBase->setColorAspects(
+10 −0
Original line number Diff line number Diff line
@@ -7201,6 +7201,16 @@ status_t ACodec::setParameters(const sp<AMessage> &params) {
            ALOGE("Failed to set parameter 'stop-time-us' (err %d)", err);
            return err;
        }

        int64_t stopTimeOffsetUs;
        err = statusFromBinderStatus(
                mGraphicBufferSource->getStopTimeOffsetUs(&stopTimeOffsetUs));

        if (err != OK) {
            ALOGE("Failed to get stop time offset (err %d)", err);
            return err;
        }
        mInputFormat->setInt64("android._stop-time-offset-us", stopTimeOffsetUs);
    }

    int32_t dummy;
+10 −1
Original line number Diff line number Diff line
@@ -1004,12 +1004,21 @@ void MediaCodecSource::onMessageReceived(const sp<AMessage> &msg) {

        mStopping = true;

        int64_t timeoutUs = kStopTimeoutUs;
        // if using surface, signal source EOS and wait for EOS to come back.
        // otherwise, stop puller (which also clears the input buffer queue)
        // and wait for the EOS message. We cannot call source->stop() because
        // the encoder may still be processing input buffers.
        if (mFlags & FLAG_USE_SURFACE_INPUT) {
            mEncoder->signalEndOfInputStream();
            // Increase the timeout if there is delay in the GraphicBufferSource
            sp<AMessage> inputFormat;
            int64_t stopTimeOffsetUs;
            if (mEncoder->getInputFormat(&inputFormat) == OK &&
                    inputFormat->findInt64("android._stop-time-offset-us", &stopTimeOffsetUs) &&
                    stopTimeOffsetUs > 0) {
                timeoutUs += stopTimeOffsetUs;
            }
        } else {
            mPuller->stop();
        }
@@ -1017,7 +1026,7 @@ void MediaCodecSource::onMessageReceived(const sp<AMessage> &msg) {
        // complete stop even if encoder/puller stalled
        sp<AMessage> timeoutMsg = new AMessage(kWhatStopStalled, mReflector);
        timeoutMsg->setInt32("generation", mGeneration);
        timeoutMsg->post(kStopTimeoutUs);
        timeoutMsg->post(timeoutUs);
        break;
    }

Loading