aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsprang <sprang@webrtc.org>2015-08-18 04:37:31 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-18 11:37:39 +0000
commit141c5951f4beda868797c2746002a4b1b267ab2a (patch)
tree5526ce6354c9c0dad3c18cdc0214d68d77d1ae3d
parent35ab4baa20a730de71b390008900a16563cbbe8e (diff)
downloadwebrtc-141c5951f4beda868797c2746002a4b1b267ab2a.tar.gz
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 Review URL: https://codereview.webrtc.org/1300863002 Cr-Commit-Position: refs/heads/master@{#9723}
-rw-r--r--webrtc/modules/rtp_rtcp/source/rtcp_sender.cc48
1 files changed, 40 insertions, 8 deletions
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
index 5ebd4a895d..e118fb262c 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -638,16 +638,48 @@ RTCPSender::BuildResult RTCPSender::BuildRPSI(RtcpContext* ctx) {
}
RTCPSender::BuildResult RTCPSender::BuildREMB(RtcpContext* ctx) {
- 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))
+ // sanity
+ if (ctx->position + 20 + 4 * remb_ssrcs_.size() >= IP_PACKET_SIZE)
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");