Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.cc

Issue 1925643002: Reland: Deliver reordered packets in arrival time order after parsing feedback message. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/transport_feedback_adapter.h" 11 #include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h"
12 12
13 #include <algorithm>
13 #include <limits> 14 #include <limits>
14 15
15 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
17 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h" 18 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
19 #include "webrtc/modules/utility/include/process_thread.h" 20 #include "webrtc/modules/utility/include/process_thread.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 const int64_t kNoTimestamp = -1; 24 const int64_t kNoTimestamp = -1;
24 const int64_t kSendTimeHistoryWindowMs = 10000; 25 const int64_t kSendTimeHistoryWindowMs = 10000;
25 const int64_t kBaseTimestampScaleFactor = 26 const int64_t kBaseTimestampScaleFactor =
26 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 8); 27 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 8);
27 const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24); 28 const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24);
28 29
30 class PacketInfoComparator {
31 public:
32 inline bool operator()(const PacketInfo& lhs, const PacketInfo& rhs) {
33 if (lhs.arrival_time_ms != rhs.arrival_time_ms)
34 return lhs.arrival_time_ms < rhs.arrival_time_ms;
35 if (lhs.send_time_ms != rhs.send_time_ms)
36 return lhs.send_time_ms < rhs.send_time_ms;
37 return lhs.sequence_number < rhs.sequence_number;
38 }
39 };
40
29 TransportFeedbackAdapter::TransportFeedbackAdapter( 41 TransportFeedbackAdapter::TransportFeedbackAdapter(
30 BitrateController* bitrate_controller, 42 BitrateController* bitrate_controller,
31 Clock* clock) 43 Clock* clock)
32 : send_time_history_(clock, kSendTimeHistoryWindowMs), 44 : send_time_history_(clock, kSendTimeHistoryWindowMs),
33 bitrate_controller_(bitrate_controller), 45 bitrate_controller_(bitrate_controller),
34 clock_(clock), 46 clock_(clock),
35 current_offset_ms_(kNoTimestamp), 47 current_offset_ms_(kNoTimestamp),
36 last_timestamp_us_(kNoTimestamp) {} 48 last_timestamp_us_(kNoTimestamp) {}
37 49
38 TransportFeedbackAdapter::~TransportFeedbackAdapter() { 50 TransportFeedbackAdapter::~TransportFeedbackAdapter() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 int64_t timestamp_ms = current_offset_ms_ + (offset_us / 1000); 109 int64_t timestamp_ms = current_offset_ms_ + (offset_us / 1000);
98 PacketInfo info(timestamp_ms, sequence_number); 110 PacketInfo info(timestamp_ms, sequence_number);
99 if (send_time_history_.GetInfo(&info, true) && info.send_time_ms >= 0) { 111 if (send_time_history_.GetInfo(&info, true) && info.send_time_ms >= 0) {
100 packet_feedback_vector.push_back(info); 112 packet_feedback_vector.push_back(info);
101 } else { 113 } else {
102 ++failed_lookups; 114 ++failed_lookups;
103 } 115 }
104 } 116 }
105 ++sequence_number; 117 ++sequence_number;
106 } 118 }
119 std::sort(packet_feedback_vector.begin(), packet_feedback_vector.end(),
120 PacketInfoComparator());
107 RTC_DCHECK(delta_it == delta_vec.end()); 121 RTC_DCHECK(delta_it == delta_vec.end());
108 if (failed_lookups > 0) { 122 if (failed_lookups > 0) {
109 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups 123 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups
110 << " packet" << (failed_lookups > 1 ? "s" : "") 124 << " packet" << (failed_lookups > 1 ? "s" : "")
111 << ". Send time history too small?"; 125 << ". Send time history too small?";
112 } 126 }
113 } 127 }
114 128
115 RTC_DCHECK(bitrate_estimator_.get() != nullptr); 129 RTC_DCHECK(bitrate_estimator_.get() != nullptr);
116 bitrate_estimator_->IncomingPacketFeedbackVector(packet_feedback_vector); 130 bitrate_estimator_->IncomingPacketFeedbackVector(packet_feedback_vector);
117 } 131 }
118 132
119 void TransportFeedbackAdapter::OnReceiveBitrateChanged( 133 void TransportFeedbackAdapter::OnReceiveBitrateChanged(
120 const std::vector<uint32_t>& ssrcs, 134 const std::vector<uint32_t>& ssrcs,
121 uint32_t bitrate) { 135 uint32_t bitrate) {
122 bitrate_controller_->UpdateDelayBasedEstimate(bitrate); 136 bitrate_controller_->UpdateDelayBasedEstimate(bitrate);
123 } 137 }
124 138
125 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms, 139 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms,
126 int64_t max_rtt_ms) { 140 int64_t max_rtt_ms) {
127 RTC_DCHECK(bitrate_estimator_.get() != nullptr); 141 RTC_DCHECK(bitrate_estimator_.get() != nullptr);
128 bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); 142 bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
129 } 143 }
130 144
131 } // namespace webrtc 145 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698