Refactor RtcEventAudioNetworkAdaptation to store config fields directly.
The event encoders and the event log writer are updated to use the new accessor methods.
Bug: None
Change-Id: I68be6be20337eac3e5e39c7095586ebd56380829
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/417781
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45961}
diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc
index fc42907..c0cba8d 100644
--- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc
+++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc
@@ -45,7 +45,6 @@
 #include "logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h"
 #include "logging/rtc_event_log/events/rtc_event_video_send_stream_config.h"
 #include "logging/rtc_event_log/rtc_stream_config.h"
-#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
 #include "modules/rtp_rtcp/source/rtcp_packet/app.h"
 #include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
 #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h"
@@ -410,21 +409,20 @@
 
   auto* audio_network_adaptation =
       rtclog_event.mutable_audio_network_adaptation();
-  if (event.config().bitrate_bps)
-    audio_network_adaptation->set_bitrate_bps(*event.config().bitrate_bps);
-  if (event.config().frame_length_ms)
-    audio_network_adaptation->set_frame_length_ms(
-        *event.config().frame_length_ms);
-  if (event.config().uplink_packet_loss_fraction) {
+  if (event.bitrate_bps())
+    audio_network_adaptation->set_bitrate_bps(*event.bitrate_bps());
+  if (event.frame_length_ms())
+    audio_network_adaptation->set_frame_length_ms(*event.frame_length_ms());
+  if (event.uplink_packet_loss_fraction()) {
     audio_network_adaptation->set_uplink_packet_loss_fraction(
-        *event.config().uplink_packet_loss_fraction);
+        *event.uplink_packet_loss_fraction());
   }
-  if (event.config().enable_fec)
-    audio_network_adaptation->set_enable_fec(*event.config().enable_fec);
-  if (event.config().enable_dtx)
-    audio_network_adaptation->set_enable_dtx(*event.config().enable_dtx);
-  if (event.config().num_channels)
-    audio_network_adaptation->set_num_channels(*event.config().num_channels);
+  if (event.enable_fec())
+    audio_network_adaptation->set_enable_fec(*event.enable_fec());
+  if (event.enable_dtx())
+    audio_network_adaptation->set_enable_dtx(*event.enable_dtx());
+  if (event.num_channels())
+    audio_network_adaptation->set_num_channels(*event.num_channels());
 
   return Serialize(&rtclog_event);
 }
diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc
index ab7297e..762c650 100644
--- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc
+++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc
@@ -61,7 +61,6 @@
 #include "logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h"
 #include "logging/rtc_event_log/events/rtc_event_video_send_stream_config.h"
 #include "logging/rtc_event_log/rtc_stream_config.h"
-#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
 #include "modules/rtp_rtcp/include/rtp_cvo.h"
 #include "modules/rtp_rtcp/source/rtcp_packet/app.h"
 #include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
@@ -972,28 +971,27 @@
   rtclog2::AudioNetworkAdaptations* proto_batch =
       event_stream->add_audio_network_adaptations();
   proto_batch->set_timestamp_ms(base_event->timestamp_ms());
