diff options
author | sprang <sprang@webrtc.org> | 2015-08-21 05:30:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-21 12:30:17 +0000 |
commit | 81a3e60c639b5b05486acd1fb84e376271e50012 (patch) | |
tree | a71e541f53896bf7012cb542f08386ae9246b511 | |
parent | dd4edc5813a0331049f53a93ac2404a8899e6ae8 (diff) | |
download | webrtc-81a3e60c639b5b05486acd1fb84e376271e50012.tar.gz |
Use RtcpPacket to send TMMBR in RtcpSender
BUG=webrtc:2450
Review URL: https://codereview.webrtc.org/1296163004
Cr-Commit-Position: refs/heads/master@{#9755}
-rw-r--r-- | webrtc/modules/rtp_rtcp/source/rtcp_sender.cc | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc index 5ebd4a895d..4c840372f5 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc @@ -706,46 +706,15 @@ RTCPSender::BuildResult RTCPSender::BuildTMMBR(RtcpContext* ctx) { } if (tmmbr_send_) { - // sanity - if (ctx->position + 20 >= IP_PACKET_SIZE) + rtcp::Tmmbr tmmbr; + tmmbr.From(ssrc_); + tmmbr.To(remote_ssrc_); + tmmbr.WithBitrateKbps(tmmbr_send_); + tmmbr.WithOverhead(packet_oh_send_); + + PacketBuiltCallback callback(ctx); + if (!callback.BuildPacket(tmmbr)) return BuildResult::kTruncated; - - // add TMMBR indicator - uint8_t FMT = 3; - *ctx->AllocateData(1) = 0x80 + FMT; - *ctx->AllocateData(1) = 205; - - // Length of 4 - *ctx->AllocateData(1) = 0; - *ctx->AllocateData(1) = 4; - - // Add our own SSRC - ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_); - - // RFC 5104 4.2.1.2. Semantics - - // SSRC of media source - ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), 0); - - // Additional Feedback Control Information (FCI) - ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), remote_ssrc_); - - uint32_t bitRate = tmmbr_send_ * 1000; - uint32_t mmbrExp = 0; - for (uint32_t i = 0; i < 64; i++) { - if (bitRate <= (0x1FFFFu << i)) { - mmbrExp = i; - break; - } - } - uint32_t mmbrMantissa = (bitRate >> mmbrExp); - - *ctx->AllocateData(1) = - static_cast<uint8_t>((mmbrExp << 2) + ((mmbrMantissa >> 15) & 0x03)); - *ctx->AllocateData(1) = static_cast<uint8_t>(mmbrMantissa >> 7); - *ctx->AllocateData(1) = static_cast<uint8_t>( - (mmbrMantissa << 1) + ((packet_oh_send_ >> 8) & 0x01)); - *ctx->AllocateData(1) = static_cast<uint8_t>(packet_oh_send_); } return BuildResult::kSuccess; } |