Chromium Code Reviews| Index: third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp |
| diff --git a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp |
| index 2631b08619bd58f7601f684da96903d271db3aaa..74539d7e973f68dccc39192f9122aa9e31a3cfcc 100644 |
| --- a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp |
| +++ b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp |
| @@ -154,9 +154,11 @@ WebRTCAnswerOptions convertToWebRTCAnswerOptions(const RTCAnswerOptions& options |
| WebRTCICECandidate convertToWebRTCIceCandidate(const RTCIceCandidateInitOrRTCIceCandidate& candidate) |
| { |
| + DCHECK(!candidate.isNull()); |
| if (candidate.isRTCIceCandidateInit()) { |
| const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandidateInit(); |
| - return WebRTCICECandidate(iceCandidateInit.candidate(), iceCandidateInit.sdpMid(), iceCandidateInit.sdpMLineIndex()); |
| + unsigned short sdpMLineIndex = iceCandidateInit.hasSdpMLineIndex() ? iceCandidateInit.sdpMLineIndex() : 0; |
|
hta - Chromium
2016/05/26 04:56:41
Count the number of times this zeroes, and add a T
Guido Urdaneta
2016/05/26 14:37:36
Done.
|
| + return WebRTCICECandidate(iceCandidateInit.candidate(), iceCandidateInit.sdpMid(), sdpMLineIndex); |
| } |
| DCHECK(candidate.isRTCIceCandidate()); |
| @@ -576,7 +578,7 @@ ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c |
| return promise; |
| } |
| -ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback) |
| +ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, const RTCSessionDescriptionInit& sessionDescriptionInit, VoidCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback) |
| { |
| ExecutionContext* context = scriptState->getExecutionContext(); |
| if (successCallback && errorCallback) { |
| @@ -591,10 +593,8 @@ ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, R |
| if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) |
| return ScriptPromise::castUndefined(scriptState); |
| - DCHECK(sessionDescription); |
| - |
| RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback); |
| - m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDescription()); |
| + m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(sessionDescriptionInit.type(), sessionDescriptionInit.sdp())); |
| return ScriptPromise::castUndefined(scriptState); |
| } |
| @@ -619,7 +619,7 @@ ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, |
| return promise; |
| } |
| -ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback) |
| +ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, const RTCSessionDescriptionInit& sessionDescriptionInit, VoidCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback) |
| { |
| ExecutionContext* context = scriptState->getExecutionContext(); |
| if (successCallback && errorCallback) { |
| @@ -634,10 +634,8 @@ ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, |
| if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) |
| return ScriptPromise::castUndefined(scriptState); |
| - DCHECK(sessionDescription); |
| - |
| RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback); |
| - m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionDescription()); |
| + m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessionDescriptionInit.type(), sessionDescriptionInit.sdp())); |
| return ScriptPromise::castUndefined(scriptState); |
| } |
| @@ -784,17 +782,20 @@ ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const |
| return promise; |
| } |
| -ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, RTCIceCandidate* iceCandidate, VoidCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback) |
| +ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate, VoidCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback) |
| { |
| - DCHECK(iceCandidate); |
| DCHECK(successCallback); |
| DCHECK(errorCallback); |
| if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) |
| return ScriptPromise::castUndefined(scriptState); |
| + if (isIceCandidateMissingSdp(candidate)) |
| + return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Candidate missing values for both sdpMid and sdpMLineIndex")); |
| + |
| RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback); |
| - bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->webCandidate()); |
| + WebRTCICECandidate webCandidate = convertToWebRTCIceCandidate(candidate); |
| + bool implemented = m_peerHandler->addICECandidate(request, webCandidate); |
| if (!implemented) |
| asyncCallErrorCallback(errorCallback, DOMException::create(OperationError, "This operation could not be completed.")); |