Make sure rtp_rtcp module doesn't directly reference anything in the pacer module, and remove build dependencies on it.

BUG=

Review URL: https://codereview.webrtc.org/1350163005

Cr-Commit-Position: refs/heads/master@{#10005}
diff --git a/webrtc/modules/pacing/BUILD.gn b/webrtc/modules/pacing/BUILD.gn
index 69cd6db..3e478c1 100644
--- a/webrtc/modules/pacing/BUILD.gn
+++ b/webrtc/modules/pacing/BUILD.gn
@@ -28,5 +28,6 @@
   deps = [
     "../../system_wrappers",
     "../bitrate_controller",
+    "../rtp_rtcp",
   ]
 }
diff --git a/webrtc/modules/pacing/bitrate_prober.cc b/webrtc/modules/pacing/bitrate_prober.cc
index bedb892..d09ad2d 100644
--- a/webrtc/modules/pacing/bitrate_prober.cc
+++ b/webrtc/modules/pacing/bitrate_prober.cc
@@ -15,6 +15,7 @@
 #include <limits>
 #include <sstream>
 
+#include "webrtc/modules/pacing/include/paced_sender.h"
 #include "webrtc/system_wrappers/interface/logging.h"
 
 namespace webrtc {
@@ -29,8 +30,6 @@
 }
 }  // namespace
 
-const size_t BitrateProber::kMinProbePacketSize = 200;
-
 BitrateProber::BitrateProber()
     : probing_state_(kDisabled),
       packet_size_last_send_(0),
@@ -90,7 +89,7 @@
   // We will send the first probe packet immediately if no packet has been
   // sent before.
   int time_until_probe_ms = 0;
