| 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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 return BuildResult::kTruncated; | 717 return BuildResult::kTruncated; |
| 718 } | 718 } |
| 719 return BuildResult::kSuccess; | 719 return BuildResult::kSuccess; |
| 720 } | 720 } |
| 721 | 721 |
| 722 RTCPSender::BuildResult RTCPSender::BuildTMMBN(RtcpContext* ctx) { | 722 RTCPSender::BuildResult RTCPSender::BuildTMMBN(RtcpContext* ctx) { |
| 723 TMMBRSet* boundingSet = tmmbr_help_.BoundingSetToSend(); | 723 TMMBRSet* boundingSet = tmmbr_help_.BoundingSetToSend(); |
| 724 if (boundingSet == NULL) | 724 if (boundingSet == NULL) |
| 725 return BuildResult::kError; | 725 return BuildResult::kError; |
| 726 | 726 |
| 727 // sanity | 727 rtcp::Tmmbn tmmbn; |
| 728 if (ctx->position + 12 + boundingSet->lengthOfSet() * 8 >= IP_PACKET_SIZE) { | 728 tmmbn.From(ssrc_); |
| 729 LOG(LS_WARNING) << "Failed to build TMMBN."; | 729 for (uint32_t i = 0; i < boundingSet->lengthOfSet(); i++) { |
| 730 return BuildResult::kTruncated; | 730 if (boundingSet->Tmmbr(i) > 0) { |
| 731 tmmbn.WithTmmbr(boundingSet->Ssrc(i), boundingSet->Tmmbr(i), |
| 732 boundingSet->PacketOH(i)); |
| 733 } |
| 731 } | 734 } |
| 732 | 735 |
| 733 uint8_t FMT = 4; | 736 PacketBuiltCallback callback(ctx); |
| 734 // add TMMBN indicator | 737 if (!callback.BuildPacket(tmmbn)) |
| 735 *ctx->AllocateData(1) = 0x80 + FMT; | 738 return BuildResult::kTruncated; |
| 736 *ctx->AllocateData(1) = 205; | |
| 737 | |
| 738 // Add length later | |
| 739 int posLength = ctx->position; | |
| 740 ctx->AllocateData(2); | |
| 741 | |
| 742 // Add our own SSRC | |
| 743 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_); | |
| 744 | |
| 745 // RFC 5104 4.2.2.2. Semantics | |
| 746 | |
| 747 // SSRC of media source | |
| 748 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), 0); | |
| 749 | |
| 750 // Additional Feedback Control Information (FCI) | |
| 751 int numBoundingSet = 0; | |
| 752 for (uint32_t n = 0; n < boundingSet->lengthOfSet(); n++) { | |
| 753 if (boundingSet->Tmmbr(n) > 0) { | |
| 754 uint32_t tmmbrSSRC = boundingSet->Ssrc(n); | |
| 755 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), tmmbrSSRC); | |
| 756 | |
| 757 uint32_t bitRate = boundingSet->Tmmbr(n) * 1000; | |
| 758 uint32_t mmbrExp = 0; | |
| 759 for (int i = 0; i < 64; i++) { | |
| 760 if (bitRate <= (0x1FFFFu << i)) { | |
| 761 mmbrExp = i; | |
| 762 break; | |
| 763 } | |
| 764 } | |
| 765 uint32_t mmbrMantissa = (bitRate >> mmbrExp); | |
| 766 uint32_t measuredOH = boundingSet->PacketOH(n); | |
| 767 | |
| 768 *ctx->AllocateData(1) = | |
| 769 static_cast<uint8_t>((mmbrExp << 2) + ((mmbrMantissa >> 15) & 0x03)); | |
| 770 *ctx->AllocateData(1) = static_cast<uint8_t>(mmbrMantissa >> 7); | |
| 771 *ctx->AllocateData(1) = static_cast<uint8_t>((mmbrMantissa << 1) + | |
| 772 ((measuredOH >> 8) & 0x01)); | |
| 773 *ctx->AllocateData(1) = static_cast<uint8_t>(measuredOH); | |
| 774 numBoundingSet++; | |
| 775 } | |
| 776 } | |
| 777 uint16_t length = static_cast<uint16_t>(2 + 2 * numBoundingSet); | |
| 778 ctx->buffer[posLength++] = static_cast<uint8_t>(length >> 8); | |
| 779 ctx->buffer[posLength] = static_cast<uint8_t>(length); | |
| 780 | 739 |
| 781 return BuildResult::kSuccess; | 740 return BuildResult::kSuccess; |
| 782 } | 741 } |
| 783 | 742 |
| 784 RTCPSender::BuildResult RTCPSender::BuildAPP(RtcpContext* ctx) { | 743 RTCPSender::BuildResult RTCPSender::BuildAPP(RtcpContext* ctx) { |
| 785 // sanity | 744 // sanity |
| 786 if (app_data_ == NULL) { | 745 if (app_data_ == NULL) { |
| 787 LOG(LS_WARNING) << "Failed to build app specific."; | 746 LOG(LS_WARNING) << "Failed to build app specific."; |
| 788 return BuildResult::kError; | 747 return BuildResult::kError; |
| 789 } | 748 } |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 | 1307 |
| 1349 bool RTCPSender::AllVolatileFlagsConsumed() const { | 1308 bool RTCPSender::AllVolatileFlagsConsumed() const { |
| 1350 for (const ReportFlag& flag : report_flags_) { | 1309 for (const ReportFlag& flag : report_flags_) { |
| 1351 if (flag.is_volatile) | 1310 if (flag.is_volatile) |
| 1352 return false; | 1311 return false; |
| 1353 } | 1312 } |
| 1354 return true; | 1313 return true; |
| 1355 } | 1314 } |
| 1356 | 1315 |
| 1357 } // namespace webrtc | 1316 } // namespace webrtc |
| OLD | NEW |