Add field trial to enable the new RTC event log format.

Bug: webrtc:8111
Change-Id: Iffcd294a8ee9342a5f1e5ad07cb320d19323e37e
Reviewed-on: https://webrtc-review.googlesource.com/c/108161
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25429}
diff --git a/logging/rtc_event_log/rtc_event_log_impl.cc b/logging/rtc_event_log/rtc_event_log_impl.cc
index 2f46e3e..c2e46a2 100644
--- a/logging/rtc_event_log/rtc_event_log_impl.cc
+++ b/logging/rtc_event_log/rtc_event_log_impl.cc
@@ -65,8 +65,10 @@
     RtcEventLog::EncodingType type) {
   switch (type) {
     case RtcEventLog::EncodingType::Legacy:
+      RTC_LOG(LS_INFO) << "Creating legacy encoder for RTC event log.";
       return absl::make_unique<RtcEventLogEncoderLegacy>();
     case RtcEventLog::EncodingType::NewFormat:
+      RTC_LOG(LS_INFO) << "Creating new format encoder for RTC event log.";
       return absl::make_unique<RtcEventLogEncoderNewFormat>();
     default:
       RTC_LOG(LS_ERROR) << "Unknown RtcEventLog encoder type (" << int(type)
diff --git a/pc/peerconnectionfactory.cc b/pc/peerconnectionfactory.cc
index edc13034..32b3980 100644
--- a/pc/peerconnectionfactory.cc
+++ b/pc/peerconnectionfactory.cc
@@ -47,6 +47,7 @@
 #include "pc/videocapturertracksource.h"
 #include "pc/videotrack.h"
 #include "rtc_base/experiments/congestion_controller_experiment.h"
+#include "system_wrappers/include/field_trial.h"
 
 namespace webrtc {
 
@@ -445,7 +446,10 @@
 
 std::unique_ptr<RtcEventLog> PeerConnectionFactory::CreateRtcEventLog_w() {
   RTC_DCHECK_RUN_ON(worker_thread_);
-  const auto encoding_type = RtcEventLog::EncodingType::Legacy;
+
+  auto encoding_type = RtcEventLog::EncodingType::Legacy;
+  if (field_trial::IsEnabled("WebRTC-RtcEventLogNewFormat"))
+    encoding_type = RtcEventLog::EncodingType::NewFormat;
   return event_log_factory_
              ? event_log_factory_->CreateRtcEventLog(encoding_type)
              : absl::make_unique<RtcEventLogNullImpl>();