-  if (packet_size_last_send_ > kMinProbePacketSize &&
+  if (packet_size_last_send_ > PacedSender::kMinProbePacketSize &&
       probing_state_ == kProbing) {
     int next_delta_ms = ComputeDeltaFromBitrate(packet_size_last_send_,
                                                 probe_bitrates_.front());
diff --git a/webrtc/modules/pacing/bitrate_prober.h b/webrtc/modules/pacing/bitrate_prober.h
index c26b0d6..b3f52af 100644
--- a/webrtc/modules/pacing/bitrate_prober.h
+++ b/webrtc/modules/pacing/bitrate_prober.h
@@ -22,8 +22,6 @@
 // on being protected by the caller.
 class BitrateProber {
  public:
-  static const size_t kMinProbePacketSize;
-
   BitrateProber();
 
   void SetEnabled(bool enable);
diff --git a/webrtc/modules/pacing/include/paced_sender.h b/webrtc/modules/pacing/include/paced_sender.h
index 645999d..afb196f 100644
--- a/webrtc/modules/pacing/include/paced_sender.h
+++ b/webrtc/modules/pacing/include/paced_sender.h
@@ -17,6 +17,7 @@
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/thread_annotations.h"
 #include "webrtc/modules/interface/module.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
 #include "webrtc/typedefs.h"
 
 namespace webrtc {
@@ -30,16 +31,8 @@
 class PacketQueue;
 }  // namespace paced_sender
 
-class PacedSender : public Module {
+class PacedSender : public Module, public RtpPacketSender {
  public:
-  enum Priority {
-    kHighPriority = 0,  // Pass through; will be sent immediately.
-    kNormalPriority = 2,  // Put in back of the line.
-    kLowPriority = 3,  // Put in back of the low priority line.
-  };
-  // Low priority packets are mixed with the normal priority packets
-  // while we are paused.
-
   class Callback {
    public:
     // Note: packets sent as a result of a callback should not pass by this
@@ -68,6 +61,8 @@
   // overshoots from the encoder.
   static const float kDefaultPaceMultiplier;
 
+  static const size_t kMinProbePacketSize = 200;
+
   PacedSender(Clock* clock,
               Callback* callback,
               int bitrate_kbps,
@@ -103,12 +98,12 @@
 
   // Returns true if we send the packet now, else it will add the packet
   // information to the queue and call TimeToSendPacket when it's time to send.
-  virtual bool SendPacket(Priority priority,
-                          uint32_t ssrc,
-                          uint16_t sequence_number,
-                          int64_t capture_time_ms,
-                          size_t bytes,
-                          bool retransmission);
+  bool SendPacket(RtpPacketSender::Priority priority,
+                  uint32_t ssrc,
+                  uint16_t sequence_number,
+                  int64_t capture_time_ms,
+                  size_t bytes,
+                  bool retransmission) override;
 
   // Returns the time since the oldest queued packet was enqueued.
   virtual int64_t QueueInMs() const;
diff --git a/webrtc/modules/pacing/include/packet_router.h b/webrtc/modules/pacing/include/packet_router.h
index d0bcf55..9d461d1 100644
--- a/webrtc/modules/pacing/include/packet_router.h
+++ b/webrtc/modules/pacing/include/packet_router.h
@@ -19,15 +19,19 @@
 #include "webrtc/base/thread_annotations.h"
 #include "webrtc/common_types.h"
 #include "webrtc/modules/pacing/include/paced_sender.h"
-#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
 
 namespace webrtc {
 
 class RtpRtcp;
+namespace rtcp {
+class TransportFeedback;
+}  // namespace rtcp
 
 // PacketRouter routes outgoing data to the correct sending RTP module, based
 // on the simulcast layer in RTPVideoHeader.
-class PacketRouter : public PacedSender::Callback {
+class PacketRouter : public PacedSender::Callback,
+                     public TransportSequenceNumberAllocator {
  public:
   PacketRouter();
   virtual ~PacketRouter();
@@ -44,7 +48,7 @@
   size_t TimeToSendPadding(size_t bytes) override;
 
   void SetTransportWideSequenceNumber(uint16_t sequence_number);
-  uint16_t AllocateSequenceNumber();
+  uint16_t AllocateSequenceNumber() override;
 
   // Send transport feedback packet to send-side.
   virtual bool SendFeedback(rtcp::TransportFeedback* packet);
diff --git a/webrtc/modules/pacing/paced_sender.cc b/webrtc/modules/pacing/paced_sender.cc
index d5df480..55c361b 100644
--- a/webrtc/modules/pacing/paced_sender.cc
+++ b/webrtc/modules/pacing/paced_sender.cc
@@ -36,7 +36,7 @@
 namespace webrtc {
 namespace paced_sender {
 struct Packet {
-  Packet(PacedSender::Priority priority,
+  Packet(RtpPacketSender::Priority priority,
          uint32_t ssrc,
          uint16_t seq_number,
          int64_t capture_time_ms,
@@ -53,7 +53,7 @@
         retransmission(retransmission),
         enqueue_order(enqueue_order) {}
 
-  PacedSender::Priority priority;
+  RtpPacketSender::Priority priority;
   uint32_t ssrc;
   uint16_t sequence_number;
   int64_t capture_time_ms;
@@ -268,9 +268,12 @@
   bitrate_bps_ = 1000 * bitrate_kbps;
 }
 
-bool PacedSender::SendPacket(Priority priority, uint32_t ssrc,
-    uint16_t sequence_number, int64_t capture_time_ms, size_t bytes,
-    bool retransmission) {
+bool PacedSender::SendPacket(RtpPacketSender::Priority priority,
+                             uint32_t ssrc,
+                             uint16_t sequence_number,
+                             int64_t capture_time_ms,
+                             size_t bytes,
+                             bool retransmission) {
   CriticalSectionScoped cs(critsect_.get());
 
   if (!enabled_) {
diff --git a/webrtc/modules/pacing/pacing.gypi b/webrtc/modules/pacing/pacing.gypi
index 29d9508..faa9784 100644
--- a/webrtc/modules/pacing/pacing.gypi
+++ b/webrtc/modules/pacing/pacing.gypi
@@ -14,6 +14,7 @@
       'dependencies': [
         '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
         '<(webrtc_root)/modules/modules.gyp:bitrate_controller',
+        '<(webrtc_root)/modules/modules.gyp:rtp_rtcp',
       ],
       'sources': [
         'include/paced_sender.h',
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
index 2050ea1..46dc230 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
@@ -16,7 +16,7 @@
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/thread_annotations.h"
 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
-#include "webrtc/modules/pacing/bitrate_prober.h"
+#include "webrtc/modules/pacing/include/paced_sender.h"
 #include "webrtc/system_wrappers/interface/clock.h"
 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
 #include "webrtc/system_wrappers/interface/logging.h"
@@ -272,7 +272,7 @@
   // For now only try to detect probes while we don't have a valid estimate, and
   // make sure the packet was paced. We currently assume that only packets
   // larger than 200 bytes are paced by the sender.
-  was_paced = was_paced && payload_size > BitrateProber::kMinProbePacketSize;
+  was_paced = was_paced && payload_size > PacedSender::kMinProbePacketSize;
   if (was_paced &&
       (!remote_rate_.ValidEstimate() ||
        now_ms - first_packet_time_ms_ < kInitialProbingIntervalMs)) {
diff --git a/webrtc/modules/rtp_rtcp/BUILD.gn b/webrtc/modules/rtp_rtcp/BUILD.gn
index b83faae..af2d2c3 100644
--- a/webrtc/modules/rtp_rtcp/BUILD.gn
+++ b/webrtc/modules/rtp_rtcp/BUILD.gn
@@ -110,7 +110,6 @@
   deps = [
     "../..:webrtc_common",
     "../../system_wrappers",
-    "../pacing",
     "../remote_bitrate_estimator",
   ]
 
diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
index 4dfb1dd..d5048fc 100644
--- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
+++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
@@ -19,8 +19,6 @@
 
 namespace webrtc {
 // Forward declarations.
-class PacedSender;
-class PacketRouter;
 class ReceiveStatistics;
 class RemoteBitrateEstimator;
 class RtpReceiver;
@@ -69,8 +67,8 @@
     RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer;
     RtpAudioFeedback* audio_messages;
     RemoteBitrateEstimator* remote_bitrate_estimator;
-    PacedSender* paced_sender;
-    PacketRouter* packet_router;
+    RtpPacketSender* paced_sender;
+    TransportSequenceNumberAllocator* transport_sequence_number_allocator;
     BitrateStatisticsObserver* send_bitrate_observer;
     FrameCountObserver* send_frame_count_observer;
     SendSideDelayObserver* send_side_delay_observer;
diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h
index 73fb96c..9ff7406 100644
--- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h
+++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h
@@ -395,5 +395,36 @@
   uint64_t multiple_packet_loss_packet_count;
 };
 
+class RtpPacketSender {
+ public:
+  RtpPacketSender() {}
+  virtual ~RtpPacketSender() {}
+
+  enum Priority {
+    kHighPriority = 0,    // Pass through; will be sent immediately.
+    kNormalPriority = 2,  // Put in back of the line.
+    kLowPriority = 3,     // Put in back of the low priority line.
+  };
+  // Low priority packets are mixed with the normal priority packets
+  // while we are paused.
+
+  // Returns true if we send the packet now, else it will add the packet
+  // information to the queue and call TimeToSendPacket when it's time to send.
+  virtual bool SendPacket(Priority priority,
+                          uint32_t ssrc,
+                          uint16_t sequence_number,
+                          int64_t capture_time_ms,
+                          size_t bytes,
+                          bool retransmission) = 0;
+};
+
+class TransportSequenceNumberAllocator {
+ public:
+  TransportSequenceNumberAllocator() {}
+  virtual ~TransportSequenceNumberAllocator() {}
+
+  virtual uint16_t AllocateSequenceNumber() = 0;
+};
+
 }  // namespace webrtc
 #endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RTCP_DEFINES_H_
diff --git a/webrtc/modules/rtp_rtcp/rtp_rtcp.gypi b/webrtc/modules/rtp_rtcp/rtp_rtcp.gypi
index a927bd0..225e744 100644
--- a/webrtc/modules/rtp_rtcp/rtp_rtcp.gypi
+++ b/webrtc/modules/rtp_rtcp/rtp_rtcp.gypi
@@ -13,7 +13,6 @@
       'type': 'static_library',
       'dependencies': [
         '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
-        '<(webrtc_root)/modules/modules.gyp:paced_sender',
         '<(webrtc_root)/modules/modules.gyp:remote_bitrate_estimator',
       ],
       'sources': [
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index b245e81..d941201 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -40,7 +40,7 @@
       audio_messages(NullObjectRtpAudioFeedback()),
       remote_bitrate_estimator(nullptr),
       paced_sender(nullptr),
-      packet_router(nullptr),
+      transport_sequence_number_allocator(nullptr),
       send_bitrate_observer(nullptr),
       send_frame_count_observer(nullptr),
       send_side_delay_observer(nullptr) {}
@@ -64,7 +64,7 @@
                   configuration.outgoing_transport,
                   configuration.audio_messages,
                   configuration.paced_sender,
-                  configuration.packet_router,
+                  configuration.transport_sequence_number_allocator,
                   configuration.transport_feedback_callback,
                   configuration.send_bitrate_observer,
                   configuration.send_frame_count_observer,
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
index 881985d..0efdc56 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
@@ -12,7 +12,6 @@
 #include "testing/gtest/include/gtest/gtest.h"
 
 #include "webrtc/common_types.h"
-#include "webrtc/modules/pacing/include/mock/mock_paced_sender.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
index 44ac965..fcaf260 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
@@ -97,16 +97,17 @@
   uint32_t ssrc_;
 };
 
-RTPSender::RTPSender(bool audio,
-                     Clock* clock,
-                     Transport* transport,
-                     RtpAudioFeedback* audio_feedback,
-                     PacedSender* paced_sender,
-                     PacketRouter* packet_router,
-                     TransportFeedbackObserver* transport_feedback_observer,
-                     BitrateStatisticsObserver* bitrate_callback,
-                     FrameCountObserver* frame_count_observer,
-                     SendSideDelayObserver* send_side_delay_observer)
+RTPSender::RTPSender(
+    bool audio,
+    Clock* clock,
+    Transport* transport,
+    RtpAudioFeedback* audio_feedback,
+    RtpPacketSender* paced_sender,
+    TransportSequenceNumberAllocator* sequence_number_allocator,
+    TransportFeedbackObserver* transport_feedback_observer,
+    BitrateStatisticsObserver* bitrate_callback,
+    FrameCountObserver* frame_count_observer,
+    SendSideDelayObserver* send_side_delay_observer)
     : clock_(clock),
       // TODO(holmer): Remove this conversion when we remove the use of
       // TickTime.
@@ -118,7 +119,7 @@
       audio_(audio ? new RTPSenderAudio(clock, this, audio_feedback) : nullptr),
       video_(audio ? nullptr : new RTPSenderVideo(clock, this)),
       paced_sender_(paced_sender),
-      packet_router_(packet_router),
+      transport_sequence_number_allocator_(sequence_number_allocator),
       transport_feedback_observer_(transport_feedback_observer),
       last_capture_time_ms_sent_(0),
       send_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
@@ -586,7 +587,8 @@
                               bool timestamp_provided,
                               uint32_t timestamp,
                               int64_t capture_time_ms) {
-  // Always send full padding packets. This is accounted for by the PacedSender,
+  // Always send full padding packets. This is accounted for by the
+  // RtpPacketSender,
   // which will make sure we don't send too much padding even if a single packet
   // is larger than requested.
   size_t padding_bytes_in_packet =
@@ -594,7 +596,7 @@
   size_t bytes_sent = 0;
   bool using_transport_seq = rtp_header_extension_map_.IsRegistered(
                                  kRtpExtensionTransportSequenceNumber) &&
-                             packet_router_;
+                             transport_sequence_number_allocator_;
   for (; bytes > 0; bytes -= padding_bytes_in_packet) {
     if (bytes < padding_bytes_in_packet)
       bytes = padding_bytes_in_packet;
@@ -711,7 +713,7 @@
     // TickTime.
     int64_t corrected_capture_tims_ms = capture_time_ms + clock_delta_ms_;
     if (!paced_sender_->SendPacket(
-            PacedSender::kHighPriority, header.ssrc, header.sequenceNumber,
+            RtpPacketSender::kHighPriority, header.ssrc, header.sequenceNumber,
             corrected_capture_tims_ms, length - header.headerLength, true)) {
       // We can't send the packet right now.
       // We will be called when it is time.
@@ -917,7 +919,8 @@
   // TODO(sprang): Potentially too much overhead in IsRegistered()?
   bool using_transport_seq = rtp_header_extension_map_.IsRegistered(
                                  kRtpExtensionTransportSequenceNumber) &&
-                             packet_router_ && !is_retransmit;
+                             transport_sequence_number_allocator_ &&
+                             !is_retransmit;
   if (using_transport_seq) {
     transport_seq =
         UpdateTransportSequenceNumber(buffer_to_send_ptr, length, rtp_header);
@@ -1000,10 +1003,12 @@
 }
 
 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again.
-int32_t RTPSender::SendToNetwork(
-    uint8_t *buffer, size_t payload_length, size_t rtp_header_length,
-    int64_t capture_time_ms, StorageType storage,
-    PacedSender::Priority priority) {
+int32_t RTPSender::SendToNetwork(uint8_t* buffer,
+                                 size_t payload_length,
+                                 size_t rtp_header_length,
+                                 int64_t capture_time_ms,
+                                 StorageType storage,
+                                 RtpPacketSender::Priority priority) {
   RtpUtility::RtpHeaderParser rtp_parser(buffer,
                                          payload_length + rtp_header_length);
   RTPHeader rtp_header;
@@ -1615,7 +1620,7 @@
       RTC_NOTREACHED();
   }
 
-  uint16_t seq = packet_router_->AllocateSequenceNumber();
+  uint16_t seq = transport_sequence_number_allocator_->AllocateSequenceNumber();
   BuildTransportSequenceNumberExtension(rtp_packet + offset, seq);
   return seq;
 }
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.h b/webrtc/modules/rtp_rtcp/source/rtp_sender.h
index 6d24ee1..f133417 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.h
@@ -17,8 +17,6 @@
 
 #include "webrtc/base/thread_annotations.h"
 #include "webrtc/common_types.h"
-#include "webrtc/modules/pacing/include/paced_sender.h"
-#include "webrtc/modules/pacing/include/packet_router.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
 #include "webrtc/modules/rtp_rtcp/source/bitrate.h"
 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
@@ -71,10 +69,12 @@
   virtual uint16_t PacketOverHead() const = 0;
   virtual uint16_t ActualSendBitrateKbit() const = 0;
 
-  virtual int32_t SendToNetwork(
-      uint8_t *data_buffer, size_t payload_length, size_t rtp_header_length,
-      int64_t capture_time_ms, StorageType storage,
-      PacedSender::Priority priority) = 0;
+  virtual int32_t SendToNetwork(uint8_t* data_buffer,
+                                size_t payload_length,
+                                size_t rtp_header_length,
+                                int64_t capture_time_ms,
+                                StorageType storage,
+                                RtpPacketSender::Priority priority) = 0;
 
   virtual bool UpdateVideoRotation(uint8_t* rtp_packet,
                                    size_t rtp_packet_length,
@@ -90,8 +90,8 @@
             Clock* clock,
             Transport* transport,
             RtpAudioFeedback* audio_feedback,
-            PacedSender* paced_sender,
-            PacketRouter* packet_router,
+            RtpPacketSender* paced_sender,
+            TransportSequenceNumberAllocator* sequence_number_allocator,
             TransportFeedbackObserver* transport_feedback_callback,
             BitrateStatisticsObserver* bitrate_callback,
             FrameCountObserver* frame_count_observer,
@@ -257,7 +257,7 @@
                         size_t rtp_header_length,
                         int64_t capture_time_ms,
                         StorageType storage,
-                        PacedSender::Priority priority) override;
+                        RtpPacketSender::Priority priority) override;
 
   // Audio.
 
@@ -370,8 +370,8 @@
                               const RTPHeader& rtp_header,
                               int64_t now_ms) const;
   // Update the transport sequence number of the packet using a new sequence
-  // number allocated by PacketRouter. Returns the assigned sequence number,
-  // or 0 if extension could not be updated.
+  // number allocated by SequenceNumberAllocator. Returns the assigned sequence
+  // number, or 0 if extension could not be updated.
   uint16_t UpdateTransportSequenceNumber(uint8_t* rtp_packet,
                                          size_t rtp_packet_length,
                                          const RTPHeader& rtp_header) const;
@@ -393,8 +393,8 @@
   rtc::scoped_ptr<RTPSenderAudio> audio_;
   rtc::scoped_ptr<RTPSenderVideo> video_;
 
-  PacedSender* const paced_sender_;
-  PacketRouter* const packet_router_;
+  RtpPacketSender* const paced_sender_;
+  TransportSequenceNumberAllocator* const transport_sequence_number_allocator_;
   TransportFeedbackObserver* const transport_feedback_observer_;
   int64_t last_capture_time_ms_sent_;
   rtc::scoped_ptr<CriticalSectionWrapper> send_critsect_;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc
index 2f3faf5..3f55db4 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc
@@ -13,6 +13,7 @@
 #include <assert.h> //assert
 #include <string.h> //memcpy
 
+#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
 #include "webrtc/system_wrappers/interface/trace_event.h"
 
@@ -368,7 +369,7 @@
                            _rtpSender->SequenceNumber());
     return _rtpSender->SendToNetwork(dataBuffer, payloadSize, rtpHeaderLength,
                                      -1, kAllowRetransmission,
-                                     PacedSender::kHighPriority);
+                                     RtpPacketSender::kHighPriority);
   }
 
     // Audio level magnitude and voice activity flag are set for each RTP packet
@@ -477,7 +478,7 @@
                              _rtpSender->SequenceNumber());
         retVal = _rtpSender->SendToNetwork(dtmfbuffer, 4, 12, -1,
                                            kAllowRetransmission,
-                                           PacedSender::kHighPriority);
+                                           RtpPacketSender::kHighPriority);
         sendCount--;
 
     }while (sendCount > 0 && retVal == 0);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc
index 555f227..d33b086 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc
@@ -12,11 +12,11 @@
  * This file includes unit tests for the RTPSender.
  */
 
+#include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 #include "webrtc/base/buffer.h"
 #include "webrtc/base/scoped_ptr.h"
-#include "webrtc/modules/pacing/include/mock/mock_paced_sender.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_cvo.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
@@ -100,6 +100,20 @@
 
 }  // namespace
 
+class MockRtpPacketSender : public RtpPacketSender {
+ public:
+  MockRtpPacketSender() {}
+  virtual ~MockRtpPacketSender() {}
+
+  MOCK_METHOD6(SendPacket,
+               bool(Priority priority,
+                    uint32_t ssrc,
+                    uint16_t sequence_number,
+                    int64_t capture_time_ms,
+                    size_t bytes,
+                    bool retransmission));
+};
+
 class RtpSenderTest : public ::testing::Test {
  protected:
   RtpSenderTest()
@@ -121,7 +135,7 @@
   }
 
   SimulatedClock fake_clock_;
-  MockPacedSender mock_paced_sender_;
+  MockRtpPacketSender mock_paced_sender_;
   rtc::scoped_ptr<RTPSender> rtp_sender_;
   int payload_;
   LoopbackTransportTest transport_;
@@ -152,12 +166,9 @@
     ASSERT_GE(rtp_length, 0);
 
     // Packet should be stored in a send bucket.
-    EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
-                                            payload_length,
-                                            rtp_length,
-                                            capture_time_ms,
-                                            kAllowRetransmission,
-                                            PacedSender::kNormalPriority));
+    EXPECT_EQ(0, rtp_sender_->SendToNetwork(
+                     packet_, payload_length, rtp_length, capture_time_ms,
+                     kAllowRetransmission, RtpPacketSender::kNormalPriority));
   }
 };
 
@@ -593,8 +604,8 @@
 
 TEST_F(RtpSenderTest, TrafficSmoothingWithExtensions) {
   EXPECT_CALL(mock_paced_sender_,
-              SendPacket(PacedSender::kNormalPriority, _, kSeqNum, _, _, _)).
-                  WillOnce(testing::Return(false));
+              SendPacket(RtpPacketSender::kNormalPriority, _, kSeqNum, _, _, _))
+      .WillOnce(testing::Return(false));
 
   rtp_sender_->SetStorePacketsStatus(true, 10);
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
@@ -609,12 +620,9 @@
   size_t rtp_length = static_cast<size_t>(rtp_length_int);
 
   // Packet should be stored in a send bucket.
-  EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
-                                          0,
-                                          rtp_length,
-                                          capture_time_ms,
-                                          kAllowRetransmission,
-                                          PacedSender::kNormalPriority));
+  EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, 0, rtp_length,
+                                          capture_time_ms, kAllowRetransmission,
+                                          RtpPacketSender::kNormalPriority));
 
   EXPECT_EQ(0, transport_.packets_sent_);
 
@@ -646,8 +654,8 @@
 
 TEST_F(RtpSenderTest, TrafficSmoothingRetransmits) {
   EXPECT_CALL(mock_paced_sender_,
-              SendPacket(PacedSender::kNormalPriority, _, kSeqNum, _, _, _)).
-                  WillOnce(testing::Return(false));
+              SendPacket(RtpPacketSender::kNormalPriority, _, kSeqNum, _, _, _))
+      .WillOnce(testing::Return(false));
 
   rtp_sender_->SetStorePacketsStatus(true, 10);
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
@@ -662,18 +670,15 @@
   size_t rtp_length = static_cast<size_t>(rtp_length_int);
 
   // Packet should be stored in a send bucket.
-  EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
-                                          0,
-                                          rtp_length,
-                                          capture_time_ms,
-                                          kAllowRetransmission,
-                                          PacedSender::kNormalPriority));
+  EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, 0, rtp_length,
+                                          capture_time_ms, kAllowRetransmission,
+                                          RtpPacketSender::kNormalPriority));
 
   EXPECT_EQ(0, transport_.packets_sent_);
 
   EXPECT_CALL(mock_paced_sender_,
-              SendPacket(PacedSender::kHighPriority, _, kSeqNum, _, _, _)).
-                  WillOnce(testing::Return(false));
+              SendPacket(RtpPacketSender::kHighPriority, _, kSeqNum, _, _, _))
+      .WillOnce(testing::Return(false));
 
   const int kStoredTimeInMs = 100;
   fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs);
