Changeset 160693 in webkit
- Timestamp:
- Dec 16, 2013 8:12:19 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r160670 r160693 1 2013-12-16 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org> 2 3 Checking RTCPeerConnection signalingState before setting local/remoteDescription 4 https://bugs.webkit.org/show_bug.cgi?id=125655 5 6 Reviewed by Eric Carlson. 7 8 Before setting a session description RTCPeerConnection must check if it is in valid state for that SDP type. 9 10 * fast/mediastream/RTCPeerConnection-have-local-answer.html: Added. 11 * fast/mediastream/RTCPeerConnection-have-local-offer-expected.txt: Added. 12 * fast/mediastream/RTCPeerConnection-have-local-offer.html: Added. 13 * fast/mediastream/RTCPeerConnection-have-local-pranswer-expected.txt: Added. 14 * fast/mediastream/RTCPeerConnection-have-local-pranswer.html: Added. 15 * fast/mediastream/RTCPeerConnection-have-remote-offer-expected.txt: Added. 16 * fast/mediastream/RTCPeerConnection-have-remote-offer.html: Added. 17 * fast/mediastream/RTCPeerConnection-have-remote-pranswer-expected.txt: Added. 18 * fast/mediastream/RTCPeerConnection-have-remote-pranswer.html: Added. 19 * fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt: 20 * fast/mediastream/RTCPeerConnection-remoteDescription.html: 21 * fast/mediastream/RTCPeerConnection-stable-expected.txt: Added. 22 * fast/mediastream/RTCPeerConnection-stable.html: Added. 23 1 24 2013-12-16 Oliver Hunt <oliver@apple.com> 2 25 -
trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt
r144808 r160693 8 8 PASS pc.setRemoteDescription(sessionDescription, requestSucceeded2, requestFailed2); did not throw exception. 9 9 PASS requestFailed was called. 10 PASS pc.remoteDescription.type is " answer"10 PASS pc.remoteDescription.type is "offer" 11 11 PASS pc.remoteDescription.sdp is "remote" 12 PASS pc.remoteDescription.type is " answer"12 PASS pc.remoteDescription.type is "offer" 13 13 PASS pc.remoteDescription.sdp is "remote" 14 14 PASS successfullyParsed is true -
trunk/LayoutTests/fast/mediastream/RTCPeerConnection-remoteDescription.html
r158991 r160693 14 14 testPassed('requestFailed was called.'); 15 15 16 shouldBeEqualToString('pc.remoteDescription.type', " answer");16 shouldBeEqualToString('pc.remoteDescription.type', "offer"); 17 17 shouldBeEqualToString('pc.remoteDescription.sdp', "remote"); 18 18 pc.close(); 19 shouldBeEqualToString('pc.remoteDescription.type', " answer");19 shouldBeEqualToString('pc.remoteDescription.type', "offer"); 20 20 shouldBeEqualToString('pc.remoteDescription.sdp', "remote"); 21 21 … … 39 39 testPassed('requestSucceeded was called.'); 40 40 41 sessionDescription = new RTCSessionDescription({type:" offer", sdp:"local"});41 sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"}); 42 42 shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded2, requestFailed2);'); 43 43 } 44 44 45 45 pc = new webkitRTCPeerConnection({iceServers:[]}); 46 var sessionDescription = new RTCSessionDescription({type:" answer", sdp:"remote"});46 var sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"}); 47 47 shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, requestFailed1);'); 48 48 -
trunk/Source/WebCore/ChangeLog
r160690 r160693 1 2013-12-16 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org> 2 3 Checking RTCPeerConnection signalingState before setting local/remoteDescription 4 https://bugs.webkit.org/show_bug.cgi?id=125655 5 6 Reviewed by Eric Carlson. 7 8 Before setting a session description RTCPeerConnection must check if it is in valid state for that SDP type. 9 10 New tests: fast/mediastream/RTCPeerConnection-have-local-answer.html 11 fast/mediastream/RTCPeerConnection-have-local-offer.html 12 fast/mediastream/RTCPeerConnection-have-local-pranswer.html 13 fast/mediastream/RTCPeerConnection-have-remote-offer.html 14 fast/mediastream/RTCPeerConnection-have-remote-pranswer.html 15 fast/mediastream/RTCPeerConnection-stable.html 16 17 Modified: fast/mediastream/RTCPeerConnection-remoteDescription.html 18 19 * Modules/mediastream/RTCPeerConnection.cpp: 20 (WebCore::RTCPeerConnection::checkStateForLocalDescription): Checks if the current state of RTCPeerConnection is 21 valid for the local SDP that is being set. 22 (WebCore::RTCPeerConnection::checkStateForRemoteDescription): Checks if the current state of RTCPeerConnection 23 is valid for the remote SDP that is being set. 24 (WebCore::RTCPeerConnection::setLocalDescription): Now calls checkStateForLocalDescription prior to set the 25 local SDP. 26 (WebCore::RTCPeerConnection::setRemoteDescription): Now Calls checkStateForRemoteDescription prior to set the 27 remote SDP. 28 * Modules/mediastream/RTCPeerConnection.h: 29 * platform/mock/RTCNotifiersMock.cpp: Adding new class to notify RTCPeerConnection about a signaling state 30 change: SignalingStateNotifier. 31 (WebCore::SignalingStateNotifier::SignalingStateNotifier): 32 (WebCore::SignalingStateNotifier::fire): 33 * platform/mock/RTCNotifiersMock.h: 34 * platform/mock/RTCPeerConnectionHandlerMock.cpp: 35 (WebCore::RTCPeerConnectionHandlerMock::signalingStateFromSDP): Defines the new state that RTCPeerConnection 36 should be, according the SDP that is being set. 37 (WebCore::RTCPeerConnectionHandlerMock::setLocalDescription): Calls signalingStateFromSDP, in order to get the 38 new signaling state and notify RTCPeerConnection object. 39 (WebCore::RTCPeerConnectionHandlerMock::setRemoteDescription): Ditto. 40 * platform/mock/RTCPeerConnectionHandlerMock.h: 41 1 42 2013-12-16 Tim Horton <timothy_horton@apple.com> 2 43 -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
r160553 r160693 63 63 #include "ScriptExecutionContext.h" 64 64 #include "VoidCallback.h" 65 #include <wtf/Functional.h> 66 #include <wtf/MainThread.h> 65 67 66 68 namespace WebCore { … … 211 213 } 212 214 215 bool RTCPeerConnection::checkStateForLocalDescription(RTCSessionDescription* localDescription) 216 { 217 if (localDescription->type() == "offer") 218 return m_signalingState == SignalingStateStable || m_signalingState == SignalingStateHaveLocalOffer; 219 if (localDescription->type() == "answer") 220 return m_signalingState == SignalingStateHaveRemoteOffer || m_signalingState == SignalingStateHaveLocalPrAnswer; 221 if (localDescription->type() == "pranswer") 222 return m_signalingState == SignalingStateHaveLocalPrAnswer || m_signalingState == SignalingStateHaveRemoteOffer; 223 224 return false; 225 } 226 227 bool RTCPeerConnection::checkStateForRemoteDescription(RTCSessionDescription* remoteDescription) 228 { 229 if (remoteDescription->type() == "offer") 230 return m_signalingState == SignalingStateStable || m_signalingState == SignalingStateHaveRemoteOffer; 231 if (remoteDescription->type() == "answer") 232 return m_signalingState == SignalingStateHaveLocalOffer || m_signalingState == SignalingStateHaveRemotePrAnswer; 233 if (remoteDescription->type() == "pranswer") 234 return m_signalingState == SignalingStateHaveRemotePrAnswer || m_signalingState == SignalingStateHaveLocalOffer; 235 236 return false; 237 } 238 213 239 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> prpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCPeerConnectionErrorCallback> errorCallback, ExceptionCode& ec) 214 240 { … … 224 250 } 225 251 252 if (!checkStateForLocalDescription(sessionDescription.get())) { 253 RefPtr<DOMError> error = DOMError::create(RTCPeerConnectionHandler::invalidSessionDescriptionErrorName()); 254 callOnMainThread(bind(&RTCPeerConnectionErrorCallback::handleEvent, errorCallback.get(), error.release())); 255 return; 256 } 257 226 258 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecutionContext(), successCallback, errorCallback); 227 259 m_peerHandler->setLocalDescription(request.release(), sessionDescription->descriptor()); … … 250 282 if (!sessionDescription) { 251 283 ec = TYPE_MISMATCH_ERR; 284 return; 285 } 286 287 if (!checkStateForRemoteDescription(sessionDescription.get())) { 288 RefPtr<DOMError> error = DOMError::create(RTCPeerConnectionHandler::invalidSessionDescriptionErrorName()); 289 callOnMainThread(bind(&RTCPeerConnectionErrorCallback::handleEvent, errorCallback.get(), error.release())); 252 290 return; 253 291 } -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
r160553 r160693 150 150 void changeIceConnectionState(IceConnectionState); 151 151 152 bool checkStateForLocalDescription(RTCSessionDescription*); 153 bool checkStateForRemoteDescription(RTCSessionDescription*); 154 152 155 SignalingState m_signalingState; 153 156 IceGatheringState m_iceGatheringState; -
trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp
r160553 r160693 81 81 } 82 82 83 SignalingStateNotifier::SignalingStateNotifier(RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient::SignalingState signalingState) 84 : m_client(client) 85 , m_signalingState(signalingState) 86 { 87 } 88 89 void SignalingStateNotifier::fire() 90 { 91 m_client->didChangeSignalingState(m_signalingState); 92 } 93 83 94 RemoteDataChannelNotifier::RemoteDataChannelNotifier(RTCPeerConnectionHandlerClient* client) 84 95 : m_client(client) -
trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h
r160553 r160693 78 78 }; 79 79 80 class SignalingStateNotifier : public MockNotifier { 81 public: 82 SignalingStateNotifier(RTCPeerConnectionHandlerClient*, RTCPeerConnectionHandlerClient::SignalingState); 83 84 void fire() OVERRIDE; 85 86 private: 87 RTCPeerConnectionHandlerClient* m_client; 88 RTCPeerConnectionHandlerClient::SignalingState m_signalingState; 89 }; 90 80 91 class RemoteDataChannelNotifier : public MockNotifier { 81 92 public: -
trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp
r160553 r160693 88 88 } 89 89 90 RTCPeerConnectionHandlerClient::SignalingState RTCPeerConnectionHandlerMock::signalingStateFromSDP(RTCSessionDescriptionDescriptor* descriptor) 91 { 92 if (descriptor->type() == "offer" && descriptor->sdp() == "local") 93 return RTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer; 94 if (descriptor->type() == "offer" && descriptor->sdp() == "remote") 95 return RTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer; 96 if (descriptor->type() == "pranswer" && descriptor->sdp() == "local") 97 return RTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer; 98 if (descriptor->type() == "pranswer" && descriptor->sdp() == "remote") 99 return RTCPeerConnectionHandlerClient::SignalingStateHaveRemotePrAnswer; 100 101 return RTCPeerConnectionHandlerClient::SignalingStateStable; 102 } 103 90 104 void RTCPeerConnectionHandlerMock::setLocalDescription(PassRefPtr<RTCVoidRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> descriptor) 91 105 { 92 RefPtr<VoidRequestNotifier> notifier; 106 RefPtr<VoidRequestNotifier> voidNotifier; 107 RefPtr<SignalingStateNotifier> signalingNotifier; 93 108 if (!descriptor.get() || descriptor->sdp() != "local") 94 notifier = adoptRef(new VoidRequestNotifier(request, false));109 voidNotifier = adoptRef(new VoidRequestNotifier(request, false, RTCPeerConnectionHandler::internalErrorName())); 95 110 else { 96 111 m_localSessionDescription = descriptor; 97 notifier = adoptRef(new VoidRequestNotifier(request, true)); 112 signalingNotifier = adoptRef(new SignalingStateNotifier(m_client, signalingStateFromSDP(m_localSessionDescription.get()))); 113 voidNotifier = adoptRef(new VoidRequestNotifier(request, true)); 114 m_timerEvents.append(adoptRef(new TimerEvent(this, signalingNotifier))); 98 115 } 99 116 100 m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));117 m_timerEvents.append(adoptRef(new TimerEvent(this, voidNotifier))); 101 118 } 102 119 103 120 void RTCPeerConnectionHandlerMock::setRemoteDescription(PassRefPtr<RTCVoidRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> descriptor) 104 121 { 105 RefPtr<VoidRequestNotifier> notifier; 122 RefPtr<VoidRequestNotifier> voidNotifier; 123 RefPtr<SignalingStateNotifier> signalingNotifier; 106 124 if (!descriptor.get() || descriptor->sdp() != "remote") 107 notifier = adoptRef(new VoidRequestNotifier(request, false));125 voidNotifier = adoptRef(new VoidRequestNotifier(request, false, RTCPeerConnectionHandler::internalErrorName())); 108 126 else { 109 127 m_remoteSessionDescription = descriptor; 110 notifier = adoptRef(new VoidRequestNotifier(request, true)); 128 signalingNotifier = adoptRef(new SignalingStateNotifier(m_client, signalingStateFromSDP(m_remoteSessionDescription.get()))); 129 voidNotifier = adoptRef(new VoidRequestNotifier(request, true)); 130 m_timerEvents.append(adoptRef(new TimerEvent(this, signalingNotifier))); 111 131 } 112 132 113 m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));133 m_timerEvents.append(adoptRef(new TimerEvent(this, voidNotifier))); 114 134 } 115 135 -
trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h
r159840 r160693 30 30 31 31 #include "RTCPeerConnectionHandler.h" 32 #include "RTCPeerConnectionHandlerClient.h" 32 33 #include "RTCSessionDescriptionDescriptor.h" 33 34 #include "TimerEventBasedMock.h" … … 61 62 62 63 private: 64 RTCPeerConnectionHandlerClient::SignalingState signalingStateFromSDP(RTCSessionDescriptionDescriptor*); 63 65 RTCPeerConnectionHandlerClient* m_client; 64 66
Note: See TracChangeset
for help on using the changeset viewer.