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

Commit 71cf1e08 authored by Dichen Zhang's avatar Dichen Zhang Committed by android-build-merger
Browse files

Merge "Fix MediaMuxerTest#testWebmOutput failure bug" into qt-dev

am: e445c281

Change-Id: I8d1faa846d34b5acde3b1a08f8c8ed49195598cf
parents 6e89801b e445c281
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -62,6 +62,14 @@ sp<WebmElement> WebmFrame::SimpleBlock(uint64_t baseTimecode) const {
            mData);
}

uint64_t WebmFrame::getAbsTimecode() {
    return mAbsTimecode;
}

void WebmFrame::updateAbsTimecode(uint64_t newAbsTimecode) {
    mAbsTimecode = newAbsTimecode;
}

bool WebmFrame::operator<(const WebmFrame &other) const {
    if (this->mEos) {
        return false;
+3 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ struct WebmFrame : LightRefBase<WebmFrame> {
public:
    const int mType;
    const bool mKey;
    const uint64_t mAbsTimecode;
    uint64_t mAbsTimecode;
    const sp<ABuffer> mData;
    const bool mEos;

@@ -33,6 +33,8 @@ public:
    WebmFrame(int type, bool key, uint64_t absTimecode, MediaBufferBase *buf);
    ~WebmFrame() {}

    uint64_t getAbsTimecode();
    void updateAbsTimecode(uint64_t newAbsTimecode);
    sp<WebmElement> SimpleBlock(uint64_t baseTimecode) const;

    bool operator<(const WebmFrame &other) const;
+9 −1
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ WebmFrameSinkThread::WebmFrameSinkThread(
      mVideoFrames(videoThread->mSink),
      mAudioFrames(audioThread->mSink),
      mCues(cues),
      mStartOffsetTimecode(UINT64_MAX),
      mDone(true) {
}

@@ -92,6 +93,7 @@ WebmFrameSinkThread::WebmFrameSinkThread(
      mVideoFrames(videoSource),
      mAudioFrames(audioSource),
      mCues(cues),
      mStartOffsetTimecode(UINT64_MAX),
      mDone(true) {
}

@@ -213,6 +215,11 @@ void WebmFrameSinkThread::run() {
        const sp<WebmFrame> audioFrame = mAudioFrames.peek();
        ALOGV("a frame: %p", audioFrame.get());

        if (mStartOffsetTimecode == UINT64_MAX) {
            mStartOffsetTimecode =
                    std::min(audioFrame->getAbsTimecode(), videoFrame->getAbsTimecode());
        }

        if (videoFrame->mEos && audioFrame->mEos) {
            break;
        }
@@ -220,10 +227,12 @@ void WebmFrameSinkThread::run() {
        if (*audioFrame < *videoFrame) {
            ALOGV("take a frame");
            mAudioFrames.take();
            audioFrame->updateAbsTimecode(audioFrame->getAbsTimecode() - mStartOffsetTimecode);
            outstandingFrames.push_back(audioFrame);
        } else {
            ALOGV("take v frame");
            mVideoFrames.take();
            videoFrame->updateAbsTimecode(videoFrame->getAbsTimecode() - mStartOffsetTimecode);
            outstandingFrames.push_back(videoFrame);
            if (videoFrame->mKey)
                numVideoKeyFrames++;
@@ -350,7 +359,6 @@ void WebmFrameMediaSourceThread::run() {
        if (mStartTimeUs == kUninitialized) {
            mStartTimeUs = timestampUs;
        }
        timestampUs -= mStartTimeUs;

        if (mPaused && !mResumed) {
            lastDurationUs = timestampUs - lastTimestampUs;
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ private:
    LinkedBlockingQueue<const sp<WebmFrame> >& mVideoFrames;
    LinkedBlockingQueue<const sp<WebmFrame> >& mAudioFrames;
    List<sp<WebmElement> >& mCues;
    uint64_t mStartOffsetTimecode;

    volatile bool mDone;