Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_sender.cc

Issue 1296163004: Use RtcpPacket to send TMMBR in RtcpSender (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 if (numBoundingSet > 0 || numBoundingSet <= numCandidates) 699 if (numBoundingSet > 0 || numBoundingSet <= numCandidates)
700 tmmbrOwner = tmmbr_help_.IsOwner(ssrc_, numBoundingSet); 700 tmmbrOwner = tmmbr_help_.IsOwner(ssrc_, numBoundingSet);
701 if (!tmmbrOwner) { 701 if (!tmmbrOwner) {
702 // did not enter bounding set, no meaning to send this request 702 // did not enter bounding set, no meaning to send this request
703 return BuildResult::kAborted; 703 return BuildResult::kAborted;
704 } 704 }
705 } 705 }
706 } 706 }
707 707
708 if (tmmbr_send_) { 708 if (tmmbr_send_) {
709 // sanity 709 rtcp::Tmmbr tmmbr;
710 if (ctx->position + 20 >= IP_PACKET_SIZE) 710 tmmbr.From(ssrc_);
711 tmmbr.To(remote_ssrc_);
712 tmmbr.WithBitrateKbps(tmmbr_send_);
713 tmmbr.WithOverhead(packet_oh_send_);
714
715 PacketBuiltCallback callback(ctx);
716 if (!callback.BuildPacket(tmmbr))
711 return BuildResult::kTruncated; 717 return BuildResult::kTruncated;
712
713 // add TMMBR indicator
714 uint8_t FMT = 3;
715 *ctx->AllocateData(1) = 0x80 + FMT;
716 *ctx->AllocateData(1) = 205;
717
718 // Length of 4
719 *ctx->AllocateData(1) = 0;
720 *ctx->AllocateData(1) = 4;
721
722 // Add our own SSRC
723 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_);
724
725 // RFC 5104 4.2.1.2. Semantics
726
727 // SSRC of media source
728 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), 0);
729
730 // Additional Feedback Control Information (FCI)
731 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), remote_ssrc_);
732
733 uint32_t bitRate = tmmbr_send_ * 1000;
734 uint32_t mmbrExp = 0;
735 for (uint32_t i = 0; i < 64; i++) {
736 if (bitRate <= (0x1FFFFu << i)) {
737 mmbrExp = i;
738 break;
739 }
740 }
741 uint32_t mmbrMantissa = (bitRate >> mmbrExp);
742
743 *ctx->AllocateData(1) =
744 static_cast<uint8_t>((mmbrExp << 2) + ((mmbrMantissa >> 15) & 0x03));
745 *ctx->AllocateData(1) = static_cast<uint8_t>(mmbrMantissa >> 7);
746 *ctx->AllocateData(1) = static_cast<uint8_t>(
747 (mmbrMantissa << 1) + ((packet_oh_send_ >> 8) & 0x01));
748 *ctx->AllocateData(1) = static_cast<uint8_t>(packet_oh_send_);
749 } 718 }
750 return BuildResult::kSuccess; 719 return BuildResult::kSuccess;
751 } 720 }
752 721
753 RTCPSender::BuildResult RTCPSender::BuildTMMBN(RtcpContext* ctx) { 722 RTCPSender::BuildResult RTCPSender::BuildTMMBN(RtcpContext* ctx) {
754 TMMBRSet* boundingSet = tmmbr_help_.BoundingSetToSend(); 723 TMMBRSet* boundingSet = tmmbr_help_.BoundingSetToSend();
755 if (boundingSet == NULL) 724 if (boundingSet == NULL)
756 return BuildResult::kError; 725 return BuildResult::kError;
757 726
758 // sanity 727 // sanity
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 1348
1380 bool RTCPSender::AllVolatileFlagsConsumed() const { 1349 bool RTCPSender::AllVolatileFlagsConsumed() const {
1381 for (const ReportFlag& flag : report_flags_) { 1350 for (const ReportFlag& flag : report_flags_) {
1382 if (flag.is_volatile) 1351 if (flag.is_volatile)
1383 return false; 1352 return false;
1384 } 1353 }
1385 return true; 1354 return true;
1386 } 1355 }
1387 1356
1388 } // namespace webrtc 1357 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698