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