Changeset 206856 in webkit
- Timestamp:
- Oct 6, 2016 1:54:49 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 18 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206855 r206856 1 2016-10-06 Adam Bergkvist <adam.bergkvist@ericsson.com> 2 3 WebRTC: Add support for the icecandidate event in MediaEndpointPeerConnection 4 https://bugs.webkit.org/show_bug.cgi?id=162957 5 6 Reviewed by Eric Carlson. 7 8 Dispatch fake ICE candidates from the WebRTC platform mock (MockMediaEndpoint) and 9 inspect the result. 10 11 * fast/mediastream/RTCPeerConnection-icecandidate-event-expected.txt: Added. 12 * fast/mediastream/RTCPeerConnection-icecandidate-event.html: Added. 13 * platform/mac/TestExpectations: 14 Skip above test until the Mac port builds with WEB_RTC 15 1 16 2016-10-06 Youenn Fablet <youenn@apple.com> 2 17 -
trunk/LayoutTests/platform/mac/TestExpectations
r206774 r206856 207 207 fast/mediastream/RTCPeerConnection-media-setup-callbacks-single-dialog.html 208 208 fast/mediastream/RTCPeerConnection-legacy-stream-based-api.html 209 fast/mediastream/RTCPeerConnection-icecandidate-event.html 209 210 210 211 # Asserts in debug. -
trunk/Source/WebCore/ChangeLog
r206854 r206856 1 2016-10-06 Adam Bergkvist <adam.bergkvist@ericsson.com> 2 3 WebRTC: Add support for the icecandidate event in MediaEndpointPeerConnection 4 https://bugs.webkit.org/show_bug.cgi?id=162957 5 6 Reviewed by Eric Carlson. 7 8 Implement MediaEndpointPeerConnection's gotIceCandidate and doneGatheringCandidates 9 callbacks. These are used by the MediaEndpoint (WebRTC backend implementation) to 10 notify about ICE events. 11 12 Add API to Internals to emulate WebRTC platform events, such as dispatching a set of ICE 13 candidates followed by a gathering done indication. Initially, only a single action, 14 "dispatch-fake-ice-candidates", is supported, but the intention is to extend the set of 15 actions to support more test cases. 16 17 Test: fast/mediastream/RTCPeerConnection-icecandidate-event.html 18 19 * Modules/mediastream/MediaEndpointPeerConnection.cpp: 20 (WebCore::MediaEndpointPeerConnection::emulatePlatformEvent): 21 (WebCore::MediaEndpointPeerConnection::gotIceCandidate): 22 (WebCore::MediaEndpointPeerConnection::doneGatheringCandidates): 23 * Modules/mediastream/MediaEndpointPeerConnection.h: 24 * Modules/mediastream/PeerConnectionBackend.h: 25 * Modules/mediastream/RTCIceTransport.h: Added. 26 RTCIceCandidate will eventually be part of the JS API, but right now it's 27 only used to keep track of the ICE states related to a RTCRtpTranscevier. 28 (WebCore::RTCIceTransport::create): 29 (WebCore::RTCIceTransport::~RTCIceTransport): 30 (WebCore::RTCIceTransport::transportState): 31 (WebCore::RTCIceTransport::setTransportState): 32 (WebCore::RTCIceTransport::gatheringState): 33 (WebCore::RTCIceTransport::setGatheringState): 34 (WebCore::RTCIceTransport::RTCIceTransport): 35 * Modules/mediastream/RTCPeerConnection.cpp: 36 (WebCore::RTCPeerConnection::emulatePlatformEvent): 37 * Modules/mediastream/RTCPeerConnection.h: 38 * Modules/mediastream/RTCRtpTransceiver.cpp: 39 (WebCore::RTCRtpTransceiver::RTCRtpTransceiver): 40 * Modules/mediastream/RTCRtpTransceiver.h: 41 (WebCore::RTCRtpTransceiver::iceTransport): 42 * WebCore.xcodeproj/project.pbxproj: 43 * platform/mediastream/MediaEndpoint.h: 44 (WebCore::MediaEndpoint::emulatePlatformEvent): 45 * platform/mediastream/PeerConnectionStates.h: 46 * platform/mock/MockMediaEndpoint.cpp: 47 (WebCore::MockMediaEndpoint::MockMediaEndpoint): 48 (WebCore::MockMediaEndpoint::updateReceiveConfiguration): 49 (WebCore::MockMediaEndpoint::emulatePlatformEvent): 50 (WebCore::MockMediaEndpoint::dispatchFakeIceCandidates): 51 (WebCore::MockMediaEndpoint::iceCandidateTimerFired): 52 * platform/mock/MockMediaEndpoint.h: 53 * testing/Internals.cpp: 54 (WebCore::Internals::emulateRTCPeerConnectionPlatformEvent): 55 Generic API to signal down to the WebRTC platform mock. 56 * testing/Internals.h: 57 * testing/Internals.idl: 58 1 59 2016-10-06 Nan Wang <n_wang@apple.com> 2 60 -
trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp
r202671 r206856 43 43 #include "RTCConfiguration.h" 44 44 #include "RTCIceCandidate.h" 45 #include "RTCIceCandidateEvent.h" 45 46 #include "RTCOfferAnswerOptions.h" 46 47 #include "RTCRtpTransceiver.h" … … 756 757 } 757 758 759 void MediaEndpointPeerConnection::emulatePlatformEvent(const String& action) 760 { 761 m_mediaEndpoint->emulatePlatformEvent(action); 762 } 763 758 764 bool MediaEndpointPeerConnection::localDescriptionTypeValidForState(RTCSessionDescription::SdpType type) const 759 765 { … … 819 825 } 820 826 821 void MediaEndpointPeerConnection::gotIceCandidate( unsigned mdescIndex, RefPtr<IceCandidate>&& candidate)827 void MediaEndpointPeerConnection::gotIceCandidate(const String& mid, RefPtr<IceCandidate>&& candidate) 822 828 { 823 829 ASSERT(isMainThread()); 824 830 825 UNUSED_PARAM(mdescIndex); 826 UNUSED_PARAM(candidate); 827 828 notImplemented(); 829 } 830 831 void MediaEndpointPeerConnection::doneGatheringCandidates(unsigned mdescIndex) 831 const MediaDescriptionVector& mediaDescriptions = internalLocalDescription()->configuration()->mediaDescriptions(); 832 size_t mediaDescriptionIndex = notFound; 833 834 for (size_t i = 0; i < mediaDescriptions.size(); ++i) { 835 if (mediaDescriptions[i]->mid() == mid) { 836 mediaDescriptionIndex = i; 837 break; 838 } 839 } 840 ASSERT(mediaDescriptionIndex != notFound); 841 842 PeerMediaDescription& mediaDescription = *mediaDescriptions[mediaDescriptionIndex]; 843 mediaDescription.addIceCandidate(candidate.copyRef()); 844 845 String candidateLine; 846 SDPProcessor::Result result = m_sdpProcessor->generateCandidateLine(*candidate, candidateLine); 847 if (result != SDPProcessor::Result::Success) { 848 LOG_ERROR("SDPProcessor internal error"); 849 return; 850 } 851 852 RefPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::create(candidateLine, mid, mediaDescriptionIndex); 853 854 m_client->fireEvent(RTCIceCandidateEvent::create(false, false, WTFMove(iceCandidate))); 855 } 856 857 void MediaEndpointPeerConnection::doneGatheringCandidates(const String& mid) 832 858 { 833 859 ASSERT(isMainThread()); 834 860 835 UNUSED_PARAM(mdescIndex); 836 837 notImplemented(); 861 RtpTransceiverVector transceivers = RtpTransceiverVector(m_client->getTransceivers()); 862 RTCRtpTransceiver* notifyingTransceiver = matchTransceiverByMid(transceivers, mid); 863 ASSERT(notifyingTransceiver); 864 865 notifyingTransceiver->iceTransport().setGatheringState(RTCIceTransport::GatheringState::Complete); 866 867 // Don't notify the script if there are transceivers still gathering. 868 RTCRtpTransceiver* stillGatheringTransceiver = matchTransceiver(transceivers, [] (RTCRtpTransceiver& current) { 869 return !current.stopped() && !current.mid().isNull() 870 && current.iceTransport().gatheringState() != RTCIceTransport::GatheringState::Complete; 871 }); 872 if (!stillGatheringTransceiver) { 873 m_client->fireEvent(RTCIceCandidateEvent::create(false, false, nullptr)); 874 m_client->updateIceGatheringState(IceGatheringState::Complete); 875 } 838 876 } 839 877 -
trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h
r202439 r206856 85 85 void clearNegotiationNeededState() override { m_negotiationNeeded = false; }; 86 86 87 void emulatePlatformEvent(const String& action) override; 88 87 89 private: 88 90 void runTask(Function<void ()>&&); … … 108 110 // MediaEndpointClient 109 111 void gotDtlsFingerprint(const String& fingerprint, const String& fingerprintFunction) override; 110 void gotIceCandidate( unsigned mdescIndex, RefPtr<IceCandidate>&&) override;111 void doneGatheringCandidates( unsigned mdescIndex) override;112 void gotIceCandidate(const String& mid, RefPtr<IceCandidate>&&) override; 113 void doneGatheringCandidates(const String& mid) override; 112 114 113 115 PeerConnectionBackendClient* m_client; -
trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
r202376 r206856 118 118 virtual void markAsNeedingNegotiation() = 0; 119 119 virtual void clearNegotiationNeededState() = 0; 120 121 virtual void emulatePlatformEvent(const String& action) = 0; 120 122 }; 121 123 -
trunk/Source/WebCore/Modules/mediastream/RTCIceTransport.h
r206855 r206856 1 1 /* 2 * Copyright (C) 201 5, 2016 Ericsson AB. All rights reserved.2 * Copyright (C) 2016 Ericsson AB. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #if ENABLE(WEB_RTC) 34 34 35 #include "PeerConnectionStates.h" 36 #include "ScriptWrappable.h" 37 #include <wtf/RefCounted.h> 38 #include <wtf/RefPtr.h> 39 35 40 namespace WebCore { 36 41 37 namespace PeerConnectionStates { 42 class RTCIceTransport : public RefCounted<RTCIceTransport>, public ScriptWrappable { 43 public: 38 44 39 enum class SignalingState { 40 Stable = 1, 41 HaveLocalOffer = 2, 42 HaveRemoteOffer = 3, 43 HaveLocalPrAnswer = 4, 44 HaveRemotePrAnswer = 5, 45 Closed = 6 45 using TransportState = PeerConnectionStates::IceTransportState; 46 using GatheringState = PeerConnectionStates::IceGatheringState; 47 48 static Ref<RTCIceTransport> create() 49 { 50 return adoptRef(*new RTCIceTransport()); 51 } 52 virtual ~RTCIceTransport() { } 53 54 TransportState transportState() const { return m_transportState; } 55 void setTransportState(TransportState state) { m_transportState = state; } 56 57 GatheringState gatheringState() const { return m_gatheringState; } 58 void setGatheringState(GatheringState state) { m_gatheringState = state; } 59 60 private: 61 RTCIceTransport() { }; 62 63 TransportState m_transportState { TransportState::New }; 64 GatheringState m_gatheringState { GatheringState::New }; 46 65 }; 47 48 enum class IceConnectionState {49 New = 1,50 Checking = 2,51 Connected = 3,52 Completed = 4,53 Failed = 5,54 Disconnected = 6,55 Closed = 756 };57 58 enum class IceGatheringState {59 New = 1,60 Gathering = 2,61 Complete = 362 };63 64 enum class IceTransportPolicy {65 Relay,66 All67 };68 69 enum class BundlePolicy {70 Balanced,71 MaxCompat,72 MaxBundle73 };74 75 }76 66 77 67 } // namespace WebCore -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
r205542 r206856 429 429 } 430 430 431 void RTCPeerConnection::emulatePlatformEvent(const String& action) 432 { 433 m_backend->emulatePlatformEvent(action); 434 } 435 431 436 void RTCPeerConnection::stop() 432 437 { -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
r206094 r206856 120 120 using RefCounted<RTCPeerConnection>::deref; 121 121 122 // Used for testing with a mock 123 void emulatePlatformEvent(const String& action); 124 122 125 private: 123 126 RTCPeerConnection(ScriptExecutionContext&); -
trunk/Source/WebCore/Modules/mediastream/RTCRtpTransceiver.cpp
r201601 r206856 65 65 , m_sender(sender) 66 66 , m_receiver(receiver) 67 , m_iceTransport(RTCIceTransport::create()) 67 68 { 68 69 } -
trunk/Source/WebCore/Modules/mediastream/RTCRtpTransceiver.h
r201601 r206856 34 34 #if ENABLE(WEB_RTC) 35 35 36 #include "RTCIceTransport.h" 36 37 #include "RTCRtpReceiver.h" 37 38 #include "RTCRtpSender.h" … … 71 72 void stop() { m_stopped = true; } 72 73 74 // FIXME: Temporary solution to keep track of ICE states for this transceiver. Later, each 75 // sender and receiver will have up to two DTLS transports, which in turn will have an ICE 76 // transport each. 77 RTCIceTransport& iceTransport() const { return *m_iceTransport; } 78 73 79 static String getNextMid(); 74 80 … … 85 91 86 92 bool m_stopped { false }; 93 94 RefPtr<RTCIceTransport> m_iceTransport; 87 95 }; 88 96 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r206843 r206856 9459 9459 5E5E2B111CFC3E4B000C0D85 /* RTCRtpTransceiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpTransceiver.h; sourceTree = "<group>"; }; 9460 9460 5E5E2B121CFC3E4B000C0D85 /* RTCRtpTransceiver.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpTransceiver.idl; sourceTree = "<group>"; }; 9461 5E6653091DA437BF00FDD84C /* RTCIceTransport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCIceTransport.h; sourceTree = "<group>"; }; 9461 9462 5EA3D6DD1C859D5300300BBB /* MockMediaEndpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockMediaEndpoint.cpp; sourceTree = "<group>"; }; 9462 9463 5EA3D6DE1C859D5300300BBB /* MockMediaEndpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockMediaEndpoint.h; sourceTree = "<group>"; }; … … 14564 14565 07AB996718DA3C010018771E /* RTCIceServer.h */, 14565 14566 07AB996818DA3C010018771E /* RTCIceServer.idl */, 14567 5E6653091DA437BF00FDD84C /* RTCIceTransport.h */, 14566 14568 073794DB19EE2C5200E5A045 /* RTCOfferAnswerOptions.cpp */, 14567 14569 073794DC19EE2C5200E5A045 /* RTCOfferAnswerOptions.h */, -
trunk/Source/WebCore/platform/mediastream/MediaEndpoint.h
r204466 r206856 49 49 public: 50 50 virtual void gotDtlsFingerprint(const String& fingerprint, const String& fingerprintFunction) = 0; 51 virtual void gotIceCandidate( unsigned mdescIndex, RefPtr<IceCandidate>&&) = 0;52 virtual void doneGatheringCandidates( unsigned mdescIndex) = 0;51 virtual void gotIceCandidate(const String& mid, RefPtr<IceCandidate>&&) = 0; 52 virtual void doneGatheringCandidates(const String& mid) = 0; 53 53 54 54 virtual ~MediaEndpointClient() { } … … 86 86 87 87 virtual void stop() = 0; 88 89 virtual void emulatePlatformEvent(const String&) { }; 88 90 }; 89 91 -
trunk/Source/WebCore/platform/mediastream/PeerConnectionStates.h
r202671 r206856 62 62 }; 63 63 64 enum class IceTransportState { 65 New = 1, 66 Checking = 2, 67 Connected = 3, 68 Completed = 4, 69 Failed = 5, 70 Disconnected = 6, 71 Closed = 7 72 }; 73 64 74 enum class IceTransportPolicy { 65 75 Relay, -
trunk/Source/WebCore/platform/mock/MockMediaEndpoint.cpp
r202048 r206856 34 34 #include "MockMediaEndpoint.h" 35 35 36 #include "MediaEndpointSessionConfiguration.h" 36 37 #include "MediaPayload.h" 37 38 #include "MockRealtimeAudioSource.h" … … 51 52 MockMediaEndpoint::MockMediaEndpoint(MediaEndpointClient& client) 52 53 : m_client(client) 54 , m_iceCandidateTimer(*this, &MockMediaEndpoint::iceCandidateTimerFired) 53 55 { 54 56 } … … 159 161 MediaEndpoint::UpdateResult MockMediaEndpoint::updateReceiveConfiguration(MediaEndpointSessionConfiguration* configuration, bool isInitiator) 160 162 { 161 UNUSED_PARAM(configuration);162 163 UNUSED_PARAM(isInitiator); 164 165 Vector<String> mids; 166 for (const RefPtr<PeerMediaDescription>& mediaDescription : configuration->mediaDescriptions()) 167 mids.append(mediaDescription->mid()); 168 m_mids.swap(mids); 163 169 164 170 return UpdateResult::Success; … … 201 207 } 202 208 209 void MockMediaEndpoint::emulatePlatformEvent(const String& action) 210 { 211 if (action == "dispatch-fake-ice-candidates") 212 dispatchFakeIceCandidates(); 213 } 214 215 void MockMediaEndpoint::dispatchFakeIceCandidates() 216 { 217 RefPtr<IceCandidate> iceCandidate = IceCandidate::create(); 218 iceCandidate->setType("host"); 219 iceCandidate->setFoundation("1"); 220 iceCandidate->setComponentId(1); 221 iceCandidate->setPriority(2013266431); 222 iceCandidate->setAddress("192.168.0.100"); 223 iceCandidate->setPort(38838); 224 iceCandidate->setTransport("UDP"); 225 m_fakeIceCandidates.append(WTFMove(iceCandidate)); 226 227 iceCandidate = IceCandidate::create(); 228 iceCandidate->setType("host"); 229 iceCandidate->setFoundation("2"); 230 iceCandidate->setComponentId(1); 231 iceCandidate->setPriority(1019216383); 232 iceCandidate->setAddress("192.168.0.100"); 233 iceCandidate->setPort(9); 234 iceCandidate->setTransport("TCP"); 235 iceCandidate->setTcpType("active"); 236 m_fakeIceCandidates.append(WTFMove(iceCandidate)); 237 238 iceCandidate = IceCandidate::create(); 239 iceCandidate->setType("srflx"); 240 iceCandidate->setFoundation("3"); 241 iceCandidate->setComponentId(1); 242 iceCandidate->setPriority(1677722111); 243 iceCandidate->setAddress("172.18.0.1"); 244 iceCandidate->setPort(47989); 245 iceCandidate->setTransport("UDP"); 246 iceCandidate->setRelatedAddress("192.168.0.100"); 247 iceCandidate->setRelatedPort(47989); 248 m_fakeIceCandidates.append(WTFMove(iceCandidate)); 249 250 // Reverse order to use takeLast() while keeping the above order 251 m_fakeIceCandidates.reverse(); 252 253 m_iceCandidateTimer.startOneShot(0); 254 } 255 256 void MockMediaEndpoint::iceCandidateTimerFired() 257 { 258 if (m_mids.isEmpty()) 259 return; 260 261 if (!m_fakeIceCandidates.isEmpty()) { 262 m_client.gotIceCandidate(m_mids[0], m_fakeIceCandidates.takeLast()); 263 m_iceCandidateTimer.startOneShot(0); 264 } else 265 m_client.doneGatheringCandidates(m_mids[0]); 266 } 267 203 268 } // namespace WebCore 204 269 -
trunk/Source/WebCore/platform/mock/MockMediaEndpoint.h
r202048 r206856 35 35 36 36 #include "MediaEndpoint.h" 37 #include "Timer.h" 37 38 38 39 namespace WebCore { … … 62 63 void stop() override; 63 64 65 void emulatePlatformEvent(const String& action) override; 66 64 67 private: 68 void dispatchFakeIceCandidates(); 69 void iceCandidateTimerFired(); 70 65 71 MediaEndpointClient& m_client; 72 Vector<String> m_mids; 73 74 Vector<RefPtr<IceCandidate>> m_fakeIceCandidates; 75 Timer m_iceCandidateTimer; 66 76 }; 67 77 -
trunk/Source/WebCore/testing/Internals.cpp
r206811 r206856 954 954 RTCPeerConnectionHandler::create = RTCPeerConnectionHandlerMock::create; 955 955 } 956 957 void Internals::emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection& connection, const String& action) 958 { 959 connection.emulatePlatformEvent(action); 960 } 956 961 #endif 957 962 -
trunk/Source/WebCore/testing/Internals.h
r206811 r206856 64 64 class Range; 65 65 class RenderedDocumentMarker; 66 class RTCPeerConnection; 66 67 class SerializedScriptValue; 67 68 class SourceBuffer; … … 369 370 void enableMockMediaEndpoint(); 370 371 void enableMockRTCPeerConnectionHandler(); 372 void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action); 371 373 #endif 372 374 -
trunk/Source/WebCore/testing/Internals.idl
r206811 r206856 408 408 [Conditional=WIRELESS_PLAYBACK_TARGET, MayThrowLegacyException] void setMockMediaPlaybackTargetPickerState(DOMString deviceName, DOMString deviceState); 409 409 [Conditional=MEDIA_STREAM] void setMockMediaCaptureDevicesEnabled(boolean enabled); 410 [Conditional=WEB_RTC] void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection connection, DOMString action); 410 411 411 412 [Conditional=VIDEO] void simulateSystemSleep();
Note: See TracChangeset
for help on using the changeset viewer.