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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 return false; | 45 return false; |
46 it->second.send_time_ms = send_time_ms; | 46 it->second.send_time_ms = send_time_ms; |
47 return true; | 47 return true; |
48 } | 48 } |
49 | 49 |
50 bool SendTimeHistory::GetFeedback(PacketFeedback* packet_feedback, | 50 bool SendTimeHistory::GetFeedback(PacketFeedback* packet_feedback, |
51 bool remove) { | 51 bool remove) { |
52 RTC_DCHECK(packet_feedback); | 52 RTC_DCHECK(packet_feedback); |
53 int64_t unwrapped_seq_num = | 53 int64_t unwrapped_seq_num = |
54 seq_num_unwrapper_.Unwrap(packet_feedback->sequence_number); | 54 seq_num_unwrapper_.Unwrap(packet_feedback->sequence_number); |
| 55 latest_acked_seq_num_.emplace( |
| 56 std::max(unwrapped_seq_num, latest_acked_seq_num_.value_or(0))); |
| 57 RTC_DCHECK_GE(*latest_acked_seq_num_, 0); |
55 auto it = history_.find(unwrapped_seq_num); | 58 auto it = history_.find(unwrapped_seq_num); |
56 if (it == history_.end()) | 59 if (it == history_.end()) |
57 return false; | 60 return false; |
58 | 61 |
59 // Save arrival_time not to overwrite it. | 62 // Save arrival_time not to overwrite it. |
60 int64_t arrival_time_ms = packet_feedback->arrival_time_ms; | 63 int64_t arrival_time_ms = packet_feedback->arrival_time_ms; |
61 *packet_feedback = it->second; | 64 *packet_feedback = it->second; |
62 packet_feedback->arrival_time_ms = arrival_time_ms; | 65 packet_feedback->arrival_time_ms = arrival_time_ms; |
63 | 66 |
64 if (remove) | 67 if (remove) |
65 history_.erase(it); | 68 history_.erase(it); |
66 return true; | 69 return true; |
67 } | 70 } |
68 | 71 |
| 72 size_t SendTimeHistory::GetOutstandingBytes(uint16_t local_net_id, |
| 73 uint16_t remote_net_id) const { |
| 74 size_t outstanding_bytes = 0; |
| 75 auto unacked_it = history_.begin(); |
| 76 if (latest_acked_seq_num_) { |
| 77 unacked_it = history_.lower_bound(*latest_acked_seq_num_); |
| 78 } |
| 79 for (; unacked_it != history_.end(); ++unacked_it) { |
| 80 if (unacked_it->second.local_net_id == local_net_id && |
| 81 unacked_it->second.remote_net_id == remote_net_id && |
| 82 unacked_it->second.send_time_ms >= 0) { |
| 83 outstanding_bytes += unacked_it->second.payload_size; |
| 84 } |
| 85 } |
| 86 return outstanding_bytes; |
| 87 } |
| 88 |
69 } // namespace webrtc | 89 } // namespace webrtc |
OLD | NEW |