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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 readyForDelete(false) { | 122 readyForDelete(false) { |
123 } | 123 } |
124 | 124 |
125 RTCPReceiveInformation::~RTCPReceiveInformation() { | 125 RTCPReceiveInformation::~RTCPReceiveInformation() { |
126 } | 126 } |
127 | 127 |
128 // Increase size of TMMBRSet if needed, and also take care of | 128 // Increase size of TMMBRSet if needed, and also take care of |
129 // the _tmmbrSetTimeouts vector. | 129 // the _tmmbrSetTimeouts vector. |
130 void RTCPReceiveInformation::VerifyAndAllocateTMMBRSet( | 130 void RTCPReceiveInformation::VerifyAndAllocateTMMBRSet( |
131 const uint32_t minimumSize) { | 131 const uint32_t minimumSize) { |
132 if (minimumSize > TmmbrSet.sizeOfSet()) { | 132 if (minimumSize > TmmbrSet.capacity()) { |
133 TmmbrSet.VerifyAndAllocateSetKeepingData(minimumSize); | 133 TmmbrSet.reserve(minimumSize); |
134 // make sure that our buffers are big enough | 134 // make sure that our buffers are big enough |
135 _tmmbrSetTimeouts.reserve(minimumSize); | 135 _tmmbrSetTimeouts.reserve(minimumSize); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 void RTCPReceiveInformation::InsertTMMBRItem( | 139 void RTCPReceiveInformation::InsertTMMBRItem( |
140 const uint32_t senderSSRC, | 140 const uint32_t senderSSRC, |
141 const RTCPUtility::RTCPPacketRTPFBTMMBRItem& TMMBRItem, | 141 const RTCPUtility::RTCPPacketRTPFBTMMBRItem& TMMBRItem, |
142 const int64_t currentTimeMS) { | 142 const int64_t currentTimeMS) { |
143 // serach to see if we have it in our list | 143 // serach to see if we have it in our list |
144 for (uint32_t i = 0; i < TmmbrSet.lengthOfSet(); i++) { | 144 for (uint32_t i = 0; i < TmmbrSet.size(); i++) { |
145 if (TmmbrSet.Ssrc(i) == senderSSRC) { | 145 if (TmmbrSet[i].ssrc() == senderSSRC) { |
146 // we already have this SSRC in our list update it | 146 // we already have this SSRC in our list update it |
147 TmmbrSet.SetEntry(i, | 147 TmmbrSet[i].set_bitrate_bps(1000 * TMMBRItem.MaxTotalMediaBitRate); |
148 TMMBRItem.MaxTotalMediaBitRate, | 148 TmmbrSet[i].set_packet_overhead(TMMBRItem.MeasuredOverhead); |
149 TMMBRItem.MeasuredOverhead, | |
150 senderSSRC); | |
151 _tmmbrSetTimeouts[i] = currentTimeMS; | 149 _tmmbrSetTimeouts[i] = currentTimeMS; |
152 return; | 150 return; |
153 } | 151 } |
154 } | 152 } |
155 VerifyAndAllocateTMMBRSet(TmmbrSet.lengthOfSet() + 1); | 153 VerifyAndAllocateTMMBRSet(TmmbrSet.capacity() + 1); |
156 TmmbrSet.AddEntry(TMMBRItem.MaxTotalMediaBitRate, | 154 TmmbrSet.push_back(rtcp::TmmbItem(senderSSRC, |
157 TMMBRItem.MeasuredOverhead, | 155 TMMBRItem.MaxTotalMediaBitRate * 1000, |
158 senderSSRC); | 156 TMMBRItem.MeasuredOverhead)); |
159 _tmmbrSetTimeouts.push_back(currentTimeMS); | 157 _tmmbrSetTimeouts.push_back(currentTimeMS); |
160 } | 158 } |
161 | 159 |
162 int32_t RTCPReceiveInformation::GetTMMBRSet( | 160 void RTCPReceiveInformation::GetTMMBRSet( |
163 const uint32_t sourceIdx, | 161 int64_t current_time_ms, |
164 const uint32_t targetIdx, | 162 std::vector<rtcp::TmmbItem>* candidates) { |
165 TMMBRSet* candidateSet, | 163 for (size_t i = 0; i < TmmbrSet.size();) { |
166 const int64_t currentTimeMS) { | 164 // use audio define since we don't know what interval the remote peer is |
167 if (sourceIdx >= TmmbrSet.lengthOfSet()) { | 165 // using |
168 return -1; | 166 if (current_time_ms - _tmmbrSetTimeouts[i] > 5 * RTCP_INTERVAL_AUDIO_MS) { |
| 167 // value timed out |
| 168 TmmbrSet.erase(TmmbrSet.begin() + i); |
| 169 _tmmbrSetTimeouts.erase(_tmmbrSetTimeouts.begin() + i); |
| 170 } else { |
| 171 candidates->push_back(TmmbrSet[i]); |
| 172 ++i; |
| 173 } |
169 } | 174 } |
170 if (targetIdx >= candidateSet->sizeOfSet()) { | |
171 return -1; | |
172 } | |
173 // use audio define since we don't know what interval the remote peer is using | |
174 if (currentTimeMS - _tmmbrSetTimeouts[sourceIdx] > | |
175 5 * RTCP_INTERVAL_AUDIO_MS) { | |
176 // value timed out | |
177 TmmbrSet.RemoveEntry(sourceIdx); | |
178 _tmmbrSetTimeouts.erase(_tmmbrSetTimeouts.begin() + sourceIdx); | |
179 return -1; | |
180 } | |
181 candidateSet->SetEntry(targetIdx, | |
182 TmmbrSet.Tmmbr(sourceIdx), | |
183 TmmbrSet.PacketOH(sourceIdx), | |
184 TmmbrSet.Ssrc(sourceIdx)); | |
185 return 0; | |
186 } | 175 } |
187 | 176 |
188 void RTCPReceiveInformation::VerifyAndAllocateBoundingSet( | 177 void RTCPReceiveInformation::VerifyAndAllocateBoundingSet( |
189 const uint32_t minimumSize) { | 178 const uint32_t minimumSize) { |
190 TmmbnBoundingSet.VerifyAndAllocateSet(minimumSize); | 179 TmmbnBoundingSet.clear(); |
| 180 TmmbnBoundingSet.reserve(minimumSize); |
191 } | 181 } |
192 } // namespace RTCPHelp | 182 } // namespace RTCPHelp |
193 } // namespace webrtc | 183 } // namespace webrtc |
OLD | NEW |