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

Commit dc816386 authored by Kim Sungyeon's avatar Kim Sungyeon Committed by Lajos Molnar
Browse files

VT: ARTPWriter: Introduce Moderator logic



Moderator logic (Not enabled as default)
    - N/W can drop packets if the writer sends a large amount of data instantly.
      The dropping is severe for UDP based protocols like RTP
    - So some logic added to prevent overflow of instant high bandwidth.

Bug: 165061754
Merged-in: I60fdf8b484ab5d077d1281df69dc5996103a25c2
Change-Id: I60fdf8b484ab5d077d1281df69dc5996103a25c2
Signed-off-by: default avatarKim Sungyeon <sy85.kim@samsung.com>
parent 71a9abf6
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -570,6 +570,11 @@ void ARTPWriter::send(const sp<ABuffer> &buffer, bool isRTCP) {
            remAddr = (struct sockaddr *)&mRTPAddr;
    }

    // Unseal code if moderator is needed (prevent overflow of instant bandwidth)
    // Set limit bits per period through the moderator.
    // ex) 6KByte/10ms = 48KBit/10ms = 4.8MBit/s instant limit
    // ModerateInstantTraffic(10, 6 * 1024);

    ssize_t n = sendto(isRTCP ? mRTCPSocket : mRTPSocket,
            buffer->data(), buffer->size(), 0, remAddr, sizeSockSt);

@@ -1515,4 +1520,15 @@ void ARTPWriter::makeSocketPairAndBind(String8& localIp, int localPort,
    }
}

// TODO : Develop more advanced moderator based on AS & TMMBR value
void ARTPWriter::ModerateInstantTraffic(uint32_t samplePeriod, uint32_t limitBytes) {
    unsigned int bytes =  mTrafficRec->readBytesForLastPeriod(samplePeriod);
    if(bytes > limitBytes) {
        ALOGI("Nuclear moderator. #seq = %d \t\t %d bits / 10ms",
              mSeqNo, bytes * 8);
        usleep(4000);
        mTrafficRec->updateClock(ALooper::GetNowUs() / 1000);
    }
}

}  // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ private:
    void send(const sp<ABuffer> &buffer, bool isRTCP);
    void makeSocketPairAndBind(String8& localIp, int localPort, String8& remoteIp, int remotePort);

    void ModerateInstantTraffic(uint32_t samplePeriod, uint32_t limitBytes);
    DISALLOW_EVIL_CONSTRUCTORS(ARTPWriter);
};