@@ -710,8 +715,8 @@
 TEST_F(RtpSenderTest, SendPadding) {
   // Make all (non-padding) packets go to send queue.
   EXPECT_CALL(mock_paced_sender_,
-              SendPacket(PacedSender::kNormalPriority, _, _, _, _, _)).
-                  WillRepeatedly(testing::Return(false));
+              SendPacket(RtpPacketSender::kNormalPriority, _, _, _, _, _))
+      .WillRepeatedly(testing::Return(false));
 
   uint16_t seq_num = kSeqNum;
   uint32_t timestamp = kTimestamp;
@@ -744,12 +749,9 @@
   size_t rtp_length = static_cast<size_t>(rtp_length_int);
 
   // Packet should be stored in a send bucket.
-  EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
-                                          0,
-                                          rtp_length,
-                                          capture_time_ms,
-                                          kAllowRetransmission,
-                                          PacedSender::kNormalPriority));
+  EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, 0, rtp_length,
+                                          capture_time_ms, kAllowRetransmission,
+                                          RtpPacketSender::kNormalPriority));
 
   int total_packets_sent = 0;
   EXPECT_EQ(total_packets_sent, transport_.packets_sent_);
@@ -802,12 +804,9 @@
   rtp_length = static_cast<size_t>(rtp_length_int);
 
   // Packet should be stored in a send bucket.
