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 |
11 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" | 11 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <limits> | 14 #include <limits> |
15 | 15 |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
| 18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
18 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 19 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
19 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" | 20 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
21 #include "webrtc/modules/utility/include/process_thread.h" | 22 #include "webrtc/modules/utility/include/process_thread.h" |
22 #include "webrtc/system_wrappers/include/field_trial.h" | 23 #include "webrtc/system_wrappers/include/field_trial.h" |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 | 26 |
26 const int64_t kNoTimestamp = -1; | 27 const int64_t kNoTimestamp = -1; |
27 const int64_t kSendTimeHistoryWindowMs = 60000; | 28 const int64_t kSendTimeHistoryWindowMs = 60000; |
28 const int64_t kBaseTimestampScaleFactor = | 29 const int64_t kBaseTimestampScaleFactor = |
29 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 8); | 30 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 8); |
30 const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24); | 31 const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24); |
31 | 32 |
32 class PacketInfoComparator { | 33 class PacketInfoComparator { |
33 public: | 34 public: |
34 inline bool operator()(const PacketInfo& lhs, const PacketInfo& rhs) { | 35 inline bool operator()(const PacketInfo& lhs, const PacketInfo& rhs) { |
35 if (lhs.arrival_time_ms != rhs.arrival_time_ms) | 36 if (lhs.arrival_time_ms != rhs.arrival_time_ms) |
36 return lhs.arrival_time_ms < rhs.arrival_time_ms; | 37 return lhs.arrival_time_ms < rhs.arrival_time_ms; |
37 if (lhs.send_time_ms != rhs.send_time_ms) | 38 if (lhs.send_time_ms != rhs.send_time_ms) |
38 return lhs.send_time_ms < rhs.send_time_ms; | 39 return lhs.send_time_ms < rhs.send_time_ms; |
39 return lhs.sequence_number < rhs.sequence_number; | 40 return lhs.sequence_number < rhs.sequence_number; |
40 } | 41 } |
41 }; | 42 }; |
42 | 43 |
43 TransportFeedbackAdapter::TransportFeedbackAdapter( | 44 TransportFeedbackAdapter::TransportFeedbackAdapter( |
| 45 RtcEventLog* event_log, |
44 Clock* clock, | 46 Clock* clock, |
45 BitrateController* bitrate_controller) | 47 BitrateController* bitrate_controller) |
46 : send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName( | 48 : send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName( |
47 "WebRTC-SendSideBwe-WithOverhead") == | 49 "WebRTC-SendSideBwe-WithOverhead") == |
48 "Enabled"), | 50 "Enabled"), |
49 transport_overhead_bytes_per_packet_(0), | 51 transport_overhead_bytes_per_packet_(0), |
50 send_time_history_(clock, kSendTimeHistoryWindowMs), | 52 send_time_history_(clock, kSendTimeHistoryWindowMs), |
| 53 event_log_(event_log), |
51 clock_(clock), | 54 clock_(clock), |
52 current_offset_ms_(kNoTimestamp), | 55 current_offset_ms_(kNoTimestamp), |
53 last_timestamp_us_(kNoTimestamp), | 56 last_timestamp_us_(kNoTimestamp), |
54 bitrate_controller_(bitrate_controller) {} | 57 bitrate_controller_(bitrate_controller) {} |
55 | 58 |
56 TransportFeedbackAdapter::~TransportFeedbackAdapter() {} | 59 TransportFeedbackAdapter::~TransportFeedbackAdapter() {} |
57 | 60 |
58 void TransportFeedbackAdapter::InitBwe() { | 61 void TransportFeedbackAdapter::InitBwe() { |
59 rtc::CritScope cs(&bwe_lock_); | 62 rtc::CritScope cs(&bwe_lock_); |
60 delay_based_bwe_.reset(new DelayBasedBwe(clock_)); | 63 delay_based_bwe_.reset(new DelayBasedBwe(event_log_, clock_)); |
61 } | 64 } |
62 | 65 |
63 void TransportFeedbackAdapter::AddPacket(uint16_t sequence_number, | 66 void TransportFeedbackAdapter::AddPacket(uint16_t sequence_number, |
64 size_t length, | 67 size_t length, |
65 int probe_cluster_id) { | 68 int probe_cluster_id) { |
66 rtc::CritScope cs(&lock_); | 69 rtc::CritScope cs(&lock_); |
67 if (send_side_bwe_with_overhead_) { | 70 if (send_side_bwe_with_overhead_) { |
68 length += transport_overhead_bytes_per_packet_; | 71 length += transport_overhead_bytes_per_packet_; |
69 } | 72 } |
70 send_time_history_.AddAndRemoveOld(sequence_number, length, probe_cluster_id); | 73 send_time_history_.AddAndRemoveOld(sequence_number, length, probe_cluster_id); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return last_packet_feedback_vector_; | 171 return last_packet_feedback_vector_; |
169 } | 172 } |
170 | 173 |
171 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms, | 174 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms, |
172 int64_t max_rtt_ms) { | 175 int64_t max_rtt_ms) { |
173 rtc::CritScope cs(&bwe_lock_); | 176 rtc::CritScope cs(&bwe_lock_); |
174 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 177 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
175 } | 178 } |
176 | 179 |
177 } // namespace webrtc | 180 } // namespace webrtc |
OLD | NEW |