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

Unified Diff: webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc

Issue 3007983002: Implement ANA statistics. (Closed)
Patch Set: Implemented additional stats. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc b/webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc
index 627d78a4b73c7799e93334635d217e0c73ef9eb7..64a5c414b2188e50d62f7a0ed141720ac826efbd 100644
--- a/webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc
@@ -14,6 +14,7 @@
#include "webrtc/rtc_base/logging.h"
#include "webrtc/rtc_base/timeutils.h"
+#include "webrtc/system_wrappers/include/field_trial.h"
namespace webrtc {
@@ -40,7 +41,17 @@ AudioNetworkAdaptorImpl::AudioNetworkAdaptorImpl(
kEventLogMinBitrateChangeBps,
kEventLogMinBitrateChangeFraction,
kEventLogMinPacketLossChangeFraction)
- : nullptr) {
+ : nullptr),
+ enable_bitrate_adaptation_(
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-BitrateAdaptation")),
+ enable_dtx_adaptation_(
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-DtxAdaptation")),
+ enable_fec_adaptation_(
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-FecAdaptation")),
+ enable_channel_adaptation_(
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-ChannelAdaptation")),
+ enable_frame_length_adaptation_(webrtc::field_trial::IsEnabled(
+ "WebRTC-Audio-FrameLengthAdaptation")) {
RTC_DCHECK(controller_manager_);
}
@@ -118,6 +129,58 @@ AudioEncoderRuntimeConfig AudioNetworkAdaptorImpl::GetEncoderRuntimeConfig() {
controller_manager_->GetSortedControllers(last_metrics_))
controller->MakeDecision(&config);
+ // Update ANA stats.
+ auto increment_opt = [](rtc::Optional<uint32_t>& a) {
+ if (a)
+ (*a)++;
+ else
+ a = rtc::Optional<uint32_t>(1);
ossu 2017/09/08 10:56:01 I think you could just do a = a.value_or(0) + 1 as
ivoc 2017/09/08 11:43:47 Nice! Done, although I needed to wrap the result i
ossu 2017/09/08 12:05:21 Ah, that's right. I'll try to look at getting a ne
+ };
+ if (prev_config_) {
+ if (config.bitrate_bps != prev_config_->bitrate_bps) {
+ increment_opt(stats_.bitrate_action_counter);
+ }
+ if (config.enable_dtx != prev_config_->enable_dtx) {
+ increment_opt(stats_.dtx_action_counter);
+ }
+ if (config.enable_fec != prev_config_->enable_fec) {
+ increment_opt(stats_.fec_action_counter);
+ }
+ if (config.frame_length_ms && prev_config_->frame_length_ms) {
+ if (*config.frame_length_ms > *prev_config_->frame_length_ms) {
+ increment_opt(stats_.frame_length_increase_counter);
+ } else if (*config.frame_length_ms < *prev_config_->frame_length_ms) {
+ increment_opt(stats_.frame_length_decrease_counter);
+ }
+ }
+ if (config.num_channels != prev_config_->num_channels) {
+ increment_opt(stats_.channel_action_counter);
+ }
+ if (config.uplink_packet_loss_fraction) {
+ stats_.uplink_packet_loss_fraction = rtc::Optional<double>(
+ static_cast<double>(*config.uplink_packet_loss_fraction));
ossu 2017/09/08 10:56:01 Why does this need a static_cast? Why isn't uplink
ivoc 2017/09/08 11:43:47 That's a good point, I changed the stat into a flo
+ }
+ }
+ prev_config_ = rtc::Optional<AudioEncoderRuntimeConfig>(config);
+
+ // Prevent certain controllers from taking action (determined by field trials)
+ if (!enable_bitrate_adaptation_ && config.bitrate_bps) {
+ config.bitrate_bps = rtc::Optional<int>();
ossu 2017/09/08 10:56:01 You can use .reset() to empty Optionals and save o
ivoc 2017/09/08 11:43:47 Done!
+ }
+ if (!enable_dtx_adaptation_ && config.enable_dtx) {
+ config.enable_dtx = rtc::Optional<bool>();
+ }
+ if (!enable_fec_adaptation_ && config.enable_fec) {
+ config.enable_fec = rtc::Optional<bool>();
+ config.uplink_packet_loss_fraction = rtc::Optional<float>();
+ }
+ if (!enable_frame_length_adaptation_ && config.frame_length_ms) {
+ config.frame_length_ms = rtc::Optional<int>();
+ }
+ if (!enable_channel_adaptation_ && config.num_channels) {
+ config.num_channels = rtc::Optional<size_t>();
+ }
+
if (debug_dump_writer_)
debug_dump_writer_->DumpEncoderRuntimeConfig(config, rtc::TimeMillis());
@@ -136,9 +199,7 @@ void AudioNetworkAdaptorImpl::StopDebugDump() {
}
ANAStats AudioNetworkAdaptorImpl::GetStats() const {
- // TODO(ivoc): Actually implement the stat.
- // Tracking bug: https://bugs.chromium.org/p/webrtc/issues/detail?id=8127
- return ANAStats();
+ return stats_;
}
void AudioNetworkAdaptorImpl::DumpNetworkMetrics() {
« no previous file with comments | « webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698