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

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

Issue 1419503004: Set send times in send time history via OnSentPacket. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments addressed Created 5 years, 1 month 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
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
(...skipping 11 matching lines...) Expand all
22 const int64_t kNoTimestamp = -1; 22 const int64_t kNoTimestamp = -1;
23 const int64_t kSendTimeHistoryWindowMs = 10000; 23 const int64_t kSendTimeHistoryWindowMs = 10000;
24 const int64_t kBaseTimestampScaleFactor = 24 const int64_t kBaseTimestampScaleFactor =
25 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 8); 25 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 8);
26 const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24); 26 const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24);
27 27
28 TransportFeedbackAdapter::TransportFeedbackAdapter( 28 TransportFeedbackAdapter::TransportFeedbackAdapter(
29 RtcpBandwidthObserver* bandwidth_observer, 29 RtcpBandwidthObserver* bandwidth_observer,
30 Clock* clock, 30 Clock* clock,
31 ProcessThread* process_thread) 31 ProcessThread* process_thread)
32 : send_time_history_(kSendTimeHistoryWindowMs), 32 : send_time_history_(clock, kSendTimeHistoryWindowMs),
33 rtcp_bandwidth_observer_(bandwidth_observer), 33 rtcp_bandwidth_observer_(bandwidth_observer),
34 process_thread_(process_thread), 34 process_thread_(process_thread),
35 clock_(clock), 35 clock_(clock),
36 current_offset_ms_(kNoTimestamp), 36 current_offset_ms_(kNoTimestamp),
37 last_timestamp_us_(kNoTimestamp) {} 37 last_timestamp_us_(kNoTimestamp) {}
38 38
39 TransportFeedbackAdapter::~TransportFeedbackAdapter() { 39 TransportFeedbackAdapter::~TransportFeedbackAdapter() {
40 if (bitrate_estimator_.get()) 40 if (bitrate_estimator_.get())
41 process_thread_->DeRegisterModule(bitrate_estimator_.get()); 41 process_thread_->DeRegisterModule(bitrate_estimator_.get());
42 } 42 }
43 43
44 void TransportFeedbackAdapter::SetBitrateEstimator( 44 void TransportFeedbackAdapter::SetBitrateEstimator(
45 RemoteBitrateEstimator* rbe) { 45 RemoteBitrateEstimator* rbe) {
46 if (bitrate_estimator_.get() != rbe) { 46 if (bitrate_estimator_.get() != rbe) {
47 bitrate_estimator_.reset(rbe); 47 bitrate_estimator_.reset(rbe);
48 process_thread_->RegisterModule(rbe); 48 process_thread_->RegisterModule(rbe);
49 } 49 }
50 } 50 }
51 51
52 void TransportFeedbackAdapter::OnSentPacket(const PacketInfo& info) { 52 void TransportFeedbackAdapter::AddPacket(uint16_t sequence_number,
53 size_t length,
54 bool was_paced) {
53 rtc::CritScope cs(&lock_); 55 rtc::CritScope cs(&lock_);
54 send_time_history_.AddAndRemoveOld(info); 56 send_time_history_.AddAndRemoveOld(sequence_number, length, was_paced);
55 } 57 }
56 58
57 void TransportFeedbackAdapter::UpdateSendTime(uint16_t sequence_number, 59 void TransportFeedbackAdapter::OnSentPacket(uint16_t sequence_number,
58 int64_t send_time_ms) { 60 int64_t send_time_ms) {
59 rtc::CritScope cs(&lock_); 61 rtc::CritScope cs(&lock_);
60 send_time_history_.UpdateSendTime(sequence_number, send_time_ms); 62 send_time_history_.OnSentPacket(sequence_number, send_time_ms);
61 } 63 }
62 64
63 void TransportFeedbackAdapter::OnTransportFeedback( 65 void TransportFeedbackAdapter::OnTransportFeedback(
64 const rtcp::TransportFeedback& feedback) { 66 const rtcp::TransportFeedback& feedback) {
65 int64_t timestamp_us = feedback.GetBaseTimeUs(); 67 int64_t timestamp_us = feedback.GetBaseTimeUs();
66 // Add timestamp deltas to a local time base selected on first packet arrival. 68 // Add timestamp deltas to a local time base selected on first packet arrival.
67 // This won't be the true time base, but makes it easier to manually inspect 69 // This won't be the true time base, but makes it easier to manually inspect
68 // time stamps. 70 // time stamps.
69 if (last_timestamp_us_ == kNoTimestamp) { 71 if (last_timestamp_us_ == kNoTimestamp) {
70 current_offset_ms_ = clock_->TimeInMilliseconds(); 72 current_offset_ms_ = clock_->TimeInMilliseconds();
(...skipping 19 matching lines...) Expand all
90 92
91 { 93 {
92 rtc::CritScope cs(&lock_); 94 rtc::CritScope cs(&lock_);
93 size_t failed_lookups = 0; 95 size_t failed_lookups = 0;
94 int64_t offset_us = 0; 96 int64_t offset_us = 0;
95 for (auto symbol : feedback.GetStatusVector()) { 97 for (auto symbol : feedback.GetStatusVector()) {
96 if (symbol != rtcp::TransportFeedback::StatusSymbol::kNotReceived) { 98 if (symbol != rtcp::TransportFeedback::StatusSymbol::kNotReceived) {
97 RTC_DCHECK(delta_it != delta_vec.end()); 99 RTC_DCHECK(delta_it != delta_vec.end());
98 offset_us += *(delta_it++); 100 offset_us += *(delta_it++);
99 int64_t timestamp_ms = current_offset_ms_ + (offset_us / 1000); 101 int64_t timestamp_ms = current_offset_ms_ + (offset_us / 1000);
100 PacketInfo info = {timestamp_ms, 0, sequence_number, 0, false}; 102 PacketInfo info(timestamp_ms, sequence_number);
101 if (send_time_history_.GetInfo(&info, true)) { 103 if (send_time_history_.GetInfo(&info, true) && info.send_time_ms >= 0) {
102 packet_feedback_vector.push_back(info); 104 packet_feedback_vector.push_back(info);
103 } else { 105 } else {
104 ++failed_lookups; 106 ++failed_lookups;
105 } 107 }
106 } 108 }
107 ++sequence_number; 109 ++sequence_number;
108 } 110 }
109 RTC_DCHECK(delta_it == delta_vec.end()); 111 RTC_DCHECK(delta_it == delta_vec.end());
110 if (failed_lookups > 0) { 112 if (failed_lookups > 0) {
111 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups 113 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups
(...skipping 12 matching lines...) Expand all
124 rtcp_bandwidth_observer_->OnReceivedEstimatedBitrate(bitrate); 126 rtcp_bandwidth_observer_->OnReceivedEstimatedBitrate(bitrate);
125 } 127 }
126 128
127 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms, 129 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms,
128 int64_t max_rtt_ms) { 130 int64_t max_rtt_ms) {
129 RTC_DCHECK(bitrate_estimator_.get() != nullptr); 131 RTC_DCHECK(bitrate_estimator_.get() != nullptr);
130 bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); 132 bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
131 } 133 }
132 134
133 } // namespace webrtc 135 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698