Create //webrtc/api:libjingle_peerconnection_api + refactorings.

Create a new target //webrtc/api:libjingle_peerconnection_api and start moving
things into it. Move remaining parts of //webrtc/api:libjingle_peerconnection
to //webrtc/pc:libjingle_peerconnection.

Moved the RTCStatsCollectorCallback into its own header file, so that
PeerConnectionInterface can include that instead of pulling in
RTCStatsCollector and PeerConnection and everything.

Separated cricket::MediaType into its own header/source set, so that it
can be used in the api.

BUG=webrtc:5883

Review-Url: https://codereview.webrtc.org/2514883002
Cr-Commit-Position: refs/heads/master@{#16210}
diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn
index 5633f28..e067791 100644
--- a/webrtc/BUILD.gn
+++ b/webrtc/BUILD.gn
@@ -284,7 +284,6 @@
         ":video_engine_tests",
         ":webrtc_nonparallel_tests",
         ":webrtc_perf_tests",
-        "api:peerconnection_unittests",
         "base:rtc_base_tests_utils",
         "common_audio:common_audio_unittests",
         "common_video:common_video_unittests",
@@ -295,6 +294,7 @@
         "modules/audio_processing:audio_processing_tests",
         "modules/rtp_rtcp:test_packet_masks_metrics",
         "modules/video_capture:video_capture_internal_impl",
+        "pc:peerconnection_unittests",
         "pc:rtc_pc_unittests",
         "stats:rtc_stats_unittests",
         "system_wrappers:system_wrappers_unittests",
diff --git a/webrtc/api/BUILD.gn b/webrtc/api/BUILD.gn
index fa3c629..9d893e0 100644
--- a/webrtc/api/BUILD.gn
+++ b/webrtc/api/BUILD.gn
@@ -14,7 +14,7 @@
 
 group("api") {
   public_deps = [
-    ":libjingle_peerconnection",
+    ":libjingle_peerconnection_api",
   ]
 }
 
@@ -34,122 +34,63 @@
   ]
 }
 
