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

Commit 4838661a authored by Byeongjo Park's avatar Byeongjo Park Committed by Lajos Molnar
Browse files

VT: Enhancements on RTP depacketizer



 1) Do not merge FU pkts if rtptimes are different.
   [Problem] There was a case that Fragmented Units of RTP be merged as
     an one frame even Fragmented Units are has different timestamp.
   [Solution] Added a condition to check rtptime between Fragmented Units.

 2) Implementation of a new frame drop rule for p-frame.
   [Problem] P-frame should be dropped only if FU packets damaged
     more than half of amount of frame.
   [Solution] Implemented a rule for p-frame drop.

 3) Discards a rtp buffer that has unexpected ssrc.
   [Problem] so many packet loss observed and video loss because about
     4 different video stream coming at the same time.
   [Solution] Allow only one stream that matched SSRC of first stream.

Bug: 165061754
Merged-in: If840df274a6fc4b04910f9201359b7c09fd2bc85
Change-Id: If840df274a6fc4b04910f9201359b7c09fd2bc85
Signed-off-by: default avatarByeongjo Park <bjo.park@samsung.com>
parent 418c5da8
Loading
Loading
Loading
Loading
+13 −14
Original line number Original line Diff line number Diff line
@@ -281,8 +281,8 @@ status_t NuPlayer::RTPSource::dequeueAccessUnit(
    }
    }


    int32_t cvo;
    int32_t cvo;
    if ((*accessUnit) != NULL && (*accessUnit)->meta()->findInt32("cvo", &cvo)) {
    if ((*accessUnit) != NULL && (*accessUnit)->meta()->findInt32("cvo", &cvo) &&
        if (cvo != mLastCVOUpdated) {
            cvo != mLastCVOUpdated) {
        sp<AMessage> msg = new AMessage();
        sp<AMessage> msg = new AMessage();
        msg->setInt32("payload-type", NuPlayer::RTPSource::RTP_CVO);
        msg->setInt32("payload-type", NuPlayer::RTPSource::RTP_CVO);
        msg->setInt32("cvo", cvo);
        msg->setInt32("cvo", cvo);
@@ -295,7 +295,6 @@ status_t NuPlayer::RTPSource::dequeueAccessUnit(
        ALOGV("notify cvo updated (%d)->(%d) to upper layer", mLastCVOUpdated, cvo);
        ALOGV("notify cvo updated (%d)->(%d) to upper layer", mLastCVOUpdated, cvo);
        mLastCVOUpdated = cvo;
        mLastCVOUpdated = cvo;
    }
    }
    }


    return finalResult;
    return finalResult;
}
}
+31 −5
Original line number Original line Diff line number Diff line
@@ -280,6 +280,11 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit(
    size_t totalCount = 1;
    size_t totalCount = 1;
    bool complete = false;
    bool complete = false;


    int32_t rtpTimeStartAt;
    CHECK(buffer->meta()->findInt32("rtp-time", &rtpTimeStartAt));
    uint32_t startSeqNo = buffer->int32Data();
    bool pFrame = nalType == 0x1;

    if (data[1] & 0x40) {
    if (data[1] & 0x40) {
        // Huh? End bit also set on the first buffer.
        // Huh? End bit also set on the first buffer.


@@ -297,16 +302,20 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit(
            size_t size = buffer->size();
            size_t size = buffer->size();


            if ((uint32_t)buffer->int32Data() != expectedSeqNo) {
            if ((uint32_t)buffer->int32Data() != expectedSeqNo) {
                ALOGV("sequence not complete, expected seqNo %d, got %d",
                ALOGV("sequence not complete, expected seqNo %d, got %d, pFrame %d",
                     expectedSeqNo, (uint32_t)buffer->int32Data());
                     expectedSeqNo, (uint32_t)buffer->int32Data(), pFrame);


                if (!pFrame)
                    return WRONG_SEQUENCE_NUMBER;
                    return WRONG_SEQUENCE_NUMBER;
            }
            }


            int32_t rtpTime;
            CHECK(buffer->meta()->findInt32("rtp-time", &rtpTime));
            if (size < 2
            if (size < 2
                    || data[0] != indicator
                    || data[0] != indicator
                    || (data[1] & 0x1f) != nalType
                    || (data[1] & 0x1f) != nalType
                    || (data[1] & 0x80)) {
                    || (data[1] & 0x80)
                    || rtpTime != rtpTimeStartAt) {
                ALOGV("Ignoring malformed FU buffer.");
                ALOGV("Ignoring malformed FU buffer.");


                // Delete the whole start of the FU.
                // Delete the whole start of the FU.
@@ -324,9 +333,26 @@ ARTPAssembler::AssemblyStatus AAVCAssembler::addFragmentedNALUnit(
            totalSize += size - 2;
            totalSize += size - 2;
            ++totalCount;
            ++totalCount;


            expectedSeqNo = expectedSeqNo + 1;
            expectedSeqNo = buffer->int32Data() + 1;


            if (data[1] & 0x40) {
            if (data[1] & 0x40) {
                if (pFrame) {
                    ALOGV("checking p-frame losses.. recvBufs %d diff %d drop? %d",
                            (uint32_t)totalCount, expectedSeqNo - startSeqNo,
                            totalCount < ((expectedSeqNo - startSeqNo) / 2));
                    if (totalCount < ((expectedSeqNo - startSeqNo) / 2)) {
                        ALOGI("drop p-frame. recvBufs %d lastSeq %d startSeq %d",
                                (uint32_t)totalCount, expectedSeqNo - 1, startSeqNo);

                        it = queue->begin();
                        for (size_t i = 0; i <= totalCount; ++i) {
                            it = queue->erase(it);
                        }
                        mNextExpectedSeqNo = expectedSeqNo;

                        return MALFORMED_PACKET;
                    }
                }
                // This is the last fragment.
                // This is the last fragment.
                complete = true;
                complete = true;
                break;
                break;
+12 −2
Original line number Original line Diff line number Diff line
@@ -47,6 +47,7 @@ ARTPSource::ARTPSource(
      mFirstSysTime(0),
      mFirstSysTime(0),
      mClockRate(0),
      mClockRate(0),
      mJbTime(300), // default jitter buffer time is 300ms.
      mJbTime(300), // default jitter buffer time is 300ms.
      mFirstSsrc(0),
      mID(id),
      mID(id),
      mHighestSeqNumber(0),
      mHighestSeqNumber(0),
      mPrevExpected(0),
      mPrevExpected(0),
@@ -121,6 +122,9 @@ void ARTPSource::timeUpdate(uint32_t rtpTime, uint64_t ntpTime) {
bool ARTPSource::queuePacket(const sp<ABuffer> &buffer) {
bool ARTPSource::queuePacket(const sp<ABuffer> &buffer) {
    uint32_t seqNum = (uint32_t)buffer->int32Data();
    uint32_t seqNum = (uint32_t)buffer->int32Data();


    int32_t ssrc = 0;
    buffer->meta()->findInt32("ssrc", &ssrc);

    if (mNumBuffersReceived++ == 0 && mFirstSysTime == 0) {
    if (mNumBuffersReceived++ == 0 && mFirstSysTime == 0) {
        int32_t firstRtpTime;
        int32_t firstRtpTime;
        CHECK(buffer->meta()->findInt32("rtp-time", &firstRtpTime));
        CHECK(buffer->meta()->findInt32("rtp-time", &firstRtpTime));
@@ -128,13 +132,19 @@ bool ARTPSource::queuePacket(const sp<ABuffer> &buffer) {
        mHighestSeqNumber = seqNum;
        mHighestSeqNumber = seqNum;
        mBaseSeqNumber = seqNum;
        mBaseSeqNumber = seqNum;
        mFirstRtpTime = firstRtpTime;
        mFirstRtpTime = firstRtpTime;
        ALOGV("first-rtp arrived: first-rtp-time=%d, sys-time=%lld, seq-num=%u",
        mFirstSsrc = ssrc;
                mFirstRtpTime, (long long)mFirstSysTime, mHighestSeqNumber);
        ALOGD("first-rtp arrived: first-rtp-time=%d, sys-time=%lld, seq-num=%u, ssrc=%d",
                mFirstRtpTime, (long long)mFirstSysTime, mHighestSeqNumber, mFirstSsrc);
        mClockRate = 90000;
        mClockRate = 90000;
        mQueue.push_back(buffer);
        mQueue.push_back(buffer);
        return true;
        return true;
    }
    }


    if (mFirstSsrc != ssrc) {
        ALOGW("Discarding a buffer due to unexpected ssrc");
        return false;
    }

    // Only the lower 16-bit of the sequence numbers are transmitted,
    // Only the lower 16-bit of the sequence numbers are transmitted,
    // derive the high-order bits by choosing the candidate closest
    // derive the high-order bits by choosing the candidate closest
    // to the highest sequence number (extended to 32 bits) received so far.
    // to the highest sequence number (extended to 32 bits) received so far.
+1 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,7 @@ struct ARTPSource : public RefBase {
    int32_t mClockRate;
    int32_t mClockRate;


    uint32_t mJbTime;
    uint32_t mJbTime;
    int32_t mFirstSsrc;


private:
private: