OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 rtc::CritScope cs(&lock_); | 145 rtc::CritScope cs(&lock_); |
146 auto it = packet_arrival_times_.lower_bound(window_start_seq_); | 146 auto it = packet_arrival_times_.lower_bound(window_start_seq_); |
147 if (it == packet_arrival_times_.end()) { | 147 if (it == packet_arrival_times_.end()) { |
148 // Feedback for all packets already sent. | 148 // Feedback for all packets already sent. |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 // TODO(sprang): Measure receive times in microseconds and remove the | 152 // TODO(sprang): Measure receive times in microseconds and remove the |
153 // conversions below. | 153 // conversions below. |
154 const int64_t first_sequence = it->first; | 154 const int64_t first_sequence = it->first; |
155 feedback_packet->WithMediaSourceSsrc(media_ssrc_); | 155 feedback_packet->SetMediaSsrc(media_ssrc_); |
156 // Base sequence is the expected next (window_start_seq_). This is known, but | 156 // Base sequence is the expected next (window_start_seq_). This is known, but |
157 // we might not have actually received it, so the base time shall be the time | 157 // we might not have actually received it, so the base time shall be the time |
158 // of the first received packet in the feedback. | 158 // of the first received packet in the feedback. |
159 feedback_packet->WithBase(static_cast<uint16_t>(window_start_seq_ & 0xFFFF), | 159 feedback_packet->SetBase(static_cast<uint16_t>(window_start_seq_ & 0xFFFF), |
160 it->second * 1000); | 160 it->second * 1000); |
161 feedback_packet->WithFeedbackSequenceNumber(feedback_sequence_++); | 161 feedback_packet->SetFeedbackSequenceNumber(feedback_sequence_++); |
162 for (; it != packet_arrival_times_.end(); ++it) { | 162 for (; it != packet_arrival_times_.end(); ++it) { |
163 if (!feedback_packet->WithReceivedPacket( | 163 if (!feedback_packet->AddReceivedPacket( |
164 static_cast<uint16_t>(it->first & 0xFFFF), it->second * 1000)) { | 164 static_cast<uint16_t>(it->first & 0xFFFF), it->second * 1000)) { |
165 // If we can't even add the first seq to the feedback packet, we won't be | 165 // If we can't even add the first seq to the feedback packet, we won't be |
166 // able to build it at all. | 166 // able to build it at all. |
167 RTC_CHECK_NE(first_sequence, it->first); | 167 RTC_CHECK_NE(first_sequence, it->first); |
168 | 168 |
169 // Could not add timestamp, feedback packet might be full. Return and | 169 // Could not add timestamp, feedback packet might be full. Return and |
170 // try again with a fresh packet. | 170 // try again with a fresh packet. |
171 break; | 171 break; |
172 } | 172 } |
173 | 173 |
174 // Note: Don't erase items from packet_arrival_times_ after sending, in case | 174 // Note: Don't erase items from packet_arrival_times_ after sending, in case |
175 // they need to be re-sent after a reordering. Removal will be handled | 175 // they need to be re-sent after a reordering. Removal will be handled |
176 // by OnPacketArrival once packets are too old. | 176 // by OnPacketArrival once packets are too old. |
177 window_start_seq_ = it->first + 1; | 177 window_start_seq_ = it->first + 1; |
178 } | 178 } |
179 | 179 |
180 return true; | 180 return true; |
181 } | 181 } |
182 | 182 |
183 } // namespace webrtc | 183 } // namespace webrtc |
OLD | NEW |