Refactoring PayloadRouter.

- Move PayloadRouter to RtpTransportControllerInterface.
- Move RetransmissionLimiter inside RtpTransportControllerSend from
  VideoSendStreamImpl.
- Move video RTP specifics into PayloadRouter, in particular ownership
  of the RTP modules.
- PayloadRouter now contains all video specific RTP code, and will be
  renamed in a follow-up to VideoRtpSender.
- Introduce VideoRtpSenderInterface.

Bug: webrtc:9517
Change-Id: I1c7b293fa6f9c320286c80533b3c584498034a38
Reviewed-on: https://webrtc-review.googlesource.com/88240
Commit-Queue: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24009}
diff --git a/modules/video_coding/decoder_database.cc b/modules/video_coding/decoder_database.cc
index 908a94a..9cb7823 100644
--- a/modules/video_coding/decoder_database.cc
+++ b/modules/video_coding/decoder_database.cc
@@ -29,6 +29,8 @@
     : payload_type(payload_type),
       external_decoder_instance(external_decoder_instance) {}
 
+VCMDecoderMapItem::~VCMDecoderMapItem() {}
+
 VCMDecoderDataBase::VCMDecoderDataBase()
     : receive_codec_(), dec_map_(), dec_external_map_() {}
 
diff --git a/modules/video_coding/decoder_database.h b/modules/video_coding/decoder_database.h
index c3779c5..8c96b41 100644
--- a/modules/video_coding/decoder_database.h
+++ b/modules/video_coding/decoder_database.h
@@ -23,6 +23,7 @@
   VCMDecoderMapItem(VideoCodec* settings,
                     int number_of_cores,
                     bool require_key_frame);
+  ~VCMDecoderMapItem();
 
   std::unique_ptr<VideoCodec> settings;
   int number_of_cores;
diff --git a/modules/video_coding/generic_encoder.cc b/modules/video_coding/generic_encoder.cc
index 7eb35e7..7d8bb6a 100644
--- a/modules/video_coding/generic_encoder.cc
+++ b/modules/video_coding/generic_encoder.cc
@@ -31,6 +31,9 @@
 const int kThrottleRatio = 100000;
 }  // namespace
 
+VCMEncodedFrameCallback::TimingFramesLayerInfo::TimingFramesLayerInfo() {}
+VCMEncodedFrameCallback::TimingFramesLayerInfo::~TimingFramesLayerInfo() {}
+
 VCMGenericEncoder::VCMGenericEncoder(
     VideoEncoder* encoder,
     VCMEncodedFrameCallback* encoded_frame_callback,
diff --git a/modules/video_coding/generic_encoder.h b/modules/video_coding/generic_encoder.h
index 0759f55..151e93e 100644
--- a/modules/video_coding/generic_encoder.h
+++ b/modules/video_coding/generic_encoder.h
@@ -38,7 +38,7 @@
  public:
   VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback,
                           media_optimization::MediaOptimization* media_opt);
-  virtual ~VCMEncodedFrameCallback();
+  ~VCMEncodedFrameCallback() override;
 
   // Implements EncodedImageCallback.
   EncodedImageCallback::Result OnEncodedImage(
@@ -102,6 +102,8 @@
     int64_t encode_start_time_ms;
   };
   struct TimingFramesLayerInfo {
+    TimingFramesLayerInfo();
+    ~TimingFramesLayerInfo();
     size_t target_bitrate_bytes_per_sec = 0;
     std::list<EncodeStartTimeRecord> encode_start_list;
   };
diff --git a/modules/video_coding/include/video_coding.h b/modules/video_coding/include/video_coding.h
index e5c30eb..8ef046a 100644
--- a/modules/video_coding/include/video_coding.h
+++ b/modules/video_coding/include/video_coding.h
@@ -46,9 +46,9 @@
 
 class EventFactoryImpl : public EventFactory {
  public:
-  virtual ~EventFactoryImpl() {}
+  ~EventFactoryImpl() override {}
 
-  virtual EventWrapper* CreateEvent() { return EventWrapper::Create(); }
+  EventWrapper* CreateEvent() override;
 };
 
 // Used to indicate which decode with errors mode should be used.
diff --git a/modules/video_coding/jitter_buffer.cc b/modules/video_coding/jitter_buffer.cc
index b98fd92..83f90e3 100644
--- a/modules/video_coding/jitter_buffer.cc
+++ b/modules/video_coding/jitter_buffer.cc
@@ -123,6 +123,9 @@
   }
 }
 
