| OLD | NEW |
| 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 rpsi.WithPictureId(ctx->picture_id); | 631 rpsi.WithPictureId(ctx->picture_id); |
| 632 | 632 |
| 633 PacketBuiltCallback callback(ctx); | 633 PacketBuiltCallback callback(ctx); |
| 634 if (!callback.BuildPacket(rpsi)) | 634 if (!callback.BuildPacket(rpsi)) |
| 635 return BuildResult::kTruncated; | 635 return BuildResult::kTruncated; |
| 636 | 636 |
| 637 return BuildResult::kSuccess; | 637 return BuildResult::kSuccess; |
| 638 } | 638 } |
| 639 | 639 |
| 640 RTCPSender::BuildResult RTCPSender::BuildREMB(RtcpContext* ctx) { | 640 RTCPSender::BuildResult RTCPSender::BuildREMB(RtcpContext* ctx) { |
| 641 // sanity | 641 rtcp::Remb remb; |
| 642 if (ctx->position + 20 + 4 * remb_ssrcs_.size() >= IP_PACKET_SIZE) | 642 remb.From(ssrc_); |
| 643 for (uint32_t ssrc : remb_ssrcs_) |
| 644 remb.AppliesTo(ssrc); |
| 645 remb.WithBitrateBps(remb_bitrate_); |
| 646 |
| 647 PacketBuiltCallback callback(ctx); |
| 648 if (!callback.BuildPacket(remb)) |
| 643 return BuildResult::kTruncated; | 649 return BuildResult::kTruncated; |
| 644 | 650 |
| 645 // add application layer feedback | |
| 646 uint8_t FMT = 15; | |
| 647 *ctx->AllocateData(1) = 0x80 + FMT; | |
| 648 *ctx->AllocateData(1) = 206; | |
| 649 | |
| 650 *ctx->AllocateData(1) = 0; | |
| 651 *ctx->AllocateData(1) = static_cast<uint8_t>(remb_ssrcs_.size() + 4); | |
| 652 | |
| 653 // Add our own SSRC | |
| 654 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_); | |
| 655 | |
| 656 // Remote SSRC must be 0 | |
| 657 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), 0); | |
| 658 | |
| 659 *ctx->AllocateData(1) = 'R'; | |
| 660 *ctx->AllocateData(1) = 'E'; | |
| 661 *ctx->AllocateData(1) = 'M'; | |
| 662 *ctx->AllocateData(1) = 'B'; | |
| 663 | |
| 664 *ctx->AllocateData(1) = remb_ssrcs_.size(); | |
| 665 // 6 bit Exp | |
| 666 // 18 bit mantissa | |
| 667 uint8_t brExp = 0; | |
| 668 for (uint32_t i = 0; i < 64; i++) { | |
| 669 if (remb_bitrate_ <= (0x3FFFFu << i)) { | |
| 670 brExp = i; | |
| 671 break; | |
| 672 } | |
| 673 } | |
| 674 const uint32_t brMantissa = (remb_bitrate_ >> brExp); | |
| 675 *ctx->AllocateData(1) = | |
| 676 static_cast<uint8_t>((brExp << 2) + ((brMantissa >> 16) & 0x03)); | |
| 677 *ctx->AllocateData(1) = static_cast<uint8_t>(brMantissa >> 8); | |
| 678 *ctx->AllocateData(1) = static_cast<uint8_t>(brMantissa); | |
| 679 | |
| 680 for (size_t i = 0; i < remb_ssrcs_.size(); i++) | |
| 681 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), remb_ssrcs_[i]); | |
| 682 | |
| 683 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 651 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
| 684 "RTCPSender::REMB"); | 652 "RTCPSender::REMB"); |
| 685 | 653 |
| 686 return BuildResult::kSuccess; | 654 return BuildResult::kSuccess; |
| 687 } | 655 } |
| 688 | 656 |
| 689 void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) { | 657 void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) { |
| 690 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); | 658 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); |
| 691 tmmbr_send_ = target_bitrate / 1000; | 659 tmmbr_send_ = target_bitrate / 1000; |
| 692 } | 660 } |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 | 1379 |
| 1412 bool RTCPSender::AllVolatileFlagsConsumed() const { | 1380 bool RTCPSender::AllVolatileFlagsConsumed() const { |
| 1413 for (const ReportFlag& flag : report_flags_) { | 1381 for (const ReportFlag& flag : report_flags_) { |
| 1414 if (flag.is_volatile) | 1382 if (flag.is_volatile) |
| 1415 return false; | 1383 return false; |
| 1416 } | 1384 } |
| 1417 return true; | 1385 return true; |
| 1418 } | 1386 } |
| 1419 | 1387 |
| 1420 } // namespace webrtc | 1388 } // namespace webrtc |
| OLD | NEW |