From dd4edc5813a0331049f53a93ac2404a8899e6ae8 Mon Sep 17 00:00:00 2001 From: sprang Date: Fri, 21 Aug 2015 04:21:51 -0700 Subject: [PATCH] Reland of Use RtcpPacket to send REMB in RtcpSender (patchset #1 id:1 of https://codereview.webrtc.org/1300863002/ ) Reason for revert: This wasn't the cause of the breakage. Re-reverting. https://code.google.com/p/webrtc/issues/detail?id=4923 Original issue's description: > Revert of Use RtcpPacket to send REMB in RtcpSender (patchset #1 id:1 of https://codereview.webrtc.org/1290573004/ ) > > Reason for revert: > A few bots started failing rtc_unittests after this was commited. Ex https://build.chromium.org/p/client.webrtc/builders/Linux64%20Debug/builds/5048 > > Original issue's description: > > Use RtcpPacket to send REMB in RtcpSender > > > > BUG=webrtc:2450 > > R=asapersson@webrtc.org > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/35ab4baa20a730de71b390008900a16563cbbe8e > > TBR=asapersson@webrtc.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:2450 > > Committed: https://crrev.com/141c5951f4beda868797c2746002a4b1b267ab2a > Cr-Commit-Position: refs/heads/master@{#9723} TBR=asapersson@webrtc.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:2450 Review URL: https://codereview.webrtc.org/1309723002 Cr-Commit-Position: refs/heads/master@{#9754} --- webrtc/modules/rtp_rtcp/source/rtcp_sender.cc | 48 ++++--------------- 1 file changed, 8 insertions(+), 40 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc index e118fb262c..5ebd4a895d 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc @@ -638,48 +638,16 @@ RTCPSender::BuildResult RTCPSender::BuildRPSI(RtcpContext* ctx) { } RTCPSender::BuildResult RTCPSender::BuildREMB(RtcpContext* ctx) { - // sanity - if (ctx->position + 20 + 4 * remb_ssrcs_.size() >= IP_PACKET_SIZE) + rtcp::Remb remb; + remb.From(ssrc_); + for (uint32_t ssrc : remb_ssrcs_) + remb.AppliesTo(ssrc); + remb.WithBitrateBps(remb_bitrate_); + + PacketBuiltCallback callback(ctx); + if (!callback.BuildPacket(remb)) return BuildResult::kTruncated; - // add application layer feedback - uint8_t FMT = 15; - *ctx->AllocateData(1) = 0x80 + FMT; - *ctx->AllocateData(1) = 206; - - *ctx->AllocateData(1) = 0; - *ctx->AllocateData(1) = static_cast(remb_ssrcs_.size() + 4); - - // Add our own SSRC - ByteWriter::WriteBigEndian(ctx->AllocateData(4), ssrc_); - - // Remote SSRC must be 0 - ByteWriter::WriteBigEndian(ctx->AllocateData(4), 0); - - *ctx->AllocateData(1) = 'R'; - *ctx->AllocateData(1) = 'E'; - *ctx->AllocateData(1) = 'M'; - *ctx->AllocateData(1) = 'B'; - - *ctx->AllocateData(1) = remb_ssrcs_.size(); - // 6 bit Exp - // 18 bit mantissa - uint8_t brExp = 0; - for (uint32_t i = 0; i < 64; i++) { - if (remb_bitrate_ <= (0x3FFFFu << i)) { - brExp = i; - break; - } - } - const uint32_t brMantissa = (remb_bitrate_ >> brExp); - *ctx->AllocateData(1) = - static_cast((brExp << 2) + ((brMantissa >> 16) & 0x03)); - *ctx->AllocateData(1) = static_cast(brMantissa >> 8); - *ctx->AllocateData(1) = static_cast(brMantissa); - - for (size_t i = 0; i < remb_ssrcs_.size(); i++) - ByteWriter::WriteBigEndian(ctx->AllocateData(4), remb_ssrcs_[i]); - TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCPSender::REMB");