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

Side by Side Diff: webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.cc

Issue 2997883002: Video/Screenshare loopback tool.
Patch Set: Rebase Created 3 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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/acknowledged_bitrate_estimator.h" 11 #include "webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h"
12 12
13 #include <utility> 13 #include <utility>
14 14
15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
16 #include "webrtc/rtc_base/ptr_util.h" 17 #include "webrtc/rtc_base/ptr_util.h"
17 18
18 namespace webrtc { 19 namespace webrtc {
19 20
20 namespace { 21 namespace {
21 bool IsInSendTimeHistory(const PacketFeedback& packet) { 22 bool IsInSendTimeHistory(const PacketFeedback& packet) {
22 return packet.send_time_ms >= 0; 23 return packet.send_time_ms >= 0;
23 } 24 }
24 } // namespace 25 } // namespace
25 26
27 AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator(
28 RtcEventLog* event_log)
29 : AcknowledgedBitrateEstimator(rtc::MakeUnique<BitrateEstimator>()) {
30 event_log_ = event_log;
31 }
32
26 AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator() 33 AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator()
27 : AcknowledgedBitrateEstimator(rtc::MakeUnique<BitrateEstimator>()) {} 34 : AcknowledgedBitrateEstimator(nullptr) {}
28 35
29 AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator( 36 AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator(
30 std::unique_ptr<BitrateEstimator> bitrate_estimator) 37 std::unique_ptr<BitrateEstimator> bitrate_estimator)
31 : bitrate_estimator_(std::move(bitrate_estimator)) {} 38 : bitrate_estimator_(std::move(bitrate_estimator)) {}
32 39
33 void AcknowledgedBitrateEstimator::IncomingPacketFeedbackVector( 40 void AcknowledgedBitrateEstimator::IncomingPacketFeedbackVector(
34 const std::vector<PacketFeedback>& packet_feedback_vector) { 41 const std::vector<PacketFeedback>& packet_feedback_vector) {
35 RTC_DCHECK(std::is_sorted(packet_feedback_vector.begin(), 42 RTC_DCHECK(std::is_sorted(packet_feedback_vector.begin(),
36 packet_feedback_vector.end(), 43 packet_feedback_vector.end(),
37 PacketFeedbackComparator())); 44 PacketFeedbackComparator()));
38 for (const auto& packet : packet_feedback_vector) { 45 for (const auto& packet : packet_feedback_vector) {
39 if (IsInSendTimeHistory(packet)) { 46 if (IsInSendTimeHistory(packet)) {
40 MaybeExpectFastRateChange(packet.send_time_ms); 47 MaybeExpectFastRateChange(packet.send_time_ms);
41 bitrate_estimator_->Update(packet.arrival_time_ms, packet.payload_size); 48 bitrate_estimator_->Update(packet.arrival_time_ms, packet.payload_size);
42 } 49 }
43 } 50 }
51 rtc::Optional<uint32_t> estimate = bitrate_estimator_->bitrate_bps();
52 if (event_log_)
53 event_log_->LogAckedBitrate(estimate ? *estimate : 0);
44 } 54 }
45 55
46 rtc::Optional<uint32_t> AcknowledgedBitrateEstimator::bitrate_bps() const { 56 rtc::Optional<uint32_t> AcknowledgedBitrateEstimator::bitrate_bps() const {
47 return bitrate_estimator_->bitrate_bps(); 57 return bitrate_estimator_->bitrate_bps();
48 } 58 }
49 59
50 void AcknowledgedBitrateEstimator::SetAlrEndedTimeMs( 60 void AcknowledgedBitrateEstimator::SetAlrEndedTimeMs(
51 int64_t alr_ended_time_ms) { 61 int64_t alr_ended_time_ms) {
52 alr_ended_time_ms_.emplace(alr_ended_time_ms); 62 alr_ended_time_ms_.emplace(alr_ended_time_ms);
53 } 63 }
54 64
55 void AcknowledgedBitrateEstimator::MaybeExpectFastRateChange( 65 void AcknowledgedBitrateEstimator::MaybeExpectFastRateChange(
56 int64_t packet_send_time_ms) { 66 int64_t packet_send_time_ms) {
57 if (alr_ended_time_ms_ && packet_send_time_ms > *alr_ended_time_ms_) { 67 if (alr_ended_time_ms_ && packet_send_time_ms > *alr_ended_time_ms_) {
58 bitrate_estimator_->ExpectFastRateChange(); 68 bitrate_estimator_->ExpectFastRateChange();
59 alr_ended_time_ms_.reset(); 69 alr_ended_time_ms_.reset();
60 } 70 }
61 } 71 }
62 72
63 } // namespace webrtc 73 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698