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: 35ab4baa20
>
> 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}
This commit is contained in:
sprang
2015-08-21 04:21:51 -07:00
committed by Commit bot
parent c232096eba
commit dd4edc5813

View File

@ -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<uint8_t>(remb_ssrcs_.size() + 4);
// Add our own SSRC
ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_);
// Remote SSRC must be 0
ByteWriter<uint32_t>::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<uint8_t>((brExp << 2) + ((brMantissa >> 16) & 0x03));
*ctx->AllocateData(1) = static_cast<uint8_t>(brMantissa >> 8);
*ctx->AllocateData(1) = static_cast<uint8_t>(brMantissa);
for (size_t i = 0; i < remb_ssrcs_.size(); i++)
ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), remb_ssrcs_[i]);
TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
"RTCPSender::REMB");