-  if (base_event->config().bitrate_bps.has_value())
-    proto_batch->set_bitrate_bps(base_event->config().bitrate_bps.value());
-  if (base_event->config().frame_length_ms.has_value()) {
-    proto_batch->set_frame_length_ms(
-        base_event->config().frame_length_ms.value());
+  if (base_event->bitrate_bps().has_value())
+    proto_batch->set_bitrate_bps(base_event->bitrate_bps().value());
+  if (base_event->frame_length_ms().has_value()) {
+    proto_batch->set_frame_length_ms(base_event->frame_length_ms().value());
   }
   std::optional<uint64_t> base_uplink_packet_loss_fraction;
-  if (base_event->config().uplink_packet_loss_fraction.has_value()) {
+  if (base_event->uplink_packet_loss_fraction().has_value()) {
     base_uplink_packet_loss_fraction = ConvertPacketLossFractionToProtoFormat(
-        base_event->config().uplink_packet_loss_fraction.value());
+        base_event->uplink_packet_loss_fraction().value());
     proto_batch->set_uplink_packet_loss_fraction(
         base_uplink_packet_loss_fraction.value());
   }
-  if (base_event->config().enable_fec.has_value())
-    proto_batch->set_enable_fec(base_event->config().enable_fec.value());
-  if (base_event->config().enable_dtx.has_value())
-    proto_batch->set_enable_dtx(base_event->config().enable_dtx.value());
+  if (base_event->enable_fec().has_value())
+    proto_batch->set_enable_fec(base_event->enable_fec().value());
+  if (base_event->enable_dtx().has_value())
+    proto_batch->set_enable_dtx(base_event->enable_dtx().value());
   // Note that `num_channels_deltas` encodes N as N-1, to keep deltas smaller,
   // but there's no reason to do the same for the base event's value, since
   // no bits will be spared.
-  if (base_event->config().num_channels.has_value())
-    proto_batch->set_num_channels(base_event->config().num_channels.value());
+  if (base_event->num_channels().has_value())
+    proto_batch->set_num_channels(base_event->num_channels().value());
 
   if (batch.size() == 1)
     return;
@@ -1016,15 +1014,15 @@
   // bitrate_bps
   for (size_t i = 0; i < values.size(); ++i) {
     const RtcEventAudioNetworkAdaptation* event = batch[i + 1];
-    if (event->config().bitrate_bps.has_value()) {
-      values[i] = ToUnsigned(event->config().bitrate_bps.value());
+    if (event->bitrate_bps().has_value()) {
+      values[i] = ToUnsigned(event->bitrate_bps().value());
     } else {
       values[i].reset();
     }
   }
   const std::optional<uint64_t> unsigned_base_bitrate_bps =
-      base_event->config().bitrate_bps.has_value()
-          ? ToUnsigned(base_event->config().bitrate_bps.value())
+      base_event->bitrate_bps().has_value()
+          ? ToUnsigned(base_event->bitrate_bps().value())
           : std::optional<uint64_t>();
   encoded_deltas = EncodeDeltas(unsigned_base_bitrate_bps, values);
   if (!encoded_deltas.empty()) {
@@ -1034,15 +1032,15 @@
   // frame_length_ms
   for (size_t i = 0; i < values.size(); ++i) {
     const RtcEventAudioNetworkAdaptation* event = batch[i + 1];
-    if (event->config().frame_length_ms.has_value()) {
-      values[i] = ToUnsigned(event->config().frame_length_ms.value());
+    if (event->frame_length_ms().has_value()) {
+      values[i] = ToUnsigned(event->frame_length_ms().value());
     } else {
       values[i].reset();
     }
   }
   const std::optional<uint64_t> unsigned_base_frame_length_ms =
-      base_event->config().frame_length_ms.has_value()
-          ? ToUnsigned(base_event->config().frame_length_ms.value())
+      base_event->frame_length_ms().has_value()
+          ? ToUnsigned(base_event->frame_length_ms().value())
           : std::optional<uint64_t>();
   encoded_deltas = EncodeDeltas(unsigned_base_frame_length_ms, values);
   if (!encoded_deltas.empty()) {
@@ -1052,9 +1050,9 @@
   // uplink_packet_loss_fraction
   for (size_t i = 0; i < values.size(); ++i) {
     const RtcEventAudioNetworkAdaptation* event = batch[i + 1];
-    if (event->config().uplink_packet_loss_fraction.has_value()) {
+    if (event->uplink_packet_loss_fraction().has_value()) {
       values[i] = ConvertPacketLossFractionToProtoFormat(
-          event->config().uplink_packet_loss_fraction.value());
+          event->uplink_packet_loss_fraction().value());
     } else {
       values[i].reset();
     }
@@ -1067,9 +1065,9 @@
   // enable_fec
   for (size_t i = 0; i < values.size(); ++i) {
     const RtcEventAudioNetworkAdaptation* event = batch[i + 1];
-    values[i] = event->config().enable_fec;
+    values[i] = event->enable_fec();
   }
-  encoded_deltas = EncodeDeltas(base_event->config().enable_fec, values);
+  encoded_deltas = EncodeDeltas(base_event->enable_fec(), values);
   if (!encoded_deltas.empty()) {
     proto_batch->set_enable_fec_deltas(encoded_deltas);
   }
@@ -1077,9 +1075,9 @@
   // enable_dtx
   for (size_t i = 0; i < values.size(); ++i) {
     const RtcEventAudioNetworkAdaptation* event = batch[i + 1];
-    values[i] = event->config().enable_dtx;
+    values[i] = event->enable_dtx();
   }
-  encoded_deltas = EncodeDeltas(base_event->config().enable_dtx, values);
+  encoded_deltas = EncodeDeltas(base_event->enable_dtx(), values);
   if (!encoded_deltas.empty()) {
     proto_batch->set_enable_dtx_deltas(encoded_deltas);
   }
@@ -1087,7 +1085,7 @@
   // num_channels
   for (size_t i = 0; i < values.size(); ++i) {
     const RtcEventAudioNetworkAdaptation* event = batch[i + 1];
-    const std::optional<size_t> num_channels = event->config().num_channels;
+    const std::optional<size_t> num_channels = event->num_channels();
     if (num_channels.has_value()) {
       // Since the number of channels is always greater than 0, we can encode
       // N channels as N-1, thereby making sure that we get smaller deltas.
@@ -1103,9 +1101,9 @@
   // In the base event, N channels encoded as N channels, but for delta
   // compression purposes, also shifted down by 1.
   std::optional<size_t> shifted_base_num_channels;
-  if (base_event->config().num_channels.has_value()) {
-    RTC_DCHECK_GT(base_event->config().num_channels.value(), 0u);
-    shifted_base_num_channels = base_event->config().num_channels.value() - 1;
+  if (base_event->num_channels().has_value()) {
+    RTC_DCHECK_GT(base_event->num_channels().value(), 0u);
+    shifted_base_num_channels = base_event->num_channels().value() - 1;
   }
   encoded_deltas = EncodeDeltas(shifted_base_num_channels, values);
   if (!encoded_deltas.empty()) {
diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc
index ac0059b..69bae30 100644
--- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc
+++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc
@@ -315,12 +315,12 @@
       event_count_);
   for (size_t i = 0; i < event_count_; ++i) {
     if (i == 0 || !force_repeated_fields_) {
-      auto runtime_config = std::make_unique<AudioEncoderRuntimeConfig>();
+      AudioEncoderRuntimeConfig runtime_config;
       const int bitrate_bps =
           checked_cast<int>(prng_.Rand(0, std::numeric_limits<int32_t>::max()));
-      runtime_config->bitrate_bps = bitrate_bps;
-      events[i] = std::make_unique<RtcEventAudioNetworkAdaptation>(
-          std::move(runtime_config));
+      runtime_config.bitrate_bps = bitrate_bps;
+      events[i] =
+          std::make_unique<RtcEventAudioNetworkAdaptation>(runtime_config);
     } else {
       events[i] = events[0]->Copy();
     }
@@ -333,11 +333,11 @@
       event_count_);
   for (size_t i = 0; i < event_count_; ++i) {
     if (i == 0 || !force_repeated_fields_) {
-      auto runtime_config = std::make_unique<AudioEncoderRuntimeConfig>();
+      AudioEncoderRuntimeConfig runtime_config;
       const int frame_length_ms = prng_.Rand(1, 1000);
-      runtime_config->frame_length_ms = frame_length_ms;
-      events[i] = std::make_unique<RtcEventAudioNetworkAdaptation>(
-          std::move(runtime_config));
+      runtime_config.frame_length_ms = frame_length_ms;
+      events[i] =
+          std::make_unique<RtcEventAudioNetworkAdaptation>(runtime_config);
     } else {
       events[i] = events[0]->Copy();
     }
@@ -352,10 +352,10 @@
     if (i == 0 || !force_repeated_fields_) {
       // To simplify the test, we just check powers of two.
       const float plr = std::pow(0.5f, prng_.Rand(1, 8));
-      auto runtime_config = std::make_unique<AudioEncoderRuntimeConfig>();
-      runtime_config->uplink_packet_loss_fraction = plr;
-      events[i] = std::make_unique<RtcEventAudioNetworkAdaptation>(
-          std::move(runtime_config));
+      AudioEncoderRuntimeConfig runtime_config;
+      runtime_config.uplink_packet_loss_fraction = plr;
+      events[i] =
+          std::make_unique<RtcEventAudioNetworkAdaptation>(runtime_config);
     } else {
       events[i] = events[0]->Copy();
     }
@@ -368,10 +368,10 @@
       event_count_);
   for (size_t i = 0; i < event_count_; ++i) {
     if (i == 0 || !force_repeated_fields_) {
-      auto runtime_config = std::make_unique<AudioEncoderRuntimeConfig>();
-      runtime_config->enable_fec = prng_.Rand<bool>();
-      events[i] = std::make_unique<RtcEventAudioNetworkAdaptation>(
-          std::move(runtime_config));
+      AudioEncoderRuntimeConfig runtime_config;
+      runtime_config.enable_fec = prng_.Rand<bool>();
+      events[i] =
+          std::make_unique<RtcEventAudioNetworkAdaptation>(runtime_config);
     } else {
       events[i] = events[0]->Copy();
     }
@@ -384,8 +384,8 @@
       event_count_);
   for (size_t i = 0; i < event_count_; ++i) {
     if (i == 0 || !force_repeated_fields_) {
-      auto runtime_config = std::make_unique<AudioEncoderRuntimeConfig>();
-      runtime_config->enable_dtx = prng_.Rand<bool>();
+      AudioEncoderRuntimeConfig runtime_config;
+      runtime_config.enable_dtx = prng_.Rand<bool>();
       events[i] = std::make_unique<RtcEventAudioNetworkAdaptation>(
           std::move(runtime_config));
     } else {
@@ -400,10 +400,10 @@
       event_count_);
   for (size_t i = 0; i < event_count_; ++i) {
     if (i == 0 || !force_repeated_fields_) {
-      auto runtime_config = std::make_unique<AudioEncoderRuntimeConfig>();
-      runtime_config->num_channels = prng_.Rand(1, 2);
-      events[i] = std::make_unique<RtcEventAudioNetworkAdaptation>(
-          std::move(runtime_config));
+      AudioEncoderRuntimeConfig runtime_config;
+      runtime_config.num_channels = prng_.Rand(1, 2);
+      events[i] =
+          std::make_unique<RtcEventAudioNetworkAdaptation>(runtime_config);
     } else {
       events[i] = events[0]->Copy();
     }
@@ -416,17 +416,17 @@
       event_count_);
   for (size_t i = 0; i < event_count_; ++i) {
     if (i == 0 || !force_repeated_fields_) {
-      auto runtime_config = std::make_unique<AudioEncoderRuntimeConfig>();
-      runtime_config->bitrate_bps =
+      AudioEncoderRuntimeConfig runtime_config;
+      runtime_config.bitrate_bps =
           checked_cast<int>(prng_.Rand(0, std::numeric_limits<int32_t>::max()));
-      runtime_config->frame_length_ms = prng_.Rand(1, 1000);
-      runtime_config->uplink_packet_loss_fraction =
+      runtime_config.frame_length_ms = prng_.Rand(1, 1000);
+      runtime_config.uplink_packet_loss_fraction =
           std::pow(0.5f, prng_.Rand(1, 8));
-      runtime_config->enable_fec = prng_.Rand<bool>();
-      runtime_config->enable_dtx = prng_.Rand<bool>();
-      runtime_config->num_channels = prng_.Rand(1, 2);
-      events[i] = std::make_unique<RtcEventAudioNetworkAdaptation>(
-          std::move(runtime_config));
+      runtime_config.enable_fec = prng_.Rand<bool>();
+      runtime_config.enable_dtx = prng_.Rand<bool>();
+      runtime_config.num_channels = prng_.Rand(1, 2);
+      events[i] =
+          std::make_unique<RtcEventAudioNetworkAdaptation>(runtime_config);
     } else {
       events[i] = events[0]->Copy();
     }
diff --git a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.cc b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.cc
index 3265bf0..7bb1c27 100644
--- a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.cc
+++ b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.cc
@@ -11,25 +11,20 @@
 #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h"
 
 #include <memory>
-#include <utility>
 
 #include "absl/memory/memory.h"
-#include "api/rtc_event_log/rtc_event.h"
 #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
-#include "rtc_base/checks.h"
 
 namespace webrtc {
 
 RtcEventAudioNetworkAdaptation::RtcEventAudioNetworkAdaptation(
-    std::unique_ptr<AudioEncoderRuntimeConfig> config)
-    : config_(std::move(config)) {
-  RTC_DCHECK(config_);
-}
-
-RtcEventAudioNetworkAdaptation::RtcEventAudioNetworkAdaptation(
-    const RtcEventAudioNetworkAdaptation& other)
-    : RtcEvent(other),
-      config_(std::make_unique<AudioEncoderRuntimeConfig>(*other.config_)) {}
+    const AudioEncoderRuntimeConfig& config)
+    : bitrate_bps_(config.bitrate_bps),
+      frame_length_ms_(config.frame_length_ms),
+      uplink_packet_loss_fraction_(config.uplink_packet_loss_fraction),
+      enable_fec_(config.enable_fec),
+      enable_dtx_(config.enable_dtx),
+      num_channels_(config.num_channels) {}
 
 RtcEventAudioNetworkAdaptation::~RtcEventAudioNetworkAdaptation() = default;
 
diff --git a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h
index 7127a94..ea78ef4 100644
--- a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h
+++ b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h
@@ -11,8 +11,10 @@
 #ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_NETWORK_ADAPTATION_H_
 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_NETWORK_ADAPTATION_H_
 
+#include <cstddef>
 #include <cstdint>
 #include <memory>
+#include <optional>
 #include <string>
 #include <vector>
 
@@ -46,7 +48,8 @@
   static constexpr Type kType = Type::AudioNetworkAdaptation;
 
   explicit RtcEventAudioNetworkAdaptation(
-      std::unique_ptr<AudioEncoderRuntimeConfig> config);
+      const AudioEncoderRuntimeConfig& config);
+
   ~RtcEventAudioNetworkAdaptation() override;
 
   Type GetType() const override { return kType; }
@@ -54,7 +57,14 @@
 
   std::unique_ptr<RtcEventAudioNetworkAdaptation> Copy() const;
 
-  const AudioEncoderRuntimeConfig& config() const { return *config_; }
+  const std::optional<int>& bitrate_bps() const { return bitrate_bps_; }
+  const std::optional<int>& frame_length_ms() const { return frame_length_ms_; }
+  const std::optional<float>& uplink_packet_loss_fraction() const {
+    return uplink_packet_loss_fraction_;
+  }
+  const std::optional<bool>& enable_fec() const { return enable_fec_; }
+  const std::optional<bool>& enable_dtx() const { return enable_dtx_; }
+  const std::optional<size_t>& num_channels() const { return num_channels_; }
 
   static std::string Encode(ArrayView<const RtcEvent*> /* batch */) {
     // TODO(terelius): Implement
@@ -70,9 +80,15 @@
   }
 
  private:
-  RtcEventAudioNetworkAdaptation(const RtcEventAudioNetworkAdaptation& other);
+  RtcEventAudioNetworkAdaptation(const RtcEventAudioNetworkAdaptation&) =
+      default;
 
-  const std::unique_ptr<const AudioEncoderRuntimeConfig> config_;
+  std::optional<int> bitrate_bps_;
+  std::optional<int> frame_length_ms_;
+  std::optional<float> uplink_packet_loss_fraction_;
+  std::optional<bool> enable_fec_;
+  std::optional<bool> enable_dtx_;
+  std::optional<size_t> num_channels_;
 };
 
 }  // namespace webrtc
diff --git a/logging/rtc_event_log/rtc_event_log_unittest_helper.cc b/logging/rtc_event_log/rtc_event_log_unittest_helper.cc
index 67f2007..9d05e0b 100644
--- a/logging/rtc_event_log/rtc_event_log_unittest_helper.cc
+++ b/logging/rtc_event_log/rtc_event_log_unittest_helper.cc
@@ -161,17 +161,16 @@
 
 std::unique_ptr<RtcEventAudioNetworkAdaptation>
 EventGenerator::NewAudioNetworkAdaptation() {
-  std::unique_ptr<AudioEncoderRuntimeConfig> config =
-      std::make_unique<AudioEncoderRuntimeConfig>();
+  AudioEncoderRuntimeConfig config;
 
-  config->bitrate_bps = prng_.Rand(0, 3000000);
-  config->enable_fec = prng_.Rand<bool>();
-  config->enable_dtx = prng_.Rand<bool>();
-  config->frame_length_ms = prng_.Rand(10, 120);
-  config->num_channels = prng_.Rand(1, 2);
-  config->uplink_packet_loss_fraction = prng_.Rand<float>();
+  config.bitrate_bps = prng_.Rand(0, 3000000);
+  config.enable_fec = prng_.Rand<bool>();
+  config.enable_dtx = prng_.Rand<bool>();
+  config.frame_length_ms = prng_.Rand(10, 120);
+  config.num_channels = prng_.Rand(1, 2);
+  config.uplink_packet_loss_fraction = prng_.Rand<float>();
 
-  return std::make_unique<RtcEventAudioNetworkAdaptation>(std::move(config));
+  return std::make_unique<RtcEventAudioNetworkAdaptation>(config);
 }
 
 std::unique_ptr<RtcEventNetEqSetMinimumDelay>
@@ -787,21 +786,18 @@
     const LoggedAudioNetworkAdaptationEvent& logged_event) const {
   EXPECT_EQ(original_event.timestamp_ms(), logged_event.log_time_ms());
 
-  EXPECT_EQ(original_event.config().bitrate_bps,
-            logged_event.config.bitrate_bps);
-  EXPECT_EQ(original_event.config().enable_dtx, logged_event.config.enable_dtx);
-  EXPECT_EQ(original_event.config().enable_fec, logged_event.config.enable_fec);
-  EXPECT_EQ(original_event.config().frame_length_ms,
+  EXPECT_EQ(original_event.bitrate_bps(), logged_event.config.bitrate_bps);
+  EXPECT_EQ(original_event.enable_dtx(), logged_event.config.enable_dtx);
+  EXPECT_EQ(original_event.enable_fec(), logged_event.config.enable_fec);
+  EXPECT_EQ(original_event.frame_length_ms(),
             logged_event.config.frame_length_ms);
-  EXPECT_EQ(original_event.config().num_channels,
-            logged_event.config.num_channels);
+  EXPECT_EQ(original_event.num_channels(), logged_event.config.num_channels);
 
   // uplink_packet_loss_fraction
-  ASSERT_EQ(original_event.config().uplink_packet_loss_fraction.has_value(),
+  ASSERT_EQ(original_event.uplink_packet_loss_fraction().has_value(),
             logged_event.config.uplink_packet_loss_fraction.has_value());
-  if (original_event.config().uplink_packet_loss_fraction.has_value()) {
-    const float original =
-        original_event.config().uplink_packet_loss_fraction.value();
+  if (original_event.uplink_packet_loss_fraction().has_value()) {
+    const float original = original_event.uplink_packet_loss_fraction().value();
     const float logged =
         logged_event.config.uplink_packet_loss_fraction.value();
     const float uplink_packet_loss_fraction_delta = std::abs(original - logged);
diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
index dd8c9fe..8388cf4 100644
--- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
+++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
@@ -55,7 +55,13 @@
     return false;
   }
   auto ana_event = static_cast<RtcEventAudioNetworkAdaptation*>(arg);
-  return ana_event->config() == config;
+  return ana_event->bitrate_bps() == config.bitrate_bps &&
+         ana_event->frame_length_ms() == config.frame_length_ms &&
+         ana_event->uplink_packet_loss_fraction() ==
+             config.uplink_packet_loss_fraction &&
+         ana_event->enable_fec() == config.enable_fec &&
+         ana_event->enable_dtx() == config.enable_dtx &&
+         ana_event->num_channels() == config.num_channels;
 }
 
 MATCHER_P(EncoderRuntimeConfigIs, config, "") {
diff --git a/modules/audio_coding/audio_network_adaptor/event_log_writer.cc b/modules/audio_coding/audio_network_adaptor/event_log_writer.cc
index e9bffa2..6ab06c5 100644
--- a/modules/audio_coding/audio_network_adaptor/event_log_writer.cc
+++ b/modules/audio_coding/audio_network_adaptor/event_log_writer.cc
@@ -15,7 +15,6 @@
 #include <cstdlib>
 #include <memory>
 #include <optional>
-#include <utility>
 
 #include "api/rtc_event_log/rtc_event_log.h"
 #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h"
@@ -67,9 +66,7 @@
 }
 
 void EventLogWriter::LogEncoderConfig(const AudioEncoderRuntimeConfig& config) {
-  auto config_copy = std::make_unique<AudioEncoderRuntimeConfig>(config);
-  event_log_->Log(
-      std::make_unique<RtcEventAudioNetworkAdaptation>(std::move(config_copy)));
+  event_log_->Log(std::make_unique<RtcEventAudioNetworkAdaptation>(config));
   last_logged_config_ = config;
 }
 
diff --git a/modules/audio_coding/audio_network_adaptor/event_log_writer_unittest.cc b/modules/audio_coding/audio_network_adaptor/event_log_writer_unittest.cc
index 1ae5794..becbcbe 100644
--- a/modules/audio_coding/audio_network_adaptor/event_log_writer_unittest.cc
+++ b/modules/audio_coding/audio_network_adaptor/event_log_writer_unittest.cc
@@ -41,7 +41,13 @@
     return false;
   }
   auto ana_event = static_cast<RtcEventAudioNetworkAdaptation*>(arg);
-  return ana_event->config() == config;
+  return ana_event->bitrate_bps() == config.bitrate_bps &&
+         ana_event->frame_length_ms() == config.frame_length_ms &&
+         ana_event->uplink_packet_loss_fraction() ==
+             config.uplink_packet_loss_fraction &&
+         ana_event->enable_fec() == config.enable_fec &&
+         ana_event->enable_dtx() == config.enable_dtx &&
+         ana_event->num_channels() == config.num_channels;
 }
 
 struct EventLogWriterStates {