-  EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
-                                          0,
-                                          rtp_length,
-                                          capture_time_ms,
-                                          kAllowRetransmission,
-                                          PacedSender::kNormalPriority));
+  EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, 0, rtp_length,
+                                          capture_time_ms, kAllowRetransmission,
+                                          RtpPacketSender::kNormalPriority));
 
   rtp_sender_->TimeToSendPacket(seq_num, capture_time_ms, false);
   // Process send bucket.
@@ -836,8 +835,8 @@
   rtp_sender_->SetRtxPayloadType(kRtxPayload, kPayload);
   // Make all packets go through the pacer.
   EXPECT_CALL(mock_paced_sender_,
-              SendPacket(PacedSender::kNormalPriority, _, _, _, _, _)).
-                  WillRepeatedly(testing::Return(false));
+              SendPacket(RtpPacketSender::kNormalPriority, _, _, _, _, _))
+      .WillRepeatedly(testing::Return(false));
 
   uint16_t seq_num = kSeqNum;
   rtp_sender_->SetStorePacketsStatus(true, 10);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc
index 1de1640..a2008bf 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -104,7 +104,7 @@
                                      StorageType storage) {
   if (_rtpSender.SendToNetwork(data_buffer, payload_length, rtp_header_length,
                                capture_time_ms, storage,
-                               PacedSender::kNormalPriority) == 0) {
+                               RtpPacketSender::kNormalPriority) == 0) {
     _videoBitrate.Update(payload_length + rtp_header_length);
     TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
                          "Video::PacketNormal", "timestamp", capture_timestamp,
@@ -150,7 +150,7 @@
   if (_rtpSender.SendToNetwork(
           red_packet->data(), red_packet->length() - rtp_header_length,
           rtp_header_length, capture_time_ms, media_packet_storage,
-          PacedSender::kNormalPriority) == 0) {
+          RtpPacketSender::kNormalPriority) == 0) {
     _videoBitrate.Update(red_packet->length());
     TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
                          "Video::PacketRed", "timestamp", capture_timestamp,
@@ -162,7 +162,7 @@
     if (_rtpSender.SendToNetwork(
             fec_packet->data(), fec_packet->length() - rtp_header_length,
             rtp_header_length, capture_time_ms, fec_storage,
-            PacedSender::kNormalPriority) == 0) {
+            RtpPacketSender::kNormalPriority) == 0) {
       _fecOverheadRate.Update(fec_packet->length());
       TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
                            "Video::PacketFec", "timestamp", capture_timestamp,
@@ -192,8 +192,8 @@
   TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
                        "Video::IntraRequest", "seqnum",
                        _rtpSender.SequenceNumber());
