| 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/remote_bitrate_estimator/remote_estimator_proxy.h" | 11 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
| 12 | 12 |
| 13 #include <limits> |
| 14 |
| 13 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/system_wrappers/include/clock.h" | 17 #include "webrtc/system_wrappers/include/clock.h" |
| 16 #include "webrtc/modules/pacing/packet_router.h" | 18 #include "webrtc/modules/pacing/packet_router.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 19 | 21 |
| 20 namespace webrtc { | 22 namespace webrtc { |
| 21 | 23 |
| 22 // TODO(sprang): Tune these! | 24 // TODO(sprang): Tune these! |
| 23 const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50; | 25 const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50; |
| 24 const int RemoteEstimatorProxy::kBackWindowMs = 500; | 26 const int RemoteEstimatorProxy::kBackWindowMs = 500; |
| 25 | 27 |
| 28 // The maximum allowed value for a timestamp in milliseconds. This is lower |
| 29 // than the numerical limit since we often convert to microseconds. |
| 30 static constexpr int64_t kMaxTimeMs = |
| 31 std::numeric_limits<int64_t>::max() / 1000; |
| 32 |
| 26 RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock, | 33 RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock, |
| 27 PacketRouter* packet_router) | 34 PacketRouter* packet_router) |
| 28 : clock_(clock), | 35 : clock_(clock), |
| 29 packet_router_(packet_router), | 36 packet_router_(packet_router), |
| 30 last_process_time_ms_(-1), | 37 last_process_time_ms_(-1), |
| 31 media_ssrc_(0), | 38 media_ssrc_(0), |
| 32 feedback_sequence_(0), | 39 feedback_sequence_(0), |
| 33 window_start_seq_(-1) {} | 40 window_start_seq_(-1) {} |
| 34 | 41 |
| 35 RemoteEstimatorProxy::~RemoteEstimatorProxy() {} | 42 RemoteEstimatorProxy::~RemoteEstimatorProxy() {} |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 RTC_DCHECK(packet_router_ != nullptr); | 89 RTC_DCHECK(packet_router_ != nullptr); |
| 83 packet_router_->SendFeedback(&feedback_packet); | 90 packet_router_->SendFeedback(&feedback_packet); |
| 84 } else { | 91 } else { |
| 85 more_to_build = false; | 92 more_to_build = false; |
| 86 } | 93 } |
| 87 } | 94 } |
| 88 } | 95 } |
| 89 | 96 |
| 90 void RemoteEstimatorProxy::OnPacketArrival(uint16_t sequence_number, | 97 void RemoteEstimatorProxy::OnPacketArrival(uint16_t sequence_number, |
| 91 int64_t arrival_time) { | 98 int64_t arrival_time) { |
| 99 if (arrival_time < 0 || arrival_time > kMaxTimeMs) { |
| 100 LOG(LS_WARNING) << "Arrival time out of bounds: " << arrival_time; |
| 101 return; |
| 102 } |
| 103 |
| 92 // TODO(holmer): We should handle a backwards wrap here if the first | 104 // TODO(holmer): We should handle a backwards wrap here if the first |
| 93 // sequence number was small and the new sequence number is large. The | 105 // sequence number was small and the new sequence number is large. The |
| 94 // SequenceNumberUnwrapper doesn't do this, so we should replace this with | 106 // SequenceNumberUnwrapper doesn't do this, so we should replace this with |
| 95 // calls to IsNewerSequenceNumber instead. | 107 // calls to IsNewerSequenceNumber instead. |
| 96 int64_t seq = unwrapper_.Unwrap(sequence_number); | 108 int64_t seq = unwrapper_.Unwrap(sequence_number); |
| 97 if (seq > window_start_seq_ + 0xFFFF / 2) { | 109 if (seq > window_start_seq_ + 0xFFFF / 2) { |
| 98 LOG(LS_WARNING) << "Skipping this sequence number (" << sequence_number | 110 LOG(LS_WARNING) << "Skipping this sequence number (" << sequence_number |
| 99 << ") since it likely is reordered, but the unwrapper" | 111 << ") since it likely is reordered, but the unwrapper" |
| 100 "failed to handle it. Feedback window starts at " | 112 "failed to handle it. Feedback window starts at " |
| 101 << window_start_seq_ << "."; | 113 << window_start_seq_ << "."; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // 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 |
| 165 // 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 |
| 166 // by OnPacketArrival once packets are too old. | 178 // by OnPacketArrival once packets are too old. |
| 167 window_start_seq_ = it->first + 1; | 179 window_start_seq_ = it->first + 1; |
| 168 } | 180 } |
| 169 | 181 |
| 170 return true; | 182 return true; |
| 171 } | 183 } |
| 172 | 184 |
| 173 } // namespace webrtc | 185 } // namespace webrtc |
| OLD | NEW |