Remove encoding code from RtcEventLogImpl and use RtcEventLogEncoder instead

RtcEventLogImpl no longer hard-codes the way encoding is done. It now relies on RtcEventEncoder for it. This gives two benefits:
1. We can decide between the current encoding and the new encoding (which is still WIP) without code duplication (no need for RtcEventLogImplNew).
2. Encoding is done only when the event needs to be written to a file. This both avoids unnecessary encoding of events which don't end up getting written to a file, as well as is useful for the new, delta-based encoding, which is stateful.

BUG=webrtc:8111

Change-Id: I9517132e5f96b8059002a66fde8d42d3a678c3bb
Reviewed-on: https://webrtc-review.googlesource.com/1365
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20118}
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 d297d27..1f0f71a 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
@@ -11,6 +11,8 @@
 #include <utility>
 #include <vector>
 
+#include "logging/rtc_event_log/events/rtc_event.h"
+#include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h"
 #include "logging/rtc_event_log/mock/mock_rtc_event_log.h"
 #include "modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h"
 #include "modules/audio_coding/audio_network_adaptor/mock/mock_controller.h"
@@ -44,6 +46,14 @@
              metric.uplink_recoverable_packet_loss_fraction;
 }
 
+MATCHER_P(IsRtcEventAnaConfigEqualTo, config, "") {
+  if (arg->GetType() != RtcEvent::Type::AudioNetworkAdaptation) {
+    return false;
+  }
+  auto ana_event = static_cast<RtcEventAudioNetworkAdaptation*>(arg);
+  return *ana_event->config_ == config;
+}
+
 MATCHER_P(EncoderRuntimeConfigIs, config, "") {
   return arg.bitrate_bps == config.bitrate_bps &&
          arg.frame_length_ms == config.frame_length_ms &&
@@ -271,8 +281,7 @@
   EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_))
       .WillOnce(SetArgPointee<0>(config));
 
-  EXPECT_CALL(*states.event_log,
-              LogAudioNetworkAdaptation(EncoderRuntimeConfigIs(config)))
+  EXPECT_CALL(*states.event_log, LogProxy(IsRtcEventAnaConfigEqualTo(config)))
       .Times(1);
   states.audio_network_adaptor->GetEncoderRuntimeConfig();
 }