Index: webrtc/modules/audio_coding/audio_network_adaptor/event_log_writer.cc |
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/event_log_writer.cc b/webrtc/modules/audio_coding/audio_network_adaptor/event_log_writer.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6d64fd740c9983f7fcffd1077f3c2b7513be28b1 |
--- /dev/null |
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/event_log_writer.cc |
@@ -0,0 +1,68 @@ |
+/* |
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#include <cmath> |
+ |
+#include "webrtc/modules/audio_coding/audio_network_adaptor/event_log_writer.h" |
+#include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
+ |
+namespace webrtc { |
+ |
+namespace { |
+constexpr int kMinBitreateChangeBps = 5000; |
minyue-webrtc
2016/12/20 10:39:29
bitrate
michaelt
2016/12/20 13:41:41
Removed
|
+constexpr float kMinPacketLossChangeFraction = 0.5; |
+} |
+ |
+EventLogWriter::EventLogWriter(RtcEventLog* event_log) |
minyue-webrtc
2016/12/20 10:39:29
I'd like to remove this constructor, put kMinBitre
michaelt
2016/12/20 13:41:41
Done.
|
+ : EventLogWriter(event_log, |
+ kMinBitreateChangeBps, |
+ kMinPacketLossChangeFraction) {} |
+ |
+EventLogWriter::EventLogWriter(RtcEventLog* event_log, |
+ int min_bitreate_change_bps, |
+ float min_packet_loss_change_fraction) |
+ : event_log_(event_log), |
+ min_bitreate_change_bps_(min_bitreate_change_bps), |
+ min_packet_loss_change_fraction_(min_packet_loss_change_fraction) { |
+ RTC_CHECK(event_log_); |
+} |
+ |
+EventLogWriter::~EventLogWriter() = default; |
+ |
+void EventLogWriter::MayLogEncoderRuntimeConfig( |
+ const AudioNetworkAdaptor::EncoderRuntimeConfig& config) { |
+ if (last_runtime_config_) { |
minyue-webrtc
2016/12/20 10:39:29
I prefer adding a
private
void LogEncoderRuntime
michaelt
2016/12/20 13:41:41
Done.
|
+ if (last_runtime_config_->num_channels != config.num_channels || |
+ last_runtime_config_->enable_dtx != config.enable_dtx || |
+ last_runtime_config_->enable_fec != config.enable_fec || |
+ last_runtime_config_->frame_length_ms != config.frame_length_ms) { |
+ event_log_->LogEncoderRuntimeConfig(config); |
+ |
+ } else if (last_runtime_config_->bitrate_bps && config.bitrate_bps && |
+ std::abs(*last_runtime_config_->bitrate_bps - |
+ *config.bitrate_bps) >= min_bitreate_change_bps_) { |
+ event_log_->LogEncoderRuntimeConfig(config); |
+ |
+ } else if (last_runtime_config_->uplink_packet_loss_fraction && |
+ config.uplink_packet_loss_fraction && |
+ std::abs(*last_runtime_config_->uplink_packet_loss_fraction - |
+ *config.uplink_packet_loss_fraction) >= |
+ min_packet_loss_change_fraction_ * |
+ *last_runtime_config_->uplink_packet_loss_fraction) { |
+ event_log_->LogEncoderRuntimeConfig(config); |
+ } |
+ |
+ } else { |
+ event_log_->LogEncoderRuntimeConfig(config); |
+ } |
+ last_runtime_config_ = |
+ rtc::Optional<AudioNetworkAdaptor::EncoderRuntimeConfig>(config); |
+} |
+} // namespace webrtc |