Reland of "Move RtcEventLog object from inside VoiceEngine to Call.", "Fix to make the start/stop functions for the Rtc Eventlog non-virtual." and "Fix for RtcEventLog ObjC interface"

The breaking tests in Chromium have been temporarily disabled, they will be fixed and reenabled soon.

Original CLs: https://codereview.webrtc.org/1748403002/, https://codereview.webrtc.org/2107253002/ and https://codereview.webrtc.org/2106103003/.

TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org,tkchin@webrtc.org
BUG=webrtc:4741, webrtc:5603, chromium:609749

Review-Url: https://codereview.webrtc.org/2110113003
Cr-Commit-Position: refs/heads/master@{#13379}
diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc
index a6a7978..cbf9da7 100644
--- a/webrtc/call/call.cc
+++ b/webrtc/call/call.cc
@@ -35,6 +35,7 @@
 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
 #include "webrtc/modules/utility/include/process_thread.h"
+#include "webrtc/system_wrappers/include/clock.h"
 #include "webrtc/system_wrappers/include/cpu_info.h"
 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
 #include "webrtc/system_wrappers/include/metrics.h"
@@ -107,6 +108,13 @@
   void OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps,
                                  uint32_t max_padding_bitrate_bps) override;
 
+  bool StartEventLog(rtc::PlatformFile log_file,
+                     int64_t max_size_bytes) override {
+    return event_log_->StartLogging(log_file, max_size_bytes);
+  }
+
+  void StopEventLog() override { event_log_->StopLogging(); }
+
  private:
   DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet,
                              size_t length);
@@ -162,7 +170,7 @@
 
   VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
 
-  RtcEventLog* event_log_ = nullptr;
+  std::unique_ptr<webrtc::RtcEventLog> event_log_;
 
   // The following members are only accessed (exclusively) from one thread and
   // from the destructor, and therefore doesn't need any explicit
@@ -210,6 +218,7 @@
       video_network_state_(kNetworkUp),
       receive_crit_(RWLockWrapper::CreateRWLock()),
       send_crit_(RWLockWrapper::CreateRWLock()),
+      event_log_(RtcEventLog::Create(webrtc::Clock::GetRealTimeClock())),
       received_video_bytes_(0),
       received_audio_bytes_(0),
       received_rtcp_bytes_(0),
@@ -221,7 +230,8 @@
       min_allocated_send_bitrate_bps_(0),
       num_bitrate_updates_(0),
       remb_(clock_),
-      congestion_controller_(new CongestionController(clock_, this, &remb_)),
+      congestion_controller_(
+          new CongestionController(clock_, this, &remb_, event_log_.get())),
       video_send_delay_stats_(new SendDelayStats(clock_)) {
   RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
   RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
@@ -231,10 +241,6 @@
     RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
                   config.bitrate_config.start_bitrate_bps);
   }
-  if (config.audio_state.get()) {
-    ScopedVoEInterface<VoECodec> voe_codec(voice_engine());
-    event_log_ = voe_codec->GetEventLog();
-  }
 
   Trace::CreateTrace();
   call_stats_->RegisterStatsObserver(congestion_controller_.get());
@@ -243,7 +249,6 @@
       config_.bitrate_config.min_bitrate_bps,
       config_.bitrate_config.start_bitrate_bps,
       config_.bitrate_config.max_bitrate_bps);
-  congestion_controller_->GetBitrateController()->SetEventLog(event_log_);
 
   module_process_thread_->Start();
   module_process_thread_->RegisterModule(call_stats_.get());
@@ -371,8 +376,9 @@
     const webrtc::AudioReceiveStream::Config& config) {
   TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
   RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
-  AudioReceiveStream* receive_stream = new AudioReceiveStream(
-      congestion_controller_.get(), config, config_.audio_state);
+  AudioReceiveStream* receive_stream =
+      new AudioReceiveStream(congestion_controller_.get(), config,
+                             config_.audio_state, event_log_.get());
   {
     WriteLockScoped write_lock(*receive_crit_);
     RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
@@ -421,8 +427,8 @@
   VideoSendStream* send_stream = new VideoSendStream(
       num_cpu_cores_, module_process_thread_.get(), call_stats_.get(),
       congestion_controller_.get(), bitrate_allocator_.get(),
-      video_send_delay_stats_.get(), &remb_, event_log_, config, encoder_config,
-      suspended_video_send_ssrcs_);
+      video_send_delay_stats_.get(), &remb_, event_log_.get(), config,
+      encoder_config, suspended_video_send_ssrcs_);
   {
     WriteLockScoped write_lock(*send_crit_);
     for (uint32_t ssrc : config.rtp.ssrcs) {
@@ -433,8 +439,7 @@
   }
   send_stream->SignalNetworkState(video_network_state_);
   UpdateAggregateNetworkState();
-  if (event_log_)
-    event_log_->LogVideoSendStreamConfig(config);
+  event_log_->LogVideoSendStreamConfig(config);
   return send_stream;
 }
 
@@ -493,13 +498,11 @@
     if (it != config.rtp.rtx.end())
       video_receive_ssrcs_[it->second.ssrc] = receive_stream;
     video_receive_streams_.insert(receive_stream);
-
     ConfigureSync(config.sync_group);
   }
   receive_stream->SignalNetworkState(video_network_state_);
   UpdateAggregateNetworkState();
-  if (event_log_)
-    event_log_->LogVideoReceiveStreamConfig(config);
+  event_log_->LogVideoReceiveStreamConfig(config);
   return receive_stream;
 }
 
@@ -827,7 +830,7 @@
       auto status = it->second->DeliverRtp(packet, length, packet_time)
                         ? DELIVERY_OK
                         : DELIVERY_PACKET_ERROR;
-      if (status == DELIVERY_OK && event_log_)
+      if (status == DELIVERY_OK)
         event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
       return status;
     }
@@ -839,7 +842,7 @@
       auto status = it->second->DeliverRtp(packet, length, packet_time)
                         ? DELIVERY_OK
                         : DELIVERY_PACKET_ERROR;
-      if (status == DELIVERY_OK && event_log_)
+      if (status == DELIVERY_OK)
         event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
       return status;
     }