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

Side by Side Diff: webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc

Issue 2745473003: Resolve cyclic dependency between audio network adaptor and event log api (Closed)
Patch Set: Revert "Activated checks for rtc_event_log_api" Created 3 years, 8 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void FrameLengthController::UpdateNetworkMetrics( 58 void FrameLengthController::UpdateNetworkMetrics(
59 const NetworkMetrics& network_metrics) { 59 const NetworkMetrics& network_metrics) {
60 if (network_metrics.uplink_bandwidth_bps) 60 if (network_metrics.uplink_bandwidth_bps)
61 uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps; 61 uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps;
62 if (network_metrics.uplink_packet_loss_fraction) 62 if (network_metrics.uplink_packet_loss_fraction)
63 uplink_packet_loss_fraction_ = network_metrics.uplink_packet_loss_fraction; 63 uplink_packet_loss_fraction_ = network_metrics.uplink_packet_loss_fraction;
64 if (network_metrics.overhead_bytes_per_packet) 64 if (network_metrics.overhead_bytes_per_packet)
65 overhead_bytes_per_packet_ = network_metrics.overhead_bytes_per_packet; 65 overhead_bytes_per_packet_ = network_metrics.overhead_bytes_per_packet;
66 } 66 }
67 67
68 void FrameLengthController::MakeDecision( 68 void FrameLengthController::MakeDecision(AudioEncoderRuntimeConfig* config) {
69 AudioNetworkAdaptor::EncoderRuntimeConfig* config) {
70 // Decision on |frame_length_ms| should not have been made. 69 // Decision on |frame_length_ms| should not have been made.
71 RTC_DCHECK(!config->frame_length_ms); 70 RTC_DCHECK(!config->frame_length_ms);
72 71
73 if (FrameLengthIncreasingDecision(*config)) { 72 if (FrameLengthIncreasingDecision(*config)) {
74 ++frame_length_ms_; 73 ++frame_length_ms_;
75 } else if (FrameLengthDecreasingDecision(*config)) { 74 } else if (FrameLengthDecreasingDecision(*config)) {
76 --frame_length_ms_; 75 --frame_length_ms_;
77 } 76 }
78 config->frame_length_ms = rtc::Optional<int>(*frame_length_ms_); 77 config->frame_length_ms = rtc::Optional<int>(*frame_length_ms_);
79 } 78 }
80 79
81 FrameLengthController::Config::FrameLengthChange::FrameLengthChange( 80 FrameLengthController::Config::FrameLengthChange::FrameLengthChange(
82 int from_frame_length_ms, 81 int from_frame_length_ms,
83 int to_frame_length_ms) 82 int to_frame_length_ms)
84 : from_frame_length_ms(from_frame_length_ms), 83 : from_frame_length_ms(from_frame_length_ms),
85 to_frame_length_ms(to_frame_length_ms) {} 84 to_frame_length_ms(to_frame_length_ms) {}
86 85
87 bool FrameLengthController::Config::FrameLengthChange::operator<( 86 bool FrameLengthController::Config::FrameLengthChange::operator<(
88 const FrameLengthChange& rhs) const { 87 const FrameLengthChange& rhs) const {
89 return from_frame_length_ms < rhs.from_frame_length_ms || 88 return from_frame_length_ms < rhs.from_frame_length_ms ||
90 (from_frame_length_ms == rhs.from_frame_length_ms && 89 (from_frame_length_ms == rhs.from_frame_length_ms &&
91 to_frame_length_ms < rhs.to_frame_length_ms); 90 to_frame_length_ms < rhs.to_frame_length_ms);
92 } 91 }
93 92
94 bool FrameLengthController::FrameLengthIncreasingDecision( 93 bool FrameLengthController::FrameLengthIncreasingDecision(
95 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) const { 94 const AudioEncoderRuntimeConfig& config) const {
96 // Increase frame length if 95 // Increase frame length if
97 // 1. |uplink_bandwidth_bps| is known to be smaller or equal than 96 // 1. |uplink_bandwidth_bps| is known to be smaller or equal than
98 // |min_encoder_bitrate_bps| plus |prevent_overuse_margin_bps| plus the 97 // |min_encoder_bitrate_bps| plus |prevent_overuse_margin_bps| plus the
99 // current overhead rate OR all the following: 98 // current overhead rate OR all the following:
100 // 2. longer frame length is available AND 99 // 2. longer frame length is available AND
101 // 3. |uplink_bandwidth_bps| is known to be smaller than a threshold AND 100 // 3. |uplink_bandwidth_bps| is known to be smaller than a threshold AND
102 // 4. |uplink_packet_loss_fraction| is known to be smaller than a threshold 101 // 4. |uplink_packet_loss_fraction| is known to be smaller than a threshold
103 // AND 102 // AND
104 // 5. FEC is not decided or is OFF. 103 // 5. FEC is not decided or is OFF.
105 104
(...skipping 16 matching lines...) Expand all
122 121
123 return (uplink_bandwidth_bps_ && 122 return (uplink_bandwidth_bps_ &&
124 *uplink_bandwidth_bps_ <= increase_threshold->second) && 123 *uplink_bandwidth_bps_ <= increase_threshold->second) &&
125 (uplink_packet_loss_fraction_ && 124 (uplink_packet_loss_fraction_ &&
126 *uplink_packet_loss_fraction_ <= 125 *uplink_packet_loss_fraction_ <=
127 config_.fl_increasing_packet_loss_fraction) && 126 config_.fl_increasing_packet_loss_fraction) &&
128 !config.enable_fec.value_or(false); 127 !config.enable_fec.value_or(false);
129 } 128 }
130 129
131 bool FrameLengthController::FrameLengthDecreasingDecision( 130 bool FrameLengthController::FrameLengthDecreasingDecision(
132 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) const { 131 const AudioEncoderRuntimeConfig& config) const {
133 // Decrease frame length if 132 // Decrease frame length if
134 // 1. shorter frame length is available AND 133 // 1. shorter frame length is available AND
135 // 2. |uplink_bandwidth_bps| is known to be bigger than 134 // 2. |uplink_bandwidth_bps| is known to be bigger than
136 // |min_encoder_bitrate_bps| plus |prevent_overuse_margin_bps| plus the 135 // |min_encoder_bitrate_bps| plus |prevent_overuse_margin_bps| plus the
137 // overhead which would be produced with the shorter frame length AND 136 // overhead which would be produced with the shorter frame length AND
138 // one or more of the followings: 137 // one or more of the followings:
139 // 3. |uplink_bandwidth_bps| is known to be larger than a threshold, 138 // 3. |uplink_bandwidth_bps| is known to be larger than a threshold,
140 // 4. |uplink_packet_loss_fraction| is known to be larger than a threshold, 139 // 4. |uplink_packet_loss_fraction| is known to be larger than a threshold,
141 // 5. FEC is decided ON. 140 // 5. FEC is decided ON.
142 if (frame_length_ms_ == config_.encoder_frame_lengths_ms.begin()) 141 if (frame_length_ms_ == config_.encoder_frame_lengths_ms.begin())
(...skipping 16 matching lines...) Expand all
159 158
160 return (uplink_bandwidth_bps_ && 159 return (uplink_bandwidth_bps_ &&
161 *uplink_bandwidth_bps_ >= decrease_threshold->second) || 160 *uplink_bandwidth_bps_ >= decrease_threshold->second) ||
162 (uplink_packet_loss_fraction_ && 161 (uplink_packet_loss_fraction_ &&
163 *uplink_packet_loss_fraction_ >= 162 *uplink_packet_loss_fraction_ >=
164 config_.fl_decreasing_packet_loss_fraction) || 163 config_.fl_decreasing_packet_loss_fraction) ||
165 config.enable_fec.value_or(false); 164 config.enable_fec.value_or(false);
166 } 165 }
167 166
168 } // namespace webrtc 167 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698