Changeset 218994 in webkit
- Timestamp:
- Jun 30, 2017 8:00:43 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r218991 r218994 1 2017-06-30 Youenn Fablet <youenn@apple.com> 2 3 Support PeerConnectionStates::BundlePolicy::MaxBundle when setting rtc configuration 4 https://bugs.webkit.org/show_bug.cgi?id=169389 5 6 Reviewed by Alex Christensen. 7 8 Covered by manual testing (appr.tc and https://youennf.github.io/webrtc-tests/src/content/peerconnection/trickle-ice/). 9 Updated test is showing some more failing but this is due to the fact that we are no longer totally lying on the configuration of the 10 underlying libwebrtc backend. 11 12 Previously, we were creating a libwebrtc peer connection and then setting its configuration. 13 libwebrtc does not like the configuration to be changed and may refuse to set the configuration. 14 Instead of doing that, we are now creating the libwebrtc peer connection with the provided configuration. 15 16 ICE candidate pool size is disabled as it is creating issues with running tests on bots. 17 18 * Modules/mediastream/MediaEndpointPeerConnection.cpp: 19 (WebCore::MediaEndpointPeerConnection::setConfiguration): 20 * Modules/mediastream/MediaEndpointPeerConnection.h: 21 * Modules/mediastream/PeerConnectionBackend.h: 22 * Modules/mediastream/RTCPeerConnection.cpp: 23 (WebCore::RTCPeerConnection::initializeWith): 24 (WebCore::iceServersFromConfiguration): 25 (WebCore::RTCPeerConnection::initializeConfiguration): 26 (WebCore::RTCPeerConnection::setConfiguration): 27 * Modules/mediastream/RTCPeerConnection.h: 28 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: 29 (WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint): 30 (WebCore::LibWebRTCMediaEndpoint::setConfiguration): 31 (WebCore::LibWebRTCMediaEndpoint::stop): 32 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h: 33 * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: 34 (WebCore::configurationFromMediaEndpointConfiguration): 35 (WebCore::LibWebRTCPeerConnectionBackend::setConfiguration): 36 * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: 37 * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp: 38 (WebCore::createActualPeerConnection): 39 (WebCore::LibWebRTCProvider::createPeerConnection): 40 * platform/mediastream/libwebrtc/LibWebRTCProvider.h: 41 42 1 43 2017-06-30 Antoine Quint <graouts@apple.com> 2 44 -
trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp
r218973 r218994 603 603 } 604 604 605 voidMediaEndpointPeerConnection::setConfiguration(MediaEndpointConfiguration&& configuration)605 bool MediaEndpointPeerConnection::setConfiguration(MediaEndpointConfiguration&& configuration) 606 606 { 607 607 m_mediaEndpoint->setConfiguration(WTFMove(configuration)); 608 return true; 608 609 } 609 610 -
trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h
r218973 r218994 57 57 RefPtr<RTCSessionDescription> pendingRemoteDescription() const final; 58 58 59 voidsetConfiguration(MediaEndpointConfiguration&&) final;59 bool setConfiguration(MediaEndpointConfiguration&&) final; 60 60 61 61 void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&) final; -
trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
r218973 r218994 89 89 virtual RefPtr<RTCSessionDescription> pendingRemoteDescription() const = 0; 90 90 91 virtual voidsetConfiguration(MediaEndpointConfiguration&&) = 0;91 virtual bool setConfiguration(MediaEndpointConfiguration&&) = 0; 92 92 93 93 virtual void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&) = 0; -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
r218973 r218994 98 98 return Exception { NOT_SUPPORTED_ERR }; 99 99 100 return setConfiguration(WTFMove(configuration));100 return initializeConfiguration(WTFMove(configuration)); 101 101 } 102 102 … … 299 299 } 300 300 301 ExceptionOr<void> RTCPeerConnection::setConfiguration(RTCConfiguration&& configuration) 302 { 303 if (isClosed()) 304 return Exception { INVALID_STATE_ERR }; 305 301 static inline std::optional<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& configuration) 302 { 306 303 Vector<MediaEndpointConfiguration::IceServerInfo> servers; 307 304 if (configuration.iceServers) { … … 309 306 for (auto& server : configuration.iceServers.value()) { 310 307 Vector<URL> serverURLs; 311 WTF::switchOn(server.urls, 312 [&serverURLs] (const String& string) { 313 serverURLs.reserveInitialCapacity(1); 308 WTF::switchOn(server.urls, [&serverURLs] (const String& string) { 309 serverURLs.reserveInitialCapacity(1); 310 serverURLs.uncheckedAppend(URL { URL { }, string }); 311 }, [&serverURLs] (const Vector<String>& vector) { 312 serverURLs.reserveInitialCapacity(vector.size()); 313 for (auto& string : vector) 314 314 serverURLs.uncheckedAppend(URL { URL { }, string }); 315 }, 316 [&serverURLs] (const Vector<String>& vector) { 317 serverURLs.reserveInitialCapacity(vector.size()); 318 for (auto& string : vector) 319 serverURLs.uncheckedAppend(URL { URL { }, string }); 320 } 321 ); 315 }); 322 316 for (auto& serverURL : serverURLs) { 323 317 if (!(serverURL.protocolIs("turn") || serverURL.protocolIs("turns") || serverURL.protocolIs("stun"))) 324 return Exception { INVALID_ACCESS_ERR };318 return std::nullopt; 325 319 } 326 320 servers.uncheckedAppend({ WTFMove(serverURLs), server.credential, server.username }); 327 321 } 328 322 } 329 330 m_backend->setConfiguration({ WTFMove(servers), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize }); 323 return servers; 324 } 325 326 ExceptionOr<void> RTCPeerConnection::initializeConfiguration(RTCConfiguration&& configuration) 327 { 328 auto servers = iceServersFromConfiguration(configuration); 329 if (!servers) 330 return Exception { INVALID_ACCESS_ERR }; 331 332 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=173938 333 // Also decide whether to report an exception or output a message in the console log if setting configuration fails. 334 m_backend->setConfiguration({ WTFMove(servers.value()), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize }); 335 336 m_configuration = WTFMove(configuration); 337 return { }; 338 } 339 340 ExceptionOr<void> RTCPeerConnection::setConfiguration(RTCConfiguration&& configuration) 341 { 342 if (isClosed()) 343 return Exception { INVALID_STATE_ERR }; 344 345 auto servers = iceServersFromConfiguration(configuration); 346 if (!servers) 347 return Exception { INVALID_ACCESS_ERR }; 348 349 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=173938 350 // Also decide whether to report an exception or output a message in the console log if setting configuration fails. 351 m_backend->setConfiguration({ WTFMove(servers.value()), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize }); 331 352 m_configuration = WTFMove(configuration); 332 353 return { }; -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
r218973 r218994 154 154 RTCPeerConnection(ScriptExecutionContext&); 155 155 156 ExceptionOr<void> initializeConfiguration(RTCConfiguration&&); 156 157 Ref<RTCRtpTransceiver> completeAddTransceiver(Ref<RTCRtpSender>&&, const RTCRtpTransceiverInit&, const String& trackId, const String& trackKind); 157 158 -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
r218973 r218994 60 60 : m_peerConnectionBackend(peerConnection) 61 61 , m_peerConnectionFactory(*client.factory()) 62 , m_backend(client.createPeerConnection(*this))63 62 , m_createSessionDescriptionObserver(*this) 64 63 , m_setLocalSessionDescriptionObserver(*this) … … 66 65 , m_statsLogTimer(*this, &LibWebRTCMediaEndpoint::gatherStatsForLogging) 67 66 { 68 ASSERT(m_backend);69 67 ASSERT(client.factory()); 68 } 69 70 bool LibWebRTCMediaEndpoint::setConfiguration(LibWebRTCProvider& client, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration) 71 { 72 if (!m_backend) { 73 m_backend = client.createPeerConnection(*this, WTFMove(configuration)); 74 return !!m_backend; 75 } 76 return m_backend->SetConfiguration(WTFMove(configuration)); 70 77 } 71 78 … … 767 774 void LibWebRTCMediaEndpoint::stop() 768 775 { 776 if (!m_backend) 777 return; 778 769 779 stopLoggingStats(); 770 780 771 ASSERT(m_backend);772 781 m_backend->Close(); 773 782 m_backend = nullptr; -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h
r218973 r218994 63 63 virtual ~LibWebRTCMediaEndpoint() { } 64 64 65 bool setConfiguration(LibWebRTCProvider&, webrtc::PeerConnectionInterface::RTCConfiguration&&); 66 65 67 webrtc::PeerConnectionInterface& backend() const { ASSERT(m_backend); return *m_backend.get(); } 66 68 void doSetLocalDescription(RTCSessionDescription&); -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
r218973 r218994 72 72 } 73 73 74 static inline webrtc::PeerConnectionInterface::BundlePolicy bundlePolicyfromConfiguration(const MediaEndpointConfiguration& configuration) 75 { 76 switch (configuration.bundlePolicy) { 77 case RTCBundlePolicy::MaxCompat: 78 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat; 79 case RTCBundlePolicy::MaxBundle: 80 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle; 81 case RTCBundlePolicy::Balanced: 82 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced; 83 } 84 } 85 86 static inline webrtc::PeerConnectionInterface::IceTransportsType iceTransportPolicyfromConfiguration(const MediaEndpointConfiguration& configuration) 87 { 88 switch (configuration.iceTransportPolicy) { 89 case RTCIceTransportPolicy::Relay: 90 return webrtc::PeerConnectionInterface::kRelay; 91 case RTCIceTransportPolicy::All: 92 return webrtc::PeerConnectionInterface::kAll; 93 } 94 } 95 74 96 static webrtc::PeerConnectionInterface::RTCConfiguration configurationFromMediaEndpointConfiguration(MediaEndpointConfiguration&& configuration) 75 97 { 76 98 webrtc::PeerConnectionInterface::RTCConfiguration rtcConfiguration; 77 99 78 if (configuration.iceTransportPolicy == RTCIceTransportPolicy::Relay) 79 rtcConfiguration.type = webrtc::PeerConnectionInterface::kRelay; 80 81 // FIXME: Support PeerConnectionStates::BundlePolicy::MaxBundle. 82 // LibWebRTC does not like it and will fail to set any configuration field otherwise. 83 // See https://bugs.webkit.org/show_bug.cgi?id=169389. 84 85 if (configuration.bundlePolicy == RTCBundlePolicy::MaxCompat) 86 rtcConfiguration.bundle_policy = webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat; 100 rtcConfiguration.type = iceTransportPolicyfromConfiguration(configuration); 101 rtcConfiguration.bundle_policy = bundlePolicyfromConfiguration(configuration); 87 102 88 103 for (auto& server : configuration.iceServers) { … … 96 111 97 112 rtcConfiguration.set_cpu_adaptation(false); 98 rtcConfiguration.ice_candidate_pool_size = configuration.iceCandidatePoolSize; 113 // FIXME: Activate ice candidate pool size once it no longer bothers test bots. 114 // rtcConfiguration.ice_candidate_pool_size = configuration.iceCandidatePoolSize; 99 115 100 116 return rtcConfiguration; 101 117 } 102 118 103 voidLibWebRTCPeerConnectionBackend::setConfiguration(MediaEndpointConfiguration&& configuration)104 { 105 m_endpoint->backend().SetConfiguration(configurationFromMediaEndpointConfiguration(WTFMove(configuration)));119 bool LibWebRTCPeerConnectionBackend::setConfiguration(MediaEndpointConfiguration&& configuration) 120 { 121 return m_endpoint->setConfiguration(libWebRTCProvider(m_peerConnection), configurationFromMediaEndpointConfiguration(WTFMove(configuration))); 106 122 } 107 123 -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h
r218973 r218994 61 61 void doStop() final; 62 62 std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) final; 63 voidsetConfiguration(MediaEndpointConfiguration&&) final;63 bool setConfiguration(MediaEndpointConfiguration&&) final; 64 64 void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&) final; 65 65 Ref<RTCRtpReceiver> createReceiver(const String& transceiverMid, const String& trackKind, const String& trackId) final; -
trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
r218973 r218994 169 169 } 170 170 171 static rtc::scoped_refptr<webrtc::PeerConnectionInterface> createActualPeerConnection(webrtc::PeerConnectionObserver& observer, std::unique_ptr<cricket::BasicPortAllocator>&& portAllocator )171 static rtc::scoped_refptr<webrtc::PeerConnectionInterface> createActualPeerConnection(webrtc::PeerConnectionObserver& observer, std::unique_ptr<cricket::BasicPortAllocator>&& portAllocator, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration) 172 172 { 173 173 ASSERT(staticFactoryAndThreads().factory); 174 174 175 webrtc::PeerConnectionInterface::RTCConfiguration config; 176 // FIXME: Add a default configuration. 177 return staticFactoryAndThreads().factory->CreatePeerConnection(config, WTFMove(portAllocator), nullptr, &observer); 178 } 179 180 rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer) 175 return staticFactoryAndThreads().factory->CreatePeerConnection(configuration, WTFMove(portAllocator), nullptr, &observer); 176 } 177 178 rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration) 181 179 { 182 180 // Default WK1 implementation. … … 188 186 ASSERT(staticFactoryAndThreads().networkThreadWithSocketServer); 189 187 190 return createActualPeerConnection(observer, nullptr );191 } 192 193 rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, rtc::NetworkManager& networkManager, rtc::PacketSocketFactory& packetSocketFactory )188 return createActualPeerConnection(observer, nullptr, WTFMove(configuration)); 189 } 190 191 rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, rtc::NetworkManager& networkManager, rtc::PacketSocketFactory& packetSocketFactory, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration) 194 192 { 195 193 ASSERT(!staticFactoryAndThreads().networkThreadWithSocketServer); … … 207 205 }); 208 206 209 return createActualPeerConnection(observer, WTFMove(portAllocator) );207 return createActualPeerConnection(observer, WTFMove(portAllocator), WTFMove(configuration)); 210 208 } 211 209 -
trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h
r218973 r218994 53 53 static bool webRTCAvailable(); 54 54 #if USE(LIBWEBRTC) 55 WEBCORE_EXPORT virtual rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver& );55 WEBCORE_EXPORT virtual rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&, webrtc::PeerConnectionInterface::RTCConfiguration&&); 56 56 57 57 WEBCORE_EXPORT webrtc::PeerConnectionFactoryInterface* factory(); … … 70 70 71 71 protected: 72 WEBCORE_EXPORT rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&, rtc::NetworkManager&, rtc::PacketSocketFactory& );72 WEBCORE_EXPORT rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&, rtc::NetworkManager&, rtc::PacketSocketFactory&, webrtc::PeerConnectionInterface::RTCConfiguration&&); 73 73 74 74 bool m_enableEnumeratingAllNetworkInterfaces { false }; -
trunk/Source/WebKit2/ChangeLog
r218985 r218994 1 2017-06-30 Youenn Fablet <youenn@apple.com> 2 3 Support PeerConnectionStates::BundlePolicy::MaxBundle when setting rtc configuration 4 https://bugs.webkit.org/show_bug.cgi?id=169389 5 6 Reviewed by Alex Christensen. 7 8 * fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt: 9 1 10 2017-06-29 Ryosuke Niwa <rniwa@webkit.org> 2 11 -
trunk/Source/WebKit2/WebProcess/Network/webrtc/LibWebRTCProvider.cpp
r218973 r218994 35 35 namespace WebKit { 36 36 37 rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer )37 rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration) 38 38 { 39 return WebCore::LibWebRTCProvider::createPeerConnection(observer, WebProcess::singleton().libWebRTCNetwork().monitor(), WebProcess::singleton().libWebRTCNetwork().socketFactory() );39 return WebCore::LibWebRTCProvider::createPeerConnection(observer, WebProcess::singleton().libWebRTCNetwork().monitor(), WebProcess::singleton().libWebRTCNetwork().socketFactory(), WTFMove(configuration)); 40 40 } 41 41 -
trunk/Source/WebKit2/WebProcess/Network/webrtc/LibWebRTCProvider.h
r218973 r218994 37 37 38 38 private: 39 rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver& ) final;39 rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&, webrtc::PeerConnectionInterface::RTCConfiguration&&) final; 40 40 }; 41 41 #else
Note: See TracChangeset
for help on using the changeset viewer.