+Vp9SsMap::Vp9SsMap() {}
+Vp9SsMap::~Vp9SsMap() {}
+
 bool Vp9SsMap::Insert(const VCMPacket& packet) {
   if (!packet.video_header.vp9().ss_data_available)
     return false;
diff --git a/modules/video_coding/jitter_buffer.h b/modules/video_coding/jitter_buffer.h
index 4908080..e1414aa 100644
--- a/modules/video_coding/jitter_buffer.h
+++ b/modules/video_coding/jitter_buffer.h
@@ -75,6 +75,9 @@
 class Vp9SsMap {
  public:
   typedef std::map<uint32_t, GofInfoVP9, TimestampLessThan> SsMap;
+  Vp9SsMap();
+  ~Vp9SsMap();
+
   bool Insert(const VCMPacket& packet);
   void Reset();
 
diff --git a/modules/video_coding/media_opt_util.cc b/modules/video_coding/media_opt_util.cc
index ca9620f..4afe47d 100644
--- a/modules/video_coding/media_opt_util.cc
+++ b/modules/video_coding/media_opt_util.cc
@@ -29,6 +29,20 @@
 
 namespace media_optimization {
 
+VCMProtectionParameters::VCMProtectionParameters()
+    : rtt(0),
+      lossPr(0.0f),
+      bitRate(0.0f),
+      packetsPerFrame(0.0f),
+      packetsPerFrameKey(0.0f),
+      frameRate(0.0f),
+      keyFrameSize(0.0f),
+      fecRateDelta(0),
+      fecRateKey(0),
+      codecWidth(0),
+      codecHeight(0),
+      numLayers(1) {}
+
 VCMProtectionMethod::VCMProtectionMethod()
     : _effectivePacketLoss(0),
       _protectionFactorK(0),
@@ -40,6 +54,34 @@
 
 VCMProtectionMethod::~VCMProtectionMethod() {}
 
+enum VCMProtectionMethodEnum VCMProtectionMethod::Type() const {
+  return _type;
+}
+
+uint8_t VCMProtectionMethod::RequiredPacketLossER() {
+  return _effectivePacketLoss;
+}
+
+uint8_t VCMProtectionMethod::RequiredProtectionFactorK() {
+  return _protectionFactorK;
+}
+
+uint8_t VCMProtectionMethod::RequiredProtectionFactorD() {
+  return _protectionFactorD;
+}
+
+bool VCMProtectionMethod::RequiredUepProtectionK() {
+  return _useUepProtectionK;
+}
+
+bool VCMProtectionMethod::RequiredUepProtectionD() {
+  return _useUepProtectionD;
+}
+
+int VCMProtectionMethod::MaxFramesFec() const {
+  return 1;
+}
+
 VCMNackFecMethod::VCMNackFecMethod(int64_t lowRttNackThresholdMs,
                                    int64_t highRttNackThresholdMs)
     : VCMFecMethod(),
diff --git a/modules/video_coding/media_opt_util.h b/modules/video_coding/media_opt_util.h
index c91ab2b..9cc8d6d 100644
--- a/modules/video_coding/media_opt_util.h
+++ b/modules/video_coding/media_opt_util.h
@@ -48,19 +48,7 @@
 const int kMaxRttDelayThreshold = 500;
 
 struct VCMProtectionParameters {
-  VCMProtectionParameters()
-      : rtt(0),
-        lossPr(0.0f),
-        bitRate(0.0f),
-        packetsPerFrame(0.0f),
-        packetsPerFrameKey(0.0f),
-        frameRate(0.0f),
-        keyFrameSize(0.0f),
-        fecRateDelta(0),
-        fecRateKey(0),
-        codecWidth(0),
-        codecHeight(0),
-        numLayers(1) {}
+  VCMProtectionParameters();
 
   int64_t rtt;
   float lossPr;
@@ -107,38 +95,38 @@
   // Returns the protection type
   //
   // Return value                 : The protection type
-  enum VCMProtectionMethodEnum Type() const { return _type; }
+  VCMProtectionMethodEnum Type() const;
 
   // Returns the effective packet loss for ER, required by this protection
   // method
   //
   // Return value                 : Required effective packet loss
-  virtual uint8_t RequiredPacketLossER() { return _effectivePacketLoss; }
+  virtual uint8_t RequiredPacketLossER();
 
   // Extracts the FEC protection factor for Key frame, required by this
   // protection method
   //
   // Return value                 : Required protectionFactor for Key frame
-  virtual uint8_t RequiredProtectionFactorK() { return _protectionFactorK; }
+  virtual uint8_t RequiredProtectionFactorK();
 
   // Extracts the FEC protection factor for Delta frame, required by this
   // protection method
   //
   // Return value                 : Required protectionFactor for delta frame
-  virtual uint8_t RequiredProtectionFactorD() { return _protectionFactorD; }
+  virtual uint8_t RequiredProtectionFactorD();
 
   // Extracts whether the FEC Unequal protection (UEP) is used for Key frame.
   //
   // Return value                 : Required Unequal protection on/off state.
-  virtual bool RequiredUepProtectionK() { return _useUepProtectionK; }
+  virtual bool RequiredUepProtectionK();
 
   // Extracts whether the the FEC Unequal protection (UEP) is used for Delta
   // frame.
   //
   // Return value                 : Required Unequal protection on/off state.
-  virtual bool RequiredUepProtectionD() { return _useUepProtectionD; }
+  virtual bool RequiredUepProtectionD();
 
-  virtual int MaxFramesFec() const { return 1; }
+  virtual int MaxFramesFec() const;
 
  protected:
   uint8_t _effectivePacketLoss;
@@ -151,14 +139,14 @@
   bool _useUepProtectionK;
   bool _useUepProtectionD;
   float _corrFecCost;
-  enum VCMProtectionMethodEnum _type;
+  VCMProtectionMethodEnum _type;
 };
 
 class VCMNackMethod : public VCMProtectionMethod {
  public:
   VCMNackMethod();
-  virtual ~VCMNackMethod();
-  virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
+  ~VCMNackMethod() override;
+  bool UpdateParameters(const VCMProtectionParameters* parameters) override;
   // Get the effective packet loss
   bool EffectivePacketLoss(const VCMProtectionParameters* parameter);
 };
@@ -166,8 +154,8 @@
 class VCMFecMethod : public VCMProtectionMethod {
  public:
   VCMFecMethod();
-  virtual ~VCMFecMethod();
-  virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
+  ~VCMFecMethod() override;
+  bool UpdateParameters(const VCMProtectionParameters* parameters) override;
   // Get the effective packet loss for ER
   bool EffectivePacketLoss(const VCMProtectionParameters* parameters);
   // Get the FEC protection factors
@@ -202,14 +190,14 @@
  public:
   VCMNackFecMethod(int64_t lowRttNackThresholdMs,
                    int64_t highRttNackThresholdMs);
-  virtual ~VCMNackFecMethod();
-  virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
+  ~VCMNackFecMethod() override;
+  bool UpdateParameters(const VCMProtectionParameters* parameters) override;
   // Get the effective packet loss for ER
   bool EffectivePacketLoss(const VCMProtectionParameters* parameters);
   // Get the protection factors
   bool ProtectionFactor(const VCMProtectionParameters* parameters);
   // Get the max number of frames the FEC is allowed to be based on.
-  int MaxFramesFec() const;
+  int MaxFramesFec() const override;
   // Turn off the FEC based on low bitrate and other factors.
   bool BitRateTooLowForFec(const VCMProtectionParameters* parameters);
 
diff --git a/modules/video_coding/session_info.cc b/modules/video_coding/session_info.cc
index 1b6f732..834684e 100644
--- a/modules/video_coding/session_info.cc
+++ b/modules/video_coding/session_info.cc
@@ -33,6 +33,8 @@
       first_packet_seq_num_(-1),
       last_packet_seq_num_(-1) {}
 
+VCMSessionInfo::~VCMSessionInfo() {}
+
 void VCMSessionInfo::UpdateDataPointers(const uint8_t* old_base_ptr,
                                         const uint8_t* new_base_ptr) {
   for (PacketIterator it = packets_.begin(); it != packets_.end(); ++it)
diff --git a/modules/video_coding/session_info.h b/modules/video_coding/session_info.h
index 0b8fd69..b845ffb 100644
--- a/modules/video_coding/session_info.h
+++ b/modules/video_coding/session_info.h
@@ -30,6 +30,7 @@
 class VCMSessionInfo {
  public:
   VCMSessionInfo();
+  ~VCMSessionInfo();
 
   void UpdateDataPointers(const uint8_t* old_base_ptr,
                           const uint8_t* new_base_ptr);
diff --git a/modules/video_coding/video_coding_impl.cc b/modules/video_coding/video_coding_impl.cc
index aa9a0d5..77bd288 100644
--- a/modules/video_coding/video_coding_impl.cc
+++ b/modules/video_coding/video_coding_impl.cc
@@ -27,6 +27,10 @@
 #include "system_wrappers/include/clock.h"
 
 namespace webrtc {
+EventWrapper* EventFactoryImpl::CreateEvent() {
+  return EventWrapper::Create();
+}
+
 namespace vcm {
 
 int64_t VCMProcessTimer::Period() const {