Merge from Chromium at DEPS revision db3f05efe0f9

This commit was generated by merge_to_master.py.

Change-Id: Ied615f07e5617f89603f29f94846edd58c32a3a9
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index a7b4851..9e7b5da 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -23,9 +23,6 @@
 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-# List of files that should not be committed to
-DO_NOT_SUBMIT_FILES = ["talk/media/webrtc/webrtcvideoengine.cc"]
-
 def _LicenseHeader(input_api):
   """Returns the license header regexp."""
   # Accept any year number from start of project to the current year
@@ -79,26 +76,11 @@
   }
   return license_header
 
-def _ProtectedFiles(input_api, output_api):
-  results = []
-  changed_files = []
-  for f in input_api.AffectedFiles():
-    changed_files.append(f.LocalPath())
-  bad_files = list(set(DO_NOT_SUBMIT_FILES) & set(changed_files))
-  if bad_files:
-    error_type = output_api.PresubmitError
-    results.append(error_type(
-        'The following affected files are only allowed to be updated when '
-        'importing libjingle',
-        bad_files))
-  return results
-
 def _CommonChecks(input_api, output_api):
   """Checks common to both upload and commit."""
   results = []
   results.extend(input_api.canned_checks.CheckLicense(
       input_api, output_api, _LicenseHeader(input_api)))
-  results.extend(_ProtectedFiles(input_api, output_api))
   return results
 
 def CheckChangeOnUpload(input_api, output_api):
diff --git a/app/webrtc/fakeportallocatorfactory.h b/app/webrtc/fakeportallocatorfactory.h
index eee98b0..bfdc56b 100644
--- a/app/webrtc/fakeportallocatorfactory.h
+++ b/app/webrtc/fakeportallocatorfactory.h
@@ -32,7 +32,7 @@
 #define TALK_APP_WEBRTC_FAKEPORTALLOCATORFACTORY_H_
 
 #include "talk/app/webrtc/peerconnectioninterface.h"
-#include "talk/p2p/client/fakeportallocator.h"
+#include "webrtc/p2p/client/fakeportallocator.h"
 
 namespace webrtc {
 
diff --git a/app/webrtc/java/android/org/webrtc/VideoRendererGui.java b/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
index e0542ed..dd1692c 100644
--- a/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
+++ b/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
@@ -80,6 +80,11 @@
   //    aspect ratio is changed if necessary.
   public static enum ScalingType
       { SCALE_ASPECT_FIT, SCALE_ASPECT_FILL, SCALE_FILL };
+  private static final int EGL14_SDK_VERSION =
+      android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
+  // Current SDK version.
+  private static final int CURRENT_SDK_VERSION =
+      android.os.Build.VERSION.SDK_INT;
 
   private final String VERTEX_SHADER_STRING =
       "varying vec2 interp_tc;\n" +
@@ -248,6 +253,8 @@
     private FloatBuffer textureCoords;
     // Flag if texture vertices or coordinates update is needed.
     private boolean updateTextureProperties;
+    // Texture properties update lock.
+    private final Object updateTextureLock = new Object();
     // Viewport dimensions.
     private int screenWidth;
     private int screenHeight;
@@ -314,36 +321,49 @@
           scalingType == ScalingType.SCALE_FILL) {
         return;
       }
-      // Re - calculate texture vertices to preserve video aspect ratio.
-      float texRight = this.texRight;
-      float texLeft = this.texLeft;
-      float texTop = this.texTop;
-      float texBottom = this.texBottom;
-      float displayWidth = (texRight - texLeft) * screenWidth / 2;
-      float displayHeight = (texTop - texBottom) * screenHeight / 2;
-      Log.d(TAG, "ID: "  + id + ". Display: " + displayWidth +
-          " x " + displayHeight + ". Video: " + videoWidth +
-          " x " + videoHeight);
-      if (displayWidth > 1 && displayHeight > 1 &&
-          videoWidth > 1 && videoHeight > 1) {
-        float displayAspectRatio = displayWidth / displayHeight;
-        float videoAspectRatio = (float)videoWidth / videoHeight;
-        if (scalingType == ScalingType.SCALE_ASPECT_FIT) {
-          // Need to re-adjust vertices width or height to match video AR.
-          if (displayAspectRatio > videoAspectRatio) {
-            float deltaX = (displayWidth - videoAspectRatio * displayHeight) /
-                    instance.screenWidth;
-            texRight -= deltaX;
-            texLeft += deltaX;
-          } else {
-            float deltaY = (displayHeight - displayWidth / videoAspectRatio) /
-                    instance.screenHeight;
-            texTop -= deltaY;
-            texBottom += deltaY;
+      synchronized(updateTextureLock) {
+        // Re - calculate texture vertices to preserve video aspect ratio.
+        float texRight = this.texRight;
+        float texLeft = this.texLeft;
+        float texTop = this.texTop;
+        float texBottom = this.texBottom;
+        float texOffsetU = 0;
+        float texOffsetV = 0;
+        float displayWidth = (texRight - texLeft) * screenWidth / 2;
+        float displayHeight = (texTop - texBottom) * screenHeight / 2;
+        Log.d(TAG, "ID: "  + id + ". Display: " + displayWidth +
+            " x " + displayHeight + ". Video: " + videoWidth +
+            " x " + videoHeight);
+        if (displayWidth > 1 && displayHeight > 1 &&
+            videoWidth > 1 && videoHeight > 1) {
+          float displayAspectRatio = displayWidth / displayHeight;
+          float videoAspectRatio = (float)videoWidth / videoHeight;
+          if (scalingType == ScalingType.SCALE_ASPECT_FIT) {
+            // Need to re-adjust vertices width or height to match video AR.
+            if (displayAspectRatio > videoAspectRatio) {
+              float deltaX = (displayWidth - videoAspectRatio * displayHeight) /
+                      instance.screenWidth;
+              texRight -= deltaX;
+              texLeft += deltaX;
+            } else {
+              float deltaY = (displayHeight - displayWidth / videoAspectRatio) /
+                      instance.screenHeight;
+              texTop -= deltaY;
+              texBottom += deltaY;
+            }
+          }
+          if (scalingType == ScalingType.SCALE_ASPECT_FILL) {
+            // Need to re-adjust UV coordinates to match display AR.
+            if (displayAspectRatio > videoAspectRatio) {
+              texOffsetV = (1.0f - videoAspectRatio / displayAspectRatio) /
+                  2.0f;
+            } else {
+              texOffsetU = (1.0f - displayAspectRatio / videoAspectRatio) /
+                  2.0f;
+            }
           }
           Log.d(TAG, "  Texture vertices: (" + texLeft + "," + texBottom +
               ") - (" + texRight + "," + texTop + ")");
-          // Re-allocate vertices buffer to adjust to video aspect ratio.
           float textureVeticesFloat[] = new float[] {
               texLeft, texTop,
               texLeft, texBottom,
@@ -351,18 +371,8 @@
               texRight, texBottom
           };
           textureVertices = directNativeFloatBuffer(textureVeticesFloat);
-        }
-        if (scalingType == ScalingType.SCALE_ASPECT_FILL) {
-          float texOffsetU = 0;
-          float texOffsetV = 0;
-          // Need to re-adjust UV coordinates to match display AR.
-          if (displayAspectRatio > videoAspectRatio) {
-            texOffsetV = (1.0f - videoAspectRatio / displayAspectRatio) / 2.0f;
-          } else {
-            texOffsetU = (1.0f - displayAspectRatio / videoAspectRatio) / 2.0f;
-          }
+
           Log.d(TAG, "  Texture UV offsets: " + texOffsetU + ", " + texOffsetV);
-          // Re-allocate coordinates buffer to adjust to display aspect ratio.
           float textureCoordinatesFloat[] = new float[] {
               texOffsetU, texOffsetV,               // left top
               texOffsetU, 1.0f - texOffsetV,        // left bottom
@@ -371,8 +381,8 @@
           };
           textureCoords = directNativeFloatBuffer(textureCoordinatesFloat);
         }
+        updateTextureProperties = false;
       }
-      updateTextureProperties = false;
     }
 
     private void draw() {
@@ -485,18 +495,23 @@
     }
 
     public void setScreenSize(final int screenWidth, final int screenHeight) {
-      this.screenWidth = screenWidth;
-      this.screenHeight = screenHeight;
-      updateTextureProperties = true;
+      synchronized(updateTextureLock) {
+        this.screenWidth = screenWidth;
+        this.screenHeight = screenHeight;
+        updateTextureProperties = true;
+      }
     }
 
     public void setPosition(int x, int y, int width, int height,
         ScalingType scalingType) {
-      texLeft = (x - 50) / 50.0f;
-      texTop = (50 - y) / 50.0f;
-      texRight = Math.min(1.0f, (x + width - 50) / 50.0f);
-      texBottom = Math.max(-1.0f, (50 - y - height) / 50.0f);
-      updateTextureProperties = true;
+      synchronized(updateTextureLock) {
+        texLeft = (x - 50) / 50.0f;
+        texTop = (50 - y) / 50.0f;
+        texRight = Math.min(1.0f, (x + width - 50) / 50.0f);
+        texBottom = Math.max(-1.0f, (50 - y - height) / 50.0f);
+        this.scalingType = scalingType;
+        updateTextureProperties = true;
+      }
     }
 
     @Override
@@ -666,8 +681,10 @@
   public void onSurfaceCreated(GL10 unused, EGLConfig config) {
     Log.d(TAG, "VideoRendererGui.onSurfaceCreated");
     // Store render EGL context
-    eglContext = EGL14.eglGetCurrentContext();
-    Log.d(TAG, "VideoRendererGui EGL Context: " + eglContext);
+    if (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION) {
+      eglContext = EGL14.eglGetCurrentContext();
+      Log.d(TAG, "VideoRendererGui EGL Context: " + eglContext);
+    }
 
     // Create YUV and OES programs.
     yuvProgram = createProgram(VERTEX_SHADER_STRING,
@@ -683,7 +700,7 @@
       onSurfaceCreatedCalled = true;
     }
     checkNoGLES2Error();
-    GLES20.glClearColor(0.0f, 0.0f, 0.1f, 1.0f);
+    GLES20.glClearColor(0.15f, 0.15f, 0.15f, 1.0f);
   }
 
   @Override
diff --git a/app/webrtc/java/jni/peerconnection_jni.cc b/app/webrtc/java/jni/peerconnection_jni.cc
index d2b1639..fb36cf8 100644
--- a/app/webrtc/java/jni/peerconnection_jni.cc
+++ b/app/webrtc/java/jni/peerconnection_jni.cc
@@ -273,11 +273,19 @@
     LoadClass(jni, "org/webrtc/IceCandidate");
 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
     LoadClass(jni, "android/graphics/SurfaceTexture");
-    LoadClass(jni, "android/opengl/EGLContext");
     LoadClass(jni, "org/webrtc/MediaCodecVideoEncoder");
     LoadClass(jni, "org/webrtc/MediaCodecVideoEncoder$OutputBufferInfo");
     LoadClass(jni, "org/webrtc/MediaCodecVideoDecoder");
     LoadClass(jni, "org/webrtc/MediaCodecVideoDecoder$DecoderOutputBufferInfo");
+    jclass j_decoder_class = GetClass("org/webrtc/MediaCodecVideoDecoder");
+    jmethodID j_is_egl14_supported_method = jni->GetStaticMethodID(
+        j_decoder_class, "isEGL14Supported", "()Z");
+    bool is_egl14_supported = jni->CallStaticBooleanMethod(
+        j_decoder_class, j_is_egl14_supported_method);
+    CHECK_EXCEPTION(jni);
+    if (is_egl14_supported) {
+      LoadClass(jni, "android/opengl/EGLContext");
+    }
 #endif
     LoadClass(jni, "org/webrtc/MediaSource$State");
     LoadClass(jni, "org/webrtc/MediaStream");
@@ -578,13 +586,6 @@
     CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
   }
 
-  virtual void OnError() OVERRIDE {
-    ScopedLocalRefFrame local_ref_frame(jni());
-    jmethodID m = GetMethodID(jni(), *j_observer_class_, "onError", "()V");
-    jni()->CallVoidMethod(*j_observer_global_, m);
-    CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
-  }
-
   virtual void OnSignalingChange(
       PeerConnectionInterface::SignalingState new_state) OVERRIDE {
     ScopedLocalRefFrame local_ref_frame(jni());
@@ -3136,12 +3137,9 @@
 }
 
 JOW(jboolean, PeerConnection_nativeAddLocalStream)(
-    JNIEnv* jni, jobject j_pc, jlong native_stream, jobject j_constraints) {
-  scoped_ptr<ConstraintsWrapper> constraints(
-      new ConstraintsWrapper(jni, j_constraints));
+    JNIEnv* jni, jobject j_pc, jlong native_stream) {
   return ExtractNativePC(jni, j_pc)->AddStream(
-      reinterpret_cast<MediaStreamInterface*>(native_stream),
-      constraints.get());
+      reinterpret_cast<MediaStreamInterface*>(native_stream));
 }
 
 JOW(void, PeerConnection_nativeRemoveLocalStream)(
diff --git a/app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java b/app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java
index 96d8b1b..f93f02a 100644
--- a/app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java
+++ b/app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java
@@ -95,6 +95,10 @@
   private EGLDisplay eglDisplay = EGL14.EGL_NO_DISPLAY;
   private EGLContext eglContext = EGL14.EGL_NO_CONTEXT;
   private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE;
+  private static final int EGL14_SDK_VERSION =
+      android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
+  private static final int CURRENT_SDK_VERSION =
+      android.os.Build.VERSION.SDK_INT;
 
 
   private MediaCodecVideoDecoder() { }
@@ -166,6 +170,11 @@
     return null;  // No HW VP8 decoder.
   }
 
+  private static boolean isEGL14Supported() {
+    Log.d(TAG, "SDK version: " + CURRENT_SDK_VERSION);
+    return (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION);
+  }
+
   private static boolean isPlatformSupported() {
     return findVp8Decoder(false) != null;
   }
diff --git a/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java b/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java
index a2d6168..4c02891 100644
--- a/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java
+++ b/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java
@@ -43,7 +43,7 @@
 // This class is an implementation detail of the Java PeerConnection API.
 // MediaCodec is thread-hostile so this class must be operated on a single
 // thread.
-class MediaCodecVideoEncoder {
+public class MediaCodecVideoEncoder {
   // This class is constructed, operated, and destroyed by its C++ incarnation,
   // so the class and its methods have non-public visibility.  The API this
   // class exposes aims to mimic the webrtc::VideoEncoder API as closely as
@@ -140,7 +140,7 @@
     return null;  // No HW VP8 encoder.
   }
 
-  private static boolean isPlatformSupported() {
+  public static boolean isPlatformSupported() {
     return findVp8HwEncoder() != null;
   }
 
diff --git a/app/webrtc/java/src/org/webrtc/PeerConnection.java b/app/webrtc/java/src/org/webrtc/PeerConnection.java
index c2617de..3aef6ff 100644
--- a/app/webrtc/java/src/org/webrtc/PeerConnection.java
+++ b/app/webrtc/java/src/org/webrtc/PeerConnection.java
@@ -71,9 +71,6 @@
     /** Triggered when a new ICE candidate has been found. */
     public void onIceCandidate(IceCandidate candidate);
 
-    /** Triggered on any error. */
-    public void onError();
-
     /** Triggered when media is received on a new stream from remote peer. */
     public void onAddStream(MediaStream stream);
 
@@ -147,9 +144,8 @@
         candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp);
   }
 
-  public boolean addStream(
-      MediaStream stream, MediaConstraints constraints) {
-    boolean ret = nativeAddLocalStream(stream.nativeStream, constraints);
+  public boolean addStream(MediaStream stream) {
+    boolean ret = nativeAddLocalStream(stream.nativeStream);
     if (!ret) {
       return false;
     }
@@ -194,8 +190,7 @@
   private native boolean nativeAddIceCandidate(
       String sdpMid, int sdpMLineIndex, String iceCandidateSdp);
 
-  private native boolean nativeAddLocalStream(
-      long nativeStream, MediaConstraints constraints);
+  private native boolean nativeAddLocalStream(long nativeStream);
 
   private native void nativeRemoveLocalStream(long nativeStream);
 
diff --git a/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java b/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java
index 240e996..048d92b 100644
--- a/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java
+++ b/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java
@@ -117,11 +117,6 @@
       ++expectedErrors;
     }
 
-    @Override
-    public synchronized void onError() {
-      assertTrue(--expectedErrors >= 0);
-    }
-
     public synchronized void expectSetSize() {
       if (RENDER_TO_GUI) {
         // When new frames are delivered to the GUI renderer we don't get
@@ -489,7 +484,7 @@
     lMS.addTrack(videoTrack);
     lMS.addTrack(factory.createAudioTrack(
         audioTrackId, factory.createAudioSource(new MediaConstraints())));
-    pc.addStream(lMS, new MediaConstraints());
+    pc.addStream(lMS);
     return new WeakReference<MediaStream>(lMS);
   }
 
diff --git a/app/webrtc/jsepicecandidate.h b/app/webrtc/jsepicecandidate.h
index 7be420c..71ed2c3 100644
--- a/app/webrtc/jsepicecandidate.h
+++ b/app/webrtc/jsepicecandidate.h
@@ -33,7 +33,7 @@
 #include <string>
 
 #include "talk/app/webrtc/jsep.h"
-#include "talk/p2p/base/candidate.h"
+#include "webrtc/p2p/base/candidate.h"
 #include "webrtc/base/constructormagic.h"
 
 namespace webrtc {
diff --git a/app/webrtc/jsepsessiondescription_unittest.cc b/app/webrtc/jsepsessiondescription_unittest.cc
index 769e34a..cf992c0 100644
--- a/app/webrtc/jsepsessiondescription_unittest.cc
+++ b/app/webrtc/jsepsessiondescription_unittest.cc
@@ -29,9 +29,9 @@
 
 #include "talk/app/webrtc/jsepicecandidate.h"
 #include "talk/app/webrtc/jsepsessiondescription.h"
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 #include "talk/session/media/mediasession.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
diff --git a/app/webrtc/mediastreamsignaling_unittest.cc b/app/webrtc/mediastreamsignaling_unittest.cc
index 038c67d..d7b9734 100644
--- a/app/webrtc/mediastreamsignaling_unittest.cc
+++ b/app/webrtc/mediastreamsignaling_unittest.cc
@@ -38,8 +38,8 @@
 #include "talk/app/webrtc/videotrack.h"
 #include "talk/media/base/fakemediaengine.h"
 #include "talk/media/devices/fakedevicemanager.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 #include "talk/session/media/channelmanager.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/scoped_ptr.h"
diff --git a/app/webrtc/objc/RTCPeerConnection.mm b/app/webrtc/objc/RTCPeerConnection.mm
index 72ba373..925de73 100644
--- a/app/webrtc/objc/RTCPeerConnection.mm
+++ b/app/webrtc/objc/RTCPeerConnection.mm
@@ -151,10 +151,8 @@
   return self.peerConnection->AddIceCandidate(iceCandidate.get());
 }
 
-- (BOOL)addStream:(RTCMediaStream*)stream
-      constraints:(RTCMediaConstraints*)constraints {
-  BOOL ret = self.peerConnection->AddStream(stream.mediaStream,
-                                            constraints.constraints);
+- (BOOL)addStream:(RTCMediaStream*)stream {
+  BOOL ret = self.peerConnection->AddStream(stream.mediaStream);
   if (!ret) {
     return NO;
   }
diff --git a/app/webrtc/objc/RTCPeerConnectionObserver.h b/app/webrtc/objc/RTCPeerConnectionObserver.h
index f66b567..8378ff8 100644
--- a/app/webrtc/objc/RTCPeerConnectionObserver.h
+++ b/app/webrtc/objc/RTCPeerConnectionObserver.h
@@ -41,8 +41,6 @@
   RTCPeerConnectionObserver(RTCPeerConnection* peerConnection);
   virtual ~RTCPeerConnectionObserver();
 
-  virtual void OnError() OVERRIDE;
-
   // Triggered when the SignalingState changed.
   virtual void OnSignalingChange(
       PeerConnectionInterface::SignalingState new_state) OVERRIDE;
diff --git a/app/webrtc/objc/RTCPeerConnectionObserver.mm b/app/webrtc/objc/RTCPeerConnectionObserver.mm
index a0206e5..f4cab7f 100644
--- a/app/webrtc/objc/RTCPeerConnectionObserver.mm
+++ b/app/webrtc/objc/RTCPeerConnectionObserver.mm
@@ -46,10 +46,6 @@
 RTCPeerConnectionObserver::~RTCPeerConnectionObserver() {
 }
 
-void RTCPeerConnectionObserver::OnError() {
-  [_peerConnection.delegate peerConnectionOnError:_peerConnection];
-}
-
 void RTCPeerConnectionObserver::OnSignalingChange(
     PeerConnectionInterface::SignalingState new_state) {
   RTCSignalingState state =
diff --git a/app/webrtc/objc/public/RTCPeerConnection.h b/app/webrtc/objc/public/RTCPeerConnection.h
index 32a9830..6d47f77 100644
--- a/app/webrtc/objc/public/RTCPeerConnection.h
+++ b/app/webrtc/objc/public/RTCPeerConnection.h
@@ -64,8 +64,7 @@
 // Add a new MediaStream to be sent on this PeerConnection.
 // Note that a SessionDescription negotiation is needed before the
 // remote peer can receive the stream.
-- (BOOL)addStream:(RTCMediaStream *)stream
-      constraints:(RTCMediaConstraints *)constraints;
+- (BOOL)addStream:(RTCMediaStream *)stream;
 
 // Remove a MediaStream from this PeerConnection.
 // Note that a SessionDescription negotiation is need before the
diff --git a/app/webrtc/objc/public/RTCPeerConnectionDelegate.h b/app/webrtc/objc/public/RTCPeerConnectionDelegate.h
index 4b177d5..ee6ec7a 100644
--- a/app/webrtc/objc/public/RTCPeerConnectionDelegate.h
+++ b/app/webrtc/objc/public/RTCPeerConnectionDelegate.h
@@ -38,9 +38,6 @@
 // implemented to get messages from PeerConnection.
 @protocol RTCPeerConnectionDelegate<NSObject>
 
-// Triggered when there is an error.
-- (void)peerConnectionOnError:(RTCPeerConnection *)peerConnection;
-
 // Triggered when the SignalingState changed.
 - (void)peerConnection:(RTCPeerConnection *)peerConnection
  signalingStateChanged:(RTCSignalingState)stateChanged;
diff --git a/app/webrtc/objctests/RTCPeerConnectionSyncObserver.m b/app/webrtc/objctests/RTCPeerConnectionSyncObserver.m
index c3f898a..fbcf217 100644
--- a/app/webrtc/objctests/RTCPeerConnectionSyncObserver.m
+++ b/app/webrtc/objctests/RTCPeerConnectionSyncObserver.m
@@ -151,11 +151,6 @@
 
 #pragma mark - RTCPeerConnectionDelegate methods
 
-- (void)peerConnectionOnError:(RTCPeerConnection*)peerConnection {
-  NSLog(@"RTCPeerConnectionDelegate::onError");
-  NSAssert(--_expectedErrors >= 0, @"Unexpected error");
-}
-
 - (void)peerConnection:(RTCPeerConnection*)peerConnection
     signalingStateChanged:(RTCSignalingState)stateChanged {
   int expectedState = [self popFirstElementAsInt:_expectedSignalingChanges];
diff --git a/app/webrtc/objctests/RTCPeerConnectionTest.mm b/app/webrtc/objctests/RTCPeerConnectionTest.mm
index 909503a..6c5950b 100644
--- a/app/webrtc/objctests/RTCPeerConnectionTest.mm
+++ b/app/webrtc/objctests/RTCPeerConnectionTest.mm
@@ -89,8 +89,7 @@
   [localMediaStream addVideoTrack:videoTrack];
   RTCAudioTrack* audioTrack = [factory audioTrackWithID:audioTrackID];
   [localMediaStream addAudioTrack:audioTrack];
-  RTCMediaConstraints* constraints = [[RTCMediaConstraints alloc] init];
-  [pc addStream:localMediaStream constraints:constraints];
+  [pc addStream:localMediaStream];
   return localMediaStream;
 }
 
diff --git a/app/webrtc/peerconnection.cc b/app/webrtc/peerconnection.cc
index d939f98..b64caf7 100644
--- a/app/webrtc/peerconnection.cc
+++ b/app/webrtc/peerconnection.cc
@@ -35,7 +35,7 @@
 #include "talk/app/webrtc/mediaconstraintsinterface.h"
 #include "talk/app/webrtc/mediastreamhandler.h"
 #include "talk/app/webrtc/streamcollection.h"
-#include "talk/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/client/basicportallocator.h"
 #include "talk/session/media/channelmanager.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/stringencode.h"
@@ -350,9 +350,10 @@
 
   // To handle both internal and externally created port allocator, we will
   // enable BUNDLE here.
-  int portallocator_flags = cricket::PORTALLOCATOR_ENABLE_BUNDLE |
-                            cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
-                            cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET;
+  int portallocator_flags = port_allocator_->flags();
+  portallocator_flags |= cricket::PORTALLOCATOR_ENABLE_BUNDLE |
+                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
+                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET;
   bool value;
   // If IPv6 flag was specified, we'll not override it by experiment.
   if (FindConstraint(
@@ -403,8 +404,7 @@
   return mediastream_signaling_->remote_streams();
 }
 
-bool PeerConnection::AddStream(MediaStreamInterface* local_stream,
-                               const MediaConstraintsInterface* constraints) {
+bool PeerConnection::AddStream(MediaStreamInterface* local_stream) {
   if (IsClosed()) {
     return false;
   }
@@ -412,7 +412,6 @@
                               local_stream))
     return false;
 
-  // TODO(perkj): Implement support for MediaConstraints in AddStream.
   if (!mediastream_signaling_->AddLocalStream(local_stream)) {
     return false;
   }
@@ -421,6 +420,11 @@
   return true;
 }
 
+bool PeerConnection::AddStream(MediaStreamInterface* local_stream,
+                               const MediaConstraintsInterface* constraints) {
+  return AddStream(local_stream);
+}
+
 void PeerConnection::RemoveStream(MediaStreamInterface* local_stream) {
   mediastream_signaling_->RemoveLocalStream(local_stream);
   if (IsClosed()) {
diff --git a/app/webrtc/peerconnection.h b/app/webrtc/peerconnection.h
index fb03802..355211c 100644
--- a/app/webrtc/peerconnection.h
+++ b/app/webrtc/peerconnection.h
@@ -65,6 +65,7 @@
       PeerConnectionObserver* observer);
   virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams();
   virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams();
+  virtual bool AddStream(MediaStreamInterface* local_stream);
   virtual bool AddStream(MediaStreamInterface* local_stream,
                          const MediaConstraintsInterface* constraints);
   virtual void RemoveStream(MediaStreamInterface* local_stream);
diff --git a/app/webrtc/peerconnection_unittest.cc b/app/webrtc/peerconnection_unittest.cc
index da75e9d..c250eea 100644
--- a/app/webrtc/peerconnection_unittest.cc
+++ b/app/webrtc/peerconnection_unittest.cc
@@ -46,8 +46,8 @@
 #include "talk/app/webrtc/test/mockpeerconnectionobservers.h"
 #include "talk/app/webrtc/videosourceinterface.h"
 #include "talk/media/webrtc/fakewebrtcvideoengine.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 #include "talk/session/media/mediasession.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/scoped_ptr.h"
@@ -179,7 +179,7 @@
       stream->AddTrack(CreateLocalVideoTrack(stream_label));
     }
 
-    EXPECT_TRUE(peer_connection_->AddStream(stream, NULL));
+    EXPECT_TRUE(peer_connection_->AddStream(stream));
   }
 
   size_t NumberOfLocalMediaStreams() {
@@ -426,7 +426,6 @@
   }
 
   // PeerConnectionObserver callbacks.
-  virtual void OnError() {}
   virtual void OnMessage(const std::string&) {}
   virtual void OnSignalingMessage(const std::string& /*msg*/) {}
   virtual void OnSignalingChange(
diff --git a/app/webrtc/peerconnectionendtoend_unittest.cc b/app/webrtc/peerconnectionendtoend_unittest.cc
index 4db3fe3..d743182 100644
--- a/app/webrtc/peerconnectionendtoend_unittest.cc
+++ b/app/webrtc/peerconnectionendtoend_unittest.cc
@@ -320,7 +320,14 @@
 
 // Verifies that a DataChannel created after the negotiation can transition to
 // "OPEN" and transfer data.
-TEST_F(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) {
+#if defined(MEMORY_SANITIZER)
+// Fails under MemorySanitizer:
+// See https://code.google.com/p/webrtc/issues/detail?id=3980.
+#define MAYBE_CreateDataChannelAfterNegotiate DISABLED_CreateDataChannelAfterNegotiate
+#else
+#define MAYBE_CreateDataChannelAfterNegotiate CreateDataChannelAfterNegotiate
+#endif
+TEST_F(PeerConnectionEndToEndTest, MAYBE_CreateDataChannelAfterNegotiate) {
   MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
 
   CreatePcs();
diff --git a/app/webrtc/peerconnectionfactory_unittest.cc b/app/webrtc/peerconnectionfactory_unittest.cc
index 5995c46..e687b8b 100644
--- a/app/webrtc/peerconnectionfactory_unittest.cc
+++ b/app/webrtc/peerconnectionfactory_unittest.cc
@@ -40,6 +40,7 @@
 #include "webrtc/base/thread.h"
 
 using webrtc::FakeVideoTrackRenderer;
+using webrtc::DataChannelInterface;
 using webrtc::MediaStreamInterface;
 using webrtc::PeerConnectionFactoryInterface;
 using webrtc::PeerConnectionInterface;
@@ -83,13 +84,13 @@
 
 class NullPeerConnectionObserver : public PeerConnectionObserver {
  public:
-  virtual void OnError() {}
   virtual void OnMessage(const std::string& msg) {}
   virtual void OnSignalingMessage(const std::string& msg) {}
   virtual void OnSignalingChange(
       PeerConnectionInterface::SignalingState new_state) {}
   virtual void OnAddStream(MediaStreamInterface* stream) {}
   virtual void OnRemoveStream(MediaStreamInterface* stream) {}
+  virtual void OnDataChannel(DataChannelInterface* data_channel) {}
   virtual void OnRenegotiationNeeded() {}
   virtual void OnIceConnectionChange(
       PeerConnectionInterface::IceConnectionState new_state) {}
diff --git a/app/webrtc/peerconnectioninterface.h b/app/webrtc/peerconnectioninterface.h
index 6ef4847..68b7879 100644
--- a/app/webrtc/peerconnectioninterface.h
+++ b/app/webrtc/peerconnectioninterface.h
@@ -255,8 +255,15 @@
   // Add a new MediaStream to be sent on this PeerConnection.
   // Note that a SessionDescription negotiation is needed before the
   // remote peer can receive the stream.
+  // TODO(perkj): Make pure virtual once Chrome mocks have implemented.
+  virtual bool AddStream(MediaStreamInterface* stream) { return false;}
+
+  // Deprecated:
+  // TODO(perkj): Remove once its not used by Chrome.
   virtual bool AddStream(MediaStreamInterface* stream,
-                         const MediaConstraintsInterface* constraints) = 0;
+                         const MediaConstraintsInterface* constraints) {
+    return false;
+  }
 
   // Remove a MediaStream from this PeerConnection.
   // Note that a SessionDescription negotiation is need before the
@@ -344,7 +351,9 @@
     kIceState,
   };
 
-  virtual void OnError() = 0;
+  // Deprecated.
+  // TODO(perkj): Remove once its not used by Chrome.
+  virtual void OnError() {}
 
   // Triggered when the SignalingState changed.
   virtual void OnSignalingChange(
@@ -361,8 +370,7 @@
   virtual void OnRemoveStream(MediaStreamInterface* stream) = 0;
 
   // Triggered when a remote peer open a data channel.
-  // TODO(perkj): Make pure virtual.
-  virtual void OnDataChannel(DataChannelInterface* data_channel) {}
+  virtual void OnDataChannel(DataChannelInterface* data_channel) = 0;
 
   // Triggered when renegotiation is needed, for example the ICE has restarted.
   virtual void OnRenegotiationNeeded() = 0;
diff --git a/app/webrtc/peerconnectioninterface_unittest.cc b/app/webrtc/peerconnectioninterface_unittest.cc
index bf60673..3be6280 100644
--- a/app/webrtc/peerconnectioninterface_unittest.cc
+++ b/app/webrtc/peerconnectioninterface_unittest.cc
@@ -132,7 +132,6 @@
       state_ = pc_->signaling_state();
     }
   }
-  virtual void OnError() {}
   virtual void OnSignalingChange(
       PeerConnectionInterface::SignalingState new_state) {
     EXPECT_EQ(pc_->signaling_state(), new_state);
@@ -320,7 +319,7 @@
     scoped_refptr<VideoTrackInterface> video_track(
         pc_factory_->CreateVideoTrack(label + "v0", video_source));
     stream->AddTrack(video_track.get());
-    EXPECT_TRUE(pc_->AddStream(stream, NULL));
+    EXPECT_TRUE(pc_->AddStream(stream));
     EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
     observer_.renegotiation_needed_ = false;
   }
@@ -332,7 +331,7 @@
     scoped_refptr<AudioTrackInterface> audio_track(
         pc_factory_->CreateAudioTrack(label + "a0", NULL));
     stream->AddTrack(audio_track.get());
-    EXPECT_TRUE(pc_->AddStream(stream, NULL));
+    EXPECT_TRUE(pc_->AddStream(stream));
     EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
     observer_.renegotiation_needed_ = false;
   }
@@ -350,7 +349,7 @@
     scoped_refptr<VideoTrackInterface> video_track(
         pc_factory_->CreateVideoTrack(video_track_label, NULL));
     stream->AddTrack(video_track.get());
-    EXPECT_TRUE(pc_->AddStream(stream, NULL));
+    EXPECT_TRUE(pc_->AddStream(stream));
     EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
     observer_.renegotiation_needed_ = false;
   }
@@ -574,7 +573,7 @@
       pc_factory_->CreateAudioTrack(
           kStreamLabel3, static_cast<AudioSourceInterface*>(NULL)));
   stream->AddTrack(audio_track.get());
-  EXPECT_TRUE(pc_->AddStream(stream, NULL));
+  EXPECT_TRUE(pc_->AddStream(stream));
   EXPECT_EQ(3u, pc_->local_streams()->count());
 
   // Remove the third stream.
@@ -1180,7 +1179,7 @@
   pc_->Close();
 
   pc_->RemoveStream(local_stream);
-  EXPECT_FALSE(pc_->AddStream(local_stream, NULL));
+  EXPECT_FALSE(pc_->AddStream(local_stream));
 
   ASSERT_FALSE(local_stream->GetAudioTracks().empty());
   rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender(
diff --git a/app/webrtc/peerconnectionproxy.h b/app/webrtc/peerconnectionproxy.h
index ed26eb8..571c676 100644
--- a/app/webrtc/peerconnectionproxy.h
+++ b/app/webrtc/peerconnectionproxy.h
@@ -39,8 +39,9 @@
                 local_streams)
   PROXY_METHOD0(rtc::scoped_refptr<StreamCollectionInterface>,
                 remote_streams)
+  PROXY_METHOD1(bool, AddStream, MediaStreamInterface*)
   PROXY_METHOD2(bool, AddStream, MediaStreamInterface*,
-                const MediaConstraintsInterface*)
+                const MediaConstraintsInterface*);
   PROXY_METHOD1(void, RemoveStream, MediaStreamInterface*)
   PROXY_METHOD1(rtc::scoped_refptr<DtmfSenderInterface>,
                 CreateDtmfSender, AudioTrackInterface*)
diff --git a/app/webrtc/portallocatorfactory.cc b/app/webrtc/portallocatorfactory.cc
index 946f8ad..da4c706 100644
--- a/app/webrtc/portallocatorfactory.cc
+++ b/app/webrtc/portallocatorfactory.cc
@@ -27,8 +27,8 @@
 
 #include "talk/app/webrtc/portallocatorfactory.h"
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/client/basicportallocator.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/network.h"
 #include "webrtc/base/thread.h"
diff --git a/app/webrtc/proxy.h b/app/webrtc/proxy.h
index 0c21ef9..134f580 100644
--- a/app/webrtc/proxy.h
+++ b/app/webrtc/proxy.h
@@ -55,6 +55,7 @@
 #ifndef TALK_APP_WEBRTC_PROXY_H_
 #define TALK_APP_WEBRTC_PROXY_H_
 
+#include "webrtc/base/event.h"
 #include "webrtc/base/thread.h"
 
 namespace webrtc {
@@ -92,6 +93,34 @@
   void value() {}
 };
 
+namespace internal {
+
+class SynchronousMethodCall
+    : public rtc::MessageData,
+      public rtc::MessageHandler {
+ public:
+  SynchronousMethodCall(rtc::MessageHandler* proxy)
+      : e_(), proxy_(proxy) {}
+  ~SynchronousMethodCall() {}
+
+  void Invoke(rtc::Thread* t) {
+    if (t->IsCurrent()) {
+      proxy_->OnMessage(NULL);
+    } else {
+      e_.reset(new rtc::Event(false, false));
+      t->Post(this, 0);
+      e_->Wait(rtc::kForever);
+    }
+  }
+
+ private:
+  void OnMessage(rtc::Message*) { proxy_->OnMessage(NULL); e_->Set(); }
+  rtc::scoped_ptr<rtc::Event> e_;
+  rtc::MessageHandler* proxy_;
+};
+
+}  // internal
+
 template <typename C, typename R>
 class MethodCall0 : public rtc::Message,
                     public rtc::MessageHandler {
@@ -100,12 +129,12 @@
   MethodCall0(C* c, Method m) : c_(c), m_(m) {}
 
   R Marshal(rtc::Thread* t) {
-    t->Send(this, 0);
+    internal::SynchronousMethodCall(this).Invoke(t);
     return r_.value();
   }
 
  private:
-  void OnMessage(rtc::Message*) {  r_.Invoke(c_, m_);}
+  void OnMessage(rtc::Message*) {  r_.Invoke(c_, m_); }
 
   C* c_;
   Method m_;
@@ -120,7 +149,7 @@
   ConstMethodCall0(C* c, Method m) : c_(c), m_(m) {}
 
   R Marshal(rtc::Thread* t) {
-    t->Send(this, 0);
+    internal::SynchronousMethodCall(this).Invoke(t);
     return r_.value();
   }
 
@@ -140,7 +169,7 @@
   MethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {}
 
   R Marshal(rtc::Thread* t) {
-    t->Send(this, 0);
+    internal::SynchronousMethodCall(this).Invoke(t);
     return r_.value();
   }
 
@@ -161,7 +190,7 @@
   ConstMethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {}
 
   R Marshal(rtc::Thread* t) {
-    t->Send(this, 0);
+    internal::SynchronousMethodCall(this).Invoke(t);
     return r_.value();
   }
 
@@ -182,7 +211,7 @@
   MethodCall2(C* c, Method m, T1 a1, T2 a2) : c_(c), m_(m), a1_(a1), a2_(a2) {}
 
   R Marshal(rtc::Thread* t) {
-    t->Send(this, 0);
+    internal::SynchronousMethodCall(this).Invoke(t);
     return r_.value();
   }
 
@@ -205,7 +234,7 @@
       : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3) {}
 
   R Marshal(rtc::Thread* t) {
-    t->Send(this, 0);
+    internal::SynchronousMethodCall(this).Invoke(t);
     return r_.value();
   }
 
diff --git a/app/webrtc/statscollector.cc b/app/webrtc/statscollector.cc
index 5271827..fefb0ad 100644
--- a/app/webrtc/statscollector.cc
+++ b/app/webrtc/statscollector.cc
@@ -89,8 +89,6 @@
 const char StatsReport::kStatsValueNameEchoReturnLossEnhancement[] =
     "googEchoCancellationReturnLossEnhancement";
 
-const char StatsReport::kStatsValueNameEncodeRelStdDev[] =
-    "googEncodeRelStdDev";
 const char StatsReport::kStatsValueNameEncodeUsagePercent[] =
     "googEncodeUsagePercent";
 const char StatsReport::kStatsValueNameExpandRate[] = "googExpandRate";
@@ -459,8 +457,6 @@
                    info.capture_queue_delay_ms_per_s);
   report->AddValue(StatsReport::kStatsValueNameEncodeUsagePercent,
                    info.encode_usage_percent);
-  report->AddValue(StatsReport::kStatsValueNameEncodeRelStdDev,
-                   info.encode_rsd);
 }
 
 void ExtractStats(const cricket::BandwidthEstimationInfo& info,
diff --git a/app/webrtc/statscollector_unittest.cc b/app/webrtc/statscollector_unittest.cc
index 2e55af9..c573a88 100644
--- a/app/webrtc/statscollector_unittest.cc
+++ b/app/webrtc/statscollector_unittest.cc
@@ -35,7 +35,7 @@
 #include "talk/app/webrtc/videotrack.h"
 #include "talk/media/base/fakemediaengine.h"
 #include "talk/media/devices/fakedevicemanager.h"
-#include "talk/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/fakesession.h"
 #include "talk/session/media/channelmanager.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
diff --git a/app/webrtc/statstypes.h b/app/webrtc/statstypes.h
index 656b83c..8a1530a 100644
--- a/app/webrtc/statstypes.h
+++ b/app/webrtc/statstypes.h
@@ -199,7 +199,6 @@
 
   // Internal StatsValue names
   static const char kStatsValueNameAvgEncodeMs[];
-  static const char kStatsValueNameEncodeRelStdDev[];
   static const char kStatsValueNameEncodeUsagePercent[];
   static const char kStatsValueNameCaptureJitterMs[];
   static const char kStatsValueNameCaptureQueueDelayMsPerS[];
diff --git a/app/webrtc/test/peerconnectiontestwrapper.cc b/app/webrtc/test/peerconnectiontestwrapper.cc
index 24932b8..e3b8015 100644
--- a/app/webrtc/test/peerconnectiontestwrapper.cc
+++ b/app/webrtc/test/peerconnectiontestwrapper.cc
@@ -253,7 +253,7 @@
     bool video, const webrtc::FakeConstraints& video_constraints) {
   rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
       GetUserMedia(audio, audio_constraints, video, video_constraints);
-  EXPECT_TRUE(peer_connection_->AddStream(stream, NULL));
+  EXPECT_TRUE(peer_connection_->AddStream(stream));
 }
 
 rtc::scoped_refptr<webrtc::MediaStreamInterface>
diff --git a/app/webrtc/test/peerconnectiontestwrapper.h b/app/webrtc/test/peerconnectiontestwrapper.h
index d4a0e4e..d8299ec 100644
--- a/app/webrtc/test/peerconnectiontestwrapper.h
+++ b/app/webrtc/test/peerconnectiontestwrapper.h
@@ -57,7 +57,6 @@
       const webrtc::DataChannelInit& init);
 
   // Implements PeerConnectionObserver.
-  virtual void OnError() {}
   virtual void OnSignalingChange(
      webrtc::PeerConnectionInterface::SignalingState new_state) {}
   virtual void OnStateChange(
diff --git a/app/webrtc/webrtcsdp.cc b/app/webrtc/webrtcsdp.cc
index 5887409..23b8f3d 100644
--- a/app/webrtc/webrtcsdp.cc
+++ b/app/webrtc/webrtcsdp.cc
@@ -39,9 +39,9 @@
 #include "talk/media/base/constants.h"
 #include "talk/media/base/cryptoparams.h"
 #include "talk/media/sctp/sctpdataengine.h"
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/port.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/port.h"
 #include "talk/session/media/mediasession.h"
 #include "talk/session/media/mediasessionclient.h"
 #include "webrtc/base/common.h"
@@ -197,13 +197,17 @@
 static const char kTimeDescription[] = "t=0 0";
 static const char kAttrGroup[] = "a=group:BUNDLE";
 static const char kConnectionNettype[] = "IN";
-static const char kConnectionAddrtype[] = "IP4";
+static const char kConnectionIpv4Addrtype[] = "IP4";
+static const char kConnectionIpv6Addrtype[] = "IP6";
 static const char kMediaTypeVideo[] = "video";
 static const char kMediaTypeAudio[] = "audio";
 static const char kMediaTypeData[] = "application";
 static const char kMediaPortRejected[] = "0";
-static const char kDefaultAddress[] = "0.0.0.0";
-static const char kDefaultPort[] = "1";
+// draft-ietf-mmusic-trickle-ice-01
+// When no candidates have been gathered, set the connection
+// address to IP6 ::.
+static const char kDummyAddress[] = "::";
+static const char kDummyPort[] = "9";
 // RFC 3556
 static const char kApplicationSpecificMaximum[] = "AS";
 
@@ -667,10 +671,13 @@
 // The value of |component_id| currently supported are 1 (RTP) and 2 (RTCP).
 // TODO: Decide the default destination in webrtcsession and
 // pass it down via SessionDescription.
-static bool GetDefaultDestination(const std::vector<Candidate>& candidates,
-    int component_id, std::string* port, std::string* ip) {
-  *port = kDefaultPort;
-  *ip = kDefaultAddress;
+static void GetDefaultDestination(
+    const std::vector<Candidate>& candidates,
+    int component_id, std::string* port,
+    std::string* ip, std::string* addr_type) {
+  *addr_type = kConnectionIpv6Addrtype;
+  *port = kDummyPort;
+  *ip = kDummyAddress;
   int current_preference = kPreferenceUnknown;
   for (std::vector<Candidate>::const_iterator it = candidates.begin();
        it != candidates.end(); ++it) {
@@ -685,8 +692,13 @@
     current_preference = preference;
     *port = it->address().PortAsString();
     *ip = it->address().ipaddr().ToString();
+    int family = it->address().ipaddr().family();
+    if (family == AF_INET) {
+      addr_type->assign(kConnectionIpv4Addrtype);
+    } else if (family == AF_INET6) {
+      addr_type->assign(kConnectionIpv6Addrtype);
+    }
   }
-  return true;
 }
 
 // Update |mline|'s default destination and append a c line after it.
@@ -705,55 +717,52 @@
   }
 
   std::ostringstream os;
-  std::string rtp_port, rtp_ip;
-  if (GetDefaultDestination(candidates, ICE_CANDIDATE_COMPONENT_RTP,
-                            &rtp_port, &rtp_ip)) {
-    // Found default RTP candidate.
-    // RFC 5245
-    // The default candidates are added to the SDP as the default
-    // destination for media.  For streams based on RTP, this is done by
-    // placing the IP address and port of the RTP candidate into the c and m
-    // lines, respectively.
-
-    // Update the port in the m line.
-    // If this is a m-line with port equal to 0, we don't change it.
-    if (fields[1] != kMediaPortRejected) {
-      new_lines.replace(fields[0].size() + 1,
-                        fields[1].size(),
-                        rtp_port);
-    }
-    // Add the c line.
-    // RFC 4566
-    // c=<nettype> <addrtype> <connection-address>
-    InitLine(kLineTypeConnection, kConnectionNettype, &os);
-    os << " " << kConnectionAddrtype << " " << rtp_ip;
-    AddLine(os.str(), &new_lines);
+  std::string rtp_port, rtp_ip, addr_type;
+  GetDefaultDestination(candidates, ICE_CANDIDATE_COMPONENT_RTP,
+                        &rtp_port, &rtp_ip, &addr_type);
+  // Found default RTP candidate.
+  // RFC 5245
+  // The default candidates are added to the SDP as the default
+  // destination for media.  For streams based on RTP, this is done by
+  // placing the IP address and port of the RTP candidate into the c and m
+  // lines, respectively.
+  // Update the port in the m line.
+  // If this is a m-line with port equal to 0, we don't change it.
+  if (fields[1] != kMediaPortRejected) {
+    new_lines.replace(fields[0].size() + 1,
+                      fields[1].size(),
+                      rtp_port);
   }
+  // Add the c line.
+  // RFC 4566
+  // c=<nettype> <addrtype> <connection-address>
+  InitLine(kLineTypeConnection, kConnectionNettype, &os);
+  os << " " << addr_type << " " << rtp_ip;
+  AddLine(os.str(), &new_lines);
   message->append(new_lines);
 }
 
 // Gets "a=rtcp" line if found default RTCP candidate from |candidates|.
 static std::string GetRtcpLine(const std::vector<Candidate>& candidates) {
-  std::string rtcp_line, rtcp_port, rtcp_ip;
-  if (GetDefaultDestination(candidates, ICE_CANDIDATE_COMPONENT_RTCP,
-                            &rtcp_port, &rtcp_ip)) {
-    // Found default RTCP candidate.
-    // RFC 5245
-    // If the agent is utilizing RTCP, it MUST encode the RTCP candidate
-    // using the a=rtcp attribute as defined in RFC 3605.
+  std::string rtcp_line, rtcp_port, rtcp_ip, addr_type;
+  GetDefaultDestination(candidates, ICE_CANDIDATE_COMPONENT_RTCP,
+                        &rtcp_port, &rtcp_ip, &addr_type);
+  // Found default RTCP candidate.
+  // RFC 5245
+  // If the agent is utilizing RTCP, it MUST encode the RTCP candidate
+  // using the a=rtcp attribute as defined in RFC 3605.
 
-    // RFC 3605
-    // rtcp-attribute =  "a=rtcp:" port  [nettype space addrtype space
-    // connection-address] CRLF
-    std::ostringstream os;
-    InitAttrLine(kAttributeRtcp, &os);
-    os << kSdpDelimiterColon
-       << rtcp_port << " "
-       << kConnectionNettype << " "
-       << kConnectionAddrtype << " "
-       << rtcp_ip;
-    rtcp_line = os.str();
-  }
+  // RFC 3605
+  // rtcp-attribute =  "a=rtcp:" port  [nettype space addrtype space
+  // connection-address] CRLF
+  std::ostringstream os;
+  InitAttrLine(kAttributeRtcp, &os);
+  os << kSdpDelimiterColon
+     << rtcp_port << " "
+     << kConnectionNettype << " "
+     << addr_type << " "
+     << rtcp_ip;
+  rtcp_line = os.str();
   return rtcp_line;
 }
 
@@ -1243,7 +1252,7 @@
   // To reject an offered stream, the port number in the corresponding stream in
   // the answer MUST be set to zero.
   const std::string port = content_info->rejected ?
-      kMediaPortRejected : kDefaultPort;
+      kMediaPortRejected : kDummyPort;
 
   rtc::SSLFingerprint* fp = (transport_info) ?
       transport_info->description.identity_fingerprint.get() : NULL;
diff --git a/app/webrtc/webrtcsdp_unittest.cc b/app/webrtc/webrtcsdp_unittest.cc
index 560d5da..ea590db 100644
--- a/app/webrtc/webrtcsdp_unittest.cc
+++ b/app/webrtc/webrtcsdp_unittest.cc
@@ -32,7 +32,7 @@
 #include "talk/app/webrtc/jsepsessiondescription.h"
 #include "talk/app/webrtc/webrtcsdp.h"
 #include "talk/media/base/constants.h"
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 #include "talk/session/media/mediasession.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
@@ -212,9 +212,9 @@
     "s=-\r\n"
     "t=0 0\r\n"
     "a=msid-semantic: WMS local_stream_1 local_stream_2\r\n"
-    "m=audio 1 RTP/SAVPF 111 103 104\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
-    "a=rtcp:1 IN IP4 0.0.0.0\r\n"
+    "m=audio 9 RTP/SAVPF 111 103 104\r\n"
+    "c=IN IP6 ::\r\n"
+    "a=rtcp:9 IN IP6 ::\r\n"
     "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
     "a=mid:audio_content_name\r\n"
     "a=sendrecv\r\n"
@@ -233,9 +233,9 @@
     "a=ssrc:4 msid:local_stream_2 audio_track_id_2\r\n"
     "a=ssrc:4 mslabel:local_stream_2\r\n"
     "a=ssrc:4 label:audio_track_id_2\r\n"
-    "m=video 1 RTP/SAVPF 120\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
-    "a=rtcp:1 IN IP4 0.0.0.0\r\n"
+    "m=video 9 RTP/SAVPF 120\r\n"
+    "c=IN IP6 ::\r\n"
+    "a=rtcp:9 IN IP6 ::\r\n"
     "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n"
     "a=mid:video_content_name\r\n"
     "a=sendrecv\r\n"
@@ -261,9 +261,9 @@
     "a=ssrc:6 label:video_track_id_3\r\n";
 
 static const char kSdpRtpDataChannelString[] =
-    "m=application 1 RTP/SAVPF 101\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
-    "a=rtcp:1 IN IP4 0.0.0.0\r\n"
+    "m=application 9 RTP/SAVPF 101\r\n"
+    "c=IN IP6 ::\r\n"
+    "a=rtcp:9 IN IP6 ::\r\n"
     "a=ice-ufrag:ufrag_data\r\n"
     "a=ice-pwd:pwd_data\r\n"
     "a=mid:data_content_name\r\n"
@@ -277,8 +277,8 @@
     "a=ssrc:10 label:data_channeld0\r\n";
 
 static const char kSdpSctpDataChannelString[] =
-    "m=application 1 DTLS/SCTP 5000\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
+    "m=application 9 DTLS/SCTP 5000\r\n"
+    "c=IN IP6 ::\r\n"
     "a=ice-ufrag:ufrag_data\r\n"
     "a=ice-pwd:pwd_data\r\n"
     "a=mid:data_content_name\r\n"
@@ -286,10 +286,10 @@
 
 // draft-ietf-mmusic-sctp-sdp-07
 static const char kSdpSctpDataChannelStringWithSctpPort[] =
-    "m=application 1 DTLS/SCTP webrtc-datachannel\r\n"
+    "m=application 9 DTLS/SCTP webrtc-datachannel\r\n"
     "a=fmtp:webrtc-datachannel max-message-size=100000\r\n"
     "a=sctp-port 5000\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
+    "c=IN IP6 ::\r\n"
     "a=ice-ufrag:ufrag_data\r\n"
     "a=ice-pwd:pwd_data\r\n"
     "a=mid:data_content_name\r\n";
@@ -315,11 +315,11 @@
     "s=-\r\n"
     "t=0 0\r\n"
     "a=msid-semantic: WMS\r\n"
-    "m=audio 1 RTP/SAVPF 111 103 104\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
+    "m=audio 9 RTP/SAVPF 111 103 104\r\n"
+    "c=IN IP6 ::\r\n"
     "a=x-google-flag:conference\r\n"
-    "m=video 1 RTP/SAVPF 120\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
+    "m=video 9 RTP/SAVPF 120\r\n"
+    "c=IN IP6 ::\r\n"
     "a=x-google-flag:conference\r\n";
 
 static const char kSdpSessionString[] =
@@ -330,9 +330,9 @@
     "a=msid-semantic: WMS local_stream\r\n";
 
 static const char kSdpAudioString[] =
-    "m=audio 1 RTP/SAVPF 111\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
-    "a=rtcp:1 IN IP4 0.0.0.0\r\n"
+    "m=audio 9 RTP/SAVPF 111\r\n"
+    "c=IN IP6 ::\r\n"
+    "a=rtcp:9 IN IP6 ::\r\n"
     "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
     "a=mid:audio_content_name\r\n"
     "a=sendrecv\r\n"
@@ -343,9 +343,9 @@
     "a=ssrc:1 label:audio_track_id_1\r\n";
 
 static const char kSdpVideoString[] =
-    "m=video 1 RTP/SAVPF 120\r\n"
-    "c=IN IP4 0.0.0.0\r\n"
-    "a=rtcp:1 IN IP4 0.0.0.0\r\n"
+    "m=video 9 RTP/SAVPF 120\r\n"
+    "c=IN IP6 ::\r\n"
+    "a=rtcp:9 IN IP6 ::\r\n"
     "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n"
     "a=mid:video_content_name\r\n"
     "a=sendrecv\r\n"
@@ -1195,7 +1195,7 @@
         // description.
         "a=msid-semantic: WMS\r\n"
         // Pl type 111 preferred.
-        "m=audio 1 RTP/SAVPF 111 104 103 102\r\n"
+        "m=audio 9 RTP/SAVPF 111 104 103 102\r\n"
         // Pltype 111 listed before 103 and 104 in the map.
         "a=rtpmap:111 opus/48000/2\r\n"
         // Pltype 103 listed before 104.
@@ -1217,7 +1217,7 @@
     os.clear();
     os.str("");
     // Pl type 100 preferred.
-    os << "m=video 1 RTP/SAVPF 99 95\r\n"
+    os << "m=video 9 RTP/SAVPF 99 95\r\n"
        << "a=rtpmap:99 VP8/90000\r\n"
        << "a=rtpmap:95 RTX/90000\r\n"
        << "a=fmtp:95 apt=99;rtx-time=1000\r\n";
@@ -1279,7 +1279,7 @@
         // this parser, and will be added to the SDP when serializing a session
         // description.
         "a=msid-semantic: WMS\r\n"
-        "m=audio 1 RTP/SAVPF 111\r\n"
+        "m=audio 9 RTP/SAVPF 111\r\n"
         "a=rtpmap:111 opus/48000/2\r\n"
         "a=rtcp-fb:111 nack\r\n"
         "m=video 3457 RTP/SAVPF 101\r\n"
@@ -1596,7 +1596,7 @@
   // TODO(pthatcher): We need to temporarily allow the SDP to control
   // this for backwards-compatibility.  Once we don't need that any
   // more, remove this.
-  InjectAfter("m=application 1 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n",
+  InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP6 ::\r\n",
               "b=AS:100\r\n",
               &expected_sdp);
   EXPECT_EQ(expected_sdp, message);
@@ -2308,7 +2308,7 @@
       "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
       "s=-\r\n"
       "t=0 0\r\n"
-      "m=audio 1 RTP/SAVPF 104 103\r\n"  // Pl type 104 preferred.
+      "m=audio 9 RTP/SAVPF 104 103\r\n"  // Pl type 104 preferred.
       "a=rtpmap:111 opus/48000/2\r\n"  // Pltype 111 listed before 103 and 104
                                        // in the map.
       "a=rtpmap:103 ISAC/16000\r\n"  // Pltype 103 listed before 104 in the map.
diff --git a/app/webrtc/webrtcsession.h b/app/webrtc/webrtcsession.h
index 86ae435..25e9646 100644
--- a/app/webrtc/webrtcsession.h
+++ b/app/webrtc/webrtcsession.h
@@ -36,7 +36,7 @@
 #include "talk/app/webrtc/peerconnectioninterface.h"
 #include "talk/app/webrtc/statstypes.h"
 #include "talk/media/base/mediachannel.h"
-#include "talk/p2p/base/session.h"
+#include "webrtc/p2p/base/session.h"
 #include "talk/session/media/mediasession.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/thread.h"
diff --git a/app/webrtc/webrtcsession_unittest.cc b/app/webrtc/webrtcsession_unittest.cc
index d3480a0..e79001a 100644
--- a/app/webrtc/webrtcsession_unittest.cc
+++ b/app/webrtc/webrtcsession_unittest.cc
@@ -40,10 +40,10 @@
 #include "talk/media/base/fakevideorenderer.h"
 #include "talk/media/base/mediachannel.h"
 #include "talk/media/devices/fakedevicemanager.h"
-#include "talk/p2p/base/stunserver.h"
-#include "talk/p2p/base/teststunserver.h"
-#include "talk/p2p/base/testturnserver.h"
-#include "talk/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/base/stunserver.h"
+#include "webrtc/p2p/base/teststunserver.h"
+#include "webrtc/p2p/base/testturnserver.h"
+#include "webrtc/p2p/client/basicportallocator.h"
 #include "talk/session/media/channelmanager.h"
 #include "talk/session/media/mediasession.h"
 #include "webrtc/base/fakenetwork.h"
diff --git a/app/webrtc/webrtcsessiondescriptionfactory.h b/app/webrtc/webrtcsessiondescriptionfactory.h
index b870856..31f72fe 100644
--- a/app/webrtc/webrtcsessiondescriptionfactory.h
+++ b/app/webrtc/webrtcsessiondescriptionfactory.h
@@ -29,7 +29,7 @@
 #define TALK_APP_WEBRTC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_
 
 #include "talk/app/webrtc/peerconnectioninterface.h"
-#include "talk/p2p/base/transportdescriptionfactory.h"
+#include "webrtc/p2p/base/transportdescriptionfactory.h"
 #include "talk/session/media/mediasession.h"
 #include "webrtc/base/messagehandler.h"
 
diff --git a/build/common.gypi b/build/common.gypi
index 7ee4224..d682381 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -39,9 +39,7 @@
     'libpeer_target_type%': 'static_library',
     'conditions': [
       ['OS=="android" or OS=="linux"', {
-        # TODO(henrike): make sure waterfall bots have $JAVA_HOME configured
-        # properly and remove the default value below. See issue 2113.
-        'java_home%': '<!(python -c "import os; dir=os.getenv(\'JAVA_HOME\', \'/usr/lib/jvm/java-6-sun\'); assert os.path.exists(os.path.join(dir, \'include/jni.h\')), \'Point \\$JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!\'; print dir")',
+        'java_home%': '<!(python -c "import os; dir=os.getenv(\'JAVA_HOME\', \'/usr/lib/jvm/java-7-openjdk-amd64\'); assert os.path.exists(os.path.join(dir, \'include/jni.h\')), \'Point \\$JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!\'; print dir")',
       }],
     ],
   },
diff --git a/build/isolate.gypi b/build/isolate.gypi
index 6f884cf..df28525 100644
--- a/build/isolate.gypi
+++ b/build/isolate.gypi
@@ -81,18 +81,6 @@
         # Files that are known to be involved in this step.
         '<(DEPTH)/tools/swarming_client/isolate.py',
         '<(DEPTH)/tools/swarming_client/run_isolated.py',
-
-        # Disable file tracking by the build driver for now. This means the
-        # project must have the proper build-time dependency for their runtime
-        # dependency. This improves the runtime of the build driver since it
-        # doesn't have to stat() all these files.
-        #
-        # More importantly, it means that even if a isolate_dependency_tracked
-        # file is missing, for example if a file was deleted and the .isolate
-        # file was not updated, that won't break the build, especially in the
-        # case where foo_tests_run is not built! This should be reenabled once
-        # the switch-over to running tests on Swarm is completed.
-        #'<@(isolate_dependency_tracked)',
       ],
       'outputs': [
         '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated',
diff --git a/examples/android/AndroidManifest.xml b/examples/android/AndroidManifest.xml
index f898641..30fd46c 100644
--- a/examples/android/AndroidManifest.xml
+++ b/examples/android/AndroidManifest.xml
@@ -4,38 +4,46 @@
           android:versionCode="1"
           android:versionName="1.0">
 
-  <uses-feature android:name="android.hardware.camera" />
-  <uses-feature android:name="android.hardware.camera.autofocus" />
-  <uses-feature android:glEsVersion="0x00020000" android:required="true"></uses-feature>
-  <uses-sdk android:minSdkVersion="13" android:targetSdkVersion="17" />
+    <uses-feature android:name="android.hardware.camera" />
+    <uses-feature android:name="android.hardware.camera.autofocus" />
+    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
+    <uses-sdk android:minSdkVersion="13" android:targetSdkVersion="19" />
 
-  <uses-permission android:name="android.permission.CAMERA"></uses-permission>
-  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
-  <uses-permission android:name="android.permission.RECORD_AUDIO" />
-  <uses-permission android:name="android.permission.INTERNET" />
-  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 
-  <application android:label="@string/app_name"
-               android:icon="@drawable/ic_launcher"
-               android:debuggable="true"
-               android:allowBackup="false">
-    <activity android:name="AppRTCDemoActivity"
-              android:label="@string/app_name"
-              android:screenOrientation="fullUser"
-              android:configChanges="orientation|screenSize"
-              android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
-      <intent-filter>
-        <action android:name="android.intent.action.MAIN" />
-        <category android:name="android.intent.category.LAUNCHER" />
-      </intent-filter>
+    <application android:label="@string/app_name"
+                 android:icon="@drawable/ic_launcher"
+                 android:allowBackup="false">
 
-      <intent-filter>
-        <action android:name="android.intent.action.VIEW" />
-        <category android:name="android.intent.category.DEFAULT" />
-        <category android:name="android.intent.category.BROWSABLE" />
-        <data android:scheme="https" android:host="apprtc.appspot.com" />
-        <data android:scheme="http" android:host="apprtc.appspot.com" />
-      </intent-filter>
-    </activity>
-  </application>
+        <activity android:name="ConnectActivity"
+                  android:label="@string/app_name">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER"/>
+            </intent-filter>
+
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW"/>
+                <category android:name="android.intent.category.DEFAULT"/>
+                <category android:name="android.intent.category.BROWSABLE"/>
+                <data android:scheme="https" android:host="apprtc.appspot.com"/>
+                <data android:scheme="http" android:host="apprtc.appspot.com"/>
+            </intent-filter>
+        </activity>
+
+        <activity android:name="SettingsActivity"
+                  android:label="@string/settings_name">
+        </activity>
+
+        <activity android:name="AppRTCDemoActivity"
+                  android:label="@string/app_name"
+                  android:screenOrientation="fullUser"
+                  android:configChanges="orientation|screenSize"
+                  android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
+        </activity>
+    </application>
 </manifest>
diff --git a/examples/android/project.properties b/examples/android/project.properties
index 8459f9b..47b7078 100644
--- a/examples/android/project.properties
+++ b/examples/android/project.properties
@@ -11,6 +11,6 @@
 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
 
 # Project target.
-target=android-19
+target=android-21
 
 java.compilerargs=-Xlint:all -Werror
diff --git a/examples/android/res/drawable-hdpi/disconnect.png b/examples/android/res/drawable-hdpi/disconnect.png
new file mode 100644
index 0000000..be36174
--- /dev/null
+++ b/examples/android/res/drawable-hdpi/disconnect.png
Binary files differ
diff --git a/examples/android/res/drawable-hdpi/ic_action_full_screen.png b/examples/android/res/drawable-hdpi/ic_action_full_screen.png
new file mode 100644
index 0000000..22f30d3
--- /dev/null
+++ b/examples/android/res/drawable-hdpi/ic_action_full_screen.png
Binary files differ
diff --git a/examples/android/res/drawable-hdpi/ic_action_return_from_full_screen.png b/examples/android/res/drawable-hdpi/ic_action_return_from_full_screen.png
new file mode 100644
index 0000000..d9436e5
--- /dev/null
+++ b/examples/android/res/drawable-hdpi/ic_action_return_from_full_screen.png
Binary files differ
diff --git a/examples/android/res/drawable-hdpi/ic_launcher.png b/examples/android/res/drawable-hdpi/ic_launcher.png
index f3e9d12..f01a31a 100644
--- a/examples/android/res/drawable-hdpi/ic_launcher.png
+++ b/examples/android/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/examples/android/res/drawable-hdpi/ic_loopback_call.png b/examples/android/res/drawable-hdpi/ic_loopback_call.png
new file mode 100644
index 0000000..3931185
--- /dev/null
+++ b/examples/android/res/drawable-hdpi/ic_loopback_call.png
Binary files differ
diff --git a/examples/android/res/drawable-ldpi/disconnect.png b/examples/android/res/drawable-ldpi/disconnect.png
new file mode 100644
index 0000000..be36174
--- /dev/null
+++ b/examples/android/res/drawable-ldpi/disconnect.png
Binary files differ
diff --git a/examples/android/res/drawable-ldpi/ic_action_full_screen.png b/examples/android/res/drawable-ldpi/ic_action_full_screen.png
new file mode 100644
index 0000000..e4a9ff0
--- /dev/null
+++ b/examples/android/res/drawable-ldpi/ic_action_full_screen.png
Binary files differ
diff --git a/examples/android/res/drawable-ldpi/ic_action_return_from_full_screen.png b/examples/android/res/drawable-ldpi/ic_action_return_from_full_screen.png
new file mode 100644
index 0000000..f5c80f0
--- /dev/null
+++ b/examples/android/res/drawable-ldpi/ic_action_return_from_full_screen.png
Binary files differ
diff --git a/examples/android/res/drawable-ldpi/ic_loopback_call.png b/examples/android/res/drawable-ldpi/ic_loopback_call.png
new file mode 100644
index 0000000..3931185
--- /dev/null
+++ b/examples/android/res/drawable-ldpi/ic_loopback_call.png
Binary files differ
diff --git a/examples/android/res/drawable-mdpi/disconnect.png b/examples/android/res/drawable-mdpi/disconnect.png
new file mode 100644
index 0000000..be36174
--- /dev/null
+++ b/examples/android/res/drawable-mdpi/disconnect.png
Binary files differ
diff --git a/examples/android/res/drawable-mdpi/ic_action_full_screen.png b/examples/android/res/drawable-mdpi/ic_action_full_screen.png
new file mode 100644
index 0000000..e4a9ff0
--- /dev/null
+++ b/examples/android/res/drawable-mdpi/ic_action_full_screen.png
Binary files differ
diff --git a/examples/android/res/drawable-mdpi/ic_action_return_from_full_screen.png b/examples/android/res/drawable-mdpi/ic_action_return_from_full_screen.png
new file mode 100644
index 0000000..f5c80f0
--- /dev/null
+++ b/examples/android/res/drawable-mdpi/ic_action_return_from_full_screen.png
Binary files differ
diff --git a/examples/android/res/drawable-mdpi/ic_launcher.png b/examples/android/res/drawable-mdpi/ic_launcher.png
index 9709a1e..b8b4b0e 100644
--- a/examples/android/res/drawable-mdpi/ic_launcher.png
+++ b/examples/android/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/examples/android/res/drawable-mdpi/ic_loopback_call.png b/examples/android/res/drawable-mdpi/ic_loopback_call.png
new file mode 100644
index 0000000..3931185
--- /dev/null
+++ b/examples/android/res/drawable-mdpi/ic_loopback_call.png
Binary files differ
diff --git a/examples/android/res/drawable-xhdpi/disconnect.png b/examples/android/res/drawable-xhdpi/disconnect.png
new file mode 100644
index 0000000..be36174
--- /dev/null
+++ b/examples/android/res/drawable-xhdpi/disconnect.png
Binary files differ
diff --git a/examples/android/res/drawable-xhdpi/ic_action_full_screen.png b/examples/android/res/drawable-xhdpi/ic_action_full_screen.png
new file mode 100644
index 0000000..6d90c07
--- /dev/null
+++ b/examples/android/res/drawable-xhdpi/ic_action_full_screen.png
Binary files differ
diff --git a/examples/android/res/drawable-xhdpi/ic_action_return_from_full_screen.png b/examples/android/res/drawable-xhdpi/ic_action_return_from_full_screen.png
new file mode 100644
index 0000000..a773b34
--- /dev/null
+++ b/examples/android/res/drawable-xhdpi/ic_action_return_from_full_screen.png
Binary files differ
diff --git a/examples/android/res/drawable-xhdpi/ic_launcher.png b/examples/android/res/drawable-xhdpi/ic_launcher.png
index db2c4f6..a3cd458 100644
--- a/examples/android/res/drawable-xhdpi/ic_launcher.png
+++ b/examples/android/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/examples/android/res/drawable-xhdpi/ic_loopback_call.png b/examples/android/res/drawable-xhdpi/ic_loopback_call.png
new file mode 100644
index 0000000..3931185
--- /dev/null
+++ b/examples/android/res/drawable-xhdpi/ic_loopback_call.png
Binary files differ
diff --git a/examples/android/res/layout/activity_connect.xml b/examples/android/res/layout/activity_connect.xml
new file mode 100644
index 0000000..5ca0f19
--- /dev/null
+++ b/examples/android/res/layout/activity_connect.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        android:weightSum="1"
+        android:layout_margin="8dp"
+        android:layout_centerHorizontal="true">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal" >
+            <ImageButton
+                android:id="@+id/add_room_button"
+                android:background="@android:drawable/ic_menu_add"
+                android:contentDescription="@string/add_room_description"
+                android:layout_marginRight="20dp"
+                android:layout_width="48dp"
+                android:layout_height="48dp"/>
+            <ImageButton
+                android:id="@+id/remove_room_button"
+                android:background="@android:drawable/ic_delete"
+                android:contentDescription="@string/remove_room_description"
+                android:layout_marginRight="20dp"
+                android:layout_width="48dp"
+                android:layout_height="48dp"/>
+            <ImageButton
+                android:id="@+id/connect_button"
+                android:background="@android:drawable/sym_action_call"
+                android:contentDescription="@string/connect_description"
+                android:layout_marginRight="20dp"
+                android:layout_width="48dp"
+                android:layout_height="48dp"/>
+            <ImageButton
+                android:id="@+id/connect_loopback_button"
+                android:background="@drawable/ic_loopback_call"
+                android:contentDescription="@string/connect_loopback_description"
+                android:layout_width="48dp"
+                android:layout_height="48dp"/>
+    </LinearLayout>
+    <TextView
+            android:id="@+id/room_edittext_description"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_margin="5dp"
+            android:text="@string/room_description"/>
+    <EditText
+            android:id="@+id/room_edittext"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:singleLine="true"
+            android:imeOptions="actionDone"/>
+    <TextView
+            android:id="@+id/room_listview_description"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="5dp"
+            android:lines="1"
+            android:maxLines="1"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:text="@string/room_names"/>
+    <ListView
+            android:id="@+id/room_listview"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:choiceMode="singleChoice"
+            android:listSelector="@android:color/darker_gray"
+            android:drawSelectorOnTop="false" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/examples/android/res/layout/activity_fullscreen.xml b/examples/android/res/layout/activity_fullscreen.xml
new file mode 100644
index 0000000..fc9ee9e
--- /dev/null
+++ b/examples/android/res/layout/activity_fullscreen.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<RelativeLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:tools="http://schemas.android.com/tools"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+
+    <android.opengl.GLSurfaceView
+            android:id="@+id/glview"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+
+    <TextView
+        android:id="@+id/room_name"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_above="@+id/menubar_fragment"
+        android:textSize="24sp"
+        android:layout_margin="8dp"/>
+    <fragment
+        android:name="org.appspot.apprtc.AppRTCDemoActivity$MenuBarFragment"
+        android:id="@+id/menubar_fragment"
+        android:layout_centerHorizontal="true"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_marginBottom="32dp"
+        tools:layout="@layout/fragment_menubar"/>
+
+</RelativeLayout>
diff --git a/examples/android/res/layout/fragment_menubar.xml b/examples/android/res/layout/fragment_menubar.xml
new file mode 100644
index 0000000..77dc819
--- /dev/null
+++ b/examples/android/res/layout/fragment_menubar.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              xmlns:tools="http://schemas.android.com/tools"
+              tools:context="org.appspot.apprtc.AppRTCDemoActivity$MenuBarFragment"
+              android:id="@+id/menubar"
+              android:orientation="horizontal"
+              android:layout_width="wrap_content"
+              android:layout_height="match_parent"
+              android:layout_gravity="center_vertical|center_horizontal">
+
+    <ImageButton
+        android:id="@+id/button_disconnect"
+        android:background="@drawable/disconnect"
+        android:contentDescription="@string/disconnect_call"
+        android:layout_marginRight="16dp"
+        android:layout_width="48dp"
+        android:layout_height="48dp"/>
+
+    <!-- TODO(kjellander): Add audio and video mute buttons. -->
+
+    <ImageButton
+        android:id="@+id/button_switch_camera"
+        android:background="@android:drawable/ic_menu_camera"
+        android:contentDescription="@string/switch_camera"
+        android:layout_marginRight="8dp"
+        android:layout_width="48dp"
+        android:layout_height="48dp"/>
+
+    <ImageButton
+        android:id="@+id/button_toggle_debug"
+        android:background="@android:drawable/ic_menu_info_details"
+        android:contentDescription="@string/disconnect_call"
+        android:layout_marginRight="8dp"
+        android:layout_width="48dp"
+        android:layout_height="48dp"/>
+
+    <ImageButton
+        android:id="@+id/button_scaling_mode"
+        android:background="@drawable/ic_action_return_from_full_screen"
+        android:contentDescription="@string/disconnect_call"
+        android:layout_width="48dp"
+        android:layout_height="48dp"/>
+
+</LinearLayout>
diff --git a/examples/android/res/menu/connect_menu.xml b/examples/android/res/menu/connect_menu.xml
new file mode 100644
index 0000000..d9f9486
--- /dev/null
+++ b/examples/android/res/menu/connect_menu.xml
@@ -0,0 +1,8 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:icon="@android:drawable/ic_menu_preferences"
+        android:showAsAction="ifRoom"
+        android:title="@string/action_settings"/>
+</menu>
diff --git a/examples/android/res/values/arrays.xml b/examples/android/res/values/arrays.xml
new file mode 100644
index 0000000..3127a85
--- /dev/null
+++ b/examples/android/res/values/arrays.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string-array name="videoResolutions">
+        <item>Default</item>
+        <item>HD (1280 x 720)</item>
+        <item>VGA (640 x 480)</item>
+        <item>QVGA (320 x 240)</item>
+    </string-array>
+    <string-array name="videoResolutionsValues">
+        <item>Default</item>
+        <item>1280 x 720</item>
+        <item>640 x 480</item>
+        <item>320 x 240</item>
+    </string-array>
+
+    <string-array name="cameraFps">
+        <item>Default</item>
+        <item>30 fps</item>
+        <item>15 fps</item>
+    </string-array>
+
+</resources>
diff --git a/examples/android/res/values/strings.xml b/examples/android/res/values/strings.xml
index bac765a..2a1d64a 100644
--- a/examples/android/res/values/strings.xml
+++ b/examples/android/res/values/strings.xml
@@ -1,4 +1,47 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <string name="app_name">AppRTC</string>
+    <string name="app_name" translatable="no">AppRTC</string>
+    <string name="settings_name" translatable="no">AppRTC Settings</string>
+    <string name="disconnect_call">Disconnect Call</string>
+    <string name="room_names">Room names:</string>
+    <string name="room_description">
+        Please enter a room name. Room names are shared with everyone, so think
+        of something unique and send it to a friend.
+    </string>
+    <string name="connect_text">Connect</string>
+    <string name="invalid_url_title">Invalid URL</string>
+    <string name="invalid_url_text">The URL or room name you entered resulted in an invalid URL: %1$s
+    </string>
+    <string name="channel_error_title">Connection error</string>
+    <string name="connecting_to">Connecting to: %1$s</string>
+    <string name="missing_url">FATAL ERROR: Missing URL to connect to.</string>
+    <string name="ok">OK</string>
+    <string name="switch_camera">Switch front/back camera</string>
+    <string name="action_settings">Settings</string>
+    <string name="add_room_description">Add new room to the list</string>
+    <string name="remove_room_description">Remove room from the list</string>
+    <string name="connect_description">Connect to the room</string>
+    <string name="connect_loopback_description">Loopback connection</string>
+
+    <!-- Settings strings. -->
+    <string name="pref_room_key">room_preference</string>
+    <string name="pref_room_list_key">room_list_preference</string>
+
+    <string name="pref_url_key">url_preference</string>
+    <string name="pref_url_title">Connection URL:</string>
+    <string name="pref_url_summary">AppRTC connection server URL.</string>
+    <string name="pref_url_dlg">Enter AppRTC connection server URL.</string>
+    <string name="pref_url_default">https://apprtc.appspot.com</string>
+
+    <string name="pref_resolution_key">resolution_preference</string>
+    <string name="pref_resolution_title">Video resolution.</string>
+    <string name="pref_resolution_summary">Video resolution.</string>
+    <string name="pref_resolution_dlg">Enter AppRTC local video resolution.</string>
+    <string name="pref_resolution_default">Default</string>
+
+    <string name="pref_fps_key">fps_preference</string>
+    <string name="pref_fps_title">Camera fps.</string>
+    <string name="pref_fps_summary">Camera fps.</string>
+    <string name="pref_fps_dlg">Enter local camera fps.</string>
+    <string name="pref_fps_default">Default</string>
 </resources>
diff --git a/examples/android/res/xml/preferences.xml b/examples/android/res/xml/preferences.xml
new file mode 100644
index 0000000..f3f91d8
--- /dev/null
+++ b/examples/android/res/xml/preferences.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+    <EditTextPreference
+        android:key="@string/pref_url_key"
+        android:title="@string/pref_url_title"
+        android:summary="@string/pref_url_summary"
+        android:defaultValue="@string/pref_url_default"
+        android:inputType="textWebEmailAddress"
+        android:dialogTitle="@string/pref_url_dlg" />
+    <ListPreference
+        android:key="@string/pref_resolution_key"
+        android:title="@string/pref_resolution_title"
+        android:summary="@string/pref_resolution_summary"
+        android:defaultValue="@string/pref_resolution_default"
+        android:dialogTitle="@string/pref_resolution_dlg"
+        android:entries="@array/videoResolutions"
+        android:entryValues="@array/videoResolutionsValues" />
+    <ListPreference
+        android:key="@string/pref_fps_key"
+        android:title="@string/pref_fps_title"
+        android:summary="@string/pref_fps_summary"
+        android:defaultValue="@string/pref_fps_default"
+        android:dialogTitle="@string/pref_fps_dlg"
+        android:entries="@array/cameraFps"
+        android:entryValues="@array/cameraFps" />
+</PreferenceScreen>
\ No newline at end of file
diff --git a/examples/android/src/org/appspot/apprtc/AppRTCClient.java b/examples/android/src/org/appspot/apprtc/AppRTCClient.java
index 4728e51..5c34fca 100644
--- a/examples/android/src/org/appspot/apprtc/AppRTCClient.java
+++ b/examples/android/src/org/appspot/apprtc/AppRTCClient.java
@@ -80,7 +80,9 @@
   }
 
   /**
-   * Signaling callbacks.
+   * Callback interface for messages delivered on signalling channel.
+   *
+   * Methods are guaranteed to be invoked on the UI thread of |activity|.
    */
   public static interface AppRTCSignalingEvents {
     /**
diff --git a/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java b/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
index 4718a01..ad0e2d5 100644
--- a/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
+++ b/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
@@ -29,19 +29,24 @@
 
 import android.app.Activity;
 import android.app.AlertDialog;
+import android.app.Fragment;
 import android.content.DialogInterface;
 import android.content.Intent;
-import android.content.res.Configuration;
+import android.content.pm.ActivityInfo;
 import android.graphics.Color;
-import android.graphics.Point;
 import android.media.AudioManager;
+import android.net.Uri;
+import android.opengl.GLSurfaceView;
 import android.os.Bundle;
 import android.util.Log;
 import android.util.TypedValue;
+import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
 import android.view.WindowManager;
-import android.widget.EditText;
+import android.widget.ImageButton;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -53,6 +58,7 @@
 import org.webrtc.StatsReport;
 import org.webrtc.VideoRenderer;
 import org.webrtc.VideoRendererGui;
+import org.webrtc.VideoRendererGui.ScalingType;
 
 /**
  * Main Activity of the AppRTCDemo Android app demonstrating interoperability
@@ -66,43 +72,112 @@
   private PeerConnectionClient pc;
   private AppRTCClient appRtcClient = new GAERTCClient(this, this);
   private AppRTCSignalingParameters appRtcParameters;
-  private AppRTCGLView vsv;
+  private View rootView;
+  private View menuBar;
+  private GLSurfaceView videoView;
   private VideoRenderer.Callbacks localRender;
   private VideoRenderer.Callbacks remoteRender;
+  private ScalingType scalingType;
   private Toast logToast;
   private final LayoutParams hudLayout =
       new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   private TextView hudView;
-  // Synchronize on quit[0] to avoid teardown-related crashes.
-  private final Boolean[] quit = new Boolean[] { false };
+  private TextView roomName;
+  private ImageButton videoScalingButton;
+  private boolean iceConnected;
 
   @Override
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
 
-    Thread.setDefaultUncaughtExceptionHandler(
-        new UnhandledExceptionHandler(this));
-
+    // Set window styles for fullscreen-window size. Needs to be done before
+    // adding content.
+    requestWindowFeature(Window.FEATURE_NO_TITLE);
     getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
     getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+    getWindow().getDecorView().setSystemUiVisibility(
+        View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+        View.SYSTEM_UI_FLAG_FULLSCREEN |
+        View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
 
-    Point displaySize = new Point();
-    getWindowManager().getDefaultDisplay().getRealSize(displaySize);
+    setContentView(R.layout.activity_fullscreen);
 
-    vsv = new AppRTCGLView(this, displaySize);
-    VideoRendererGui.setView(vsv);
-    remoteRender = VideoRendererGui.create(0, 0, 100, 100,
-        VideoRendererGui.ScalingType.SCALE_ASPECT_FIT);
-    localRender = VideoRendererGui.create(0, 0, 100, 100,
-        VideoRendererGui.ScalingType.SCALE_ASPECT_FIT);
+    Thread.setDefaultUncaughtExceptionHandler(
+        new UnhandledExceptionHandler(this));
+    iceConnected = false;
 
-    vsv.setOnClickListener(new View.OnClickListener() {
-        @Override public void onClick(View v) {
-          toggleHUD();
-        }
-      });
-    setContentView(vsv);
-    logAndToast("Tap the screen to toggle stats visibility");
+    rootView = findViewById(android.R.id.content);
+    menuBar = findViewById(R.id.menubar_fragment);
+    roomName = (TextView) findViewById(R.id.room_name);
+    videoView = (GLSurfaceView) findViewById(R.id.glview);
+
+    VideoRendererGui.setView(videoView);
+    scalingType = ScalingType.SCALE_ASPECT_FILL;
+    remoteRender = VideoRendererGui.create(0, 0, 100, 100, scalingType);
+    localRender = VideoRendererGui.create(0, 0, 100, 100, scalingType);
+
+    videoView.setOnClickListener(
+        new View.OnClickListener() {
+          @Override
+          public void onClick(View view) {
+            int visibility = menuBar.getVisibility() == View.VISIBLE
+                    ? View.INVISIBLE : View.VISIBLE;
+            menuBar.setVisibility(visibility);
+            roomName.setVisibility(visibility);
+            if (visibility == View.VISIBLE) {
+              menuBar.bringToFront();
+              roomName.bringToFront();
+              rootView.invalidate();
+            }
+          }
+        });
+
+    ((ImageButton) findViewById(R.id.button_disconnect)).setOnClickListener(
+        new View.OnClickListener() {
+          @Override
+          public void onClick(View view) {
+            logAndToast("Disconnecting call.");
+            disconnect();
+          }
+        });
+
+    ((ImageButton) findViewById(R.id.button_switch_camera)).setOnClickListener(
+        new View.OnClickListener() {
+          @Override
+          public void onClick(View view) {
+            if (pc != null) {
+              pc.switchCamera();
+            }
+          }
+        });
+
+    ((ImageButton) findViewById(R.id.button_toggle_debug)).setOnClickListener(
+        new View.OnClickListener() {
+          @Override
+          public void onClick(View view) {
+            int visibility = hudView.getVisibility() == View.VISIBLE
+                ? View.INVISIBLE : View.VISIBLE;
+            hudView.setVisibility(visibility);
+          }
+        });
+
+    videoScalingButton = (ImageButton) findViewById(R.id.button_scaling_mode);
+    videoScalingButton.setOnClickListener(
+        new View.OnClickListener() {
+          @Override
+          public void onClick(View view) {
+            if (scalingType == ScalingType.SCALE_ASPECT_FILL) {
+              videoScalingButton.setBackgroundResource(
+                  R.drawable.ic_action_full_screen);
+              scalingType = ScalingType.SCALE_ASPECT_FIT;
+            } else {
+              videoScalingButton.setBackgroundResource(
+                  R.drawable.ic_action_return_from_full_screen);
+              scalingType = ScalingType.SCALE_ASPECT_FILL;
+            }
+            updateVideoView();
+          }
+        });
 
     hudView = new TextView(this);
     hudView.setTextColor(Color.BLACK);
@@ -123,17 +198,44 @@
     audioManager.setSpeakerphoneOn(!isWiredHeadsetOn);
 
     final Intent intent = getIntent();
-    if ("android.intent.action.VIEW".equals(intent.getAction())) {
-      connectToRoom(intent.getData().toString());
-      return;
+    Uri url = intent.getData();
+    if (url != null) {
+      String room = url.getQueryParameter("r");
+      String loopback = url.getQueryParameter("debug");
+      if ((room != null && !room.equals("")) ||
+          (loopback != null && loopback.equals("loopback"))) {
+        logAndToast(getString(R.string.connecting_to, url));
+        appRtcClient.connectToRoom(url.toString());
+        if (room != null && !room.equals("")) {
+          roomName.setText(room);
+        } else {
+          roomName.setText("loopback");
+        }
+      } else {
+        logAndToast("Empty or missing room name!");
+        finish();
+      }
+    } else {
+      logAndToast(getString(R.string.missing_url));
+      Log.wtf(TAG, "Didn't get any URL in intent!");
+      finish();
     }
-    showGetRoomUI();
+  }
+
+  public static class MenuBarFragment extends Fragment {
+    @Override
+    public View onCreateView(
+        LayoutInflater inflater,
+        ViewGroup container,
+        Bundle savedInstanceState) {
+      return inflater.inflate(R.layout.fragment_menubar, container, false);
+    }
   }
 
   @Override
   public void onPause() {
     super.onPause();
-    vsv.onPause();
+    videoView.onPause();
     if (pc != null) {
       pc.stopVideoSource();
     }
@@ -142,56 +244,25 @@
   @Override
   public void onResume() {
     super.onResume();
-    vsv.onResume();
+    videoView.onResume();
     if (pc != null) {
       pc.startVideoSource();
     }
   }
 
   @Override
-  public void onConfigurationChanged (Configuration newConfig) {
-    Point displaySize = new Point();
-    getWindowManager().getDefaultDisplay().getSize(displaySize);
-    vsv.updateDisplaySize(displaySize);
-    super.onConfigurationChanged(newConfig);
-  }
-
-  @Override
   protected void onDestroy() {
-    disconnectAndExit();
+    disconnect();
     super.onDestroy();
   }
 
-  private void showGetRoomUI() {
-    final EditText roomInput = new EditText(this);
-    roomInput.setText("https://apprtc.appspot.com/?r=");
-    roomInput.setSelection(roomInput.getText().length());
-    DialogInterface.OnClickListener listener =
-        new DialogInterface.OnClickListener() {
-          @Override
-          public void onClick(DialogInterface dialog, int which) {
-            abortUnless(which == DialogInterface.BUTTON_POSITIVE, "lolwat?");
-            dialog.dismiss();
-            connectToRoom(roomInput.getText().toString());
-          }
-        };
-    AlertDialog.Builder builder = new AlertDialog.Builder(this);
-    builder
-        .setMessage("Enter room URL").setView(roomInput)
-        .setPositiveButton("Go!", listener).show();
-  }
-
-  private void connectToRoom(String roomUrl) {
-    logAndToast("Connecting to room...");
-    appRtcClient.connectToRoom(roomUrl);
-  }
-
-  // Toggle visibility of the heads-up display.
-  private void toggleHUD() {
-    if (hudView.getVisibility() == View.VISIBLE) {
-      hudView.setVisibility(View.INVISIBLE);
+  private void updateVideoView() {
+    VideoRendererGui.update(remoteRender, 0, 0, 100, 100, scalingType);
+    if (iceConnected) {
+      VideoRendererGui.update(localRender, 70, 70, 28, 28,
+          ScalingType.SCALE_ASPECT_FIT);
     } else {
-      hudView.setVisibility(View.VISIBLE);
+      VideoRendererGui.update(localRender, 0, 0, 100, 100, scalingType);
     }
   }
 
@@ -243,22 +314,29 @@
   }
 
   // Disconnect from remote resources, dispose of local resources, and exit.
-  private void disconnectAndExit() {
-    synchronized (quit[0]) {
-      if (quit[0]) {
-        return;
-      }
-      quit[0] = true;
-      if (pc != null) {
-        pc.close();
-        pc = null;
-      }
-      if (appRtcClient != null) {
-        appRtcClient.disconnect();
-        appRtcClient = null;
-      }
-      finish();
+  private void disconnect() {
+    if (appRtcClient != null) {
+      appRtcClient.disconnect();
+      appRtcClient = null;
     }
+    if (pc != null) {
+      pc.close();
+      pc = null;
+    }
+    finish();
+  }
+
+  private void disconnectWithMessage(String errorMessage) {
+    new AlertDialog.Builder(this)
+    .setTitle(getText(R.string.channel_error_title))
+    .setMessage(errorMessage)
+    .setCancelable(false)
+    .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
+        public void onClick(DialogInterface dialog, int id) {
+          dialog.cancel();
+          disconnect();
+        }
+      }).create().show();
   }
 
   // Poor-man's assert(): die with |msg| unless |condition| is true.
@@ -289,40 +367,42 @@
     logAndToast("Creating peer connection...");
     pc = new PeerConnectionClient(
         this, localRender, remoteRender, appRtcParameters, this);
+    if (pc.isHDVideo()) {
+      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+    } else {
+      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+    }
 
     {
-      final PeerConnectionClient finalPC = pc;
       final Runnable repeatedStatsLogger = new Runnable() {
-          public void run() {
-            synchronized (quit[0]) {
-              if (quit[0]) {
-                return;
-              }
-              final Runnable runnableThis = this;
-              if (hudView.getVisibility() == View.INVISIBLE) {
-                vsv.postDelayed(runnableThis, 1000);
-                return;
-              }
-              boolean success = finalPC.getStats(new StatsObserver() {
-                  public void onComplete(final StatsReport[] reports) {
-                    runOnUiThread(new Runnable() {
-                        public void run() {
-                          updateHUD(reports);
-                        }
-                      });
-                    for (StatsReport report : reports) {
-                      Log.d(TAG, "Stats: " + report.toString());
-                    }
-                    vsv.postDelayed(runnableThis, 1000);
+        public void run() {
+            if (pc == null) {
+              return;
+            }
+            final Runnable runnableThis = this;
+            if (hudView.getVisibility() == View.INVISIBLE) {
+              videoView.postDelayed(runnableThis, 1000);
+              return;
+            }
+            boolean success = pc.getStats(new StatsObserver() {
+                public void onComplete(final StatsReport[] reports) {
+                  runOnUiThread(new Runnable() {
+                      public void run() {
+                        updateHUD(reports);
+                      }
+                    });
+                  for (StatsReport report : reports) {
+                    Log.d(TAG, "Stats: " + report.toString());
                   }
-                }, null);
-              if (!success) {
-                throw new RuntimeException("getStats() return false!");
-              }
+                  videoView.postDelayed(runnableThis, 1000);
+                }
+              }, null);
+            if (!success) {
+              throw new RuntimeException("getStats() return false!");
             }
           }
-        };
-      vsv.postDelayed(repeatedStatsLogger, 1000);
+      };
+      videoView.postDelayed(repeatedStatsLogger, 1000);
     }
 
     logAndToast("Waiting for remote connection...");
@@ -330,6 +410,9 @@
 
   @Override
   public void onChannelOpen() {
+    if (pc == null) {
+      return;
+    }
     if (appRtcParameters.initiator) {
       logAndToast("Creating OFFER...");
       // Create offer. Offer SDP will be sent to answering client in
@@ -340,6 +423,9 @@
 
   @Override
   public void onRemoteDescription(final SessionDescription sdp) {
+    if (pc == null) {
+      return;
+    }
     logAndToast("Received remote " + sdp.type + " ...");
     pc.setRemoteDescription(sdp);
     if (!appRtcParameters.initiator) {
@@ -352,19 +438,20 @@
 
   @Override
   public void onRemoteIceCandidate(final IceCandidate candidate) {
-    pc.addRemoteIceCandidate(candidate);
+    if (pc != null) {
+      pc.addRemoteIceCandidate(candidate);
+    }
   }
 
   @Override
   public void onChannelClose() {
     logAndToast("Remote end hung up; dropping PeerConnection");
-    disconnectAndExit();
+    disconnect();
   }
 
   @Override
   public void onChannelError(int code, String description) {
-    logAndToast("Channel error: " + code + ". " + description);
-    disconnectAndExit();
+    disconnectWithMessage(description);
   }
 
   // -----Implementation of PeerConnectionClient.PeerConnectionEvents.---------
@@ -372,19 +459,35 @@
   // All callbacks are invoked from UI thread.
   @Override
   public void onLocalDescription(final SessionDescription sdp) {
-    logAndToast("Sending " + sdp.type + " ...");
-    appRtcClient.sendLocalDescription(sdp);
+    if (appRtcClient != null) {
+      logAndToast("Sending " + sdp.type + " ...");
+      appRtcClient.sendLocalDescription(sdp);
+    }
   }
 
   @Override
   public void onIceCandidate(final IceCandidate candidate) {
-    appRtcClient.sendLocalIceCandidate(candidate);
+    if (appRtcClient != null) {
+      appRtcClient.sendLocalIceCandidate(candidate);
+    }
   }
 
   @Override
   public void onIceConnected() {
     logAndToast("ICE connected");
-    VideoRendererGui.update(localRender, 70, 70, 28, 28,
-        VideoRendererGui.ScalingType.SCALE_ASPECT_FIT);
+    iceConnected = true;
+    updateVideoView();
   }
+
+  @Override
+  public void onIceDisconnected() {
+    logAndToast("ICE disconnected");
+    disconnect();
+  }
+
+  @Override
+  public void onPeerConnectionError(String description) {
+    disconnectWithMessage(description);
+  }
+
 }
diff --git a/examples/android/src/org/appspot/apprtc/ConnectActivity.java b/examples/android/src/org/appspot/apprtc/ConnectActivity.java
new file mode 100644
index 0000000..8f00c1c
--- /dev/null
+++ b/examples/android/src/org/appspot/apprtc/ConnectActivity.java
@@ -0,0 +1,322 @@
+/*
+ * libjingle
+ * Copyright 2014, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.appspot.apprtc;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.EditorInfo;
+import android.webkit.URLUtil;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.webrtc.MediaCodecVideoEncoder;
+
+
+/**
+ * Handles the initial setup where the user selects which room to join.
+ */
+public class ConnectActivity extends Activity {
+
+  private static final String TAG = "ConnectActivity";
+  private ImageButton addRoomButton;
+  private ImageButton removeRoomButton;
+  private ImageButton connectButton;
+  private ImageButton connectLoopbackButton;
+  private EditText roomEditText;
+  private ListView roomListView;
+  private SharedPreferences sharedPref;
+  private String keyprefUrl;
+  private String keyprefResolution;
+  private String keyprefFps;
+  private String keyprefRoom;
+  private String keyprefRoomList;
+  private ArrayList<String> roomList;
+  private ArrayAdapter<String> adapter;
+
+  @Override
+  public void onCreate(Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+
+    // Get setting keys.
+    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
+    sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+    keyprefUrl = getString(R.string.pref_url_key);
+    keyprefResolution = getString(R.string.pref_resolution_key);
+    keyprefFps = getString(R.string.pref_fps_key);
+    keyprefRoom = getString(R.string.pref_room_key);
+    keyprefRoomList = getString(R.string.pref_room_list_key);
+
+    // If an implicit VIEW intent is launching the app, go directly to that URL.
+    final Intent intent = getIntent();
+    if ("android.intent.action.VIEW".equals(intent.getAction())) {
+      connectToRoom(intent.getData().toString());
+      return;
+    }
+
+    setContentView(R.layout.activity_connect);
+
+    roomEditText = (EditText) findViewById(R.id.room_edittext);
+    roomEditText.setOnEditorActionListener(
+        new TextView.OnEditorActionListener() {
+          @Override
+          public boolean onEditorAction(
+              TextView textView, int i, KeyEvent keyEvent) {
+            if (i == EditorInfo.IME_ACTION_DONE) {
+              addRoomButton.performClick();
+              return true;
+            }
+            return false;
+          }
+    });
+    roomEditText.requestFocus();
+
+    roomListView = (ListView) findViewById(R.id.room_listview);
+    roomListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
+
+    addRoomButton = (ImageButton) findViewById(R.id.add_room_button);
+    addRoomButton.setOnClickListener(addRoomListener);
+    removeRoomButton = (ImageButton) findViewById(R.id.remove_room_button);
+    removeRoomButton.setOnClickListener(removeRoomListener);
+    connectButton = (ImageButton) findViewById(R.id.connect_button);
+    connectButton.setOnClickListener(connectListener);
+    connectLoopbackButton =
+        (ImageButton) findViewById(R.id.connect_loopback_button);
+    connectLoopbackButton.setOnClickListener(connectListener);
+  }
+
+  @Override
+  public boolean onCreateOptionsMenu(Menu menu) {
+    getMenuInflater().inflate(R.menu.connect_menu, menu);
+    return true;
+  }
+
+  @Override
+  public boolean onOptionsItemSelected(MenuItem item) {
+    // Handle presses on the action bar items.
+    if (item.getItemId() == R.id.action_settings) {
+      Intent intent = new Intent(this, SettingsActivity.class);
+      startActivity(intent);
+      return true;
+    } else {
+      return super.onOptionsItemSelected(item);
+    }
+  }
+
+  @Override
+  public void onPause() {
+    super.onPause();
+    String room = roomEditText.getText().toString();
+    String roomListJson = new JSONArray(roomList).toString();
+    SharedPreferences.Editor editor = sharedPref.edit();
+    editor.putString(keyprefRoom, room);
+    editor.putString(keyprefRoomList, roomListJson);
+    editor.commit();
+  }
+
+  @Override
+  public void onResume() {
+    super.onResume();
+    String room = sharedPref.getString(keyprefRoom, "");
+    roomEditText.setText(room);
+    roomList = new ArrayList<String>();
+    String roomListJson = sharedPref.getString(keyprefRoomList, null);
+    if (roomListJson != null) {
+      try {
+        JSONArray jsonArray = new JSONArray(roomListJson);
+        for (int i = 0; i < jsonArray.length(); i++) {
+          roomList.add(jsonArray.get(i).toString());
+        }
+      } catch (JSONException e) {
+        Log.e(TAG, "Failed to load room list: " + e.toString());
+      }
+    }
+    adapter = new ArrayAdapter<String>(
+        this, android.R.layout.simple_list_item_1, roomList);
+    roomListView.setAdapter(adapter);
+    if (adapter.getCount() > 0) {
+      roomListView.requestFocus();
+      roomListView.setItemChecked(0, true);
+    }
+  }
+
+  private final OnClickListener connectListener = new OnClickListener() {
+    @Override
+    public void onClick(View view) {
+      boolean loopback = false;
+      if (view.getId() == R.id.connect_loopback_button) {
+        loopback = true;
+      }
+      String url = sharedPref.getString(keyprefUrl,
+          getString(R.string.pref_url_default));
+      if (loopback) {
+        url += "/?debug=loopback";
+      } else {
+        String roomName = getSelectedItem();
+        if (roomName == null) {
+          roomName = roomEditText.getText().toString();
+        }
+        url += "/?r=" + roomName;
+      }
+      String parametersResolution = null;
+      String parametersFps = null;
+      // Add video resolution constraints.
+      String resolution = sharedPref.getString(keyprefResolution,
+          getString(R.string.pref_resolution_default));
+      String[] dimensions = resolution.split("[ x]+");
+      if (dimensions.length == 2) {
+        try {
+          int maxWidth = Integer.parseInt(dimensions[0]);
+          int maxHeight = Integer.parseInt(dimensions[1]);
+          if (maxWidth > 0 && maxHeight > 0) {
+            parametersResolution = "minHeight=" + maxHeight + ",maxHeight=" +
+                maxHeight + ",minWidth=" + maxWidth + ",maxWidth=" + maxWidth;
+          }
+        } catch (NumberFormatException e) {
+          Log.e(TAG, "Wrong video resolution setting: " + resolution);
+        }
+      }
+      // Add camera fps constraints.
+      String fps = sharedPref.getString(keyprefFps,
+          getString(R.string.pref_fps_default));
+      String[] fpsValues = fps.split("[ x]+");
+      if (fpsValues.length == 2) {
+        try {
+          int cameraFps = Integer.parseInt(fpsValues[0]);
+          if (cameraFps > 0) {
+            parametersFps = "minFrameRate=" + cameraFps +
+                ",maxFrameRate=" + cameraFps;
+          }
+        } catch (NumberFormatException e) {
+          Log.e(TAG, "Wrong camera fps setting: " + fps);
+        }
+      }
+      // Modify connection URL.
+      if (parametersResolution != null || parametersFps != null) {
+        url += "&video=";
+        if (parametersResolution != null) {
+          url += parametersResolution;
+          if (parametersFps != null) {
+            url += ",";
+          }
+        }
+        if (parametersFps != null) {
+          url += parametersFps;
+        }
+      } else {
+        if (MediaCodecVideoEncoder.isPlatformSupported()) {
+          url += "&hd=true";
+        }
+      }
+      // TODO(kjellander): Add support for custom parameters to the URL.
+      connectToRoom(url);
+    }
+  };
+
+  private void connectToRoom(String roomUrl) {
+    if (validateUrl(roomUrl)) {
+      Uri url = Uri.parse(roomUrl);
+      Intent intent = new Intent(this, AppRTCDemoActivity.class);
+      intent.setData(url);
+      startActivity(intent);
+    }
+  }
+
+  private boolean validateUrl(String url) {
+    if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url))
+      return true;
+
+    new AlertDialog.Builder(this)
+        .setTitle(getText(R.string.invalid_url_title))
+        .setMessage(getString(R.string.invalid_url_text, url))
+        .setCancelable(false)
+        .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
+            public void onClick(DialogInterface dialog, int id) {
+              dialog.cancel();
+            }
+          }).create().show();
+    return false;
+  }
+
+  private final OnClickListener addRoomListener = new OnClickListener() {
+    @Override
+    public void onClick(View view) {
+      String newRoom = roomEditText.getText().toString();
+      if (newRoom.length() > 0 && !roomList.contains(newRoom)) {
+        adapter.add(newRoom);
+        adapter.notifyDataSetChanged();
+      }
+    }
+  };
+
+  private final OnClickListener removeRoomListener = new OnClickListener() {
+    @Override
+    public void onClick(View view) {
+      String selectedRoom = getSelectedItem();
+      if (selectedRoom != null) {
+        adapter.remove(selectedRoom);
+        adapter.notifyDataSetChanged();
+      }
+    }
+  };
+
+  private String getSelectedItem() {
+    int position = AdapterView.INVALID_POSITION;
+    if (roomListView.getCheckedItemCount() > 0 && adapter.getCount() > 0) {
+      position = roomListView.getCheckedItemPosition();
+      if (position >= adapter.getCount()) {
+        position = AdapterView.INVALID_POSITION;
+      }
+    }
+    if (position != AdapterView.INVALID_POSITION) {
+      return adapter.getItem(position);
+    } else {
+      return null;
+    }
+  }
+
+}
diff --git a/examples/android/src/org/appspot/apprtc/GAEChannelClient.java b/examples/android/src/org/appspot/apprtc/GAEChannelClient.java
index bcc06ab..5fd0a54 100644
--- a/examples/android/src/org/appspot/apprtc/GAEChannelClient.java
+++ b/examples/android/src/org/appspot/apprtc/GAEChannelClient.java
@@ -51,15 +51,12 @@
 
   /**
    * Callback interface for messages delivered on the Google AppEngine channel.
-   *
-   * Methods are guaranteed to be invoked on the UI thread of |activity| passed
-   * to GAEChannelClient's constructor.
    */
   public interface GAEMessageHandler {
     public void onOpen();
-    public void onMessage(String data);
+    public void onMessage(final String data);
     public void onClose();
-    public void onError(int code, String description);
+    public void onError(final int code, final String description);
   }
 
   /** Asynchronously open an AppEngine channel. */
@@ -83,8 +80,7 @@
               ", desc: " + description);
         }
       });
-    proxyingMessageHandler =
-        new ProxyingMessageHandler(activity, handler, token);
+    proxyingMessageHandler = new ProxyingMessageHandler(handler, token);
     webView.addJavascriptInterface(
         proxyingMessageHandler, "androidMessageHandler");
     webView.loadUrl("file:///android_asset/channel.html");
@@ -102,72 +98,52 @@
   }
 
   // Helper class for proxying callbacks from the Java<->JS interaction
-  // (private, background) thread to the Activity's UI thread.
+  // (private, background) thread.
   private static class ProxyingMessageHandler {
-    private final Activity activity;
     private final GAEMessageHandler handler;
-    private final boolean[] disconnected = { false };
+    private boolean disconnected = false;
     private final String token;
 
-    public
-     ProxyingMessageHandler(Activity activity, GAEMessageHandler handler,
-                            String token) {
-      this.activity = activity;
+    public ProxyingMessageHandler(GAEMessageHandler handler, String token) {
       this.handler = handler;
       this.token = token;
     }
 
     public void disconnect() {
-      disconnected[0] = true;
+      disconnected = true;
     }
 
-    private boolean disconnected() {
-      return disconnected[0];
-    }
-
-    @JavascriptInterface public String getToken() {
+    @JavascriptInterface
+    public String getToken() {
       return token;
     }
 
-    @JavascriptInterface public void onOpen() {
-      activity.runOnUiThread(new Runnable() {
-          public void run() {
-            if (!disconnected()) {
-              handler.onOpen();
-            }
-          }
-        });
+    @JavascriptInterface
+    public void onOpen() {
+      if (!disconnected) {
+        handler.onOpen();
+      }
     }
 
-    @JavascriptInterface public void onMessage(final String data) {
-      activity.runOnUiThread(new Runnable() {
-          public void run() {
-            if (!disconnected()) {
-              handler.onMessage(data);
-            }
-          }
-        });
+    @JavascriptInterface
+    public void onMessage(final String data) {
+      if (!disconnected) {
+        handler.onMessage(data);
+      }
     }
 
-    @JavascriptInterface public void onClose() {
-      activity.runOnUiThread(new Runnable() {
-          public void run() {
-            if (!disconnected()) {
-              handler.onClose();
-            }
-          }
-        });
+    @JavascriptInterface
+    public void onClose() {
+      if (!disconnected) {
+        handler.onClose();
+      }
     }
 
-    @JavascriptInterface public void onError(
-        final int code, final String description) {
-      activity.runOnUiThread(new Runnable() {
-          public void run() {
-            if (!disconnected()) {
-              handler.onError(code, description);
-            }
-          }
-        });
+    @JavascriptInterface
+    public void onError(final int code, final String description) {
+      if (!disconnected) {
+        handler.onError(code, description);
+      }
     }
   }
 }
diff --git a/examples/android/src/org/appspot/apprtc/GAERTCClient.java b/examples/android/src/org/appspot/apprtc/GAERTCClient.java
index 1d1f817..c3d9564 100644
--- a/examples/android/src/org/appspot/apprtc/GAERTCClient.java
+++ b/examples/android/src/org/appspot/apprtc/GAERTCClient.java
@@ -29,7 +29,6 @@
 import android.app.Activity;
 import android.os.AsyncTask;
 import android.util.Log;
-import android.webkit.JavascriptInterface;
 
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -41,7 +40,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.LinkedList;
@@ -83,11 +81,6 @@
    */
   @Override
   public void connectToRoom(String url) {
-    while (url.indexOf('?') < 0) {
-      // Keep redirecting until we get a room number.
-      (new RedirectResolver()).execute(url);
-      return;  // RedirectResolver above calls us back with the next URL.
-    }
     (new RoomParameterGetter()).execute(url);
   }
 
@@ -97,6 +90,7 @@
   @Override
   public void disconnect() {
     if (channelClient != null) {
+      Log.d(TAG, "Closing GAE Channel.");
       sendMessage("{\"type\": \"bye\"}");
       channelClient.close();
       channelClient = null;
@@ -151,68 +145,36 @@
     }
   }
 
-  // Load the given URL and return the value of the Location header of the
-  // resulting 302 response.  If the result is not a 302, throws.
-  private class RedirectResolver extends AsyncTask<String, Void, String> {
-    @Override
-    protected String doInBackground(String... urls) {
-      if (urls.length != 1) {
-        throw new RuntimeException("Must be called with a single URL");
-      }
-      try {
-        return followRedirect(urls[0]);
-      } catch (IOException e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    @Override
-    protected void onPostExecute(String url) {
-      connectToRoom(url);
-    }
-
-    private String followRedirect(String url) throws IOException {
-      HttpURLConnection connection = (HttpURLConnection)
-          new URL(url).openConnection();
-      connection.setInstanceFollowRedirects(false);
-      int code = connection.getResponseCode();
-      if (code != HttpURLConnection.HTTP_MOVED_TEMP) {
-        throw new IOException("Unexpected response: " + code + " for " + url +
-            ", with contents: " + drainStream(connection.getInputStream()));
-      }
-      int n = 0;
-      String name, value;
-      while ((name = connection.getHeaderFieldKey(n)) != null) {
-        value = connection.getHeaderField(n);
-        if (name.equals("Location")) {
-          return value;
-        }
-        ++n;
-      }
-      throw new IOException("Didn't find Location header!");
-    }
-  }
-
   // AsyncTask that converts an AppRTC room URL into the set of signaling
   // parameters to use with that room.
   private class RoomParameterGetter
       extends AsyncTask<String, Void, AppRTCSignalingParameters> {
+    private Exception exception = null;
+
     @Override
     protected AppRTCSignalingParameters doInBackground(String... urls) {
       if (urls.length != 1) {
-        throw new RuntimeException("Must be called with a single URL");
+        exception = new RuntimeException("Must be called with a single URL");
+        return null;
       }
       try {
+        exception = null;
         return getParametersForRoomUrl(urls[0]);
       } catch (JSONException e) {
-        throw new RuntimeException(e);
+        exception = e;
       } catch (IOException e) {
-        throw new RuntimeException(e);
+        exception = e;
       }
+      return null;
     }
 
     @Override
     protected void onPostExecute(AppRTCSignalingParameters params) {
+      if (exception != null) {
+        Log.e(TAG, "Room connection error: " + exception.toString());
+        events.onChannelError(0, exception.getMessage());
+        return;
+      }
       channelClient =
           new GAEChannelClient(activity, channelToken, gaeHandler);
       synchronized (sendQueue) {
@@ -445,42 +407,67 @@
   // Implementation detail: handler for receiving GAE messages and dispatching
   // them appropriately.
   private class GAEHandler implements GAEChannelClient.GAEMessageHandler {
-    @JavascriptInterface public void onOpen() {
-      events.onChannelOpen();
-    }
+    private boolean channelOpen = false;
 
-    @JavascriptInterface public void onMessage(String msg) {
-      Log.d(TAG, "RECEIVE: " + msg);
-      try {
-        JSONObject json = new JSONObject(msg);
-        String type = (String) json.get("type");
-        if (type.equals("candidate")) {
-          IceCandidate candidate = new IceCandidate(
-              (String) json.get("id"),
-              json.getInt("label"),
-              (String) json.get("candidate"));
-          events.onRemoteIceCandidate(candidate);
-        } else if (type.equals("answer") || type.equals("offer")) {
-          SessionDescription sdp = new SessionDescription(
-              SessionDescription.Type.fromCanonicalForm(type),
-              (String)json.get("sdp"));
-          events.onRemoteDescription(sdp);
-        } else if (type.equals("bye")) {
-          events.onChannelClose();
-        } else {
-          throw new RuntimeException("Unexpected message: " + msg);
+    public void onOpen() {
+      activity.runOnUiThread(new Runnable() {
+        public void run() {
+          events.onChannelOpen();
+          channelOpen = true;
         }
-      } catch (JSONException e) {
-        throw new RuntimeException(e);
-      }
+      });
     }
 
-    @JavascriptInterface public void onClose() {
-      events.onChannelClose();
+    public void onMessage(final String msg) {
+      Log.d(TAG, "RECEIVE: " + msg);
+      activity.runOnUiThread(new Runnable() {
+        public void run() {
+          if (!channelOpen) {
+            return;
+          }
+          try {
+            JSONObject json = new JSONObject(msg);
+            String type = (String) json.get("type");
+            if (type.equals("candidate")) {
+              IceCandidate candidate = new IceCandidate(
+                  (String) json.get("id"),
+                  json.getInt("label"),
+                  (String) json.get("candidate"));
+              events.onRemoteIceCandidate(candidate);
+            } else if (type.equals("answer") || type.equals("offer")) {
+              SessionDescription sdp = new SessionDescription(
+                  SessionDescription.Type.fromCanonicalForm(type),
+                  (String)json.get("sdp"));
+              events.onRemoteDescription(sdp);
+            } else if (type.equals("bye")) {
+              events.onChannelClose();
+            } else {
+              events.onChannelError(1, "Unexpected channel message: " + msg);
+            }
+          } catch (JSONException e) {
+            events.onChannelError(1, "Channel message JSON parsing error: " +
+                e.toString());
+          }
+        }
+      });
     }
 
-    @JavascriptInterface public void onError(int code, String description) {
-      events.onChannelError(code, description);
+    public void onClose() {
+      activity.runOnUiThread(new Runnable() {
+        public void run() {
+          events.onChannelClose();
+          channelOpen = false;
+        }
+      });
+    }
+
+    public void onError(final int code, final String description) {
+      activity.runOnUiThread(new Runnable() {
+        public void run() {
+          events.onChannelError(code, description);
+          channelOpen = false;
+        }
+      });
     }
   }
 
diff --git a/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java b/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java
index 0376000..9c917bb 100644
--- a/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java
+++ b/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java
@@ -37,6 +37,7 @@
 import org.webrtc.MediaStream;
 import org.webrtc.MediaStreamTrack;
 import org.webrtc.PeerConnection;
+import org.webrtc.MediaConstraints.KeyValuePair;
 import org.webrtc.PeerConnection.IceConnectionState;
 import org.webrtc.PeerConnectionFactory;
 import org.webrtc.SdpObserver;
@@ -60,13 +61,17 @@
   private boolean videoSourceStopped;
   private final PCObserver pcObserver = new PCObserver();
   private final SDPObserver sdpObserver = new SDPObserver();
+  private final VideoRenderer.Callbacks localRender;
   private final VideoRenderer.Callbacks remoteRender;
   private LinkedList<IceCandidate> queuedRemoteCandidates =
       new LinkedList<IceCandidate>();
   private MediaConstraints sdpMediaConstraints;
+  private MediaConstraints videoConstraints;
   private PeerConnectionEvents events;
   private boolean isInitiator;
+  private boolean useFrontFacingCamera = true;
   private SessionDescription localSdp = null; // either offer or answer SDP
+  private MediaStream videoMediaStream = null;
 
   public PeerConnectionClient(
       Activity activity,
@@ -75,6 +80,7 @@
       AppRTCSignalingParameters appRtcParameters,
       PeerConnectionEvents events) {
     this.activity = activity;
+    this.localRender = localRender;
     this.remoteRender = remoteRender;
     this.events = events;
     isInitiator = appRtcParameters.initiator;
@@ -84,9 +90,9 @@
         "OfferToReceiveAudio", "true"));
     sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
         "OfferToReceiveVideo", "true"));
+    videoConstraints = appRtcParameters.videoConstraints;
 
     factory = new PeerConnectionFactory();
-
     MediaConstraints pcConstraints = appRtcParameters.pcConstraints;
     pcConstraints.optional.add(
         new MediaConstraints.KeyValuePair("RtpDataChannels", "true"));
@@ -101,23 +107,47 @@
     //     EnumSet.of(Logging.TraceLevel.TRACE_ALL),
     //     Logging.Severity.LS_SENSITIVE);
 
-    Log.d(TAG, "Creating local video source");
-    MediaStream lMS = factory.createLocalMediaStream("ARDAMS");
-    if (appRtcParameters.videoConstraints != null) {
-      VideoCapturer capturer = getVideoCapturer();
-      videoSource = factory.createVideoSource(
-          capturer, appRtcParameters.videoConstraints);
-      VideoTrack videoTrack =
-          factory.createVideoTrack("ARDAMSv0", videoSource);
-      videoTrack.addRenderer(new VideoRenderer(localRender));
-      lMS.addTrack(videoTrack);
+    if (videoConstraints != null) {
+      videoMediaStream = factory.createLocalMediaStream("ARDAMSVideo");
+      videoMediaStream.addTrack(createVideoTrack(useFrontFacingCamera));
+      pc.addStream(videoMediaStream);
     }
+
     if (appRtcParameters.audioConstraints != null) {
+      MediaStream lMS = factory.createLocalMediaStream("ARDAMSAudio");
       lMS.addTrack(factory.createAudioTrack(
           "ARDAMSa0",
           factory.createAudioSource(appRtcParameters.audioConstraints)));
+      pc.addStream(lMS);
     }
-    pc.addStream(lMS, new MediaConstraints());
+  }
+
+  public boolean isHDVideo() {
+    if (videoConstraints == null) {
+      return false;
+    }
+    int minWidth = 0;
+    int minHeight = 0;
+    for (KeyValuePair keyValuePair : videoConstraints.mandatory) {
+      if (keyValuePair.getKey().equals("minWidth")) {
+        try {
+          minWidth = Integer.parseInt(keyValuePair.getValue());
+        } catch (NumberFormatException e) {
+          Log.e(TAG, "Can not parse video width from video constraints");
+        }
+      } else if (keyValuePair.getKey().equals("minHeight")) {
+        try {
+          minHeight = Integer.parseInt(keyValuePair.getValue());
+        } catch (NumberFormatException e) {
+          Log.e(TAG, "Can not parse video height from video constraints");
+        }
+      }
+    }
+    if (minWidth * minHeight >= 1280 * 720) {
+      return true;
+    } else {
+      return false;
+    }
   }
 
   public boolean getStats(StatsObserver observer, MediaStreamTrack track) {
@@ -125,33 +155,58 @@
   }
 
   public void createOffer() {
-    isInitiator = true;
-    pc.createOffer(sdpObserver, sdpMediaConstraints);
+    activity.runOnUiThread(new Runnable() {
+      public void run() {
+        if (pc != null) {
+          isInitiator = true;
+          pc.createOffer(sdpObserver, sdpMediaConstraints);
+        }
+      }
+    });
   }
 
   public void createAnswer() {
-    isInitiator = false;
-    pc.createAnswer(sdpObserver, sdpMediaConstraints);
+    activity.runOnUiThread(new Runnable() {
+      public void run() {
+        if (pc != null) {
+          isInitiator = false;
+          pc.createAnswer(sdpObserver, sdpMediaConstraints);
+        }
+      }
+    });
   }
 
 
-  public void addRemoteIceCandidate(IceCandidate candidate) {
-    if (queuedRemoteCandidates != null) {
-      queuedRemoteCandidates.add(candidate);
-    } else {
-      pc.addIceCandidate(candidate);
-    }
+  public void addRemoteIceCandidate(final IceCandidate candidate) {
+    activity.runOnUiThread(new Runnable() {
+      public void run() {
+        if (pc != null) {
+          if (queuedRemoteCandidates != null) {
+            queuedRemoteCandidates.add(candidate);
+          } else {
+            pc.addIceCandidate(candidate);
+          }
+        }
+      }
+    });
   }
 
-  public void setRemoteDescription(SessionDescription sdp) {
-    SessionDescription sdpISAC = new SessionDescription(
-        sdp.type, preferISAC(sdp.description));
-    Log.d(TAG, "Set remote SDP");
-    pc.setRemoteDescription(sdpObserver, sdpISAC);
+  public void setRemoteDescription(final SessionDescription sdp) {
+    activity.runOnUiThread(new Runnable() {
+      public void run() {
+        if (pc != null) {
+          SessionDescription sdpISAC = new SessionDescription(
+              sdp.type, preferISAC(sdp.description));
+          Log.d(TAG, "Set remote SDP");
+          pc.setRemoteDescription(sdpObserver, sdpISAC);
+        }
+      }
+    });
   }
 
   public void stopVideoSource() {
     if (videoSource != null) {
+      Log.d(TAG, "Stop video source.");
       videoSource.stop();
       videoSourceStopped = true;
     }
@@ -159,24 +214,30 @@
 
   public void startVideoSource() {
     if (videoSource != null && videoSourceStopped) {
+      Log.d(TAG, "Restart video source.");
       videoSource.restart();
       videoSourceStopped = false;
     }
   }
 
   public void close() {
-    if (pc != null) {
-      pc.dispose();
-      pc = null;
-    }
-    if (videoSource != null) {
-      videoSource.dispose();
-      videoSource = null;
-    }
-    if (factory != null) {
-      factory.dispose();
-      factory = null;
-    }
+    activity.runOnUiThread(new Runnable() {
+      public void run() {
+        Log.d(TAG, "Closing peer connection.");
+        if (pc != null) {
+          pc.dispose();
+          pc = null;
+        }
+        if (videoSource != null) {
+          videoSource.dispose();
+          videoSource = null;
+        }
+        if (factory != null) {
+          factory.dispose();
+          factory = null;
+        }
+      }
+    });
   }
 
   /**
@@ -198,15 +259,38 @@
      * CONNECTED).
      */
     public void onIceConnected();
+
+    /**
+     * Callback fired once connection is closed (IceConnectionState is
+     * DISCONNECTED).
+     */
+    public void onIceDisconnected();
+
+    /**
+     * Callback fired once peer connection error happened.
+     */
+    public void onPeerConnectionError(String description);
+  }
+
+  private void reportError(final String errorMessage) {
+    activity.runOnUiThread(new Runnable() {
+      public void run() {
+        events.onPeerConnectionError(errorMessage);
+      }
+    });
   }
 
   // Cycle through likely device names for the camera and return the first
   // capturer that works, or crash if none do.
-  private VideoCapturer getVideoCapturer() {
+  private VideoCapturer getVideoCapturer(boolean useFrontFacing) {
     String[] cameraFacing = { "front", "back" };
-    int[] cameraIndex = { 0, 1 };
-    int[] cameraOrientation = { 0, 90, 180, 270 };
+    if (!useFrontFacing) {
+      cameraFacing[0] = "back";
+      cameraFacing[1] = "front";
+    }
     for (String facing : cameraFacing) {
+      int[] cameraIndex = { 0, 1 };
+      int[] cameraOrientation = { 0, 90, 180, 270 };
       for (int index : cameraIndex) {
         for (int orientation : cameraOrientation) {
           String name = "Camera " + index + ", Facing " + facing +
@@ -219,13 +303,30 @@
         }
       }
     }
-    throw new RuntimeException("Failed to open capturer");
+    reportError("Failed to open capturer");
+    return null;
+  }
+
+  private VideoTrack createVideoTrack(boolean frontFacing) {
+    VideoCapturer capturer = getVideoCapturer(frontFacing);
+    if (videoSource != null) {
+      videoSource.stop();
+      videoSource.dispose();
+    }
+
+    videoSource = factory.createVideoSource(
+        capturer, videoConstraints);
+    String trackExtension = frontFacing ? "frontFacing" : "backFacing";
+    VideoTrack videoTrack =
+        factory.createVideoTrack("ARDAMSv0" + trackExtension, videoSource);
+    videoTrack.addRenderer(new VideoRenderer(localRender));
+    return videoTrack;
   }
 
   // Poor-man's assert(): die with |msg| unless |condition| is true.
-  private static void abortUnless(boolean condition, String msg) {
+  private void abortUnless(boolean condition, String msg) {
     if (!condition) {
-      throw new RuntimeException(msg);
+      reportError(msg);
     }
   }
 
@@ -285,24 +386,58 @@
     queuedRemoteCandidates = null;
   }
 
+  public void switchCamera() {
+    if (videoConstraints == null)
+      return;  // No video is sent.
+
+    if (pc.signalingState() != PeerConnection.SignalingState.STABLE) {
+      Log.e(TAG, "Switching camera during negotiation is not handled.");
+      return;
+    }
+
+    pc.removeStream(videoMediaStream);
+    VideoTrack currentTrack = videoMediaStream.videoTracks.get(0);
+    videoMediaStream.removeTrack(currentTrack);
+
+    String trackId = currentTrack.id();
+    // On Android, there can only be one camera open at the time and we
+    // need to release our implicit references to the videoSource before the
+    // PeerConnectionFactory is released. Since createVideoTrack creates a new
+    // videoSource and frees the old one, we need to release the track here.
+    currentTrack.dispose();
+
+    useFrontFacingCamera = !useFrontFacingCamera;
+    VideoTrack newTrack = createVideoTrack(useFrontFacingCamera);
+    videoMediaStream.addTrack(newTrack);
+    pc.addStream(videoMediaStream);
+
+    SessionDescription remoteDesc = pc.getRemoteDescription();
+    if (localSdp == null || remoteDesc == null) {
+      Log.d(TAG, "Switching camera before the negotiation started.");
+      return;
+    }
+
+    localSdp = new SessionDescription(localSdp.type,
+        localSdp.description.replaceAll(trackId, newTrack.id()));
+
+    if (isInitiator) {
+      pc.setLocalDescription(new SwitchCameraSdbObserver(), localSdp);
+      pc.setRemoteDescription(new SwitchCameraSdbObserver(), remoteDesc);
+    } else {
+      pc.setRemoteDescription(new SwitchCameraSdbObserver(), remoteDesc);
+      pc.setLocalDescription(new SwitchCameraSdbObserver(), localSdp);
+    }
+  }
+
   // Implementation detail: observe ICE & stream changes and react accordingly.
   private class PCObserver implements PeerConnection.Observer {
     @Override
     public void onIceCandidate(final IceCandidate candidate){
       activity.runOnUiThread(new Runnable() {
-          public void run() {
-            events.onIceCandidate(candidate);
-          }
-        });
-    }
-
-    @Override
-    public void onError(){
-      activity.runOnUiThread(new Runnable() {
-          public void run() {
-            throw new RuntimeException("PeerConnection error!");
-          }
-        });
+        public void run() {
+          events.onIceCandidate(candidate);
+        }
+      });
     }
 
     @Override
@@ -321,47 +456,50 @@
             events.onIceConnected();
           }
         });
+      } else if (newState == IceConnectionState.DISCONNECTED) {
+        activity.runOnUiThread(new Runnable() {
+          public void run() {
+            events.onIceDisconnected();
+          }
+        });
+      } else if (newState == IceConnectionState.FAILED) {
+        reportError("ICE connection failed.");
       }
     }
 
     @Override
     public void onIceGatheringChange(
-        PeerConnection.IceGatheringState newState) {
+      PeerConnection.IceGatheringState newState) {
     }
 
     @Override
     public void onAddStream(final MediaStream stream){
       activity.runOnUiThread(new Runnable() {
-          public void run() {
-            abortUnless(stream.audioTracks.size() <= 1 &&
-                stream.videoTracks.size() <= 1,
-                "Weird-looking stream: " + stream);
-            if (stream.videoTracks.size() == 1) {
-              stream.videoTracks.get(0).addRenderer(
-                  new VideoRenderer(remoteRender));
-            }
+        public void run() {
+          abortUnless(stream.audioTracks.size() <= 1 &&
+              stream.videoTracks.size() <= 1,
+              "Weird-looking stream: " + stream);
+          if (stream.videoTracks.size() == 1) {
+            stream.videoTracks.get(0).addRenderer(
+                new VideoRenderer(remoteRender));
           }
-        });
+        }
+      });
     }
 
     @Override
     public void onRemoveStream(final MediaStream stream){
       activity.runOnUiThread(new Runnable() {
-          public void run() {
-            stream.videoTracks.get(0).dispose();
-          }
-        });
+        public void run() {
+          stream.videoTracks.get(0).dispose();
+        }
+      });
     }
 
     @Override
     public void onDataChannel(final DataChannel dc) {
-      activity.runOnUiThread(new Runnable() {
-          public void run() {
-            throw new RuntimeException(
-                "AppRTC doesn't use data channels, but got: " + dc.label() +
-                " anyway!");
-          }
-        });
+      reportError("AppRTC doesn't use data channels, but got: " + dc.label() +
+          " anyway!");
     }
 
     @Override
@@ -381,65 +519,82 @@
           origSdp.type, preferISAC(origSdp.description));
       localSdp = sdp;
       activity.runOnUiThread(new Runnable() {
-          public void run() {
+        public void run() {
+          if (pc != null) {
             Log.d(TAG, "Set local SDP from " + sdp.type);
             pc.setLocalDescription(sdpObserver, sdp);
           }
-        });
+        }
+      });
     }
 
     @Override
     public void onSetSuccess() {
       activity.runOnUiThread(new Runnable() {
-          public void run() {
-            if (isInitiator) {
-              // For offering peer connection we first create offer and set
-              // local SDP, then after receiving answer set remote SDP.
-              if (pc.getRemoteDescription() == null) {
-                // We've just set our local SDP so time to send it.
-                Log.d(TAG, "Local SDP set succesfully");
-                events.onLocalDescription(localSdp);
-              } else {
-                // We've just set remote description,
-                // so drain remote ICE candidates.
-                Log.d(TAG, "Remote SDP set succesfully");
-                drainRemoteCandidates();
-              }
+        public void run() {
+          if (pc == null) {
+            return;
+          }
+          if (isInitiator) {
+            // For offering peer connection we first create offer and set
+            // local SDP, then after receiving answer set remote SDP.
+            if (pc.getRemoteDescription() == null) {
+              // We've just set our local SDP so time to send it.
+              Log.d(TAG, "Local SDP set succesfully");
+              events.onLocalDescription(localSdp);
             } else {
-              // For answering peer connection we set remote SDP and then
-              // create answer and set local SDP.
-              if (pc.getLocalDescription() != null) {
-                // We've just set our local SDP so time to send it and drain
-                // remote ICE candidates.
-                Log.d(TAG, "Local SDP set succesfully");
-                events.onLocalDescription(localSdp);
-                drainRemoteCandidates();
-              } else {
-                // We've just set remote SDP - do nothing for now -
-                // answer will be created soon.
-                Log.d(TAG, "Remote SDP set succesfully");
-              }
+              // We've just set remote description,
+              // so drain remote ICE candidates.
+              Log.d(TAG, "Remote SDP set succesfully");
+              drainRemoteCandidates();
+            }
+          } else {
+            // For answering peer connection we set remote SDP and then
+            // create answer and set local SDP.
+            if (pc.getLocalDescription() != null) {
+              // We've just set our local SDP so time to send it and drain
+              // remote ICE candidates.
+              Log.d(TAG, "Local SDP set succesfully");
+              events.onLocalDescription(localSdp);
+              drainRemoteCandidates();
+            } else {
+              // We've just set remote SDP - do nothing for now -
+              // answer will be created soon.
+              Log.d(TAG, "Remote SDP set succesfully");
             }
           }
-        });
+        }
+      });
     }
 
     @Override
     public void onCreateFailure(final String error) {
-      activity.runOnUiThread(new Runnable() {
-          public void run() {
-            throw new RuntimeException("createSDP error: " + error);
-          }
-        });
+      reportError("createSDP error: " + error);
     }
 
     @Override
     public void onSetFailure(final String error) {
-      activity.runOnUiThread(new Runnable() {
-          public void run() {
-            throw new RuntimeException("setSDP error: " + error);
-          }
-        });
+      reportError("setSDP error: " + error);
+    }
+  }
+
+  private class SwitchCameraSdbObserver implements SdpObserver {
+    @Override
+    public void onCreateSuccess(SessionDescription sdp) {
+    }
+
+    @Override
+    public void onSetSuccess() {
+      Log.d(TAG, "Camera switch SDP set succesfully");
+    }
+
+    @Override
+    public void onCreateFailure(final String error) {
+    }
+
+    @Override
+    public void onSetFailure(final String error) {
+      reportError("setSDP error while switching camera: " + error);
     }
   }
 }
diff --git a/examples/android/src/org/appspot/apprtc/SettingsActivity.java b/examples/android/src/org/appspot/apprtc/SettingsActivity.java
new file mode 100644
index 0000000..2354ceb
--- /dev/null
+++ b/examples/android/src/org/appspot/apprtc/SettingsActivity.java
@@ -0,0 +1,92 @@
+/*
+ * libjingle
+ * Copyright 2014, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.appspot.apprtc;
+
+import android.app.Activity;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.os.Bundle;
+import android.preference.Preference;
+
+public class SettingsActivity extends Activity
+    implements OnSharedPreferenceChangeListener{
+  private SettingsFragment settingsFragment;
+  private String keyprefUrl;
+  private String keyprefResolution;
+  private String keyprefFps;
+
+  @Override
+  protected void onCreate(Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+    keyprefUrl = getString(R.string.pref_url_key);
+    keyprefResolution = getString(R.string.pref_resolution_key);
+    keyprefFps = getString(R.string.pref_fps_key);
+
+    // Display the fragment as the main content.
+    settingsFragment = new SettingsFragment();
+    getFragmentManager().beginTransaction()
+        .replace(android.R.id.content, settingsFragment)
+        .commit();
+  }
+
+  @Override
+  protected void onResume() {
+    super.onResume();
+    // Set summary to be the user-description for the selected value
+    SharedPreferences sharedPreferences =
+        settingsFragment.getPreferenceScreen().getSharedPreferences();
+    sharedPreferences.registerOnSharedPreferenceChangeListener(this);
+    updateSummary(sharedPreferences, keyprefUrl);
+    updateSummary(sharedPreferences, keyprefResolution);
+    updateSummary(sharedPreferences, keyprefFps);
+  }
+
+  @Override
+  protected void onPause() {
+    super.onPause();
+    SharedPreferences sharedPreferences =
+        settingsFragment.getPreferenceScreen().getSharedPreferences();
+    sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
+  }
+
+  @Override
+  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+      String key) {
+    if (key.equals(keyprefUrl) || key.equals(keyprefResolution) ||
+        key.equals(keyprefFps)) {
+      updateSummary(sharedPreferences, key);
+    }
+  }
+
+  private void updateSummary(SharedPreferences sharedPreferences, String key) {
+    Preference updatedPref = settingsFragment.findPreference(key);
+    // Set summary to be the user-description for the selected value
+    updatedPref.setSummary(sharedPreferences.getString(key, ""));
+  }
+
+}
diff --git a/examples/android/src/org/appspot/apprtc/AppRTCGLView.java b/examples/android/src/org/appspot/apprtc/SettingsFragment.java
similarity index 65%
rename from examples/android/src/org/appspot/apprtc/AppRTCGLView.java
rename to examples/android/src/org/appspot/apprtc/SettingsFragment.java
index e622ab9..ec4b704 100644
--- a/examples/android/src/org/appspot/apprtc/AppRTCGLView.java
+++ b/examples/android/src/org/appspot/apprtc/SettingsFragment.java
@@ -27,32 +27,15 @@
 
 package org.appspot.apprtc;
 
-import android.content.Context;
-import android.graphics.Point;
-import android.opengl.GLSurfaceView;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
 
-public class AppRTCGLView extends GLSurfaceView {
-  private Point screenDimensions;
-
-  public AppRTCGLView(Context c, Point screenDimensions) {
-    super(c);
-    this.screenDimensions = screenDimensions;
-  }
-
-  public void updateDisplaySize(Point screenDimensions) {
-    this.screenDimensions = screenDimensions;
-  }
+public class SettingsFragment extends PreferenceFragment {
 
   @Override
-  protected void onMeasure(int unusedX, int unusedY) {
-    // Go big or go home!
-    setMeasuredDimension(screenDimensions.x, screenDimensions.y);
-  }
-
-  @Override
-  protected void onAttachedToWindow() {
-    super.onAttachedToWindow();
-    setSystemUiVisibility(SYSTEM_UI_FLAG_HIDE_NAVIGATION |
-        SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+  public void onCreate(Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+    // Load the preferences from an XML resource
+    addPreferencesFromResource(R.xml.preferences);
   }
 }
diff --git a/examples/call/call_main.cc b/examples/call/call_main.cc
index cb309dc..638f6f9 100644
--- a/examples/call/call_main.cc
+++ b/examples/call/call_main.cc
@@ -41,13 +41,13 @@
 #include "talk/examples/call/callclient.h"
 #include "talk/examples/call/console.h"
 #include "talk/examples/call/mediaenginefactory.h"
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 #include "talk/session/media/mediasessionclient.h"
 #include "talk/session/media/srtpfilter.h"
-#include "talk/xmpp/xmppauth.h"
-#include "talk/xmpp/xmppclientsettings.h"
-#include "talk/xmpp/xmpppump.h"
-#include "talk/xmpp/xmppsocket.h"
+#include "webrtc/libjingle/xmpp/xmppauth.h"
+#include "webrtc/libjingle/xmpp/xmppclientsettings.h"
+#include "webrtc/libjingle/xmpp/xmpppump.h"
+#include "webrtc/libjingle/xmpp/xmppsocket.h"
 #include "webrtc/base/pathutils.h"
 #include "webrtc/base/ssladapter.h"
 #include "webrtc/base/stream.h"
diff --git a/examples/call/callclient.cc b/examples/call/callclient.cc
index b31e24a..866133e 100644
--- a/examples/call/callclient.cc
+++ b/examples/call/callclient.cc
@@ -53,17 +53,17 @@
 #include "talk/media/base/videorenderer.h"
 #include "talk/media/devices/devicemanager.h"
 #include "talk/media/devices/videorendererfactory.h"
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/p2p/client/basicportallocator.h"
-#include "talk/p2p/client/sessionmanagertask.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/client/sessionmanagertask.h"
 #include "talk/session/media/mediamessages.h"
 #include "talk/session/media/mediasessionclient.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/hangoutpubsubclient.h"
-#include "talk/xmpp/mucroomconfigtask.h"
-#include "talk/xmpp/mucroomlookuptask.h"
-#include "talk/xmpp/pingtask.h"
-#include "talk/xmpp/presenceouttask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/hangoutpubsubclient.h"
+#include "webrtc/libjingle/xmpp/mucroomconfigtask.h"
+#include "webrtc/libjingle/xmpp/mucroomlookuptask.h"
+#include "webrtc/libjingle/xmpp/pingtask.h"
+#include "webrtc/libjingle/xmpp/presenceouttask.h"
 
 namespace {
 
diff --git a/examples/call/callclient.h b/examples/call/callclient.h
index 50c584b..075dc6e 100644
--- a/examples/call/callclient.h
+++ b/examples/call/callclient.h
@@ -34,12 +34,12 @@
 
 #include "talk/examples/call/console.h"
 #include "talk/media/base/mediachannel.h"
-#include "talk/p2p/base/session.h"
+#include "webrtc/p2p/base/session.h"
 #include "talk/session/media/mediamessages.h"
 #include "talk/session/media/mediasessionclient.h"
-#include "talk/xmpp/hangoutpubsubclient.h"
-#include "talk/xmpp/presencestatus.h"
-#include "talk/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/hangoutpubsubclient.h"
+#include "webrtc/libjingle/xmpp/presencestatus.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sslidentity.h"
 
diff --git a/examples/call/callclient_unittest.cc b/examples/call/callclient_unittest.cc
index d11580e..256853a 100644
--- a/examples/call/callclient_unittest.cc
+++ b/examples/call/callclient_unittest.cc
@@ -30,7 +30,7 @@
 #include "talk/examples/call/callclient.h"
 #include "talk/media/base/filemediaengine.h"
 #include "talk/media/base/mediaengine.h"
-#include "talk/xmpp/xmppthread.h"
+#include "webrtc/libjingle/xmpp/xmppthread.h"
 #include "webrtc/base/gunit.h"
 
 TEST(CallClientTest, CreateCallClientWithDefaultMediaEngine) {
diff --git a/examples/call/friendinvitesendtask.cc b/examples/call/friendinvitesendtask.cc
index dae1006..e2b8dde 100644
--- a/examples/call/friendinvitesendtask.cc
+++ b/examples/call/friendinvitesendtask.cc
@@ -26,7 +26,7 @@
  */
 
 #include "talk/examples/call/friendinvitesendtask.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 
 namespace buzz {
 
diff --git a/examples/call/friendinvitesendtask.h b/examples/call/friendinvitesendtask.h
index 625f077..2928452 100644
--- a/examples/call/friendinvitesendtask.h
+++ b/examples/call/friendinvitesendtask.h
@@ -28,8 +28,8 @@
 #ifndef _FRIENDINVITESENDTASK_H_
 #define _FRIENDINVITESENDTASK_H_
 
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/examples/call/muc.h b/examples/call/muc.h
index 0e937ca..9be192f 100644
--- a/examples/call/muc.h
+++ b/examples/call/muc.h
@@ -29,8 +29,8 @@
 #define _MUC_H_
 
 #include <map>
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/presencestatus.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/presencestatus.h"
 
 namespace buzz {
 
diff --git a/examples/call/mucinviterecvtask.cc b/examples/call/mucinviterecvtask.cc
index e32456f..32de8fe 100644
--- a/examples/call/mucinviterecvtask.cc
+++ b/examples/call/mucinviterecvtask.cc
@@ -26,7 +26,7 @@
  */
 
 #include "talk/examples/call/mucinviterecvtask.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 
 namespace buzz {
 
diff --git a/examples/call/mucinviterecvtask.h b/examples/call/mucinviterecvtask.h
index ddfd6be..0466c94 100644
--- a/examples/call/mucinviterecvtask.h
+++ b/examples/call/mucinviterecvtask.h
@@ -30,8 +30,8 @@
 
 #include <vector>
 
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/sigslot.h"
 
 namespace buzz {
diff --git a/examples/call/mucinvitesendtask.cc b/examples/call/mucinvitesendtask.cc
index d648fef..2299b78 100644
--- a/examples/call/mucinvitesendtask.cc
+++ b/examples/call/mucinvitesendtask.cc
@@ -26,8 +26,8 @@
  */
 
 #include "talk/examples/call/mucinvitesendtask.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
 
 namespace buzz {
 
diff --git a/examples/call/mucinvitesendtask.h b/examples/call/mucinvitesendtask.h
index 3ae74c1..673efb0 100644
--- a/examples/call/mucinvitesendtask.h
+++ b/examples/call/mucinvitesendtask.h
@@ -29,8 +29,8 @@
 #define _MUCINVITESENDTASK_H_
 
 #include "talk/examples/call/muc.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/examples/call/presencepushtask.cc b/examples/call/presencepushtask.cc
index b598eb6..8d8dca8 100644
--- a/examples/call/presencepushtask.cc
+++ b/examples/call/presencepushtask.cc
@@ -28,7 +28,7 @@
 #include "talk/examples/call/presencepushtask.h"
 
 #include "talk/examples/call/muc.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/stringencode.h"
 
 
diff --git a/examples/call/presencepushtask.h b/examples/call/presencepushtask.h
index c13a4f5..e3d3268 100644
--- a/examples/call/presencepushtask.h
+++ b/examples/call/presencepushtask.h
@@ -31,9 +31,9 @@
 #include <vector>
 
 #include "talk/examples/call/callclient.h"
-#include "talk/xmpp/presencestatus.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/presencestatus.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/sigslot.h"
 
 namespace buzz {
diff --git a/examples/login/login_main.cc b/examples/login/login_main.cc
index bfe12af..581c986 100644
--- a/examples/login/login_main.cc
+++ b/examples/login/login_main.cc
@@ -29,10 +29,10 @@
 
 #include <iostream>
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/xmppclientsettings.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmppthread.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/xmppclientsettings.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmppthread.h"
 #include "webrtc/base/thread.h"
 
 int main(int argc, char **argv) {
diff --git a/examples/objc/AppRTCDemo/APPRTCConnectionManager.m b/examples/objc/AppRTCDemo/APPRTCConnectionManager.m
index b411a62..9a39528 100644
--- a/examples/objc/AppRTCDemo/APPRTCConnectionManager.m
+++ b/examples/objc/AppRTCDemo/APPRTCConnectionManager.m
@@ -170,7 +170,7 @@
 #endif
 
   [lms addAudioTrack:[self.peerConnectionFactory audioTrackWithID:@"ARDAMSa0"]];
-  [self.peerConnection addStream:lms constraints:constraints];
+  [self.peerConnection addStream:lms];
   [self.logger logMessage:@"onICEServers - added local stream."];
 }
 
@@ -243,16 +243,6 @@
 
 #pragma mark - RTCPeerConnectionDelegate
 
-- (void)peerConnectionOnError:(RTCPeerConnection*)peerConnection {
-  dispatch_async(dispatch_get_main_queue(), ^{
-    NSString* message = @"PeerConnection error";
-    NSLog(@"%@", message);
-    NSAssert(NO, @"PeerConnection failed.");
-    [self.delegate connectionManager:self
-                 didErrorWithMessage:message];
-  });
-}
-
 - (void)peerConnection:(RTCPeerConnection*)peerConnection
     signalingStateChanged:(RTCSignalingState)stateChanged {
   dispatch_async(dispatch_get_main_queue(), ^{
diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc
index f49aee6..e81f7fc 100644
--- a/examples/peerconnection/client/conductor.cc
+++ b/examples/peerconnection/client/conductor.cc
@@ -137,11 +137,6 @@
 // PeerConnectionObserver implementation.
 //
 
-void Conductor::OnError() {
-  LOG(LS_ERROR) << __FUNCTION__;
-  main_wnd_->QueueUIThreadCallback(PEER_CONNECTION_ERROR, NULL);
-}
-
 // Called when a remote stream is added
 void Conductor::OnAddStream(webrtc::MediaStreamInterface* stream) {
   LOG(INFO) << __FUNCTION__ << " " << stream->label();
@@ -373,7 +368,7 @@
 
   stream->AddTrack(audio_track);
   stream->AddTrack(video_track);
-  if (!peer_connection_->AddStream(stream, NULL)) {
+  if (!peer_connection_->AddStream(stream)) {
     LOG(LS_ERROR) << "Adding stream to PeerConnection failed";
   }
   typedef std::pair<std::string,
@@ -440,10 +435,6 @@
       break;
     }
 
-    case PEER_CONNECTION_ERROR:
-      main_wnd_->MessageBox("Error", "an unknown error occurred", true);
-      break;
-
     case NEW_STREAM_ADDED: {
       webrtc::MediaStreamInterface* stream =
           reinterpret_cast<webrtc::MediaStreamInterface*>(
diff --git a/examples/peerconnection/client/conductor.h b/examples/peerconnection/client/conductor.h
index 0aff531..3ef5253 100644
--- a/examples/peerconnection/client/conductor.h
+++ b/examples/peerconnection/client/conductor.h
@@ -58,7 +58,6 @@
     MEDIA_CHANNELS_INITIALIZED = 1,
     PEER_CONNECTION_CLOSED,
     SEND_MESSAGE_TO_PEER,
-    PEER_CONNECTION_ERROR,
     NEW_STREAM_ADDED,
     STREAM_REMOVED,
   };
@@ -80,11 +79,11 @@
   //
   // PeerConnectionObserver implementation.
   //
-  virtual void OnError();
   virtual void OnStateChange(
       webrtc::PeerConnectionObserver::StateType state_changed) {}
   virtual void OnAddStream(webrtc::MediaStreamInterface* stream);
   virtual void OnRemoveStream(webrtc::MediaStreamInterface* stream);
+  virtual void OnDataChannel(webrtc::DataChannelInterface* channel) {}
   virtual void OnRenegotiationNeeded() {}
   virtual void OnIceChange() {}
   virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate);
diff --git a/examples/relayserver/relayserver_main.cc b/examples/relayserver/relayserver_main.cc
index 1a4ab78..5a8bec3 100644
--- a/examples/relayserver/relayserver_main.cc
+++ b/examples/relayserver/relayserver_main.cc
@@ -27,7 +27,7 @@
 
 #include <iostream>  // NOLINT
 
-#include "talk/p2p/base/relayserver.h"
+#include "webrtc/p2p/base/relayserver.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/thread.h"
 
diff --git a/examples/stunserver/stunserver_main.cc b/examples/stunserver/stunserver_main.cc
index f800f31..3cbed91 100644
--- a/examples/stunserver/stunserver_main.cc
+++ b/examples/stunserver/stunserver_main.cc
@@ -31,7 +31,7 @@
 
 #include <iostream>
 
-#include "talk/p2p/base/stunserver.h"
+#include "webrtc/p2p/base/stunserver.h"
 #include "webrtc/base/thread.h"
 
 using namespace cricket;
diff --git a/examples/turnserver/turnserver_main.cc b/examples/turnserver/turnserver_main.cc
index 607b8cf..692b8a2 100644
--- a/examples/turnserver/turnserver_main.cc
+++ b/examples/turnserver/turnserver_main.cc
@@ -27,8 +27,8 @@
 
 #include <iostream>  // NOLINT
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/turnserver.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/turnserver.h"
 #include "webrtc/base/asyncudpsocket.h"
 #include "webrtc/base/optionsfile.h"
 #include "webrtc/base/stringencode.h"
diff --git a/libjingle.gyp b/libjingle.gyp
index 335a788..803eaa3 100755
--- a/libjingle.gyp
+++ b/libjingle.gyp
@@ -299,7 +299,7 @@
   'targets': [
     {
       'target_name': 'libjingle',
-      'type': 'static_library',
+      'type': 'none',
       'dependencies': [
         '<(DEPTH)/third_party/expat/expat.gyp:expat',
         '<(DEPTH)/third_party/jsoncpp/jsoncpp.gyp:jsoncpp',
@@ -309,81 +309,6 @@
         '<(DEPTH)/third_party/expat/expat.gyp:expat',
         '<(DEPTH)/third_party/jsoncpp/jsoncpp.gyp:jsoncpp',
       ],
-      'sources': [
-        'xmpp/asyncsocket.h',
-        'xmpp/chatroommodule.h',
-        'xmpp/chatroommoduleimpl.cc',
-        'xmpp/constants.cc',
-        'xmpp/constants.h',
-        'xmpp/discoitemsquerytask.cc',
-        'xmpp/discoitemsquerytask.h',
-        'xmpp/hangoutpubsubclient.cc',
-        'xmpp/hangoutpubsubclient.h',
-        'xmpp/iqtask.cc',
-        'xmpp/iqtask.h',
-        'xmpp/jid.cc',
-        'xmpp/jid.h',
-        'xmpp/module.h',
-        'xmpp/moduleimpl.cc',
-        'xmpp/moduleimpl.h',
-        'xmpp/mucroomconfigtask.cc',
-        'xmpp/mucroomconfigtask.h',
-        'xmpp/mucroomdiscoverytask.cc',
-        'xmpp/mucroomdiscoverytask.h',
-        'xmpp/mucroomlookuptask.cc',
-        'xmpp/mucroomlookuptask.h',
-        'xmpp/mucroomuniquehangoutidtask.cc',
-        'xmpp/mucroomuniquehangoutidtask.h',
-        'xmpp/pingtask.cc',
-        'xmpp/pingtask.h',
-        'xmpp/plainsaslhandler.h',
-        'xmpp/presenceouttask.cc',
-        'xmpp/presenceouttask.h',
-        'xmpp/presencereceivetask.cc',
-        'xmpp/presencereceivetask.h',
-        'xmpp/presencestatus.cc',
-        'xmpp/presencestatus.h',
-        'xmpp/prexmppauth.h',
-        'xmpp/pubsub_task.cc',
-        'xmpp/pubsub_task.h',
-        'xmpp/pubsubclient.cc',
-        'xmpp/pubsubclient.h',
-        'xmpp/pubsubstateclient.cc',
-        'xmpp/pubsubstateclient.h',
-        'xmpp/pubsubtasks.cc',
-        'xmpp/pubsubtasks.h',
-        'xmpp/receivetask.cc',
-        'xmpp/receivetask.h',
-        'xmpp/rostermodule.h',
-        'xmpp/rostermoduleimpl.cc',
-        'xmpp/rostermoduleimpl.h',
-        'xmpp/saslcookiemechanism.h',
-        'xmpp/saslhandler.h',
-        'xmpp/saslmechanism.cc',
-        'xmpp/saslmechanism.h',
-        'xmpp/saslplainmechanism.h',
-        'xmpp/xmppauth.cc',
-        'xmpp/xmppauth.h',
-        'xmpp/xmppclient.cc',
-        'xmpp/xmppclient.h',
-        'xmpp/xmppclientsettings.h',
-        'xmpp/xmppengine.h',
-        'xmpp/xmppengineimpl.cc',
-        'xmpp/xmppengineimpl.h',
-        'xmpp/xmppengineimpl_iq.cc',
-        'xmpp/xmpplogintask.cc',
-        'xmpp/xmpplogintask.h',
-        'xmpp/xmpppump.cc',
-        'xmpp/xmpppump.h',
-        'xmpp/xmppsocket.cc',
-        'xmpp/xmppsocket.h',
-        'xmpp/xmppstanzaparser.cc',
-        'xmpp/xmppstanzaparser.h',
-        'xmpp/xmpptask.cc',
-        'xmpp/xmpptask.h',
-        'xmpp/xmppthread.cc',
-        'xmpp/xmppthread.h',
-      ],
     },  # target libjingle
     {
       'target_name': 'libjingle_media',
@@ -401,8 +326,10 @@
         '<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine',
         '<(webrtc_root)/sound/sound.gyp:rtc_sound',
         '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
-        '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
+        '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers_default',
         '<(webrtc_root)/libjingle/xmllite/xmllite.gyp:rtc_xmllite',
+        '<(webrtc_root)/libjingle/xmpp/xmpp.gyp:rtc_xmpp',
+        '<(webrtc_root)/p2p/p2p.gyp:rtc_p2p',
         'libjingle',
       ],
       'direct_dependent_settings': {
@@ -628,90 +555,6 @@
         ],
       },
       'sources': [
-        'p2p/base/asyncstuntcpsocket.cc',
-        'p2p/base/asyncstuntcpsocket.h',
-        'p2p/base/basicpacketsocketfactory.cc',
-        'p2p/base/basicpacketsocketfactory.h',
-        'p2p/base/candidate.h',
-        'p2p/base/common.h',
-        'p2p/base/constants.cc',
-        'p2p/base/constants.h',
-        'p2p/base/dtlstransportchannel.cc',
-        'p2p/base/dtlstransportchannel.h',
-        'p2p/base/p2ptransport.cc',
-        'p2p/base/p2ptransport.h',
-        'p2p/base/p2ptransportchannel.cc',
-        'p2p/base/p2ptransportchannel.h',
-        'p2p/base/packetsocketfactory.h',
-        'p2p/base/parsing.cc',
-        'p2p/base/parsing.h',
-        'p2p/base/port.cc',
-        'p2p/base/port.h',
-        'p2p/base/portallocator.cc',
-        'p2p/base/portallocator.h',
-        'p2p/base/portallocatorsessionproxy.cc',
-        'p2p/base/portallocatorsessionproxy.h',
-        'p2p/base/portinterface.h',
-        'p2p/base/portproxy.cc',
-        'p2p/base/portproxy.h',
-        'p2p/base/pseudotcp.cc',
-        'p2p/base/pseudotcp.h',
-        'p2p/base/rawtransport.cc',
-        'p2p/base/rawtransport.h',
-        'p2p/base/rawtransportchannel.cc',
-        'p2p/base/rawtransportchannel.h',
-        'p2p/base/relayport.cc',
-        'p2p/base/relayport.h',
-        'p2p/base/relayserver.cc',
-        'p2p/base/relayserver.h',
-        'p2p/base/session.cc',
-        'p2p/base/session.h',
-        'p2p/base/sessionclient.h',
-        'p2p/base/sessiondescription.cc',
-        'p2p/base/sessiondescription.h',
-        'p2p/base/sessionid.h',
-        'p2p/base/sessionmanager.cc',
-        'p2p/base/sessionmanager.h',
-        'p2p/base/sessionmessages.cc',
-        'p2p/base/sessionmessages.h',
-        'p2p/base/stun.cc',
-        'p2p/base/stun.h',
-        'p2p/base/stunport.cc',
-        'p2p/base/stunport.h',
-        'p2p/base/stunrequest.cc',
-        'p2p/base/stunrequest.h',
-        'p2p/base/stunserver.cc',
-        'p2p/base/stunserver.h',
-        'p2p/base/tcpport.cc',
-        'p2p/base/tcpport.h',
-        'p2p/base/transport.cc',
-        'p2p/base/transport.h',
-        'p2p/base/transportchannel.cc',
-        'p2p/base/transportchannel.h',
-        'p2p/base/transportchannelimpl.h',
-        'p2p/base/transportchannelproxy.cc',
-        'p2p/base/transportchannelproxy.h',
-        'p2p/base/transportdescription.cc',
-        'p2p/base/transportdescription.h',
-        'p2p/base/transportdescriptionfactory.cc',
-        'p2p/base/transportdescriptionfactory.h',
-        'p2p/base/transportinfo.h',
-        'p2p/base/turnport.cc',
-        'p2p/base/turnport.h',
-        'p2p/base/turnserver.cc',
-        'p2p/base/turnserver.h',
-        'p2p/base/udpport.h',
-        'p2p/client/autoportallocator.h',
-        'p2p/client/basicportallocator.cc',
-        'p2p/client/basicportallocator.h',
-        'p2p/client/connectivitychecker.cc',
-        'p2p/client/connectivitychecker.h',
-        'p2p/client/httpportallocator.cc',
-        'p2p/client/httpportallocator.h',
-        'p2p/client/sessionmanagertask.h',
-        'p2p/client/sessionsendtask.h',
-        'p2p/client/socketmonitor.cc',
-        'p2p/client/socketmonitor.h',
         'session/tunnel/pseudotcpchannel.cc',
         'session/tunnel/pseudotcpchannel.h',
         'session/tunnel/tunnelsessionclient.cc',
diff --git a/libjingle_examples.gyp b/libjingle_examples.gyp
index 085da39..d0f1747 100755
--- a/libjingle_examples.gyp
+++ b/libjingle_examples.gyp
@@ -39,8 +39,8 @@
         'libjingle.gyp:libjingle_p2p',
       ],
       'sources': [
-        'xmpp/jingleinfotask.cc',
-        'xmpp/jingleinfotask.h',
+        '<(webrtc_root)/libjingle/xmpp/jingleinfotask.cc',
+        '<(webrtc_root)/libjingle/xmpp/jingleinfotask.h',
       ],
     },  # target libjingle_xmpphelp
     {
@@ -317,17 +317,41 @@
                 'examples/android/build.xml',
                 'examples/android/jni/Android.mk',
                 'examples/android/project.properties',
+                'examples/android/res/drawable-hdpi/disconnect.png',
+                'examples/android/res/drawable-hdpi/ic_action_full_screen.png',
+                'examples/android/res/drawable-hdpi/ic_action_return_from_full_screen.png',
+                'examples/android/res/drawable-hdpi/ic_loopback_call.png',
                 'examples/android/res/drawable-hdpi/ic_launcher.png',
+                'examples/android/res/drawable-ldpi/disconnect.png',
+                'examples/android/res/drawable-ldpi/ic_action_full_screen.png',
+                'examples/android/res/drawable-ldpi/ic_action_return_from_full_screen.png',
+                'examples/android/res/drawable-ldpi/ic_loopback_call.png',
                 'examples/android/res/drawable-ldpi/ic_launcher.png',
+                'examples/android/res/drawable-mdpi/disconnect.png',
+                'examples/android/res/drawable-mdpi/ic_action_full_screen.png',
+                'examples/android/res/drawable-mdpi/ic_action_return_from_full_screen.png',
+                'examples/android/res/drawable-mdpi/ic_loopback_call.png',
                 'examples/android/res/drawable-mdpi/ic_launcher.png',
+                'examples/android/res/drawable-xhdpi/disconnect.png',
+                'examples/android/res/drawable-xhdpi/ic_action_full_screen.png',
+                'examples/android/res/drawable-xhdpi/ic_action_return_from_full_screen.png',
+                'examples/android/res/drawable-xhdpi/ic_loopback_call.png',
                 'examples/android/res/drawable-xhdpi/ic_launcher.png',
+                'examples/android/res/layout/activity_connect.xml',
+                'examples/android/res/layout/activity_fullscreen.xml',
+                'examples/android/res/layout/fragment_menubar.xml',
+                'examples/android/res/menu/connect_menu.xml',
+                'examples/android/res/values/arrays.xml',
                 'examples/android/res/values/strings.xml',
+                'examples/android/res/xml/preferences.xml',
                 'examples/android/src/org/appspot/apprtc/AppRTCClient.java',
                 'examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java',
-                'examples/android/src/org/appspot/apprtc/AppRTCGLView.java',
+                'examples/android/src/org/appspot/apprtc/ConnectActivity.java',
                 'examples/android/src/org/appspot/apprtc/GAEChannelClient.java',
                 'examples/android/src/org/appspot/apprtc/GAERTCClient.java',
                 'examples/android/src/org/appspot/apprtc/PeerConnectionClient.java',
+                'examples/android/src/org/appspot/apprtc/SettingsActivity.java',
+                'examples/android/src/org/appspot/apprtc/SettingsFragment.java',
                 'examples/android/src/org/appspot/apprtc/UnhandledExceptionHandler.java',
               ],
               'outputs': [
diff --git a/libjingle_media_unittest.isolate b/libjingle_media_unittest.isolate
index 666478b..970a166 100644
--- a/libjingle_media_unittest.isolate
+++ b/libjingle_media_unittest.isolate
@@ -31,12 +31,9 @@
         'command': [
           '<(PRODUCT_DIR)/libjingle_media_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_tracked': [
-          'media/testdata/captured-320x240-2s-48.frames',
+        'files': [
           '<(PRODUCT_DIR)/libjingle_media_unittest<(EXECUTABLE_SUFFIX)',
-        ],
-        'isolate_dependency_untracked': [
-          '<(DEPTH)/tools/swarming_client/',
+          'media/testdata/captured-320x240-2s-48.frames',
         ],
       },
     }],
diff --git a/libjingle_p2p_unittest.isolate b/libjingle_p2p_unittest.isolate
index 9ff0d77..d9f0423 100644
--- a/libjingle_p2p_unittest.isolate
+++ b/libjingle_p2p_unittest.isolate
@@ -31,12 +31,9 @@
         'command': [
           '<(PRODUCT_DIR)/libjingle_p2p_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_tracked': [
+        'files': [
           '<(PRODUCT_DIR)/libjingle_p2p_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_untracked': [
-          '<(DEPTH)/tools/swarming_client/',
-        ],
       },
     }],
   ],
diff --git a/libjingle_peerconnection_unittest.isolate b/libjingle_peerconnection_unittest.isolate
index df07d4a..4bc8c43 100644
--- a/libjingle_peerconnection_unittest.isolate
+++ b/libjingle_peerconnection_unittest.isolate
@@ -31,12 +31,9 @@
         'command': [
           '<(PRODUCT_DIR)/libjingle_peerconnection_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_tracked': [
+        'files': [
           '<(PRODUCT_DIR)/libjingle_peerconnection_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_untracked': [
-          '<(DEPTH)/tools/swarming_client/',
-        ],
       },
     }],
   ],
diff --git a/libjingle_sound_unittest.isolate b/libjingle_sound_unittest.isolate
index 728e810..b534200 100644
--- a/libjingle_sound_unittest.isolate
+++ b/libjingle_sound_unittest.isolate
@@ -31,12 +31,9 @@
         'command': [
           '<(PRODUCT_DIR)/libjingle_sound_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_tracked': [
+        'files': [
           '<(PRODUCT_DIR)/libjingle_sound_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_untracked': [
-          '<(DEPTH)/tools/swarming_client/',
-        ],
       },
     }],
   ],
diff --git a/libjingle_tests.gyp b/libjingle_tests.gyp
index 44adec3..6a25c0f 100755
--- a/libjingle_tests.gyp
+++ b/libjingle_tests.gyp
@@ -81,21 +81,7 @@
         'libjingle_unittest_main',
       ],
       'sources': [
-        'xmpp/fakexmppclient.h',
-        'xmpp/hangoutpubsubclient_unittest.cc',
-        'xmpp/jid_unittest.cc',
-        'xmpp/mucroomconfigtask_unittest.cc',
-        'xmpp/mucroomdiscoverytask_unittest.cc',
-        'xmpp/mucroomlookuptask_unittest.cc',
-        'xmpp/mucroomuniquehangoutidtask_unittest.cc',
-        'xmpp/pingtask_unittest.cc',
-        'xmpp/pubsubclient_unittest.cc',
-        'xmpp/pubsubtasks_unittest.cc',
-        'xmpp/util_unittest.cc',
-        'xmpp/util_unittest.h',
-        'xmpp/xmppengine_unittest.cc',
-        'xmpp/xmpplogintask_unittest.cc',
-        'xmpp/xmppstanzaparser_unittest.cc',
+        '<(DEPTH)/webrtc/test/testsupport/always_passing_unittest.cc',
       ],  # sources
     },  # target libjingle_unittest
     {
@@ -190,28 +176,6 @@
         '<(DEPTH)/third_party/libsrtp/srtp',
       ],
       'sources': [
-        'p2p/base/dtlstransportchannel_unittest.cc',
-        'p2p/base/fakesession.h',
-        'p2p/base/p2ptransportchannel_unittest.cc',
-        'p2p/base/port_unittest.cc',
-        'p2p/base/portallocatorsessionproxy_unittest.cc',
-        'p2p/base/pseudotcp_unittest.cc',
-        'p2p/base/relayport_unittest.cc',
-        'p2p/base/relayserver_unittest.cc',
-        'p2p/base/session_unittest.cc',
-        'p2p/base/stun_unittest.cc',
-        'p2p/base/stunport_unittest.cc',
-        'p2p/base/stunrequest_unittest.cc',
-        'p2p/base/stunserver_unittest.cc',
-        'p2p/base/testrelayserver.h',
-        'p2p/base/teststunserver.h',
-        'p2p/base/testturnserver.h',
-        'p2p/base/transport_unittest.cc',
-        'p2p/base/transportdescriptionfactory_unittest.cc',
-        'p2p/base/turnport_unittest.cc',
-        'p2p/client/connectivitychecker_unittest.cc',
-        'p2p/client/fakeportallocator.h',
-        'p2p/client/portallocator_unittest.cc',
         'session/media/bundlefilter_unittest.cc',
         'session/media/channel_unittest.cc',
         'session/media/channelmanager_unittest.cc',
@@ -438,7 +402,6 @@
           ],
           'includes': [
             'build/isolate.gypi',
-            'libjingle_media_unittest.isolate',
           ],
           'sources': [
             'libjingle_media_unittest.isolate',
@@ -452,7 +415,6 @@
           ],
           'includes': [
             'build/isolate.gypi',
-            'libjingle_p2p_unittest.isolate',
           ],
           'sources': [
             'libjingle_p2p_unittest.isolate',
@@ -466,26 +428,11 @@
           ],
           'includes': [
             'build/isolate.gypi',
-            'libjingle_peerconnection_unittest.isolate',
           ],
           'sources': [
             'libjingle_peerconnection_unittest.isolate',
           ],
         },
-        {
-          'target_name': 'libjingle_unittest_run',
-          'type': 'none',
-          'dependencies': [
-            'libjingle_unittest',
-          ],
-          'includes': [
-            'build/isolate.gypi',
-            'libjingle_unittest.isolate',
-          ],
-          'sources': [
-            'libjingle_unittest.isolate',
-          ],
-        },
       ],
     }],
   ],
diff --git a/libjingle_unittest.isolate b/libjingle_unittest.isolate
index 0507f6a..9313beb 100644
--- a/libjingle_unittest.isolate
+++ b/libjingle_unittest.isolate
@@ -31,12 +31,9 @@
         'command': [
           '<(PRODUCT_DIR)/libjingle_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_tracked': [
+        'files': [
           '<(PRODUCT_DIR)/libjingle_unittest<(EXECUTABLE_SUFFIX)',
         ],
-        'isolate_dependency_untracked': [
-          '<(DEPTH)/tools/swarming_client/',
-        ],
       },
     }],
   ],
diff --git a/media/base/fakemediaengine.h b/media/base/fakemediaengine.h
index 87bc8a3..db5e2e4 100644
--- a/media/base/fakemediaengine.h
+++ b/media/base/fakemediaengine.h
@@ -38,7 +38,7 @@
 #include "talk/media/base/mediaengine.h"
 #include "talk/media/base/rtputils.h"
 #include "talk/media/base/streamparams.h"
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 #include "webrtc/base/buffer.h"
 #include "webrtc/base/stringutils.h"
 
diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h
index b1164b5..5e03ef9 100644
--- a/media/base/mediachannel.h
+++ b/media/base/mediachannel.h
@@ -843,7 +843,6 @@
         capture_jitter_ms(0),
         avg_encode_ms(0),
         encode_usage_percent(0),
-        encode_rsd(0),
         capture_queue_delay_ms_per_s(0) {
   }
 
@@ -865,7 +864,6 @@
   int capture_jitter_ms;
   int avg_encode_ms;
   int encode_usage_percent;
-  int encode_rsd;
   int capture_queue_delay_ms_per_s;
   VariableInfo<int> adapt_frame_drops;
   VariableInfo<int> effects_frame_drops;
@@ -973,7 +971,7 @@
   // StatsOptions::include_received_propagation_stats is true.
   int total_received_propagation_delta_ms;
   std::vector<int> recent_received_propagation_delta_ms;
-  std::vector<int64> recent_received_packet_group_arrival_time_ms;
+  std::vector<int64_t> recent_received_packet_group_arrival_time_ms;
 };
 
 struct VoiceMediaInfo {
diff --git a/media/base/videoengine_unittest.h b/media/base/videoengine_unittest.h
index 6ea5b8c..472d42a 100644
--- a/media/base/videoengine_unittest.h
+++ b/media/base/videoengine_unittest.h
@@ -783,10 +783,7 @@
   void SetSendSetsTransportBufferSizes() {
     EXPECT_TRUE(SetOneCodec(DefaultCodec()));
     EXPECT_TRUE(SetSend(true));
-    // TODO(sriniv): Remove or re-enable this.
-    // As part of b/8030474, send-buffer is size now controlled through
-    // portallocator flags. Its not set by channels.
-    // EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size());
+    EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size());
     EXPECT_EQ(64 * 1024, network_interface_.recvbuf_size());
   }
   // Tests that we can send frames and the right payload type is used.
@@ -1380,6 +1377,9 @@
     EXPECT_EQ(0, renderer_.num_rendered_frames());
     EXPECT_TRUE(SendFrame());
     EXPECT_FRAME_WAIT(1, 640, 400, kTimeout);
+    // Wait for one frame so they don't get dropped because we send frames too
+    // tightly.
+    rtc::Thread::Current()->ProcessMessages(30);
     // Remove the capturer.
     EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
     // Wait for one black frame for removing the capturer.
diff --git a/media/webrtc/webrtcvideoengine.cc b/media/webrtc/webrtcvideoengine.cc
index 4a4e29a..04092f3 100644
--- a/media/webrtc/webrtcvideoengine.cc
+++ b/media/webrtc/webrtcvideoengine.cc
@@ -66,6 +66,22 @@
 
 namespace {
 
+cricket::VideoFormat CreateVideoFormat(int width, int height, int framerate) {
+  return cricket::VideoFormat(
+      width,
+      height,
+      cricket::VideoFormat::FpsToInterval(framerate),
+      cricket::FOURCC_ANY);
+}
+
+cricket::VideoFormat VideoFormatFromCodec(const cricket::VideoCodec& codec) {
+  return CreateVideoFormat(codec.width, codec.height, codec.framerate);
+}
+
+cricket::VideoFormat VideoFormatFromVieCodec(const webrtc::VideoCodec& codec) {
+  return CreateVideoFormat(codec.width, codec.height, codec.maxFramerate);
+}
+
 template <class T>
 bool Changed(cricket::Settable<T> proposed,
              cricket::Settable<T> original) {
@@ -172,10 +188,12 @@
 }
 
 struct FlushBlackFrameData : public rtc::MessageData {
-  FlushBlackFrameData(uint32 s, int64 t) : ssrc(s), timestamp(t) {
+  FlushBlackFrameData(uint32 s, int64 t, int i)
+      : ssrc(s), timestamp(t), interval(i) {
   }
   uint32 ssrc;
   int64 timestamp;
+  int interval;
 };
 
 class WebRtcRenderAdapter : public webrtc::ExternalRenderer {
@@ -592,6 +610,15 @@
 class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
  public:
   typedef std::map<int, webrtc::VideoEncoder*> EncoderMap;  // key: payload type
+
+  enum AdaptFormatType {
+    // This is how we make SetSendStreamFormat take precedence over
+    // SetSendCodecs.
+    kAdaptFormatTypeNone = 0,  // Unset
+    kAdaptFormatTypeCodec = 1,  // From SetSendCodec
+    kAdaptFormatTypeStream = 2,  // From SetStreamFormat
+  };
+
   WebRtcVideoChannelSendInfo(int channel_id, int capture_id,
                              webrtc::ViEExternalCapture* external_capture,
                              rtc::CpuMonitor* cpu_monitor)
@@ -602,15 +629,24 @@
         video_capturer_(NULL),
         encoder_observer_(channel_id),
         external_capture_(external_capture),
-        interval_(0),
         cpu_monitor_(cpu_monitor),
-        old_adaptation_changes_(0) {
+        old_adaptation_changes_(0),
+        adapt_format_type_(kAdaptFormatTypeNone) {
   }
 
   int channel_id() const { return channel_id_; }
   int capture_id() const { return capture_id_; }
   void set_sending(bool sending) { sending_ = sending; }
   bool sending() const { return sending_; }
+  void set_send_params(const VideoSendParams& send_params) {
+    send_params_ = send_params;
+  }
+  const VideoSendParams& send_params() const {
+    return send_params_;
+  }
+  const Settable<CapturedFrameInfo>& last_captured_frame_info() const {
+    return last_captured_frame_info_;
+  }
   void set_muted(bool on) {
     // TODO(asapersson): add support.
     // video_adapter_.SetBlackOutput(on);
@@ -620,25 +656,51 @@
 
   WebRtcEncoderObserver* encoder_observer() { return &encoder_observer_; }
   webrtc::ViEExternalCapture* external_capture() { return external_capture_; }
-  const VideoFormat& video_format() const {
-    return video_format_;
+  const VideoFormat& adapt_format() const { return adapt_format_; }
+  AdaptFormatType adapt_format_type() const { return adapt_format_type_; }
+  bool adapt_format_set() const {
+    return adapt_format_type() != kAdaptFormatTypeNone;
   }
-  void set_video_format(const VideoFormat& video_format) {
-    video_format_ = video_format;
-    if (video_format_ != cricket::VideoFormat()) {
-      interval_ = video_format_.interval;
+
+  // Returns true if the last captured frame info changed.
+  void SetLastCapturedFrameInfo(
+      const VideoFrame* frame, bool screencast, bool* changed) {
+    CapturedFrameInfo last;
+    if (last_captured_frame_info_.Get(&last) &&
+        frame->GetWidth() == last.width &&
+        frame->GetHeight() == last.height &&
+        screencast == last.screencast) {
+      *changed = false;
+      return;
     }
-    CoordinatedVideoAdapter* adapter = video_adapter();
-    if (adapter) {
-      adapter->OnOutputFormatRequest(video_format_);
-    }
+
+    last_captured_frame_info_.Set(CapturedFrameInfo(
+        frame->GetWidth(), frame->GetHeight(), screencast));
+    *changed = true;
   }
-  void set_interval(int64 interval) {
-    if (video_format() == cricket::VideoFormat()) {
-      interval_ = interval;
+
+  // Tells the video adapter to adapt down to a given format.  The
+  // type indicates where the format came from, where different types
+  // have slightly different behavior and priority.
+  void SetAdaptFormat(const VideoFormat& format, AdaptFormatType type) {
+    if (type < adapt_format_type_) {
+      // Formats from SetSendStream format are higher priority than
+      // ones from SetSendCodecs wich is higher priority than not
+      // being set.  If something lower-prioirty comes in, just ignore
+      // it.
+      return;
     }
+
+    // TODO(pthatcher): Use the adapter for all max size enforcement,
+    // both codec-based and SetSendStreamFormat-based.  For now, we
+    // can't do that without fixing a lot of unit tests.
+    if (video_adapter() && type == kAdaptFormatTypeStream) {
+      video_adapter()->OnOutputFormatRequest(format);
+    }
+
+    adapt_format_ = format;
+    adapt_format_type_ = type;
   }
-  int64 interval() { return interval_; }
 
   int CurrentAdaptReason() const {
     if (!video_adapter()) {
@@ -653,15 +715,20 @@
     return old_adaptation_changes_ + video_adapter()->adaptation_changes();
   }
 
-  StreamParams* stream_params() { return stream_params_.get(); }
   void set_stream_params(const StreamParams& sp) {
-    stream_params_.reset(new StreamParams(sp));
+    send_params_.stream = sp;
   }
-  void ClearStreamParams() { stream_params_.reset(); }
-  bool has_ssrc(uint32 local_ssrc) const {
-    return !stream_params_ ? false :
-        stream_params_->has_ssrc(local_ssrc);
+  const StreamParams& stream_params() const { return send_params_.stream; }
+  // A default send channel can be non-active if a stream hasn't been
+  // added yet, or if all streams have been removed (at which point,
+  // Deactive is called).
+  bool IsActive() {
+    return stream_params().first_ssrc() != 0;
   }
+  void Deactivate() {
+    send_params_.stream = StreamParams();
+  }
+
   WebRtcLocalStreamInfo* local_stream_info() {
     return &local_stream_info_;
   }
@@ -696,6 +763,13 @@
     CoordinatedVideoAdapter* adapter = video_adapter();
     ASSERT(adapter && "Video adapter should not be null here.");
 
+    // TODO(pthatcher): Use the adapter for all max size enforcement,
+    // both codec-based and SetSendStreamFormat-based. For now, we
+    // can't do that without fixing a lot of unit tests.
+    if (adapt_format_type_ == kAdaptFormatTypeStream) {
+      adapter->OnOutputFormatRequest(adapt_format_);
+    }
+
     UpdateAdapterCpuOptions();
 
     overuse_observer_.reset(new WebRtcOveruseObserver(adapter));
@@ -826,6 +900,9 @@
  private:
   int channel_id_;
   int capture_id_;
+  VideoSendParams send_params_;
+  // TODO(pthatcher): Merge CapturedFrameInfo and LocalStreamInfo.
+  Settable<CapturedFrameInfo> last_captured_frame_info_;
   bool sending_;
   bool muted_;
   VideoCapturer* video_capturer_;
@@ -833,20 +910,17 @@
   webrtc::ViEExternalCapture* external_capture_;
   EncoderMap registered_encoders_;
 
-  VideoFormat video_format_;
-
-  rtc::scoped_ptr<StreamParams> stream_params_;
-
   WebRtcLocalStreamInfo local_stream_info_;
 
-  int64 interval_;
-
   rtc::CpuMonitor* cpu_monitor_;
   rtc::scoped_ptr<WebRtcOveruseObserver> overuse_observer_;
 
   int old_adaptation_changes_;
 
   VideoOptions video_options_;
+
+  VideoFormat adapt_format_;
+  AdaptFormatType adapt_format_type_;
 };
 
 const WebRtcVideoEngine::VideoCodecPref
@@ -861,17 +935,6 @@
   {640, 400, FPS_TO_INTERVAL(30), FOURCC_ANY};
 // TODO(ronghuawu): Change to 640x360.
 
-static void UpdateVideoCodec(const cricket::VideoFormat& video_format,
-                             webrtc::VideoCodec* target_codec) {
-  if ((!target_codec) || (video_format == cricket::VideoFormat())) {
-    return;
-  }
-  target_codec->width = video_format.width;
-  target_codec->height = video_format.height;
-  target_codec->maxFramerate = cricket::VideoFormat::IntervalToFps(
-      video_format.interval);
-}
-
 static bool GetCpuOveruseOptions(const VideoOptions& options,
                                  webrtc::CpuOveruseOptions* overuse_options) {
   int underuse_threshold = 0;
@@ -1103,11 +1166,8 @@
   }
 
   ASSERT(!video_codecs_.empty());
-  default_codec_format_ = VideoFormat(
-      video_codecs_[0].width,
-      video_codecs_[0].height,
-      VideoFormat::FpsToInterval(video_codecs_[0].framerate),
-      FOURCC_ANY);
+  default_codec_format_ = VideoFormatFromCodec(video_codecs_[0]);
+
   return true;
 }
 
@@ -1774,15 +1834,15 @@
     const webrtc::VideoCodec& codec) {
   // Codec type not supported or encoder already registered, so
   // nothing to do.
-  if (!engine()->IsExternalEncoderCodecType(codec.codecType)
-      || send_channel->IsEncoderRegistered(codec.plType)) {
+  if (!engine()->IsExternalEncoderCodecType(codec.codecType) ||
+      send_channel->IsEncoderRegistered(codec.plType)) {
     return true;
   }
 
   webrtc::VideoEncoder* encoder =
       engine()->CreateExternalEncoder(codec.codecType);
   if (!encoder) {
-    // No encoder factor, so nothing to do.
+    // No external encoder created, so nothing to do.
     return true;
   }
 
@@ -1813,7 +1873,9 @@
     LOG(LS_ERROR) << "The specified ssrc " << ssrc << " is not in use.";
     return false;
   }
-  send_channel->set_video_format(format);
+
+  send_channel->SetAdaptFormat(
+      format, WebRtcVideoChannelSendInfo::kAdaptFormatTypeStream);
   return true;
 }
 
@@ -1897,7 +1959,7 @@
   // If the default channel is already used for sending create a new channel
   // otherwise use the default channel for sending.
   int channel_id = kChannelIdUnset;
-  if (!DefaultSendChannelInUse()) {
+  if (!DefaultSendChannelIsActive()) {
     channel_id = default_channel_id_;
   } else {
     if (!CreateChannel(ssrc_key, MD_SEND, &channel_id)) {
@@ -1955,9 +2017,9 @@
   }
   WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrcKey(ssrc_key);
   int channel_id = send_channel->channel_id();
-  if (IsDefaultChannelId(channel_id) && !send_channel->stream_params()) {
-    // Default channel will still exist. However, if stream_params() is NULL
-    // there is no stream to remove.
+  if (IsDefaultChannelId(channel_id) && !send_channel->IsActive()) {
+    // Default channel will still exist. However, there is no stream
+    // to remove.
     return false;
   }
   if (sending_) {
@@ -1979,7 +2041,7 @@
   // The receive channels depend on the default channel, recycle it instead.
   if (IsDefaultChannelId(channel_id)) {
     SetCapturer(GetDefaultSendChannelSsrc(), NULL);
-    send_channel->ClearStreamParams();
+    send_channel->Deactivate();
   } else {
     return DeleteSendChannel(ssrc_key);
   }
@@ -1995,7 +2057,7 @@
   // TODO(zhurunz) Remove this once BWE works properly across different send
   // and receive channels.
   // Reuse default channel for recv stream in 1:1 call.
-  if (!InConferenceMode() && first_receive_ssrc_ == kSsrcUnset) {
+  if (!ConferenceModeIsEnabled() && first_receive_ssrc_ == kSsrcUnset) {
     LOG(LS_INFO) << "Recv stream " << sp.first_ssrc()
                  << " reuse default channel #"
                  << default_channel_id_;
@@ -2211,11 +2273,11 @@
 
 bool WebRtcVideoMediaChannel::HasReadySendChannels() {
   return !send_channels_.empty() &&
-      ((send_channels_.size() > 1) || DefaultSendChannelInUse());
+      ((send_channels_.size() > 1) || DefaultSendChannelIsActive());
 }
 
-bool WebRtcVideoMediaChannel::DefaultSendChannelInUse() {
-  return GetDefaultSendChannel() && GetDefaultSendChannel()->stream_params();
+bool WebRtcVideoMediaChannel::DefaultSendChannelIsActive() {
+  return GetDefaultSendChannel() && GetDefaultSendChannel()->IsActive();
 }
 
 bool WebRtcVideoMediaChannel::GetSendChannelSsrcKey(uint32 local_ssrc,
@@ -2240,7 +2302,7 @@
     for (SendChannelMap::iterator iter = send_channels_.begin();
          iter != send_channels_.end(); ++iter) {
       WebRtcVideoChannelSendInfo* send_channel = iter->second;
-      if (send_channel->has_ssrc(local_ssrc)) {
+      if (send_channel->stream_params().has_ssrc(local_ssrc)) {
         *ssrc_key = iter->first;
         return true;
       }
@@ -2284,7 +2346,7 @@
     // this point a duplicate SSRC has been detected.
     return false;
   }
-  if (!DefaultSendChannelInUse()) {
+  if (!DefaultSendChannelIsActive()) {
     // |ssrc_key| should be kDefaultChannelSsrcKey here as the default
     // channel should be re-used whenever it is not used.
     *ssrc_key = kDefaultChannelSsrcKey;
@@ -2310,10 +2372,7 @@
 }
 
 uint32 WebRtcVideoMediaChannel::GetDefaultSendChannelSsrc() {
-  if (!DefaultSendChannelInUse()) {
-    return 0;
-  }
-  return GetDefaultSendChannel()->stream_params()->first_ssrc();
+  return GetDefaultSendChannel()->stream_params().first_ssrc();
 }
 
 bool WebRtcVideoMediaChannel::DeleteSendChannel(uint32 ssrc_key) {
@@ -2377,7 +2436,8 @@
   send_channel->set_video_capturer(NULL, engine()->vie());
   const int64 timestamp = send_channel->local_stream_info()->time_stamp();
   if (send_codec_) {
-    QueueBlackFrame(ssrc, timestamp, send_codec_->maxFramerate);
+    QueueBlackFrame(ssrc, timestamp,
+                    VideoFormat::FpsToInterval(send_codec_->maxFramerate));
   }
   return true;
 }
@@ -2418,8 +2478,7 @@
       WebRtcVideoChannelSendInfo* send_channel = iter->second;
       const int channel_id = send_channel->channel_id();
       VideoSenderInfo sinfo;
-      const StreamParams* send_params = send_channel->stream_params();
-      if (!send_params) {
+      if (!send_channel->IsActive()) {
         // This should only happen if the default vie channel is not in use.
         // This can happen if no streams have ever been added or the stream
         // corresponding to the default channel has been removed. Note that
@@ -2439,8 +2498,9 @@
       WebRtcLocalStreamInfo* channel_stream_info =
           send_channel->local_stream_info();
 
-      for (size_t i = 0; i < send_params->ssrcs.size(); ++i) {
-        sinfo.add_ssrc(send_params->ssrcs[i]);
+      const StreamParams& sp = send_channel->stream_params();
+      for (size_t i = 0; i < sp.ssrcs.size(); ++i) {
+        sinfo.add_ssrc(sp.ssrcs[i]);
       }
       sinfo.codec_name = send_codec_->plName;
       sinfo.bytes_sent = bytes_sent;
@@ -2493,7 +2553,6 @@
       sinfo.capture_jitter_ms = metrics.capture_jitter_ms;
       sinfo.avg_encode_ms = metrics.avg_encode_time_ms;
       sinfo.encode_usage_percent = metrics.encode_usage_percent;
-      sinfo.encode_rsd = metrics.encode_rsd;
       sinfo.capture_queue_delay_ms_per_s = metrics.capture_queue_delay_ms_per_s;
 #else
       sinfo.capture_jitter_ms = -1;
@@ -2723,7 +2782,8 @@
   }
   const int64 timestamp = send_channel->local_stream_info()->time_stamp();
   if (send_codec_) {
-    QueueBlackFrame(ssrc, timestamp, send_codec_->maxFramerate);
+    QueueBlackFrame(ssrc, timestamp,
+                    VideoFormat::FpsToInterval(send_codec_->maxFramerate));
   }
   return true;
 }
@@ -2745,7 +2805,7 @@
   int processing_channel_id = GetRecvChannelId(ssrc);
   if (processing_channel_id == kChannelIdUnset) {
     // Allocate an unsignalled recv channel for processing in conference mode.
-    if (!InConferenceMode()) {
+    if (!ConferenceModeIsEnabled()) {
       // If we can't find or allocate one, use the default.
       processing_channel_id = default_channel_id_;
     } else if (!CreateUnsignalledRecvChannel(ssrc, &processing_channel_id)) {
@@ -3048,12 +3108,13 @@
                           rtc::Socket::OPT_RCVBUF,
                           kVideoRtpBufferSize);
 
-    // TODO(sriniv): Remove or re-enable this.
-    // As part of b/8030474, send-buffer is size now controlled through
-    // portallocator flags.
-    // network_interface_->SetOption(NetworkInterface::ST_RTP,
-    //                              rtc::Socket::OPT_SNDBUF,
-    //                              kVideoRtpBufferSize);
+  // Speculative change to increase the outbound socket buffer size.
+  // In b/15152257, we are seeing a significant number of packets discarded
+  // due to lack of socket buffer space, although it's not yet clear what the
+  // ideal value should be.
+  MediaChannel::SetOption(NetworkInterface::ST_RTP,
+                          rtc::Socket::OPT_SNDBUF,
+                          kVideoRtpBufferSize);
 }
 
 void WebRtcVideoMediaChannel::UpdateAspectRatio(int ratio_w, int ratio_h) {
@@ -3140,23 +3201,32 @@
     // Send codec has not been set. No reason to process the frame any further.
     return false;
   }
-  const VideoFormat& video_format = send_channel->video_format();
+
+  // TODO(pthatcher): Move drop logic to adapter.
   // If the frame should be dropped.
-  const bool video_format_set = video_format != cricket::VideoFormat();
-  if (video_format_set &&
-      (video_format.width == 0 && video_format.height == 0)) {
+  if (send_channel->adapt_format_set() &&
+      send_channel->adapt_format().width == 0 &&
+      send_channel->adapt_format().height == 0) {
     return true;
   }
 
-  // Checks if we need to reset vie send codec.
-  if (!MaybeResetVieSendCodec(send_channel,
-                              static_cast<int>(frame->GetWidth()),
-                              static_cast<int>(frame->GetHeight()),
-                              is_screencast, NULL)) {
-    LOG(LS_ERROR) << "MaybeResetVieSendCodec failed with "
-                  << frame->GetWidth() << "x" << frame->GetHeight();
-    return false;
+  bool changed;
+  send_channel->SetLastCapturedFrameInfo(frame, is_screencast, &changed);
+  if (changed) {
+    // If the last captured frame info changed, then calling
+    // SetSendParams will update to the latest resolution.
+    VideoSendParams send_params = send_channel->send_params();
+    // Note: We must copy the send_params because otherwise the memory
+    // checker will complain.
+    if (!SetSendParams(send_channel, send_params)) {
+      LOG(LS_ERROR) << "SetSendParams from SendFrame failed with "
+                    << frame->GetWidth() << "x" << frame->GetHeight()
+                    << " screencast? " << is_screencast;
+      return false;
+    }
+    LogSendCodecChange("Captured frame size changed");
   }
+
   const VideoFrame* frame_out = frame;
   rtc::scoped_ptr<VideoFrame> processed_frame;
   // TODO(hellner): Remove the need for disabling mute when screencasting.
@@ -3458,6 +3528,8 @@
     LOG_RTCERR2(ConnectCaptureDevice, vie_capture, channel_id);
     return false;
   }
+
+  // Set up a new send channel.
   rtc::scoped_ptr<WebRtcVideoChannelSendInfo> send_channel(
       new WebRtcVideoChannelSendInfo(channel_id, vie_capture,
                                      external_capture,
@@ -3549,7 +3621,7 @@
                                          int fec_payload_type,
                                          bool nack_enabled) {
   bool enable = (red_payload_type != -1 && fec_payload_type != -1 &&
-      !InConferenceMode());
+      !ConferenceModeIsEnabled());
   if (enable) {
     if (engine_->vie()->rtp()->SetHybridNACKFECStatus(
         channel_id, nack_enabled, red_payload_type, fec_payload_type) != 0) {
@@ -3600,67 +3672,29 @@
     return false;
   }
 
+  send_channel->SetAdaptFormat(
+      VideoFormatFromVieCodec(codec),
+      WebRtcVideoChannelSendInfo::kAdaptFormatTypeCodec);
+
+  MaybeRegisterExternalEncoder(send_channel, codec);
+
+  VideoSendParams send_params = send_channel->send_params();
+  send_params.codec = codec;
+  if (!SetSendParams(send_channel, send_params)) {
+    return false;
+  }
+
+  // NOTE: SetRtxSendPayloadType must be called after all simulcast SSRCs
+  // are configured. Otherwise ssrc's configured after this point will use
+  // the primary PT for RTX.
   const int channel_id = send_channel->channel_id();
-  // Make a copy of the codec
-  webrtc::VideoCodec target_codec = codec;
-
-  // Set the default number of temporal layers for VP8.
-  if (webrtc::kVideoCodecVP8 == codec.codecType) {
-    target_codec.codecSpecific.VP8.numberOfTemporalLayers =
-        kDefaultNumberOfTemporalLayers;
-
-    // Turn off the VP8 error resilience
-    target_codec.codecSpecific.VP8.resilience = webrtc::kResilienceOff;
-
-    bool enable_denoising =
-        options_.video_noise_reduction.GetWithDefaultIfUnset(true);
-    target_codec.codecSpecific.VP8.denoisingOn = enable_denoising;
+  if (send_rtx_type_ != -1 &&
+      engine()->vie()->rtp()->SetRtxSendPayloadType(channel_id,
+                                                    send_rtx_type_) != 0) {
+    LOG_RTCERR2(SetRtxSendPayloadType, channel_id, send_rtx_type_);
+    return false;
   }
 
-  MaybeRegisterExternalEncoder(send_channel, target_codec);
-
-  // Resolution and framerate may vary for different send channels.
-  const VideoFormat& video_format = send_channel->video_format();
-  UpdateVideoCodec(video_format, &target_codec);
-
-  if (target_codec.width == 0 && target_codec.height == 0) {
-    const uint32 ssrc = send_channel->stream_params()->first_ssrc();
-    LOG(LS_INFO) << "0x0 resolution selected. Captured frames will be dropped "
-                 << "for ssrc: " << ssrc << ".";
-  } else {
-    StreamParams* send_params = send_channel->stream_params();
-    SanitizeBitrates(channel_id, &target_codec);
-    webrtc::VideoCodec current_codec;
-    if (!engine()->vie()->codec()->GetSendCodec(channel_id, current_codec)) {
-      // Compare against existing configured send codec.
-      if (current_codec == target_codec) {
-        // Codec is already configured on channel. no need to apply.
-        return true;
-      }
-    }
-
-    if (0 != engine()->vie()->codec()->SetSendCodec(channel_id, target_codec)) {
-      LOG_RTCERR2(SetSendCodec, channel_id, target_codec.plName);
-      return false;
-    }
-
-    if (send_params) {
-      if (!SetSendSsrcs(channel_id, *send_params, target_codec)) {
-        return false;
-      }
-    }
-    // NOTE: SetRtxSendPayloadType must be called after all simulcast SSRCs
-    // are configured. Otherwise ssrc's configured after this point will use
-    // the primary PT for RTX.
-    if (send_rtx_type_ != -1 &&
-        engine()->vie()->rtp()->SetRtxSendPayloadType(channel_id,
-                                                      send_rtx_type_) != 0) {
-        LOG_RTCERR2(SetRtxSendPayloadType, channel_id, send_rtx_type_);
-        return false;
-    }
-  }
-  send_channel->set_interval(
-      cricket::VideoFormat::FpsToInterval(target_codec.maxFramerate));
   return true;
 }
 
@@ -3833,117 +3867,107 @@
   return recv_channel_id;
 }
 
-// If the new frame size is different from the send codec size we set on vie,
-// we need to reset the send codec on vie.
-// The new send codec size should not exceed send_codec_ which is controlled
-// only by the 'jec' logic.
-// TODO(pthatcher): Get rid of this function, so we only ever set up
-// codecs in a single place.
-bool WebRtcVideoMediaChannel::MaybeResetVieSendCodec(
+bool WebRtcVideoMediaChannel::SetSendParams(
     WebRtcVideoChannelSendInfo* send_channel,
-    int new_width,
-    int new_height,
-    bool is_screencast,
-    bool* reset) {
-  if (reset) {
-    *reset = false;
-  }
-  ASSERT(send_codec_.get() != NULL);
+    const VideoSendParams& send_params) {
+  const int channel_id = send_channel->channel_id();
 
-  webrtc::VideoCodec target_codec = *send_codec_;
-  const VideoFormat& video_format = send_channel->video_format();
-  UpdateVideoCodec(video_format, &target_codec);
+  CapturedFrameInfo frame;
+  send_channel->last_captured_frame_info().Get(&frame);
 
-  // Vie send codec size should not exceed target_codec.
-  int target_width = new_width;
-  int target_height = new_height;
-  if (!is_screencast &&
-      (new_width > target_codec.width || new_height > target_codec.height)) {
-    target_width = target_codec.width;
-    target_height = target_codec.height;
+  // TODO(pthatcher): This checking of the max height and width is
+  // only needed because some unit tests bypass the VideoAdapter, and
+  // others expect behavior from the adapter different than what it
+  // actually does.  We should fix the tests and remove this block.
+  VideoFormat max = send_channel->adapt_format();
+  size_t max_width = static_cast<size_t>(max.width);
+  size_t max_height = static_cast<size_t>(max.height);
+  if (!send_channel->last_captured_frame_info().IsSet() ||
+      (!frame.screencast &&
+       (frame.width > max_width || frame.height > max_height))) {
+    frame.width = max_width;
+    frame.height = max_height;
   }
 
+  webrtc::VideoCodec codec;
+  ConfigureVieCodecFromSendParams(channel_id, send_params, frame, &codec);
+  // TODO(pthatcher): Figure out a clean way to configure the max
+  // framerate and sanitize the bitrates inside of
+  // ConfigureVieCodecFromSendParams.
+  codec.maxFramerate = max.framerate();
+  SanitizeBitrates(channel_id, &codec);
+
   // Get current vie codec.
-  webrtc::VideoCodec vie_codec;
-  const int channel_id = send_channel->channel_id();
-  if (engine()->vie()->codec()->GetSendCodec(channel_id, vie_codec) != 0) {
+  webrtc::VideoCodec current;
+  if (engine()->vie()->codec()->GetSendCodec(channel_id, current) != 0) {
     LOG_RTCERR1(GetSendCodec, channel_id);
     return false;
   }
-  const int cur_width = vie_codec.width;
-  const int cur_height = vie_codec.height;
 
-  // Only reset send codec when there is a size change. Additionally,
-  // automatic resize needs to be turned off when screencasting and on when
-  // not screencasting.
-  // Don't allow automatic resizing for screencasting.
-  bool automatic_resize = !is_screencast;
-  // Turn off VP8 frame dropping when screensharing as the current model does
-  // not work well at low fps.
-  bool vp8_frame_dropping = !is_screencast;
-  // TODO(pbos): Remove |video_noise_reduction| and enable it for all
-  // non-screencast.
-  bool enable_denoising =
-      options_.video_noise_reduction.GetWithDefaultIfUnset(true);
-  // Disable denoising for screencasting.
-  if (is_screencast) {
-    enable_denoising = false;
-  }
-  int screencast_min_bitrate =
-      options_.screencast_min_bitrate.GetWithDefaultIfUnset(0);
-  StreamParams* send_params = send_channel->stream_params();
-  bool reset_send_codec =
-    target_width != cur_width || target_height != cur_height;
-  if (vie_codec.codecType == webrtc::kVideoCodecVP8) {
-    reset_send_codec = reset_send_codec ||
-      automatic_resize != vie_codec.codecSpecific.VP8.automaticResizeOn ||
-      enable_denoising != vie_codec.codecSpecific.VP8.denoisingOn ||
-      vp8_frame_dropping != vie_codec.codecSpecific.VP8.frameDroppingOn;
-  }
-
-  if (reset_send_codec) {
-    // Set the new codec on vie.
-    vie_codec.width = target_width;
-    vie_codec.height = target_height;
-    vie_codec.maxFramerate = target_codec.maxFramerate;
-    vie_codec.startBitrate = target_codec.startBitrate;
-    vie_codec.minBitrate = target_codec.minBitrate;
-    vie_codec.maxBitrate = target_codec.maxBitrate;
-    vie_codec.targetBitrate = 0;
-    if (vie_codec.codecType == webrtc::kVideoCodecVP8) {
-      vie_codec.codecSpecific.VP8.automaticResizeOn = automatic_resize;
-      vie_codec.codecSpecific.VP8.denoisingOn = enable_denoising;
-      vie_codec.codecSpecific.VP8.frameDroppingOn = vp8_frame_dropping;
-    }
-    SanitizeBitrates(channel_id, &vie_codec);
-
-    if (engine()->vie()->codec()->SetSendCodec(channel_id, vie_codec) != 0) {
+  if (current != codec) {
+    if (engine()->vie()->codec()->SetSendCodec(channel_id, codec) != 0) {
       LOG_RTCERR1(SetSendCodec, channel_id);
       return false;
     }
-
-    if (is_screencast) {
-      engine()->vie()->rtp()->SetMinTransmitBitrate(channel_id,
-                                                    screencast_min_bitrate);
-    } else {
-      // In case of switching from screencast to regular capture, set
-      // min bitrate padding and pacer back to defaults.
-      engine()->vie()->rtp()->SetMinTransmitBitrate(channel_id, 0);
-    }
-    engine()->vie()->rtp()->SetTransmissionSmoothingStatus(channel_id, true);
-    // TODO(sriniv): SetSendCodec already sets ssrc's like below.
-    // Consider removing.
-    if (send_params) {
-      if (!SetSendSsrcs(channel_id, *send_params, target_codec)) {
-        return false;
-      }
-    }
-    if (reset) {
-      *reset = true;
-    }
-    LogSendCodecChange("Capture size changed");
   }
 
+  if (frame.screencast) {
+    int screencast_min_bitrate =
+        options_.screencast_min_bitrate.GetWithDefaultIfUnset(0);
+    engine()->vie()->rtp()->SetMinTransmitBitrate(channel_id,
+                                                  screencast_min_bitrate);
+  } else {
+    // In case of switching from screencast to regular capture, set
+    // min bitrate padding and pacer back to defaults.
+    engine()->vie()->rtp()->SetMinTransmitBitrate(channel_id, 0);
+  }
+  engine()->vie()->rtp()->SetTransmissionSmoothingStatus(channel_id, true);
+
+  if (send_channel->IsActive()) {
+    if (!SetSendSsrcs(channel_id, send_params.stream, codec)) {
+      return false;
+    }
+  }
+
+  send_channel->set_send_params(send_params);
+  return true;
+}
+
+bool WebRtcVideoMediaChannel::ConfigureVieCodecFromSendParams(
+    int channel_id,
+    const VideoSendParams& send_params,
+    const CapturedFrameInfo& last_captured_frame_info,
+    webrtc::VideoCodec* codec_out) {
+  webrtc::VideoCodec codec = send_params.codec;
+
+  codec.width = static_cast<int>(last_captured_frame_info.width);
+  codec.height = static_cast<int>(last_captured_frame_info.height);
+  codec.targetBitrate = 0;
+  if (codec.codecType == webrtc::kVideoCodecVP8) {
+    codec.codecSpecific.VP8.numberOfTemporalLayers =
+        kDefaultNumberOfTemporalLayers;
+    codec.codecSpecific.VP8.resilience = webrtc::kResilienceOff;
+  }
+
+  if (last_captured_frame_info.screencast) {
+    codec.mode = webrtc::kScreensharing;
+    if (codec.codecType == webrtc::kVideoCodecVP8) {
+      codec.codecSpecific.VP8.denoisingOn = false;
+      codec.codecSpecific.VP8.automaticResizeOn = false;
+      codec.codecSpecific.VP8.frameDroppingOn = false;
+    }
+  } else {
+    codec.mode = webrtc::kRealtimeVideo;
+    if (codec.codecType == webrtc::kVideoCodecVP8) {
+      // TODO(pthatcher): Pass in options in VideoSendParams.
+      codec.codecSpecific.VP8.denoisingOn =
+          options_.video_noise_reduction.GetWithDefaultIfUnset(true);
+      codec.codecSpecific.VP8.automaticResizeOn = true;
+      codec.codecSpecific.VP8.frameDroppingOn = true;
+    }
+  }
+
+  *codec_out = codec;
   return true;
 }
 
@@ -3987,10 +4011,9 @@
 }
 
 void WebRtcVideoMediaChannel::OnMessage(rtc::Message* msg) {
-  FlushBlackFrameData* black_frame_data =
-      static_cast<FlushBlackFrameData*>(msg->pdata);
-  FlushBlackFrame(black_frame_data->ssrc, black_frame_data->timestamp);
-  delete black_frame_data;
+  FlushBlackFrameData* data = static_cast<FlushBlackFrameData*>(msg->pdata);
+  FlushBlackFrame(data->ssrc, data->timestamp, data->interval);
+  delete data;
 }
 
 int WebRtcVideoMediaChannel::SendPacket(int channel, const void* data,
@@ -4007,19 +4030,18 @@
 }
 
 void WebRtcVideoMediaChannel::QueueBlackFrame(uint32 ssrc, int64 timestamp,
-                                              int framerate) {
+                                              int interval) {
   if (timestamp) {
     FlushBlackFrameData* black_frame_data = new FlushBlackFrameData(
-        ssrc,
-        timestamp);
+        ssrc, timestamp, interval);
     const int delay_ms = static_cast<int>(
-        2 * cricket::VideoFormat::FpsToInterval(framerate) *
-        rtc::kNumMillisecsPerSec / rtc::kNumNanosecsPerSec);
+        2 * interval * rtc::kNumMillisecsPerSec / rtc::kNumNanosecsPerSec);
     worker_thread()->PostDelayed(delay_ms, this, 0, black_frame_data);
   }
 }
 
-void WebRtcVideoMediaChannel::FlushBlackFrame(uint32 ssrc, int64 timestamp) {
+void WebRtcVideoMediaChannel::FlushBlackFrame(
+    uint32 ssrc, int64 timestamp, int interval) {
   WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc);
   if (!send_channel) {
     return;
@@ -4041,7 +4063,7 @@
     WebRtcVideoFrame black_frame;
     // Black frame is not screencast.
     const bool screencasting = false;
-    const int64 timestamp_delta = send_channel->interval();
+    const int64 timestamp_delta = interval;
     if (!black_frame.InitToBlack(send_codec_->width, send_codec_->height, 1, 1,
                                  last_frame_elapsed_time + timestamp_delta,
                                  last_frame_time_stamp + timestamp_delta) ||
@@ -4094,7 +4116,7 @@
 
 bool WebRtcVideoMediaChannel::SetPrimaryAndRtxSsrcs(
     int channel_id, int idx, uint32 primary_ssrc,
-    const StreamParams& send_params) {
+    const StreamParams& sp) {
   LOG(LS_INFO) << "Set primary ssrc " << primary_ssrc
                << " on channel " << channel_id << " idx " << idx;
   if (engine()->vie()->rtp()->SetLocalSSRC(
@@ -4105,7 +4127,7 @@
   }
 
   uint32 rtx_ssrc = 0;
-  if (send_params.GetFidSsrc(primary_ssrc, &rtx_ssrc)) {
+  if (sp.GetFidSsrc(primary_ssrc, &rtx_ssrc)) {
     LOG(LS_INFO) << "Set rtx ssrc " << rtx_ssrc
                  << " on channel " << channel_id << " idx " << idx;
     if (engine()->vie()->rtp()->SetLocalSSRC(
diff --git a/media/webrtc/webrtcvideoengine.h b/media/webrtc/webrtcvideoengine.h
index 72ba9df..cc81ee9 100644
--- a/media/webrtc/webrtcvideoengine.h
+++ b/media/webrtc/webrtcvideoengine.h
@@ -234,6 +234,22 @@
   rtc::scoped_ptr<rtc::CpuMonitor> cpu_monitor_;
 };
 
+struct CapturedFrameInfo {
+  CapturedFrameInfo() : width(0), height(0), screencast(false) {}
+  CapturedFrameInfo(size_t width, size_t height, bool screencast) :
+      width(width), height(height), screencast(screencast) {}
+
+  size_t width;
+  size_t height;
+  bool screencast;
+};
+
+// TODO(pthatcher): Add VideoOptions.
+struct VideoSendParams {
+  webrtc::VideoCodec codec;
+  StreamParams stream;
+};
+
 class WebRtcVideoMediaChannel : public rtc::MessageHandler,
                                 public VideoMediaChannel,
                                 public webrtc::Transport {
@@ -316,6 +332,22 @@
   virtual int SendPacket(int channel, const void* data, int len) OVERRIDE;
   virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE;
 
+  bool ConferenceModeIsEnabled() const {
+    return options_.conference_mode.GetWithDefaultIfUnset(false);
+  }
+
+  // We take lots of things as input from applications (packaged in
+  // params), but ViE wants lots of those packed instead as a
+  // webrtc::VideoCodec.  This is where we convert between the inputs
+  // we get from the applications and the input to give to ViE.  We
+  // also configure the codec differently depending on the latest
+  // frame that we have received (in particular, depending on the
+  // resolution and whether the it was a screencast frame or not).
+  virtual bool ConfigureVieCodecFromSendParams(
+      int channel_id,
+      const VideoSendParams& send_params,
+      const CapturedFrameInfo& last_captured_frame_info,
+      webrtc::VideoCodec* codec);
   // Checks the current bitrate estimate and modifies the bitrates
   // accordingly, including converting kAutoBandwidth to the correct defaults.
   virtual void SanitizeBitrates(
@@ -359,6 +391,9 @@
   bool SetSendCodec(const webrtc::VideoCodec& codec);
   bool SetSendCodec(WebRtcVideoChannelSendInfo* send_channel,
                     const webrtc::VideoCodec& codec);
+  bool SetSendParams(WebRtcVideoChannelSendInfo* send_channel,
+                     const VideoSendParams& params);
+
   // Prepares the channel with channel id |info->channel_id()| to receive all
   // codecs in |receive_codecs_| and start receive packets.
   bool SetReceiveCodecs(WebRtcVideoChannelRecvInfo* info);
@@ -370,12 +405,6 @@
   bool MaybeRegisterExternalEncoder(
       WebRtcVideoChannelSendInfo* send_channel,
       const webrtc::VideoCodec& codec);
-  // Given captured video frame size, checks if we need to reset vie send codec.
-  // |reset| is set to whether resetting has happened on vie or not.
-  // Returns false on error.
-  bool MaybeResetVieSendCodec(WebRtcVideoChannelSendInfo* send_channel,
-                              int new_width, int new_height, bool is_screencast,
-                              bool* reset);
   // Helper function for starting the sending of media on all channels or
   // |channel_id|. Note that these two function do not change |sending_|.
   bool StartSend();
@@ -387,7 +416,7 @@
   bool SendIntraFrame(int channel_id);
 
   bool HasReadySendChannels();
-  bool DefaultSendChannelInUse();
+  bool DefaultSendChannelIsActive();
 
   // Returns the ssrc key corresponding to the provided local SSRC in
   // |ssrc_key|. The return value is true upon success.  If the local
@@ -414,14 +443,11 @@
   WebRtcVideoChannelRecvInfo* GetDefaultRecvChannel();
   WebRtcVideoChannelRecvInfo* GetRecvChannelBySsrc(uint32 ssrc);
 
-  bool InConferenceMode() const {
-    return options_.conference_mode.GetWithDefaultIfUnset(false);
-  }
   bool RemoveCapturer(uint32 ssrc);
 
   rtc::MessageQueue* worker_thread() { return engine_->worker_thread(); }
-  void QueueBlackFrame(uint32 ssrc, int64 timestamp, int framerate);
-  void FlushBlackFrame(uint32 ssrc, int64 timestamp);
+  void QueueBlackFrame(uint32 ssrc, int64 timestamp, int interval);
+  void FlushBlackFrame(uint32 ssrc, int64 timestamp, int interval);
 
   void SetNetworkTransmissionState(bool is_transmitting);
 
diff --git a/media/webrtc/webrtcvideoengine2.cc b/media/webrtc/webrtcvideoengine2.cc
index 96df0f7..d79f71d 100644
--- a/media/webrtc/webrtcvideoengine2.cc
+++ b/media/webrtc/webrtcvideoengine2.cc
@@ -42,6 +42,7 @@
 #include "webrtc/base/logging.h"
 #include "webrtc/base/stringutils.h"
 #include "webrtc/call.h"
+#include "webrtc/video_decoder.h"
 #include "webrtc/video_encoder.h"
 
 #define UNIMPLEMENTED                                                 \
@@ -56,10 +57,18 @@
   return _stricmp(name1.c_str(), name2.c_str()) == 0;
 }
 
+const char* kInternallySupportedCodecs[] = {
+    kVp8CodecName,
+};
+
 // True if codec is supported by a software implementation that's always
 // available.
 static bool CodecIsInternallySupported(const std::string& codec_name) {
-  return CodecNameMatches(codec_name, kVp8CodecName);
+  for (size_t i = 0; i < ARRAY_SIZE(kInternallySupportedCodecs); ++i) {
+    if (CodecNameMatches(codec_name, kInternallySupportedCodecs[i]))
+      return true;
+  }
+  return false;
 }
 
 static std::string CodecVectorToString(const std::vector<VideoCodec>& codecs) {
@@ -117,6 +126,8 @@
 
 static const int kDefaultRtcpReceiverReportSsrc = 1;
 
+static const int kConferenceModeTemporalLayerBitrateBps = 100000;
+
 // External video encoders are given payloads 120-127. This also means that we
 // only support up to 8 external payload types.
 static const int kExternalVideoPayloadTypeBase = 120;
@@ -238,8 +249,9 @@
     const VideoOptions& options,
     size_t num_streams) {
   if (num_streams != 1) {
-    LOG(LS_ERROR) << "Unsupported number of streams: " << num_streams;
-    return std::vector<webrtc::VideoStream>();
+    LOG(LS_WARNING) << "Unsupported number of streams (" << num_streams
+                    << "), falling back to one.";
+    num_streams = 1;
   }
 
   webrtc::VideoStream stream;
@@ -250,6 +262,12 @@
 
   int min_bitrate = kMinVideoBitrate;
   codec.GetParam(kCodecParamMinBitrate, &min_bitrate);
+  // Clamp the min video bitrate, this is set from JavaScript directly and needs
+  // to be sanitized.
+  if (min_bitrate < kMinVideoBitrate) {
+    min_bitrate = kMinVideoBitrate;
+  }
+
   int max_bitrate = kMaxVideoBitrate;
   codec.GetParam(kCodecParamMaxBitrate, &max_bitrate);
   stream.min_bitrate_bps = min_bitrate * 1000;
@@ -419,10 +437,12 @@
   assert(initialized_);
   LOG(LS_INFO) << "CreateChannel: "
                << (voice_channel != NULL ? "With" : "Without")
-               << " voice channel.";
+               << " voice channel. Options: " << options.ToString();
   WebRtcVideoChannel2* channel =
       new WebRtcVideoChannel2(call_factory_,
+                              voice_engine_,
                               voice_channel,
+                              options,
                               external_encoder_factory_,
                               external_decoder_factory_,
                               GetVideoEncoderFactory());
@@ -430,7 +450,6 @@
     delete channel;
     return NULL;
   }
-  channel->SetOptions(options);
   channel->SetRecvCodecs(video_codecs_);
   return channel;
 }
@@ -744,24 +763,35 @@
 
 WebRtcVideoChannel2::WebRtcVideoChannel2(
     WebRtcCallFactory* call_factory,
+    WebRtcVoiceEngine* voice_engine,
     VoiceMediaChannel* voice_channel,
+    const VideoOptions& options,
     WebRtcVideoEncoderFactory* external_encoder_factory,
     WebRtcVideoDecoderFactory* external_decoder_factory,
     WebRtcVideoEncoderFactory2* encoder_factory)
     : unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
+      voice_channel_(voice_channel),
       external_encoder_factory_(external_encoder_factory),
       external_decoder_factory_(external_decoder_factory),
       encoder_factory_(encoder_factory) {
-  // TODO(pbos): Connect the video and audio with |voice_channel|.
+  SetDefaultOptions();
+  options_.SetAll(options);
   webrtc::Call::Config config(this);
   config.overuse_callback = this;
+  if (voice_engine != NULL) {
+    config.voice_engine = voice_engine->voe()->engine();
+  }
+
+  // Set start bitrate for the call. A default is provided by SetDefaultOptions.
+  int start_bitrate_kbps;
+  options_.video_start_bitrate.Get(&start_bitrate_kbps);
+  config.stream_start_bitrate_bps = start_bitrate_kbps * 1000;
+
   call_.reset(call_factory->CreateCall(config));
 
   rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc;
   sending_ = false;
   default_send_ssrc_ = 0;
-
-  SetDefaultOptions();
 }
 
 void WebRtcVideoChannel2::SetDefaultOptions() {
@@ -769,6 +799,9 @@
   options_.suspend_below_min_bitrate.Set(false);
   options_.use_payload_padding.Set(false);
   options_.video_noise_reduction.Set(true);
+  options_.video_start_bitrate.Set(
+      webrtc::Call::Config::kDefaultStartBitrateBps / 1000);
+  options_.screencast_min_bitrate.Set(0);
 }
 
 WebRtcVideoChannel2::~WebRtcVideoChannel2() {
@@ -789,6 +822,37 @@
 
 bool WebRtcVideoChannel2::Init() { return true; }
 
+bool WebRtcVideoChannel2::CodecIsExternallySupported(
+    const std::string& name) const {
+  if (external_encoder_factory_ == NULL) {
+    return false;
+  }
+
+  const std::vector<WebRtcVideoEncoderFactory::VideoCodec> external_codecs =
+      external_encoder_factory_->codecs();
+  for (size_t c = 0; c < external_codecs.size(); ++c) {
+    if (CodecNameMatches(name, external_codecs[c].name)) {
+      return true;
+    }
+  }
+  return false;
+}
+
+std::vector<WebRtcVideoChannel2::VideoCodecSettings>
+WebRtcVideoChannel2::FilterSupportedCodecs(
+    const std::vector<WebRtcVideoChannel2::VideoCodecSettings>& mapped_codecs)
+    const {
+  std::vector<VideoCodecSettings> supported_codecs;
+  for (size_t i = 0; i < mapped_codecs.size(); ++i) {
+    const VideoCodecSettings& codec = mapped_codecs[i];
+    if (CodecIsInternallySupported(codec.codec.name) ||
+        CodecIsExternallySupported(codec.codec.name)) {
+      supported_codecs.push_back(codec);
+    }
+  }
+  return supported_codecs;
+}
+
 bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector<VideoCodec>& codecs) {
   LOG(LS_INFO) << "SetRecvCodecs: " << CodecVectorToString(codecs);
   if (!ValidateCodecFormats(codecs)) {
@@ -797,21 +861,19 @@
 
   const std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(codecs);
   if (mapped_codecs.empty()) {
-    LOG(LS_ERROR) << "SetRecvCodecs called without video codec payloads.";
+    LOG(LS_ERROR) << "SetRecvCodecs called without any video codecs.";
     return false;
   }
 
-  // TODO(pbos): Add a decoder factory which controls supported codecs.
-  // Blocked on webrtc:2854.
-  for (size_t i = 0; i < mapped_codecs.size(); ++i) {
-    if (!CodecNameMatches(mapped_codecs[i].codec.name, kVp8CodecName)) {
-      LOG(LS_ERROR) << "SetRecvCodecs called with unsupported codec: '"
-                    << mapped_codecs[i].codec.name << "'";
-      return false;
-    }
+  const std::vector<VideoCodecSettings> supported_codecs =
+      FilterSupportedCodecs(mapped_codecs);
+
+  if (mapped_codecs.size() != supported_codecs.size()) {
+    LOG(LS_ERROR) << "SetRecvCodecs called with unsupported video codecs.";
+    return false;
   }
 
-  recv_codecs_ = mapped_codecs;
+  recv_codecs_ = supported_codecs;
 
   rtc::CritScope stream_lock(&stream_crit_);
   for (std::map<uint32, WebRtcVideoReceiveStream*>::iterator it =
@@ -998,8 +1060,20 @@
 
   webrtc::VideoReceiveStream::Config config;
   ConfigureReceiverRtp(&config, sp);
-  receive_streams_[ssrc] =
-      new WebRtcVideoReceiveStream(call_.get(), config, recv_codecs_);
+
+  // Set up A/V sync if there is a VoiceChannel.
+  // TODO(pbos): The A/V is synched by the receiving channel. So we need to know
+  // the SSRC of the remote audio channel in order to sync the correct webrtc
+  // VoiceEngine channel. For now sync the first channel in non-conference to
+  // match existing behavior in WebRtcVideoEngine.
+  if (voice_channel_ != NULL && receive_streams_.empty() &&
+      !options_.conference_mode.GetWithDefaultIfUnset(false)) {
+    config.audio_channel_id =
+        static_cast<WebRtcVoiceMediaChannel*>(voice_channel_)->voe_channel();
+  }
+
+  receive_streams_[ssrc] = new WebRtcVideoReceiveStream(
+      call_.get(), external_decoder_factory_, config, recv_codecs_);
 
   return true;
 }
@@ -1284,12 +1358,13 @@
                           rtc::Socket::OPT_RCVBUF,
                           kVideoRtpBufferSize);
 
-  // TODO(sriniv): Remove or re-enable this.
-  // As part of b/8030474, send-buffer is size now controlled through
-  // portallocator flags.
-  // network_interface_->SetOption(NetworkInterface::ST_RTP,
-  //                              rtc::Socket::OPT_SNDBUF,
-  //                              kVideoRtpBufferSize);
+  // Speculative change to increase the outbound socket buffer size.
+  // In b/15152257, we are seeing a significant number of packets discarded
+  // due to lack of socket buffer space, although it's not yet clear what the
+  // ideal value should be.
+  MediaChannel::SetOption(NetworkInterface::ST_RTP,
+                          rtc::Socket::OPT_SNDBUF,
+                          kVideoRtpBufferSize);
 }
 
 void WebRtcVideoChannel2::UpdateAspectRatio(int ratio_w, int ratio_h) {
@@ -1663,30 +1738,47 @@
 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions(
     int width,
     int height,
-    bool override_max) {
+    bool is_screencast) {
+  if (last_dimensions_.width == width && last_dimensions_.height == height &&
+      last_dimensions_.is_screencast == is_screencast) {
+    // Configured using the same parameters, do not reconfigure.
+    return;
+  }
+
+  last_dimensions_.width = width;
+  last_dimensions_.height = height;
+  last_dimensions_.is_screencast = is_screencast;
+
   assert(!parameters_.encoder_config.streams.empty());
   LOG(LS_VERBOSE) << "SetDimensions: " << width << "x" << height;
 
   VideoCodecSettings codec_settings;
   parameters_.codec_settings.Get(&codec_settings);
   // Restrict dimensions according to codec max.
-  if (!override_max) {
+  if (!is_screencast) {
     if (codec_settings.codec.width < width)
       width = codec_settings.codec.width;
     if (codec_settings.codec.height < height)
       height = codec_settings.codec.height;
   }
 
-  if (parameters_.encoder_config.streams.back().width == width &&
-      parameters_.encoder_config.streams.back().height == height) {
-    return;
-  }
-
   webrtc::VideoEncoderConfig encoder_config = parameters_.encoder_config;
   encoder_config.encoder_specific_settings =
       encoder_factory_->CreateVideoEncoderSettings(codec_settings.codec,
                                                    parameters_.options);
 
+  if (is_screencast) {
+    int screencast_min_bitrate_kbps;
+    parameters_.options.screencast_min_bitrate.Get(
+        &screencast_min_bitrate_kbps);
+    encoder_config.min_transmit_bitrate_bps =
+        screencast_min_bitrate_kbps * 1000;
+    encoder_config.content_type = webrtc::VideoEncoderConfig::kScreenshare;
+  } else {
+    encoder_config.min_transmit_bitrate_bps = 0;
+    encoder_config.content_type = webrtc::VideoEncoderConfig::kRealtimeVideo;
+  }
+
   VideoCodec codec = codec_settings.codec;
   codec.width = width;
   codec.height = height;
@@ -1694,6 +1786,14 @@
   encoder_config.streams = encoder_factory_->CreateVideoStreams(
       codec, parameters_.options, parameters_.config.rtp.ssrcs.size());
 
+  // Conference mode screencast uses 2 temporal layers split at 100kbit.
+  if (parameters_.options.conference_mode.GetWithDefaultIfUnset(false) &&
+      is_screencast && encoder_config.streams.size() == 1) {
+    encoder_config.streams[0].temporal_layer_thresholds_bps.clear();
+    encoder_config.streams[0].temporal_layer_thresholds_bps.push_back(
+        kConferenceModeTemporalLayerBitrateBps);
+  }
+
   bool stream_reconfigured = stream_->ReconfigureVideoEncoder(encoder_config);
 
   encoder_factory_->DestroyVideoEncoderSettings(
@@ -1826,11 +1926,13 @@
 
 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream(
     webrtc::Call* call,
+    WebRtcVideoDecoderFactory* external_decoder_factory,
     const webrtc::VideoReceiveStream::Config& config,
     const std::vector<VideoCodecSettings>& recv_codecs)
     : call_(call),
       stream_(NULL),
       config_(config),
+      external_decoder_factory_(external_decoder_factory),
       renderer_(NULL),
       last_width_(-1),
       last_height_(-1) {
@@ -1841,39 +1943,67 @@
 
 WebRtcVideoChannel2::WebRtcVideoReceiveStream::~WebRtcVideoReceiveStream() {
   call_->DestroyVideoReceiveStream(stream_);
+  ClearDecoders(&allocated_decoders_);
+}
+
+WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder
+WebRtcVideoChannel2::WebRtcVideoReceiveStream::CreateOrReuseVideoDecoder(
+    std::vector<AllocatedDecoder>* old_decoders,
+    const VideoCodec& codec) {
+  webrtc::VideoCodecType type = CodecTypeFromName(codec.name);
+
+  for (size_t i = 0; i < old_decoders->size(); ++i) {
+    if ((*old_decoders)[i].type == type) {
+      AllocatedDecoder decoder = (*old_decoders)[i];
+      (*old_decoders)[i] = old_decoders->back();
+      old_decoders->pop_back();
+      return decoder;
+    }
+  }
+
+  if (external_decoder_factory_ != NULL) {
+    webrtc::VideoDecoder* decoder =
+        external_decoder_factory_->CreateVideoDecoder(type);
+    if (decoder != NULL) {
+      return AllocatedDecoder(decoder, type, true);
+    }
+  }
+
+  if (type == webrtc::kVideoCodecVP8) {
+    return AllocatedDecoder(
+        webrtc::VideoDecoder::Create(webrtc::VideoDecoder::kVp8), type, false);
+  }
+
+  // This shouldn't happen, we should not be trying to create something we don't
+  // support.
+  assert(false);
+  return AllocatedDecoder(NULL, webrtc::kVideoCodecUnknown, false);
 }
 
 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvCodecs(
     const std::vector<VideoCodecSettings>& recv_codecs) {
+  std::vector<AllocatedDecoder> old_decoders = allocated_decoders_;
+  allocated_decoders_.clear();
+  config_.decoders.clear();
+  for (size_t i = 0; i < recv_codecs.size(); ++i) {
+    AllocatedDecoder allocated_decoder =
+        CreateOrReuseVideoDecoder(&old_decoders, recv_codecs[i].codec);
+    allocated_decoders_.push_back(allocated_decoder);
+
+    webrtc::VideoReceiveStream::Decoder decoder;
+    decoder.decoder = allocated_decoder.decoder;
+    decoder.payload_type = recv_codecs[i].codec.id;
+    decoder.payload_name = recv_codecs[i].codec.name;
+    config_.decoders.push_back(decoder);
+  }
+
   // TODO(pbos): Reconfigure RTX based on incoming recv_codecs.
-  // TODO(pbos): Base receive codecs off recv_codecs_ and set up using a
-  // DecoderFactory similar to send side. Pending webrtc:2854.
-  // Also set up default codecs if there's nothing in recv_codecs_.
-  webrtc::VideoCodec codec;
-  memset(&codec, 0, sizeof(codec));
-
-  codec.plType = kDefaultVideoCodecPref.payload_type;
-  strcpy(codec.plName, kDefaultVideoCodecPref.name);
-  codec.codecType = webrtc::kVideoCodecVP8;
-  codec.codecSpecific.VP8.resilience = webrtc::kResilientStream;
-  codec.codecSpecific.VP8.numberOfTemporalLayers = 1;
-  codec.codecSpecific.VP8.denoisingOn = true;
-  codec.codecSpecific.VP8.errorConcealmentOn = false;
-  codec.codecSpecific.VP8.automaticResizeOn = false;
-  codec.codecSpecific.VP8.frameDroppingOn = true;
-  codec.codecSpecific.VP8.keyFrameInterval = 3000;
-  // Bitrates don't matter and are ignored for the receiver. This is put in to
-  // have the current underlying implementation accept the VideoCodec.
-  codec.minBitrate = codec.startBitrate = codec.maxBitrate = 300;
-  config_.codecs.clear();
-  config_.codecs.push_back(codec);
-
   config_.rtp.fec = recv_codecs.front().fec;
-
   config_.rtp.nack.rtp_history_ms =
       IsNackEnabled(recv_codecs.begin()->codec) ? kNackHistoryMs : 0;
   config_.rtp.remb = IsRembEnabled(recv_codecs.begin()->codec);
 
+  ClearDecoders(&old_decoders);
   RecreateWebRtcStream();
 }
 
@@ -1891,6 +2021,19 @@
   stream_->Start();
 }
 
+void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders(
+    std::vector<AllocatedDecoder>* allocated_decoders) {
+  for (size_t i = 0; i < allocated_decoders->size(); ++i) {
+    if ((*allocated_decoders)[i].external) {
+      external_decoder_factory_->DestroyVideoDecoder(
+          (*allocated_decoders)[i].decoder);
+    } else {
+      delete (*allocated_decoders)[i].decoder;
+    }
+  }
+  allocated_decoders->clear();
+}
+
 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RenderFrame(
     const webrtc::I420VideoFrame& frame,
     int time_to_render_ms) {
@@ -2050,31 +2193,6 @@
   return video_codecs;
 }
 
-std::vector<WebRtcVideoChannel2::VideoCodecSettings>
-WebRtcVideoChannel2::FilterSupportedCodecs(
-    const std::vector<WebRtcVideoChannel2::VideoCodecSettings>& mapped_codecs) {
-  std::vector<VideoCodecSettings> supported_codecs;
-  for (size_t i = 0; i < mapped_codecs.size(); ++i) {
-    const VideoCodecSettings& codec = mapped_codecs[i];
-    if (CodecIsInternallySupported(codec.codec.name)) {
-      supported_codecs.push_back(codec);
-    }
-
-    if (external_encoder_factory_ == NULL) {
-      continue;
-    }
-    const std::vector<WebRtcVideoEncoderFactory::VideoCodec> external_codecs =
-        external_encoder_factory_->codecs();
-    for (size_t c = 0; c < external_codecs.size(); ++c) {
-      if (CodecNameMatches(codec.codec.name, external_codecs[c].name)) {
-        supported_codecs.push_back(codec);
-        break;
-      }
-    }
-  }
-  return supported_codecs;
-}
-
 }  // namespace cricket
 
 #endif  // HAVE_WEBRTC_VIDEO
diff --git a/media/webrtc/webrtcvideoengine2.h b/media/webrtc/webrtcvideoengine2.h
index 8831a1b..0b812ef 100644
--- a/media/webrtc/webrtcvideoengine2.h
+++ b/media/webrtc/webrtcvideoengine2.h
@@ -211,7 +211,9 @@
                             public webrtc::LoadObserver {
  public:
   WebRtcVideoChannel2(WebRtcCallFactory* call_factory,
+                      WebRtcVoiceEngine* voice_engine,
                       VoiceMediaChannel* voice_channel,
+                      const VideoOptions& options,
                       WebRtcVideoEncoderFactory* external_encoder_factory,
                       WebRtcVideoDecoderFactory* external_decoder_factory,
                       WebRtcVideoEncoderFactory2* encoder_factory);
@@ -274,6 +276,7 @@
  private:
   void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config,
                             const StreamParams& sp) const;
+  bool CodecIsExternallySupported(const std::string& name) const;
 
   struct VideoCodecSettings {
     VideoCodecSettings();
@@ -345,6 +348,13 @@
       bool external;
     };
 
+    struct LastDimensions {
+      LastDimensions() : width(-1), height(-1), is_screencast(false) {}
+      int width;
+      int height;
+      bool is_screencast;
+    };
+
     AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec)
         EXCLUSIVE_LOCKS_REQUIRED(lock_);
     void DestroyVideoEncoder(AllocatedEncoder* encoder);
@@ -352,8 +362,7 @@
                             const VideoOptions& options)
         EXCLUSIVE_LOCKS_REQUIRED(lock_);
     void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_);
-    // When |override_max| is false constrain width/height to codec dimensions.
-    void SetDimensions(int width, int height, bool override_max)
+    void SetDimensions(int width, int height, bool is_screencast)
         EXCLUSIVE_LOCKS_REQUIRED(lock_);
 
     webrtc::Call* const call_;
@@ -364,6 +373,7 @@
     webrtc::VideoSendStream* stream_ GUARDED_BY(lock_);
     VideoSendStreamParameters parameters_ GUARDED_BY(lock_);
     AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_);
+    LastDimensions last_dimensions_ GUARDED_BY(lock_);
 
     VideoCapturer* capturer_ GUARDED_BY(lock_);
     bool sending_ GUARDED_BY(lock_);
@@ -381,6 +391,7 @@
    public:
     WebRtcVideoReceiveStream(
         webrtc::Call*,
+        WebRtcVideoDecoderFactory* external_decoder_factory,
         const webrtc::VideoReceiveStream::Config& config,
         const std::vector<VideoCodecSettings>& recv_codecs);
     ~WebRtcVideoReceiveStream();
@@ -397,14 +408,32 @@
     VideoReceiverInfo GetVideoReceiverInfo();
 
    private:
+    struct AllocatedDecoder {
+      AllocatedDecoder(webrtc::VideoDecoder* decoder,
+                       webrtc::VideoCodecType type,
+                       bool external)
+          : decoder(decoder), type(type), external(external) {}
+      webrtc::VideoDecoder* decoder;
+      webrtc::VideoCodecType type;
+      bool external;
+    };
+
     void SetSize(int width, int height);
     void RecreateWebRtcStream();
 
+    AllocatedDecoder CreateOrReuseVideoDecoder(
+        std::vector<AllocatedDecoder>* old_decoder,
+        const VideoCodec& codec);
+    void ClearDecoders(std::vector<AllocatedDecoder>* allocated_decoders);
+
     webrtc::Call* const call_;
 
     webrtc::VideoReceiveStream* stream_;
     webrtc::VideoReceiveStream::Config config_;
 
+    WebRtcVideoDecoderFactory* const external_decoder_factory_;
+    std::vector<AllocatedDecoder> allocated_decoders_;
+
     rtc::CriticalSection renderer_lock_;
     cricket::VideoRenderer* renderer_ GUARDED_BY(renderer_lock_);
     int last_width_ GUARDED_BY(renderer_lock_);
@@ -423,7 +452,7 @@
   static std::vector<VideoCodecSettings> MapCodecs(
       const std::vector<VideoCodec>& codecs);
   std::vector<VideoCodecSettings> FilterSupportedCodecs(
-      const std::vector<VideoCodecSettings>& mapped_codecs);
+      const std::vector<VideoCodecSettings>& mapped_codecs) const;
 
   void FillSenderStats(VideoMediaInfo* info);
   void FillReceiverStats(VideoMediaInfo* info);
@@ -449,6 +478,7 @@
   Settable<VideoCodecSettings> send_codec_;
   std::vector<webrtc::RtpExtension> send_rtp_extensions_;
 
+  VoiceMediaChannel* const voice_channel_;
   WebRtcVideoEncoderFactory* const external_encoder_factory_;
   WebRtcVideoDecoderFactory* const external_decoder_factory_;
   WebRtcVideoEncoderFactory2* const encoder_factory_;
diff --git a/media/webrtc/webrtcvideoengine2_unittest.cc b/media/webrtc/webrtcvideoengine2_unittest.cc
index 85b7b9e..0b85723 100644
--- a/media/webrtc/webrtcvideoengine2_unittest.cc
+++ b/media/webrtc/webrtcvideoengine2_unittest.cc
@@ -34,6 +34,7 @@
 #include "talk/media/webrtc/webrtcvideochannelfactory.h"
 #include "talk/media/webrtc/webrtcvideoengine2.h"
 #include "talk/media/webrtc/webrtcvideoengine2_unittest.h"
+#include "talk/media/webrtc/webrtcvoiceengine.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/stringutils.h"
 #include "webrtc/video_encoder.h"
@@ -79,10 +80,14 @@
   ReconfigureVideoEncoder(encoder_config);
 }
 
-webrtc::VideoSendStream::Config FakeVideoSendStream::GetConfig() {
+webrtc::VideoSendStream::Config FakeVideoSendStream::GetConfig() const {
   return config_;
 }
 
+webrtc::VideoEncoderConfig FakeVideoSendStream::GetEncoderConfig() const {
+  return encoder_config_;
+}
+
 std::vector<webrtc::VideoStream> FakeVideoSendStream::GetVideoStreams() {
   return encoder_config_.streams;
 }
@@ -170,9 +175,6 @@
   receiving_ = false;
 }
 
-void FakeVideoReceiveStream::GetCurrentReceiveCodec(webrtc::VideoCodec* codec) {
-}
-
 FakeCall::FakeCall(const webrtc::Call::Config& config)
     : config_(config), network_state_(kNetworkUp) {
   SetVideoCodecs(GetDefaultVideoCodecs());
@@ -327,9 +329,32 @@
   }
 
  protected:
+  class FakeCallFactory : public WebRtcCallFactory {
+   public:
+    FakeCallFactory() : fake_call_(NULL) {}
+    FakeCall* GetCall() { return fake_call_; }
+
+   private:
+    virtual webrtc::Call* CreateCall(
+        const webrtc::Call::Config& config) OVERRIDE {
+      assert(fake_call_ == NULL);
+      fake_call_ = new FakeCall(config);
+      return fake_call_;
+    }
+
+    FakeCall* fake_call_;
+  };
+
   VideoMediaChannel* SetUpForExternalEncoderFactory(
       cricket::WebRtcVideoEncoderFactory* encoder_factory,
       const std::vector<VideoCodec>& codecs);
+
+  VideoMediaChannel* SetUpForExternalDecoderFactory(
+      cricket::WebRtcVideoDecoderFactory* decoder_factory,
+      const std::vector<VideoCodec>& codecs);
+
+  void TestStartBitrate(bool override_start_bitrate, int start_bitrate_bps);
+
   WebRtcVideoEngine2 engine_;
   VideoCodec default_codec_;
   VideoCodec default_red_codec_;
@@ -337,9 +362,42 @@
   VideoCodec default_rtx_codec_;
 };
 
-// TODO(pbos): Add test that verifies that sync is configured properly.
-TEST_F(WebRtcVideoEngine2Test, DISABLED_CreateChannelWithVoiceEngine) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
+TEST_F(WebRtcVideoEngine2Test, ConfiguresAvSyncForFirstReceiveChannel) {
+  FakeCallFactory call_factory;
+  engine_.SetCallFactory(&call_factory);
+
+  WebRtcVoiceEngine voice_engine;
+  engine_.SetVoiceEngine(&voice_engine);
+  voice_engine.Init(rtc::Thread::Current());
+  engine_.Init(rtc::Thread::Current());
+
+  rtc::scoped_ptr<VoiceMediaChannel> voice_channel(
+      voice_engine.CreateChannel());
+  ASSERT_TRUE(voice_channel.get() != NULL);
+  WebRtcVoiceMediaChannel* webrtc_voice_channel =
+      static_cast<WebRtcVoiceMediaChannel*>(voice_channel.get());
+  ASSERT_NE(webrtc_voice_channel->voe_channel(), -1);
+  rtc::scoped_ptr<VideoMediaChannel> channel(
+      engine_.CreateChannel(cricket::VideoOptions(), voice_channel.get()));
+
+  FakeCall* fake_call = call_factory.GetCall();
+  ASSERT_TRUE(fake_call != NULL);
+
+  webrtc::Call::Config call_config = fake_call->GetConfig();
+
+  ASSERT_TRUE(voice_engine.voe()->engine() != NULL);
+  ASSERT_EQ(voice_engine.voe()->engine(), call_config.voice_engine);
+
+  EXPECT_TRUE(channel->AddRecvStream(StreamParams::CreateLegacy(kSsrc)));
+  EXPECT_TRUE(channel->AddRecvStream(StreamParams::CreateLegacy(kSsrc + 1)));
+  std::vector<FakeVideoReceiveStream*> receive_streams =
+      fake_call->GetVideoReceiveStreams();
+
+  ASSERT_EQ(2u, receive_streams.size());
+  EXPECT_EQ(webrtc_voice_channel->voe_channel(),
+            receive_streams[0]->GetConfig().audio_channel_id);
+  EXPECT_EQ(-1, receive_streams[1]->GetConfig().audio_channel_id)
+      << "AV sync should only be set up for the first receive channel.";
 }
 
 TEST_F(WebRtcVideoEngine2Test, FindCodec) {
@@ -425,6 +483,39 @@
   FAIL() << "Absolute Sender Time extension not in header-extension list.";
 }
 
+void WebRtcVideoEngine2Test::TestStartBitrate(bool override_start_bitrate,
+                                              int start_bitrate_bps) {
+  FakeCallFactory call_factory;
+  engine_.SetCallFactory(&call_factory);
+
+  engine_.Init(rtc::Thread::Current());
+
+  cricket::VideoOptions options;
+  if (override_start_bitrate) {
+    options.video_start_bitrate.Set(start_bitrate_bps / 1000);
+  }
+
+  rtc::scoped_ptr<VideoMediaChannel> channel(
+      engine_.CreateChannel(options, NULL));
+
+  EXPECT_EQ(override_start_bitrate
+                ? start_bitrate_bps
+                : webrtc::Call::Config::kDefaultStartBitrateBps,
+            call_factory.GetCall()->GetConfig().stream_start_bitrate_bps);
+}
+
+TEST_F(WebRtcVideoEngine2Test, UsesCorrectDefaultStartBitrate) {
+  TestStartBitrate(false, -1);
+}
+
+TEST_F(WebRtcVideoEngine2Test, CreateChannelCanUseIncreasedStartBitrate) {
+  TestStartBitrate(true, 2 * webrtc::Call::Config::kDefaultStartBitrateBps);
+}
+
+TEST_F(WebRtcVideoEngine2Test, CreateChannelCanUseDecreasedStartBitrate) {
+  TestStartBitrate(true, webrtc::Call::Config::kDefaultStartBitrateBps / 2);
+}
+
 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) {
   engine_.Init(rtc::Thread::Current());
   rtc::scoped_ptr<VideoMediaChannel> channel(
@@ -492,6 +583,19 @@
   return channel;
 }
 
+VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory(
+    cricket::WebRtcVideoDecoderFactory* decoder_factory,
+    const std::vector<VideoCodec>& codecs) {
+  engine_.SetExternalDecoderFactory(decoder_factory);
+  engine_.Init(rtc::Thread::Current());
+
+  VideoMediaChannel* channel =
+      engine_.CreateChannel(cricket::VideoOptions(), NULL);
+  EXPECT_TRUE(channel->SetRecvCodecs(codecs));
+
+  return channel;
+}
+
 TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) {
   cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
   encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264");
@@ -545,6 +649,50 @@
   EXPECT_EQ("H264", external_codec.name);
 }
 
+TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) {
+  cricket::FakeWebRtcVideoDecoderFactory decoder_factory;
+  decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
+  std::vector<cricket::VideoCodec> codecs;
+  codecs.push_back(kVp8Codec);
+
+  rtc::scoped_ptr<VideoMediaChannel> channel(
+      SetUpForExternalDecoderFactory(&decoder_factory, codecs));
+
+  EXPECT_TRUE(
+      channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
+  ASSERT_EQ(1u, decoder_factory.decoders().size());
+
+  // Setting codecs of the same type should not reallocate the decoder.
+  EXPECT_TRUE(channel->SetRecvCodecs(codecs));
+  EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders());
+
+  // Remove stream previously added to free the external decoder instance.
+  EXPECT_TRUE(channel->RemoveRecvStream(kSsrc));
+  EXPECT_EQ(0u, decoder_factory.decoders().size());
+}
+
+// Verifies that we can set up decoders that are not internally supported.
+TEST_F(WebRtcVideoEngine2Test, RegisterExternalH264DecoderIfSupported) {
+  // TODO(pbos): Do not assume that encoder/decoder support is symmetric. We
+  // can't even query the WebRtcVideoDecoderFactory for supported codecs.
+  // For now we add a FakeWebRtcVideoEncoderFactory to add H264 to supported
+  // codecs.
+  cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
+  encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264");
+  engine_.SetExternalEncoderFactory(&encoder_factory);
+  cricket::FakeWebRtcVideoDecoderFactory decoder_factory;
+  decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264);
+  std::vector<cricket::VideoCodec> codecs;
+  codecs.push_back(kH264Codec);
+
+  rtc::scoped_ptr<VideoMediaChannel> channel(
+      SetUpForExternalDecoderFactory(&decoder_factory, codecs));
+
+  EXPECT_TRUE(
+      channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
+  ASSERT_EQ(1u, decoder_factory.decoders().size());
+}
+
 class WebRtcVideoEngine2BaseTest
     : public VideoEngineTest<cricket::WebRtcVideoEngine2> {
  protected:
@@ -670,7 +818,7 @@
   EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get()));
 
   // Capture format HD -> adapt (OnOutputFormatRequest VGA) -> VGA.
-  cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0);
+  cricket::VideoCodec codec = kVp8Codec720p;
   EXPECT_TRUE(SetOneCodec(codec));
   codec.width /= 2;
   codec.height /= 2;
@@ -841,60 +989,6 @@
   uint32 last_ssrc_;
 };
 
-TEST_F(WebRtcVideoChannel2Test, DISABLED_MaxBitrateResetsWithConferenceMode) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_StartSendBitrate) {
-  // TODO(pbos): Is this test testing vie_ ? this is confusing. No API to set
-  // start send bitrate from outside? Add defaults here that should be kept?
-  std::vector<cricket::VideoCodec> codec_list;
-  codec_list.push_back(kVp8Codec);
-  EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
-  const unsigned int kVideoMinSendBitrateKbps = 50;
-  const unsigned int kVideoTargetSendBitrateKbps = 300;
-  const unsigned int kVideoMaxSendBitrateKbps = 2000;
-  FakeVideoSendStream* stream = AddSendStream();
-  std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
-  ASSERT_EQ(1u, video_streams.size());
-  EXPECT_EQ(kVideoMinSendBitrateKbps,
-            video_streams.back().min_bitrate_bps / 1000);
-  EXPECT_EQ(kVideoTargetSendBitrateKbps,
-            video_streams.back().target_bitrate_bps / 1000);
-  EXPECT_EQ(kVideoMaxSendBitrateKbps,
-            video_streams.back().max_bitrate_bps / 1000);
-#if 0
-  // TODO(pbos): un-#if
-  VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
-                     kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
-                     kVideoDefaultStartSendBitrateKbps);
-  EXPECT_EQ(0, vie_.StartSend(send_channel));
-
-  // Increase the send bitrate and verify it is used as start bitrate.
-  const unsigned int kVideoSendBitrateBps = 768000;
-  vie_.SetSendBitrates(send_channel, kVideoSendBitrateBps, 0, 0);
-  EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
-  VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
-                     kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
-                     kVideoSendBitrateBps / 1000);
-
-  // Never set a start bitrate higher than the max bitrate.
-  vie_.SetSendBitrates(send_channel, kVideoMaxSendBitrateKbps + 500, 0, 0);
-  EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
-  VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
-                     kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
-                     kVideoDefaultStartSendBitrateKbps);
-
-  // Use the default start bitrate if the send bitrate is lower.
-  vie_.SetSendBitrates(send_channel, kVideoDefaultStartSendBitrateKbps - 50, 0,
-                       0);
-  EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
-  VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
-                     kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
-                     kVideoDefaultStartSendBitrateKbps);
-#endif
-}
-
 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) {
   EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
   EXPECT_TRUE(channel_->SetSend(true));
@@ -1188,8 +1282,97 @@
   FAIL() << "Not implemented.";  // TODO(pbos): Implement.
 }
 
-TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthScreencast) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
+TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
+  static const int kScreenshareMinBitrateKbps = 800;
+  cricket::VideoCodec codec = kVp8Codec360p;
+  std::vector<cricket::VideoCodec> codecs;
+  codecs.push_back(codec);
+  EXPECT_TRUE(channel_->SetSendCodecs(codecs));
+  VideoOptions options;
+  options.screencast_min_bitrate.Set(kScreenshareMinBitrateKbps);
+  channel_->SetOptions(options);
+
+  AddSendStream();
+
+  cricket::FakeVideoCapturer capturer;
+  capturer.SetScreencast(false);
+  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  cricket::VideoFormat capture_format_hd =
+      capturer.GetSupportedFormats()->front();
+  EXPECT_EQ(1280, capture_format_hd.width);
+  EXPECT_EQ(720, capture_format_hd.height);
+  EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
+
+  EXPECT_TRUE(channel_->SetSend(true));
+
+  EXPECT_TRUE(capturer.CaptureFrame());
+  ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
+  FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
+
+  EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
+
+  // Verify non-screencast settings.
+  webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig();
+  EXPECT_EQ(webrtc::VideoEncoderConfig::kRealtimeVideo,
+            encoder_config.content_type);
+  EXPECT_EQ(codec.width, encoder_config.streams.front().width);
+  EXPECT_EQ(codec.height, encoder_config.streams.front().height);
+  EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps)
+      << "Non-screenshare shouldn't use min-transmit bitrate.";
+
+  capturer.SetScreencast(true);
+  EXPECT_TRUE(capturer.CaptureFrame());
+
+  EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
+
+  // Verify screencast settings.
+  encoder_config = send_stream->GetEncoderConfig();
+  EXPECT_EQ(webrtc::VideoEncoderConfig::kScreenshare,
+            encoder_config.content_type);
+  EXPECT_EQ(kScreenshareMinBitrateKbps * 1000,
+            encoder_config.min_transmit_bitrate_bps);
+
+  EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width);
+  EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height);
+  EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty());
+
+  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+}
+
+TEST_F(WebRtcVideoChannel2Test,
+       ConferenceModeScreencastConfiguresTemporalLayer) {
+  static const int kConferenceScreencastTemporalBitrateBps = 100000;
+  VideoOptions options;
+  options.conference_mode.Set(true);
+  channel_->SetOptions(options);
+
+  AddSendStream();
+
+  cricket::FakeVideoCapturer capturer;
+  capturer.SetScreencast(true);
+  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  cricket::VideoFormat capture_format_hd =
+      capturer.GetSupportedFormats()->front();
+  EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
+
+  EXPECT_TRUE(channel_->SetSend(true));
+
+  EXPECT_TRUE(capturer.CaptureFrame());
+  ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
+  FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
+
+  webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig();
+
+  // Verify screencast settings.
+  encoder_config = send_stream->GetEncoderConfig();
+  EXPECT_EQ(webrtc::VideoEncoderConfig::kScreenshare,
+            encoder_config.content_type);
+  ASSERT_EQ(1u, encoder_config.streams.size());
+  ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size());
+  EXPECT_EQ(kConferenceScreencastTemporalBitrateBps,
+            encoder_config.streams[0].temporal_layer_thresholds_bps[0]);
+
+  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
 }
 
 TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendSsrcAndCname) {
@@ -1289,7 +1472,7 @@
 }
 
 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse) {
-  cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0);
+  cricket::VideoCodec codec = kVp8Codec720p;
   std::vector<cricket::VideoCodec> codecs;
   codecs.push_back(codec);
   EXPECT_TRUE(channel_->SetSendCodecs(codecs));
@@ -1451,13 +1634,13 @@
 }
 
 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMinMaxBitrate) {
-  SetSendCodecsShouldWorkForBitrates("10", "20");
+  SetSendCodecsShouldWorkForBitrates("100", "200");
 }
 
 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) {
   std::vector<VideoCodec> video_codecs = engine_.codecs();
-  video_codecs[0].params[kCodecParamMinBitrate] = "30";
-  video_codecs[0].params[kCodecParamMaxBitrate] = "20";
+  video_codecs[0].params[kCodecParamMinBitrate] = "300";
+  video_codecs[0].params[kCodecParamMaxBitrate] = "200";
   EXPECT_FALSE(channel_->SetSendCodecs(video_codecs));
 }
 
@@ -1565,8 +1748,8 @@
 
   FakeVideoReceiveStream* stream = AddRecvStream();
   webrtc::VideoReceiveStream::Config config = stream->GetConfig();
-  EXPECT_STREQ(engine_.codecs()[0].name.c_str(), config.codecs[0].plName);
-  EXPECT_EQ(engine_.codecs()[0].id, config.codecs[0].plType);
+  EXPECT_EQ(engine_.codecs()[0].name, config.decoders[0].payload_name);
+  EXPECT_EQ(engine_.codecs()[0].id, config.decoders[0].payload_type);
 }
 
 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) {
@@ -1678,55 +1861,6 @@
   FAIL() << "Not implemented.";  // TODO(pbos): Implement.
 }
 
-TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithLoweredBitrate) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsSucceedsWhenSending) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetCodecOnScreencast) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_DontResetCodecOnSendFrame) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test,
-       DISABLED_DontRegisterDecoderIfFactoryIsNotGiven) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterDecoderIfFactoryIsGiven) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderMultipleTimes) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderForNonVP8) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_FeedbackParamsForNonVP8) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecAddedToTheEnd) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecIgnored) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
-TEST_F(WebRtcVideoChannel2Test, DISABLED_UpdateEncoderCodecsAfterSetFactory) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
-
 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) {
   EXPECT_EQ(webrtc::Call::kNetworkUp, fake_call_->GetNetworkState());
 
@@ -1737,7 +1871,4 @@
   EXPECT_EQ(webrtc::Call::kNetworkUp, fake_call_->GetNetworkState());
 }
 
-TEST_F(WebRtcVideoChannel2Test, DISABLED_CaptureFrameTimestampToNtpTimestamp) {
-  FAIL() << "Not implemented.";  // TODO(pbos): Implement.
-}
 }  // namespace cricket
diff --git a/media/webrtc/webrtcvideoengine2_unittest.h b/media/webrtc/webrtcvideoengine2_unittest.h
index b3014ad..3b62289 100644
--- a/media/webrtc/webrtcvideoengine2_unittest.h
+++ b/media/webrtc/webrtcvideoengine2_unittest.h
@@ -41,7 +41,8 @@
  public:
   FakeVideoSendStream(const webrtc::VideoSendStream::Config& config,
                       const webrtc::VideoEncoderConfig& encoder_config);
-  webrtc::VideoSendStream::Config GetConfig();
+  webrtc::VideoSendStream::Config GetConfig() const;
+  webrtc::VideoEncoderConfig GetEncoderConfig() const;
   std::vector<webrtc::VideoStream> GetVideoStreams();
 
   bool IsSending() const;
@@ -86,7 +87,6 @@
 
   virtual void Start() OVERRIDE;
   virtual void Stop() OVERRIDE;
-  virtual void GetCurrentReceiveCodec(webrtc::VideoCodec* codec);
 
   webrtc::VideoReceiveStream::Config config_;
   bool receiving_;
diff --git a/media/webrtc/webrtcvideoengine_unittest.cc b/media/webrtc/webrtcvideoengine_unittest.cc
index 4060493..00d6e4b 100644
--- a/media/webrtc/webrtcvideoengine_unittest.cc
+++ b/media/webrtc/webrtcvideoengine_unittest.cc
@@ -1475,7 +1475,7 @@
       kMaxBandwidthKbps, kMinBandwidthKbps, kStartBandwidthKbps);
 
   // Set the start bitrate option.
-  int kBoostedStartBandwidthKbps = 1000;
+  unsigned int kBoostedStartBandwidthKbps = 1000;
   ASSERT_NE(kStartBandwidthKbps, kBoostedStartBandwidthKbps);
   cricket::VideoOptions options;
   options.video_start_bitrate.Set(kBoostedStartBandwidthKbps);
diff --git a/media/webrtc/webrtcvoiceengine.cc b/media/webrtc/webrtcvoiceengine.cc
index f9e7878..95e16e4 100644
--- a/media/webrtc/webrtcvoiceengine.cc
+++ b/media/webrtc/webrtcvoiceengine.cc
@@ -110,13 +110,26 @@
 
 static const char kIsacCodecName[] = "ISAC";
 static const char kL16CodecName[] = "L16";
-// Codec parameters for Opus.
-static const int kOpusMonoBitrate = 32000;
+
 // Parameter used for NACK.
 // This value is equivalent to 5 seconds of audio data at 20 ms per packet.
 static const int kNackMaxPackets = 250;
-static const int kOpusStereoBitrate = 64000;
+
+// Codec parameters for Opus.
 // draft-spittka-payload-rtp-opus-03
+
+// Recommended bitrates:
+// 8-12 kb/s for NB speech,
+// 16-20 kb/s for WB speech,
+// 28-40 kb/s for FB speech,
+// 48-64 kb/s for FB mono music, and
+// 64-128 kb/s for FB stereo music.
+// The current implementation applies the following values to mono signals,
+// and multiplies them by 2 for stereo.
+static const int kOpusBitrateNb = 12000;
+static const int kOpusBitrateWb = 20000;
+static const int kOpusBitrateFb = 32000;
+
 // Opus bitrate should be in the range between 6000 and 510000.
 static const int kOpusMinBitrate = 6000;
 static const int kOpusMaxBitrate = 510000;
@@ -405,22 +418,37 @@
   return codec.GetParam(kCodecParamStereo, &value) && value == 1;
 }
 
-// TODO(minyue): Clamp bitrate when invalid.
-static bool IsValidOpusBitrate(int bitrate) {
-  return (bitrate >= kOpusMinBitrate && bitrate <= kOpusMaxBitrate);
-}
-
-// Returns 0 if params[kCodecParamMaxAverageBitrate] is not defined or invalid.
-// Returns the value of params[kCodecParamMaxAverageBitrate] otherwise.
-static int GetOpusBitrateFromParams(const AudioCodec& codec) {
+// Use params[kCodecParamMaxAverageBitrate] if it is defined, use codec.bitrate
+// otherwise. If the value (either from params or codec.bitrate) <=0, use the
+// default configuration. If the value is beyond feasible bit rate of Opus,
+// clamp it. Returns the Opus bit rate for operation.
+static int GetOpusBitrate(const AudioCodec& codec, int max_playback_rate) {
   int bitrate = 0;
+  bool use_param = true;
   if (!codec.GetParam(kCodecParamMaxAverageBitrate, &bitrate)) {
-    return 0;
+    bitrate = codec.bitrate;
+    use_param = false;
   }
-  if (!IsValidOpusBitrate(bitrate)) {
-    LOG(LS_WARNING) << "Codec parameter \"maxaveragebitrate\" has an "
-                    << "invalid value: " << bitrate;
-    return 0;
+  if (bitrate <= 0) {
+    if (max_playback_rate <= 8000) {
+      bitrate = kOpusBitrateNb;
+    } else if (max_playback_rate <= 16000) {
+      bitrate = kOpusBitrateWb;
+    } else {
+      bitrate = kOpusBitrateFb;
+    }
+
+    if (IsOpusStereoEnabled(codec)) {
+      bitrate *= 2;
+    }
+  } else if (bitrate < kOpusMinBitrate || bitrate > kOpusMaxBitrate) {
+    bitrate = (bitrate < kOpusMinBitrate) ? kOpusMinBitrate : kOpusMaxBitrate;
+    std::string rate_source =
+        use_param ? "Codec parameter \"maxaveragebitrate\"" :
+            "Supplied Opus bitrate";
+    LOG(LS_WARNING) << rate_source
+                    << " is invalid and is replaced by: "
+                    << bitrate;
   }
   return bitrate;
 }
@@ -450,39 +478,11 @@
   // If OPUS, change what we send according to the "stereo" codec
   // parameter, and not the "channels" parameter.  We set
   // voe_codec.channels to 2 if "stereo=1" and 1 otherwise.  If
-  // the bitrate is not specified, i.e. is zero, we set it to the
+  // the bitrate is not specified, i.e. is <= zero, we set it to the
   // appropriate default value for mono or stereo Opus.
 
-  // TODO(minyue): The determination of bit rate might take the maximum playback
-  // rate into account.
-
-  if (IsOpusStereoEnabled(codec)) {
-    voe_codec->channels = 2;
-    if (!IsValidOpusBitrate(codec.bitrate)) {
-      if (codec.bitrate != 0) {
-        LOG(LS_WARNING) << "Overrides the invalid supplied bitrate("
-                        << codec.bitrate
-                        << ") with default opus stereo bitrate: "
-                        << kOpusStereoBitrate;
-      }
-      voe_codec->rate = kOpusStereoBitrate;
-    }
-  } else {
-    voe_codec->channels = 1;
-    if (!IsValidOpusBitrate(codec.bitrate)) {
-      if (codec.bitrate != 0) {
-        LOG(LS_WARNING) << "Overrides the invalid supplied bitrate("
-                        << codec.bitrate
-                        << ") with default opus mono bitrate: "
-                        << kOpusMonoBitrate;
-      }
-      voe_codec->rate = kOpusMonoBitrate;
-    }
-  }
-  int bitrate_from_params = GetOpusBitrateFromParams(codec);
-  if (bitrate_from_params != 0) {
-    voe_codec->rate = bitrate_from_params;
-  }
+  voe_codec->channels = IsOpusStereoEnabled(codec) ? 2 : 1;
+  voe_codec->rate = GetOpusBitrate(codec, *max_playback_rate);
 }
 
 void WebRtcVoiceEngine::ConstructCodecs() {
@@ -514,7 +514,7 @@
                          ARRAY_SIZE(kCodecPrefs) - (pref - kCodecPrefs));
         LOG(LS_INFO) << ToString(codec);
         if (IsIsac(codec)) {
-          // Indicate auto-bandwidth in signaling.
+          // Indicate auto-bitrate in signaling.
           codec.bitrate = 0;
         }
         if (IsOpus(codec)) {
@@ -1246,7 +1246,7 @@
           // Apply codec-specific settings.
           if (IsIsac(codec)) {
             // If ISAC and an explicit bitrate is not specified,
-            // enable auto bandwidth adjustment.
+            // enable auto bitrate adjustment.
             voe_codec.rate = (in.bitrate > 0) ? in.bitrate : -1;
           }
           *out = voe_codec;
@@ -1811,8 +1811,8 @@
     : WebRtcMediaChannel<VoiceMediaChannel, WebRtcVoiceEngine>(
           engine,
           engine->CreateMediaVoiceChannel()),
-      send_bw_setting_(false),
-      send_bw_bps_(0),
+      send_bitrate_setting_(false),
+      send_bitrate_bps_(0),
       options_(),
       dtmf_allowed_(false),
       desired_playout_(false),
@@ -2047,9 +2047,7 @@
   bool nack_enabled = nack_enabled_;
   bool enable_codec_fec = false;
 
-  // max_playback_rate <= 0 will not trigger setting of maximum encoding
-  // bandwidth.
-  int max_playback_rate = 0;
+  int opus_max_playback_rate = 0;
 
   // Set send codec (the first non-telephone-event/CN codec)
   for (std::vector<AudioCodec>::const_iterator it = codecs.begin();
@@ -2067,7 +2065,6 @@
       continue;
     }
 
-
     // We'll use the first codec in the list to actually send audio data.
     // Be sure to use the payload type requested by the remote side.
     // "red", for RED audio, is a special case where the actual codec to be
@@ -2099,7 +2096,8 @@
       // For Opus as the send codec, we are to enable inband FEC if requested
       // and set maximum playback rate.
       if (IsOpus(*it)) {
-        GetOpusConfig(*it, &send_codec, &enable_codec_fec, &max_playback_rate);
+        GetOpusConfig(*it, &send_codec, &enable_codec_fec,
+                      &opus_max_playback_rate);
       }
     }
     found_send_codec = true;
@@ -2135,15 +2133,16 @@
   }
 
   // maxplaybackrate should be set after SetSendCodec.
-  if (max_playback_rate > 0) {
+  // If opus_max_playback_rate <= 0, the default maximum playback rate of 48 kHz
+  // will be used.
+  if (opus_max_playback_rate > 0) {
     LOG(LS_INFO) << "Attempt to set maximum playback rate to "
-                 << max_playback_rate
+                 << opus_max_playback_rate
                  << " Hz on channel "
                  << channel;
 #ifdef USE_WEBRTC_DEV_BRANCH
-    // (max_playback_rate + 1) >> 1 is to obtain ceil(max_playback_rate / 2.0).
     if (engine()->voe()->codec()->SetOpusMaxPlaybackRate(
-        channel, max_playback_rate) == -1) {
+        channel, opus_max_playback_rate) == -1) {
       LOG(LS_WARNING) << "Could not set maximum playback rate.";
     }
 #endif
@@ -2152,8 +2151,8 @@
   // Always update the |send_codec_| to the currently set send codec.
   send_codec_.reset(new webrtc::CodecInst(send_codec));
 
-  if (send_bw_setting_) {
-    SetSendBandwidthInternal(send_bw_bps_);
+  if (send_bitrate_setting_) {
+    SetSendBitrateInternal(send_bitrate_bps_);
   }
 
   // Loop through the codecs list again to config the telephone-event/CN codec.
@@ -3206,25 +3205,27 @@
   return true;
 }
 
+// TODO(minyue): SetMaxSendBandwidth() is subject to be renamed to
+// SetMaxSendBitrate() in future.
 bool WebRtcVoiceMediaChannel::SetMaxSendBandwidth(int bps) {
-  LOG(LS_INFO) << "WebRtcVoiceMediaChanne::SetSendBandwidth.";
+  LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBandwidth.";
 
-  return SetSendBandwidthInternal(bps);
+  return SetSendBitrateInternal(bps);
 }
 
-bool WebRtcVoiceMediaChannel::SetSendBandwidthInternal(int bps) {
-  LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendBandwidthInternal.";
+bool WebRtcVoiceMediaChannel::SetSendBitrateInternal(int bps) {
+  LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendBitrateInternal.";
 
-  send_bw_setting_ = true;
-  send_bw_bps_ = bps;
+  send_bitrate_setting_ = true;
+  send_bitrate_bps_ = bps;
 
   if (!send_codec_) {
     LOG(LS_INFO) << "The send codec has not been set up yet. "
-                 << "The send bandwidth setting will be applied later.";
+                 << "The send bitrate setting will be applied later.";
     return true;
   }
 
-  // Bandwidth is auto by default.
+  // Bitrate is auto by default.
   // TODO(bemasc): Fix this so that if SetMaxSendBandwidth(50) is followed by
   // SetMaxSendBandwith(0), the second call removes the previous limit.
   if (bps <= 0)
diff --git a/media/webrtc/webrtcvoiceengine.h b/media/webrtc/webrtcvoiceengine.h
index 8d762d4..f19059b 100644
--- a/media/webrtc/webrtcvoiceengine.h
+++ b/media/webrtc/webrtcvoiceengine.h
@@ -435,7 +435,7 @@
     return channel_id == voe_channel();
   }
   bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs);
-  bool SetSendBandwidthInternal(int bps);
+  bool SetSendBitrateInternal(int bps);
 
   bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id,
                           const RtpHeaderExtension* extension);
@@ -453,8 +453,8 @@
   std::vector<AudioCodec> recv_codecs_;
   std::vector<AudioCodec> send_codecs_;
   rtc::scoped_ptr<webrtc::CodecInst> send_codec_;
-  bool send_bw_setting_;
-  int send_bw_bps_;
+  bool send_bitrate_setting_;
+  int send_bitrate_bps_;
   AudioOptions options_;
   bool dtmf_allowed_;
   bool desired_playout_;
diff --git a/media/webrtc/webrtcvoiceengine_unittest.cc b/media/webrtc/webrtcvoiceengine_unittest.cc
index b044e92..5deabd2 100644
--- a/media/webrtc/webrtcvoiceengine_unittest.cc
+++ b/media/webrtc/webrtcvoiceengine_unittest.cc
@@ -40,7 +40,7 @@
 #include "talk/media/webrtc/fakewebrtcvoiceengine.h"
 #include "talk/media/webrtc/webrtcvie.h"
 #include "talk/media/webrtc/webrtcvoiceengine.h"
-#include "talk/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/fakesession.h"
 #include "talk/session/media/channel.h"
 
 // Tests for the WebRtcVoiceEngine/VoiceChannel code.
@@ -876,21 +876,20 @@
   codecs[0].params["stereo"] = "0";
   webrtc::CodecInst gcodec;
 
-  // bitrate that's out of the range between 6000 and 510000 will be considered
-  // as invalid and ignored.
+  // bitrate that's out of the range between 6000 and 510000 will be clamped.
   codecs[0].bitrate = 5999;
   EXPECT_TRUE(channel_->SetSendCodecs(codecs));
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
   EXPECT_EQ(1, gcodec.channels);
-  EXPECT_EQ(32000, gcodec.rate);
+  EXPECT_EQ(6000, gcodec.rate);
 
   codecs[0].bitrate = 510001;
   EXPECT_TRUE(channel_->SetSendCodecs(codecs));
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
   EXPECT_EQ(1, gcodec.channels);
-  EXPECT_EQ(32000, gcodec.rate);
+  EXPECT_EQ(510000, gcodec.rate);
 }
 
 // Test that with bitrate=0 and stereo=1,
@@ -920,21 +919,20 @@
   codecs[0].params["stereo"] = "1";
   webrtc::CodecInst gcodec;
 
-  // bitrate that's out of the range between 6000 and 510000 will be considered
-  // as invalid and ignored.
+  // bitrate that's out of the range between 6000 and 510000 will be clamped.
   codecs[0].bitrate = 5999;
   EXPECT_TRUE(channel_->SetSendCodecs(codecs));
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
   EXPECT_EQ(2, gcodec.channels);
-  EXPECT_EQ(64000, gcodec.rate);
+  EXPECT_EQ(6000, gcodec.rate);
 
   codecs[0].bitrate = 510001;
   EXPECT_TRUE(channel_->SetSendCodecs(codecs));
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
   EXPECT_EQ(2, gcodec.channels);
-  EXPECT_EQ(64000, gcodec.rate);
+  EXPECT_EQ(510000, gcodec.rate);
 }
 
 // Test that with bitrate=N and stereo unset,
@@ -1020,13 +1018,13 @@
   codecs[0].params["maxaveragebitrate"] = "5999";
   EXPECT_TRUE(channel_->SetSendCodecs(codecs));
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
-  EXPECT_EQ(30000, gcodec.rate);
+  EXPECT_EQ(6000, gcodec.rate);
 
   // Ignore if larger than 510000.
   codecs[0].params["maxaveragebitrate"] = "510001";
   EXPECT_TRUE(channel_->SetSendCodecs(codecs));
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
-  EXPECT_EQ(30000, gcodec.rate);
+  EXPECT_EQ(510000, gcodec.rate);
 
   codecs[0].params["maxaveragebitrate"] = "200000";
   EXPECT_TRUE(channel_->SetSendCodecs(codecs));
@@ -1256,9 +1254,12 @@
   webrtc::CodecInst gcodec;
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
-  // TODO(minyue): Default bit rate is not but can in future be affected by
-  // kCodecParamMaxPlaybackRate.
-  EXPECT_EQ(32000, gcodec.rate);
+
+  EXPECT_EQ(12000, gcodec.rate);
+  codecs[0].SetParam(cricket::kCodecParamStereo, "1");
+  EXPECT_TRUE(channel_->SetSendCodecs(codecs));
+  EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
+  EXPECT_EQ(24000, gcodec.rate);
 }
 
 // Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode.
@@ -1275,9 +1276,12 @@
   webrtc::CodecInst gcodec;
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
-  // TODO(minyue): Default bit rate is not but can in future be affected by
-  // kCodecParamMaxPlaybackRate.
-  EXPECT_EQ(32000, gcodec.rate);
+
+  EXPECT_EQ(20000, gcodec.rate);
+  codecs[0].SetParam(cricket::kCodecParamStereo, "1");
+  EXPECT_TRUE(channel_->SetSendCodecs(codecs));
+  EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
+  EXPECT_EQ(40000, gcodec.rate);
 }
 
 // Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode.
@@ -1294,9 +1298,12 @@
   webrtc::CodecInst gcodec;
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
-  // TODO(minyue): Default bit rate is not but can in future be affected by
-  // kCodecParamMaxPlaybackRate.
-  EXPECT_EQ(32000, gcodec.rate);
+
+  EXPECT_EQ(20000, gcodec.rate);
+  codecs[0].SetParam(cricket::kCodecParamStereo, "1");
+  EXPECT_TRUE(channel_->SetSendCodecs(codecs));
+  EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
+  EXPECT_EQ(40000, gcodec.rate);
 }
 
 // Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode.
@@ -1313,9 +1320,12 @@
   webrtc::CodecInst gcodec;
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
-  // TODO(minyue): Default bit rate is not but can in future be affected by
-  // kCodecParamMaxPlaybackRate.
+
   EXPECT_EQ(32000, gcodec.rate);
+  codecs[0].SetParam(cricket::kCodecParamStereo, "1");
+  EXPECT_TRUE(channel_->SetSendCodecs(codecs));
+  EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
+  EXPECT_EQ(64000, gcodec.rate);
 }
 
 // Test 24000 < maxplaybackrate triggers Opus full band mode.
@@ -1332,9 +1342,12 @@
   webrtc::CodecInst gcodec;
   EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
   EXPECT_STREQ("opus", gcodec.plname);
-  // TODO(minyue): Default bit rate is not but can in future be affected by
-  // kCodecParamMaxPlaybackRate.
+
   EXPECT_EQ(32000, gcodec.rate);
+  codecs[0].SetParam(cricket::kCodecParamStereo, "1");
+  EXPECT_TRUE(channel_->SetSendCodecs(codecs));
+  EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
+  EXPECT_EQ(64000, gcodec.rate);
 }
 
 // Test Opus that without maxplaybackrate, default playback rate is used.
diff --git a/p2p/base/asyncstuntcpsocket.cc b/p2p/base/asyncstuntcpsocket.cc
index c1aeead..73bb152 100644
--- a/p2p/base/asyncstuntcpsocket.cc
+++ b/p2p/base/asyncstuntcpsocket.cc
@@ -25,11 +25,11 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/asyncstuntcpsocket.h"
+#include "webrtc/p2p/base/asyncstuntcpsocket.h"
 
 #include <string.h>
 
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
 
diff --git a/p2p/base/asyncstuntcpsocket.h b/p2p/base/asyncstuntcpsocket.h
index 136b4df..3675c9e 100644
--- a/p2p/base/asyncstuntcpsocket.h
+++ b/p2p/base/asyncstuntcpsocket.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_ASYNCSTUNTCPSOCKET_H_
-#define TALK_P2P_BASE_ASYNCSTUNTCPSOCKET_H_
+#ifndef WEBRTC_P2P_BASE_ASYNCSTUNTCPSOCKET_H_
+#define WEBRTC_P2P_BASE_ASYNCSTUNTCPSOCKET_H_
 
 #include "webrtc/base/asynctcpsocket.h"
 #include "webrtc/base/scoped_ptr.h"
@@ -64,4 +64,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_ASYNCSTUNTCPSOCKET_H_
+#endif  // WEBRTC_P2P_BASE_ASYNCSTUNTCPSOCKET_H_
diff --git a/p2p/base/asyncstuntcpsocket_unittest.cc b/p2p/base/asyncstuntcpsocket_unittest.cc
index 46e5d63..ba407e7 100644
--- a/p2p/base/asyncstuntcpsocket_unittest.cc
+++ b/p2p/base/asyncstuntcpsocket_unittest.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/asyncstuntcpsocket.h"
+#include "webrtc/p2p/base/asyncstuntcpsocket.h"
 #include "webrtc/base/asyncsocket.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/physicalsocketserver.h"
diff --git a/p2p/base/basicpacketsocketfactory.cc b/p2p/base/basicpacketsocketfactory.cc
index 2b3b06f..1e0ddf8 100644
--- a/p2p/base/basicpacketsocketfactory.cc
+++ b/p2p/base/basicpacketsocketfactory.cc
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
 
-#include "talk/p2p/base/asyncstuntcpsocket.h"
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/asyncstuntcpsocket.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/asynctcpsocket.h"
 #include "webrtc/base/asyncudpsocket.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/basicpacketsocketfactory.h b/p2p/base/basicpacketsocketfactory.h
index 77b1652..f895efa 100644
--- a/p2p/base/basicpacketsocketfactory.h
+++ b/p2p/base/basicpacketsocketfactory.h
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_BASICPACKETSOCKETFACTORY_H_
-#define TALK_P2P_BASE_BASICPACKETSOCKETFACTORY_H_
+#ifndef WEBRTC_P2P_BASE_BASICPACKETSOCKETFACTORY_H_
+#define WEBRTC_P2P_BASE_BASICPACKETSOCKETFACTORY_H_
 
-#include "talk/p2p/base/packetsocketfactory.h"
+#include "webrtc/p2p/base/packetsocketfactory.h"
 
 namespace rtc {
 
@@ -65,4 +65,4 @@
 
 }  // namespace rtc
 
-#endif  // TALK_P2P_BASE_BASICPACKETSOCKETFACTORY_H_
+#endif  // WEBRTC_P2P_BASE_BASICPACKETSOCKETFACTORY_H_
diff --git a/p2p/base/candidate.h b/p2p/base/candidate.h
index cb0b1bc..64872f3 100644
--- a/p2p/base/candidate.h
+++ b/p2p/base/candidate.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_CANDIDATE_H_
-#define TALK_P2P_BASE_CANDIDATE_H_
+#ifndef WEBRTC_P2P_BASE_CANDIDATE_H_
+#define WEBRTC_P2P_BASE_CANDIDATE_H_
 
 #include <limits.h>
 #include <math.h>
@@ -35,7 +35,7 @@
 #include <sstream>
 #include <string>
 
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/socketaddress.h"
 
@@ -226,4 +226,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_CANDIDATE_H_
+#endif  // WEBRTC_P2P_BASE_CANDIDATE_H_
diff --git a/p2p/base/common.h b/p2p/base/common.h
index a33e9e0..0aeb77e 100644
--- a/p2p/base/common.h
+++ b/p2p/base/common.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_COMMON_H_
-#define TALK_P2P_BASE_COMMON_H_
+#ifndef WEBRTC_P2P_BASE_COMMON_H_
+#define WEBRTC_P2P_BASE_COMMON_H_
 
 #include "webrtc/base/logging.h"
 
@@ -34,4 +34,4 @@
 #define LOG_J(sev, obj) LOG(sev) << "Jingle:" << obj->ToString() << ": "
 #define LOG_JV(sev, obj) LOG_V(sev) << "Jingle:" << obj->ToString() << ": "
 
-#endif  // TALK_P2P_BASE_COMMON_H_
+#endif  // WEBRTC_P2P_BASE_COMMON_H_
diff --git a/p2p/base/constants.cc b/p2p/base/constants.cc
index 278a615..54cfb75 100644
--- a/p2p/base/constants.cc
+++ b/p2p/base/constants.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 
 #include <string>
 
diff --git a/p2p/base/constants.h b/p2p/base/constants.h
index 4cd1166..9c53b7d 100644
--- a/p2p/base/constants.h
+++ b/p2p/base/constants.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_CONSTANTS_H_
-#define TALK_P2P_BASE_CONSTANTS_H_
+#ifndef WEBRTC_P2P_BASE_CONSTANTS_H_
+#define WEBRTC_P2P_BASE_CONSTANTS_H_
 
 #include <string>
 #include "webrtc/libjingle/xmllite/qname.h"
@@ -273,4 +273,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_CONSTANTS_H_
+#endif  // WEBRTC_P2P_BASE_CONSTANTS_H_
diff --git a/p2p/base/dtlstransport.h b/p2p/base/dtlstransport.h
index 318c14a..66b08b4 100644
--- a/p2p/base/dtlstransport.h
+++ b/p2p/base/dtlstransport.h
@@ -25,11 +25,11 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_DTLSTRANSPORT_H_
-#define TALK_P2P_BASE_DTLSTRANSPORT_H_
+#ifndef WEBRTC_P2P_BASE_DTLSTRANSPORT_H_
+#define WEBRTC_P2P_BASE_DTLSTRANSPORT_H_
 
-#include "talk/p2p/base/dtlstransportchannel.h"
-#include "talk/p2p/base/transport.h"
+#include "webrtc/p2p/base/dtlstransportchannel.h"
+#include "webrtc/p2p/base/transport.h"
 
 namespace rtc {
 class SSLIdentity;
@@ -254,4 +254,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_DTLSTRANSPORT_H_
+#endif  // WEBRTC_P2P_BASE_DTLSTRANSPORT_H_
diff --git a/p2p/base/dtlstransportchannel.cc b/p2p/base/dtlstransportchannel.cc
index e0f4141..78d4622 100644
--- a/p2p/base/dtlstransportchannel.cc
+++ b/p2p/base/dtlstransportchannel.cc
@@ -26,9 +26,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/dtlstransportchannel.h"
+#include "webrtc/p2p/base/dtlstransportchannel.h"
 
-#include "talk/p2p/base/common.h"
+#include "webrtc/p2p/base/common.h"
 #include "webrtc/base/buffer.h"
 #include "webrtc/base/dscp.h"
 #include "webrtc/base/messagequeue.h"
diff --git a/p2p/base/dtlstransportchannel.h b/p2p/base/dtlstransportchannel.h
index 44769c9..6706013 100644
--- a/p2p/base/dtlstransportchannel.h
+++ b/p2p/base/dtlstransportchannel.h
@@ -26,13 +26,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
-#define TALK_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
+#ifndef WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
+#define WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/transportchannelimpl.h"
+#include "webrtc/p2p/base/transportchannelimpl.h"
 #include "webrtc/base/buffer.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sslstreamadapter.h"
@@ -261,4 +261,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
+#endif  // WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
diff --git a/p2p/base/dtlstransportchannel_unittest.cc b/p2p/base/dtlstransportchannel_unittest.cc
index 64825bc..44854c7 100644
--- a/p2p/base/dtlstransportchannel_unittest.cc
+++ b/p2p/base/dtlstransportchannel_unittest.cc
@@ -28,8 +28,8 @@
 
 #include <set>
 
-#include "talk/p2p/base/dtlstransport.h"
-#include "talk/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/dtlstransport.h"
+#include "webrtc/p2p/base/fakesession.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/dscp.h"
 #include "webrtc/base/gunit.h"
diff --git a/p2p/base/fakesession.h b/p2p/base/fakesession.h
index 7c99719..cb9111f 100644
--- a/p2p/base/fakesession.h
+++ b/p2p/base/fakesession.h
@@ -25,17 +25,17 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_FAKESESSION_H_
-#define TALK_P2P_BASE_FAKESESSION_H_
+#ifndef WEBRTC_P2P_BASE_FAKESESSION_H_
+#define WEBRTC_P2P_BASE_FAKESESSION_H_
 
 #include <map>
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/session.h"
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/base/transportchannel.h"
-#include "talk/p2p/base/transportchannelimpl.h"
+#include "webrtc/p2p/base/session.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/transportchannelimpl.h"
 #include "webrtc/base/buffer.h"
 #include "webrtc/base/fakesslidentity.h"
 #include "webrtc/base/messagequeue.h"
@@ -506,4 +506,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_FAKESESSION_H_
+#endif  // WEBRTC_P2P_BASE_FAKESESSION_H_
diff --git a/p2p/base/p2ptransport.cc b/p2p/base/p2ptransport.cc
index 06941ac..bc316cf 100644
--- a/p2p/base/p2ptransport.cc
+++ b/p2p/base/p2ptransport.cc
@@ -25,19 +25,19 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/p2ptransport.h"
+#include "webrtc/p2p/base/p2ptransport.h"
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/p2ptransportchannel.h"
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/p2p/base/sessionmessages.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/p2ptransportchannel.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/sessionmessages.h"
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/base64.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/stringencode.h"
diff --git a/p2p/base/p2ptransport.h b/p2p/base/p2ptransport.h
index 500bb9b..fc65bab 100644
--- a/p2p/base/p2ptransport.h
+++ b/p2p/base/p2ptransport.h
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_P2PTRANSPORT_H_
-#define TALK_P2P_BASE_P2PTRANSPORT_H_
+#ifndef WEBRTC_P2P_BASE_P2PTRANSPORT_H_
+#define WEBRTC_P2P_BASE_P2PTRANSPORT_H_
 
 #include <string>
 #include <vector>
-#include "talk/p2p/base/transport.h"
+#include "webrtc/p2p/base/transport.h"
 
 namespace cricket {
 
@@ -100,4 +100,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_P2PTRANSPORT_H_
+#endif  // WEBRTC_P2P_BASE_P2PTRANSPORT_H_
diff --git a/p2p/base/p2ptransportchannel.cc b/p2p/base/p2ptransportchannel.cc
index b1dc223..daedbeb 100644
--- a/p2p/base/p2ptransportchannel.cc
+++ b/p2p/base/p2ptransportchannel.cc
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/p2ptransportchannel.h"
+#include "webrtc/p2p/base/p2ptransportchannel.h"
 
 #include <set>
-#include "talk/p2p/base/common.h"
-#include "talk/p2p/base/relayport.h"  // For RELAY_PORT_TYPE.
-#include "talk/p2p/base/stunport.h"  // For STUN_PORT_TYPE.
+#include "webrtc/p2p/base/common.h"
+#include "webrtc/p2p/base/relayport.h"  // For RELAY_PORT_TYPE.
+#include "webrtc/p2p/base/stunport.h"  // For STUN_PORT_TYPE.
 #include "webrtc/base/common.h"
 #include "webrtc/base/crc32.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/p2ptransportchannel.h b/p2p/base/p2ptransportchannel.h
index 229e512..6d45999 100644
--- a/p2p/base/p2ptransportchannel.h
+++ b/p2p/base/p2ptransportchannel.h
@@ -34,18 +34,18 @@
 // When all of the available connections become invalid (non-writable), we
 // kick off a process of determining more candidates and more connections.
 //
-#ifndef TALK_P2P_BASE_P2PTRANSPORTCHANNEL_H_
-#define TALK_P2P_BASE_P2PTRANSPORTCHANNEL_H_
+#ifndef WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
+#define WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
 
 #include <map>
 #include <string>
 #include <vector>
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/p2ptransport.h"
-#include "talk/p2p/base/portallocator.h"
-#include "talk/p2p/base/portinterface.h"
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/base/transportchannelimpl.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/p2ptransport.h"
+#include "webrtc/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/portinterface.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/base/transportchannelimpl.h"
 #include "webrtc/base/asyncpacketsocket.h"
 #include "webrtc/base/sigslot.h"
 
@@ -256,4 +256,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_P2PTRANSPORTCHANNEL_H_
+#endif  // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
diff --git a/p2p/base/p2ptransportchannel_unittest.cc b/p2p/base/p2ptransportchannel_unittest.cc
index 44c76ee..d7c0b9f 100644
--- a/p2p/base/p2ptransportchannel_unittest.cc
+++ b/p2p/base/p2ptransportchannel_unittest.cc
@@ -25,11 +25,11 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/p2ptransportchannel.h"
-#include "talk/p2p/base/testrelayserver.h"
-#include "talk/p2p/base/teststunserver.h"
-#include "talk/p2p/base/testturnserver.h"
-#include "talk/p2p/client/basicportallocator.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/dscp.h"
 #include "webrtc/base/fakenetwork.h"
 #include "webrtc/base/firewallsocketserver.h"
diff --git a/p2p/base/packetsocketfactory.h b/p2p/base/packetsocketfactory.h
index 46767c2..0160cac 100644
--- a/p2p/base/packetsocketfactory.h
+++ b/p2p/base/packetsocketfactory.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_PACKETSOCKETFACTORY_H_
-#define TALK_P2P_BASE_PACKETSOCKETFACTORY_H_
+#ifndef WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_
+#define WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_
 
 #include "webrtc/base/proxyinfo.h"
 
@@ -66,4 +66,4 @@
 
 }  // namespace rtc
 
-#endif  // TALK_P2P_BASE_PACKETSOCKETFACTORY_H_
+#endif  // WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_
diff --git a/p2p/base/parsing.cc b/p2p/base/parsing.cc
index 1465096..eace88b 100644
--- a/p2p/base/parsing.cc
+++ b/p2p/base/parsing.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/parsing.h"
+#include "webrtc/p2p/base/parsing.h"
 
 #include <stdlib.h>
 #include <algorithm>
diff --git a/p2p/base/parsing.h b/p2p/base/parsing.h
index 2aab2f8..f150747 100644
--- a/p2p/base/parsing.h
+++ b/p2p/base/parsing.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_PARSING_H_
-#define TALK_P2P_BASE_PARSING_H_
+#ifndef WEBRTC_P2P_BASE_PARSING_H_
+#define WEBRTC_P2P_BASE_PARSING_H_
 
 #include <string>
 #include <vector>
@@ -154,4 +154,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_PARSING_H_
+#endif  // WEBRTC_P2P_BASE_PARSING_H_
diff --git a/p2p/base/port.cc b/p2p/base/port.cc
index 0cf46eb..aa88872 100644
--- a/p2p/base/port.cc
+++ b/p2p/base/port.cc
@@ -25,12 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/port.h"
+#include "webrtc/p2p/base/port.h"
 
 #include <algorithm>
 #include <vector>
 
-#include "talk/p2p/base/common.h"
+#include "webrtc/p2p/base/common.h"
+#include "webrtc/p2p/base/portallocator.h"
 #include "webrtc/base/base64.h"
 #include "webrtc/base/crc32.h"
 #include "webrtc/base/helpers.h"
@@ -187,7 +188,8 @@
       ice_protocol_(ICEPROTO_HYBRID),
       ice_role_(ICEROLE_UNKNOWN),
       tiebreaker_(0),
-      shared_socket_(true) {
+      shared_socket_(true),
+      candidate_filter_(CF_ALL) {
   Construct();
 }
 
@@ -213,7 +215,8 @@
       ice_protocol_(ICEPROTO_HYBRID),
       ice_role_(ICEROLE_UNKNOWN),
       tiebreaker_(0),
-      shared_socket_(false) {
+      shared_socket_(false),
+      candidate_filter_(CF_ALL) {
   ASSERT(factory_ != NULL);
   Construct();
 }
@@ -1334,7 +1337,7 @@
 void Connection::OnMessage(rtc::Message *pmsg) {
   ASSERT(pmsg->message_id == MSG_DELETE);
 
-  LOG_J(LS_INFO, this) << "Connection deleted";
+  LOG_J(LS_INFO, this) << "Connection deleted due to read or write timeout";
   SignalDestroyed(this);
   delete this;
 }
diff --git a/p2p/base/port.h b/p2p/base/port.h
index 4893586..490aee5 100644
--- a/p2p/base/port.h
+++ b/p2p/base/port.h
@@ -25,20 +25,20 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_PORT_H_
-#define TALK_P2P_BASE_PORT_H_
+#ifndef WEBRTC_P2P_BASE_PORT_H_
+#define WEBRTC_P2P_BASE_PORT_H_
 
 #include <map>
 #include <set>
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/packetsocketfactory.h"
-#include "talk/p2p/base/portinterface.h"
-#include "talk/p2p/base/stun.h"
-#include "talk/p2p/base/stunrequest.h"
-#include "talk/p2p/base/transport.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/packetsocketfactory.h"
+#include "webrtc/p2p/base/portinterface.h"
+#include "webrtc/p2p/base/stun.h"
+#include "webrtc/p2p/base/stunrequest.h"
+#include "webrtc/p2p/base/transport.h"
 #include "webrtc/base/asyncpacketsocket.h"
 #include "webrtc/base/network.h"
 #include "webrtc/base/proxyinfo.h"
@@ -308,6 +308,10 @@
   // Returns if Hybrid ICE protocol is used.
   bool IsHybridIce() const;
 
+  void set_candidate_filter(uint32 candidate_filter) {
+    candidate_filter_ = candidate_filter;
+  }
+
  protected:
   enum {
     MSG_CHECKTIMEOUT = 0,
@@ -351,6 +355,8 @@
     return rtc::DSCP_NO_CHANGE;
   }
 
+  uint32 candidate_filter() { return candidate_filter_; }
+
  private:
   void Construct();
   // Called when one of our connections deletes itself.
@@ -392,6 +398,12 @@
   std::string user_agent_;
   rtc::ProxyInfo proxy_;
 
+  // Candidate filter is pushed down to Port such that each Port could
+  // make its own decision on how to create candidates. For example,
+  // when IceTransportsType is set to relay, both RelayPort and
+  // TurnPort will hide raddr to avoid local address leakage.
+  uint32 candidate_filter_;
+
   friend class Connection;
 };
 
@@ -604,4 +616,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_PORT_H_
+#endif  // WEBRTC_P2P_BASE_PORT_H_
diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc
index efa3f65..bd4520f 100644
--- a/p2p/base/port_unittest.cc
+++ b/p2p/base/port_unittest.cc
@@ -25,16 +25,16 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/portproxy.h"
-#include "talk/p2p/base/relayport.h"
-#include "talk/p2p/base/stunport.h"
-#include "talk/p2p/base/tcpport.h"
-#include "talk/p2p/base/testrelayserver.h"
-#include "talk/p2p/base/teststunserver.h"
-#include "talk/p2p/base/testturnserver.h"
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/base/turnport.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/portproxy.h"
+#include "webrtc/p2p/base/relayport.h"
+#include "webrtc/p2p/base/stunport.h"
+#include "webrtc/p2p/base/tcpport.h"
+#include "webrtc/p2p/base/testrelayserver.h"
+#include "webrtc/p2p/base/teststunserver.h"
+#include "webrtc/p2p/base/testturnserver.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/base/turnport.h"
 #include "webrtc/base/crc32.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
diff --git a/p2p/base/portallocator.cc b/p2p/base/portallocator.cc
index 369af86..84fb344 100644
--- a/p2p/base/portallocator.cc
+++ b/p2p/base/portallocator.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/portallocator.h"
 
-#include "talk/p2p/base/portallocatorsessionproxy.h"
+#include "webrtc/p2p/base/portallocatorsessionproxy.h"
 
 namespace cricket {
 
diff --git a/p2p/base/portallocator.h b/p2p/base/portallocator.h
index 5bc389e..29a1b0e 100644
--- a/p2p/base/portallocator.h
+++ b/p2p/base/portallocator.h
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_PORTALLOCATOR_H_
-#define TALK_P2P_BASE_PORTALLOCATOR_H_
+#ifndef WEBRTC_P2P_BASE_PORTALLOCATOR_H_
+#define WEBRTC_P2P_BASE_PORTALLOCATOR_H_
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/portinterface.h"
+#include "webrtc/p2p/base/portinterface.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/proxyinfo.h"
 #include "webrtc/base/sigslot.h"
@@ -206,4 +206,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_PORTALLOCATOR_H_
+#endif  // WEBRTC_P2P_BASE_PORTALLOCATOR_H_
diff --git a/p2p/base/portallocatorsessionproxy.cc b/p2p/base/portallocatorsessionproxy.cc
index a6c8065..2801f26 100644
--- a/p2p/base/portallocatorsessionproxy.cc
+++ b/p2p/base/portallocatorsessionproxy.cc
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/portallocatorsessionproxy.h"
+#include "webrtc/p2p/base/portallocatorsessionproxy.h"
 
-#include "talk/p2p/base/portallocator.h"
-#include "talk/p2p/base/portproxy.h"
+#include "webrtc/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/portproxy.h"
 #include "webrtc/base/thread.h"
 
 namespace cricket {
diff --git a/p2p/base/portallocatorsessionproxy.h b/p2p/base/portallocatorsessionproxy.h
index 659c730..fdd5d02 100644
--- a/p2p/base/portallocatorsessionproxy.h
+++ b/p2p/base/portallocatorsessionproxy.h
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
-#define TALK_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
+#ifndef WEBRTC_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
+#define WEBRTC_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
 
 #include <string>
 
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/portallocator.h"
 
 namespace cricket {
 class PortAllocator;
@@ -120,4 +120,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
+#endif  // WEBRTC_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
diff --git a/p2p/base/portallocatorsessionproxy_unittest.cc b/p2p/base/portallocatorsessionproxy_unittest.cc
index 3a69b46..30353ee 100644
--- a/p2p/base/portallocatorsessionproxy_unittest.cc
+++ b/p2p/base/portallocatorsessionproxy_unittest.cc
@@ -27,10 +27,10 @@
 
 #include <vector>
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/portallocatorsessionproxy.h"
-#include "talk/p2p/client/basicportallocator.h"
-#include "talk/p2p/client/fakeportallocator.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/portallocatorsessionproxy.h"
+#include "webrtc/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/client/fakeportallocator.h"
 #include "webrtc/base/fakenetwork.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/thread.h"
diff --git a/p2p/base/portinterface.h b/p2p/base/portinterface.h
index 8cab5b4..d53dc2e 100644
--- a/p2p/base/portinterface.h
+++ b/p2p/base/portinterface.h
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_PORTINTERFACE_H_
-#define TALK_P2P_BASE_PORTINTERFACE_H_
+#ifndef WEBRTC_P2P_BASE_PORTINTERFACE_H_
+#define WEBRTC_P2P_BASE_PORTINTERFACE_H_
 
 #include <string>
 
-#include "talk/p2p/base/transport.h"
+#include "webrtc/p2p/base/transport.h"
 #include "webrtc/base/socketaddress.h"
 
 namespace rtc {
@@ -140,4 +140,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_PORTINTERFACE_H_
+#endif  // WEBRTC_P2P_BASE_PORTINTERFACE_H_
diff --git a/p2p/base/portproxy.cc b/p2p/base/portproxy.cc
index 841cd85..5a5d1ff 100644
--- a/p2p/base/portproxy.cc
+++ b/p2p/base/portproxy.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/portproxy.h"
+#include "webrtc/p2p/base/portproxy.h"
 
 namespace cricket {
 
diff --git a/p2p/base/portproxy.h b/p2p/base/portproxy.h
index 8c28223..6f79318 100644
--- a/p2p/base/portproxy.h
+++ b/p2p/base/portproxy.h
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_PORTPROXY_H_
-#define TALK_P2P_BASE_PORTPROXY_H_
+#ifndef WEBRTC_P2P_BASE_PORTPROXY_H_
+#define WEBRTC_P2P_BASE_PORTPROXY_H_
 
-#include "talk/p2p/base/portinterface.h"
+#include "webrtc/p2p/base/portinterface.h"
 #include "webrtc/base/sigslot.h"
 
 namespace rtc {
@@ -101,4 +101,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_PORTPROXY_H_
+#endif  // WEBRTC_P2P_BASE_PORTPROXY_H_
diff --git a/p2p/base/pseudotcp.cc b/p2p/base/pseudotcp.cc
index 9a944f0..a82cd67 100644
--- a/p2p/base/pseudotcp.cc
+++ b/p2p/base/pseudotcp.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/pseudotcp.h"
+#include "webrtc/p2p/base/pseudotcp.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/p2p/base/pseudotcp.h b/p2p/base/pseudotcp.h
index 46e9d3b..e3455de 100644
--- a/p2p/base/pseudotcp.h
+++ b/p2p/base/pseudotcp.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_PSEUDOTCP_H_
-#define TALK_P2P_BASE_PSEUDOTCP_H_
+#ifndef WEBRTC_P2P_BASE_PSEUDOTCP_H_
+#define WEBRTC_P2P_BASE_PSEUDOTCP_H_
 
 #include <list>
 
@@ -255,4 +255,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_PSEUDOTCP_H_
+#endif  // WEBRTC_P2P_BASE_PSEUDOTCP_H_
diff --git a/p2p/base/pseudotcp_unittest.cc b/p2p/base/pseudotcp_unittest.cc
index d9435cf..522eb18 100644
--- a/p2p/base/pseudotcp_unittest.cc
+++ b/p2p/base/pseudotcp_unittest.cc
@@ -27,7 +27,7 @@
 
 #include <vector>
 
-#include "talk/p2p/base/pseudotcp.h"
+#include "webrtc/p2p/base/pseudotcp.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/messagehandler.h"
diff --git a/p2p/base/rawtransport.cc b/p2p/base/rawtransport.cc
index 2af1864..f363dd1 100644
--- a/p2p/base/rawtransport.cc
+++ b/p2p/base/rawtransport.cc
@@ -27,14 +27,14 @@
 
 #include <string>
 #include <vector>
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/rawtransport.h"
-#include "talk/p2p/base/rawtransportchannel.h"
-#include "talk/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/rawtransport.h"
+#include "webrtc/p2p/base/rawtransportchannel.h"
+#include "webrtc/p2p/base/sessionmanager.h"
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/common.h"
 
 #if defined(FEATURE_ENABLE_PSTN)
diff --git a/p2p/base/rawtransport.h b/p2p/base/rawtransport.h
index 3a20ef5..7458191 100644
--- a/p2p/base/rawtransport.h
+++ b/p2p/base/rawtransport.h
@@ -25,11 +25,11 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_RAWTRANSPORT_H_
-#define TALK_P2P_BASE_RAWTRANSPORT_H_
+#ifndef WEBRTC_P2P_BASE_RAWTRANSPORT_H_
+#define WEBRTC_P2P_BASE_RAWTRANSPORT_H_
 
 #include <string>
-#include "talk/p2p/base/transport.h"
+#include "webrtc/p2p/base/transport.h"
 
 #if defined(FEATURE_ENABLE_PSTN)
 namespace cricket {
@@ -78,4 +78,4 @@
 
 #endif  // defined(FEATURE_ENABLE_PSTN)
 
-#endif  // TALK_P2P_BASE_RAWTRANSPORT_H_
+#endif  // WEBRTC_P2P_BASE_RAWTRANSPORT_H_
diff --git a/p2p/base/rawtransportchannel.cc b/p2p/base/rawtransportchannel.cc
index ae268e3..ef2286b 100644
--- a/p2p/base/rawtransportchannel.cc
+++ b/p2p/base/rawtransportchannel.cc
@@ -25,20 +25,20 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/rawtransportchannel.h"
+#include "webrtc/p2p/base/rawtransportchannel.h"
 
 #include <string>
 #include <vector>
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/portallocator.h"
-#include "talk/p2p/base/portinterface.h"
-#include "talk/p2p/base/rawtransport.h"
-#include "talk/p2p/base/relayport.h"
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/p2p/base/stunport.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/portinterface.h"
+#include "webrtc/p2p/base/rawtransport.h"
+#include "webrtc/p2p/base/relayport.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/stunport.h"
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/common.h"
 
 #if defined(FEATURE_ENABLE_PSTN)
diff --git a/p2p/base/rawtransportchannel.h b/p2p/base/rawtransportchannel.h
index 8fbf073..25f6e4f 100644
--- a/p2p/base/rawtransportchannel.h
+++ b/p2p/base/rawtransportchannel.h
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_RAWTRANSPORTCHANNEL_H_
-#define TALK_P2P_BASE_RAWTRANSPORTCHANNEL_H_
+#ifndef WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_
+#define WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_
 
 #include <string>
 #include <vector>
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/rawtransport.h"
-#include "talk/p2p/base/transportchannelimpl.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/rawtransport.h"
+#include "webrtc/p2p/base/transportchannelimpl.h"
 #include "webrtc/base/messagequeue.h"
 
 #if defined(FEATURE_ENABLE_PSTN)
@@ -203,4 +203,4 @@
 }  // namespace cricket
 
 #endif  // defined(FEATURE_ENABLE_PSTN)
-#endif  // TALK_P2P_BASE_RAWTRANSPORTCHANNEL_H_
+#endif  // WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_
diff --git a/p2p/base/relayport.cc b/p2p/base/relayport.cc
index 55052a5..2db42c9 100644
--- a/p2p/base/relayport.cc
+++ b/p2p/base/relayport.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/relayport.h"
+#include "webrtc/p2p/base/relayport.h"
 #include "webrtc/base/asyncpacketsocket.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/relayport.h b/p2p/base/relayport.h
index f22d045..bc0c5d9 100644
--- a/p2p/base/relayport.h
+++ b/p2p/base/relayport.h
@@ -25,16 +25,16 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_RELAYPORT_H_
-#define TALK_P2P_BASE_RELAYPORT_H_
+#ifndef WEBRTC_P2P_BASE_RELAYPORT_H_
+#define WEBRTC_P2P_BASE_RELAYPORT_H_
 
 #include <deque>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/base/stunrequest.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/base/stunrequest.h"
 
 namespace cricket {
 
@@ -115,4 +115,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_RELAYPORT_H_
+#endif  // WEBRTC_P2P_BASE_RELAYPORT_H_
diff --git a/p2p/base/relayport_unittest.cc b/p2p/base/relayport_unittest.cc
index ebb16c5..2f4515e 100644
--- a/p2p/base/relayport_unittest.cc
+++ b/p2p/base/relayport_unittest.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/relayport.h"
-#include "talk/p2p/base/relayserver.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/relayport.h"
+#include "webrtc/p2p/base/relayserver.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/relayserver.cc b/p2p/base/relayserver.cc
index b5d1ac6..ebf165b 100644
--- a/p2p/base/relayserver.cc
+++ b/p2p/base/relayserver.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/relayserver.h"
+#include "webrtc/p2p/base/relayserver.h"
 
 #ifdef POSIX
 #include <errno.h>
diff --git a/p2p/base/relayserver.h b/p2p/base/relayserver.h
index 248d0e7..8065174 100644
--- a/p2p/base/relayserver.h
+++ b/p2p/base/relayserver.h
@@ -25,15 +25,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_RELAYSERVER_H_
-#define TALK_P2P_BASE_RELAYSERVER_H_
+#ifndef WEBRTC_P2P_BASE_RELAYSERVER_H_
+#define WEBRTC_P2P_BASE_RELAYSERVER_H_
 
 #include <map>
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/asyncudpsocket.h"
 #include "webrtc/base/socketaddresspair.h"
 #include "webrtc/base/thread.h"
@@ -249,4 +249,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_RELAYSERVER_H_
+#endif  // WEBRTC_P2P_BASE_RELAYSERVER_H_
diff --git a/p2p/base/relayserver_unittest.cc b/p2p/base/relayserver_unittest.cc
index 5d77ca6..5ea5e10 100644
--- a/p2p/base/relayserver_unittest.cc
+++ b/p2p/base/relayserver_unittest.cc
@@ -27,7 +27,7 @@
 
 #include <string>
 
-#include "talk/p2p/base/relayserver.h"
+#include "webrtc/p2p/base/relayserver.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/session.cc b/p2p/base/session.cc
index a9bf815..c4db1cf 100644
--- a/p2p/base/session.cc
+++ b/p2p/base/session.cc
@@ -25,16 +25,16 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/session.h"
+#include "webrtc/p2p/base/session.h"
 
-#include "talk/p2p/base/dtlstransport.h"
-#include "talk/p2p/base/p2ptransport.h"
-#include "talk/p2p/base/sessionclient.h"
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/base/transportchannelproxy.h"
-#include "talk/p2p/base/transportinfo.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/p2p/base/dtlstransport.h"
+#include "webrtc/p2p/base/p2ptransport.h"
+#include "webrtc/p2p/base/sessionclient.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/base/transportchannelproxy.h"
+#include "webrtc/p2p/base/transportinfo.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/helpers.h"
@@ -42,7 +42,7 @@
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sslstreamadapter.h"
 
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 
 namespace cricket {
 
diff --git a/p2p/base/session.h b/p2p/base/session.h
index e06cf00..cbe350f 100644
--- a/p2p/base/session.h
+++ b/p2p/base/session.h
@@ -25,22 +25,22 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_SESSION_H_
-#define TALK_P2P_BASE_SESSION_H_
+#ifndef WEBRTC_P2P_BASE_SESSION_H_
+#define WEBRTC_P2P_BASE_SESSION_H_
 
 #include <list>
 #include <map>
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/base/sessionclient.h"
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/p2p/base/sessionmessages.h"
-#include "talk/p2p/base/transport.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/base/sessionclient.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/sessionmessages.h"
+#include "webrtc/p2p/base/transport.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/refcount.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/scoped_ref_ptr.h"
@@ -744,4 +744,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_SESSION_H_
+#endif  // WEBRTC_P2P_BASE_SESSION_H_
diff --git a/p2p/base/session_unittest.cc b/p2p/base/session_unittest.cc
index 4674d2c..c7a3db9 100644
--- a/p2p/base/session_unittest.cc
+++ b/p2p/base/session_unittest.cc
@@ -31,22 +31,22 @@
 #include <map>
 #include <sstream>
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/p2ptransport.h"
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/portallocator.h"
-#include "talk/p2p/base/relayport.h"
-#include "talk/p2p/base/relayserver.h"
-#include "talk/p2p/base/session.h"
-#include "talk/p2p/base/sessionclient.h"
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/p2p/base/stunport.h"
-#include "talk/p2p/base/stunserver.h"
-#include "talk/p2p/base/transportchannel.h"
-#include "talk/p2p/base/transportchannelproxy.h"
-#include "talk/p2p/base/udpport.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/p2ptransport.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/relayport.h"
+#include "webrtc/p2p/base/relayserver.h"
+#include "webrtc/p2p/base/session.h"
+#include "webrtc/p2p/base/sessionclient.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/stunport.h"
+#include "webrtc/p2p/base/stunserver.h"
+#include "webrtc/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/transportchannelproxy.h"
+#include "webrtc/p2p/base/udpport.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/base64.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/gunit.h"
diff --git a/p2p/base/sessionclient.h b/p2p/base/sessionclient.h
index 10b0c92..f7952f0 100644
--- a/p2p/base/sessionclient.h
+++ b/p2p/base/sessionclient.h
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_SESSIONCLIENT_H_
-#define TALK_P2P_BASE_SESSIONCLIENT_H_
+#ifndef WEBRTC_P2P_BASE_SESSIONCLIENT_H_
+#define WEBRTC_P2P_BASE_SESSIONCLIENT_H_
 
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 
 namespace buzz {
 class XmlElement;
@@ -92,4 +92,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_SESSIONCLIENT_H_
+#endif  // WEBRTC_P2P_BASE_SESSIONCLIENT_H_
diff --git a/p2p/base/sessiondescription.cc b/p2p/base/sessiondescription.cc
index 7ad3d48..57f08c9 100644
--- a/p2p/base/sessiondescription.cc
+++ b/p2p/base/sessiondescription.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
 
diff --git a/p2p/base/sessiondescription.h b/p2p/base/sessiondescription.h
index 56dd412..bc76761 100644
--- a/p2p/base/sessiondescription.h
+++ b/p2p/base/sessiondescription.h
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_SESSIONDESCRIPTION_H_
-#define TALK_P2P_BASE_SESSIONDESCRIPTION_H_
+#ifndef WEBRTC_P2P_BASE_SESSIONDESCRIPTION_H_
+#define WEBRTC_P2P_BASE_SESSIONDESCRIPTION_H_
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/transportinfo.h"
+#include "webrtc/p2p/base/transportinfo.h"
 #include "webrtc/base/constructormagic.h"
 
 namespace cricket {
@@ -199,4 +199,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_SESSIONDESCRIPTION_H_
+#endif  // WEBRTC_P2P_BASE_SESSIONDESCRIPTION_H_
diff --git a/p2p/base/sessionid.h b/p2p/base/sessionid.h
index 6942942..52ee990 100644
--- a/p2p/base/sessionid.h
+++ b/p2p/base/sessionid.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_SESSIONID_H_
-#define TALK_P2P_BASE_SESSIONID_H_
+#ifndef WEBRTC_P2P_BASE_SESSIONID_H_
+#define WEBRTC_P2P_BASE_SESSIONID_H_
 
 // TODO: Remove this file.
 
@@ -34,4 +34,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_SESSIONID_H_
+#endif  // WEBRTC_P2P_BASE_SESSIONID_H_
diff --git a/p2p/base/sessionmanager.cc b/p2p/base/sessionmanager.cc
index d173517..7f27f6c 100644
--- a/p2p/base/sessionmanager.cc
+++ b/p2p/base/sessionmanager.cc
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/sessionmanager.h"
 
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/session.h"
-#include "talk/p2p/base/sessionmessages.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/session.h"
+#include "webrtc/p2p/base/sessionmessages.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/sessionmanager.h b/p2p/base/sessionmanager.h
index 92aeb3d..0e0e9a4 100644
--- a/p2p/base/sessionmanager.h
+++ b/p2p/base/sessionmanager.h
@@ -25,16 +25,16 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_SESSIONMANAGER_H_
-#define TALK_P2P_BASE_SESSIONMANAGER_H_
+#ifndef WEBRTC_P2P_BASE_SESSIONMANAGER_H_
+#define WEBRTC_P2P_BASE_SESSIONMANAGER_H_
 
 #include <map>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include "talk/p2p/base/portallocator.h"
-#include "talk/p2p/base/transportdescriptionfactory.h"
+#include "webrtc/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/transportdescriptionfactory.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/thread.h"
 
@@ -208,4 +208,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_SESSIONMANAGER_H_
+#endif  // WEBRTC_P2P_BASE_SESSIONMANAGER_H_
diff --git a/p2p/base/sessionmessages.cc b/p2p/base/sessionmessages.cc
index b2fd9d6..0534271 100644
--- a/p2p/base/sessionmessages.cc
+++ b/p2p/base/sessionmessages.cc
@@ -25,19 +25,19 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/sessionmessages.h"
+#include "webrtc/p2p/base/sessionmessages.h"
 
 #include <stdio.h>
 #include <string>
 
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/p2ptransport.h"
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/sessionclient.h"
-#include "talk/p2p/base/sessiondescription.h"
-#include "talk/p2p/base/transport.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/p2ptransport.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/sessionclient.h"
+#include "webrtc/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/transport.h"
 #include "webrtc/libjingle/xmllite/xmlconstants.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/stringutils.h"
diff --git a/p2p/base/sessionmessages.h b/p2p/base/sessionmessages.h
index 7e1f8ac..0ab56ce 100644
--- a/p2p/base/sessionmessages.h
+++ b/p2p/base/sessionmessages.h
@@ -25,17 +25,17 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_SESSIONMESSAGES_H_
-#define TALK_P2P_BASE_SESSIONMESSAGES_H_
+#ifndef WEBRTC_P2P_BASE_SESSIONMESSAGES_H_
+#define WEBRTC_P2P_BASE_SESSIONMESSAGES_H_
 
 #include <map>
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/sessiondescription.h"  // Needed to delete contents.
-#include "talk/p2p/base/transportinfo.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/sessiondescription.h"  // Needed to delete contents.
+#include "webrtc/p2p/base/transportinfo.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
 #include "webrtc/base/basictypes.h"
 
@@ -240,4 +240,4 @@
                          SessionRedirect* redirect);
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_SESSIONMESSAGES_H_
+#endif  // WEBRTC_P2P_BASE_SESSIONMESSAGES_H_
diff --git a/p2p/base/stun.cc b/p2p/base/stun.cc
index 061fd9a..6bdf77e 100644
--- a/p2p/base/stun.cc
+++ b/p2p/base/stun.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/stun.h"
 
 #include <string.h>
 
diff --git a/p2p/base/stun.h b/p2p/base/stun.h
index c4f522b..5a43a3c 100644
--- a/p2p/base/stun.h
+++ b/p2p/base/stun.h
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_STUN_H_
-#define TALK_P2P_BASE_STUN_H_
+#ifndef WEBRTC_P2P_BASE_STUN_H_
+#define WEBRTC_P2P_BASE_STUN_H_
 
 // This file contains classes for dealing with the STUN protocol, as specified
 // in RFC 5389, and its descendants.
@@ -646,4 +646,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_STUN_H_
+#endif  // WEBRTC_P2P_BASE_STUN_H_
diff --git a/p2p/base/stun_unittest.cc b/p2p/base/stun_unittest.cc
index 00dffed..34a47cb 100644
--- a/p2p/base/stun_unittest.cc
+++ b/p2p/base/stun_unittest.cc
@@ -27,7 +27,7 @@
 
 #include <string>
 
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/stunport.cc b/p2p/base/stunport.cc
index a185a35..0602c5a 100644
--- a/p2p/base/stunport.cc
+++ b/p2p/base/stunport.cc
@@ -25,10 +25,11 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/stunport.h"
+#include "webrtc/p2p/base/stunport.h"
 
-#include "talk/p2p/base/common.h"
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/common.h"
+#include "webrtc/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
@@ -395,8 +396,17 @@
   // For STUN, related address is the local socket address.
   if ((!SharedSocket() || stun_reflected_addr != socket_->GetLocalAddress()) &&
       !HasCandidateWithAddress(stun_reflected_addr)) {
+
+    rtc::SocketAddress related_address = socket_->GetLocalAddress();
+    if (!(candidate_filter() & CF_HOST)) {
+      // If candidate filter doesn't have CF_HOST specified, empty raddr to
+      // avoid local address leakage.
+      related_address = rtc::EmptySocketAddressWithFamily(
+          related_address.family());
+    }
+
     AddAddress(stun_reflected_addr, socket_->GetLocalAddress(),
-               socket_->GetLocalAddress(), UDP_PROTOCOL_NAME, "",
+               related_address, UDP_PROTOCOL_NAME, "",
                STUN_PORT_TYPE, ICE_TYPE_PREFERENCE_SRFLX, 0, false);
   }
   MaybeSetPortCompleteOrError();
diff --git a/p2p/base/stunport.h b/p2p/base/stunport.h
index 1fc1f64..9767546 100644
--- a/p2p/base/stunport.h
+++ b/p2p/base/stunport.h
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_STUNPORT_H_
-#define TALK_P2P_BASE_STUNPORT_H_
+#ifndef WEBRTC_P2P_BASE_STUNPORT_H_
+#define WEBRTC_P2P_BASE_STUNPORT_H_
 
 #include <string>
 
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/base/stunrequest.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/base/stunrequest.h"
 #include "webrtc/base/asyncpacketsocket.h"
 
 // TODO(mallinath) - Rename stunport.cc|h to udpport.cc|h.
@@ -252,4 +252,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_STUNPORT_H_
+#endif  // WEBRTC_P2P_BASE_STUNPORT_H_
diff --git a/p2p/base/stunport_unittest.cc b/p2p/base/stunport_unittest.cc
index 5c97ecc..7b289ea 100644
--- a/p2p/base/stunport_unittest.cc
+++ b/p2p/base/stunport_unittest.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/stunport.h"
-#include "talk/p2p/base/teststunserver.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/stunport.h"
+#include "webrtc/p2p/base/teststunserver.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/physicalsocketserver.h"
diff --git a/p2p/base/stunrequest.cc b/p2p/base/stunrequest.cc
index 148718f..55d270e 100644
--- a/p2p/base/stunrequest.cc
+++ b/p2p/base/stunrequest.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/stunrequest.h"
+#include "webrtc/p2p/base/stunrequest.h"
 
 #include "webrtc/base/common.h"
 #include "webrtc/base/helpers.h"
diff --git a/p2p/base/stunrequest.h b/p2p/base/stunrequest.h
index 374f7e7..be73445 100644
--- a/p2p/base/stunrequest.h
+++ b/p2p/base/stunrequest.h
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_STUNREQUEST_H_
-#define TALK_P2P_BASE_STUNREQUEST_H_
+#ifndef WEBRTC_P2P_BASE_STUNREQUEST_H_
+#define WEBRTC_P2P_BASE_STUNREQUEST_H_
 
 #include <map>
 #include <string>
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/thread.h"
 
@@ -130,4 +130,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_STUNREQUEST_H_
+#endif  // WEBRTC_P2P_BASE_STUNREQUEST_H_
diff --git a/p2p/base/stunrequest_unittest.cc b/p2p/base/stunrequest_unittest.cc
index 2783aa3..5c7b97b 100644
--- a/p2p/base/stunrequest_unittest.cc
+++ b/p2p/base/stunrequest_unittest.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/stunrequest.h"
+#include "webrtc/p2p/base/stunrequest.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/stunserver.cc b/p2p/base/stunserver.cc
index df428f9..a4beca4 100644
--- a/p2p/base/stunserver.cc
+++ b/p2p/base/stunserver.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/stunserver.h"
+#include "webrtc/p2p/base/stunserver.h"
 
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/stunserver.h b/p2p/base/stunserver.h
index a141e5b..5bbe258 100644
--- a/p2p/base/stunserver.h
+++ b/p2p/base/stunserver.h
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_STUNSERVER_H_
-#define TALK_P2P_BASE_STUNSERVER_H_
+#ifndef WEBRTC_P2P_BASE_STUNSERVER_H_
+#define WEBRTC_P2P_BASE_STUNSERVER_H_
 
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/asyncudpsocket.h"
 #include "webrtc/base/scoped_ptr.h"
 
@@ -80,4 +80,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_STUNSERVER_H_
+#endif  // WEBRTC_P2P_BASE_STUNSERVER_H_
diff --git a/p2p/base/stunserver_unittest.cc b/p2p/base/stunserver_unittest.cc
index 405d8ae..4cf3c33 100644
--- a/p2p/base/stunserver_unittest.cc
+++ b/p2p/base/stunserver_unittest.cc
@@ -27,7 +27,7 @@
 
 #include <string>
 
-#include "talk/p2p/base/stunserver.h"
+#include "webrtc/p2p/base/stunserver.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/physicalsocketserver.h"
diff --git a/p2p/base/tcpport.cc b/p2p/base/tcpport.cc
index cb5b726..aa08a92 100644
--- a/p2p/base/tcpport.cc
+++ b/p2p/base/tcpport.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/tcpport.h"
+#include "webrtc/p2p/base/tcpport.h"
 
-#include "talk/p2p/base/common.h"
+#include "webrtc/p2p/base/common.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
 
@@ -304,20 +304,23 @@
   // the one we asked for. This is seen in Chrome, where TCP sockets cannot be
   // given a binding address, and the platform is expected to pick the
   // correct local address.
-  if (socket->GetLocalAddress().ipaddr() == port()->ip()) {
+  const rtc::IPAddress& socket_ip = socket->GetLocalAddress().ipaddr();
+  if (socket_ip == port()->ip()) {
     LOG_J(LS_VERBOSE, this) << "Connection established to "
                             << socket->GetRemoteAddress().ToSensitiveString();
     set_connected(true);
   } else {
-    LOG_J(LS_WARNING, this) << "Dropping connection as TCP socket bound to a "
-                            << "different address from the local candidate.";
+    LOG_J(LS_WARNING, this) << "Dropping connection as TCP socket bound to IP "
+                            << socket_ip.ToSensitiveString()
+                            << ", different from the local candidate IP "
+                            << port()->ip().ToSensitiveString();
     socket_->Close();
   }
 }
 
 void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) {
   ASSERT(socket == socket_);
-  LOG_J(LS_VERBOSE, this) << "Connection closed with error " << error;
+  LOG_J(LS_INFO, this) << "Connection closed with error " << error;
   set_connected(false);
   set_write_state(STATE_WRITE_TIMEOUT);
 }
diff --git a/p2p/base/tcpport.h b/p2p/base/tcpport.h
index 97bd977..c331f6b 100644
--- a/p2p/base/tcpport.h
+++ b/p2p/base/tcpport.h
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TCPPORT_H_
-#define TALK_P2P_BASE_TCPPORT_H_
+#ifndef WEBRTC_P2P_BASE_TCPPORT_H_
+#define WEBRTC_P2P_BASE_TCPPORT_H_
 
 #include <list>
 #include <string>
-#include "talk/p2p/base/port.h"
+#include "webrtc/p2p/base/port.h"
 #include "webrtc/base/asyncpacketsocket.h"
 
 namespace cricket {
@@ -150,4 +150,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TCPPORT_H_
+#endif  // WEBRTC_P2P_BASE_TCPPORT_H_
diff --git a/p2p/base/testrelayserver.h b/p2p/base/testrelayserver.h
index eaeefc8..003b42c 100644
--- a/p2p/base/testrelayserver.h
+++ b/p2p/base/testrelayserver.h
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TESTRELAYSERVER_H_
-#define TALK_P2P_BASE_TESTRELAYSERVER_H_
+#ifndef WEBRTC_P2P_BASE_TESTRELAYSERVER_H_
+#define WEBRTC_P2P_BASE_TESTRELAYSERVER_H_
 
-#include "talk/p2p/base/relayserver.h"
+#include "webrtc/p2p/base/relayserver.h"
 #include "webrtc/base/asynctcpsocket.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sigslot.h"
@@ -115,4 +115,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TESTRELAYSERVER_H_
+#endif  // WEBRTC_P2P_BASE_TESTRELAYSERVER_H_
diff --git a/p2p/base/teststunserver.h b/p2p/base/teststunserver.h
index 840150b..eef15d7 100644
--- a/p2p/base/teststunserver.h
+++ b/p2p/base/teststunserver.h
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TESTSTUNSERVER_H_
-#define TALK_P2P_BASE_TESTSTUNSERVER_H_
+#ifndef WEBRTC_P2P_BASE_TESTSTUNSERVER_H_
+#define WEBRTC_P2P_BASE_TESTSTUNSERVER_H_
 
-#include "talk/p2p/base/stunserver.h"
+#include "webrtc/p2p/base/stunserver.h"
 #include "webrtc/base/socketaddress.h"
 #include "webrtc/base/thread.h"
 
@@ -72,4 +72,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TESTSTUNSERVER_H_
+#endif  // WEBRTC_P2P_BASE_TESTSTUNSERVER_H_
diff --git a/p2p/base/testturnserver.h b/p2p/base/testturnserver.h
index 6c30afe..64da877 100644
--- a/p2p/base/testturnserver.h
+++ b/p2p/base/testturnserver.h
@@ -25,15 +25,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TESTTURNSERVER_H_
-#define TALK_P2P_BASE_TESTTURNSERVER_H_
+#ifndef WEBRTC_P2P_BASE_TESTTURNSERVER_H_
+#define WEBRTC_P2P_BASE_TESTTURNSERVER_H_
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/stun.h"
-#include "talk/p2p/base/turnserver.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/stun.h"
+#include "webrtc/p2p/base/turnserver.h"
 #include "webrtc/base/asyncudpsocket.h"
 #include "webrtc/base/thread.h"
 
@@ -117,4 +117,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TESTTURNSERVER_H_
+#endif  // WEBRTC_P2P_BASE_TESTTURNSERVER_H_
diff --git a/p2p/base/transport.cc b/p2p/base/transport.cc
index d88f5e7..f33f942 100644
--- a/p2p/base/transport.cc
+++ b/p2p/base/transport.cc
@@ -25,16 +25,16 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/transport.h"
+#include "webrtc/p2p/base/transport.h"
 
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/p2p/base/transportchannelimpl.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/transportchannelimpl.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/transport.h b/p2p/base/transport.h
index 21661f6..fbc7f6f 100644
--- a/p2p/base/transport.h
+++ b/p2p/base/transport.h
@@ -43,16 +43,16 @@
 // It is not possible to do so here because the subclass constructor will
 // already have run.
 
-#ifndef TALK_P2P_BASE_TRANSPORT_H_
-#define TALK_P2P_BASE_TRANSPORT_H_
+#ifndef WEBRTC_P2P_BASE_TRANSPORT_H_
+#define WEBRTC_P2P_BASE_TRANSPORT_H_
 
 #include <map>
 #include <string>
 #include <vector>
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/sessiondescription.h"
-#include "talk/p2p/base/transportinfo.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/transportinfo.h"
 #include "webrtc/base/criticalsection.h"
 #include "webrtc/base/messagequeue.h"
 #include "webrtc/base/sigslot.h"
@@ -527,4 +527,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TRANSPORT_H_
+#endif  // WEBRTC_P2P_BASE_TRANSPORT_H_
diff --git a/p2p/base/transport_unittest.cc b/p2p/base/transport_unittest.cc
index 8f7dae2..9ef7d60 100644
--- a/p2p/base/transport_unittest.cc
+++ b/p2p/base/transport_unittest.cc
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/fakesession.h"
-#include "talk/p2p/base/p2ptransport.h"
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/rawtransport.h"
-#include "talk/p2p/base/sessionmessages.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/p2ptransport.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/rawtransport.h"
+#include "webrtc/p2p/base/sessionmessages.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/fakesslidentity.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/thread.h"
diff --git a/p2p/base/transportchannel.cc b/p2p/base/transportchannel.cc
index 50ebfb9..13048ed 100644
--- a/p2p/base/transportchannel.cc
+++ b/p2p/base/transportchannel.cc
@@ -26,7 +26,7 @@
  */
 
 #include <sstream>
-#include "talk/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/transportchannel.h"
 
 namespace cricket {
 
diff --git a/p2p/base/transportchannel.h b/p2p/base/transportchannel.h
index b0beb04..56d9467 100644
--- a/p2p/base/transportchannel.h
+++ b/p2p/base/transportchannel.h
@@ -25,15 +25,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TRANSPORTCHANNEL_H_
-#define TALK_P2P_BASE_TRANSPORTCHANNEL_H_
+#ifndef WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_
+#define WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/base/transportdescription.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/base/transportdescription.h"
 #include "webrtc/base/asyncpacketsocket.h"
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/dscp.h"
@@ -157,4 +157,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TRANSPORTCHANNEL_H_
+#endif  // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_
diff --git a/p2p/base/transportchannelimpl.h b/p2p/base/transportchannelimpl.h
index fde980b..73afdee 100644
--- a/p2p/base/transportchannelimpl.h
+++ b/p2p/base/transportchannelimpl.h
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_
-#define TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_
+#ifndef WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_
+#define WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_
 
 #include <string>
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/base/transportchannel.h"
 
 namespace buzz { class XmlElement; }
 
@@ -125,4 +125,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_
+#endif  // WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_
diff --git a/p2p/base/transportchannelproxy.cc b/p2p/base/transportchannelproxy.cc
index 9fa0b6a..259b8dd 100644
--- a/p2p/base/transportchannelproxy.cc
+++ b/p2p/base/transportchannelproxy.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/base/transportchannelimpl.h"
-#include "talk/p2p/base/transportchannelproxy.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/base/transportchannelimpl.h"
+#include "webrtc/p2p/base/transportchannelproxy.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/thread.h"
diff --git a/p2p/base/transportchannelproxy.h b/p2p/base/transportchannelproxy.h
index 07b9090..dee4313 100644
--- a/p2p/base/transportchannelproxy.h
+++ b/p2p/base/transportchannelproxy.h
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TRANSPORTCHANNELPROXY_H_
-#define TALK_P2P_BASE_TRANSPORTCHANNELPROXY_H_
+#ifndef WEBRTC_P2P_BASE_TRANSPORTCHANNELPROXY_H_
+#define WEBRTC_P2P_BASE_TRANSPORTCHANNELPROXY_H_
 
 #include <string>
 #include <utility>
 #include <vector>
 
-#include "talk/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/transportchannel.h"
 #include "webrtc/base/messagehandler.h"
 
 namespace rtc {
@@ -109,4 +109,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TRANSPORTCHANNELPROXY_H_
+#endif  // WEBRTC_P2P_BASE_TRANSPORTCHANNELPROXY_H_
diff --git a/p2p/base/transportdescription.cc b/p2p/base/transportdescription.cc
index 08460d7..8bdcbb3 100644
--- a/p2p/base/transportdescription.cc
+++ b/p2p/base/transportdescription.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/transportdescription.h"
+#include "webrtc/p2p/base/transportdescription.h"
 
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 #include "webrtc/base/stringutils.h"
 
 namespace cricket {
diff --git a/p2p/base/transportdescription.h b/p2p/base/transportdescription.h
index efd04ff..5763d23 100644
--- a/p2p/base/transportdescription.h
+++ b/p2p/base/transportdescription.h
@@ -25,15 +25,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TRANSPORTDESCRIPTION_H_
-#define TALK_P2P_BASE_TRANSPORTDESCRIPTION_H_
+#ifndef WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_
+#define WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_
 
 #include <algorithm>
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/constants.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sslfingerprint.h"
 
@@ -185,4 +185,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TRANSPORTDESCRIPTION_H_
+#endif  // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_
diff --git a/p2p/base/transportdescriptionfactory.cc b/p2p/base/transportdescriptionfactory.cc
index 4eb603c..7260b9c 100644
--- a/p2p/base/transportdescriptionfactory.cc
+++ b/p2p/base/transportdescriptionfactory.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/transportdescriptionfactory.h"
+#include "webrtc/p2p/base/transportdescriptionfactory.h"
 
-#include "talk/p2p/base/transportdescription.h"
+#include "webrtc/p2p/base/transportdescription.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/messagedigest.h"
diff --git a/p2p/base/transportdescriptionfactory.h b/p2p/base/transportdescriptionfactory.h
index 84f25ac..bcd14c6 100644
--- a/p2p/base/transportdescriptionfactory.h
+++ b/p2p/base/transportdescriptionfactory.h
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_
-#define TALK_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_
+#ifndef WEBRTC_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_
+#define WEBRTC_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_
 
-#include "talk/p2p/base/transportdescription.h"
+#include "webrtc/p2p/base/transportdescription.h"
 
 namespace rtc {
 class SSLIdentity;
@@ -80,4 +80,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_
+#endif  // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_
diff --git a/p2p/base/transportdescriptionfactory_unittest.cc b/p2p/base/transportdescriptionfactory_unittest.cc
index 5c17f96..a793853 100644
--- a/p2p/base/transportdescriptionfactory_unittest.cc
+++ b/p2p/base/transportdescriptionfactory_unittest.cc
@@ -28,9 +28,9 @@
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/transportdescription.h"
-#include "talk/p2p/base/transportdescriptionfactory.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/transportdescription.h"
+#include "webrtc/p2p/base/transportdescriptionfactory.h"
 #include "webrtc/base/fakesslidentity.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/ssladapter.h"
diff --git a/p2p/base/transportinfo.h b/p2p/base/transportinfo.h
index 5ffb10a..414b6ca 100644
--- a/p2p/base/transportinfo.h
+++ b/p2p/base/transportinfo.h
@@ -25,15 +25,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TRANSPORTINFO_H_
-#define TALK_P2P_BASE_TRANSPORTINFO_H_
+#ifndef WEBRTC_P2P_BASE_TRANSPORTINFO_H_
+#define WEBRTC_P2P_BASE_TRANSPORTINFO_H_
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/transportdescription.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/transportdescription.h"
 #include "webrtc/base/helpers.h"
 
 namespace cricket {
@@ -57,4 +57,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TRANSPORTINFO_H_
+#endif  // WEBRTC_P2P_BASE_TRANSPORTINFO_H_
diff --git a/p2p/base/turnport.cc b/p2p/base/turnport.cc
index 2908d71..b38317b 100644
--- a/p2p/base/turnport.cc
+++ b/p2p/base/turnport.cc
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/turnport.h"
+#include "webrtc/p2p/base/turnport.h"
 
 #include <functional>
 
-#include "talk/p2p/base/common.h"
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/common.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/asyncpacketsocket.h"
 #include "webrtc/base/byteorder.h"
 #include "webrtc/base/common.h"
@@ -588,10 +588,18 @@
 void TurnPort::OnAllocateSuccess(const rtc::SocketAddress& address,
                                  const rtc::SocketAddress& stun_address) {
   connected_ = true;
+
+  rtc::SocketAddress related_address = stun_address;
+    if (!(candidate_filter() & CF_REFLEXIVE)) {
+    // If candidate filter only allows relay type of address, empty raddr to
+    // avoid local address leakage.
+    related_address = rtc::EmptySocketAddressWithFamily(stun_address.family());
+  }
+
   // For relayed candidate, Base is the candidate itself.
-  AddAddress(address,  // Candidate address.
-             address,  // Base address.
-             stun_address,  // Related address.
+  AddAddress(address,          // Candidate address.
+             address,          // Base address.
+             related_address,  // Related address.
              UDP_PROTOCOL_NAME,
              "",  // TCP canddiate type, empty for turn candidates.
              RELAY_PORT_TYPE,
diff --git a/p2p/base/turnport.h b/p2p/base/turnport.h
index ab7d4e7..6345aea 100644
--- a/p2p/base/turnport.h
+++ b/p2p/base/turnport.h
@@ -25,16 +25,16 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TURNPORT_H_
-#define TALK_P2P_BASE_TURNPORT_H_
+#ifndef WEBRTC_P2P_BASE_TURNPORT_H_
+#define WEBRTC_P2P_BASE_TURNPORT_H_
 
 #include <stdio.h>
 #include <list>
 #include <set>
 #include <string>
 
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/client/basicportallocator.h"
 #include "webrtc/base/asyncpacketsocket.h"
 
 namespace rtc {
@@ -251,4 +251,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TURNPORT_H_
+#endif  // WEBRTC_P2P_BASE_TURNPORT_H_
diff --git a/p2p/base/turnport_unittest.cc b/p2p/base/turnport_unittest.cc
index c5261e4..95615ff 100644
--- a/p2p/base/turnport_unittest.cc
+++ b/p2p/base/turnport_unittest.cc
@@ -28,12 +28,12 @@
 #include <dirent.h>
 #endif
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/tcpport.h"
-#include "talk/p2p/base/testturnserver.h"
-#include "talk/p2p/base/turnport.h"
-#include "talk/p2p/base/udpport.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/tcpport.h"
+#include "webrtc/p2p/base/testturnserver.h"
+#include "webrtc/p2p/base/turnport.h"
+#include "webrtc/p2p/base/udpport.h"
 #include "webrtc/base/asynctcpsocket.h"
 #include "webrtc/base/buffer.h"
 #include "webrtc/base/dscp.h"
diff --git a/p2p/base/turnserver.cc b/p2p/base/turnserver.cc
index dbcbcd4..28096ae 100644
--- a/p2p/base/turnserver.cc
+++ b/p2p/base/turnserver.cc
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/turnserver.h"
+#include "webrtc/p2p/base/turnserver.h"
 
-#include "talk/p2p/base/asyncstuntcpsocket.h"
-#include "talk/p2p/base/common.h"
-#include "talk/p2p/base/packetsocketfactory.h"
-#include "talk/p2p/base/stun.h"
+#include "webrtc/p2p/base/asyncstuntcpsocket.h"
+#include "webrtc/p2p/base/common.h"
+#include "webrtc/p2p/base/packetsocketfactory.h"
+#include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
diff --git a/p2p/base/turnserver.h b/p2p/base/turnserver.h
index 553d00c..44878fd 100644
--- a/p2p/base/turnserver.h
+++ b/p2p/base/turnserver.h
@@ -25,15 +25,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_TURNSERVER_H_
-#define TALK_P2P_BASE_TURNSERVER_H_
+#ifndef WEBRTC_P2P_BASE_TURNSERVER_H_
+#define WEBRTC_P2P_BASE_TURNSERVER_H_
 
 #include <list>
 #include <map>
 #include <set>
 #include <string>
 
-#include "talk/p2p/base/portinterface.h"
+#include "webrtc/p2p/base/portinterface.h"
 #include "webrtc/base/asyncpacketsocket.h"
 #include "webrtc/base/messagequeue.h"
 #include "webrtc/base/sigslot.h"
@@ -204,4 +204,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_BASE_TURNSERVER_H_
+#endif  // WEBRTC_P2P_BASE_TURNSERVER_H_
diff --git a/p2p/base/udpport.h b/p2p/base/udpport.h
index fc981fd..35be1a1 100644
--- a/p2p/base/udpport.h
+++ b/p2p/base/udpport.h
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_BASE_UDPPORT_H_
-#define TALK_P2P_BASE_UDPPORT_H_
+#ifndef WEBRTC_P2P_BASE_UDPPORT_H_
+#define WEBRTC_P2P_BASE_UDPPORT_H_
 
 // StunPort will be handling UDPPort functionality.
-#include "talk/p2p/base/stunport.h"
+#include "webrtc/p2p/base/stunport.h"
 
-#endif  // TALK_P2P_BASE_UDPPORT_H_
+#endif  // WEBRTC_P2P_BASE_UDPPORT_H_
diff --git a/p2p/client/autoportallocator.h b/p2p/client/autoportallocator.h
index ed87162..e7f2169 100644
--- a/p2p/client/autoportallocator.h
+++ b/p2p/client/autoportallocator.h
@@ -25,15 +25,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_CLIENT_AUTOPORTALLOCATOR_H_
-#define TALK_P2P_CLIENT_AUTOPORTALLOCATOR_H_
+#ifndef WEBRTC_P2P_CLIENT_AUTOPORTALLOCATOR_H_
+#define WEBRTC_P2P_CLIENT_AUTOPORTALLOCATOR_H_
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/client/httpportallocator.h"
-#include "talk/xmpp/jingleinfotask.h"
-#include "talk/xmpp/xmppclient.h"
+#include "webrtc/p2p/client/httpportallocator.h"
+#include "webrtc/libjingle/xmpp/jingleinfotask.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
 #include "webrtc/base/sigslot.h"
 
 // This class sets the relay and stun servers using XmppClient.
@@ -66,4 +66,4 @@
   }
 };
 
-#endif  // TALK_P2P_CLIENT_AUTOPORTALLOCATOR_H_
+#endif  // WEBRTC_P2P_CLIENT_AUTOPORTALLOCATOR_H_
diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc
index 0ec13e7..27d0db2 100644
--- a/p2p/client/basicportallocator.cc
+++ b/p2p/client/basicportallocator.cc
@@ -25,19 +25,19 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/client/basicportallocator.h"
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/common.h"
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/base/relayport.h"
-#include "talk/p2p/base/stunport.h"
-#include "talk/p2p/base/tcpport.h"
-#include "talk/p2p/base/turnport.h"
-#include "talk/p2p/base/udpport.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/common.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/base/relayport.h"
+#include "webrtc/p2p/base/stunport.h"
+#include "webrtc/p2p/base/tcpport.h"
+#include "webrtc/p2p/base/turnport.h"
+#include "webrtc/p2p/base/udpport.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
@@ -497,6 +497,9 @@
   port->set_send_retransmit_count_attribute((allocator_->flags() &
       PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0);
 
+  // Push down the candidate_filter to individual port.
+  port->set_candidate_filter(allocator_->candidate_filter());
+
   PortData data(port, seq);
   ports_.push_back(data);
 
diff --git a/p2p/client/basicportallocator.h b/p2p/client/basicportallocator.h
index d424772..e2389d3 100644
--- a/p2p/client/basicportallocator.h
+++ b/p2p/client/basicportallocator.h
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_CLIENT_BASICPORTALLOCATOR_H_
-#define TALK_P2P_CLIENT_BASICPORTALLOCATOR_H_
+#ifndef WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
+#define WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
 
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/base/portallocator.h"
 #include "webrtc/base/messagequeue.h"
 #include "webrtc/base/network.h"
 #include "webrtc/base/scoped_ptr.h"
@@ -255,4 +255,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_CLIENT_BASICPORTALLOCATOR_H_
+#endif  // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
diff --git a/p2p/client/connectivitychecker.cc b/p2p/client/connectivitychecker.cc
index 723c5a1..38a7dd2 100644
--- a/p2p/client/connectivitychecker.cc
+++ b/p2p/client/connectivitychecker.cc
@@ -27,14 +27,14 @@
 
 #include <string>
 
-#include "talk/p2p/client/connectivitychecker.h"
+#include "webrtc/p2p/client/connectivitychecker.h"
 
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/common.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/port.h"
-#include "talk/p2p/base/relayport.h"
-#include "talk/p2p/base/stunport.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/common.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/p2p/base/relayport.h"
+#include "webrtc/p2p/base/stunport.h"
 #include "webrtc/base/asynchttprequest.h"
 #include "webrtc/base/autodetectproxy.h"
 #include "webrtc/base/helpers.h"
diff --git a/p2p/client/connectivitychecker.h b/p2p/client/connectivitychecker.h
index d4cda1e..ba3d003 100644
--- a/p2p/client/connectivitychecker.h
+++ b/p2p/client/connectivitychecker.h
@@ -1,14 +1,14 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
 
-#ifndef TALK_P2P_CLIENT_CONNECTIVITYCHECKER_H_
-#define TALK_P2P_CLIENT_CONNECTIVITYCHECKER_H_
+#ifndef WEBRTC_P2P_CLIENT_CONNECTIVITYCHECKER_H_
+#define WEBRTC_P2P_CLIENT_CONNECTIVITYCHECKER_H_
 
 #include <map>
 #include <string>
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/client/httpportallocator.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/client/httpportallocator.h"
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/messagehandler.h"
 #include "webrtc/base/network.h"
@@ -271,4 +271,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_CLIENT_CONNECTIVITYCHECKER_H_
+#endif  // WEBRTC_P2P_CLIENT_CONNECTIVITYCHECKER_H_
diff --git a/p2p/client/connectivitychecker_unittest.cc b/p2p/client/connectivitychecker_unittest.cc
index 187505a..5a2a608 100644
--- a/p2p/client/connectivitychecker_unittest.cc
+++ b/p2p/client/connectivitychecker_unittest.cc
@@ -27,11 +27,11 @@
 
 #include <string>
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/relayport.h"
-#include "talk/p2p/base/stunport.h"
-#include "talk/p2p/client/connectivitychecker.h"
-#include "talk/p2p/client/httpportallocator.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/relayport.h"
+#include "webrtc/p2p/base/stunport.h"
+#include "webrtc/p2p/client/connectivitychecker.h"
+#include "webrtc/p2p/client/httpportallocator.h"
 #include "webrtc/base/asynchttprequest.h"
 #include "webrtc/base/fakenetwork.h"
 #include "webrtc/base/gunit.h"
diff --git a/p2p/client/fakeportallocator.h b/p2p/client/fakeportallocator.h
index e1a04dd..04c5f47 100644
--- a/p2p/client/fakeportallocator.h
+++ b/p2p/client/fakeportallocator.h
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_CLIENT_FAKEPORTALLOCATOR_H_
-#define TALK_P2P_CLIENT_FAKEPORTALLOCATOR_H_
+#ifndef WEBRTC_P2P_CLIENT_FAKEPORTALLOCATOR_H_
+#define WEBRTC_P2P_CLIENT_FAKEPORTALLOCATOR_H_
 
 #include <string>
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/portallocator.h"
-#include "talk/p2p/base/udpport.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/portallocator.h"
+#include "webrtc/p2p/base/udpport.h"
 #include "webrtc/base/scoped_ptr.h"
 
 namespace rtc {
@@ -135,4 +135,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_CLIENT_FAKEPORTALLOCATOR_H_
+#endif  // WEBRTC_P2P_CLIENT_FAKEPORTALLOCATOR_H_
diff --git a/p2p/client/httpportallocator.cc b/p2p/client/httpportallocator.cc
index 31c9b51..ce52593 100644
--- a/p2p/client/httpportallocator.cc
+++ b/p2p/client/httpportallocator.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/client/httpportallocator.h"
+#include "webrtc/p2p/client/httpportallocator.h"
 
 #include <algorithm>
 #include <map>
diff --git a/p2p/client/httpportallocator.h b/p2p/client/httpportallocator.h
index 7ace943..cab8e7e 100644
--- a/p2p/client/httpportallocator.h
+++ b/p2p/client/httpportallocator.h
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_CLIENT_HTTPPORTALLOCATOR_H_
-#define TALK_P2P_CLIENT_HTTPPORTALLOCATOR_H_
+#ifndef WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_
+#define WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_
 
 #include <list>
 #include <string>
 #include <vector>
 
-#include "talk/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/client/basicportallocator.h"
 
 class HttpPortAllocatorTest_TestSessionRequestUrl_Test;
 
@@ -187,4 +187,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_CLIENT_HTTPPORTALLOCATOR_H_
+#endif  // WEBRTC_P2P_CLIENT_HTTPPORTALLOCATOR_H_
diff --git a/p2p/client/portallocator_unittest.cc b/p2p/client/portallocator_unittest.cc
index 84b8d03..5b1a869 100644
--- a/p2p/client/portallocator_unittest.cc
+++ b/p2p/client/portallocator_unittest.cc
@@ -25,15 +25,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/base/basicpacketsocketfactory.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/p2ptransportchannel.h"
-#include "talk/p2p/base/portallocatorsessionproxy.h"
-#include "talk/p2p/base/testrelayserver.h"
-#include "talk/p2p/base/teststunserver.h"
-#include "talk/p2p/base/testturnserver.h"
-#include "talk/p2p/client/basicportallocator.h"
-#include "talk/p2p/client/httpportallocator.h"
+#include "webrtc/p2p/base/basicpacketsocketfactory.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/p2ptransportchannel.h"
+#include "webrtc/p2p/base/portallocatorsessionproxy.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/p2p/client/httpportallocator.h"
 #include "webrtc/base/fakenetwork.h"
 #include "webrtc/base/firewallsocketserver.h"
 #include "webrtc/base/gunit.h"
@@ -113,6 +113,8 @@
         candidate_allocation_done_(false) {
     cricket::ServerAddresses stun_servers;
     stun_servers.insert(kStunAddr);
+    // Passing the addresses of GTURN servers will enable GTURN in
+    // Basicportallocator.
     allocator_.reset(new cricket::BasicPortAllocator(
         &network_manager_,
         stun_servers,
@@ -137,6 +139,14 @@
     allocator().set_step_delay(cricket::kMinimumStepDelay);
   }
 
+  // Create a BasicPortAllocator without GTURN and add the TURN servers.
+  void ResetWithTurnServers(const rtc::SocketAddress& udp_turn,
+                            const rtc::SocketAddress& tcp_turn) {
+    allocator_.reset(new cricket::BasicPortAllocator(&network_manager_));
+    allocator().set_step_delay(cricket::kMinimumStepDelay);
+    AddTurnServers(udp_turn, tcp_turn);
+  }
+
   void AddTurnServers(const rtc::SocketAddress& udp_turn,
                       const rtc::SocketAddress& tcp_turn) {
     cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
@@ -565,17 +575,32 @@
 }
 
 // Test ICE candidate filter mechanism with options Relay/Host/Reflexive.
+// This test also verifies that when the allocator is only allowed to use
+// relay (i.e. IceTransportsType is relay), the raddr is an empty
+// address with the correct family. This is to prevent any local
+// reflective address leakage in the sdp line.
 TEST_F(PortAllocatorTest, TestCandidateFilterWithRelayOnly) {
   AddInterface(kClientAddr);
+  // GTURN is not configured here.
+  ResetWithTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
   allocator().set_candidate_filter(cricket::CF_RELAY);
   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
   session_->StartGettingPorts();
   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
-  // Using GTURN, we will have 4 candidates.
-  EXPECT_EQ(4U, candidates_.size());
+  EXPECT_PRED5(CheckCandidate,
+               candidates_[0],
+               cricket::ICE_CANDIDATE_COMPONENT_RTP,
+               "relay",
+               "udp",
+               rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
+
+  EXPECT_EQ(1U, candidates_.size());
   EXPECT_EQ(1U, ports_.size());  // Only Relay port will be in ready state.
   for (size_t i = 0; i < candidates_.size(); ++i) {
     EXPECT_EQ(std::string(cricket::RELAY_PORT_TYPE), candidates_[i].type());
+    EXPECT_EQ(
+        candidates_[0].related_address(),
+        rtc::EmptySocketAddressWithFamily(candidates_[0].address().family()));
   }
 }
 
@@ -611,6 +636,9 @@
   EXPECT_EQ(1U, ports_.size());  // Only UDP port will be in ready state.
   for (size_t i = 0; i < candidates_.size(); ++i) {
     EXPECT_EQ(std::string(cricket::STUN_PORT_TYPE), candidates_[i].type());
+    EXPECT_EQ(
+        candidates_[0].related_address(),
+        rtc::EmptySocketAddressWithFamily(candidates_[0].address().family()));
   }
 }
 
diff --git a/p2p/client/sessionmanagertask.h b/p2p/client/sessionmanagertask.h
index e16d9d6..753d938 100644
--- a/p2p/client/sessionmanagertask.h
+++ b/p2p/client/sessionmanagertask.h
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_CLIENT_SESSIONMANAGERTASK_H_
-#define TALK_P2P_CLIENT_SESSIONMANAGERTASK_H_
+#ifndef WEBRTC_P2P_CLIENT_SESSIONMANAGERTASK_H_
+#define WEBRTC_P2P_CLIENT_SESSIONMANAGERTASK_H_
 
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/p2p/client/sessionsendtask.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/client/sessionsendtask.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace cricket {
 
@@ -90,4 +90,4 @@
 
 }  // namespace cricket
 
-#endif // TALK_P2P_CLIENT_SESSIONMANAGERTASK_H_
+#endif // WEBRTC_P2P_CLIENT_SESSIONMANAGERTASK_H_
diff --git a/p2p/client/sessionsendtask.h b/p2p/client/sessionsendtask.h
index c8734d2..7dafc1e 100644
--- a/p2p/client/sessionsendtask.h
+++ b/p2p/client/sessionsendtask.h
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_CLIENT_SESSIONSENDTASK_H_
-#define TALK_P2P_CLIENT_SESSIONSENDTASK_H_
+#ifndef WEBRTC_P2P_CLIENT_SESSIONSENDTASK_H_
+#define WEBRTC_P2P_CLIENT_SESSIONSENDTASK_H_
 
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/xmppclient.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/common.h"
 
 namespace cricket {
@@ -142,4 +142,4 @@
 
 }
 
-#endif // TALK_P2P_CLIENT_SESSIONSENDTASK_H_
+#endif // WEBRTC_P2P_CLIENT_SESSIONSENDTASK_H_
diff --git a/p2p/client/socketmonitor.cc b/p2p/client/socketmonitor.cc
index 1924c70..a3a33e3 100644
--- a/p2p/client/socketmonitor.cc
+++ b/p2p/client/socketmonitor.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/p2p/client/socketmonitor.h"
+#include "webrtc/p2p/client/socketmonitor.h"
 
 #include "webrtc/base/common.h"
 
diff --git a/p2p/client/socketmonitor.h b/p2p/client/socketmonitor.h
index 87b11cf..77241fe 100644
--- a/p2p/client/socketmonitor.h
+++ b/p2p/client/socketmonitor.h
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_P2P_CLIENT_SOCKETMONITOR_H_
-#define TALK_P2P_CLIENT_SOCKETMONITOR_H_
+#ifndef WEBRTC_P2P_CLIENT_SOCKETMONITOR_H_
+#define WEBRTC_P2P_CLIENT_SOCKETMONITOR_H_
 
 #include <vector>
 
-#include "talk/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/transportchannel.h"
 #include "webrtc/base/criticalsection.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/thread.h"
@@ -68,4 +68,4 @@
 
 }  // namespace cricket
 
-#endif  // TALK_P2P_CLIENT_SOCKETMONITOR_H_
+#endif  // WEBRTC_P2P_CLIENT_SOCKETMONITOR_H_
diff --git a/session/media/audiomonitor.h b/session/media/audiomonitor.h
index e5585a4..454f0fe 100644
--- a/session/media/audiomonitor.h
+++ b/session/media/audiomonitor.h
@@ -29,7 +29,7 @@
 #define TALK_SESSION_MEDIA_AUDIOMONITOR_H_
 
 #include <vector>
-#include "talk/p2p/base/port.h"
+#include "webrtc/p2p/base/port.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/thread.h"
 
diff --git a/session/media/call.cc b/session/media/call.cc
index ad28130..7e59ac6 100644
--- a/session/media/call.cc
+++ b/session/media/call.cc
@@ -28,7 +28,7 @@
 #include <string>
 #include "talk/media/base/constants.h"
 #include "talk/media/base/screencastid.h"
-#include "talk/p2p/base/parsing.h"
+#include "webrtc/p2p/base/parsing.h"
 #include "talk/session/media/call.h"
 #include "talk/session/media/currentspeakermonitor.h"
 #include "talk/session/media/mediasessionclient.h"
diff --git a/session/media/call.h b/session/media/call.h
index be9397e..5a2d49b 100644
--- a/session/media/call.h
+++ b/session/media/call.h
@@ -37,13 +37,13 @@
 #include "talk/media/base/screencastid.h"
 #include "talk/media/base/streamparams.h"
 #include "talk/media/base/videocommon.h"
-#include "talk/p2p/base/session.h"
-#include "talk/p2p/client/socketmonitor.h"
+#include "webrtc/p2p/base/session.h"
+#include "webrtc/p2p/client/socketmonitor.h"
 #include "talk/session/media/audiomonitor.h"
 #include "talk/session/media/currentspeakermonitor.h"
 #include "talk/session/media/mediamessages.h"
 #include "talk/session/media/mediasession.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 #include "webrtc/base/messagequeue.h"
 
 namespace cricket {
diff --git a/session/media/channel.cc b/session/media/channel.cc
index 3615da8..414a131 100644
--- a/session/media/channel.cc
+++ b/session/media/channel.cc
@@ -29,7 +29,7 @@
 
 #include "talk/media/base/constants.h"
 #include "talk/media/base/rtputils.h"
-#include "talk/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/transportchannel.h"
 #include "talk/session/media/channelmanager.h"
 #include "talk/session/media/mediamessages.h"
 #include "talk/session/media/typingmonitor.h"
diff --git a/session/media/channel.h b/session/media/channel.h
index 6da29a4..29980bb 100644
--- a/session/media/channel.h
+++ b/session/media/channel.h
@@ -35,8 +35,8 @@
 #include "talk/media/base/mediaengine.h"
 #include "talk/media/base/streamparams.h"
 #include "talk/media/base/videocapturer.h"
-#include "talk/p2p/base/session.h"
-#include "talk/p2p/client/socketmonitor.h"
+#include "webrtc/p2p/base/session.h"
+#include "webrtc/p2p/client/socketmonitor.h"
 #include "talk/session/media/audiomonitor.h"
 #include "talk/session/media/bundlefilter.h"
 #include "talk/session/media/mediamonitor.h"
diff --git a/session/media/channel_unittest.cc b/session/media/channel_unittest.cc
index 698a34a..0fba14e 100644
--- a/session/media/channel_unittest.cc
+++ b/session/media/channel_unittest.cc
@@ -31,7 +31,7 @@
 #include "talk/media/base/rtpdump.h"
 #include "talk/media/base/screencastid.h"
 #include "talk/media/base/testutils.h"
-#include "talk/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/fakesession.h"
 #include "talk/session/media/channel.h"
 #include "talk/session/media/mediamessages.h"
 #include "talk/session/media/mediarecorder.h"
diff --git a/session/media/channelmanager.h b/session/media/channelmanager.h
index 98a3c96..764451d 100644
--- a/session/media/channelmanager.h
+++ b/session/media/channelmanager.h
@@ -33,7 +33,7 @@
 
 #include "talk/media/base/capturemanager.h"
 #include "talk/media/base/mediaengine.h"
-#include "talk/p2p/base/session.h"
+#include "webrtc/p2p/base/session.h"
 #include "talk/session/media/voicechannel.h"
 #include "webrtc/base/criticalsection.h"
 #include "webrtc/base/fileutils.h"
diff --git a/session/media/channelmanager_unittest.cc b/session/media/channelmanager_unittest.cc
index 1363364..4c6f4ab 100644
--- a/session/media/channelmanager_unittest.cc
+++ b/session/media/channelmanager_unittest.cc
@@ -29,7 +29,7 @@
 #include "talk/media/base/nullvideorenderer.h"
 #include "talk/media/base/testutils.h"
 #include "talk/media/devices/fakedevicemanager.h"
-#include "talk/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/fakesession.h"
 #include "talk/session/media/channelmanager.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
diff --git a/session/media/mediamessages.cc b/session/media/mediamessages.cc
index 6c9f681..011fd7d 100644
--- a/session/media/mediamessages.cc
+++ b/session/media/mediamessages.cc
@@ -31,8 +31,8 @@
 
 #include "talk/session/media/mediamessages.h"
 
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/parsing.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/parsing.h"
 #include "talk/session/media/mediasessionclient.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
 #include "webrtc/base/logging.h"
diff --git a/session/media/mediamessages.h b/session/media/mediamessages.h
index 4a56e4b..d918e3e 100644
--- a/session/media/mediamessages.h
+++ b/session/media/mediamessages.h
@@ -41,8 +41,8 @@
 
 #include "talk/media/base/mediachannel.h"  // For RtpHeaderExtension
 #include "talk/media/base/streamparams.h"
-#include "talk/p2p/base/parsing.h"
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/parsing.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 #include "webrtc/base/basictypes.h"
 
 namespace cricket {
diff --git a/session/media/mediamessages_unittest.cc b/session/media/mediamessages_unittest.cc
index 9ebd38c..a9f00e4 100644
--- a/session/media/mediamessages_unittest.cc
+++ b/session/media/mediamessages_unittest.cc
@@ -30,7 +30,7 @@
 #include <string>
 #include <vector>
 
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 #include "talk/session/media/mediasessionclient.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
 #include "webrtc/base/gunit.h"
diff --git a/session/media/mediarecorder_unittest.cc b/session/media/mediarecorder_unittest.cc
index 9feb22a..b71a984 100644
--- a/session/media/mediarecorder_unittest.cc
+++ b/session/media/mediarecorder_unittest.cc
@@ -28,7 +28,7 @@
 #include "talk/media/base/fakemediaengine.h"
 #include "talk/media/base/rtpdump.h"
 #include "talk/media/base/testutils.h"
-#include "talk/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/fakesession.h"
 #include "talk/session/media/channel.h"
 #include "talk/session/media/mediarecorder.h"
 #include "webrtc/base/bytebuffer.h"
diff --git a/session/media/mediasession.cc b/session/media/mediasession.cc
index 54eeffa..96e45a6 100644
--- a/session/media/mediasession.cc
+++ b/session/media/mediasession.cc
@@ -34,10 +34,10 @@
 
 #include "talk/media/base/constants.h"
 #include "talk/media/base/cryptoparams.h"
-#include "talk/p2p/base/constants.h"
+#include "webrtc/p2p/base/constants.h"
 #include "talk/session/media/channelmanager.h"
 #include "talk/session/media/srtpfilter.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/scoped_ptr.h"
@@ -1191,8 +1191,14 @@
         }
         video_added = true;
       } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)) {
-        if (!AddDataContentForOffer(options, current_description, &data_codecs,
-                                    &current_streams, offer.get())) {
+        MediaSessionOptions options_copy(options);
+        if (IsSctp(static_cast<const MediaContentDescription*>(
+                it->description))) {
+          options_copy.data_channel_type = DCT_SCTP;
+        }
+        if (!AddDataContentForOffer(options_copy, current_description,
+                                    &data_codecs, &current_streams,
+                                    offer.get())) {
           return NULL;
         }
         data_added = true;
diff --git a/session/media/mediasession.h b/session/media/mediasession.h
index 992439c..462ddd2 100644
--- a/session/media/mediasession.h
+++ b/session/media/mediasession.h
@@ -40,9 +40,9 @@
 #include "talk/media/base/mediachannel.h"
 #include "talk/media/base/mediaengine.h"  // For DataChannelType
 #include "talk/media/base/streamparams.h"
-#include "talk/p2p/base/sessiondescription.h"
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/base/transportdescriptionfactory.h"
+#include "webrtc/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/base/transportdescriptionfactory.h"
 #include "webrtc/base/scoped_ptr.h"
 
 namespace cricket {
diff --git a/session/media/mediasession_unittest.cc b/session/media/mediasession_unittest.cc
index ef155f0..9ee6065 100644
--- a/session/media/mediasession_unittest.cc
+++ b/session/media/mediasession_unittest.cc
@@ -30,9 +30,9 @@
 
 #include "talk/media/base/codec.h"
 #include "talk/media/base/testutils.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/transportdescription.h"
-#include "talk/p2p/base/transportinfo.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/transportdescription.h"
+#include "webrtc/p2p/base/transportinfo.h"
 #include "talk/session/media/mediasession.h"
 #include "talk/session/media/srtpfilter.h"
 #include "webrtc/base/fakesslidentity.h"
@@ -628,6 +628,33 @@
   EXPECT_TRUE(offer->GetContentByName("data") != NULL);
 }
 
+// Test creating an sctp data channel from an already generated offer.
+TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) {
+  MediaSessionOptions opts;
+  opts.recv_audio = false;
+  opts.bundle_enabled = true;
+  opts.data_channel_type = cricket::DCT_SCTP;
+  f1_.set_secure(SEC_ENABLED);
+  rtc::scoped_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL));
+  ASSERT_TRUE(offer1.get() != NULL);
+  const ContentInfo* data = offer1->GetContentByName("data");
+  ASSERT_TRUE(data != NULL);
+  const MediaContentDescription* mdesc =
+      static_cast<const MediaContentDescription*>(data->description);
+  ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol());
+
+  // Now set data_channel_type to 'none' (default) and make sure that the
+  // datachannel type that gets generated from the previous offer, is of the
+  // same type.
+  opts.data_channel_type = cricket::DCT_NONE;
+  rtc::scoped_ptr<SessionDescription> offer2(
+      f1_.CreateOffer(opts, offer1.get()));
+  data = offer2->GetContentByName("data");
+  ASSERT_TRUE(data != NULL);
+  mdesc = static_cast<const MediaContentDescription*>(data->description);
+  EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol());
+}
+
 // Create an audio, video offer without legacy StreamParams.
 TEST_F(MediaSessionDescriptionFactoryTest,
        TestCreateOfferWithoutLegacyStreams) {
diff --git a/session/media/mediasessionclient.cc b/session/media/mediasessionclient.cc
index 826909a..5cb7917 100644
--- a/session/media/mediasessionclient.cc
+++ b/session/media/mediasessionclient.cc
@@ -32,13 +32,13 @@
 #include "talk/media/base/capturemanager.h"
 #include "talk/media/base/cryptoparams.h"
 #include "talk/media/sctp/sctpdataengine.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/parsing.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/parsing.h"
 #include "talk/session/media/mediamessages.h"
 #include "talk/session/media/srtpfilter.h"
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlconstants.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/helpers.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/stringencode.h"
diff --git a/session/media/mediasessionclient.h b/session/media/mediasessionclient.h
index 61d1f1d..c66c221 100644
--- a/session/media/mediasessionclient.h
+++ b/session/media/mediasessionclient.h
@@ -33,10 +33,10 @@
 #include <string>
 #include <vector>
 #include "talk/media/base/cryptoparams.h"
-#include "talk/p2p/base/session.h"
-#include "talk/p2p/base/sessionclient.h"
-#include "talk/p2p/base/sessiondescription.h"
-#include "talk/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/session.h"
+#include "webrtc/p2p/base/sessionclient.h"
+#include "webrtc/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/sessionmanager.h"
 #include "talk/session/media/call.h"
 #include "talk/session/media/channelmanager.h"
 #include "talk/session/media/mediasession.h"
diff --git a/session/media/mediasessionclient_unittest.cc b/session/media/mediasessionclient_unittest.cc
index bb3043d..3e8a90f 100644
--- a/session/media/mediasessionclient_unittest.cc
+++ b/session/media/mediasessionclient_unittest.cc
@@ -31,13 +31,13 @@
 #include "talk/media/base/fakemediaengine.h"
 #include "talk/media/base/testutils.h"
 #include "talk/media/devices/fakedevicemanager.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/client/basicportallocator.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/client/basicportallocator.h"
 #include "talk/session/media/mediasessionclient.h"
 #include "webrtc/libjingle/xmllite/xmlbuilder.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
 #include "webrtc/libjingle/xmllite/xmlprinter.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/scoped_ptr.h"
diff --git a/session/media/rtcpmuxfilter.h b/session/media/rtcpmuxfilter.h
index 40951a2..948b3c3 100644
--- a/session/media/rtcpmuxfilter.h
+++ b/session/media/rtcpmuxfilter.h
@@ -28,7 +28,7 @@
 #ifndef TALK_SESSION_MEDIA_RTCPMUXFILTER_H_
 #define TALK_SESSION_MEDIA_RTCPMUXFILTER_H_
 
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 #include "webrtc/base/basictypes.h"
 
 namespace cricket {
diff --git a/session/media/srtpfilter.cc b/session/media/srtpfilter.cc
index c79bf13..5a774db 100644
--- a/session/media/srtpfilter.cc
+++ b/session/media/srtpfilter.cc
@@ -150,7 +150,7 @@
                               const uint8* send_key, int send_key_len,
                               const std::string& recv_cs,
                               const uint8* recv_key, int recv_key_len) {
-  if (state_ == ST_ACTIVE) {
+  if (IsActive()) {
     LOG(LS_ERROR) << "Tried to set SRTP Params when filter already active";
     return false;
   }
@@ -212,6 +212,7 @@
     LOG(LS_WARNING) << "Failed to ProtectRtp: SRTP not active";
     return false;
   }
+  ASSERT(send_session_ != NULL);
   return send_session_->ProtectRtp(p, in_len, max_len, out_len);
 }
 
@@ -221,7 +222,7 @@
     LOG(LS_WARNING) << "Failed to ProtectRtp: SRTP not active";
     return false;
   }
-
+  ASSERT(send_session_ != NULL);
   return send_session_->ProtectRtp(p, in_len, max_len, out_len, index);
 }
 
@@ -233,6 +234,7 @@
   if (send_rtcp_session_) {
     return send_rtcp_session_->ProtectRtcp(p, in_len, max_len, out_len);
   } else {
+    ASSERT(send_session_ != NULL);
     return send_session_->ProtectRtcp(p, in_len, max_len, out_len);
   }
 }
@@ -242,6 +244,7 @@
     LOG(LS_WARNING) << "Failed to UnprotectRtp: SRTP not active";
     return false;
   }
+  ASSERT(recv_session_ != NULL);
   return recv_session_->UnprotectRtp(p, in_len, out_len);
 }
 
@@ -253,6 +256,7 @@
   if (recv_rtcp_session_) {
     return recv_rtcp_session_->UnprotectRtcp(p, in_len, out_len);
   } else {
+    ASSERT(recv_session_ != NULL);
     return recv_session_->UnprotectRtcp(p, in_len, out_len);
   }
 }
@@ -263,13 +267,16 @@
     return false;
   }
 
+  ASSERT(send_session_ != NULL);
   return send_session_->GetRtpAuthParams(key, key_len, tag_len);
 }
 
 void SrtpFilter::set_signal_silent_time(uint32 signal_silent_time_in_ms) {
   signal_silent_time_in_ms_ = signal_silent_time_in_ms;
-  if (state_ == ST_ACTIVE) {
+  if (IsActive()) {
+    ASSERT(send_session_ != NULL);
     send_session_->set_signal_silent_time(signal_silent_time_in_ms);
+    ASSERT(recv_session_ != NULL);
     recv_session_->set_signal_silent_time(signal_silent_time_in_ms);
     if (send_rtcp_session_)
       send_rtcp_session_->set_signal_silent_time(signal_silent_time_in_ms);
@@ -292,7 +299,7 @@
   offer_params_ = params;
   if (state_ == ST_INIT) {
     state_ = (source == CS_LOCAL) ? ST_SENTOFFER : ST_RECEIVEDOFFER;
-  } else {  // state >= ST_ACTIVE
+  } else if (state_ == ST_ACTIVE) {
     state_ =
         (source == CS_LOCAL) ? ST_SENTUPDATEDOFFER : ST_RECEIVEDUPDATEDOFFER;
   }
diff --git a/session/media/srtpfilter.h b/session/media/srtpfilter.h
index ce3368f..3134418 100644
--- a/session/media/srtpfilter.h
+++ b/session/media/srtpfilter.h
@@ -34,7 +34,7 @@
 #include <vector>
 
 #include "talk/media/base/cryptoparams.h"
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sigslotrepeater.h"
diff --git a/session/media/srtpfilter_unittest.cc b/session/media/srtpfilter_unittest.cc
index 19efa2a..51d701d 100644
--- a/session/media/srtpfilter_unittest.cc
+++ b/session/media/srtpfilter_unittest.cc
@@ -27,7 +27,7 @@
 
 #include "talk/media/base/cryptoparams.h"
 #include "talk/media/base/fakertp.h"
-#include "talk/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/sessiondescription.h"
 #include "talk/session/media/srtpfilter.h"
 #include "webrtc/base/byteorder.h"
 #include "webrtc/base/gunit.h"
@@ -82,9 +82,12 @@
                      const std::vector<CryptoParams>& params2) {
     EXPECT_TRUE(f1_.SetOffer(params1, CS_LOCAL));
     EXPECT_TRUE(f2_.SetOffer(params1, CS_REMOTE));
+    EXPECT_FALSE(f1_.IsActive());
+    EXPECT_FALSE(f2_.IsActive());
     EXPECT_TRUE(f2_.SetAnswer(params2, CS_LOCAL));
     EXPECT_TRUE(f1_.SetAnswer(params2, CS_REMOTE));
     EXPECT_TRUE(f1_.IsActive());
+    EXPECT_TRUE(f2_.IsActive());
   }
   void TestProtectUnprotect(const std::string& cs1, const std::string& cs2) {
     char rtp_packet[sizeof(kPcmuFrame) + 10];
@@ -139,6 +142,7 @@
 // Test that we can set up the session and keys properly.
 TEST_F(SrtpFilterTest, TestGoodSetupOneCipherSuite) {
   EXPECT_TRUE(f1_.SetOffer(MakeVector(kTestCryptoParams1), CS_LOCAL));
+  EXPECT_FALSE(f1_.IsActive());
   EXPECT_TRUE(f1_.SetAnswer(MakeVector(kTestCryptoParams2), CS_REMOTE));
   EXPECT_TRUE(f1_.IsActive());
 }
@@ -153,6 +157,7 @@
   answer[0].tag = 2;
   answer[0].cipher_suite = CS_AES_CM_128_HMAC_SHA1_32;
   EXPECT_TRUE(f1_.SetOffer(offer, CS_LOCAL));
+  EXPECT_FALSE(f1_.IsActive());
   EXPECT_TRUE(f1_.SetAnswer(answer, CS_REMOTE));
   EXPECT_TRUE(f1_.IsActive());
 }
@@ -188,6 +193,7 @@
 TEST_F(SrtpFilterTest, TestGoodSetupMultipleOffers) {
   EXPECT_TRUE(f1_.SetOffer(MakeVector(kTestCryptoParams1), CS_LOCAL));
   EXPECT_TRUE(f1_.SetOffer(MakeVector(kTestCryptoParams2), CS_LOCAL));
+  EXPECT_FALSE(f1_.IsActive());
   EXPECT_TRUE(f1_.SetAnswer(MakeVector(kTestCryptoParams2), CS_REMOTE));
   EXPECT_TRUE(f1_.IsActive());
   EXPECT_TRUE(f1_.SetOffer(MakeVector(kTestCryptoParams1), CS_LOCAL));
@@ -196,6 +202,7 @@
 
   EXPECT_TRUE(f2_.SetOffer(MakeVector(kTestCryptoParams1), CS_REMOTE));
   EXPECT_TRUE(f2_.SetOffer(MakeVector(kTestCryptoParams2), CS_REMOTE));
+  EXPECT_FALSE(f2_.IsActive());
   EXPECT_TRUE(f2_.SetAnswer(MakeVector(kTestCryptoParams2), CS_LOCAL));
   EXPECT_TRUE(f2_.IsActive());
   EXPECT_TRUE(f2_.SetOffer(MakeVector(kTestCryptoParams1), CS_REMOTE));
@@ -206,6 +213,7 @@
 TEST_F(SrtpFilterTest, TestBadSetupMultipleOffers) {
   EXPECT_TRUE(f1_.SetOffer(MakeVector(kTestCryptoParams1), CS_LOCAL));
   EXPECT_FALSE(f1_.SetOffer(MakeVector(kTestCryptoParams2), CS_REMOTE));
+  EXPECT_FALSE(f1_.IsActive());
   EXPECT_TRUE(f1_.SetAnswer(MakeVector(kTestCryptoParams1), CS_REMOTE));
   EXPECT_TRUE(f1_.IsActive());
   EXPECT_TRUE(f1_.SetOffer(MakeVector(kTestCryptoParams2), CS_LOCAL));
@@ -214,6 +222,7 @@
 
   EXPECT_TRUE(f2_.SetOffer(MakeVector(kTestCryptoParams2), CS_REMOTE));
   EXPECT_FALSE(f2_.SetOffer(MakeVector(kTestCryptoParams1), CS_LOCAL));
+  EXPECT_FALSE(f2_.IsActive());
   EXPECT_TRUE(f2_.SetAnswer(MakeVector(kTestCryptoParams2), CS_LOCAL));
   EXPECT_TRUE(f2_.IsActive());
   EXPECT_TRUE(f2_.SetOffer(MakeVector(kTestCryptoParams2), CS_REMOTE));
@@ -402,6 +411,8 @@
 
   EXPECT_TRUE(f1_.SetOffer(offer, CS_LOCAL));
   EXPECT_TRUE(f2_.SetOffer(offer, CS_REMOTE));
+  EXPECT_FALSE(f1_.IsActive());
+  EXPECT_FALSE(f2_.IsActive());
   EXPECT_TRUE(f2_.SetProvisionalAnswer(answer, CS_LOCAL));
   EXPECT_TRUE(f1_.SetProvisionalAnswer(answer, CS_REMOTE));
   EXPECT_TRUE(f1_.IsActive());
@@ -425,6 +436,8 @@
 
   EXPECT_TRUE(f1_.SetOffer(offer, CS_LOCAL));
   EXPECT_TRUE(f2_.SetOffer(offer, CS_REMOTE));
+  EXPECT_FALSE(f1_.IsActive());
+  EXPECT_FALSE(f2_.IsActive());
   EXPECT_TRUE(f2_.SetProvisionalAnswer(answer, CS_LOCAL));
   EXPECT_TRUE(f1_.SetProvisionalAnswer(answer, CS_REMOTE));
   EXPECT_FALSE(f1_.IsActive());
@@ -438,6 +451,33 @@
   TestProtectUnprotect(CS_AES_CM_128_HMAC_SHA1_80, CS_AES_CM_128_HMAC_SHA1_80);
 }
 
+// Test that if we get a new local offer after a provisional answer
+// with no crypto, that we are in an inactive state.
+TEST_F(SrtpFilterTest, TestLocalOfferAfterProvisionalAnswerWithoutCrypto) {
+  std::vector<CryptoParams> offer(MakeVector(kTestCryptoParams1));
+  std::vector<CryptoParams> answer;
+
+  EXPECT_TRUE(f1_.SetOffer(offer, CS_LOCAL));
+  EXPECT_TRUE(f2_.SetOffer(offer, CS_REMOTE));
+  EXPECT_TRUE(f1_.SetProvisionalAnswer(answer, CS_REMOTE));
+  EXPECT_TRUE(f2_.SetProvisionalAnswer(answer, CS_LOCAL));
+  EXPECT_FALSE(f1_.IsActive());
+  EXPECT_FALSE(f2_.IsActive());
+  // The calls to set an offer after a provisional answer fail, so the
+  // state doesn't change.
+  EXPECT_FALSE(f1_.SetOffer(offer, CS_LOCAL));
+  EXPECT_FALSE(f2_.SetOffer(offer, CS_REMOTE));
+  EXPECT_FALSE(f1_.IsActive());
+  EXPECT_FALSE(f2_.IsActive());
+
+  answer.push_back(kTestCryptoParams2);
+  EXPECT_TRUE(f2_.SetAnswer(answer, CS_LOCAL));
+  EXPECT_TRUE(f1_.SetAnswer(answer, CS_REMOTE));
+  EXPECT_TRUE(f1_.IsActive());
+  EXPECT_TRUE(f2_.IsActive());
+  TestProtectUnprotect(CS_AES_CM_128_HMAC_SHA1_80, CS_AES_CM_128_HMAC_SHA1_80);
+}
+
 // Test that we can disable encryption.
 TEST_F(SrtpFilterTest, TestDisableEncryption) {
   std::vector<CryptoParams> offer(MakeVector(kTestCryptoParams1));
diff --git a/session/media/typingmonitor_unittest.cc b/session/media/typingmonitor_unittest.cc
index 95fa7a4..66e2401 100644
--- a/session/media/typingmonitor_unittest.cc
+++ b/session/media/typingmonitor_unittest.cc
@@ -26,7 +26,7 @@
  */
 
 #include "talk/media/base/fakemediaengine.h"
-#include "talk/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/fakesession.h"
 #include "talk/session/media/channel.h"
 #include "talk/session/media/currentspeakermonitor.h"
 #include "talk/session/media/typingmonitor.h"
diff --git a/session/tunnel/pseudotcpchannel.cc b/session/tunnel/pseudotcpchannel.cc
index f277614..861e178 100644
--- a/session/tunnel/pseudotcpchannel.cc
+++ b/session/tunnel/pseudotcpchannel.cc
@@ -27,8 +27,8 @@
 
 #include <string>
 #include "pseudotcpchannel.h"
-#include "talk/p2p/base/candidate.h"
-#include "talk/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/candidate.h"
+#include "webrtc/p2p/base/transportchannel.h"
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
diff --git a/session/tunnel/pseudotcpchannel.h b/session/tunnel/pseudotcpchannel.h
index 5ccfa4c..ad6d907 100644
--- a/session/tunnel/pseudotcpchannel.h
+++ b/session/tunnel/pseudotcpchannel.h
@@ -28,8 +28,8 @@
 #ifndef TALK_SESSION_TUNNEL_PSEUDOTCPCHANNEL_H_
 #define TALK_SESSION_TUNNEL_PSEUDOTCPCHANNEL_H_
 
-#include "talk/p2p/base/pseudotcp.h"
-#include "talk/p2p/base/session.h"
+#include "webrtc/p2p/base/pseudotcp.h"
+#include "webrtc/p2p/base/session.h"
 #include "webrtc/base/criticalsection.h"
 #include "webrtc/base/messagequeue.h"
 #include "webrtc/base/stream.h"
diff --git a/session/tunnel/securetunnelsessionclient.cc b/session/tunnel/securetunnelsessionclient.cc
index cb41c3b..4ed8185 100644
--- a/session/tunnel/securetunnelsessionclient.cc
+++ b/session/tunnel/securetunnelsessionclient.cc
@@ -27,7 +27,7 @@
 
 // SecureTunnelSessionClient and SecureTunnelSession implementation.
 
-#include "talk/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/transportchannel.h"
 #include "talk/session/tunnel/pseudotcpchannel.h"
 #include "talk/session/tunnel/securetunnelsessionclient.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
diff --git a/session/tunnel/tunnelsessionclient.cc b/session/tunnel/tunnelsessionclient.cc
index 7221db4..7d2a7d1 100644
--- a/session/tunnel/tunnelsessionclient.cc
+++ b/session/tunnel/tunnelsessionclient.cc
@@ -26,8 +26,8 @@
  */
 
 #include "pseudotcpchannel.h"
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/transportchannel.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/transportchannel.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
 #include "tunnelsessionclient.h"
 #include "webrtc/base/basicdefs.h"
diff --git a/session/tunnel/tunnelsessionclient.h b/session/tunnel/tunnelsessionclient.h
index d3fa64a..87beaed 100644
--- a/session/tunnel/tunnelsessionclient.h
+++ b/session/tunnel/tunnelsessionclient.h
@@ -30,14 +30,14 @@
 
 #include <vector>
 
-#include "talk/p2p/base/constants.h"
-#include "talk/p2p/base/pseudotcp.h"
-#include "talk/p2p/base/session.h"
-#include "talk/p2p/base/sessionclient.h"
-#include "talk/p2p/base/sessiondescription.h"
-#include "talk/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/constants.h"
+#include "webrtc/p2p/base/pseudotcp.h"
+#include "webrtc/p2p/base/session.h"
+#include "webrtc/p2p/base/sessionclient.h"
+#include "webrtc/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/base/sessionmanager.h"
 #include "webrtc/libjingle/xmllite/qname.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/criticalsection.h"
 #include "webrtc/base/stream.h"
 
diff --git a/session/tunnel/tunnelsessionclient_unittest.cc b/session/tunnel/tunnelsessionclient_unittest.cc
index 6d46918..6bd746a 100644
--- a/session/tunnel/tunnelsessionclient_unittest.cc
+++ b/session/tunnel/tunnelsessionclient_unittest.cc
@@ -26,9 +26,9 @@
  */
 
 #include <string>
-#include "talk/p2p/base/sessionmanager.h"
-#include "talk/p2p/base/transport.h"
-#include "talk/p2p/client/fakeportallocator.h"
+#include "webrtc/p2p/base/sessionmanager.h"
+#include "webrtc/p2p/base/transport.h"
+#include "webrtc/p2p/client/fakeportallocator.h"
 #include "talk/session/tunnel/tunnelsessionclient.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/messagehandler.h"
diff --git a/xmpp/chatroommodule.h b/xmpp/chatroommodule.h
index 8358fc1..145ab89 100644
--- a/xmpp/chatroommodule.h
+++ b/xmpp/chatroommodule.h
@@ -28,8 +28,8 @@
 #ifndef TALK_XMPP_CHATROOMMODULE_H_
 #define TALK_XMPP_CHATROOMMODULE_H_
 
-#include "talk/xmpp/module.h"
-#include "talk/xmpp/rostermodule.h"
+#include "webrtc/libjingle/xmpp/module.h"
+#include "webrtc/libjingle/xmpp/rostermodule.h"
 
 namespace buzz {
 
diff --git a/xmpp/chatroommoduleimpl.cc b/xmpp/chatroommoduleimpl.cc
index 45db014..33c752e 100644
--- a/xmpp/chatroommoduleimpl.cc
+++ b/xmpp/chatroommoduleimpl.cc
@@ -31,9 +31,9 @@
 #include <sstream>
 #include <string>
 #include <vector>
-#include "talk/xmpp/chatroommodule.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/moduleimpl.h"
+#include "webrtc/libjingle/xmpp/chatroommodule.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/moduleimpl.h"
 #include "webrtc/base/common.h"
 
 namespace buzz {
diff --git a/xmpp/constants.cc b/xmpp/constants.cc
index 297eafd..fce9c75 100644
--- a/xmpp/constants.cc
+++ b/xmpp/constants.cc
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 
 #include <string>
 
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlconstants.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 #include "webrtc/base/basicdefs.h"
 
 namespace buzz {
diff --git a/xmpp/constants.h b/xmpp/constants.h
index 6aa1a54..52088ca 100644
--- a/xmpp/constants.h
+++ b/xmpp/constants.h
@@ -30,7 +30,7 @@
 
 #include <string>
 #include "webrtc/libjingle/xmllite/qname.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 
 namespace buzz {
 
diff --git a/xmpp/discoitemsquerytask.cc b/xmpp/discoitemsquerytask.cc
index d900b85..b739ba3 100644
--- a/xmpp/discoitemsquerytask.cc
+++ b/xmpp/discoitemsquerytask.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/discoitemsquerytask.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/discoitemsquerytask.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/scoped_ptr.h"
 
 namespace buzz {
diff --git a/xmpp/discoitemsquerytask.h b/xmpp/discoitemsquerytask.h
index 409fc90..c31d261 100644
--- a/xmpp/discoitemsquerytask.h
+++ b/xmpp/discoitemsquerytask.h
@@ -54,7 +54,7 @@
 #include <string>
 #include <vector>
 
-#include "talk/xmpp/iqtask.h"
+#include "webrtc/libjingle/xmpp/iqtask.h"
 
 namespace buzz {
 
diff --git a/xmpp/fakexmppclient.h b/xmpp/fakexmppclient.h
index 3522ba9..2e37dd1 100644
--- a/xmpp/fakexmppclient.h
+++ b/xmpp/fakexmppclient.h
@@ -33,7 +33,7 @@
 #include <string>
 #include <vector>
 
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/xmpp/hangoutpubsubclient.cc b/xmpp/hangoutpubsubclient.cc
index 63f5bcf..dacccf1 100644
--- a/xmpp/hangoutpubsubclient.cc
+++ b/xmpp/hangoutpubsubclient.cc
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/hangoutpubsubclient.h"
+#include "webrtc/libjingle/xmpp/hangoutpubsubclient.h"
 
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 #include "webrtc/base/logging.h"
 
 
diff --git a/xmpp/hangoutpubsubclient.h b/xmpp/hangoutpubsubclient.h
index 5692fc6..03c96f2 100644
--- a/xmpp/hangoutpubsubclient.h
+++ b/xmpp/hangoutpubsubclient.h
@@ -32,9 +32,9 @@
 #include <string>
 #include <vector>
 
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/pubsubclient.h"
-#include "talk/xmpp/pubsubstateclient.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/pubsubclient.h"
+#include "webrtc/libjingle/xmpp/pubsubstateclient.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/sigslotrepeater.h"
diff --git a/xmpp/hangoutpubsubclient_unittest.cc b/xmpp/hangoutpubsubclient_unittest.cc
index 555ee5c..574e21a 100644
--- a/xmpp/hangoutpubsubclient_unittest.cc
+++ b/xmpp/hangoutpubsubclient_unittest.cc
@@ -5,10 +5,10 @@
 
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/fakexmppclient.h"
-#include "talk/xmpp/hangoutpubsubclient.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/fakexmppclient.h"
+#include "webrtc/libjingle/xmpp/hangoutpubsubclient.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 #include "webrtc/base/faketaskrunner.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/iqtask.cc b/xmpp/iqtask.cc
index f6a21d4..d4cf310 100644
--- a/xmpp/iqtask.cc
+++ b/xmpp/iqtask.cc
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/iqtask.h"
+#include "webrtc/libjingle/xmpp/iqtask.h"
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
 
 namespace buzz {
 
diff --git a/xmpp/iqtask.h b/xmpp/iqtask.h
index 312c4af..8b0c04b 100644
--- a/xmpp/iqtask.h
+++ b/xmpp/iqtask.h
@@ -30,8 +30,8 @@
 
 #include <string>
 
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/xmpp/jid.cc b/xmpp/jid.cc
index 702e477..0410458 100644
--- a/xmpp/jid.cc
+++ b/xmpp/jid.cc
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 
 #include <ctype.h>
 
 #include <algorithm>
 #include <string>
 
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
 
diff --git a/xmpp/jid_unittest.cc b/xmpp/jid_unittest.cc
index 05835cf..9cae2f8 100644
--- a/xmpp/jid_unittest.cc
+++ b/xmpp/jid_unittest.cc
@@ -1,7 +1,7 @@
 // Copyright 2004 Google Inc. All Rights Reserved
 
 
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 #include "webrtc/base/gunit.h"
 
 using buzz::Jid;
diff --git a/xmpp/jingleinfotask.cc b/xmpp/jingleinfotask.cc
index 3ceae07..3b8fdde 100644
--- a/xmpp/jingleinfotask.cc
+++ b/xmpp/jingleinfotask.cc
@@ -25,11 +25,11 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/jingleinfotask.h"
+#include "webrtc/libjingle/xmpp/jingleinfotask.h"
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/xmppclient.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/socketaddress.h"
 
 namespace buzz {
diff --git a/xmpp/jingleinfotask.h b/xmpp/jingleinfotask.h
index 18cb5a9..ac03ecf 100644
--- a/xmpp/jingleinfotask.h
+++ b/xmpp/jingleinfotask.h
@@ -30,9 +30,9 @@
 
 #include <vector>
 
-#include "talk/p2p/client/httpportallocator.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/p2p/client/httpportallocator.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/sigslot.h"
 
 namespace buzz {
diff --git a/xmpp/module.h b/xmpp/module.h
index a5d0687..f1cff11 100644
--- a/xmpp/module.h
+++ b/xmpp/module.h
@@ -28,7 +28,7 @@
 #ifndef TALK_XMPP_MODULE_H_
 #define TALK_XMPP_MODULE_H_
 
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 
 namespace buzz {
 
diff --git a/xmpp/moduleimpl.cc b/xmpp/moduleimpl.cc
index 4635bee..8ac755d 100644
--- a/xmpp/moduleimpl.cc
+++ b/xmpp/moduleimpl.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/moduleimpl.h"
+#include "webrtc/libjingle/xmpp/moduleimpl.h"
 #include "webrtc/base/common.h"
 
 namespace buzz {
diff --git a/xmpp/moduleimpl.h b/xmpp/moduleimpl.h
index 897bfce..f1986f3 100644
--- a/xmpp/moduleimpl.h
+++ b/xmpp/moduleimpl.h
@@ -28,8 +28,8 @@
 #ifndef TALK_XMPP_MODULEIMPL_H_
 #define TALK_XMPP_MODULEIMPL_H_
 
-#include "talk/xmpp/module.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/module.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 
 namespace buzz {
 
diff --git a/xmpp/mucroomconfigtask.cc b/xmpp/mucroomconfigtask.cc
index 536eb9b..86ba5f6 100644
--- a/xmpp/mucroomconfigtask.cc
+++ b/xmpp/mucroomconfigtask.cc
@@ -28,9 +28,9 @@
 #include <string>
 #include <vector>
 
-#include "talk/xmpp/mucroomconfigtask.h"
+#include "webrtc/libjingle/xmpp/mucroomconfigtask.h"
 
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/scoped_ptr.h"
 
 namespace buzz {
diff --git a/xmpp/mucroomconfigtask.h b/xmpp/mucroomconfigtask.h
index ba0dbaa..5626d3e 100644
--- a/xmpp/mucroomconfigtask.h
+++ b/xmpp/mucroomconfigtask.h
@@ -29,7 +29,7 @@
 #define TALK_XMPP_MUCROOMCONFIGTASK_H_
 
 #include <string>
-#include "talk/xmpp/iqtask.h"
+#include "webrtc/libjingle/xmpp/iqtask.h"
 
 namespace buzz {
 
diff --git a/xmpp/mucroomconfigtask_unittest.cc b/xmpp/mucroomconfigtask_unittest.cc
index bf5e7b4..e9e1281 100644
--- a/xmpp/mucroomconfigtask_unittest.cc
+++ b/xmpp/mucroomconfigtask_unittest.cc
@@ -29,9 +29,9 @@
 #include <vector>
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/fakexmppclient.h"
-#include "talk/xmpp/mucroomconfigtask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/fakexmppclient.h"
+#include "webrtc/libjingle/xmpp/mucroomconfigtask.h"
 #include "webrtc/base/faketaskrunner.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/mucroomdiscoverytask.cc b/xmpp/mucroomdiscoverytask.cc
index c7477ae..0ec4fbe 100644
--- a/xmpp/mucroomdiscoverytask.cc
+++ b/xmpp/mucroomdiscoverytask.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/mucroomdiscoverytask.h"
+#include "webrtc/libjingle/xmpp/mucroomdiscoverytask.h"
 
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 
 namespace buzz {
 
diff --git a/xmpp/mucroomdiscoverytask.h b/xmpp/mucroomdiscoverytask.h
index 4097cc6..dc5918d 100644
--- a/xmpp/mucroomdiscoverytask.h
+++ b/xmpp/mucroomdiscoverytask.h
@@ -30,7 +30,7 @@
 
 #include <map>
 #include <string>
-#include "talk/xmpp/iqtask.h"
+#include "webrtc/libjingle/xmpp/iqtask.h"
 
 namespace buzz {
 
diff --git a/xmpp/mucroomdiscoverytask_unittest.cc b/xmpp/mucroomdiscoverytask_unittest.cc
index e1a633e..77fdf86 100644
--- a/xmpp/mucroomdiscoverytask_unittest.cc
+++ b/xmpp/mucroomdiscoverytask_unittest.cc
@@ -29,9 +29,9 @@
 #include <vector>
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/fakexmppclient.h"
-#include "talk/xmpp/mucroomdiscoverytask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/fakexmppclient.h"
+#include "webrtc/libjingle/xmpp/mucroomdiscoverytask.h"
 #include "webrtc/base/faketaskrunner.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/mucroomlookuptask.cc b/xmpp/mucroomlookuptask.cc
index 8e1895c..6832ade 100644
--- a/xmpp/mucroomlookuptask.cc
+++ b/xmpp/mucroomlookuptask.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/mucroomlookuptask.h"
+#include "webrtc/libjingle/xmpp/mucroomlookuptask.h"
 
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/scoped_ptr.h"
 
diff --git a/xmpp/mucroomlookuptask.h b/xmpp/mucroomlookuptask.h
index 48f2484..9bcca2c 100644
--- a/xmpp/mucroomlookuptask.h
+++ b/xmpp/mucroomlookuptask.h
@@ -29,7 +29,7 @@
 #define TALK_XMPP_MUCROOMLOOKUPTASK_H_
 
 #include <string>
-#include "talk/xmpp/iqtask.h"
+#include "webrtc/libjingle/xmpp/iqtask.h"
 
 namespace buzz {
 
diff --git a/xmpp/mucroomlookuptask_unittest.cc b/xmpp/mucroomlookuptask_unittest.cc
index 03be292..961e664 100644
--- a/xmpp/mucroomlookuptask_unittest.cc
+++ b/xmpp/mucroomlookuptask_unittest.cc
@@ -29,9 +29,9 @@
 #include <vector>
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/fakexmppclient.h"
-#include "talk/xmpp/mucroomlookuptask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/fakexmppclient.h"
+#include "webrtc/libjingle/xmpp/mucroomlookuptask.h"
 #include "webrtc/base/faketaskrunner.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/mucroomuniquehangoutidtask.cc b/xmpp/mucroomuniquehangoutidtask.cc
index 78a8edf..db94741 100644
--- a/xmpp/mucroomuniquehangoutidtask.cc
+++ b/xmpp/mucroomuniquehangoutidtask.cc
@@ -1,9 +1,9 @@
 // Copyright 2012 Google Inc. All Rights Reserved.
 
 
-#include "talk/xmpp/mucroomuniquehangoutidtask.h"
+#include "webrtc/libjingle/xmpp/mucroomuniquehangoutidtask.h"
 
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 
 namespace buzz {
 
diff --git a/xmpp/mucroomuniquehangoutidtask.h b/xmpp/mucroomuniquehangoutidtask.h
index d222bac..83de434 100644
--- a/xmpp/mucroomuniquehangoutidtask.h
+++ b/xmpp/mucroomuniquehangoutidtask.h
@@ -4,7 +4,7 @@
 #ifndef TALK_XMPP_MUCROOMUNIQUEHANGOUTIDTASK_H_
 #define TALK_XMPP_MUCROOMUNIQUEHANGOUTIDTASK_H_
 
-#include "talk/xmpp/iqtask.h"
+#include "webrtc/libjingle/xmpp/iqtask.h"
 
 namespace buzz {
 
diff --git a/xmpp/mucroomuniquehangoutidtask_unittest.cc b/xmpp/mucroomuniquehangoutidtask_unittest.cc
index 42bed13..d8f7c20 100644
--- a/xmpp/mucroomuniquehangoutidtask_unittest.cc
+++ b/xmpp/mucroomuniquehangoutidtask_unittest.cc
@@ -29,9 +29,9 @@
 #include <vector>
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/fakexmppclient.h"
-#include "talk/xmpp/mucroomuniquehangoutidtask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/fakexmppclient.h"
+#include "webrtc/libjingle/xmpp/mucroomuniquehangoutidtask.h"
 #include "webrtc/base/faketaskrunner.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/pingtask.cc b/xmpp/pingtask.cc
index 7922ea0..619c3a8 100644
--- a/xmpp/pingtask.cc
+++ b/xmpp/pingtask.cc
@@ -1,9 +1,9 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
 
-#include "talk/xmpp/pingtask.h"
+#include "webrtc/libjingle/xmpp/pingtask.h"
 
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/scoped_ptr.h"
 
diff --git a/xmpp/pingtask.h b/xmpp/pingtask.h
index 2a869a3..87d74b4 100644
--- a/xmpp/pingtask.h
+++ b/xmpp/pingtask.h
@@ -28,7 +28,7 @@
 #ifndef TALK_XMPP_PINGTASK_H_
 #define TALK_XMPP_PINGTASK_H_
 
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/messagehandler.h"
 #include "webrtc/base/messagequeue.h"
 
diff --git a/xmpp/pingtask_unittest.cc b/xmpp/pingtask_unittest.cc
index fe88a5c..a0b6618 100644
--- a/xmpp/pingtask_unittest.cc
+++ b/xmpp/pingtask_unittest.cc
@@ -29,9 +29,9 @@
 #include <vector>
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/fakexmppclient.h"
-#include "talk/xmpp/pingtask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/fakexmppclient.h"
+#include "webrtc/libjingle/xmpp/pingtask.h"
 #include "webrtc/base/faketaskrunner.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/plainsaslhandler.h b/xmpp/plainsaslhandler.h
index 31032e4..f23782d 100644
--- a/xmpp/plainsaslhandler.h
+++ b/xmpp/plainsaslhandler.h
@@ -29,8 +29,8 @@
 #define TALK_XMPP_PLAINSASLHANDLER_H_
 
 #include <algorithm>
-#include "talk/xmpp/saslhandler.h"
-#include "talk/xmpp/saslplainmechanism.h"
+#include "webrtc/libjingle/xmpp/saslhandler.h"
+#include "webrtc/libjingle/xmpp/saslplainmechanism.h"
 #include "webrtc/base/cryptstring.h"
 
 namespace buzz {
diff --git a/xmpp/presenceouttask.cc b/xmpp/presenceouttask.cc
index a77d9d6..39ef646 100644
--- a/xmpp/presenceouttask.cc
+++ b/xmpp/presenceouttask.cc
@@ -27,9 +27,9 @@
 
 #include <time.h>
 #include <sstream>
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/presenceouttask.h"
-#include "talk/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/presenceouttask.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
 #include "webrtc/base/stringencode.h"
 
 namespace buzz {
diff --git a/xmpp/presenceouttask.h b/xmpp/presenceouttask.h
index 53bbae5..f6b04af 100644
--- a/xmpp/presenceouttask.h
+++ b/xmpp/presenceouttask.h
@@ -28,9 +28,9 @@
 #ifndef TALK_XMPP_PRESENCEOUTTASK_H_
 #define TALK_XMPP_PRESENCEOUTTASK_H_
 
-#include "talk/xmpp/presencestatus.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/presencestatus.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/xmpp/presencereceivetask.cc b/xmpp/presencereceivetask.cc
index 940c53b..0a159ac 100644
--- a/xmpp/presencereceivetask.cc
+++ b/xmpp/presencereceivetask.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/presencereceivetask.h"
+#include "webrtc/libjingle/xmpp/presencereceivetask.h"
 
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/stringencode.h"
 
 namespace buzz {
diff --git a/xmpp/presencereceivetask.h b/xmpp/presencereceivetask.h
index 6a090f3..80e11d8 100644
--- a/xmpp/presencereceivetask.h
+++ b/xmpp/presencereceivetask.h
@@ -30,8 +30,8 @@
 
 #include "webrtc/base/sigslot.h"
 
-#include "talk/xmpp/presencestatus.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/presencestatus.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/xmpp/presencestatus.cc b/xmpp/presencestatus.cc
index c75b705..2ab89b2 100644
--- a/xmpp/presencestatus.cc
+++ b/xmpp/presencestatus.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/presencestatus.h"
+#include "webrtc/libjingle/xmpp/presencestatus.h"
 
 namespace buzz {
 PresenceStatus::PresenceStatus()
diff --git a/xmpp/presencestatus.h b/xmpp/presencestatus.h
index 45c5471..c133e40 100644
--- a/xmpp/presencestatus.h
+++ b/xmpp/presencestatus.h
@@ -28,8 +28,8 @@
 #ifndef THIRD_PARTY_LIBJINGLE_FILES_TALK_XMPP_PRESENCESTATUS_H_
 #define THIRD_PARTY_LIBJINGLE_FILES_TALK_XMPP_PRESENCESTATUS_H_
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 
 namespace buzz {
 
diff --git a/xmpp/prexmppauth.h b/xmpp/prexmppauth.h
index 71fcae4..7ddc85b 100644
--- a/xmpp/prexmppauth.h
+++ b/xmpp/prexmppauth.h
@@ -28,7 +28,7 @@
 #ifndef TALK_XMPP_PREXMPPAUTH_H_
 #define TALK_XMPP_PREXMPPAUTH_H_
 
-#include "talk/xmpp/saslhandler.h"
+#include "webrtc/libjingle/xmpp/saslhandler.h"
 #include "webrtc/base/cryptstring.h"
 #include "webrtc/base/sigslot.h"
 
diff --git a/xmpp/pubsub_task.cc b/xmpp/pubsub_task.cc
index 3552764..98446fd 100644
--- a/xmpp/pubsub_task.cc
+++ b/xmpp/pubsub_task.cc
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/pubsub_task.h"
+#include "webrtc/libjingle/xmpp/pubsub_task.h"
 
 #include <map>
 #include <string>
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/common.h"
 
 namespace buzz {
diff --git a/xmpp/pubsub_task.h b/xmpp/pubsub_task.h
index 2787cbc..a219b60 100644
--- a/xmpp/pubsub_task.h
+++ b/xmpp/pubsub_task.h
@@ -31,8 +31,8 @@
 #include <map>
 #include <string>
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/xmpp/pubsubclient.cc b/xmpp/pubsubclient.cc
index b627587..a5793ef 100644
--- a/xmpp/pubsubclient.cc
+++ b/xmpp/pubsubclient.cc
@@ -25,14 +25,14 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/pubsubclient.h"
+#include "webrtc/libjingle/xmpp/pubsubclient.h"
 
 #include <string>
 #include <vector>
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/pubsubtasks.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/pubsubtasks.h"
 
 namespace buzz {
 
diff --git a/xmpp/pubsubclient.h b/xmpp/pubsubclient.h
index d7b5066..6465957 100644
--- a/xmpp/pubsubclient.h
+++ b/xmpp/pubsubclient.h
@@ -31,8 +31,8 @@
 #include <string>
 #include <vector>
 
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/pubsubtasks.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/pubsubtasks.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/sigslotrepeater.h"
 #include "webrtc/base/task.h"
diff --git a/xmpp/pubsubclient_unittest.cc b/xmpp/pubsubclient_unittest.cc
index f191a18..b3049d8 100644
--- a/xmpp/pubsubclient_unittest.cc
+++ b/xmpp/pubsubclient_unittest.cc
@@ -5,10 +5,10 @@
 
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/fakexmppclient.h"
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/pubsubclient.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/fakexmppclient.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/pubsubclient.h"
 #include "webrtc/base/faketaskrunner.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/pubsubstateclient.cc b/xmpp/pubsubstateclient.cc
index 5cd7b1a..2ed7b20 100644
--- a/xmpp/pubsubstateclient.cc
+++ b/xmpp/pubsubstateclient.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/pubsubstateclient.h"
+#include "webrtc/libjingle/xmpp/pubsubstateclient.h"
 
 namespace buzz {
 
diff --git a/xmpp/pubsubstateclient.h b/xmpp/pubsubstateclient.h
index 09ef0f4..79b1329 100644
--- a/xmpp/pubsubstateclient.h
+++ b/xmpp/pubsubstateclient.h
@@ -34,9 +34,9 @@
 
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/pubsubclient.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/pubsubclient.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/sigslotrepeater.h"
diff --git a/xmpp/pubsubtasks.cc b/xmpp/pubsubtasks.cc
index 015708e..091a7ad 100644
--- a/xmpp/pubsubtasks.cc
+++ b/xmpp/pubsubtasks.cc
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/pubsubtasks.h"
+#include "webrtc/libjingle/xmpp/pubsubtasks.h"
 
 #include <string>
 #include <vector>
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/receivetask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/receivetask.h"
 
 // An implementation of the tasks for XEP-0060
 // (http://xmpp.org/extensions/xep-0060.html).
diff --git a/xmpp/pubsubtasks.h b/xmpp/pubsubtasks.h
index 94be276..280c613 100644
--- a/xmpp/pubsubtasks.h
+++ b/xmpp/pubsubtasks.h
@@ -30,8 +30,8 @@
 
 #include <vector>
 
-#include "talk/xmpp/iqtask.h"
-#include "talk/xmpp/receivetask.h"
+#include "webrtc/libjingle/xmpp/iqtask.h"
+#include "webrtc/libjingle/xmpp/receivetask.h"
 #include "webrtc/base/sigslot.h"
 
 namespace buzz {
diff --git a/xmpp/pubsubtasks_unittest.cc b/xmpp/pubsubtasks_unittest.cc
index 48cd04a..7ea21e7 100644
--- a/xmpp/pubsubtasks_unittest.cc
+++ b/xmpp/pubsubtasks_unittest.cc
@@ -5,11 +5,11 @@
 
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/fakexmppclient.h"
-#include "talk/xmpp/iqtask.h"
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/pubsubtasks.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/fakexmppclient.h"
+#include "webrtc/libjingle/xmpp/iqtask.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/pubsubtasks.h"
 #include "webrtc/base/faketaskrunner.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/receivetask.cc b/xmpp/receivetask.cc
index c2fb244..4c4fae5 100644
--- a/xmpp/receivetask.cc
+++ b/xmpp/receivetask.cc
@@ -25,8 +25,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/receivetask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/receivetask.h"
 
 namespace buzz {
 
diff --git a/xmpp/receivetask.h b/xmpp/receivetask.h
index b18e0f0..7055339 100644
--- a/xmpp/receivetask.h
+++ b/xmpp/receivetask.h
@@ -28,7 +28,7 @@
 #ifndef TALK_XMPP_RECEIVETASK_H_
 #define TALK_XMPP_RECEIVETASK_H_
 
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/xmpp/rostermodule.h b/xmpp/rostermodule.h
index dfb647d..9ae7f70 100644
--- a/xmpp/rostermodule.h
+++ b/xmpp/rostermodule.h
@@ -28,7 +28,7 @@
 #ifndef TALK_XMPP_ROSTERMODULE_H_
 #define TALK_XMPP_ROSTERMODULE_H_
 
-#include "talk/xmpp/module.h"
+#include "webrtc/libjingle/xmpp/module.h"
 
 namespace buzz {
 
diff --git a/xmpp/rostermodule_unittest.cc b/xmpp/rostermodule_unittest.cc
index cb7f773..fb82546 100644
--- a/xmpp/rostermodule_unittest.cc
+++ b/xmpp/rostermodule_unittest.cc
@@ -30,10 +30,10 @@
 #include <string>
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/rostermodule.h"
-#include "talk/xmpp/util_unittest.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/rostermodule.h"
+#include "webrtc/libjingle/xmpp/util_unittest.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/scoped_ptr.h"
 
diff --git a/xmpp/rostermoduleimpl.cc b/xmpp/rostermoduleimpl.cc
index e52e78e..8841db6 100644
--- a/xmpp/rostermoduleimpl.cc
+++ b/xmpp/rostermoduleimpl.cc
@@ -31,8 +31,8 @@
 #include <sstream>
 #include <string>
 #include <vector>
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/rostermoduleimpl.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/rostermoduleimpl.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/stringencode.h"
 
diff --git a/xmpp/rostermoduleimpl.h b/xmpp/rostermoduleimpl.h
index 37d1117..efef5ed 100644
--- a/xmpp/rostermoduleimpl.h
+++ b/xmpp/rostermoduleimpl.h
@@ -28,8 +28,8 @@
 #ifndef TALK_XMPP_XMPPTHREAD_H_
 #define TALK_XMPP_XMPPTHREAD_H_
 
-#include "talk/xmpp/moduleimpl.h"
-#include "talk/xmpp/rostermodule.h"
+#include "webrtc/libjingle/xmpp/moduleimpl.h"
+#include "webrtc/libjingle/xmpp/rostermodule.h"
 
 namespace buzz {
 
diff --git a/xmpp/saslcookiemechanism.h b/xmpp/saslcookiemechanism.h
index eda142c..0f193f2 100644
--- a/xmpp/saslcookiemechanism.h
+++ b/xmpp/saslcookiemechanism.h
@@ -30,8 +30,8 @@
 
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/saslmechanism.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/saslmechanism.h"
 
 namespace buzz {
 
diff --git a/xmpp/saslmechanism.cc b/xmpp/saslmechanism.cc
index 8877084..9fb01bc 100644
--- a/xmpp/saslmechanism.cc
+++ b/xmpp/saslmechanism.cc
@@ -26,8 +26,8 @@
  */
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/saslmechanism.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/saslmechanism.h"
 #include "webrtc/base/base64.h"
 
 using rtc::Base64;
diff --git a/xmpp/saslplainmechanism.h b/xmpp/saslplainmechanism.h
index 36b9bb9..c9d428e 100644
--- a/xmpp/saslplainmechanism.h
+++ b/xmpp/saslplainmechanism.h
@@ -28,7 +28,7 @@
 #ifndef TALK_XMPP_SASLPLAINMECHANISM_H_
 #define TALK_XMPP_SASLPLAINMECHANISM_H_
 
-#include "talk/xmpp/saslmechanism.h"
+#include "webrtc/libjingle/xmpp/saslmechanism.h"
 #include "webrtc/base/cryptstring.h"
 
 namespace buzz {
diff --git a/xmpp/util_unittest.cc b/xmpp/util_unittest.cc
index 3e47d3f..d245efe 100644
--- a/xmpp/util_unittest.cc
+++ b/xmpp/util_unittest.cc
@@ -5,8 +5,8 @@
 #include <sstream>
 #include <string>
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/util_unittest.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/util_unittest.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/gunit.h"
 
 namespace buzz {
diff --git a/xmpp/util_unittest.h b/xmpp/util_unittest.h
index c9377ff..806b505 100644
--- a/xmpp/util_unittest.h
+++ b/xmpp/util_unittest.h
@@ -30,7 +30,7 @@
 
 #include <sstream>
 #include <string>
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 
 namespace buzz {
 
diff --git a/xmpp/xmppauth.cc b/xmpp/xmppauth.cc
index d828475..255f3a7 100644
--- a/xmpp/xmppauth.cc
+++ b/xmpp/xmppauth.cc
@@ -25,13 +25,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/xmppauth.h"
+#include "webrtc/libjingle/xmpp/xmppauth.h"
 
 #include <algorithm>
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/saslcookiemechanism.h"
-#include "talk/xmpp/saslplainmechanism.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/saslcookiemechanism.h"
+#include "webrtc/libjingle/xmpp/saslplainmechanism.h"
 
 XmppAuth::XmppAuth() : done_(false) {
 }
diff --git a/xmpp/xmppauth.h b/xmpp/xmppauth.h
index fec73e6..9fabd5e 100644
--- a/xmpp/xmppauth.h
+++ b/xmpp/xmppauth.h
@@ -30,9 +30,9 @@
 
 #include <vector>
 
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/prexmppauth.h"
-#include "talk/xmpp/saslhandler.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/prexmppauth.h"
+#include "webrtc/libjingle/xmpp/saslhandler.h"
 #include "webrtc/base/cryptstring.h"
 #include "webrtc/base/sigslot.h"
 
diff --git a/xmpp/xmppclient.cc b/xmpp/xmppclient.cc
index 27aa5e4..66d1e97 100644
--- a/xmpp/xmppclient.cc
+++ b/xmpp/xmppclient.cc
@@ -25,12 +25,12 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/plainsaslhandler.h"
-#include "talk/xmpp/prexmppauth.h"
-#include "talk/xmpp/saslplainmechanism.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/plainsaslhandler.h"
+#include "webrtc/libjingle/xmpp/prexmppauth.h"
+#include "webrtc/libjingle/xmpp/saslplainmechanism.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/xmppclient.h b/xmpp/xmppclient.h
index 53b2d24..74e4030 100644
--- a/xmpp/xmppclient.h
+++ b/xmpp/xmppclient.h
@@ -29,10 +29,10 @@
 #define TALK_XMPP_XMPPCLIENT_H_
 
 #include <string>
-#include "talk/xmpp/asyncsocket.h"
-#include "talk/xmpp/xmppclientsettings.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/asyncsocket.h"
+#include "webrtc/libjingle/xmpp/xmppclientsettings.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/basicdefs.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/task.h"
diff --git a/xmpp/xmppclientsettings.h b/xmpp/xmppclientsettings.h
index 50028b7..04acf36 100644
--- a/xmpp/xmppclientsettings.h
+++ b/xmpp/xmppclientsettings.h
@@ -28,8 +28,8 @@
 #ifndef TALK_XMPP_XMPPCLIENTSETTINGS_H_
 #define TALK_XMPP_XMPPCLIENTSETTINGS_H_
 
-#include "talk/p2p/base/port.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/p2p/base/port.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/cryptstring.h"
 
 namespace buzz {
diff --git a/xmpp/xmppengine.h b/xmpp/xmppengine.h
index 461e90f..1806ba9 100644
--- a/xmpp/xmppengine.h
+++ b/xmpp/xmppengine.h
@@ -31,7 +31,7 @@
 // also part of the API
 #include "webrtc/libjingle/xmllite/qname.h"
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/jid.h"
 
 
 namespace buzz {
diff --git a/xmpp/xmppengine_unittest.cc b/xmpp/xmppengine_unittest.cc
index b519a65..6b0dc96 100644
--- a/xmpp/xmppengine_unittest.cc
+++ b/xmpp/xmppengine_unittest.cc
@@ -5,11 +5,11 @@
 #include <sstream>
 #include <string>
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/plainsaslhandler.h"
-#include "talk/xmpp/saslplainmechanism.h"
-#include "talk/xmpp/util_unittest.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/plainsaslhandler.h"
+#include "webrtc/libjingle/xmpp/saslplainmechanism.h"
+#include "webrtc/libjingle/xmpp/util_unittest.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/gunit.h"
 
diff --git a/xmpp/xmppengineimpl.cc b/xmpp/xmppengineimpl.cc
index 5de9de7..98d89e2 100644
--- a/xmpp/xmppengineimpl.cc
+++ b/xmpp/xmppengineimpl.cc
@@ -25,7 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/xmppengineimpl.h"
+#include "webrtc/libjingle/xmpp/xmppengineimpl.h"
 
 #include <algorithm>
 #include <sstream>
@@ -33,9 +33,9 @@
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
 #include "webrtc/libjingle/xmllite/xmlprinter.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/saslhandler.h"
-#include "talk/xmpp/xmpplogintask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/saslhandler.h"
+#include "webrtc/libjingle/xmpp/xmpplogintask.h"
 #include "webrtc/base/common.h"
 
 namespace buzz {
diff --git a/xmpp/xmppengineimpl.h b/xmpp/xmppengineimpl.h
index 4eacf2f..a3da795 100644
--- a/xmpp/xmppengineimpl.h
+++ b/xmpp/xmppengineimpl.h
@@ -30,8 +30,8 @@
 
 #include <sstream>
 #include <vector>
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmppstanzaparser.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmppstanzaparser.h"
 
 namespace buzz {
 
diff --git a/xmpp/xmppengineimpl_iq.cc b/xmpp/xmppengineimpl_iq.cc
index 208e164..d48f021 100644
--- a/xmpp/xmppengineimpl_iq.cc
+++ b/xmpp/xmppengineimpl_iq.cc
@@ -27,8 +27,8 @@
 
 #include <algorithm>
 #include <vector>
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/xmppengineimpl.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/xmppengineimpl.h"
 #include "webrtc/base/common.h"
 
 namespace buzz {
diff --git a/xmpp/xmpplogintask.cc b/xmpp/xmpplogintask.cc
index a48a94c..7788c0d 100644
--- a/xmpp/xmpplogintask.cc
+++ b/xmpp/xmpplogintask.cc
@@ -25,16 +25,16 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/xmpplogintask.h"
+#include "webrtc/libjingle/xmpp/xmpplogintask.h"
 
 #include <string>
 #include <vector>
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/saslmechanism.h"
-#include "talk/xmpp/xmppengineimpl.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/saslmechanism.h"
+#include "webrtc/libjingle/xmpp/xmppengineimpl.h"
 #include "webrtc/base/base64.h"
 #include "webrtc/base/common.h"
 
diff --git a/xmpp/xmpplogintask.h b/xmpp/xmpplogintask.h
index 8685658..631ebdf 100644
--- a/xmpp/xmpplogintask.h
+++ b/xmpp/xmpplogintask.h
@@ -31,8 +31,8 @@
 #include <string>
 #include <vector>
 
-#include "talk/xmpp/jid.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/jid.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/scoped_ptr.h"
 
diff --git a/xmpp/xmpplogintask_unittest.cc b/xmpp/xmpplogintask_unittest.cc
index ae9a554..82973c4 100644
--- a/xmpp/xmpplogintask_unittest.cc
+++ b/xmpp/xmpplogintask_unittest.cc
@@ -5,11 +5,11 @@
 #include <sstream>
 #include <string>
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/plainsaslhandler.h"
-#include "talk/xmpp/saslplainmechanism.h"
-#include "talk/xmpp/util_unittest.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/plainsaslhandler.h"
+#include "webrtc/libjingle/xmpp/saslplainmechanism.h"
+#include "webrtc/libjingle/xmpp/util_unittest.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/cryptstring.h"
 #include "webrtc/base/gunit.h"
diff --git a/xmpp/xmpppump.cc b/xmpp/xmpppump.cc
index cf7aa7b..e9e7823 100644
--- a/xmpp/xmpppump.cc
+++ b/xmpp/xmpppump.cc
@@ -25,9 +25,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/xmpppump.h"
+#include "webrtc/libjingle/xmpp/xmpppump.h"
 
-#include "talk/xmpp/xmppauth.h"
+#include "webrtc/libjingle/xmpp/xmppauth.h"
 
 namespace buzz {
 
diff --git a/xmpp/xmpppump.h b/xmpp/xmpppump.h
index ff72f54..082afb9 100644
--- a/xmpp/xmpppump.h
+++ b/xmpp/xmpppump.h
@@ -28,9 +28,9 @@
 #ifndef TALK_XMPP_XMPPPUMP_H_
 #define TALK_XMPP_XMPPPUMP_H_
 
-#include "talk/xmpp/xmppclient.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 #include "webrtc/base/messagequeue.h"
 #include "webrtc/base/taskrunner.h"
 #include "webrtc/base/thread.h"
diff --git a/xmpp/xmppsocket.h b/xmpp/xmppsocket.h
index 3d6df52..240bbe9 100644
--- a/xmpp/xmppsocket.h
+++ b/xmpp/xmppsocket.h
@@ -28,8 +28,8 @@
 #ifndef TALK_XMPP_XMPPSOCKET_H_
 #define TALK_XMPP_XMPPSOCKET_H_
 
-#include "talk/xmpp/asyncsocket.h"
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/asyncsocket.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/asyncsocket.h"
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/sigslot.h"
diff --git a/xmpp/xmppstanzaparser.cc b/xmpp/xmppstanzaparser.cc
index 4795839..a4ca2ed 100644
--- a/xmpp/xmppstanzaparser.cc
+++ b/xmpp/xmppstanzaparser.cc
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/xmppstanzaparser.h"
+#include "webrtc/libjingle/xmpp/xmppstanzaparser.h"
 
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/constants.h"
 #include "webrtc/base/common.h"
 #ifdef EXPAT_RELATIVE_PATH
 #include "expat.h"
diff --git a/xmpp/xmppstanzaparser_unittest.cc b/xmpp/xmppstanzaparser_unittest.cc
index 0b114c0..433de5e 100644
--- a/xmpp/xmppstanzaparser_unittest.cc
+++ b/xmpp/xmppstanzaparser_unittest.cc
@@ -5,7 +5,7 @@
 #include <sstream>
 #include <string>
 #include "webrtc/libjingle/xmllite/xmlelement.h"
-#include "talk/xmpp/xmppstanzaparser.h"
+#include "webrtc/libjingle/xmpp/xmppstanzaparser.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/gunit.h"
 
diff --git a/xmpp/xmpptask.cc b/xmpp/xmpptask.cc
index c5e86fa..31aba62 100644
--- a/xmpp/xmpptask.cc
+++ b/xmpp/xmpptask.cc
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/xmppclient.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpptask.h"
+#include "webrtc/libjingle/xmpp/constants.h"
+#include "webrtc/libjingle/xmpp/xmppclient.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpptask.h"
 
 namespace buzz {
 
diff --git a/xmpp/xmpptask.h b/xmpp/xmpptask.h
index f6dd156..a8d1124 100644
--- a/xmpp/xmpptask.h
+++ b/xmpp/xmpptask.h
@@ -30,7 +30,7 @@
 
 #include <deque>
 #include <string>
-#include "talk/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
 #include "webrtc/base/sigslot.h"
 #include "webrtc/base/task.h"
 #include "webrtc/base/taskparent.h"
diff --git a/xmpp/xmppthread.cc b/xmpp/xmppthread.cc
index e67bffe..ad9246b 100644
--- a/xmpp/xmppthread.cc
+++ b/xmpp/xmppthread.cc
@@ -25,10 +25,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "talk/xmpp/xmppthread.h"
+#include "webrtc/libjingle/xmpp/xmppthread.h"
 
-#include "talk/xmpp/xmppauth.h"
-#include "talk/xmpp/xmppclientsettings.h"
+#include "webrtc/libjingle/xmpp/xmppauth.h"
+#include "webrtc/libjingle/xmpp/xmppclientsettings.h"
 
 namespace buzz {
 namespace {
diff --git a/xmpp/xmppthread.h b/xmpp/xmppthread.h
index bfb74d6..5a77f00 100644
--- a/xmpp/xmppthread.h
+++ b/xmpp/xmppthread.h
@@ -28,10 +28,10 @@
 #ifndef TALK_XMPP_XMPPTHREAD_H_
 #define TALK_XMPP_XMPPTHREAD_H_
 
-#include "talk/xmpp/xmppclientsettings.h"
-#include "talk/xmpp/xmppengine.h"
-#include "talk/xmpp/xmpppump.h"
-#include "talk/xmpp/xmppsocket.h"
+#include "webrtc/libjingle/xmpp/xmppclientsettings.h"
+#include "webrtc/libjingle/xmpp/xmppengine.h"
+#include "webrtc/libjingle/xmpp/xmpppump.h"
+#include "webrtc/libjingle/xmpp/xmppsocket.h"
 #include "webrtc/base/thread.h"
 
 namespace buzz {