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/remb.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" |
12 | 12 |
13 #include <utility> | |
14 | |
15 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
19 | 17 |
20 namespace webrtc { | 18 namespace webrtc { |
21 namespace rtcp { | 19 namespace rtcp { |
22 constexpr uint8_t Remb::kFeedbackMessageType; | 20 constexpr uint8_t Remb::kFeedbackMessageType; |
23 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). | 21 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). |
24 // | 22 // |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 ssrcs_.clear(); | 74 ssrcs_.clear(); |
77 ssrcs_.reserve(number_of_ssrcs); | 75 ssrcs_.reserve(number_of_ssrcs); |
78 for (uint8_t i = 0; i < number_of_ssrcs; ++i) { | 76 for (uint8_t i = 0; i < number_of_ssrcs; ++i) { |
79 ssrcs_.push_back(ByteReader<uint32_t>::ReadBigEndian(next_ssrc)); | 77 ssrcs_.push_back(ByteReader<uint32_t>::ReadBigEndian(next_ssrc)); |
80 next_ssrc += sizeof(uint32_t); | 78 next_ssrc += sizeof(uint32_t); |
81 } | 79 } |
82 | 80 |
83 return true; | 81 return true; |
84 } | 82 } |
85 | 83 |
86 bool Remb::SetSsrcs(std::vector<uint32_t> ssrcs) { | 84 bool Remb::AppliesTo(uint32_t ssrc) { |
87 if (ssrcs.size() > kMaxNumberOfSsrcs) { | 85 if (ssrcs_.size() >= kMaxNumberOfSsrcs) { |
| 86 LOG(LS_WARNING) << "Max number of REMB feedback SSRCs reached."; |
| 87 return false; |
| 88 } |
| 89 ssrcs_.push_back(ssrc); |
| 90 return true; |
| 91 } |
| 92 |
| 93 bool Remb::AppliesToMany(const std::vector<uint32_t>& ssrcs) { |
| 94 if (ssrcs_.size() + ssrcs.size() > kMaxNumberOfSsrcs) { |
88 LOG(LS_WARNING) << "Not enough space for all given SSRCs."; | 95 LOG(LS_WARNING) << "Not enough space for all given SSRCs."; |
89 return false; | 96 return false; |
90 } | 97 } |
91 ssrcs_ = std::move(ssrcs); | 98 // Append. |
| 99 ssrcs_.insert(ssrcs_.end(), ssrcs.begin(), ssrcs.end()); |
92 return true; | 100 return true; |
93 } | 101 } |
94 | 102 |
95 bool Remb::Create(uint8_t* packet, | 103 bool Remb::Create(uint8_t* packet, |
96 size_t* index, | 104 size_t* index, |
97 size_t max_length, | 105 size_t max_length, |
98 RtcpPacket::PacketReadyCallback* callback) const { | 106 RtcpPacket::PacketReadyCallback* callback) const { |
99 while (*index + BlockLength() > max_length) { | 107 while (*index + BlockLength() > max_length) { |
100 if (!OnBufferFull(packet, index, callback)) | 108 if (!OnBufferFull(packet, index, callback)) |
101 return false; | 109 return false; |
(...skipping 21 matching lines...) Expand all Loading... |
123 | 131 |
124 for (uint32_t ssrc : ssrcs_) { | 132 for (uint32_t ssrc : ssrcs_) { |
125 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, ssrc); | 133 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, ssrc); |
126 *index += sizeof(uint32_t); | 134 *index += sizeof(uint32_t); |
127 } | 135 } |
128 RTC_DCHECK_EQ(index_end, *index); | 136 RTC_DCHECK_EQ(index_end, *index); |
129 return true; | 137 return true; |
130 } | 138 } |
131 } // namespace rtcp | 139 } // namespace rtcp |
132 } // namespace webrtc | 140 } // namespace webrtc |
OLD | NEW |