OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
12 | 12 |
| 13 #include <utility> |
| 14 |
13 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
14 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
15 #include "webrtc/rtc_base/checks.h" | 17 #include "webrtc/rtc_base/checks.h" |
16 #include "webrtc/rtc_base/logging.h" | 18 #include "webrtc/rtc_base/logging.h" |
17 | 19 |
18 namespace webrtc { | 20 namespace webrtc { |
19 namespace rtcp { | 21 namespace rtcp { |
20 constexpr uint8_t SenderReport::kPacketType; | 22 constexpr uint8_t SenderReport::kPacketType; |
21 // Sender report (SR) (RFC 3550). | 23 // Sender report (SR) (RFC 3550). |
22 // 0 1 2 3 | 24 // 0 1 2 3 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Write report blocks. | 108 // Write report blocks. |
107 for (const ReportBlock& block : report_blocks_) { | 109 for (const ReportBlock& block : report_blocks_) { |
108 block.Create(packet + *index); | 110 block.Create(packet + *index); |
109 *index += ReportBlock::kLength; | 111 *index += ReportBlock::kLength; |
110 } | 112 } |
111 // Ensure bytes written match expected. | 113 // Ensure bytes written match expected. |
112 RTC_DCHECK_EQ(*index, index_end); | 114 RTC_DCHECK_EQ(*index, index_end); |
113 return true; | 115 return true; |
114 } | 116 } |
115 | 117 |
| 118 bool SenderReport::SetReportBlocks(std::vector<ReportBlock> blocks) { |
| 119 if (blocks.size() > kMaxNumberOfReportBlocks) { |
| 120 LOG(LS_WARNING) << "Max report blocks reached."; |
| 121 return false; |
| 122 } |
| 123 report_blocks_ = std::move(blocks); |
| 124 return true; |
| 125 } |
| 126 |
116 bool SenderReport::AddReportBlock(const ReportBlock& block) { | 127 bool SenderReport::AddReportBlock(const ReportBlock& block) { |
117 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { | 128 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { |
118 LOG(LS_WARNING) << "Max report blocks reached."; | 129 LOG(LS_WARNING) << "Max report blocks reached."; |
119 return false; | 130 return false; |
120 } | 131 } |
121 report_blocks_.push_back(block); | 132 report_blocks_.push_back(block); |
122 return true; | 133 return true; |
123 } | 134 } |
124 | 135 |
125 } // namespace rtcp | 136 } // namespace rtcp |
126 } // namespace webrtc | 137 } // namespace webrtc |
OLD | NEW |