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

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

Issue 3007983002: Implement ANA statistics. (Closed)
Patch Set: 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
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 654bc27df55a1d33bd8b2bd91940806b8be48008..07b484e15cce4ad2409d39efd398e05a736d783a 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 {
@@ -42,6 +43,17 @@ AudioNetworkAdaptorImpl::AudioNetworkAdaptorImpl(
kEventLogMinPacketLossChangeFraction)
: nullptr) {
RTC_DCHECK(controller_manager_);
+ // Set the field trial flags to determine if adaptation is enabled.
+ enable_bitrate_adaptation_ =
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-BitrateAdaptation");
+ enable_channel_adaptation_ =
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-ChannelAdaptation");
+ enable_dtx_adaptation_ =
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-DtxAdaptation");
+ enable_fec_adaptation_ =
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-FecAdaptation");
+ enable_frame_length_adaptation_ =
+ webrtc::field_trial::IsEnabled("WebRTC-Audio-FrameLengthAdaptation");
}
AudioNetworkAdaptorImpl::~AudioNetworkAdaptorImpl() = default;
@@ -118,6 +130,49 @@ AudioEncoderRuntimeConfig AudioNetworkAdaptorImpl::GetEncoderRuntimeConfig() {
controller_manager_->GetSortedControllers(last_metrics_))
controller->MakeDecision(&config);
+ // Update ANA stats.
+ auto increment_opt = [](rtc::Optional<int>& a) {
+ if (a)
+ (*a)++;
+ else
+ a = rtc::Optional<int>(1);
+ };
+ if (prev_config_) {
+ if (config.bitrate_bps != prev_config_->bitrate_bps) {
+ increment_opt(stats_.ana_bitrate_action_counter);
+ }
+ if (config.enable_dtx != prev_config_->enable_dtx) {
+ increment_opt(stats_.ana_dtx_action_counter);
+ }
+ if (config.enable_fec != prev_config_->enable_fec) {
alexnarest 2017/09/04 11:24:02 In addition I think we want to record the fact FEC
ivoc 2017/09/05 09:01:40 Another option is to add another stat for uplink p
alexnarest 2017/09/05 10:43:27 Yes, I think it is a good idea
+ increment_opt(stats_.ana_fec_action_counter);
+ }
+ if (config.frame_length_ms != prev_config_->frame_length_ms) {
alexnarest 2017/09/05 10:43:27 It would be helpful to report inc/dec counters rat
+ increment_opt(stats_.ana_frame_length_action_counter);
+ }
+ if (config.num_channels != prev_config_->num_channels) {
+ increment_opt(stats_.ana_channel_action_counter);
+ }
+ }
+ 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>();
+ }
+ if (!enable_dtx_adaptation_ && config.enable_dtx) {
+ config.enable_dtx = rtc::Optional<bool>();
+ }
+ if (!enable_fec_adaptation_ && config.enable_fec) {
alexnarest 2017/09/04 11:24:01 In addition to enable_fec we want to prevent PL sm
ivoc 2017/09/05 09:01:40 Good point, done.
+ config.enable_fec = rtc::Optional<bool>();
+ }
+ 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());
@@ -137,8 +192,7 @@ void AudioNetworkAdaptorImpl::StopDebugDump() {
AudioNetworkAdaptorImpl::AudioNetworkAdaptorStats
AudioNetworkAdaptorImpl::GetStats() const {
- // TODO(ivoc): Actually implement the stat.
- return AudioNetworkAdaptorStats();
+ return stats_;
}
void AudioNetworkAdaptorImpl::DumpNetworkMetrics() {

Powered by Google App Engine
This is Rietveld 408576698