diff options
Diffstat (limited to 'app/webrtc')
37 files changed, 287 insertions, 239 deletions
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 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { // 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 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { 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 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { 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 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { 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 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { }; textureCoords = directNativeFloatBuffer(textureCoordinatesFloat); } + updateTextureProperties = false; } - updateTextureProperties = false; } private void draw() { @@ -485,18 +495,23 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { } 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 class VideoRendererGui implements GLSurfaceView.Renderer { 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 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { 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 @@ class ClassReferenceHolder { 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 @@ class PCOJava : public PeerConnectionObserver { 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_nativeAddIceCandidate)( } 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 @@ class MediaCodecVideoDecoder { 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 @@ class MediaCodecVideoDecoder { 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 @@ import java.nio.ByteBuffer; // 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 @@ class MediaCodecVideoEncoder { 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 @@ public class PeerConnection { /** 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 @@ public class PeerConnection { 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 @@ public class PeerConnection { 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 @@ public class PeerConnectionTest extends TestCase { ++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 @@ public class PeerConnectionTest extends TestCase { 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 @@ class RTCStatsObserver : public StatsObserver { 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 @@ class RTCPeerConnectionObserver : public PeerConnectionObserver { 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( 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 @@ bool PeerConnection::DoInitialize( // 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 @@ PeerConnection::remote_streams() { 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 @@ bool PeerConnection::AddStream(MediaStreamInterface* local_stream, local_stream)) return false; - // TODO(perkj): Implement support for MediaConstraints in AddStream. if (!mediastream_signaling_->AddLocalStream(local_stream)) { return false; } @@ -421,6 +420,11 @@ bool PeerConnection::AddStream(MediaStreamInterface* local_stream, 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 @@ class PeerConnection : public PeerConnectionInterface, 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 @@ class PeerConnectionTestClientBase 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 @@ class PeerConnectionTestClientBase } // 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 @@ TEST_F(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) { // 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 @@ static const char kTurnIceServerWithIPv6Address[] = 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 @@ class PeerConnectionInterface : public rtc::RefCountInterface { // 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 @@ class PeerConnectionObserver { 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 @@ class PeerConnectionObserver { 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 @@ class MockPeerConnectionObserver : public PeerConnectionObserver { 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 @@ class PeerConnectionInterfaceTest : public testing::Test { 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 @@ class PeerConnectionInterfaceTest : public testing::Test { 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 @@ class PeerConnectionInterfaceTest : public testing::Test { 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 @@ TEST_F(PeerConnectionInterfaceTest, AddStreams) { 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 @@ TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) { 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 @@ BEGIN_PROXY_MAP(PeerConnection) 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 @@ class ReturnType<void> { 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 @@ class MethodCall0 : public rtc::Message, 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 @@ class ConstMethodCall0 : public rtc::Message, 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 @@ class MethodCall1 : public rtc::Message, 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 @@ class ConstMethodCall1 : public rtc::Message, 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 @@ class MethodCall2 : public rtc::Message, 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 @@ class MethodCall3 : public rtc::Message, : 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::kStatsValueNameEchoReturnLoss[] = const char StatsReport::kStatsValueNameEchoReturnLossEnhancement[] = "googEchoCancellationReturnLossEnhancement"; -const char StatsReport::kStatsValueNameEncodeRelStdDev[] = - "googEncodeRelStdDev"; const char StatsReport::kStatsValueNameEncodeUsagePercent[] = "googEncodeUsagePercent"; const char StatsReport::kStatsValueNameExpandRate[] = "googExpandRate"; @@ -459,8 +457,6 @@ void ExtractStats(const cricket::VideoSenderInfo& info, StatsReport* report) { 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 @@ class StatsReport { // 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 @@ void PeerConnectionTestWrapper::GetAndAddUserMedia( 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 @@ class PeerConnectionTestWrapper 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 kSessionName[] = "s=-"; 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 @@ static int GetCandidatePreferenceFromType(const std::string& type) { // 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 @@ static bool GetDefaultDestination(const std::vector<Candidate>& candidates, 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 @@ static void UpdateMediaDefaultDestination( } 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 @@ void BuildMediaDescription(const ContentInfo* content_info, // 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 @@ static const char kSdpString[] = "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 @@ static const char kSdpString[] = "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 @@ static const char kSdpString[] = "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 @@ static const char kSdpRtpDataChannelString[] = "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 @@ static const char kSdpSctpDataChannelString[] = // 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 @@ static const char kSdpConferenceString[] = "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 @@ static const char kSdpSessionString[] = "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 @@ static const char kSdpAudioString[] = "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 @@ class WebRtcSdpTest : public testing::Test { // 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 @@ class WebRtcSdpTest : public testing::Test { 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 @@ class WebRtcSdpTest : public testing::Test { // 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 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { // 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 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithReorderedPltypes) { "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" |