-config("libjingle_peerconnection_warnings_config") {
-  # GN orders flags on a target before flags from configs. The default config
-  # adds these flags so to cancel them out they need to come from a config and
-  # cannot be on the target directly.
-  if (!is_win && !is_clang) {
-    cflags = [ "-Wno-maybe-uninitialized" ]  # Only exists for GCC.
-  }
-}
-
-rtc_static_library("libjingle_peerconnection") {
+rtc_static_library("libjingle_peerconnection_api") {
   check_includes = false  # TODO(kjellander): Remove (bugs.webrtc.org/6828)
   cflags = []
   sources = [
-    "audiotrack.cc",
-    "audiotrack.h",
-    "datachannel.cc",
     "datachannel.h",
     "datachannelinterface.h",
-    "dtmfsender.cc",
-    "dtmfsender.h",
     "dtmfsenderinterface.h",
     "jsep.h",
-    "jsepicecandidate.cc",
     "jsepicecandidate.h",
-    "jsepsessiondescription.cc",
     "jsepsessiondescription.h",
-    "localaudiosource.cc",
-    "localaudiosource.h",
     "mediaconstraintsinterface.cc",
     "mediaconstraintsinterface.h",
-    "mediacontroller.cc",
     "mediacontroller.h",
-    "mediastream.cc",
     "mediastream.h",
+    "mediastreaminterface.cc",
     "mediastreaminterface.h",
-    "mediastreamobserver.cc",
-    "mediastreamobserver.h",
     "mediastreamproxy.h",
     "mediastreamtrack.h",
     "mediastreamtrackproxy.h",
+    "mediatypes.cc",
+    "mediatypes.h",
     "notifier.h",
-    "ortcfactory.cc",
-    "ortcfactory.h",
     "ortcfactoryinterface.h",
-    "peerconnection.cc",
-    "peerconnection.h",
-    "peerconnectionfactory.cc",
-    "peerconnectionfactory.h",
     "peerconnectionfactoryproxy.h",
     "peerconnectioninterface.h",
     "peerconnectionproxy.h",
     "proxy.h",
-    "remoteaudiosource.cc",
-    "remoteaudiosource.h",
-    "rtcstatscollector.cc",
-    "rtcstatscollector.h",
     "rtpparameters.h",
-    "rtpreceiver.cc",
-    "rtpreceiver.h",
     "rtpreceiverinterface.h",
-    "rtpsender.cc",
     "rtpsender.h",
     "rtpsenderinterface.h",
-    "sctputils.cc",
-    "sctputils.h",
-    "statscollector.cc",
-    "statscollector.h",
     "statstypes.cc",
     "statstypes.h",
     "streamcollection.h",
     "trackmediainfomap.cc",
     "trackmediainfomap.h",
     "udptransportinterface.h",
-    "videocapturertracksource.cc",
-    "videocapturertracksource.h",
+    "umametrics.h",
     "videosourceproxy.h",
-    "videotrack.cc",
-    "videotrack.h",
-    "videotracksource.cc",
     "videotracksource.h",
-    "webrtcsdp.cc",
-    "webrtcsdp.h",
-    "webrtcsession.cc",
-    "webrtcsession.h",
-    "webrtcsessiondescriptionfactory.cc",
-    "webrtcsessiondescriptionfactory.h",
   ]
 
-  configs += [ ":libjingle_peerconnection_warnings_config" ]
-
   if (!build_with_chromium && is_clang) {
     # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
     suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
   }
 
   deps = [
-    ":call_api",
     ":rtc_stats_api",
-    "../call",
-    "../media",
-    "../pc",
-    "../stats",
   ]
+}
 
-  if (rtc_use_quic) {
-    sources += [
-      "quicdatachannel.cc",
-      "quicdatachannel.h",
-      "quicdatatransport.cc",
-      "quicdatatransport.h",
-    ]
-    deps += [ "//third_party/libquic" ]
-    public_deps = [
-      "//third_party/libquic",
-    ]
-  }
+# TODO(ossu): Remove once downstream projects have updated.
+rtc_source_set("libjingle_peerconnection") {
+  deps = [
+    "../pc:libjingle_peerconnection",
+  ]
 }
 
 rtc_source_set("rtc_stats_api") {
@@ -157,6 +98,7 @@
   sources = [
     "stats/rtcstats.h",
     "stats/rtcstats_objects.h",
+    "stats/rtcstatscollectorcallback.h",
     "stats/rtcstatsreport.h",
   ]
 
@@ -210,134 +152,6 @@
 }
 
 if (rtc_include_tests) {
-  config("peerconnection_unittests_config") {
-    # The warnings below are enabled by default. Since GN orders compiler flags
-    # for a target before flags from configs, the only way to disable such
-    # warnings is by having them in a separate config, loaded from the target.
-    # TODO(kjellander): Make the code compile without disabling these flags.
-    # See https://bugs.webrtc.org/3307.
-    if (is_clang && is_win) {
-      cflags = [
-        # See https://bugs.chromium.org/p/webrtc/issues/detail?id=6267
-        # for -Wno-sign-compare
-        "-Wno-sign-compare",
-        "-Wno-unused-function",
-      ]
-    }
-
-    if (!is_win) {
-      cflags = [ "-Wno-sign-compare" ]
-    }
-  }
-
-  rtc_test("peerconnection_unittests") {
-    check_includes = false  # TODO(kjellander): Remove (bugs.webrtc.org/6828)
-    testonly = true
-    sources = [
-      "datachannel_unittest.cc",
-      "dtmfsender_unittest.cc",
-      "jsepsessiondescription_unittest.cc",
-      "localaudiosource_unittest.cc",
-      "mediaconstraintsinterface_unittest.cc",
-      "mediastream_unittest.cc",
-      "ortcfactory_unittest.cc",
-      "peerconnection_unittest.cc",
-      "peerconnectionendtoend_unittest.cc",
-      "peerconnectionfactory_unittest.cc",
-      "peerconnectioninterface_unittest.cc",
-      "proxy_unittest.cc",
-      "rtcstats_integrationtest.cc",
-      "rtcstatscollector_unittest.cc",
-      "rtpsenderreceiver_unittest.cc",
-      "sctputils_unittest.cc",
-      "statscollector_unittest.cc",
-      "test/fakeaudiocapturemodule.cc",
-      "test/fakeaudiocapturemodule.h",
-      "test/fakeaudiocapturemodule_unittest.cc",
-      "test/fakeconstraints.h",
-      "test/fakedatachannelprovider.h",
-      "test/fakeperiodicvideocapturer.h",
-      "test/fakertccertificategenerator.h",
-      "test/fakevideotrackrenderer.h",
-      "test/mock_datachannel.h",
-      "test/mock_peerconnection.h",
-      "test/mock_rtpreceiver.h",
-      "test/mock_rtpsender.h",
-      "test/mock_webrtcsession.h",
-      "test/mockpeerconnectionobservers.h",
-      "test/peerconnectiontestwrapper.cc",
-      "test/peerconnectiontestwrapper.h",
-      "test/rtcstatsobtainer.h",
-      "test/testsdpstrings.h",
-      "trackmediainfomap_unittest.cc",
-      "videocapturertracksource_unittest.cc",
-      "videotrack_unittest.cc",
-      "webrtcsdp_unittest.cc",
-      "webrtcsession_unittest.cc",
-    ]
-
-    if (rtc_enable_sctp) {
-      defines = [ "HAVE_SCTP" ]
-    }
-
-    configs += [ ":peerconnection_unittests_config" ]
-
-    if (!build_with_chromium && is_clang) {
-      # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
-      suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
-    }
-
-    # TODO(jschuh): Bug 1348: fix this warning.
-    configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
-
-    if (is_win) {
-      cflags = [
-        "/wd4245",  # conversion from int to size_t, signed/unsigned mismatch.
-        "/wd4389",  # signed/unsigned mismatch.
-      ]
-    }
-
-    if (rtc_use_quic) {
-      public_deps = [
-        "//third_party/libquic",
-      ]
-      sources += [
-        "quicdatachannel_unittest.cc",
-        "quicdatatransport_unittest.cc",
-      ]
-    }
-
-    deps = []
-    if (is_android) {
-      sources += [
-        "test/androidtestinitializer.cc",
-        "test/androidtestinitializer.h",
-      ]
-      deps += [
-        "//testing/android/native_test:native_test_support",
-        "//webrtc/sdk/android:libjingle_peerconnection_java",
-        "//webrtc/sdk/android:libjingle_peerconnection_jni",
-      ]
-    }
-
-    deps += [
-      ":fakemetricsobserver",
-      ":libjingle_peerconnection",
-      "..:webrtc_common",
-      "../base:rtc_base_tests_utils",
-      "../media:rtc_unittest_main",
-      "../pc:rtc_pc",
-      "../system_wrappers:metrics_default",
-      "//testing/gmock",
-    ]
-
-    if (is_android) {
-      deps += [ "//testing/android/native_test:native_test_support" ]
-
-      shard_timeout = 900
-    }
-  }
-
   rtc_source_set("mock_audio_mixer") {
     testonly = true
     sources = [
@@ -354,6 +168,22 @@
     ]
   }
 
+  rtc_source_set("libjingle_peerconnection_test_api") {
+    testonly = true
+    sources = [
+      "test/fakeconstraints.h",
+    ]
+
+    public_deps = [
+      ":libjingle_peerconnection_api",
+    ]
+
+    deps = [
+      "../base:rtc_base_approved",
+      "//webrtc/test:test_support",
+    ]
+  }
+
   rtc_source_set("fakemetricsobserver") {
     testonly = true
     sources = [
@@ -361,7 +191,7 @@
       "fakemetricsobserver.h",
     ]
     deps = [
-      ":libjingle_peerconnection",
+      ":libjingle_peerconnection_api",
       "../base:rtc_base_approved",
     ]
     if (!build_with_chromium && is_clang) {
diff --git a/webrtc/api/DEPS b/webrtc/api/DEPS
index 75f756d..01d719a 100644
--- a/webrtc/api/DEPS
+++ b/webrtc/api/DEPS
@@ -5,35 +5,10 @@
   "+webrtc/media",
   "+webrtc/p2p",
   "+webrtc/pc",
-  "+webrtc/logging/rtc_event_log",
-  "+webrtc/modules/audio_device",
-  "+webrtc/modules/rtp_rtcp",
-  "+webrtc/modules/video_coding",
-  "+webrtc/modules/video_render",
-  "+webrtc/system_wrappers",
 ]
 
 specific_include_rules = {
-  "androidtestinitializer\.cc": [
-    "+base/android",  # Allowed only for Android tests.
-    "+webrtc/voice_engine",
-  ],
-  # The call/call.h exceptions are here only until the peerconnection
-  # implementation has been moved out of api/. See:
-  # http://bugs.webrtc.org/5883
-  "mediacontroller\.cc": [
-    "+webrtc/call/call.h"
-  ],
-  "peerconnection\.cc": [
-    "+webrtc/call/call.h"
-  ],
   "peerconnection_jni\.cc": [
     "+webrtc/voice_engine",
   ],
-  "peerconnectionfactory\.cc": [
-    "+webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h",
-  ],
-  "webrtcsession\.cc": [
-    "+webrtc/call/call.h"
-  ],
 }
diff --git a/webrtc/api/datachannel.h b/webrtc/api/datachannel.h
index cdb2e62..28112ad 100644
--- a/webrtc/api/datachannel.h
+++ b/webrtc/api/datachannel.h
@@ -11,288 +11,8 @@
 #ifndef WEBRTC_API_DATACHANNEL_H_
 #define WEBRTC_API_DATACHANNEL_H_
 
-#include <deque>
-#include <set>
-#include <string>
-
-#include "webrtc/api/datachannelinterface.h"
-#include "webrtc/api/proxy.h"
-#include "webrtc/base/messagehandler.h"
-#include "webrtc/base/scoped_ref_ptr.h"
-#include "webrtc/base/sigslot.h"
-#include "webrtc/media/base/mediachannel.h"
-#include "webrtc/pc/channel.h"
-
-namespace webrtc {
-
-class DataChannel;
-
-class DataChannelProviderInterface {
- public:
-  // Sends the data to the transport.
-  virtual bool SendData(const cricket::SendDataParams& params,
-                        const rtc::CopyOnWriteBuffer& payload,
-                        cricket::SendDataResult* result) = 0;
-  // Connects to the transport signals.
-  virtual bool ConnectDataChannel(DataChannel* data_channel) = 0;
-  // Disconnects from the transport signals.
-  virtual void DisconnectDataChannel(DataChannel* data_channel) = 0;
-  // Adds the data channel SID to the transport for SCTP.
-  virtual void AddSctpDataStream(int sid) = 0;
-  // Removes the data channel SID from the transport for SCTP.
-  virtual void RemoveSctpDataStream(int sid) = 0;
-  // Returns true if the transport channel is ready to send data.
-  virtual bool ReadyToSendData() const = 0;
-
- protected:
-  virtual ~DataChannelProviderInterface() {}
-};
-
-struct InternalDataChannelInit : public DataChannelInit {
-  enum OpenHandshakeRole {
-    kOpener,
-    kAcker,
-    kNone
-  };
-  // The default role is kOpener because the default |negotiated| is false.
-  InternalDataChannelInit() : open_handshake_role(kOpener) {}
-  explicit InternalDataChannelInit(const DataChannelInit& base)
-      : DataChannelInit(base), open_handshake_role(kOpener) {
-    // If the channel is externally negotiated, do not send the OPEN message.
-    if (base.negotiated) {
-      open_handshake_role = kNone;
-    }
-  }
-
-  OpenHandshakeRole open_handshake_role;
-};
-
-// Helper class to allocate unique IDs for SCTP DataChannels
-class SctpSidAllocator {
- public:
-  // Gets the first unused odd/even id based on the DTLS role. If |role| is
-  // SSL_CLIENT, the allocated id starts from 0 and takes even numbers;
-  // otherwise, the id starts from 1 and takes odd numbers.
-  // Returns false if no id can be allocated.
-  bool AllocateSid(rtc::SSLRole role, int* sid);
-
-  // Attempts to reserve a specific sid. Returns false if it's unavailable.
-  bool ReserveSid(int sid);
-
-  // Indicates that |sid| isn't in use any more, and is thus available again.
-  void ReleaseSid(int sid);
-
- private:
-  // Checks if |sid| is available to be assigned to a new SCTP data channel.
-  bool IsSidAvailable(int sid) const;
-
-  std::set<int> used_sids_;
-};
-
-// DataChannel is a an implementation of the DataChannelInterface based on
-// libjingle's data engine. It provides an implementation of unreliable or
-// reliabledata channels. Currently this class is specifically designed to use
-// both RtpDataEngine and SctpDataEngine.
-
-// DataChannel states:
-// kConnecting: The channel has been created the transport might not yet be
-//              ready.
-// kOpen: The channel have a local SSRC set by a call to UpdateSendSsrc
-//        and a remote SSRC set by call to UpdateReceiveSsrc and the transport
-//        has been writable once.
-// kClosing: DataChannelInterface::Close has been called or UpdateReceiveSsrc
-//           has been called with SSRC==0
-// kClosed: Both UpdateReceiveSsrc and UpdateSendSsrc has been called with
-//          SSRC==0.
-class DataChannel : public DataChannelInterface,
-                    public sigslot::has_slots<>,
-                    public rtc::MessageHandler {
- public:
-  static rtc::scoped_refptr<DataChannel> Create(
-      DataChannelProviderInterface* provider,
-      cricket::DataChannelType dct,
-      const std::string& label,
-      const InternalDataChannelInit& config);
-
-  virtual void RegisterObserver(DataChannelObserver* observer);
-  virtual void UnregisterObserver();
-
-  virtual std::string label() const { return label_; }
-  virtual bool reliable() const;
-  virtual bool ordered() const { return config_.ordered; }
-  virtual uint16_t maxRetransmitTime() const {
-    return config_.maxRetransmitTime;
-  }
-  virtual uint16_t maxRetransmits() const { return config_.maxRetransmits; }
-  virtual std::string protocol() const { return config_.protocol; }
-  virtual bool negotiated() const { return config_.negotiated; }
-  virtual int id() const { return config_.id; }
-  virtual uint64_t buffered_amount() const;
-  virtual void Close();
-  virtual DataState state() const { return state_; }
-  virtual uint32_t messages_sent() const { return messages_sent_; }
-  virtual uint64_t bytes_sent() const { return bytes_sent_; }
-  virtual uint32_t messages_received() const { return messages_received_; }
-  virtual uint64_t bytes_received() const { return bytes_received_; }
-  virtual bool Send(const DataBuffer& buffer);
-
-  // rtc::MessageHandler override.
-  virtual void OnMessage(rtc::Message* msg);
-
-  // Called when the channel's ready to use.  That can happen when the
-  // underlying DataMediaChannel becomes ready, or when this channel is a new
-  // stream on an existing DataMediaChannel, and we've finished negotiation.
-  void OnChannelReady(bool writable);
-
-  // Slots for provider to connect signals to.
-  void OnDataReceived(const cricket::ReceiveDataParams& params,
-                      const rtc::CopyOnWriteBuffer& payload);
-  void OnStreamClosedRemotely(int sid);
-
-  // The remote peer request that this channel should be closed.
-  void RemotePeerRequestClose();
-
-  // The following methods are for SCTP only.
-
-  // Sets the SCTP sid and adds to transport layer if not set yet. Should only
-  // be called once.
-  void SetSctpSid(int sid);
-  // Called when the transport channel is created.
-  // Only needs to be called for SCTP data channels.
-  void OnTransportChannelCreated();
-  // Called when the transport channel is destroyed.
-  // This method makes sure the DataChannel is disconnected and changes state
-  // to kClosed.
-  void OnTransportChannelDestroyed();
-
-  // The following methods are for RTP only.
-
-  // Set the SSRC this channel should use to send data on the
-  // underlying data engine. |send_ssrc| == 0 means that the channel is no
-  // longer part of the session negotiation.
-  void SetSendSsrc(uint32_t send_ssrc);
-  // Set the SSRC this channel should use to receive data from the
-  // underlying data engine.
-  void SetReceiveSsrc(uint32_t receive_ssrc);
-
-  cricket::DataChannelType data_channel_type() const {
-    return data_channel_type_;
-  }
-
-  // Emitted when state transitions to kOpen.
-  sigslot::signal1<DataChannel*> SignalOpened;
-  // Emitted when state transitions to kClosed.
-  // In the case of SCTP channels, this signal can be used to tell when the
-  // channel's sid is free.
-  sigslot::signal1<DataChannel*> SignalClosed;
-
- protected:
-  DataChannel(DataChannelProviderInterface* client,
-              cricket::DataChannelType dct,
-              const std::string& label);
-  virtual ~DataChannel();
-
- private:
-  // A packet queue which tracks the total queued bytes. Queued packets are
-  // owned by this class.
-  class PacketQueue {
-   public:
-    PacketQueue();
-    ~PacketQueue();
-
-    size_t byte_count() const {
-      return byte_count_;
-    }
-
-    bool Empty() const;
-
-    DataBuffer* Front();
-
-    void Pop();
-
-    void Push(DataBuffer* packet);
-
-    void Clear();
-
-    void Swap(PacketQueue* other);
-
-   private:
-    std::deque<DataBuffer*> packets_;
-    size_t byte_count_;
-  };
-
-  // The OPEN(_ACK) signaling state.
-  enum HandshakeState {
-    kHandshakeInit,
-    kHandshakeShouldSendOpen,
-    kHandshakeShouldSendAck,
-    kHandshakeWaitingForAck,
-    kHandshakeReady
-  };
-
-  bool Init(const InternalDataChannelInit& config);
-  void DoClose();
-  void UpdateState();
-  void SetState(DataState state);
-  void DisconnectFromProvider();
-
-  void DeliverQueuedReceivedData();
-
-  void SendQueuedDataMessages();
-  bool SendDataMessage(const DataBuffer& buffer, bool queue_if_blocked);
-  bool QueueSendDataMessage(const DataBuffer& buffer);
-
-  void SendQueuedControlMessages();
-  void QueueControlMessage(const rtc::CopyOnWriteBuffer& buffer);
-  bool SendControlMessage(const rtc::CopyOnWriteBuffer& buffer);
-
-  std::string label_;
-  InternalDataChannelInit config_;
-  DataChannelObserver* observer_;
-  DataState state_;
-  uint32_t messages_sent_;
-  uint64_t bytes_sent_;
-  uint32_t messages_received_;
-  uint64_t bytes_received_;
-  cricket::DataChannelType data_channel_type_;
-  DataChannelProviderInterface* provider_;
-  HandshakeState handshake_state_;
-  bool connected_to_provider_;
-  bool send_ssrc_set_;
-  bool receive_ssrc_set_;
-  bool writable_;
-  uint32_t send_ssrc_;
-  uint32_t receive_ssrc_;
-  // Control messages that always have to get sent out before any queued
-  // data.
-  PacketQueue queued_control_data_;
-  PacketQueue queued_received_data_;
-  PacketQueue queued_send_data_;
-};
-
-// Define proxy for DataChannelInterface.
-BEGIN_SIGNALING_PROXY_MAP(DataChannel)
-  PROXY_SIGNALING_THREAD_DESTRUCTOR()
-  PROXY_METHOD1(void, RegisterObserver, DataChannelObserver*)
-  PROXY_METHOD0(void, UnregisterObserver)
-  PROXY_CONSTMETHOD0(std::string, label)
-  PROXY_CONSTMETHOD0(bool, reliable)
-  PROXY_CONSTMETHOD0(bool, ordered)
-  PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime)
-  PROXY_CONSTMETHOD0(uint16_t, maxRetransmits)
-  PROXY_CONSTMETHOD0(std::string, protocol)
-  PROXY_CONSTMETHOD0(bool, negotiated)
-  PROXY_CONSTMETHOD0(int, id)
-  PROXY_CONSTMETHOD0(DataState, state)
-  PROXY_CONSTMETHOD0(uint32_t, messages_sent)
-  PROXY_CONSTMETHOD0(uint64_t, bytes_sent)
-  PROXY_CONSTMETHOD0(uint32_t, messages_received)
-  PROXY_CONSTMETHOD0(uint64_t, bytes_received)
-  PROXY_CONSTMETHOD0(uint64_t, buffered_amount)
-  PROXY_METHOD0(void, Close)
-  PROXY_METHOD1(bool, Send, const DataBuffer&)
-END_PROXY_MAP()
-
-}  // namespace webrtc
+// Including this file is deprecated. It is no longer part of the public API.
+// This only includes the file in its new location for backwards compatibility.
+#include "webrtc/pc/datachannel.h"
 
 #endif  // WEBRTC_API_DATACHANNEL_H_
diff --git a/webrtc/api/mediacontroller.h b/webrtc/api/mediacontroller.h
index 5ada20d..9c2b708 100644
--- a/webrtc/api/mediacontroller.h
+++ b/webrtc/api/mediacontroller.h
@@ -11,34 +11,8 @@
 #ifndef WEBRTC_API_MEDIACONTROLLER_H_
 #define WEBRTC_API_MEDIACONTROLLER_H_
 
-#include "webrtc/base/thread.h"
-
-namespace cricket {
-class ChannelManager;
-struct MediaConfig;
-}  // namespace cricket
-
-namespace webrtc {
-class Call;
-class VoiceEngine;
-class RtcEventLog;
-
-// The MediaController currently owns shared state between media channels, but
-// in the future will create and own RtpSenders and RtpReceivers.
-class MediaControllerInterface {
- public:
-  static MediaControllerInterface* Create(
-      const cricket::MediaConfig& config,
-      rtc::Thread* worker_thread,
-      cricket::ChannelManager* channel_manager,
-      webrtc::RtcEventLog* event_log);
-
-  virtual ~MediaControllerInterface() {}
-  virtual void Close() = 0;
-  virtual webrtc::Call* call_w() = 0;
-  virtual cricket::ChannelManager* channel_manager() const = 0;
-  virtual const cricket::MediaConfig& config() const = 0;
-};
-}  // namespace webrtc
+// Including this file is deprecated. It is no longer part of the public API.
+// This only includes the file in its new location for backwards compatibility.
+#include "webrtc/pc/mediacontroller.h"
 
 #endif  // WEBRTC_API_MEDIACONTROLLER_H_
diff --git a/webrtc/api/mediastream.h b/webrtc/api/mediastream.h
index 1f80f25..e6556c5 100644
--- a/webrtc/api/mediastream.h
+++ b/webrtc/api/mediastream.h
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2011 The WebRTC project authors. All Rights Reserved.
+ *  Copyright 2015 The WebRTC project authors. All Rights Reserved.
  *
  *  Use of this source code is governed by a BSD-style license
  *  that can be found in the LICENSE file in the root of the source
@@ -8,51 +8,11 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-// This file contains the implementation of MediaStreamInterface interface.
-
 #ifndef WEBRTC_API_MEDIASTREAM_H_
 #define WEBRTC_API_MEDIASTREAM_H_
 
-#include <string>
-#include <vector>
-
-#include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/notifier.h"
-
-namespace webrtc {
-
-class MediaStream : public Notifier<MediaStreamInterface> {
- public:
-  static rtc::scoped_refptr<MediaStream> Create(const std::string& label);
-
-  std::string label() const override { return label_; }
-
-  bool AddTrack(AudioTrackInterface* track) override;
-  bool AddTrack(VideoTrackInterface* track) override;
-  bool RemoveTrack(AudioTrackInterface* track) override;
-  bool RemoveTrack(VideoTrackInterface* track) override;
-  rtc::scoped_refptr<AudioTrackInterface>
-      FindAudioTrack(const std::string& track_id) override;
-  rtc::scoped_refptr<VideoTrackInterface>
-      FindVideoTrack(const std::string& track_id) override;
-
-  AudioTrackVector GetAudioTracks() override { return audio_tracks_; }
-  VideoTrackVector GetVideoTracks() override { return video_tracks_; }
-
- protected:
-  explicit MediaStream(const std::string& label);
-
- private:
-  template <typename TrackVector, typename Track>
-  bool AddTrack(TrackVector* Tracks, Track* track);
-  template <typename TrackVector>
-  bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track);
-
-  std::string label_;
-  AudioTrackVector audio_tracks_;
-  VideoTrackVector video_tracks_;
-};
-
-}  // namespace webrtc
+// Including this file is deprecated. It is no longer part of the public API.
+// This only includes the file in its new location for backwards compatibility.
+#include "webrtc/pc/mediastream.h"
 
 #endif  // WEBRTC_API_MEDIASTREAM_H_
diff --git a/webrtc/api/test/androidtestinitializer.h b/webrtc/api/mediastreaminterface.cc
similarity index 60%
copy from webrtc/api/test/androidtestinitializer.h
copy to webrtc/api/mediastreaminterface.cc
index b56783e..d4fe5cb 100644
--- a/webrtc/api/test/androidtestinitializer.h
+++ b/webrtc/api/mediastreaminterface.cc
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2015 The WebRTC project authors. All Rights Reserved.
+ *  Copyright 2017 The WebRTC project authors. All Rights Reserved.
  *
  *  Use of this source code is governed by a BSD-style license
  *  that can be found in the LICENSE file in the root of the source
@@ -8,13 +8,11 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_
-#define WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_
+#include "webrtc/api/mediastreaminterface.h"
 
 namespace webrtc {
 
-void InitializeAndroidObjects();
+const char MediaStreamTrackInterface::kVideoKind[] = "video";
+const char MediaStreamTrackInterface::kAudioKind[] = "audio";
 
 }  // namespace webrtc
-
-#endif  // WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_
diff --git a/webrtc/api/mediastreamtrack.h b/webrtc/api/mediastreamtrack.h
index 9ba0420..6075abe 100644
--- a/webrtc/api/mediastreamtrack.h
+++ b/webrtc/api/mediastreamtrack.h
@@ -11,52 +11,8 @@
 #ifndef WEBRTC_API_MEDIASTREAMTRACK_H_
 #define WEBRTC_API_MEDIASTREAMTRACK_H_
 
-#include <string>
-
-#include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/notifier.h"
-
-namespace webrtc {
-
-// MediaTrack implements the interface common to AudioTrackInterface and
-// VideoTrackInterface.
-template <typename T>
-class MediaStreamTrack : public Notifier<T> {
- public:
-  typedef typename T::TrackState TypedTrackState;
-
-  std::string id() const override { return id_; }
-  MediaStreamTrackInterface::TrackState state() const override {
-    return state_;
-  }
-  bool enabled() const override { return enabled_; }
-  bool set_enabled(bool enable) override {
-    bool fire_on_change = (enable != enabled_);
-    enabled_ = enable;
-    if (fire_on_change) {
-      Notifier<T>::FireOnChanged();
-    }
-    return fire_on_change;
-  }
-
- protected:
-  explicit MediaStreamTrack(const std::string& id)
-      : enabled_(true), id_(id), state_(MediaStreamTrackInterface::kLive) {}
-
-  bool set_state(MediaStreamTrackInterface::TrackState new_state) {
-    bool fire_on_change = (state_ != new_state);
-    state_ = new_state;
-    if (fire_on_change)
-      Notifier<T>::FireOnChanged();
-    return true;
-  }
-
- private:
-  bool enabled_;
-  std::string id_;
-  MediaStreamTrackInterface::TrackState state_;
-};
-
-}  // namespace webrtc
+// Including this file is deprecated. It is no longer part of the public API.
+// This only includes the file in its new location for backwards compatibility.
+#include "webrtc/pc/mediastreamtrack.h"
 
 #endif  // WEBRTC_API_MEDIASTREAMTRACK_H_
diff --git a/webrtc/api/mediatypes.cc b/webrtc/api/mediatypes.cc
new file mode 100644
index 0000000..97b0189
--- /dev/null
+++ b/webrtc/api/mediatypes.cc
@@ -0,0 +1,35 @@
+/*
+ *  Copyright 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/api/mediatypes.h"
+#include "webrtc/base/checks.h"
+
+namespace cricket {
+
+std::string MediaTypeToString(MediaType type) {
+  std::string type_str;
+  switch (type) {
+    case MEDIA_TYPE_AUDIO:
+      type_str = "audio";
+      break;
+    case MEDIA_TYPE_VIDEO:
+      type_str = "video";
+      break;
+    case MEDIA_TYPE_DATA:
+      type_str = "data";
+      break;
+    default:
+      RTC_NOTREACHED();
+      break;
+  }
+  return type_str;
+}
+
+}  // namespace cricket
diff --git a/webrtc/api/mediatypes.h b/webrtc/api/mediatypes.h
new file mode 100644
index 0000000..19acf4b
--- /dev/null
+++ b/webrtc/api/mediatypes.h
@@ -0,0 +1,28 @@
+/*
+ *  Copyright 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_API_MEDIATYPES_H_
+#define WEBRTC_API_MEDIATYPES_H_
+
+#include <string>
+
+namespace cricket {
+
+enum MediaType {
+  MEDIA_TYPE_AUDIO,
+  MEDIA_TYPE_VIDEO,
+  MEDIA_TYPE_DATA
+};
+
+std::string MediaTypeToString(MediaType type);
+
+}  // namespace cricket
+
+#endif  // WEBRTC_API_MEDIATYPES_H_
diff --git a/webrtc/api/peerconnectioninterface.h b/webrtc/api/peerconnectioninterface.h
index e622e52..e42c60f 100644
--- a/webrtc/api/peerconnectioninterface.h
+++ b/webrtc/api/peerconnectioninterface.h
@@ -61,7 +61,7 @@
 #include "webrtc/api/dtmfsenderinterface.h"
 #include "webrtc/api/jsep.h"
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/rtcstatscollector.h"
+#include "webrtc/api/stats/rtcstatscollectorcallback.h"
 #include "webrtc/api/rtpreceiverinterface.h"
 #include "webrtc/api/rtpsenderinterface.h"
 #include "webrtc/api/statstypes.h"
diff --git a/webrtc/api/rtpreceiverinterface.h b/webrtc/api/rtpreceiverinterface.h
index 103df47..4e47c9a 100644
--- a/webrtc/api/rtpreceiverinterface.h
+++ b/webrtc/api/rtpreceiverinterface.h
@@ -16,12 +16,12 @@
 
 #include <string>
 
+#include "webrtc/api/mediatypes.h"
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/api/proxy.h"
 #include "webrtc/api/rtpparameters.h"
 #include "webrtc/base/refcount.h"
 #include "webrtc/base/scoped_ref_ptr.h"
-#include "webrtc/pc/mediasession.h"
 
 namespace webrtc {
 
diff --git a/webrtc/api/rtpsender.h b/webrtc/api/rtpsender.h
index 6c05921..3b7faec 100644
--- a/webrtc/api/rtpsender.h
+++ b/webrtc/api/rtpsender.h
@@ -8,228 +8,11 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-// This file contains classes that implement RtpSenderInterface.
-// An RtpSender associates a MediaStreamTrackInterface with an underlying
-// transport (provided by AudioProviderInterface/VideoProviderInterface)
-
 #ifndef WEBRTC_API_RTPSENDER_H_
 #define WEBRTC_API_RTPSENDER_H_
 
-#include <memory>
-#include <string>
-
-#include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/rtpsenderinterface.h"
-#include "webrtc/api/statscollector.h"
-#include "webrtc/base/basictypes.h"
-#include "webrtc/base/criticalsection.h"
-#include "webrtc/media/base/audiosource.h"
-#include "webrtc/pc/channel.h"
-
-namespace webrtc {
-
-// Internal interface used by PeerConnection.
-class RtpSenderInternal : public RtpSenderInterface {
- public:
-  // Used to set the SSRC of the sender, once a local description has been set.
-  // If |ssrc| is 0, this indiates that the sender should disconnect from the
-  // underlying transport (this occurs if the sender isn't seen in a local
-  // description).
-  virtual void SetSsrc(uint32_t ssrc) = 0;
-
-  // TODO(deadbeef): Support one sender having multiple stream ids.
-  virtual void set_stream_id(const std::string& stream_id) = 0;
-  virtual std::string stream_id() const = 0;
-
-  virtual void Stop() = 0;
-};
-
-// LocalAudioSinkAdapter receives data callback as a sink to the local
-// AudioTrack, and passes the data to the sink of AudioSource.
-class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
-                              public cricket::AudioSource {
- public:
-  LocalAudioSinkAdapter();
-  virtual ~LocalAudioSinkAdapter();
-
- private:
-  // AudioSinkInterface implementation.
-  void OnData(const void* audio_data,
-              int bits_per_sample,
-              int sample_rate,
-              size_t number_of_channels,
-              size_t number_of_frames) override;
-
-  // cricket::AudioSource implementation.
-  void SetSink(cricket::AudioSource::Sink* sink) override;
-
-  cricket::AudioSource::Sink* sink_;
-  // Critical section protecting |sink_|.
-  rtc::CriticalSection lock_;
-};
-
-class AudioRtpSender : public ObserverInterface,
-                       public rtc::RefCountedObject<RtpSenderInternal> {
- public:
-  // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called
-  // at the appropriate times.
-  // |channel| can be null if one does not exist yet.
-  AudioRtpSender(AudioTrackInterface* track,
-                 const std::string& stream_id,
-                 cricket::VoiceChannel* channel,
-                 StatsCollector* stats);
-
-  // Randomly generates stream_id.
-  // |channel| can be null if one does not exist yet.
-  AudioRtpSender(AudioTrackInterface* track,
-                 cricket::VoiceChannel* channel,
-                 StatsCollector* stats);
-
-  // Randomly generates id and stream_id.
-  // |channel| can be null if one does not exist yet.
-  AudioRtpSender(cricket::VoiceChannel* channel, StatsCollector* stats);
-
-  virtual ~AudioRtpSender();
-
-  // ObserverInterface implementation
-  void OnChanged() override;
-
-  // RtpSenderInterface implementation
-  bool SetTrack(MediaStreamTrackInterface* track) override;
-  rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
-    return track_;
-  }
-
-  uint32_t ssrc() const override { return ssrc_; }
-
-  cricket::MediaType media_type() const override {
-    return cricket::MEDIA_TYPE_AUDIO;
-  }
-
-  std::string id() const override { return id_; }
-
-  std::vector<std::string> stream_ids() const override {
-    std::vector<std::string> ret = {stream_id_};
-    return ret;
-  }
-
-  RtpParameters GetParameters() const override;
-  bool SetParameters(const RtpParameters& parameters) override;
-
-  // RtpSenderInternal implementation.
-  void SetSsrc(uint32_t ssrc) override;
-
-  void set_stream_id(const std::string& stream_id) override {
-    stream_id_ = stream_id;
-  }
-  std::string stream_id() const override { return stream_id_; }
-
-  void Stop() override;
-
-  // Does not take ownership.
-  // Should call SetChannel(nullptr) before |channel| is destroyed.
-  void SetChannel(cricket::VoiceChannel* channel) { channel_ = channel; }
-
- private:
-  // TODO(nisse): Since SSRC == 0 is technically valid, figure out
-  // some other way to test if we have a valid SSRC.
-  bool can_send_track() const { return track_ && ssrc_; }
-  // Helper function to construct options for
-  // AudioProviderInterface::SetAudioSend.
-  void SetAudioSend();
-  // Helper function to call SetAudioSend with "stop sending" parameters.
-  void ClearAudioSend();
-
-  std::string id_;
-  std::string stream_id_;
-  cricket::VoiceChannel* channel_ = nullptr;
-  StatsCollector* stats_;
-  rtc::scoped_refptr<AudioTrackInterface> track_;
-  uint32_t ssrc_ = 0;
-  bool cached_track_enabled_ = false;
-  bool stopped_ = false;
-
-  // Used to pass the data callback from the |track_| to the other end of
-  // cricket::AudioSource.
-  std::unique_ptr<LocalAudioSinkAdapter> sink_adapter_;
-};
-
-class VideoRtpSender : public ObserverInterface,
-                       public rtc::RefCountedObject<RtpSenderInternal> {
- public:
-  // |channel| can be null if one does not exist yet.
-  VideoRtpSender(VideoTrackInterface* track,
-                 const std::string& stream_id,
-                 cricket::VideoChannel* channel);
-
-  // Randomly generates stream_id.
-  // |channel| can be null if one does not exist yet.
-  VideoRtpSender(VideoTrackInterface* track, cricket::VideoChannel* channel);
-
-  // Randomly generates id and stream_id.
-  // |channel| can be null if one does not exist yet.
-  explicit VideoRtpSender(cricket::VideoChannel* channel);
-
-  virtual ~VideoRtpSender();
-
-  // ObserverInterface implementation
-  void OnChanged() override;
-
-  // RtpSenderInterface implementation
-  bool SetTrack(MediaStreamTrackInterface* track) override;
-  rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
-    return track_;
-  }
-
-  uint32_t ssrc() const override { return ssrc_; }
-
-  cricket::MediaType media_type() const override {
-    return cricket::MEDIA_TYPE_VIDEO;
-  }
-
-  std::string id() const override { return id_; }
-
-  std::vector<std::string> stream_ids() const override {
-    std::vector<std::string> ret = {stream_id_};
-    return ret;
-  }
-
-  RtpParameters GetParameters() const override;
-  bool SetParameters(const RtpParameters& parameters) override;
-
-  // RtpSenderInternal implementation.
-  void SetSsrc(uint32_t ssrc) override;
-
-  void set_stream_id(const std::string& stream_id) override {
-    stream_id_ = stream_id;
-  }
-  std::string stream_id() const override { return stream_id_; }
-
-  void Stop() override;
-
-  // Does not take ownership.
-  // Should call SetChannel(nullptr) before |channel| is destroyed.
-  void SetChannel(cricket::VideoChannel* channel) { channel_ = channel; }
-
- private:
-  bool can_send_track() const { return track_ && ssrc_; }
-  // Helper function to construct options for
-  // VideoProviderInterface::SetVideoSend.
-  void SetVideoSend();
-  // Helper function to call SetVideoSend with "stop sending" parameters.
-  void ClearVideoSend();
-
-  std::string id_;
-  std::string stream_id_;
-  cricket::VideoChannel* channel_ = nullptr;
-  rtc::scoped_refptr<VideoTrackInterface> track_;
-  uint32_t ssrc_ = 0;
-  bool cached_track_enabled_ = false;
-  VideoTrackInterface::ContentHint cached_track_content_hint_ =
-      VideoTrackInterface::ContentHint::kNone;
-  bool stopped_ = false;
-};
-
-}  // namespace webrtc
+// Including this file is deprecated. It is no longer part of the public API.
+// This only includes the file in its new location for backwards compatibility.
+#include "webrtc/pc/rtpsender.h"
 
 #endif  // WEBRTC_API_RTPSENDER_H_
diff --git a/webrtc/api/rtpsenderinterface.h b/webrtc/api/rtpsenderinterface.h
index 2e6b742..7129376 100644
--- a/webrtc/api/rtpsenderinterface.h
+++ b/webrtc/api/rtpsenderinterface.h
@@ -17,12 +17,12 @@
 #include <string>
 #include <vector>
 
+#include "webrtc/api/mediatypes.h"
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/api/proxy.h"
 #include "webrtc/api/rtpparameters.h"
 #include "webrtc/base/refcount.h"
 #include "webrtc/base/scoped_ref_ptr.h"
-#include "webrtc/pc/mediasession.h"
 
 namespace webrtc {
 
diff --git a/webrtc/api/stats/rtcstatscollectorcallback.h b/webrtc/api/stats/rtcstatscollectorcallback.h
new file mode 100644
index 0000000..2493e49
--- /dev/null
+++ b/webrtc/api/stats/rtcstatscollectorcallback.h
@@ -0,0 +1,30 @@
+/*
+ *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_API_STATS_RTCSTATSCOLLECTORCALLBACK_H_
+#define WEBRTC_API_STATS_RTCSTATSCOLLECTORCALLBACK_H_
+
+#include "webrtc/api/stats/rtcstatsreport.h"
+#include "webrtc/base/refcount.h"
+#include "webrtc/base/scoped_ref_ptr.h"
+
+namespace webrtc {
+
+class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface {
+ public:
+  virtual ~RTCStatsCollectorCallback() {}
+
+  virtual void OnStatsDelivered(
+      const rtc::scoped_refptr<const RTCStatsReport>& report) = 0;
+};
+
+}  // namespace webrtc
+
+#endif  // WEBRTC_API_STATS_RTCSTATSCOLLECTORCALLBACK_H_
diff --git a/webrtc/api/statstypes.cc b/webrtc/api/statstypes.cc
index 80b0d76..300bb4a 100644
--- a/webrtc/api/statstypes.cc
+++ b/webrtc/api/statstypes.cc
@@ -632,6 +632,8 @@
   RTC_DCHECK(id_.get());
 }
 
+StatsReport::~StatsReport() = default;
+
 // static
 StatsReport::Id StatsReport::NewBandwidthEstimationId() {
   return Id(new RefCountedObject<BandwidthEstimationId>());
diff --git a/webrtc/api/statstypes.h b/webrtc/api/statstypes.h
index 788c2c4..26e2ac4 100644
--- a/webrtc/api/statstypes.h
+++ b/webrtc/api/statstypes.h
@@ -342,6 +342,7 @@
 
   // Ownership of |id| is passed to |this|.
   explicit StatsReport(const Id& id);
+  ~StatsReport();
 
   // Factory functions for various types of stats IDs.
   static Id NewBandwidthEstimationId();
diff --git a/webrtc/api/streamcollection.h b/webrtc/api/streamcollection.h
index bedad83..0f847f1 100644
--- a/webrtc/api/streamcollection.h
+++ b/webrtc/api/streamcollection.h
@@ -11,98 +11,8 @@
 #ifndef WEBRTC_API_STREAMCOLLECTION_H_
 #define WEBRTC_API_STREAMCOLLECTION_H_
 
-#include <string>
-#include <vector>
-
-#include "webrtc/api/peerconnectioninterface.h"
-
-namespace webrtc {
-
-// Implementation of StreamCollection.
-class StreamCollection : public StreamCollectionInterface {
- public:
-  static rtc::scoped_refptr<StreamCollection> Create() {
-    rtc::RefCountedObject<StreamCollection>* implementation =
-         new rtc::RefCountedObject<StreamCollection>();
-    return implementation;
-  }
-
-  static rtc::scoped_refptr<StreamCollection> Create(
-      StreamCollection* streams) {
-    rtc::RefCountedObject<StreamCollection>* implementation =
-         new rtc::RefCountedObject<StreamCollection>(streams);
-    return implementation;
-  }
-
-  virtual size_t count() {
-    return media_streams_.size();
-  }
-
-  virtual MediaStreamInterface* at(size_t index) {
-    return media_streams_.at(index);
-  }
-
-  virtual MediaStreamInterface* find(const std::string& label) {
-    for (StreamVector::iterator it = media_streams_.begin();
-         it != media_streams_.end(); ++it) {
-      if ((*it)->label().compare(label) == 0) {
-        return (*it);
-      }
-    }
-    return NULL;
-  }
-
-  virtual MediaStreamTrackInterface* FindAudioTrack(
-      const std::string& id) {
-    for (size_t i = 0; i < media_streams_.size(); ++i) {
-      MediaStreamTrackInterface* track = media_streams_[i]->FindAudioTrack(id);
-      if (track) {
-        return track;
-      }
-    }
-    return NULL;
-  }
-
-  virtual MediaStreamTrackInterface* FindVideoTrack(
-      const std::string& id) {
-    for (size_t i = 0; i < media_streams_.size(); ++i) {
-      MediaStreamTrackInterface* track = media_streams_[i]->FindVideoTrack(id);
-      if (track) {
-        return track;
-      }
-    }
-    return NULL;
-  }
-
-  void AddStream(MediaStreamInterface* stream) {
-    for (StreamVector::iterator it = media_streams_.begin();
-         it != media_streams_.end(); ++it) {
-      if ((*it)->label().compare(stream->label()) == 0)
-        return;
-    }
-    media_streams_.push_back(stream);
-  }
-
-  void RemoveStream(MediaStreamInterface* remove_stream) {
-    for (StreamVector::iterator it = media_streams_.begin();
-         it != media_streams_.end(); ++it) {
-      if ((*it)->label().compare(remove_stream->label()) == 0) {
-        media_streams_.erase(it);
-        break;
-      }
-    }
-  }
-
- protected:
-  StreamCollection() {}
-  explicit StreamCollection(StreamCollection* original)
-      : media_streams_(original->media_streams_) {
-  }
-  typedef std::vector<rtc::scoped_refptr<MediaStreamInterface> >
-      StreamVector;
-  StreamVector media_streams_;
-};
-
-}  // namespace webrtc
+// Including this file is deprecated. It is no longer part of the public API.
+// This only includes the file in its new location for backwards compatibility.
+#include "webrtc/pc/streamcollection.h"
 
 #endif  // WEBRTC_API_STREAMCOLLECTION_H_
diff --git a/webrtc/api/videotracksource.h b/webrtc/api/videotracksource.h
index 330af23..45366cd 100644
--- a/webrtc/api/videotracksource.h
+++ b/webrtc/api/videotracksource.h
@@ -11,45 +11,8 @@
 #ifndef WEBRTC_API_VIDEOTRACKSOURCE_H_
 #define WEBRTC_API_VIDEOTRACKSOURCE_H_
 
-#include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/notifier.h"
-#include "webrtc/base/thread_checker.h"
-#include "webrtc/media/base/mediachannel.h"
-#include "webrtc/media/base/videosinkinterface.h"
-
-// VideoTrackSource implements VideoTrackSourceInterface.
-namespace webrtc {
-
-class VideoTrackSource : public Notifier<VideoTrackSourceInterface> {
- public:
-  VideoTrackSource(rtc::VideoSourceInterface<VideoFrame>* source, bool remote);
-  void SetState(SourceState new_state);
-  // OnSourceDestroyed clears this instance pointer to |source_|. It is useful
-  // when the underlying rtc::VideoSourceInterface is destroyed before the
-  // reference counted VideoTrackSource.
-  void OnSourceDestroyed();
-
-  SourceState state() const override { return state_; }
-  bool remote() const override { return remote_; }
-
-  bool is_screencast() const override { return false; }
-  rtc::Optional<bool> needs_denoising() const override {
-    return rtc::Optional<bool>(); }
-
-  bool GetStats(Stats* stats) override { return false; }
-
-  void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
-                       const rtc::VideoSinkWants& wants) override;
-  void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
-
- private:
-  rtc::ThreadChecker worker_thread_checker_;
-  rtc::VideoSourceInterface<VideoFrame>* source_;
-  cricket::VideoOptions options_;
-  SourceState state_;
-  const bool remote_;
-};
-
-}  // namespace webrtc
+// Including this file is deprecated. It is no longer part of the public API.
+// This only includes the file in its new location for backwards compatibility.
+#include "webrtc/pc/videotracksource.h"
 
 #endif  //  WEBRTC_API_VIDEOTRACKSOURCE_H_
diff --git a/webrtc/build/gn_isolate_map.pyl b/webrtc/build/gn_isolate_map.pyl
index ed56777..a6e357e 100644
--- a/webrtc/build/gn_isolate_map.pyl
+++ b/webrtc/build/gn_isolate_map.pyl
@@ -52,7 +52,7 @@
     "type": "windowed_test_launcher",
   },
   "peerconnection_unittests": {
-    "label": "//webrtc/api:peerconnection_unittests",
+    "label": "//webrtc/pc:peerconnection_unittests",
     "type": "console_test_launcher",
   },
   "rtc_media_unittests": {
diff --git a/webrtc/examples/BUILD.gn b/webrtc/examples/BUILD.gn
index eaa3bc9..6f7eaa7 100644
--- a/webrtc/examples/BUILD.gn
+++ b/webrtc/examples/BUILD.gn
@@ -505,7 +505,7 @@
     }
     deps = [
       "//third_party/libyuv",
-      "//webrtc/api:libjingle_peerconnection",
+      "//webrtc/pc:libjingle_peerconnection",
       "//webrtc/system_wrappers:field_trial_default",
       "//webrtc/system_wrappers:metrics_default",
     ]
diff --git a/webrtc/examples/DEPS b/webrtc/examples/DEPS
index f065c89..524aa26 100644
--- a/webrtc/examples/DEPS
+++ b/webrtc/examples/DEPS
@@ -6,4 +6,5 @@
   "+webrtc/modules/audio_device",
   "+webrtc/modules/video_capture",
   "+webrtc/p2p",
+  "+webrtc/pc",
 ]
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
index e5fa8a1..b35bc1b 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -12,13 +12,6 @@
 #include <memory>
 
 #include "webrtc/api/fakemetricsobserver.h"
-#include "webrtc/p2p/base/fakeportallocator.h"
-#include "webrtc/p2p/base/packettransportinterface.h"
-#include "webrtc/p2p/base/p2ptransportchannel.h"
-#include "webrtc/p2p/base/testrelayserver.h"
-#include "webrtc/p2p/base/teststunserver.h"
-#include "webrtc/p2p/base/testturnserver.h"
-#include "webrtc/p2p/client/basicportallocator.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/dscp.h"
 #include "webrtc/base/fakeclock.h"
@@ -36,6 +29,13 @@
 #include "webrtc/base/thread.h"
 #include "webrtc/base/virtualsocketserver.h"
 #include "webrtc/p2p/base/icetransportinternal.h"
+#include "webrtc/p2p/base/fakeportallocator.h"
+#include "webrtc/p2p/base/p2ptransportchannel.h"
+#include "webrtc/p2p/base/packettransportinterface.h"
+#include "webrtc/p2p/base/testrelayserver.h"
+#include "webrtc/p2p/base/teststunserver.h"
+#include "webrtc/p2p/base/testturnserver.h"
+#include "webrtc/p2p/client/basicportallocator.h"
 
 namespace {
 
diff --git a/webrtc/pc/BUILD.gn b/webrtc/pc/BUILD.gn
index f2bdbc3..5c4d87c 100644
--- a/webrtc/pc/BUILD.gn
+++ b/webrtc/pc/BUILD.gn
@@ -7,6 +7,10 @@
 # be found in the AUTHORS file in the root of the source tree.
 
 import("../build/webrtc.gni")
+if (is_android) {
+  import("//build/config/android/config.gni")
+  import("//build/config/android/rules.gni")
+}
 
 group("pc") {
   public_deps = [
@@ -69,6 +73,100 @@
   }
 }
 
+config("libjingle_peerconnection_warnings_config") {
+  # GN orders flags on a target before flags from configs. The default config
+  # adds these flags so to cancel them out they need to come from a config and
+  # cannot be on the target directly.
+  if (!is_win && !is_clang) {
+    cflags = [ "-Wno-maybe-uninitialized" ]  # Only exists for GCC.
+  }
+}
+
+rtc_static_library("libjingle_peerconnection") {
+  check_includes = false  # TODO(kjellander): Remove (bugs.webrtc.org/6828)
+  cflags = []
+  sources = [
+    "audiotrack.cc",
+    "audiotrack.h",
+    "datachannel.cc",
+    "datachannel.h",
+    "dtmfsender.cc",
+    "dtmfsender.h",
+    "jsepicecandidate.cc",
+    "jsepsessiondescription.cc",
+    "localaudiosource.cc",
+    "localaudiosource.h",
+    "mediacontroller.cc",
+    "mediacontroller.h",
+    "mediastream.cc",
+    "mediastream.h",
+    "mediastreamobserver.cc",
+    "mediastreamobserver.h",
+    "mediastreamtrack.h",
+    "ortcfactory.cc",
+    "ortcfactory.h",
+    "peerconnection.cc",
+    "peerconnection.h",
+    "peerconnectionfactory.cc",
+    "peerconnectionfactory.h",
+    "remoteaudiosource.cc",
+    "remoteaudiosource.h",
+    "rtcstatscollector.cc",
+    "rtcstatscollector.h",
+    "rtpreceiver.cc",
+    "rtpreceiver.h",
+    "rtpsender.cc",
+    "rtpsender.h",
+    "sctputils.cc",
+    "sctputils.h",
+    "statscollector.cc",
+    "statscollector.h",
+    "streamcollection.h",
+    "videocapturertracksource.cc",
+    "videocapturertracksource.h",
+    "videotrack.cc",
+    "videotrack.h",
+    "videotracksource.cc",
+    "videotracksource.h",
+    "webrtcsdp.cc",
+    "webrtcsdp.h",
+    "webrtcsession.cc",
+    "webrtcsession.h",
+    "webrtcsessiondescriptionfactory.cc",
+    "webrtcsessiondescriptionfactory.h",
+  ]
+
+  configs += [ ":libjingle_peerconnection_warnings_config" ]
+
+  if (!build_with_chromium && is_clang) {
+    # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
+    suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
+  }
+
+  deps = [
+    ":rtc_pc",
+    "../api:call_api",
+    "../api:libjingle_peerconnection_api",
+    "../api:rtc_stats_api",
+    "../call",
+    "../media",
+    "../stats",
+  ]
+
+  if (rtc_use_quic) {
+    sources += [
+      "quicdatachannel.cc",
+      "quicdatachannel.h",
+      "quicdatatransport.cc",
+      "quicdatatransport.h",
+    ]
+    deps += [ "//third_party/libquic" ]
+    public_deps = [
+      "//third_party/libquic",
+    ]
+  }
+}
+
 if (rtc_include_tests) {
   config("rtc_pc_unittests_config") {
     # GN orders flags on a target before flags from configs. The default config
@@ -106,8 +204,8 @@
     }
 
     deps = [
+      ":libjingle_peerconnection",
       ":rtc_pc",
-      "../api:libjingle_peerconnection",
       "../base:rtc_base_tests_utils",
       "../media:rtc_unittest_main",
       "../system_wrappers:metrics_default",
@@ -121,4 +219,130 @@
       deps += [ "//testing/android/native_test:native_test_support" ]
     }
   }
+
+  config("peerconnection_unittests_config") {
+    # The warnings below are enabled by default. Since GN orders compiler flags
+    # for a target before flags from configs, the only way to disable such
+    # warnings is by having them in a separate config, loaded from the target.
+    # TODO(kjellander): Make the code compile without disabling these flags.
+    # See https://bugs.webrtc.org/3307.
+    if (is_clang && is_win) {
+      cflags = [
+        # See https://bugs.chromium.org/p/webrtc/issues/detail?id=6267
+        # for -Wno-sign-compare
+        "-Wno-sign-compare",
+        "-Wno-unused-function",
+      ]
+    }
+
+    if (!is_win) {
+      cflags = [ "-Wno-sign-compare" ]
+    }
+  }
+
+  rtc_test("peerconnection_unittests") {
+    check_includes = false  # TODO(kjellander): Remove (bugs.webrtc.org/6828)
+    testonly = true
+    sources = [
+      "datachannel_unittest.cc",
+      "dtmfsender_unittest.cc",
+      "fakemediacontroller.h",
+      "jsepsessiondescription_unittest.cc",
+      "localaudiosource_unittest.cc",
+      "mediaconstraintsinterface_unittest.cc",
+      "mediastream_unittest.cc",
+      "ortcfactory_unittest.cc",
+      "peerconnection_unittest.cc",
+      "peerconnectionendtoend_unittest.cc",
+      "peerconnectionfactory_unittest.cc",
+      "peerconnectioninterface_unittest.cc",
+      "proxy_unittest.cc",
+      "rtcstats_integrationtest.cc",
+      "rtcstatscollector_unittest.cc",
+      "rtpsenderreceiver_unittest.cc",
+      "sctputils_unittest.cc",
+      "statscollector_unittest.cc",
+      "test/fakeaudiocapturemodule.cc",
+      "test/fakeaudiocapturemodule.h",
+      "test/fakeaudiocapturemodule_unittest.cc",
+      "test/fakedatachannelprovider.h",
+      "test/fakeperiodicvideocapturer.h",
+      "test/fakertccertificategenerator.h",
+      "test/fakevideotrackrenderer.h",
+      "test/fakevideotracksource.h",
+      "test/mock_datachannel.h",
+      "test/mock_peerconnection.h",
+      "test/mock_webrtcsession.h",
+      "test/mockpeerconnectionobservers.h",
+      "test/peerconnectiontestwrapper.cc",
+      "test/peerconnectiontestwrapper.h",
+      "test/rtcstatsobtainer.h",
+      "test/testsdpstrings.h",
+      "videocapturertracksource_unittest.cc",
+      "videotrack_unittest.cc",
+      "webrtcsdp_unittest.cc",
+      "webrtcsession_unittest.cc",
+    ]
+
+    if (rtc_enable_sctp) {
+      defines = [ "HAVE_SCTP" ]
+    }
+
+    configs += [ ":peerconnection_unittests_config" ]
+
+    if (!build_with_chromium && is_clang) {
+      # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
+      suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
+    }
+
+    # TODO(jschuh): Bug 1348: fix this warning.
+    configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
+
+    if (is_win) {
+      cflags = [
+        "/wd4245",  # conversion from int to size_t, signed/unsigned mismatch.
+        "/wd4389",  # signed/unsigned mismatch.
+      ]
+    }
+
+    if (rtc_use_quic) {
+      public_deps = [
+        "//third_party/libquic",
+      ]
+      sources += [
+        "quicdatachannel_unittest.cc",
+        "quicdatatransport_unittest.cc",
+      ]
+    }
+
+    deps = []
+    if (is_android) {
+      sources += [
+        "test/androidtestinitializer.cc",
+        "test/androidtestinitializer.h",
+      ]
+      deps += [
+        "//testing/android/native_test:native_test_support",
+        "//webrtc/sdk/android:libjingle_peerconnection_java",
+        "//webrtc/sdk/android:libjingle_peerconnection_jni",
+      ]
+    }
+
+    deps += [
+      ":libjingle_peerconnection",
+      "..:webrtc_common",
+      "../api:fakemetricsobserver",
+      "../base:rtc_base_tests_utils",
+      "../media:rtc_unittest_main",
+      "../pc:rtc_pc",
+      "../system_wrappers:metrics_default",
+      "//testing/gmock",
+    ]
+
+    if (is_android) {
+      deps += [ "//testing/android/native_test:native_test_support" ]
+
+      shard_timeout = 900
+    }
+  }
 }
diff --git a/webrtc/pc/DEPS b/webrtc/pc/DEPS
index 2bb6253..5da778c 100644
--- a/webrtc/pc/DEPS
+++ b/webrtc/pc/DEPS
@@ -1,15 +1,29 @@
 include_rules = [
+  "+third_party/libsrtp"
   "+webrtc/api",
   "+webrtc/base",
+  "+webrtc/call",
   "+webrtc/common_video/h264",
   "+webrtc/logging/rtc_event_log",
+  "+webrtc/logging/rtc_event_log",
   "+webrtc/media",
+  "+webrtc/modules/audio_device",
+  "+webrtc/modules/rtp_rtcp",
+  "+webrtc/modules/video_coding",
+  "+webrtc/modules/video_render",
   "+webrtc/p2p",
-  "+third_party/libsrtp"
+  "+webrtc/system_wrappers",
 ]
 
 specific_include_rules = {
+  "androidtestinitializer\.cc": [
+    "+base/android",  # Allowed only for Android tests.
+    "+webrtc/voice_engine",
+  ],
   "srtpfilter_unittest\.cc": [
     "+crypto",
   ],
+  "peerconnectionfactory\.cc": [
+    "+webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h",
+  ],
 }
diff --git a/webrtc/api/audiotrack.cc b/webrtc/pc/audiotrack.cc
similarity index 95%
rename from webrtc/api/audiotrack.cc
rename to webrtc/pc/audiotrack.cc
index c2c9557..951acbf 100644
--- a/webrtc/api/audiotrack.cc
+++ b/webrtc/pc/audiotrack.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/audiotrack.h"
+#include "webrtc/pc/audiotrack.h"
 
 #include "webrtc/base/checks.h"
 
@@ -16,8 +16,6 @@
 
 namespace webrtc {
 
-const char MediaStreamTrackInterface::kAudioKind[] = "audio";
-
 // static
 scoped_refptr<AudioTrack> AudioTrack::Create(
     const std::string& id,
diff --git a/webrtc/api/audiotrack.h b/webrtc/pc/audiotrack.h
similarity index 91%
rename from webrtc/api/audiotrack.h
rename to webrtc/pc/audiotrack.h
index 096caf9..33f4b1f 100644
--- a/webrtc/api/audiotrack.h
+++ b/webrtc/pc/audiotrack.h
@@ -8,17 +8,17 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_AUDIOTRACK_H_
-#define WEBRTC_API_AUDIOTRACK_H_
+#ifndef WEBRTC_PC_AUDIOTRACK_H_
+#define WEBRTC_PC_AUDIOTRACK_H_
 
 #include <string>
 
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/mediastreamtrack.h"
 #include "webrtc/api/notifier.h"
 #include "webrtc/base/constructormagic.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 #include "webrtc/base/thread_checker.h"
+#include "webrtc/pc/mediastreamtrack.h"
 
 namespace webrtc {
 
@@ -56,4 +56,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_AUDIOTRACK_H_
+#endif  // WEBRTC_PC_AUDIOTRACK_H_
diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc
index 0570267..f667900 100644
--- a/webrtc/pc/channelmanager.cc
+++ b/webrtc/pc/channelmanager.cc
@@ -12,7 +12,6 @@
 
 #include <algorithm>
 
-#include "webrtc/api/mediacontroller.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/common.h"
@@ -23,6 +22,7 @@
 #include "webrtc/media/base/device.h"
 #include "webrtc/media/base/rtpdataengine.h"
 #include "webrtc/pc/srtpfilter.h"
+#include "webrtc/pc/mediacontroller.h"
 
 namespace cricket {
 
diff --git a/webrtc/pc/channelmanager_unittest.cc b/webrtc/pc/channelmanager_unittest.cc
index cf54b91..74c3590 100644
--- a/webrtc/pc/channelmanager_unittest.cc
+++ b/webrtc/pc/channelmanager_unittest.cc
@@ -8,7 +8,6 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/fakemediacontroller.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/thread.h"
@@ -19,6 +18,7 @@
 #include "webrtc/media/engine/fakewebrtccall.h"
 #include "webrtc/p2p/base/faketransportcontroller.h"
 #include "webrtc/pc/channelmanager.h"
+#include "webrtc/pc/fakemediacontroller.h"
 
 namespace cricket {
 const bool kDefaultRtcpMuxRequired = true;
diff --git a/webrtc/api/datachannel.cc b/webrtc/pc/datachannel.cc
similarity index 99%
rename from webrtc/api/datachannel.cc
rename to webrtc/pc/datachannel.cc
index c0bc3dc..5606a64 100644
--- a/webrtc/api/datachannel.cc
+++ b/webrtc/pc/datachannel.cc
@@ -8,16 +8,16 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/datachannel.h"
+#include "webrtc/pc/datachannel.h"
 
 #include <memory>
 #include <string>
 
-#include "webrtc/api/sctputils.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/refcount.h"
 #include "webrtc/media/sctp/sctptransportinternal.h"
+#include "webrtc/pc/sctputils.h"
 
 namespace webrtc {
 
diff --git a/webrtc/pc/datachannel.h b/webrtc/pc/datachannel.h
new file mode 100644
index 0000000..2619a85
--- /dev/null
+++ b/webrtc/pc/datachannel.h
@@ -0,0 +1,298 @@
+/*
+ *  Copyright 2012 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_PC_DATACHANNEL_H_
+#define WEBRTC_PC_DATACHANNEL_H_
+
+#include <deque>
+#include <set>
+#include <string>
+
+#include "webrtc/api/datachannelinterface.h"
+#include "webrtc/api/proxy.h"
+#include "webrtc/base/messagehandler.h"
+#include "webrtc/base/scoped_ref_ptr.h"
+#include "webrtc/base/sigslot.h"
+#include "webrtc/media/base/mediachannel.h"
+#include "webrtc/pc/channel.h"
+
+namespace webrtc {
+
+class DataChannel;
+
+class DataChannelProviderInterface {
+ public:
+  // Sends the data to the transport.
+  virtual bool SendData(const cricket::SendDataParams& params,
+                        const rtc::CopyOnWriteBuffer& payload,
+                        cricket::SendDataResult* result) = 0;
+  // Connects to the transport signals.
+  virtual bool ConnectDataChannel(DataChannel* data_channel) = 0;
+  // Disconnects from the transport signals.
+  virtual void DisconnectDataChannel(DataChannel* data_channel) = 0;
+  // Adds the data channel SID to the transport for SCTP.
+  virtual void AddSctpDataStream(int sid) = 0;
+  // Removes the data channel SID from the transport for SCTP.
+  virtual void RemoveSctpDataStream(int sid) = 0;
+  // Returns true if the transport channel is ready to send data.
+  virtual bool ReadyToSendData() const = 0;
+
+ protected:
+  virtual ~DataChannelProviderInterface() {}
+};
+
+struct InternalDataChannelInit : public DataChannelInit {
+  enum OpenHandshakeRole {
+    kOpener,
+    kAcker,
+    kNone
+  };
+  // The default role is kOpener because the default |negotiated| is false.
+  InternalDataChannelInit() : open_handshake_role(kOpener) {}
+  explicit InternalDataChannelInit(const DataChannelInit& base)
+      : DataChannelInit(base), open_handshake_role(kOpener) {
+    // If the channel is externally negotiated, do not send the OPEN message.
+    if (base.negotiated) {
+      open_handshake_role = kNone;
+    }
+  }
+
+  OpenHandshakeRole open_handshake_role;
+};
+
+// Helper class to allocate unique IDs for SCTP DataChannels
+class SctpSidAllocator {
+ public:
+  // Gets the first unused odd/even id based on the DTLS role. If |role| is
+  // SSL_CLIENT, the allocated id starts from 0 and takes even numbers;
+  // otherwise, the id starts from 1 and takes odd numbers.
+  // Returns false if no id can be allocated.
+  bool AllocateSid(rtc::SSLRole role, int* sid);
+
+  // Attempts to reserve a specific sid. Returns false if it's unavailable.
+  bool ReserveSid(int sid);
+
+  // Indicates that |sid| isn't in use any more, and is thus available again.
+  void ReleaseSid(int sid);
+
+ private:
+  // Checks if |sid| is available to be assigned to a new SCTP data channel.
+  bool IsSidAvailable(int sid) const;
+
+  std::set<int> used_sids_;
+};
+
+// DataChannel is a an implementation of the DataChannelInterface based on
+// libjingle's data engine. It provides an implementation of unreliable or
+// reliabledata channels. Currently this class is specifically designed to use
+// both RtpDataEngine and SctpDataEngine.
+
+// DataChannel states:
+// kConnecting: The channel has been created the transport might not yet be
+//              ready.
+// kOpen: The channel have a local SSRC set by a call to UpdateSendSsrc
+//        and a remote SSRC set by call to UpdateReceiveSsrc and the transport
+//        has been writable once.
+// kClosing: DataChannelInterface::Close has been called or UpdateReceiveSsrc
+//           has been called with SSRC==0
+// kClosed: Both UpdateReceiveSsrc and UpdateSendSsrc has been called with
+//          SSRC==0.
+class DataChannel : public DataChannelInterface,
+                    public sigslot::has_slots<>,
+                    public rtc::MessageHandler {
+ public:
+  static rtc::scoped_refptr<DataChannel> Create(
+      DataChannelProviderInterface* provider,
+      cricket::DataChannelType dct,
+      const std::string& label,
+      const InternalDataChannelInit& config);
+
+  virtual void RegisterObserver(DataChannelObserver* observer);
+  virtual void UnregisterObserver();
+
+  virtual std::string label() const { return label_; }
+  virtual bool reliable() const;
+  virtual bool ordered() const { return config_.ordered; }
+  virtual uint16_t maxRetransmitTime() const {
+    return config_.maxRetransmitTime;
+  }
+  virtual uint16_t maxRetransmits() const { return config_.maxRetransmits; }
+  virtual std::string protocol() const { return config_.protocol; }
+  virtual bool negotiated() const { return config_.negotiated; }
+  virtual int id() const { return config_.id; }
+  virtual uint64_t buffered_amount() const;
+  virtual void Close();
+  virtual DataState state() const { return state_; }
+  virtual uint32_t messages_sent() const { return messages_sent_; }
+  virtual uint64_t bytes_sent() const { return bytes_sent_; }
+  virtual uint32_t messages_received() const { return messages_received_; }
+  virtual uint64_t bytes_received() const { return bytes_received_; }
+  virtual bool Send(const DataBuffer& buffer);
+
+  // rtc::MessageHandler override.
+  virtual void OnMessage(rtc::Message* msg);
+
+  // Called when the channel's ready to use.  That can happen when the
+  // underlying DataMediaChannel becomes ready, or when this channel is a new
+  // stream on an existing DataMediaChannel, and we've finished negotiation.
+  void OnChannelReady(bool writable);
+
+  // Slots for provider to connect signals to.
+  void OnDataReceived(const cricket::ReceiveDataParams& params,
+                      const rtc::CopyOnWriteBuffer& payload);
+  void OnStreamClosedRemotely(int sid);
+
+  // The remote peer request that this channel should be closed.
+  void RemotePeerRequestClose();
+
+  // The following methods are for SCTP only.
+
+  // Sets the SCTP sid and adds to transport layer if not set yet. Should only
+  // be called once.
+  void SetSctpSid(int sid);
+  // Called when the transport channel is created.
+  // Only needs to be called for SCTP data channels.
+  void OnTransportChannelCreated();
+  // Called when the transport channel is destroyed.
+  // This method makes sure the DataChannel is disconnected and changes state
+  // to kClosed.
+  void OnTransportChannelDestroyed();
+
+  // The following methods are for RTP only.
+
+  // Set the SSRC this channel should use to send data on the
+  // underlying data engine. |send_ssrc| == 0 means that the channel is no
+  // longer part of the session negotiation.
+  void SetSendSsrc(uint32_t send_ssrc);
+  // Set the SSRC this channel should use to receive data from the
+  // underlying data engine.
+  void SetReceiveSsrc(uint32_t receive_ssrc);
+
+  cricket::DataChannelType data_channel_type() const {
+    return data_channel_type_;
+  }
+
+  // Emitted when state transitions to kOpen.
+  sigslot::signal1<DataChannel*> SignalOpened;
+  // Emitted when state transitions to kClosed.
+  // In the case of SCTP channels, this signal can be used to tell when the
+  // channel's sid is free.
+  sigslot::signal1<DataChannel*> SignalClosed;
+
+ protected:
+  DataChannel(DataChannelProviderInterface* client,
+              cricket::DataChannelType dct,
+              const std::string& label);
+  virtual ~DataChannel();
+
+ private:
+  // A packet queue which tracks the total queued bytes. Queued packets are
+  // owned by this class.
+  class PacketQueue {
+   public:
+    PacketQueue();
+    ~PacketQueue();
+
+    size_t byte_count() const {
+      return byte_count_;
+    }
+
+    bool Empty() const;
+
+    DataBuffer* Front();
+
+    void Pop();
+
+    void Push(DataBuffer* packet);
+
+    void Clear();
+
+    void Swap(PacketQueue* other);
+
+   private:
+    std::deque<DataBuffer*> packets_;
+    size_t byte_count_;
+  };
+
+  // The OPEN(_ACK) signaling state.
+  enum HandshakeState {
+    kHandshakeInit,
+    kHandshakeShouldSendOpen,
+    kHandshakeShouldSendAck,
+    kHandshakeWaitingForAck,
+    kHandshakeReady
+  };
+
+  bool Init(const InternalDataChannelInit& config);
+  void DoClose();
+  void UpdateState();
+  void SetState(DataState state);
+  void DisconnectFromProvider();
+
+  void DeliverQueuedReceivedData();
+
+  void SendQueuedDataMessages();
+  bool SendDataMessage(const DataBuffer& buffer, bool queue_if_blocked);
+  bool QueueSendDataMessage(const DataBuffer& buffer);
+
+  void SendQueuedControlMessages();
+  void QueueControlMessage(const rtc::CopyOnWriteBuffer& buffer);
+  bool SendControlMessage(const rtc::CopyOnWriteBuffer& buffer);
+
+  std::string label_;
+  InternalDataChannelInit config_;
+  DataChannelObserver* observer_;
+  DataState state_;
+  uint32_t messages_sent_;
+  uint64_t bytes_sent_;
+  uint32_t messages_received_;
+  uint64_t bytes_received_;
+  cricket::DataChannelType data_channel_type_;
+  DataChannelProviderInterface* provider_;
+  HandshakeState handshake_state_;
+  bool connected_to_provider_;
+  bool send_ssrc_set_;
+  bool receive_ssrc_set_;
+  bool writable_;
+  uint32_t send_ssrc_;
+  uint32_t receive_ssrc_;
+  // Control messages that always have to get sent out before any queued
+  // data.
+  PacketQueue queued_control_data_;
+  PacketQueue queued_received_data_;
+  PacketQueue queued_send_data_;
+};
+
+// Define proxy for DataChannelInterface.
+BEGIN_SIGNALING_PROXY_MAP(DataChannel)
+  PROXY_SIGNALING_THREAD_DESTRUCTOR()
+  PROXY_METHOD1(void, RegisterObserver, DataChannelObserver*)
+  PROXY_METHOD0(void, UnregisterObserver)
+  PROXY_CONSTMETHOD0(std::string, label)
+  PROXY_CONSTMETHOD0(bool, reliable)
+  PROXY_CONSTMETHOD0(bool, ordered)
+  PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime)
+  PROXY_CONSTMETHOD0(uint16_t, maxRetransmits)
+  PROXY_CONSTMETHOD0(std::string, protocol)
+  PROXY_CONSTMETHOD0(bool, negotiated)
+  PROXY_CONSTMETHOD0(int, id)
+  PROXY_CONSTMETHOD0(DataState, state)
+  PROXY_CONSTMETHOD0(uint32_t, messages_sent)
+  PROXY_CONSTMETHOD0(uint64_t, bytes_sent)
+  PROXY_CONSTMETHOD0(uint32_t, messages_received)
+  PROXY_CONSTMETHOD0(uint64_t, bytes_received)
+  PROXY_CONSTMETHOD0(uint64_t, buffered_amount)
+  PROXY_METHOD0(void, Close)
+  PROXY_METHOD1(bool, Send, const DataBuffer&)
+END_PROXY_MAP()
+
+}  // namespace webrtc
+
+#endif  // WEBRTC_PC_DATACHANNEL_H_
diff --git a/webrtc/api/datachannel_unittest.cc b/webrtc/pc/datachannel_unittest.cc
similarity index 99%
rename from webrtc/api/datachannel_unittest.cc
rename to webrtc/pc/datachannel_unittest.cc
index 4ce1be5..13ab63c 100644
--- a/webrtc/api/datachannel_unittest.cc
+++ b/webrtc/pc/datachannel_unittest.cc
@@ -10,10 +10,10 @@
 
 #include <memory>
 
-#include "webrtc/api/datachannel.h"
-#include "webrtc/api/sctputils.h"
-#include "webrtc/api/test/fakedatachannelprovider.h"
 #include "webrtc/base/gunit.h"
+#include "webrtc/pc/datachannel.h"
+#include "webrtc/pc/sctputils.h"
+#include "webrtc/pc/test/fakedatachannelprovider.h"
 
 using webrtc::DataChannel;
 using webrtc::SctpSidAllocator;
diff --git a/webrtc/api/dtmfsender.cc b/webrtc/pc/dtmfsender.cc
similarity index 99%
rename from webrtc/api/dtmfsender.cc
rename to webrtc/pc/dtmfsender.cc
index c715d3d..2ef921b 100644
--- a/webrtc/api/dtmfsender.cc
+++ b/webrtc/pc/dtmfsender.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/dtmfsender.h"
+#include "webrtc/pc/dtmfsender.h"
 
 #include <ctype.h>
 
diff --git a/webrtc/api/dtmfsender.h b/webrtc/pc/dtmfsender.h
similarity index 97%
rename from webrtc/api/dtmfsender.h
rename to webrtc/pc/dtmfsender.h
index d4e8f06..1163adf 100644
--- a/webrtc/api/dtmfsender.h
+++ b/webrtc/pc/dtmfsender.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_DTMFSENDER_H_
-#define WEBRTC_API_DTMFSENDER_H_
+#ifndef WEBRTC_PC_DTMFSENDER_H_
+#define WEBRTC_PC_DTMFSENDER_H_
 
 #include <string>
 
@@ -121,4 +121,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_DTMFSENDER_H_
+#endif  // WEBRTC_PC_DTMFSENDER_H_
diff --git a/webrtc/api/dtmfsender_unittest.cc b/webrtc/pc/dtmfsender_unittest.cc
similarity index 99%
rename from webrtc/api/dtmfsender_unittest.cc
rename to webrtc/pc/dtmfsender_unittest.cc
index 54f3a7b..a58c1ec 100644
--- a/webrtc/api/dtmfsender_unittest.cc
+++ b/webrtc/pc/dtmfsender_unittest.cc
@@ -8,18 +8,18 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/dtmfsender.h"
+#include "webrtc/pc/dtmfsender.h"
 
 #include <memory>
 #include <set>
 #include <string>
 #include <vector>
 
-#include "webrtc/api/audiotrack.h"
 #include "webrtc/base/fakeclock.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/timeutils.h"
+#include "webrtc/pc/audiotrack.h"
 
 using webrtc::AudioTrackInterface;
 using webrtc::AudioTrack;
diff --git a/webrtc/api/fakemediacontroller.h b/webrtc/pc/fakemediacontroller.h
similarity index 88%
rename from webrtc/api/fakemediacontroller.h
rename to webrtc/pc/fakemediacontroller.h
index bc3f3e2..6d639ed 100644
--- a/webrtc/api/fakemediacontroller.h
+++ b/webrtc/pc/fakemediacontroller.h
@@ -8,12 +8,12 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_FAKEMEDIACONTROLLER_H_
-#define WEBRTC_API_FAKEMEDIACONTROLLER_H_
+#ifndef WEBRTC_PC_FAKEMEDIACONTROLLER_H_
+#define WEBRTC_PC_FAKEMEDIACONTROLLER_H_
 
-#include "webrtc/api/mediacontroller.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/media/base/mediachannel.h"
+#include "webrtc/pc/mediacontroller.h"
 
 namespace cricket {
 
@@ -39,4 +39,4 @@
   webrtc::Call* call_;
 };
 }  // namespace cricket
-#endif  // WEBRTC_API_FAKEMEDIACONTROLLER_H_
+#endif  // WEBRTC_PC_FAKEMEDIACONTROLLER_H_
diff --git a/webrtc/api/jsepicecandidate.cc b/webrtc/pc/jsepicecandidate.cc
similarity index 98%
rename from webrtc/api/jsepicecandidate.cc
rename to webrtc/pc/jsepicecandidate.cc
index cced1b4..51faa07 100644
--- a/webrtc/api/jsepicecandidate.cc
+++ b/webrtc/pc/jsepicecandidate.cc
@@ -12,8 +12,8 @@
 
 #include <vector>
 
-#include "webrtc/api/webrtcsdp.h"
 #include "webrtc/base/stringencode.h"
+#include "webrtc/pc/webrtcsdp.h"
 
 namespace webrtc {
 
diff --git a/webrtc/api/jsepsessiondescription.cc b/webrtc/pc/jsepsessiondescription.cc
similarity index 99%
rename from webrtc/api/jsepsessiondescription.cc
rename to webrtc/pc/jsepsessiondescription.cc
index 6f73a1e..02919b6 100644
--- a/webrtc/api/jsepsessiondescription.cc
+++ b/webrtc/pc/jsepsessiondescription.cc
@@ -12,10 +12,10 @@
 
 #include <memory>
 
-#include "webrtc/api/webrtcsdp.h"
 #include "webrtc/base/arraysize.h"
 #include "webrtc/base/stringencode.h"
 #include "webrtc/pc/mediasession.h"
+#include "webrtc/pc/webrtcsdp.h"
 
 using cricket::SessionDescription;
 
diff --git a/webrtc/api/jsepsessiondescription_unittest.cc b/webrtc/pc/jsepsessiondescription_unittest.cc
similarity index 100%
rename from webrtc/api/jsepsessiondescription_unittest.cc
rename to webrtc/pc/jsepsessiondescription_unittest.cc
diff --git a/webrtc/api/localaudiosource.cc b/webrtc/pc/localaudiosource.cc
similarity index 97%
rename from webrtc/api/localaudiosource.cc
rename to webrtc/pc/localaudiosource.cc
index 57cfdf8..3d79da9 100644
--- a/webrtc/api/localaudiosource.cc
+++ b/webrtc/pc/localaudiosource.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/localaudiosource.h"
+#include "webrtc/pc/localaudiosource.h"
 
 #include <vector>
 
diff --git a/webrtc/api/localaudiosource.h b/webrtc/pc/localaudiosource.h
similarity index 93%
rename from webrtc/api/localaudiosource.h
rename to webrtc/pc/localaudiosource.h
index e1c023e..58e90af 100644
--- a/webrtc/api/localaudiosource.h
+++ b/webrtc/pc/localaudiosource.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_LOCALAUDIOSOURCE_H_
-#define WEBRTC_API_LOCALAUDIOSOURCE_H_
+#ifndef WEBRTC_PC_LOCALAUDIOSOURCE_H_
+#define WEBRTC_PC_LOCALAUDIOSOURCE_H_
 
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/api/notifier.h"
@@ -57,4 +57,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_LOCALAUDIOSOURCE_H_
+#endif  // WEBRTC_PC_LOCALAUDIOSOURCE_H_
diff --git a/webrtc/api/localaudiosource_unittest.cc b/webrtc/pc/localaudiosource_unittest.cc
similarity index 98%
rename from webrtc/api/localaudiosource_unittest.cc
rename to webrtc/pc/localaudiosource_unittest.cc
index 12f46b7..394a2ea 100644
--- a/webrtc/api/localaudiosource_unittest.cc
+++ b/webrtc/pc/localaudiosource_unittest.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/localaudiosource.h"
+#include "webrtc/pc/localaudiosource.h"
 
 #include <string>
 #include <vector>
diff --git a/webrtc/api/mediaconstraintsinterface_unittest.cc b/webrtc/pc/mediaconstraintsinterface_unittest.cc
similarity index 100%
rename from webrtc/api/mediaconstraintsinterface_unittest.cc
rename to webrtc/pc/mediaconstraintsinterface_unittest.cc
diff --git a/webrtc/api/mediacontroller.cc b/webrtc/pc/mediacontroller.cc
similarity index 98%
rename from webrtc/api/mediacontroller.cc
rename to webrtc/pc/mediacontroller.cc
index c64ff01..fa8acad 100644
--- a/webrtc/api/mediacontroller.cc
+++ b/webrtc/pc/mediacontroller.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/mediacontroller.h"
+#include "webrtc/pc/mediacontroller.h"
 
 #include <memory>
 
diff --git a/webrtc/pc/mediacontroller.h b/webrtc/pc/mediacontroller.h
new file mode 100644
index 0000000..85617af
--- /dev/null
+++ b/webrtc/pc/mediacontroller.h
@@ -0,0 +1,44 @@
+/*
+ *  Copyright 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_PC_MEDIACONTROLLER_H_
+#define WEBRTC_PC_MEDIACONTROLLER_H_
+
+#include "webrtc/base/thread.h"
+
+namespace cricket {
+class ChannelManager;
+struct MediaConfig;
+}  // namespace cricket
+
+namespace webrtc {
+class Call;
+class VoiceEngine;
+class RtcEventLog;
+
+// The MediaController currently owns shared state between media channels, but
+// in the future will create and own RtpSenders and RtpReceivers.
+class MediaControllerInterface {
+ public:
+  static MediaControllerInterface* Create(
+      const cricket::MediaConfig& config,
+      rtc::Thread* worker_thread,
+      cricket::ChannelManager* channel_manager,
+      webrtc::RtcEventLog* event_log);
+
+  virtual ~MediaControllerInterface() {}
+  virtual void Close() = 0;
+  virtual webrtc::Call* call_w() = 0;
+  virtual cricket::ChannelManager* channel_manager() const = 0;
+  virtual const cricket::MediaConfig& config() const = 0;
+};
+}  // namespace webrtc
+
+#endif  // WEBRTC_PC_MEDIACONTROLLER_H_
diff --git a/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc
index 5e69423..910c72b 100644
--- a/webrtc/pc/mediasession.cc
+++ b/webrtc/pc/mediasession.cc
@@ -1193,25 +1193,6 @@
   return current_tdesc->secure();
 }
 
-std::string MediaTypeToString(MediaType type) {
-  std::string type_str;
-  switch (type) {
-    case MEDIA_TYPE_AUDIO:
-      type_str = "audio";
-      break;
-    case MEDIA_TYPE_VIDEO:
-      type_str = "video";
-      break;
-    case MEDIA_TYPE_DATA:
-      type_str = "data";
-      break;
-    default:
-      RTC_NOTREACHED();
-      break;
-  }
-  return type_str;
-}
-
 std::string MediaContentDirectionToString(MediaContentDirection direction) {
   std::string dir_str;
   switch (direction) {
diff --git a/webrtc/pc/mediasession.h b/webrtc/pc/mediasession.h
index ee2126d..06815ec 100644
--- a/webrtc/pc/mediasession.h
+++ b/webrtc/pc/mediasession.h
@@ -18,6 +18,7 @@
 #include <string>
 #include <vector>
 
+#include "webrtc/api/mediatypes.h"
 #include "webrtc/media/base/codec.h"
 #include "webrtc/media/base/cryptoparams.h"
 #include "webrtc/media/base/mediachannel.h"
@@ -37,14 +38,6 @@
 typedef std::vector<CryptoParams> CryptoParamsVec;
 typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions;
 
-enum MediaType {
-  MEDIA_TYPE_AUDIO,
-  MEDIA_TYPE_VIDEO,
-  MEDIA_TYPE_DATA
-};
-
-std::string MediaTypeToString(MediaType type);
-
 enum MediaContentDirection {
   MD_INACTIVE,
   MD_SENDONLY,
diff --git a/webrtc/api/mediastream.cc b/webrtc/pc/mediastream.cc
similarity index 98%
rename from webrtc/api/mediastream.cc
rename to webrtc/pc/mediastream.cc
index bef04ae..1830792 100644
--- a/webrtc/api/mediastream.cc
+++ b/webrtc/pc/mediastream.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/mediastream.h"
+#include "webrtc/pc/mediastream.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/logging.h"
 
diff --git a/webrtc/pc/mediastream.h b/webrtc/pc/mediastream.h
new file mode 100644
index 0000000..56fbed9
--- /dev/null
+++ b/webrtc/pc/mediastream.h
@@ -0,0 +1,58 @@
+/*
+ *  Copyright 2011 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+// This file contains the implementation of MediaStreamInterface interface.
+
+#ifndef WEBRTC_PC_MEDIASTREAM_H_
+#define WEBRTC_PC_MEDIASTREAM_H_
+
+#include <string>
+#include <vector>
+
+#include "webrtc/api/mediastreaminterface.h"
+#include "webrtc/api/notifier.h"
+
+namespace webrtc {
+
+class MediaStream : public Notifier<MediaStreamInterface> {
+ public:
+  static rtc::scoped_refptr<MediaStream> Create(const std::string& label);
+
+  std::string label() const override { return label_; }
+
+  bool AddTrack(AudioTrackInterface* track) override;
+  bool AddTrack(VideoTrackInterface* track) override;
+  bool RemoveTrack(AudioTrackInterface* track) override;
+  bool RemoveTrack(VideoTrackInterface* track) override;
+  rtc::scoped_refptr<AudioTrackInterface>
+      FindAudioTrack(const std::string& track_id) override;
+  rtc::scoped_refptr<VideoTrackInterface>
+      FindVideoTrack(const std::string& track_id) override;
+
+  AudioTrackVector GetAudioTracks() override { return audio_tracks_; }
+  VideoTrackVector GetVideoTracks() override { return video_tracks_; }
+
+ protected:
+  explicit MediaStream(const std::string& label);
+
+ private:
+  template <typename TrackVector, typename Track>
+  bool AddTrack(TrackVector* Tracks, Track* track);
+  template <typename TrackVector>
+  bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track);
+
+  std::string label_;
+  AudioTrackVector audio_tracks_;
+  VideoTrackVector video_tracks_;
+};
+
+}  // namespace webrtc
+
+#endif  // WEBRTC_PC_MEDIASTREAM_H_
diff --git a/webrtc/api/mediastream_unittest.cc b/webrtc/pc/mediastream_unittest.cc
similarity index 96%
rename from webrtc/api/mediastream_unittest.cc
rename to webrtc/pc/mediastream_unittest.cc
index 5df08ce..e2e3985 100644
--- a/webrtc/api/mediastream_unittest.cc
+++ b/webrtc/pc/mediastream_unittest.cc
@@ -10,14 +10,14 @@
 
 #include <string>
 
-#include "webrtc/api/audiotrack.h"
-#include "webrtc/api/mediastream.h"
-#include "webrtc/api/test/fakevideotracksource.h"
-#include "webrtc/api/videotrack.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/refcount.h"
 #include "webrtc/test/gmock.h"
 #include "webrtc/test/gtest.h"
+#include "webrtc/pc/audiotrack.h"
+#include "webrtc/pc/mediastream.h"
+#include "webrtc/pc/test/fakevideotracksource.h"
+#include "webrtc/pc/videotrack.h"
 
 static const char kStreamLabel1[] = "local_stream_1";
 static const char kVideoTrackId[] = "dummy_video_cam_1";
diff --git a/webrtc/api/mediastreamobserver.cc b/webrtc/pc/mediastreamobserver.cc
similarity index 98%
rename from webrtc/api/mediastreamobserver.cc
rename to webrtc/pc/mediastreamobserver.cc
index 0cf52b4..bf17582 100644
--- a/webrtc/api/mediastreamobserver.cc
+++ b/webrtc/pc/mediastreamobserver.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/mediastreamobserver.h"
+#include "webrtc/pc/mediastreamobserver.h"
 
 #include <algorithm>
 
diff --git a/webrtc/api/mediastreamobserver.h b/webrtc/pc/mediastreamobserver.h
similarity index 91%
rename from webrtc/api/mediastreamobserver.h
rename to webrtc/pc/mediastreamobserver.h
index 3179976..5d9012b 100644
--- a/webrtc/api/mediastreamobserver.h
+++ b/webrtc/pc/mediastreamobserver.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_MEDIASTREAMOBSERVER_H_
-#define WEBRTC_API_MEDIASTREAMOBSERVER_H_
+#ifndef WEBRTC_PC_MEDIASTREAMOBSERVER_H_
+#define WEBRTC_PC_MEDIASTREAMOBSERVER_H_
 
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/base/scoped_ref_ptr.h"
@@ -45,4 +45,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_MEDIASTREAMOBSERVER_H_
+#endif  // WEBRTC_PC_MEDIASTREAMOBSERVER_H_
diff --git a/webrtc/pc/mediastreamtrack.h b/webrtc/pc/mediastreamtrack.h
new file mode 100644
index 0000000..0fb2de2
--- /dev/null
+++ b/webrtc/pc/mediastreamtrack.h
@@ -0,0 +1,62 @@
+/*
+ *  Copyright 2011 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_PC_MEDIASTREAMTRACK_H_
+#define WEBRTC_PC_MEDIASTREAMTRACK_H_
+
+#include <string>
+
+#include "webrtc/api/mediastreaminterface.h"
+#include "webrtc/api/notifier.h"
+
+namespace webrtc {
+
+// MediaTrack implements the interface common to AudioTrackInterface and
+// VideoTrackInterface.
+template <typename T>
+class MediaStreamTrack : public Notifier<T> {
+ public:
+  typedef typename T::TrackState TypedTrackState;
+
+  std::string id() const override { return id_; }
+  MediaStreamTrackInterface::TrackState state() const override {
+    return state_;
+  }
+  bool enabled() const override { return enabled_; }
+  bool set_enabled(bool enable) override {
+    bool fire_on_change = (enable != enabled_);
+    enabled_ = enable;
+    if (fire_on_change) {
+      Notifier<T>::FireOnChanged();
+    }
+    return fire_on_change;
+  }
+
+ protected:
+  explicit MediaStreamTrack(const std::string& id)
+      : enabled_(true), id_(id), state_(MediaStreamTrackInterface::kLive) {}
+
+  bool set_state(MediaStreamTrackInterface::TrackState new_state) {
+    bool fire_on_change = (state_ != new_state);
+    state_ = new_state;
+    if (fire_on_change)
+      Notifier<T>::FireOnChanged();
+    return true;
+  }
+
+ private:
+  bool enabled_;
+  std::string id_;
+  MediaStreamTrackInterface::TrackState state_;
+};
+
+}  // namespace webrtc
+
+#endif  // WEBRTC_PC_MEDIASTREAMTRACK_H_
diff --git a/webrtc/api/ortcfactory.cc b/webrtc/pc/ortcfactory.cc
similarity index 98%
rename from webrtc/api/ortcfactory.cc
rename to webrtc/pc/ortcfactory.cc
index ba41a03..47d39b7 100644
--- a/webrtc/api/ortcfactory.cc
+++ b/webrtc/pc/ortcfactory.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/ortcfactory.h"
+#include "webrtc/pc/ortcfactory.h"
 
 #include <string>
 #include <utility>  // For std::move.
diff --git a/webrtc/api/ortcfactory.h b/webrtc/pc/ortcfactory.h
similarity index 95%
rename from webrtc/api/ortcfactory.h
rename to webrtc/pc/ortcfactory.h
index dc92774..65fe10f 100644
--- a/webrtc/api/ortcfactory.h
+++ b/webrtc/pc/ortcfactory.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_ORTCFACTORY_H_
-#define WEBRTC_API_ORTCFACTORY_H_
+#ifndef WEBRTC_PC_ORTCFACTORY_H_
+#define WEBRTC_PC_ORTCFACTORY_H_
 
 #include <memory>
 
@@ -61,4 +61,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_ORTCFACTORY_H_
+#endif  // WEBRTC_PC_ORTCFACTORY_H_
diff --git a/webrtc/api/ortcfactory_unittest.cc b/webrtc/pc/ortcfactory_unittest.cc
similarity index 100%
rename from webrtc/api/ortcfactory_unittest.cc
rename to webrtc/pc/ortcfactory_unittest.cc
diff --git a/webrtc/api/peerconnection.cc b/webrtc/pc/peerconnection.cc
similarity index 99%
rename from webrtc/api/peerconnection.cc
rename to webrtc/pc/peerconnection.cc
index 78e6790..cbd0d4b 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/pc/peerconnection.cc
@@ -8,28 +8,18 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/peerconnection.h"
+#include "webrtc/pc/peerconnection.h"
 
 #include <algorithm>
 #include <cctype>  // for isdigit
 #include <utility>
 #include <vector>
 
-#include "webrtc/api/audiotrack.h"
-#include "webrtc/api/dtmfsender.h"
 #include "webrtc/api/jsepicecandidate.h"
 #include "webrtc/api/jsepsessiondescription.h"
 #include "webrtc/api/mediaconstraintsinterface.h"
-#include "webrtc/api/mediastream.h"
-#include "webrtc/api/mediastreamobserver.h"
 #include "webrtc/api/mediastreamproxy.h"
 #include "webrtc/api/mediastreamtrackproxy.h"
-#include "webrtc/api/remoteaudiosource.h"
-#include "webrtc/api/rtpreceiver.h"
-#include "webrtc/api/rtpsender.h"
-#include "webrtc/api/streamcollection.h"
-#include "webrtc/api/videocapturertracksource.h"
-#include "webrtc/api/videotrack.h"
 #include "webrtc/base/arraysize.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/checks.h"
@@ -40,7 +30,18 @@
 #include "webrtc/call/call.h"
 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
 #include "webrtc/media/sctp/sctptransport.h"
+#include "webrtc/pc/audiotrack.h"
 #include "webrtc/pc/channelmanager.h"
+#include "webrtc/pc/dtmfsender.h"
+#include "webrtc/pc/mediastream.h"
+#include "webrtc/pc/mediastreamobserver.h"
+#include "webrtc/pc/remoteaudiosource.h"
+#include "webrtc/pc/rtpreceiver.h"
+#include "webrtc/pc/rtpsender.h"
+#include "webrtc/pc/streamcollection.h"
+#include "webrtc/pc/videocapturertracksource.h"
+#include "webrtc/pc/videotrack.h"
+#include "webrtc/system_wrappers/include/clock.h"
 #include "webrtc/system_wrappers/include/field_trial.h"
 
 namespace {
diff --git a/webrtc/api/peerconnection.h b/webrtc/pc/peerconnection.h
similarity index 97%
rename from webrtc/api/peerconnection.h
rename to webrtc/pc/peerconnection.h
index 82dc8ed..ac8f33c 100644
--- a/webrtc/api/peerconnection.h
+++ b/webrtc/pc/peerconnection.h
@@ -8,22 +8,22 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_PEERCONNECTION_H_
-#define WEBRTC_API_PEERCONNECTION_H_
+#ifndef WEBRTC_PC_PEERCONNECTION_H_
+#define WEBRTC_PC_PEERCONNECTION_H_
 
 #include <string>
 #include <map>
 #include <memory>
 #include <vector>
 
-#include "webrtc/api/peerconnectionfactory.h"
 #include "webrtc/api/peerconnectioninterface.h"
-#include "webrtc/api/rtcstatscollector.h"
-#include "webrtc/api/rtpreceiver.h"
-#include "webrtc/api/rtpsender.h"
-#include "webrtc/api/statscollector.h"
-#include "webrtc/api/streamcollection.h"
-#include "webrtc/api/webrtcsession.h"
+#include "webrtc/pc/peerconnectionfactory.h"
+#include "webrtc/pc/rtcstatscollector.h"
+#include "webrtc/pc/rtpreceiver.h"
+#include "webrtc/pc/rtpsender.h"
+#include "webrtc/pc/statscollector.h"
+#include "webrtc/pc/streamcollection.h"
+#include "webrtc/pc/webrtcsession.h"
 
 namespace webrtc {
 
@@ -452,4 +452,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_PEERCONNECTION_H_
+#endif  // WEBRTC_PC_PEERCONNECTION_H_
diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/pc/peerconnection_unittest.cc
similarity index 99%
rename from webrtc/api/peerconnection_unittest.cc
rename to webrtc/pc/peerconnection_unittest.cc
index c27e53f..a172a60 100644
--- a/webrtc/api/peerconnection_unittest.cc
+++ b/webrtc/pc/peerconnection_unittest.cc
@@ -17,19 +17,10 @@
 #include <utility>
 #include <vector>
 
-#include "webrtc/api/dtmfsender.h"
 #include "webrtc/api/fakemetricsobserver.h"
-#include "webrtc/api/localaudiosource.h"
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/peerconnection.h"
-#include "webrtc/api/peerconnectionfactory.h"
 #include "webrtc/api/peerconnectioninterface.h"
-#include "webrtc/api/test/fakeaudiocapturemodule.h"
 #include "webrtc/api/test/fakeconstraints.h"
-#include "webrtc/api/test/fakeperiodicvideocapturer.h"
-#include "webrtc/api/test/fakertccertificategenerator.h"
-#include "webrtc/api/test/fakevideotrackrenderer.h"
-#include "webrtc/api/test/mockpeerconnectionobservers.h"
 #include "webrtc/base/fakenetwork.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
@@ -44,7 +35,16 @@
 #include "webrtc/p2p/base/sessiondescription.h"
 #include "webrtc/p2p/base/testturnserver.h"
 #include "webrtc/p2p/client/basicportallocator.h"
+#include "webrtc/pc/dtmfsender.h"
+#include "webrtc/pc/localaudiosource.h"
 #include "webrtc/pc/mediasession.h"
+#include "webrtc/pc/peerconnection.h"
+#include "webrtc/pc/peerconnectionfactory.h"
+#include "webrtc/pc/test/fakeaudiocapturemodule.h"
+#include "webrtc/pc/test/fakeperiodicvideocapturer.h"
+#include "webrtc/pc/test/fakertccertificategenerator.h"
+#include "webrtc/pc/test/fakevideotrackrenderer.h"
+#include "webrtc/pc/test/mockpeerconnectionobservers.h"
 
 #define MAYBE_SKIP_TEST(feature)                    \
   if (!(feature())) {                               \
diff --git a/webrtc/api/peerconnectionendtoend_unittest.cc b/webrtc/pc/peerconnectionendtoend_unittest.cc
similarity index 98%
rename from webrtc/api/peerconnectionendtoend_unittest.cc
rename to webrtc/pc/peerconnectionendtoend_unittest.cc
index 4110db0..4327e1d 100644
--- a/webrtc/api/peerconnectionendtoend_unittest.cc
+++ b/webrtc/pc/peerconnectionendtoend_unittest.cc
@@ -10,12 +10,6 @@
 
 #include <memory>
 
-#include "webrtc/api/test/peerconnectiontestwrapper.h"
-// Notice that mockpeerconnectionobservers.h must be included after the above!
-#include "webrtc/api/test/mockpeerconnectionobservers.h"
-#ifdef WEBRTC_ANDROID
-#include "webrtc/api/test/androidtestinitializer.h"
-#endif
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/ssladapter.h"
@@ -23,6 +17,12 @@
 #include "webrtc/base/sslstreamadapter.h"
 #include "webrtc/base/stringencode.h"
 #include "webrtc/base/stringutils.h"
+#ifdef WEBRTC_ANDROID
+#include "webrtc/pc/test/androidtestinitializer.h"
+#endif
+#include "webrtc/pc/test/peerconnectiontestwrapper.h"
+// Notice that mockpeerconnectionobservers.h must be included after the above!
+#include "webrtc/pc/test/mockpeerconnectionobservers.h"
 
 #define MAYBE_SKIP_TEST(feature)                    \
   if (!(feature())) {                               \
diff --git a/webrtc/api/peerconnectionfactory.cc b/webrtc/pc/peerconnectionfactory.cc
similarity index 97%
rename from webrtc/api/peerconnectionfactory.cc
rename to webrtc/pc/peerconnectionfactory.cc
index 32f461e..99a1daa 100644
--- a/webrtc/api/peerconnectionfactory.cc
+++ b/webrtc/pc/peerconnectionfactory.cc
@@ -8,22 +8,16 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/peerconnectionfactory.h"
+#include "webrtc/pc/peerconnectionfactory.h"
 
 #include <utility>
 
-#include "webrtc/api/audiotrack.h"
-#include "webrtc/api/localaudiosource.h"
 #include "webrtc/api/mediaconstraintsinterface.h"
-#include "webrtc/api/mediastream.h"
 #include "webrtc/api/mediastreamproxy.h"
 #include "webrtc/api/mediastreamtrackproxy.h"
-#include "webrtc/api/peerconnection.h"
 #include "webrtc/api/peerconnectionfactoryproxy.h"
 #include "webrtc/api/peerconnectionproxy.h"
-#include "webrtc/api/videocapturertracksource.h"
 #include "webrtc/api/videosourceproxy.h"
-#include "webrtc/api/videotrack.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/media/engine/webrtcmediaengine.h"
@@ -33,6 +27,12 @@
 #include "webrtc/modules/audio_device/include/audio_device.h"
 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
 #include "webrtc/p2p/client/basicportallocator.h"
+#include "webrtc/pc/audiotrack.h"
+#include "webrtc/pc/localaudiosource.h"
+#include "webrtc/pc/mediastream.h"
+#include "webrtc/pc/peerconnection.h"
+#include "webrtc/pc/videocapturertracksource.h"
+#include "webrtc/pc/videotrack.h"
 
 namespace webrtc {
 
diff --git a/webrtc/api/peerconnectionfactory.h b/webrtc/pc/peerconnectionfactory.h
similarity index 96%
rename from webrtc/api/peerconnectionfactory.h
rename to webrtc/pc/peerconnectionfactory.h
index 4b412ba..6e77d91 100644
--- a/webrtc/api/peerconnectionfactory.h
+++ b/webrtc/pc/peerconnectionfactory.h
@@ -8,19 +8,19 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_PEERCONNECTIONFACTORY_H_
-#define WEBRTC_API_PEERCONNECTIONFACTORY_H_
+#ifndef WEBRTC_PC_PEERCONNECTIONFACTORY_H_
+#define WEBRTC_PC_PEERCONNECTIONFACTORY_H_
 
 #include <memory>
 #include <string>
 
-#include "webrtc/api/mediacontroller.h"
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 #include "webrtc/base/thread.h"
 #include "webrtc/base/rtccertificategenerator.h"
 #include "webrtc/pc/channelmanager.h"
+#include "webrtc/pc/mediacontroller.h"
 
 namespace rtc {
 class BasicNetworkManager;
@@ -143,4 +143,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_PEERCONNECTIONFACTORY_H_
+#endif  // WEBRTC_PC_PEERCONNECTIONFACTORY_H_
diff --git a/webrtc/api/peerconnectionfactory_unittest.cc b/webrtc/pc/peerconnectionfactory_unittest.cc
similarity index 98%
rename from webrtc/api/peerconnectionfactory_unittest.cc
rename to webrtc/pc/peerconnectionfactory_unittest.cc
index 8b5b335..a178998 100644
--- a/webrtc/api/peerconnectionfactory_unittest.cc
+++ b/webrtc/pc/peerconnectionfactory_unittest.cc
@@ -13,18 +13,18 @@
 #include <utility>
 
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/peerconnectionfactory.h"
-#ifdef WEBRTC_ANDROID
-#include "webrtc/api/test/androidtestinitializer.h"
-#endif
-#include "webrtc/api/test/fakertccertificategenerator.h"
-#include "webrtc/api/test/fakevideotrackrenderer.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/thread.h"
 #include "webrtc/media/base/fakevideocapturer.h"
 #include "webrtc/media/engine/webrtccommon.h"
 #include "webrtc/media/engine/webrtcvoe.h"
 #include "webrtc/p2p/base/fakeportallocator.h"
+#include "webrtc/pc/peerconnectionfactory.h"
+#ifdef WEBRTC_ANDROID
+#include "webrtc/pc/test/androidtestinitializer.h"
+#endif
+#include "webrtc/pc/test/fakertccertificategenerator.h"
+#include "webrtc/pc/test/fakevideotrackrenderer.h"
 
 using webrtc::DataChannelInterface;
 using webrtc::FakeVideoTrackRenderer;
diff --git a/webrtc/api/peerconnectioninterface_unittest.cc b/webrtc/pc/peerconnectioninterface_unittest.cc
similarity index 99%
rename from webrtc/api/peerconnectioninterface_unittest.cc
rename to webrtc/pc/peerconnectioninterface_unittest.cc
index be3825c..09395a4 100644
--- a/webrtc/api/peerconnectioninterface_unittest.cc
+++ b/webrtc/pc/peerconnectioninterface_unittest.cc
@@ -13,22 +13,12 @@
 #include <string>
 #include <utility>
 
-#include "webrtc/api/audiotrack.h"
 #include "webrtc/api/jsepsessiondescription.h"
-#include "webrtc/api/mediastream.h"
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/peerconnection.h"
 #include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/api/rtpreceiverinterface.h"
 #include "webrtc/api/rtpsenderinterface.h"
-#include "webrtc/api/streamcollection.h"
 #include "webrtc/api/test/fakeconstraints.h"
-#include "webrtc/api/test/fakertccertificategenerator.h"
-#include "webrtc/api/test/fakevideotracksource.h"
-#include "webrtc/api/test/mockpeerconnectionobservers.h"
-#include "webrtc/api/test/testsdpstrings.h"
-#include "webrtc/api/videocapturertracksource.h"
-#include "webrtc/api/videotrack.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/ssladapter.h"
 #include "webrtc/base/sslstreamadapter.h"
@@ -38,11 +28,21 @@
 #include "webrtc/media/sctp/sctptransportinternal.h"
 #include "webrtc/p2p/base/fakeportallocator.h"
 #include "webrtc/p2p/base/faketransportcontroller.h"
+#include "webrtc/pc/audiotrack.h"
 #include "webrtc/pc/mediasession.h"
+#include "webrtc/pc/mediastream.h"
+#include "webrtc/pc/peerconnection.h"
+#include "webrtc/pc/streamcollection.h"
+#include "webrtc/pc/test/fakertccertificategenerator.h"
+#include "webrtc/pc/test/fakevideotracksource.h"
+#include "webrtc/pc/test/mockpeerconnectionobservers.h"
+#include "webrtc/pc/test/testsdpstrings.h"
+#include "webrtc/pc/videocapturertracksource.h"
+#include "webrtc/pc/videotrack.h"
 #include "webrtc/test/gmock.h"
 
 #ifdef WEBRTC_ANDROID
-#include "webrtc/api/test/androidtestinitializer.h"
+#include "webrtc/pc/test/androidtestinitializer.h"
 #endif
 
 static const char kStreamLabel1[] = "local_stream_1";
diff --git a/webrtc/api/proxy_unittest.cc b/webrtc/pc/proxy_unittest.cc
similarity index 100%
rename from webrtc/api/proxy_unittest.cc
rename to webrtc/pc/proxy_unittest.cc
diff --git a/webrtc/api/quicdatachannel.cc b/webrtc/pc/quicdatachannel.cc
similarity index 99%
rename from webrtc/api/quicdatachannel.cc
rename to webrtc/pc/quicdatachannel.cc
index 2ab2a34..8907ce7 100644
--- a/webrtc/api/quicdatachannel.cc
+++ b/webrtc/pc/quicdatachannel.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/quicdatachannel.h"
+#include "webrtc/pc/quicdatachannel.h"
 
 #include "webrtc/base/bind.h"
 #include "webrtc/base/bytebuffer.h"
diff --git a/webrtc/api/quicdatachannel.h b/webrtc/pc/quicdatachannel.h
similarity index 98%
rename from webrtc/api/quicdatachannel.h
rename to webrtc/pc/quicdatachannel.h
index 18a10ac..2f6288b 100644
--- a/webrtc/api/quicdatachannel.h
+++ b/webrtc/pc/quicdatachannel.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_QUICDATACHANNEL_H_
-#define WEBRTC_API_QUICDATACHANNEL_H_
+#ifndef WEBRTC_PC_QUICDATACHANNEL_H_
+#define WEBRTC_PC_QUICDATACHANNEL_H_
 
 #include <string>
 #include <unordered_map>
@@ -217,4 +217,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_QUICDATACHANNEL_H_
+#endif  // WEBRTC_PC_QUICDATACHANNEL_H_
diff --git a/webrtc/api/quicdatachannel_unittest.cc b/webrtc/pc/quicdatachannel_unittest.cc
similarity index 99%
rename from webrtc/api/quicdatachannel_unittest.cc
rename to webrtc/pc/quicdatachannel_unittest.cc
index 7245ccf..649c36f 100644
--- a/webrtc/api/quicdatachannel_unittest.cc
+++ b/webrtc/pc/quicdatachannel_unittest.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/quicdatachannel.h"
+#include "webrtc/pc/quicdatachannel.h"
 
 #include <map>
 #include <memory>
diff --git a/webrtc/api/quicdatatransport.cc b/webrtc/pc/quicdatatransport.cc
similarity index 99%
rename from webrtc/api/quicdatatransport.cc
rename to webrtc/pc/quicdatatransport.cc
index 44143cc..8b0a93f 100644
--- a/webrtc/api/quicdatatransport.cc
+++ b/webrtc/pc/quicdatatransport.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/quicdatatransport.h"
+#include "webrtc/pc/quicdatatransport.h"
 
 #include "webrtc/base/bind.h"
 #include "webrtc/base/logging.h"
diff --git a/webrtc/api/quicdatatransport.h b/webrtc/pc/quicdatatransport.h
similarity index 96%
rename from webrtc/api/quicdatatransport.h
rename to webrtc/pc/quicdatatransport.h
index b8d3f84..6b35a10 100644
--- a/webrtc/api/quicdatatransport.h
+++ b/webrtc/pc/quicdatatransport.h
@@ -8,18 +8,18 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_QUICDATATRANSPORT_H_
-#define WEBRTC_API_QUICDATATRANSPORT_H_
+#ifndef WEBRTC_PC_QUICDATATRANSPORT_H_
+#define WEBRTC_PC_QUICDATATRANSPORT_H_
 
 #include <string>
 #include <unordered_map>
 
 #include "webrtc/api/datachannelinterface.h"
-#include "webrtc/api/quicdatachannel.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/thread.h"
 #include "webrtc/p2p/base/transportcontroller.h"
+#include "webrtc/pc/quicdatachannel.h"
 
 namespace cricket {
 class QuicTransportChannel;
@@ -112,4 +112,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_QUICDATATRANSPORT_H_
+#endif  // WEBRTC_PC_QUICDATATRANSPORT_H_
diff --git a/webrtc/api/quicdatatransport_unittest.cc b/webrtc/pc/quicdatatransport_unittest.cc
similarity index 99%
rename from webrtc/api/quicdatatransport_unittest.cc
rename to webrtc/pc/quicdatatransport_unittest.cc
index a9c605f..af28159 100644
--- a/webrtc/api/quicdatatransport_unittest.cc
+++ b/webrtc/pc/quicdatatransport_unittest.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/quicdatatransport.h"
+#include "webrtc/pc/quicdatatransport.h"
 
 #include <memory>
 #include <set>
@@ -16,12 +16,12 @@
 #include <unordered_map>
 #include <vector>
 
-#include "webrtc/api/quicdatachannel.h"
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/p2p/base/faketransportcontroller.h"
 #include "webrtc/p2p/quic/quictransportchannel.h"
 #include "webrtc/p2p/quic/reliablequicstream.h"
+#include "webrtc/pc/quicdatachannel.h"
 
 using webrtc::DataBuffer;
 using webrtc::DataChannelInit;
diff --git a/webrtc/api/remoteaudiosource.cc b/webrtc/pc/remoteaudiosource.cc
similarity index 98%
rename from webrtc/api/remoteaudiosource.cc
rename to webrtc/pc/remoteaudiosource.cc
index 47213fa..b256819 100644
--- a/webrtc/api/remoteaudiosource.cc
+++ b/webrtc/pc/remoteaudiosource.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/remoteaudiosource.h"
+#include "webrtc/pc/remoteaudiosource.h"
 
 #include <algorithm>
 #include <functional>
diff --git a/webrtc/api/remoteaudiosource.h b/webrtc/pc/remoteaudiosource.h
similarity index 94%
rename from webrtc/api/remoteaudiosource.h
rename to webrtc/pc/remoteaudiosource.h
index a67b895..b84a016 100644
--- a/webrtc/api/remoteaudiosource.h
+++ b/webrtc/pc/remoteaudiosource.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_REMOTEAUDIOSOURCE_H_
-#define WEBRTC_API_REMOTEAUDIOSOURCE_H_
+#ifndef WEBRTC_PC_REMOTEAUDIOSOURCE_H_
+#define WEBRTC_PC_REMOTEAUDIOSOURCE_H_
 
 #include <list>
 #include <string>
@@ -73,4 +73,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_REMOTEAUDIOSOURCE_H_
+#endif  // WEBRTC_PC_REMOTEAUDIOSOURCE_H_
diff --git a/webrtc/api/rtcstats_integrationtest.cc b/webrtc/pc/rtcstats_integrationtest.cc
similarity index 99%
rename from webrtc/api/rtcstats_integrationtest.cc
rename to webrtc/pc/rtcstats_integrationtest.cc
index 6d14c46..6bba2cb 100644
--- a/webrtc/api/rtcstats_integrationtest.cc
+++ b/webrtc/pc/rtcstats_integrationtest.cc
@@ -15,14 +15,14 @@
 #include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/api/stats/rtcstats_objects.h"
 #include "webrtc/api/stats/rtcstatsreport.h"
-#include "webrtc/api/test/peerconnectiontestwrapper.h"
-#include "webrtc/api/test/rtcstatsobtainer.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/physicalsocketserver.h"
 #include "webrtc/base/refcountedobject.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 #include "webrtc/base/virtualsocketserver.h"
+#include "webrtc/pc/test/peerconnectiontestwrapper.h"
+#include "webrtc/pc/test/rtcstatsobtainer.h"
 
 namespace webrtc {
 
diff --git a/webrtc/api/rtcstatscollector.cc b/webrtc/pc/rtcstatscollector.cc
similarity index 99%
rename from webrtc/api/rtcstatscollector.cc
rename to webrtc/pc/rtcstatscollector.cc
index e7929cb..1a25f32 100644
--- a/webrtc/api/rtcstatscollector.cc
+++ b/webrtc/pc/rtcstatscollector.cc
@@ -8,23 +8,23 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/rtcstatscollector.h"
+#include "webrtc/pc/rtcstatscollector.h"
 
 #include <memory>
 #include <sstream>
 #include <utility>
 #include <vector>
 
-#include "webrtc/api/peerconnection.h"
-#include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/webrtcsession.h"
+#include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/timeutils.h"
 #include "webrtc/media/base/mediachannel.h"
 #include "webrtc/p2p/base/candidate.h"
 #include "webrtc/p2p/base/p2pconstants.h"
 #include "webrtc/p2p/base/port.h"
+#include "webrtc/pc/peerconnection.h"
+#include "webrtc/pc/webrtcsession.h"
 
 namespace webrtc {
 
diff --git a/webrtc/api/rtcstatscollector.h b/webrtc/pc/rtcstatscollector.h
similarity index 94%
rename from webrtc/api/rtcstatscollector.h
rename to webrtc/pc/rtcstatscollector.h
index cd3c55e..de0af33 100644
--- a/webrtc/api/rtcstatscollector.h
+++ b/webrtc/pc/rtcstatscollector.h
@@ -8,17 +8,16 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_RTCSTATSCOLLECTOR_H_
-#define WEBRTC_API_RTCSTATSCOLLECTOR_H_
+#ifndef WEBRTC_PC_RTCSTATSCOLLECTOR_H_
+#define WEBRTC_PC_RTCSTATSCOLLECTOR_H_
 
 #include <map>
 #include <memory>
 #include <set>
 #include <vector>
 
-#include "webrtc/api/datachannel.h"
-#include "webrtc/api/datachannelinterface.h"
 #include "webrtc/api/stats/rtcstats_objects.h"
+#include "webrtc/api/stats/rtcstatscollectorcallback.h"
 #include "webrtc/api/stats/rtcstatsreport.h"
 #include "webrtc/api/trackmediainfomap.h"
 #include "webrtc/base/asyncinvoker.h"
@@ -29,6 +28,7 @@
 #include "webrtc/base/sslidentity.h"
 #include "webrtc/base/timeutils.h"
 #include "webrtc/media/base/mediachannel.h"
+#include "webrtc/pc/datachannel.h"
 
 namespace cricket {
 class Candidate;
@@ -44,14 +44,6 @@
 struct SessionStats;
 struct ChannelNamePairs;
 
-class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface {
- public:
-  virtual ~RTCStatsCollectorCallback() {}
-
-  virtual void OnStatsDelivered(
-      const rtc::scoped_refptr<const RTCStatsReport>& report) = 0;
-};
-
 // All public methods of the collector are to be called on the signaling thread.
 // Stats are gathered on the signaling, worker and network threads
 // asynchronously. The callback is invoked on the signaling thread. Resulting
@@ -197,4 +189,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_RTCSTATSCOLLECTOR_H_
+#endif  // WEBRTC_PC_RTCSTATSCOLLECTOR_H_
diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/pc/rtcstatscollector_unittest.cc
similarity index 99%
rename from webrtc/api/rtcstatscollector_unittest.cc
rename to webrtc/pc/rtcstatscollector_unittest.cc
index c5e8a9c..fd6e1ba 100644
--- a/webrtc/api/rtcstatscollector_unittest.cc
+++ b/webrtc/pc/rtcstatscollector_unittest.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/rtcstatscollector.h"
+#include "webrtc/pc/rtcstatscollector.h"
 
 #include <initializer_list>
 #include <memory>
@@ -17,17 +17,11 @@
 #include <vector>
 
 #include "webrtc/api/jsepsessiondescription.h"
-#include "webrtc/api/mediastream.h"
-#include "webrtc/api/mediastreamtrack.h"
 #include "webrtc/api/rtpparameters.h"
 #include "webrtc/api/stats/rtcstats_objects.h"
 #include "webrtc/api/stats/rtcstatsreport.h"
-#include "webrtc/api/test/mock_datachannel.h"
-#include "webrtc/api/test/mock_peerconnection.h"
 #include "webrtc/api/test/mock_rtpreceiver.h"
 #include "webrtc/api/test/mock_rtpsender.h"
-#include "webrtc/api/test/mock_webrtcsession.h"
-#include "webrtc/api/test/rtcstatsobtainer.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/fakeclock.h"
 #include "webrtc/base/fakesslidentity.h"
@@ -42,6 +36,12 @@
 #include "webrtc/media/base/test/mock_mediachannel.h"
 #include "webrtc/p2p/base/p2pconstants.h"
 #include "webrtc/p2p/base/port.h"
+#include "webrtc/pc/mediastream.h"
+#include "webrtc/pc/mediastreamtrack.h"
+#include "webrtc/pc/test/mock_datachannel.h"
+#include "webrtc/pc/test/mock_peerconnection.h"
+#include "webrtc/pc/test/mock_webrtcsession.h"
+#include "webrtc/pc/test/rtcstatsobtainer.h"
 
 using testing::_;
 using testing::Invoke;
diff --git a/webrtc/api/rtpreceiver.cc b/webrtc/pc/rtpreceiver.cc
similarity index 98%
rename from webrtc/api/rtpreceiver.cc
rename to webrtc/pc/rtpreceiver.cc
index a5a764c..f57babb 100644
--- a/webrtc/api/rtpreceiver.cc
+++ b/webrtc/pc/rtpreceiver.cc
@@ -8,13 +8,13 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/rtpreceiver.h"
+#include "webrtc/pc/rtpreceiver.h"
 
 #include "webrtc/api/mediastreamtrackproxy.h"
-#include "webrtc/api/audiotrack.h"
 #include "webrtc/api/videosourceproxy.h"
-#include "webrtc/api/videotrack.h"
 #include "webrtc/base/trace_event.h"
+#include "webrtc/pc/audiotrack.h"
+#include "webrtc/pc/videotrack.h"
 
 namespace webrtc {
 
diff --git a/webrtc/api/rtpreceiver.h b/webrtc/pc/rtpreceiver.h
similarity index 95%
rename from webrtc/api/rtpreceiver.h
rename to webrtc/pc/rtpreceiver.h
index b6807c4..c135f22 100644
--- a/webrtc/api/rtpreceiver.h
+++ b/webrtc/pc/rtpreceiver.h
@@ -12,8 +12,8 @@
 // An RtpReceiver associates a MediaStreamTrackInterface with an underlying
 // transport (provided by cricket::VoiceChannel/cricket::VideoChannel)
 
-#ifndef WEBRTC_API_RTPRECEIVER_H_
-#define WEBRTC_API_RTPRECEIVER_H_
+#ifndef WEBRTC_PC_RTPRECEIVER_H_
+#define WEBRTC_PC_RTPRECEIVER_H_
 
 #include <stdint.h>
 
@@ -21,11 +21,12 @@
 
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/api/rtpreceiverinterface.h"
-#include "webrtc/api/remoteaudiosource.h"
-#include "webrtc/api/videotracksource.h"
+#include "webrtc/base/basictypes.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/media/base/videobroadcaster.h"
 #include "webrtc/pc/channel.h"
+#include "webrtc/pc/remoteaudiosource.h"
+#include "webrtc/pc/videotracksource.h"
 
 namespace webrtc {
 
@@ -154,4 +155,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_RTPRECEIVER_H_
+#endif  // WEBRTC_PC_RTPRECEIVER_H_
diff --git a/webrtc/api/rtpsender.cc b/webrtc/pc/rtpsender.cc
similarity index 99%
rename from webrtc/api/rtpsender.cc
rename to webrtc/pc/rtpsender.cc
index b2e2461..3e8c7e1 100644
--- a/webrtc/api/rtpsender.cc
+++ b/webrtc/pc/rtpsender.cc
@@ -8,13 +8,13 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/rtpsender.h"
+#include "webrtc/pc/rtpsender.h"
 
-#include "webrtc/api/localaudiosource.h"
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/trace_event.h"
+#include "webrtc/pc/localaudiosource.h"
 
 namespace webrtc {
 
diff --git a/webrtc/pc/rtpsender.h b/webrtc/pc/rtpsender.h
new file mode 100644
index 0000000..ed244b4
--- /dev/null
+++ b/webrtc/pc/rtpsender.h
@@ -0,0 +1,235 @@
+/*
+ *  Copyright 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+// This file contains classes that implement RtpSenderInterface.
+// An RtpSender associates a MediaStreamTrackInterface with an underlying
+// transport (provided by AudioProviderInterface/VideoProviderInterface)
+
+#ifndef WEBRTC_PC_RTPSENDER_H_
+#define WEBRTC_PC_RTPSENDER_H_
+
+#include <memory>
+#include <string>
+
+#include "webrtc/api/mediastreaminterface.h"
+#include "webrtc/api/rtpsenderinterface.h"
+#include "webrtc/base/basictypes.h"
+#include "webrtc/base/criticalsection.h"
+#include "webrtc/media/base/audiosource.h"
+#include "webrtc/pc/channel.h"
+#include "webrtc/pc/statscollector.h"
+
+namespace webrtc {
+
+// Internal interface used by PeerConnection.
+class RtpSenderInternal : public RtpSenderInterface {
+ public:
+  // Used to set the SSRC of the sender, once a local description has been set.
+  // If |ssrc| is 0, this indiates that the sender should disconnect from the
+  // underlying transport (this occurs if the sender isn't seen in a local
+  // description).
+  virtual void SetSsrc(uint32_t ssrc) = 0;
+
+  // TODO(deadbeef): Support one sender having multiple stream ids.
+  virtual void set_stream_id(const std::string& stream_id) = 0;
+  virtual std::string stream_id() const = 0;
+
+  virtual void Stop() = 0;
+};
+
+// LocalAudioSinkAdapter receives data callback as a sink to the local
+// AudioTrack, and passes the data to the sink of AudioSource.
+class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
+                              public cricket::AudioSource {
+ public:
+  LocalAudioSinkAdapter();
+  virtual ~LocalAudioSinkAdapter();
+
+ private:
+  // AudioSinkInterface implementation.
+  void OnData(const void* audio_data,
+              int bits_per_sample,
+              int sample_rate,
+              size_t number_of_channels,
+              size_t number_of_frames) override;
+
+  // cricket::AudioSource implementation.
+  void SetSink(cricket::AudioSource::Sink* sink) override;
+
+  cricket::AudioSource::Sink* sink_;
+  // Critical section protecting |sink_|.
+  rtc::CriticalSection lock_;
+};
+
+class AudioRtpSender : public ObserverInterface,
+                       public rtc::RefCountedObject<RtpSenderInternal> {
+ public:
+  // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called
+  // at the appropriate times.
+  // |channel| can be null if one does not exist yet.
+  AudioRtpSender(AudioTrackInterface* track,
+                 const std::string& stream_id,
+                 cricket::VoiceChannel* channel,
+                 StatsCollector* stats);
+
+  // Randomly generates stream_id.
+  // |channel| can be null if one does not exist yet.
+  AudioRtpSender(AudioTrackInterface* track,
+                 cricket::VoiceChannel* channel,
+                 StatsCollector* stats);
+
+  // Randomly generates id and stream_id.
+  // |channel| can be null if one does not exist yet.
+  AudioRtpSender(cricket::VoiceChannel* channel, StatsCollector* stats);
+
+  virtual ~AudioRtpSender();
+
+  // ObserverInterface implementation
+  void OnChanged() override;
+
+  // RtpSenderInterface implementation
+  bool SetTrack(MediaStreamTrackInterface* track) override;
+  rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
+    return track_;
+  }
+
+  uint32_t ssrc() const override { return ssrc_; }
+
+  cricket::MediaType media_type() const override {
+    return cricket::MEDIA_TYPE_AUDIO;
+  }
+
+  std::string id() const override { return id_; }
+
+  std::vector<std::string> stream_ids() const override {
+    std::vector<std::string> ret = {stream_id_};
+    return ret;
+  }
+
+  RtpParameters GetParameters() const override;
+  bool SetParameters(const RtpParameters& parameters) override;
+
+  // RtpSenderInternal implementation.
+  void SetSsrc(uint32_t ssrc) override;
+
+  void set_stream_id(const std::string& stream_id) override {
+    stream_id_ = stream_id;
+  }
+  std::string stream_id() const override { return stream_id_; }
+
+  void Stop() override;
+
+  // Does not take ownership.
+  // Should call SetChannel(nullptr) before |channel| is destroyed.
+  void SetChannel(cricket::VoiceChannel* channel) { channel_ = channel; }
+
+ private:
+  // TODO(nisse): Since SSRC == 0 is technically valid, figure out
+  // some other way to test if we have a valid SSRC.
+  bool can_send_track() const { return track_ && ssrc_; }
+  // Helper function to construct options for
+  // AudioProviderInterface::SetAudioSend.
+  void SetAudioSend();
+  // Helper function to call SetAudioSend with "stop sending" parameters.
+  void ClearAudioSend();
+
+  std::string id_;
+  std::string stream_id_;
+  cricket::VoiceChannel* channel_ = nullptr;
+  StatsCollector* stats_;
+  rtc::scoped_refptr<AudioTrackInterface> track_;
+  uint32_t ssrc_ = 0;
+  bool cached_track_enabled_ = false;
+  bool stopped_ = false;
+
+  // Used to pass the data callback from the |track_| to the other end of
+  // cricket::AudioSource.
+  std::unique_ptr<LocalAudioSinkAdapter> sink_adapter_;
+};
+
+class VideoRtpSender : public ObserverInterface,
+                       public rtc::RefCountedObject<RtpSenderInternal> {
+ public:
+  // |channel| can be null if one does not exist yet.
+  VideoRtpSender(VideoTrackInterface* track,
+                 const std::string& stream_id,
+                 cricket::VideoChannel* channel);
+
+  // Randomly generates stream_id.
+  // |channel| can be null if one does not exist yet.
+  VideoRtpSender(VideoTrackInterface* track, cricket::VideoChannel* channel);
+
+  // Randomly generates id and stream_id.
+  // |channel| can be null if one does not exist yet.
+  explicit VideoRtpSender(cricket::VideoChannel* channel);
+
+  virtual ~VideoRtpSender();
+
+  // ObserverInterface implementation
+  void OnChanged() override;
+
+  // RtpSenderInterface implementation
+  bool SetTrack(MediaStreamTrackInterface* track) override;
+  rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
+    return track_;
+  }
+
+  uint32_t ssrc() const override { return ssrc_; }
+
+  cricket::MediaType media_type() const override {
+    return cricket::MEDIA_TYPE_VIDEO;
+  }
+
+  std::string id() const override { return id_; }
+
+  std::vector<std::string> stream_ids() const override {
+    std::vector<std::string> ret = {stream_id_};
+    return ret;
+  }
+
+  RtpParameters GetParameters() const override;
+  bool SetParameters(const RtpParameters& parameters) override;
+
+  // RtpSenderInternal implementation.
+  void SetSsrc(uint32_t ssrc) override;
+
+  void set_stream_id(const std::string& stream_id) override {
+    stream_id_ = stream_id;
+  }
+  std::string stream_id() const override { return stream_id_; }
+
+  void Stop() override;
+
+  // Does not take ownership.
+  // Should call SetChannel(nullptr) before |channel| is destroyed.
+  void SetChannel(cricket::VideoChannel* channel) { channel_ = channel; }
+
+ private:
+  bool can_send_track() const { return track_ && ssrc_; }
+  // Helper function to construct options for
+  // VideoProviderInterface::SetVideoSend.
+  void SetVideoSend();
+  // Helper function to call SetVideoSend with "stop sending" parameters.
+  void ClearVideoSend();
+
+  std::string id_;
+  std::string stream_id_;
+  cricket::VideoChannel* channel_ = nullptr;
+  rtc::scoped_refptr<VideoTrackInterface> track_;
+  uint32_t ssrc_ = 0;
+  bool cached_track_enabled_ = false;
+  VideoTrackInterface::ContentHint cached_track_content_hint_ =
+      VideoTrackInterface::ContentHint::kNone;
+  bool stopped_ = false;
+};
+
+}  // namespace webrtc
+
+#endif  // WEBRTC_PC_RTPSENDER_H_
diff --git a/webrtc/api/rtpsenderreceiver_unittest.cc b/webrtc/pc/rtpsenderreceiver_unittest.cc
similarity index 98%
rename from webrtc/api/rtpsenderreceiver_unittest.cc
rename to webrtc/pc/rtpsenderreceiver_unittest.cc
index fc1b748..86c0612 100644
--- a/webrtc/api/rtpsenderreceiver_unittest.cc
+++ b/webrtc/pc/rtpsenderreceiver_unittest.cc
@@ -12,24 +12,24 @@
 #include <string>
 #include <utility>
 
-#include "webrtc/api/audiotrack.h"
-#include "webrtc/api/fakemediacontroller.h"
-#include "webrtc/api/localaudiosource.h"
-#include "webrtc/api/mediastream.h"
-#include "webrtc/api/remoteaudiosource.h"
-#include "webrtc/api/rtpreceiver.h"
-#include "webrtc/api/rtpsender.h"
-#include "webrtc/api/streamcollection.h"
-#include "webrtc/api/test/fakevideotracksource.h"
-#include "webrtc/api/videotrack.h"
-#include "webrtc/api/videotracksource.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
 #include "webrtc/media/base/fakemediaengine.h"
 #include "webrtc/media/base/mediachannel.h"
 #include "webrtc/media/engine/fakewebrtccall.h"
 #include "webrtc/p2p/base/faketransportcontroller.h"
+#include "webrtc/pc/audiotrack.h"
 #include "webrtc/pc/channelmanager.h"
+#include "webrtc/pc/fakemediacontroller.h"
+#include "webrtc/pc/localaudiosource.h"
+#include "webrtc/pc/mediastream.h"
+#include "webrtc/pc/remoteaudiosource.h"
+#include "webrtc/pc/rtpreceiver.h"
+#include "webrtc/pc/rtpsender.h"
+#include "webrtc/pc/streamcollection.h"
+#include "webrtc/pc/test/fakevideotracksource.h"
+#include "webrtc/pc/videotrack.h"
+#include "webrtc/pc/videotracksource.h"
 #include "webrtc/test/gmock.h"
 #include "webrtc/test/gtest.h"
 
diff --git a/webrtc/api/sctputils.cc b/webrtc/pc/sctputils.cc
similarity index 99%
rename from webrtc/api/sctputils.cc
rename to webrtc/pc/sctputils.cc
index d6ea601..1c2f76f 100644
--- a/webrtc/api/sctputils.cc
+++ b/webrtc/pc/sctputils.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/sctputils.h"
+#include "webrtc/pc/sctputils.h"
 
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/copyonwritebuffer.h"
diff --git a/webrtc/api/sctputils.h b/webrtc/pc/sctputils.h
similarity index 92%
rename from webrtc/api/sctputils.h
rename to webrtc/pc/sctputils.h
index 2fb1943..940bd36 100644
--- a/webrtc/api/sctputils.h
+++ b/webrtc/pc/sctputils.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_SCTPUTILS_H_
-#define WEBRTC_API_SCTPUTILS_H_
+#ifndef WEBRTC_PC_SCTPUTILS_H_
+#define WEBRTC_PC_SCTPUTILS_H_
 
 #include <string>
 
@@ -38,4 +38,4 @@
 void WriteDataChannelOpenAckMessage(rtc::CopyOnWriteBuffer* payload);
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_SCTPUTILS_H_
+#endif  // WEBRTC_PC_SCTPUTILS_H_
diff --git a/webrtc/api/sctputils_unittest.cc b/webrtc/pc/sctputils_unittest.cc
similarity index 99%
rename from webrtc/api/sctputils_unittest.cc
rename to webrtc/pc/sctputils_unittest.cc
index 45a127d..dc56e94 100644
--- a/webrtc/api/sctputils_unittest.cc
+++ b/webrtc/pc/sctputils_unittest.cc
@@ -8,10 +8,10 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/sctputils.h"
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/copyonwritebuffer.h"
 #include "webrtc/base/gunit.h"
+#include "webrtc/pc/sctputils.h"
 
 class SctpUtilsTest : public testing::Test {
  public:
diff --git a/webrtc/api/statscollector.cc b/webrtc/pc/statscollector.cc
similarity index 99%
rename from webrtc/api/statscollector.cc
rename to webrtc/pc/statscollector.cc
index 7761d10..3e0c2bf 100644
--- a/webrtc/api/statscollector.cc
+++ b/webrtc/pc/statscollector.cc
@@ -8,16 +8,16 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/statscollector.h"
+#include "webrtc/pc/statscollector.h"
 
 #include <memory>
 #include <utility>
 #include <vector>
 
-#include "webrtc/api/peerconnection.h"
 #include "webrtc/base/base64.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/pc/channel.h"
+#include "webrtc/pc/peerconnection.h"
 
 namespace webrtc {
 namespace {
diff --git a/webrtc/api/statscollector.h b/webrtc/pc/statscollector.h
similarity index 97%
rename from webrtc/api/statscollector.h
rename to webrtc/pc/statscollector.h
index 7c19821..bf895ed 100644
--- a/webrtc/api/statscollector.h
+++ b/webrtc/pc/statscollector.h
@@ -11,8 +11,8 @@
 // This file contains a class used for gathering statistics from an ongoing
 // libjingle PeerConnection.
 
-#ifndef WEBRTC_API_STATSCOLLECTOR_H_
-#define WEBRTC_API_STATSCOLLECTOR_H_
+#ifndef WEBRTC_PC_STATSCOLLECTOR_H_
+#define WEBRTC_PC_STATSCOLLECTOR_H_
 
 #include <map>
 #include <string>
@@ -21,7 +21,7 @@
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/api/statstypes.h"
-#include "webrtc/api/webrtcsession.h"
+#include "webrtc/pc/webrtcsession.h"
 
 namespace webrtc {
 
@@ -149,4 +149,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_STATSCOLLECTOR_H_
+#endif  // WEBRTC_PC_STATSCOLLECTOR_H_
diff --git a/webrtc/api/statscollector_unittest.cc b/webrtc/pc/statscollector_unittest.cc
similarity index 99%
rename from webrtc/api/statscollector_unittest.cc
rename to webrtc/pc/statscollector_unittest.cc
index f72e355..ef218c00 100644
--- a/webrtc/api/statscollector_unittest.cc
+++ b/webrtc/pc/statscollector_unittest.cc
@@ -13,18 +13,9 @@
 #include <algorithm>
 #include <memory>
 
-#include "webrtc/api/statscollector.h"
+#include "webrtc/pc/statscollector.h"
 
-#include "webrtc/api/mediastream.h"
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/mediastreamtrack.h"
-#include "webrtc/api/peerconnection.h"
-#include "webrtc/api/peerconnectionfactory.h"
-#include "webrtc/api/test/fakedatachannelprovider.h"
-#include "webrtc/api/test/fakevideotracksource.h"
-#include "webrtc/api/test/mock_peerconnection.h"
-#include "webrtc/api/test/mock_webrtcsession.h"
-#include "webrtc/api/videotrack.h"
 #include "webrtc/base/base64.h"
 #include "webrtc/base/fakesslidentity.h"
 #include "webrtc/base/gunit.h"
@@ -35,6 +26,15 @@
 #include "webrtc/media/base/test/mock_mediachannel.h"
 #include "webrtc/p2p/base/faketransportcontroller.h"
 #include "webrtc/pc/channelmanager.h"
+#include "webrtc/pc/mediastream.h"
+#include "webrtc/pc/mediastreamtrack.h"
+#include "webrtc/pc/peerconnection.h"
+#include "webrtc/pc/peerconnectionfactory.h"
+#include "webrtc/pc/test/fakedatachannelprovider.h"
+#include "webrtc/pc/test/fakevideotracksource.h"
+#include "webrtc/pc/test/mock_peerconnection.h"
+#include "webrtc/pc/test/mock_webrtcsession.h"
+#include "webrtc/pc/videotrack.h"
 #include "webrtc/test/gmock.h"
 #include "webrtc/test/gtest.h"
 
diff --git a/webrtc/pc/streamcollection.h b/webrtc/pc/streamcollection.h
new file mode 100644
index 0000000..b4d1f27
--- /dev/null
+++ b/webrtc/pc/streamcollection.h
@@ -0,0 +1,108 @@
+/*
+ *  Copyright 2011 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_PC_STREAMCOLLECTION_H_
+#define WEBRTC_PC_STREAMCOLLECTION_H_
+
+#include <string>
+#include <vector>
+
+#include "webrtc/api/peerconnectioninterface.h"
+
+namespace webrtc {
+
+// Implementation of StreamCollection.
+class StreamCollection : public StreamCollectionInterface {
+ public:
+  static rtc::scoped_refptr<StreamCollection> Create() {
+    rtc::RefCountedObject<StreamCollection>* implementation =
+         new rtc::RefCountedObject<StreamCollection>();
+    return implementation;
+  }
+
+  static rtc::scoped_refptr<StreamCollection> Create(
+      StreamCollection* streams) {
+    rtc::RefCountedObject<StreamCollection>* implementation =
+         new rtc::RefCountedObject<StreamCollection>(streams);
+    return implementation;
+  }
+
+  virtual size_t count() {
+    return media_streams_.size();
+  }
+
+  virtual MediaStreamInterface* at(size_t index) {
+    return media_streams_.at(index);
+  }
+
+  virtual MediaStreamInterface* find(const std::string& label) {
+    for (StreamVector::iterator it = media_streams_.begin();
+         it != media_streams_.end(); ++it) {
+      if ((*it)->label().compare(label) == 0) {
+        return (*it);
+      }
+    }
+    return NULL;
+  }
+
+  virtual MediaStreamTrackInterface* FindAudioTrack(
+      const std::string& id) {
+    for (size_t i = 0; i < media_streams_.size(); ++i) {
+      MediaStreamTrackInterface* track = media_streams_[i]->FindAudioTrack(id);
+      if (track) {
+        return track;
+      }
+    }
+    return NULL;
+  }
+
+  virtual MediaStreamTrackInterface* FindVideoTrack(
+      const std::string& id) {
+    for (size_t i = 0; i < media_streams_.size(); ++i) {
+      MediaStreamTrackInterface* track = media_streams_[i]->FindVideoTrack(id);
+      if (track) {
+        return track;
+      }
+    }
+    return NULL;
+  }
+
+  void AddStream(MediaStreamInterface* stream) {
+    for (StreamVector::iterator it = media_streams_.begin();
+         it != media_streams_.end(); ++it) {
+      if ((*it)->label().compare(stream->label()) == 0)
+        return;
+    }
+    media_streams_.push_back(stream);
+  }
+
+  void RemoveStream(MediaStreamInterface* remove_stream) {
+    for (StreamVector::iterator it = media_streams_.begin();
+         it != media_streams_.end(); ++it) {
+      if ((*it)->label().compare(remove_stream->label()) == 0) {
+        media_streams_.erase(it);
+        break;
+      }
+    }
+  }
+
+ protected:
+  StreamCollection() {}
+  explicit StreamCollection(StreamCollection* original)
+      : media_streams_(original->media_streams_) {
+  }
+  typedef std::vector<rtc::scoped_refptr<MediaStreamInterface> >
+      StreamVector;
+  StreamVector media_streams_;
+};
+
+}  // namespace webrtc
+
+#endif  // WEBRTC_PC_STREAMCOLLECTION_H_
diff --git a/webrtc/api/test/DEPS b/webrtc/pc/test/DEPS
similarity index 100%
rename from webrtc/api/test/DEPS
rename to webrtc/pc/test/DEPS
diff --git a/webrtc/api/test/androidtestinitializer.cc b/webrtc/pc/test/androidtestinitializer.cc
similarity index 96%
rename from webrtc/api/test/androidtestinitializer.cc
rename to webrtc/pc/test/androidtestinitializer.cc
index 7c1f5f8..c95d7bc 100644
--- a/webrtc/api/test/androidtestinitializer.cc
+++ b/webrtc/pc/test/androidtestinitializer.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/test/androidtestinitializer.h"
+#include "webrtc/pc/test/androidtestinitializer.h"
 
 #include <pthread.h>
 
diff --git a/webrtc/api/test/androidtestinitializer.h b/webrtc/pc/test/androidtestinitializer.h
similarity index 76%
rename from webrtc/api/test/androidtestinitializer.h
rename to webrtc/pc/test/androidtestinitializer.h
index b56783e..48df9cc 100644
--- a/webrtc/api/test/androidtestinitializer.h
+++ b/webrtc/pc/test/androidtestinitializer.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_
-#define WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_
+#ifndef WEBRTC_PC_TEST_ANDROIDTESTINITIALIZER_H_
+#define WEBRTC_PC_TEST_ANDROIDTESTINITIALIZER_H_
 
 namespace webrtc {
 
@@ -17,4 +17,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_
+#endif  // WEBRTC_PC_TEST_ANDROIDTESTINITIALIZER_H_
diff --git a/webrtc/api/test/fakeaudiocapturemodule.cc b/webrtc/pc/test/fakeaudiocapturemodule.cc
similarity index 99%
rename from webrtc/api/test/fakeaudiocapturemodule.cc
rename to webrtc/pc/test/fakeaudiocapturemodule.cc
index c0b761f..01fd5ee 100644
--- a/webrtc/api/test/fakeaudiocapturemodule.cc
+++ b/webrtc/pc/test/fakeaudiocapturemodule.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/test/fakeaudiocapturemodule.h"
+#include "webrtc/pc/test/fakeaudiocapturemodule.h"
 
 #include "webrtc/base/checks.h"
 #include "webrtc/base/common.h"
diff --git a/webrtc/api/test/fakeaudiocapturemodule.h b/webrtc/pc/test/fakeaudiocapturemodule.h
similarity index 98%
rename from webrtc/api/test/fakeaudiocapturemodule.h
rename to webrtc/pc/test/fakeaudiocapturemodule.h
index 34aa7e0..72735b6 100644
--- a/webrtc/api/test/fakeaudiocapturemodule.h
+++ b/webrtc/pc/test/fakeaudiocapturemodule.h
@@ -17,8 +17,8 @@
 // Note P postfix of a function indicates that it should only be called by the
 // processing thread.
 
-#ifndef WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_
-#define WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_
+#ifndef WEBRTC_PC_TEST_FAKEAUDIOCAPTUREMODULE_H_
+#define WEBRTC_PC_TEST_FAKEAUDIOCAPTUREMODULE_H_
 
 #include <memory>
 
@@ -278,4 +278,4 @@
   rtc::CriticalSection crit_callback_;
 };
 
-#endif  // WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_
+#endif  // WEBRTC_PC_TEST_FAKEAUDIOCAPTUREMODULE_H_
diff --git a/webrtc/api/test/fakeaudiocapturemodule_unittest.cc b/webrtc/pc/test/fakeaudiocapturemodule_unittest.cc
similarity index 99%
rename from webrtc/api/test/fakeaudiocapturemodule_unittest.cc
rename to webrtc/pc/test/fakeaudiocapturemodule_unittest.cc
index 53fb5f2..aa40af7 100644
--- a/webrtc/api/test/fakeaudiocapturemodule_unittest.cc
+++ b/webrtc/pc/test/fakeaudiocapturemodule_unittest.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/test/fakeaudiocapturemodule.h"
+#include "webrtc/pc/test/fakeaudiocapturemodule.h"
 
 #include <algorithm>
 
diff --git a/webrtc/api/test/fakedatachannelprovider.h b/webrtc/pc/test/fakedatachannelprovider.h
similarity index 95%
rename from webrtc/api/test/fakedatachannelprovider.h
rename to webrtc/pc/test/fakedatachannelprovider.h
index 3e796a3..114f3de 100644
--- a/webrtc/api/test/fakedatachannelprovider.h
+++ b/webrtc/pc/test/fakedatachannelprovider.h
@@ -8,11 +8,11 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_
-#define WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_
+#ifndef WEBRTC_PC_TEST_FAKEDATACHANNELPROVIDER_H_
+#define WEBRTC_PC_TEST_FAKEDATACHANNELPROVIDER_H_
 
-#include "webrtc/api/datachannel.h"
 #include "webrtc/base/checks.h"
+#include "webrtc/pc/datachannel.h"
 
 class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
  public:
@@ -144,4 +144,4 @@
   std::set<uint32_t> send_ssrcs_;
   std::set<uint32_t> recv_ssrcs_;
 };
-#endif  // WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_
+#endif  // WEBRTC_PC_TEST_FAKEDATACHANNELPROVIDER_H_
diff --git a/webrtc/api/test/fakeperiodicvideocapturer.h b/webrtc/pc/test/fakeperiodicvideocapturer.h
similarity index 93%
rename from webrtc/api/test/fakeperiodicvideocapturer.h
rename to webrtc/pc/test/fakeperiodicvideocapturer.h
index 2c16195..551df8b 100644
--- a/webrtc/api/test/fakeperiodicvideocapturer.h
+++ b/webrtc/pc/test/fakeperiodicvideocapturer.h
@@ -11,8 +11,8 @@
 // FakePeriodicVideoCapturer implements a fake cricket::VideoCapturer that
 // creates video frames periodically after it has been started.
 
-#ifndef WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_
-#define WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_
+#ifndef WEBRTC_PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_
+#define WEBRTC_PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_
 
 #include <vector>
 
@@ -71,4 +71,4 @@
 
 }  // namespace webrtc
 
-#endif  //  WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_
+#endif  //  WEBRTC_PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_
diff --git a/webrtc/api/test/fakertccertificategenerator.h b/webrtc/pc/test/fakertccertificategenerator.h
similarity index 98%
rename from webrtc/api/test/fakertccertificategenerator.h
rename to webrtc/pc/test/fakertccertificategenerator.h
index cd1e4bf..ce36834 100644
--- a/webrtc/api/test/fakertccertificategenerator.h
+++ b/webrtc/pc/test/fakertccertificategenerator.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_FAKERTCCERTIFICATEGENERATOR_H_
-#define WEBRTC_API_TEST_FAKERTCCERTIFICATEGENERATOR_H_
+#ifndef WEBRTC_PC_TEST_FAKERTCCERTIFICATEGENERATOR_H_
+#define WEBRTC_PC_TEST_FAKERTCCERTIFICATEGENERATOR_H_
 
 #include <memory>
 #include <string>
@@ -228,4 +228,4 @@
   int generated_certificates_ = 0;
 };
 
-#endif  // WEBRTC_API_TEST_FAKERTCCERTIFICATEGENERATOR_H_
+#endif  // WEBRTC_PC_TEST_FAKERTCCERTIFICATEGENERATOR_H_
diff --git a/webrtc/api/test/fakevideotrackrenderer.h b/webrtc/pc/test/fakevideotrackrenderer.h
similarity index 85%
rename from webrtc/api/test/fakevideotrackrenderer.h
rename to webrtc/pc/test/fakevideotrackrenderer.h
index 0d9b248..9bf0b95 100644
--- a/webrtc/api/test/fakevideotrackrenderer.h
+++ b/webrtc/pc/test/fakevideotrackrenderer.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_
-#define WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_
+#ifndef WEBRTC_PC_TEST_FAKEVIDEOTRACKRENDERER_H_
+#define WEBRTC_PC_TEST_FAKEVIDEOTRACKRENDERER_H_
 
 #include "webrtc/api/mediastreaminterface.h"
 #include "webrtc/media/base/fakevideorenderer.h"
@@ -30,4 +30,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_
+#endif  // WEBRTC_PC_TEST_FAKEVIDEOTRACKRENDERER_H_
diff --git a/webrtc/api/test/fakevideotracksource.h b/webrtc/pc/test/fakevideotracksource.h
similarity index 87%
rename from webrtc/api/test/fakevideotracksource.h
rename to webrtc/pc/test/fakevideotracksource.h
index 0638a1f..aa5f3f5 100644
--- a/webrtc/api/test/fakevideotracksource.h
+++ b/webrtc/pc/test/fakevideotracksource.h
@@ -8,12 +8,12 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_FAKEVIDEOTRACKSOURCE_H_
-#define WEBRTC_API_TEST_FAKEVIDEOTRACKSOURCE_H_
+#ifndef WEBRTC_PC_TEST_FAKEVIDEOTRACKSOURCE_H_
+#define WEBRTC_PC_TEST_FAKEVIDEOTRACKSOURCE_H_
 
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/videotracksource.h"
 #include "webrtc/media/base/fakevideocapturer.h"
+#include "webrtc/pc/videotracksource.h"
 
 namespace webrtc {
 
@@ -46,4 +46,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_FAKEVIDEOTRACKSOURCE_H_
+#endif  // WEBRTC_PC_TEST_FAKEVIDEOTRACKSOURCE_H_
diff --git a/webrtc/api/test/mock_datachannel.h b/webrtc/pc/test/mock_datachannel.h
similarity index 91%
rename from webrtc/api/test/mock_datachannel.h
rename to webrtc/pc/test/mock_datachannel.h
index 1cb1948..105fcba 100644
--- a/webrtc/api/test/mock_datachannel.h
+++ b/webrtc/pc/test/mock_datachannel.h
@@ -8,10 +8,10 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_MOCK_DATACHANNEL_H_
-#define WEBRTC_API_TEST_MOCK_DATACHANNEL_H_
+#ifndef WEBRTC_PC_TEST_MOCK_DATACHANNEL_H_
+#define WEBRTC_PC_TEST_MOCK_DATACHANNEL_H_
 
-#include "webrtc/api/datachannel.h"
+#include "webrtc/pc/datachannel.h"
 #include "webrtc/test/gmock.h"
 
 namespace webrtc {
@@ -55,4 +55,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_MOCK_DATACHANNEL_H_
+#endif  // WEBRTC_PC_TEST_MOCK_DATACHANNEL_H_
diff --git a/webrtc/api/test/mock_peerconnection.h b/webrtc/pc/test/mock_peerconnection.h
similarity index 88%
rename from webrtc/api/test/mock_peerconnection.h
rename to webrtc/pc/test/mock_peerconnection.h
index ca39d2a..4dca0af 100644
--- a/webrtc/api/test/mock_peerconnection.h
+++ b/webrtc/pc/test/mock_peerconnection.h
@@ -8,12 +8,12 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_MOCK_PEERCONNECTION_H_
-#define WEBRTC_API_TEST_MOCK_PEERCONNECTION_H_
+#ifndef WEBRTC_PC_TEST_MOCK_PEERCONNECTION_H_
+#define WEBRTC_PC_TEST_MOCK_PEERCONNECTION_H_
 
 #include <vector>
 
-#include "webrtc/api/peerconnection.h"
+#include "webrtc/pc/peerconnection.h"
 #include "webrtc/test/gmock.h"
 
 namespace webrtc {
@@ -43,4 +43,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_MOCK_PEERCONNECTION_H_
+#endif  // WEBRTC_PC_TEST_MOCK_PEERCONNECTION_H_
diff --git a/webrtc/api/test/mock_webrtcsession.h b/webrtc/pc/test/mock_webrtcsession.h
similarity index 93%
rename from webrtc/api/test/mock_webrtcsession.h
rename to webrtc/pc/test/mock_webrtcsession.h
index ae75035..d476377 100644
--- a/webrtc/api/test/mock_webrtcsession.h
+++ b/webrtc/pc/test/mock_webrtcsession.h
@@ -8,13 +8,13 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_MOCK_WEBRTCSESSION_H_
-#define WEBRTC_API_TEST_MOCK_WEBRTCSESSION_H_
+#ifndef WEBRTC_PC_TEST_MOCK_WEBRTCSESSION_H_
+#define WEBRTC_PC_TEST_MOCK_WEBRTCSESSION_H_
 
 #include <memory>
 #include <string>
 
-#include "webrtc/api/webrtcsession.h"
+#include "webrtc/pc/webrtcsession.h"
 #include "webrtc/media/sctp/sctptransportinternal.h"
 #include "webrtc/test/gmock.h"
 
@@ -62,4 +62,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_MOCK_WEBRTCSESSION_H_
+#endif  // WEBRTC_PC_TEST_MOCK_WEBRTCSESSION_H_
diff --git a/webrtc/api/test/mockpeerconnectionobservers.h b/webrtc/pc/test/mockpeerconnectionobservers.h
similarity index 97%
rename from webrtc/api/test/mockpeerconnectionobservers.h
rename to webrtc/pc/test/mockpeerconnectionobservers.h
index 1f000af..bde59a8 100644
--- a/webrtc/api/test/mockpeerconnectionobservers.h
+++ b/webrtc/pc/test/mockpeerconnectionobservers.h
@@ -10,8 +10,8 @@
 
 // This file contains mock implementations of observers used in PeerConnection.
 
-#ifndef WEBRTC_API_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
-#define WEBRTC_API_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
+#ifndef WEBRTC_PC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
+#define WEBRTC_PC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
 
 #include <memory>
 #include <string>
@@ -227,4 +227,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
+#endif  // WEBRTC_PC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
diff --git a/webrtc/api/test/peerconnectiontestwrapper.cc b/webrtc/pc/test/peerconnectiontestwrapper.cc
similarity index 97%
rename from webrtc/api/test/peerconnectiontestwrapper.cc
rename to webrtc/pc/test/peerconnectiontestwrapper.cc
index b1eb586..6404e2b 100644
--- a/webrtc/api/test/peerconnectiontestwrapper.cc
+++ b/webrtc/pc/test/peerconnectiontestwrapper.cc
@@ -10,12 +10,12 @@
 
 #include <utility>
 
-#include "webrtc/api/test/fakeperiodicvideocapturer.h"
-#include "webrtc/api/test/fakertccertificategenerator.h"
-#include "webrtc/api/test/mockpeerconnectionobservers.h"
-#include "webrtc/api/test/peerconnectiontestwrapper.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/p2p/base/fakeportallocator.h"
+#include "webrtc/pc/test/fakeperiodicvideocapturer.h"
+#include "webrtc/pc/test/fakertccertificategenerator.h"
+#include "webrtc/pc/test/mockpeerconnectionobservers.h"
+#include "webrtc/pc/test/peerconnectiontestwrapper.h"
 
 static const char kStreamLabelBase[] = "stream_label";
 static const char kVideoTrackLabelBase[] = "video_track";
diff --git a/webrtc/api/test/peerconnectiontestwrapper.h b/webrtc/pc/test/peerconnectiontestwrapper.h
similarity index 94%
rename from webrtc/api/test/peerconnectiontestwrapper.h
rename to webrtc/pc/test/peerconnectiontestwrapper.h
index 6433e8f..59e6968 100644
--- a/webrtc/api/test/peerconnectiontestwrapper.h
+++ b/webrtc/pc/test/peerconnectiontestwrapper.h
@@ -8,16 +8,16 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_
-#define WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_
+#ifndef WEBRTC_PC_TEST_PEERCONNECTIONTESTWRAPPER_H_
+#define WEBRTC_PC_TEST_PEERCONNECTIONTESTWRAPPER_H_
 
 #include <memory>
 
 #include "webrtc/api/peerconnectioninterface.h"
-#include "webrtc/api/test/fakeaudiocapturemodule.h"
 #include "webrtc/api/test/fakeconstraints.h"
-#include "webrtc/api/test/fakevideotrackrenderer.h"
 #include "webrtc/base/sigslot.h"
+#include "webrtc/pc/test/fakeaudiocapturemodule.h"
+#include "webrtc/pc/test/fakevideotrackrenderer.h"
 
 class PeerConnectionTestWrapper
     : public webrtc::PeerConnectionObserver,
@@ -115,4 +115,4 @@
   std::unique_ptr<webrtc::FakeVideoTrackRenderer> renderer_;
 };
 
-#endif  // WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_
+#endif  // WEBRTC_PC_TEST_PEERCONNECTIONTESTWRAPPER_H_
diff --git a/webrtc/api/test/rtcstatsobtainer.h b/webrtc/pc/test/rtcstatsobtainer.h
similarity index 91%
rename from webrtc/api/test/rtcstatsobtainer.h
rename to webrtc/pc/test/rtcstatsobtainer.h
index aeae87c..d0d4b61 100644
--- a/webrtc/api/test/rtcstatsobtainer.h
+++ b/webrtc/pc/test/rtcstatsobtainer.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_TEST_RTCSTATSOBTAINER_H_
-#define WEBRTC_API_TEST_RTCSTATSOBTAINER_H_
+#ifndef WEBRTC_PC_TEST_RTCSTATSOBTAINER_H_
+#define WEBRTC_PC_TEST_RTCSTATSOBTAINER_H_
 
 #include "webrtc/api/stats/rtcstatsreport.h"
 #include "webrtc/base/gunit.h"
@@ -50,4 +50,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_RTCSTATSOBTAINER_H_
+#endif  // WEBRTC_PC_TEST_RTCSTATSOBTAINER_H_
diff --git a/webrtc/api/test/testsdpstrings.h b/webrtc/pc/test/testsdpstrings.h
similarity index 97%
rename from webrtc/api/test/testsdpstrings.h
rename to webrtc/pc/test/testsdpstrings.h
index b203aad..ff097b2 100644
--- a/webrtc/api/test/testsdpstrings.h
+++ b/webrtc/pc/test/testsdpstrings.h
@@ -10,8 +10,8 @@
 
 // This file contain SDP strings used for testing.
 
-#ifndef WEBRTC_API_TEST_TESTSDPSTRINGS_H_
-#define WEBRTC_API_TEST_TESTSDPSTRINGS_H_
+#ifndef WEBRTC_PC_TEST_TESTSDPSTRINGS_H_
+#define WEBRTC_PC_TEST_TESTSDPSTRINGS_H_
 
 namespace webrtc {
 
@@ -129,4 +129,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_TEST_TESTSDPSTRINGS_H_
+#endif  // WEBRTC_PC_TEST_TESTSDPSTRINGS_H_
diff --git a/webrtc/api/videocapturertracksource.cc b/webrtc/pc/videocapturertracksource.cc
similarity index 99%
rename from webrtc/api/videocapturertracksource.cc
rename to webrtc/pc/videocapturertracksource.cc
index 0d6d46d..771429a 100644
--- a/webrtc/api/videocapturertracksource.cc
+++ b/webrtc/pc/videocapturertracksource.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/videocapturertracksource.h"
+#include "webrtc/pc/videocapturertracksource.h"
 
 #include <cstdlib>
 #include <string>
diff --git a/webrtc/api/videocapturertracksource.h b/webrtc/pc/videocapturertracksource.h
similarity index 93%
rename from webrtc/api/videocapturertracksource.h
rename to webrtc/pc/videocapturertracksource.h
index b0a2810..30991a1 100644
--- a/webrtc/api/videocapturertracksource.h
+++ b/webrtc/pc/videocapturertracksource.h
@@ -8,17 +8,17 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_
-#define WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_
+#ifndef WEBRTC_PC_VIDEOCAPTURERTRACKSOURCE_H_
+#define WEBRTC_PC_VIDEOCAPTURERTRACKSOURCE_H_
 
 #include <memory>
 
 #include "webrtc/api/mediastreaminterface.h"
-#include "webrtc/api/videotracksource.h"
 #include "webrtc/base/asyncinvoker.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/media/base/videocapturer.h"
 #include "webrtc/media/base/videocommon.h"
+#include "webrtc/pc/videotracksource.h"
 
 // VideoCapturerTrackSource implements VideoTrackSourceInterface. It owns a
 // cricket::VideoCapturer and make sure the camera is started at a resolution
@@ -81,4 +81,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_
+#endif  // WEBRTC_PC_VIDEOCAPTURERTRACKSOURCE_H_
diff --git a/webrtc/api/videocapturertracksource_unittest.cc b/webrtc/pc/videocapturertracksource_unittest.cc
similarity index 99%
rename from webrtc/api/videocapturertracksource_unittest.cc
rename to webrtc/pc/videocapturertracksource_unittest.cc
index a0350d9..144d4b4 100644
--- a/webrtc/api/videocapturertracksource_unittest.cc
+++ b/webrtc/pc/videocapturertracksource_unittest.cc
@@ -13,11 +13,11 @@
 #include <vector>
 
 #include "webrtc/api/test/fakeconstraints.h"
-#include "webrtc/api/videocapturertracksource.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/media/base/fakemediaengine.h"
 #include "webrtc/media/base/fakevideocapturer.h"
 #include "webrtc/media/base/fakevideorenderer.h"
+#include "webrtc/pc/videocapturertracksource.h"
 
 using webrtc::FakeConstraints;
 using webrtc::VideoCapturerTrackSource;
diff --git a/webrtc/api/videotrack.cc b/webrtc/pc/videotrack.cc
similarity index 96%
rename from webrtc/api/videotrack.cc
rename to webrtc/pc/videotrack.cc
index 2fa2ba6..494d728 100644
--- a/webrtc/api/videotrack.cc
+++ b/webrtc/pc/videotrack.cc
@@ -8,14 +8,12 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/videotrack.h"
+#include "webrtc/pc/videotrack.h"
 
 #include <string>
 
 namespace webrtc {
 
-const char MediaStreamTrackInterface::kVideoKind[] = "video";
-
 VideoTrack::VideoTrack(const std::string& label,
                        VideoTrackSourceInterface* video_source)
     : MediaStreamTrack<VideoTrackInterface>(label),
diff --git a/webrtc/api/videotrack.h b/webrtc/pc/videotrack.h
similarity index 92%
rename from webrtc/api/videotrack.h
rename to webrtc/pc/videotrack.h
index ebea848..7e75e14 100644
--- a/webrtc/api/videotrack.h
+++ b/webrtc/pc/videotrack.h
@@ -8,16 +8,16 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_VIDEOTRACK_H_
-#define WEBRTC_API_VIDEOTRACK_H_
+#ifndef WEBRTC_PC_VIDEOTRACK_H_
+#define WEBRTC_PC_VIDEOTRACK_H_
 
 #include <string>
 #include <vector>
 
-#include "webrtc/api/mediastreamtrack.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 #include "webrtc/base/thread_checker.h"
 #include "webrtc/media/base/videosourcebase.h"
+#include "webrtc/pc/mediastreamtrack.h"
 
 namespace webrtc {
 
@@ -57,4 +57,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_VIDEOTRACK_H_
+#endif  // WEBRTC_PC_VIDEOTRACK_H_
diff --git a/webrtc/api/videotrack_unittest.cc b/webrtc/pc/videotrack_unittest.cc
similarity index 95%
rename from webrtc/api/videotrack_unittest.cc
rename to webrtc/pc/videotrack_unittest.cc
index 5320482..6f4330f 100644
--- a/webrtc/api/videotrack_unittest.cc
+++ b/webrtc/pc/videotrack_unittest.cc
@@ -11,12 +11,12 @@
 #include <memory>
 #include <string>
 
-#include "webrtc/api/test/fakevideotrackrenderer.h"
-#include "webrtc/api/videocapturertracksource.h"
-#include "webrtc/api/videotrack.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/media/base/fakevideocapturer.h"
 #include "webrtc/media/base/fakemediaengine.h"
+#include "webrtc/pc/test/fakevideotrackrenderer.h"
+#include "webrtc/pc/videocapturertracksource.h"
+#include "webrtc/pc/videotrack.h"
 
 using webrtc::FakeVideoTrackRenderer;
 using webrtc::MediaSourceInterface;
diff --git a/webrtc/api/videotracksource.cc b/webrtc/pc/videotracksource.cc
similarity index 96%
rename from webrtc/api/videotracksource.cc
rename to webrtc/pc/videotracksource.cc
index 83ae493..f3ca8d7 100644
--- a/webrtc/api/videotracksource.cc
+++ b/webrtc/pc/videotracksource.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/videotracksource.h"
+#include "webrtc/pc/videotracksource.h"
 
 #include <string>
 
diff --git a/webrtc/pc/videotracksource.h b/webrtc/pc/videotracksource.h
new file mode 100644
index 0000000..259b1c3
--- /dev/null
+++ b/webrtc/pc/videotracksource.h
@@ -0,0 +1,55 @@
+/*
+ *  Copyright 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_PC_VIDEOTRACKSOURCE_H_
+#define WEBRTC_PC_VIDEOTRACKSOURCE_H_
+
+#include "webrtc/api/mediastreaminterface.h"
+#include "webrtc/api/notifier.h"
+#include "webrtc/base/thread_checker.h"
+#include "webrtc/media/base/mediachannel.h"
+#include "webrtc/media/base/videosinkinterface.h"
+
+// VideoTrackSource implements VideoTrackSourceInterface.
+namespace webrtc {
+
+class VideoTrackSource : public Notifier<VideoTrackSourceInterface> {
+ public:
+  VideoTrackSource(rtc::VideoSourceInterface<VideoFrame>* source, bool remote);
+  void SetState(SourceState new_state);
+  // OnSourceDestroyed clears this instance pointer to |source_|. It is useful
+  // when the underlying rtc::VideoSourceInterface is destroyed before the
+  // reference counted VideoTrackSource.
+  void OnSourceDestroyed();
+
+  SourceState state() const override { return state_; }
+  bool remote() const override { return remote_; }
+
+  bool is_screencast() const override { return false; }
+  rtc::Optional<bool> needs_denoising() const override {
+    return rtc::Optional<bool>(); }
+
+  bool GetStats(Stats* stats) override { return false; }
+
+  void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
+                       const rtc::VideoSinkWants& wants) override;
+  void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
+
+ private:
+  rtc::ThreadChecker worker_thread_checker_;
+  rtc::VideoSourceInterface<VideoFrame>* source_;
+  cricket::VideoOptions options_;
+  SourceState state_;
+  const bool remote_;
+};
+
+}  // namespace webrtc
+
+#endif  //  WEBRTC_PC_VIDEOTRACKSOURCE_H_
diff --git a/webrtc/api/webrtcsdp.cc b/webrtc/pc/webrtcsdp.cc
similarity index 99%
rename from webrtc/api/webrtcsdp.cc
rename to webrtc/pc/webrtcsdp.cc
index c79c851..d4003c2 100644
--- a/webrtc/api/webrtcsdp.cc
+++ b/webrtc/pc/webrtcsdp.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/webrtcsdp.h"
+#include "webrtc/pc/webrtcsdp.h"
 
 #include <ctype.h>
 #include <limits.h>
diff --git a/webrtc/api/webrtcsdp.h b/webrtc/pc/webrtcsdp.h
similarity index 96%
rename from webrtc/api/webrtcsdp.h
rename to webrtc/pc/webrtcsdp.h
index e7fdb34..beaf0c5 100644
--- a/webrtc/api/webrtcsdp.h
+++ b/webrtc/pc/webrtcsdp.h
@@ -17,8 +17,8 @@
 // * draft-lennox-mmusic-sdp-source-selection-02 -
 //   Mechanisms for Media Source Selection in SDP
 
-#ifndef WEBRTC_API_WEBRTCSDP_H_
-#define WEBRTC_API_WEBRTCSDP_H_
+#ifndef WEBRTC_PC_WEBRTCSDP_H_
+#define WEBRTC_PC_WEBRTCSDP_H_
 
 #include <string>
 
@@ -84,4 +84,4 @@
 
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_WEBRTCSDP_H_
+#endif  // WEBRTC_PC_WEBRTCSDP_H_
diff --git a/webrtc/api/webrtcsdp_unittest.cc b/webrtc/pc/webrtcsdp_unittest.cc
similarity index 99%
rename from webrtc/api/webrtcsdp_unittest.cc
rename to webrtc/pc/webrtcsdp_unittest.cc
index d4accba..54eb22e 100644
--- a/webrtc/api/webrtcsdp_unittest.cc
+++ b/webrtc/pc/webrtcsdp_unittest.cc
@@ -14,10 +14,6 @@
 #include <vector>
 
 #include "webrtc/api/jsepsessiondescription.h"
-#ifdef WEBRTC_ANDROID
-#include "webrtc/api/test/androidtestinitializer.h"
-#endif
-#include "webrtc/api/webrtcsdp.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
@@ -30,6 +26,10 @@
 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
 #include "webrtc/p2p/base/p2pconstants.h"
 #include "webrtc/pc/mediasession.h"
+#ifdef WEBRTC_ANDROID
+#include "webrtc/pc/test/androidtestinitializer.h"
+#endif
+#include "webrtc/pc/webrtcsdp.h"
 
 using cricket::AudioCodec;
 using cricket::AudioContentDescription;
diff --git a/webrtc/api/webrtcsession.cc b/webrtc/pc/webrtcsession.cc
similarity index 99%
rename from webrtc/api/webrtcsession.cc
rename to webrtc/pc/webrtcsession.cc
index e98bcb0..def02d4 100644
--- a/webrtc/api/webrtcsession.cc
+++ b/webrtc/pc/webrtcsession.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/webrtcsession.h"
+#include "webrtc/pc/webrtcsession.h"
 
 #include <limits.h>
 
@@ -21,8 +21,6 @@
 #include "webrtc/api/jsepicecandidate.h"
 #include "webrtc/api/jsepsessiondescription.h"
 #include "webrtc/api/peerconnectioninterface.h"
-#include "webrtc/api/sctputils.h"
-#include "webrtc/api/webrtcsessiondescriptionfactory.h"
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/checks.h"
@@ -38,6 +36,8 @@
 #include "webrtc/pc/channel.h"
 #include "webrtc/pc/channelmanager.h"
 #include "webrtc/pc/mediasession.h"
+#include "webrtc/pc/sctputils.h"
+#include "webrtc/pc/webrtcsessiondescriptionfactory.h"
 
 #ifdef HAVE_QUIC
 #include "webrtc/p2p/quic/quictransportchannel.h"
diff --git a/webrtc/api/webrtcsession.h b/webrtc/pc/webrtcsession.h
similarity index 98%
rename from webrtc/api/webrtcsession.h
rename to webrtc/pc/webrtcsession.h
index 0030342..c250833 100644
--- a/webrtc/api/webrtcsession.h
+++ b/webrtc/pc/webrtcsession.h
@@ -8,17 +8,14 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_WEBRTCSESSION_H_
-#define WEBRTC_API_WEBRTCSESSION_H_
+#ifndef WEBRTC_PC_WEBRTCSESSION_H_
+#define WEBRTC_PC_WEBRTCSESSION_H_
 
 #include <memory>
 #include <set>
 #include <string>
 #include <vector>
 
-#include "webrtc/api/datachannel.h"
-#include "webrtc/api/dtmfsender.h"
-#include "webrtc/api/mediacontroller.h"
 #include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/api/statstypes.h"
 #include "webrtc/base/constructormagic.h"
@@ -29,10 +26,13 @@
 #include "webrtc/media/base/mediachannel.h"
 #include "webrtc/p2p/base/candidate.h"
 #include "webrtc/p2p/base/transportcontroller.h"
+#include "webrtc/pc/datachannel.h"
+#include "webrtc/pc/dtmfsender.h"
+#include "webrtc/pc/mediacontroller.h"
 #include "webrtc/pc/mediasession.h"
 
 #ifdef HAVE_QUIC
-#include "webrtc/api/quicdatatransport.h"
+#include "webrtc/pc/quicdatatransport.h"
 #endif  // HAVE_QUIC
 
 namespace cricket {
@@ -651,4 +651,4 @@
 };
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_WEBRTCSESSION_H_
+#endif  // WEBRTC_PC_WEBRTCSESSION_H_
diff --git a/webrtc/api/webrtcsession_unittest.cc b/webrtc/pc/webrtcsession_unittest.cc
similarity index 99%
rename from webrtc/api/webrtcsession_unittest.cc
rename to webrtc/pc/webrtcsession_unittest.cc
index 1a7a026..053f64c 100644
--- a/webrtc/api/webrtcsession_unittest.cc
+++ b/webrtc/pc/webrtcsession_unittest.cc
@@ -12,17 +12,9 @@
 #include <utility>
 #include <vector>
 
-#include "webrtc/api/audiotrack.h"
-#include "webrtc/api/fakemediacontroller.h"
 #include "webrtc/api/fakemetricsobserver.h"
 #include "webrtc/api/jsepicecandidate.h"
 #include "webrtc/api/jsepsessiondescription.h"
-#include "webrtc/api/peerconnection.h"
-#include "webrtc/api/sctputils.h"
-#include "webrtc/api/test/fakertccertificategenerator.h"
-#include "webrtc/api/videotrack.h"
-#include "webrtc/api/webrtcsession.h"
-#include "webrtc/api/webrtcsessiondescriptionfactory.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/fakenetwork.h"
 #include "webrtc/base/firewallsocketserver.h"
@@ -47,8 +39,16 @@
 #include "webrtc/p2p/base/teststunserver.h"
 #include "webrtc/p2p/base/testturnserver.h"
 #include "webrtc/p2p/client/basicportallocator.h"
+#include "webrtc/pc/audiotrack.h"
 #include "webrtc/pc/channelmanager.h"
+#include "webrtc/pc/fakemediacontroller.h"
 #include "webrtc/pc/mediasession.h"
+#include "webrtc/pc/peerconnection.h"
+#include "webrtc/pc/sctputils.h"
+#include "webrtc/pc/test/fakertccertificategenerator.h"
+#include "webrtc/pc/videotrack.h"
+#include "webrtc/pc/webrtcsession.h"
+#include "webrtc/pc/webrtcsessiondescriptionfactory.h"
 
 #define MAYBE_SKIP_TEST(feature)                    \
   if (!(feature())) {                               \
diff --git a/webrtc/api/webrtcsessiondescriptionfactory.cc b/webrtc/pc/webrtcsessiondescriptionfactory.cc
similarity index 99%
rename from webrtc/api/webrtcsessiondescriptionfactory.cc
rename to webrtc/pc/webrtcsessiondescriptionfactory.cc
index 65ee7ef..168e5a2 100644
--- a/webrtc/api/webrtcsessiondescriptionfactory.cc
+++ b/webrtc/pc/webrtcsessiondescriptionfactory.cc
@@ -8,16 +8,16 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "webrtc/api/webrtcsessiondescriptionfactory.h"
+#include "webrtc/pc/webrtcsessiondescriptionfactory.h"
 
 #include <utility>
 
 #include "webrtc/api/jsep.h"
 #include "webrtc/api/jsepsessiondescription.h"
 #include "webrtc/api/mediaconstraintsinterface.h"
-#include "webrtc/api/webrtcsession.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/sslidentity.h"
+#include "webrtc/pc/webrtcsession.h"
 
 using cricket::MediaSessionOptions;
 
diff --git a/webrtc/api/webrtcsessiondescriptionfactory.h b/webrtc/pc/webrtcsessiondescriptionfactory.h
similarity index 97%
rename from webrtc/api/webrtcsessiondescriptionfactory.h
rename to webrtc/pc/webrtcsessiondescriptionfactory.h
index 314679d..7572f24 100644
--- a/webrtc/api/webrtcsessiondescriptionfactory.h
+++ b/webrtc/pc/webrtcsessiondescriptionfactory.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
-#define WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
+#ifndef WEBRTC_PC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
+#define WEBRTC_PC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
 
 #include <memory>
 
@@ -166,4 +166,4 @@
 };
 }  // namespace webrtc
 
-#endif  // WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
+#endif  // WEBRTC_PC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
diff --git a/webrtc/sdk/BUILD.gn b/webrtc/sdk/BUILD.gn
index 4ccd530..e610242 100644
--- a/webrtc/sdk/BUILD.gn
+++ b/webrtc/sdk/BUILD.gn
@@ -219,7 +219,7 @@
 
     deps += [
       ":rtc_sdk_common_objc",
-      "../api:libjingle_peerconnection",
+      "../pc:libjingle_peerconnection",
     ]
 
     if (rtc_build_libyuv) {
diff --git a/webrtc/sdk/android/BUILD.gn b/webrtc/sdk/android/BUILD.gn
index 2adcdb5..1df43e2 100644
--- a/webrtc/sdk/android/BUILD.gn
+++ b/webrtc/sdk/android/BUILD.gn
@@ -67,7 +67,7 @@
   }
 
   deps = [
-    "//webrtc/api:libjingle_peerconnection",
+    "//webrtc/pc:libjingle_peerconnection",
   ]
 
   if (rtc_build_libyuv) {
@@ -89,7 +89,7 @@
   configs += [ ":libjingle_peerconnection_jni_warnings_config" ]
 
   deps = [
-    "//webrtc/api:libjingle_peerconnection",
+    "//webrtc/pc:libjingle_peerconnection",
     "//webrtc/system_wrappers:field_trial_default",
     "//webrtc/system_wrappers:metrics_default",
   ]
@@ -105,7 +105,7 @@
   deps = [
     ":libjingle_peerconnection_jni",
     ":libjingle_peerconnection_metrics_default_jni",
-    "//webrtc/api:libjingle_peerconnection",
+    "//webrtc/pc:libjingle_peerconnection",
   ]
   output_extension = "so"
 }
diff --git a/webrtc/sdk/android/src/jni/DEPS b/webrtc/sdk/android/src/jni/DEPS
index e803553..95eff5e 100644
--- a/webrtc/sdk/android/src/jni/DEPS
+++ b/webrtc/sdk/android/src/jni/DEPS
@@ -1,5 +1,6 @@
 include_rules = [
   "+third_party/libyuv",
   "+webrtc/common_video/libyuv/include/webrtc_libyuv.h",
+  "+webrtc/pc",
   "+webrtc/voice_engine/include/voe_base.h",
 ]
\ No newline at end of file
diff --git a/webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc b/webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc
index 0b2cdccb..dd6bd1e 100644
--- a/webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc
+++ b/webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc
@@ -8,9 +8,9 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "webrtc/api/videosourceproxy.h"
 #include "webrtc/sdk/android/src/jni/androidvideotracksource.h"
 #include "webrtc/sdk/android/src/jni/classreferenceholder.h"
-#include "webrtc/api/videosourceproxy.h"
 
 // Identifiers are over 80 characters long so this is needed to fit them on one
 // line.
diff --git a/webrtc/sdk/android/src/jni/peerconnection_jni.cc b/webrtc/sdk/android/src/jni/peerconnection_jni.cc
index 8c38a46..212fa43 100644
--- a/webrtc/sdk/android/src/jni/peerconnection_jni.cc
+++ b/webrtc/sdk/android/src/jni/peerconnection_jni.cc
@@ -45,19 +45,11 @@
 
 #include "third_party/libyuv/include/libyuv/convert_from.h"
 #include "third_party/libyuv/include/libyuv/scale.h"
-#include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h"
-#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h"
-#include "webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.h"
-#include "webrtc/sdk/android/src/jni/androidvideotracksource.h"
-#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
-#include "webrtc/sdk/android/src/jni/jni_helpers.h"
-#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
 #include "webrtc/api/mediaconstraintsinterface.h"
 #include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/api/rtpreceiverinterface.h"
 #include "webrtc/api/rtpsenderinterface.h"
 #include "webrtc/api/videosourceproxy.h"
-#include "webrtc/api/webrtcsdp.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/event_tracer.h"
@@ -72,6 +64,14 @@
 #include "webrtc/media/engine/webrtcvideodecoderfactory.h"
 #include "webrtc/media/engine/webrtcvideoencoderfactory.h"
 #include "webrtc/system_wrappers/include/field_trial.h"
+#include "webrtc/pc/webrtcsdp.h"
+#include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h"
+#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h"
+#include "webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.h"
+#include "webrtc/sdk/android/src/jni/androidvideotracksource.h"
+#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
+#include "webrtc/sdk/android/src/jni/jni_helpers.h"
+#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
 #include "webrtc/system_wrappers/include/field_trial_default.h"
 #include "webrtc/system_wrappers/include/logcat_trace_context.h"
 #include "webrtc/system_wrappers/include/trace.h"
diff --git a/webrtc/sdk/objc/DEPS b/webrtc/sdk/objc/DEPS
index 137f67a..46aeb8e 100644
--- a/webrtc/sdk/objc/DEPS
+++ b/webrtc/sdk/objc/DEPS
@@ -1,9 +1,10 @@
 include_rules = [
   "+WebRTC",
   "+webrtc/api",
-  "+webrtc/common_video/include",
   "+webrtc/common_video/h264",
+  "+webrtc/common_video/include",
   "+webrtc/media",
   "+webrtc/modules/video_coding",
+  "+webrtc/pc",
   "+webrtc/system_wrappers",
 ]
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory+Private.h b/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory+Private.h
index a7e453c..ed18077 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory+Private.h
+++ b/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory+Private.h
@@ -10,7 +10,7 @@
 
 #import "WebRTC/RTCPeerConnectionFactory.h"
 
-#include "webrtc/api/peerconnectionfactory.h"
+#include "webrtc/api/peerconnectioninterface.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 
 NS_ASSUME_NONNULL_BEGIN
diff --git a/webrtc/test/fuzzers/BUILD.gn b/webrtc/test/fuzzers/BUILD.gn
index 224b212..1cb12d5 100644
--- a/webrtc/test/fuzzers/BUILD.gn
+++ b/webrtc/test/fuzzers/BUILD.gn
@@ -266,7 +266,7 @@
     "sdp_parser_fuzzer.cc",
   ]
   deps = [
-    "../../api:libjingle_peerconnection",
+    "../../pc:libjingle_peerconnection",
   ]
   seed_corpus = "corpora/sdp-corpus"
 }