-  return _rtpSender.SendToNetwork(
-      data, 0, length, -1, kDontStore, PacedSender::kNormalPriority);
+  return _rtpSender.SendToNetwork(data, 0, length, -1, kDontStore,
+                                  RtpPacketSender::kNormalPriority);
 }
 
 void RTPSenderVideo::SetGenericFECStatus(const bool enable,
diff --git a/webrtc/video/BUILD.gn b/webrtc/video/BUILD.gn
index 1d26b41..04d95ce 100644
--- a/webrtc/video/BUILD.gn
+++ b/webrtc/video/BUILD.gn
@@ -70,6 +70,7 @@
     "..:webrtc_common",
     "../common_video",
     "../modules/bitrate_controller",
+    "../modules/pacing",
     "../modules/rtp_rtcp",
     "../modules/utility",
     "../modules/video_capture:video_capture_module",
diff --git a/webrtc/video/webrtc_video.gypi b/webrtc/video/webrtc_video.gypi
index 03dc0ff..198fe3e 100644
--- a/webrtc/video/webrtc_video.gypi
+++ b/webrtc/video/webrtc_video.gypi
@@ -12,6 +12,7 @@
       '<(webrtc_root)/common.gyp:webrtc_common',
       '<(webrtc_root)/common_video/common_video.gyp:common_video',
       '<(webrtc_root)/modules/modules.gyp:bitrate_controller',
+      '<(webrtc_root)/modules/modules.gyp:paced_sender',
       '<(webrtc_root)/modules/modules.gyp:rtp_rtcp',
       '<(webrtc_root)/modules/modules.gyp:video_capture_module',
       '<(webrtc_root)/modules/modules.gyp:video_processing',
diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc
index b812926..0b2b309 100644
--- a/webrtc/video_engine/vie_channel.cc
+++ b/webrtc/video_engine/vie_channel.cc
@@ -1138,8 +1138,8 @@
     RtcpRttStats* rtt_stats,
     RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
     RemoteBitrateEstimator* remote_bitrate_estimator,
-    PacedSender* paced_sender,
-    PacketRouter* packet_router,
+    RtpPacketSender* paced_sender,
+    TransportSequenceNumberAllocator* transport_sequence_number_allocator,
     BitrateStatisticsObserver* send_bitrate_observer,
     FrameCountObserver* send_frame_count_observer,
     SendSideDelayObserver* send_side_delay_observer,
@@ -1156,7 +1156,8 @@
   configuration.rtcp_packet_type_counter_observer =
       rtcp_packet_type_counter_observer;
   configuration.paced_sender = paced_sender;
-  configuration.packet_router = packet_router;
+  configuration.transport_sequence_number_allocator =
+      transport_sequence_number_allocator;
   configuration.send_bitrate_observer = send_bitrate_observer;
   configuration.send_frame_count_observer = send_frame_count_observer;
   configuration.send_side_delay_observer = send_side_delay_observer;
diff --git a/webrtc/video_engine/vie_channel.h b/webrtc/video_engine/vie_channel.h
index fc01592..29f7d03 100644
--- a/webrtc/video_engine/vie_channel.h
+++ b/webrtc/video_engine/vie_channel.h
@@ -298,8 +298,8 @@
       RtcpRttStats* rtt_stats,
       RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
       RemoteBitrateEstimator* remote_bitrate_estimator,
-      PacedSender* paced_sender,
-      PacketRouter* packet_router,
+      RtpPacketSender* paced_sender,
+      TransportSequenceNumberAllocator* transport_sequence_number_allocator,
       BitrateStatisticsObserver* send_bitrate_observer,
       FrameCountObserver* send_frame_count_observer,
       SendSideDelayObserver* send_side_delay_observer,