Changeset 218994 in webkit


Ignore:
Timestamp:
Jun 30, 2017 8:00:43 AM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore:

Support PeerConnectionStates::BundlePolicy::MaxBundle when setting rtc configuration
https://bugs.webkit.org/show_bug.cgi?id=169389

Reviewed by Alex Christensen.

Covered by manual testing (appr.tc and https://youennf.github.io/webrtc-tests/src/content/peerconnection/trickle-ice/).
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

underlying libwebrtc backend.

Previously, we were creating a libwebrtc peer connection and then setting its configuration.
libwebrtc does not like the configuration to be changed and may refuse to set the configuration.
Instead of doing that, we are now creating the libwebrtc peer connection with the provided configuration.

ICE candidate pool size is disabled as it is creating issues with running tests on bots.

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-30

  • Modules/mediastream/MediaEndpointPeerConnection.cpp:

(WebCore::MediaEndpointPeerConnection::setConfiguration):

  • Modules/mediastream/MediaEndpointPeerConnection.h:
  • Modules/mediastream/PeerConnectionBackend.h:
  • Modules/mediastream/RTCPeerConnection.cpp:

(WebCore::RTCPeerConnection::initializeWith):
(WebCore::iceServersFromConfiguration):
(WebCore::RTCPeerConnection::initializeConfiguration):
(WebCore::RTCPeerConnection::setConfiguration):

  • Modules/mediastream/RTCPeerConnection.h:
  • Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:

(WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
(WebCore::LibWebRTCMediaEndpoint::setConfiguration):
(WebCore::LibWebRTCMediaEndpoint::stop):

  • Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
  • Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:

(WebCore::configurationFromMediaEndpointConfiguration):
(WebCore::LibWebRTCPeerConnectionBackend::setConfiguration):

  • Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
  • platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:

(WebCore::createActualPeerConnection):
(WebCore::LibWebRTCProvider::createPeerConnection):

  • platform/mediastream/libwebrtc/LibWebRTCProvider.h:

Source/WebKit2:
Support PeerConnectionStates::BundlePolicy::MaxBundle when setting rtc configuration
https://bugs.webkit.org/show_bug.cgi?id=169389

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-30
Reviewed by Alex Christensen.

  • fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt:
Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r218991 r218994  
     12017-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
    1432017-06-30  Antoine Quint  <graouts@apple.com>
    244
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp

    r218973 r218994  
    603603}
    604604
    605 void MediaEndpointPeerConnection::setConfiguration(MediaEndpointConfiguration&& configuration)
     605bool MediaEndpointPeerConnection::setConfiguration(MediaEndpointConfiguration&& configuration)
    606606{
    607607    m_mediaEndpoint->setConfiguration(WTFMove(configuration));
     608    return true;
    608609}
    609610
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h

    r218973 r218994  
    5757    RefPtr<RTCSessionDescription> pendingRemoteDescription() const final;
    5858
    59     void setConfiguration(MediaEndpointConfiguration&&) final;
     59    bool setConfiguration(MediaEndpointConfiguration&&) final;
    6060
    6161    void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&) final;
  • trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h

    r218973 r218994  
    8989    virtual RefPtr<RTCSessionDescription> pendingRemoteDescription() const = 0;
    9090
    91     virtual void setConfiguration(MediaEndpointConfiguration&&) = 0;
     91    virtual bool setConfiguration(MediaEndpointConfiguration&&) = 0;
    9292
    9393    virtual void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&) = 0;
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

    r218973 r218994  
    9898        return Exception { NOT_SUPPORTED_ERR };
    9999
    100     return setConfiguration(WTFMove(configuration));
     100    return initializeConfiguration(WTFMove(configuration));
    101101}
    102102
     
    299299}
    300300
    301 ExceptionOr<void> RTCPeerConnection::setConfiguration(RTCConfiguration&& configuration)
    302 {
    303     if (isClosed())
    304         return Exception { INVALID_STATE_ERR };
    305 
     301static inline std::optional<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& configuration)
     302{
    306303    Vector<MediaEndpointConfiguration::IceServerInfo> servers;
    307304    if (configuration.iceServers) {
     
    309306        for (auto& server : configuration.iceServers.value()) {
    310307            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)
    314314                    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            });
    322316            for (auto& serverURL : serverURLs) {
    323317                if (!(serverURL.protocolIs("turn") || serverURL.protocolIs("turns") || serverURL.protocolIs("stun")))
    324                     return Exception { INVALID_ACCESS_ERR };
     318                    return std::nullopt;
    325319            }
    326320            servers.uncheckedAppend({ WTFMove(serverURLs), server.credential, server.username });
    327321        }
    328322    }
    329 
    330     m_backend->setConfiguration({ WTFMove(servers), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize });
     323    return servers;
     324}
     325
     326ExceptionOr<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
     340ExceptionOr<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 });
    331352    m_configuration = WTFMove(configuration);
    332353    return { };
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h

    r218973 r218994  
    154154    RTCPeerConnection(ScriptExecutionContext&);
    155155
     156    ExceptionOr<void> initializeConfiguration(RTCConfiguration&&);
    156157    Ref<RTCRtpTransceiver> completeAddTransceiver(Ref<RTCRtpSender>&&, const RTCRtpTransceiverInit&, const String& trackId, const String& trackKind);
    157158
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp

    r218973 r218994  
    6060    : m_peerConnectionBackend(peerConnection)
    6161    , m_peerConnectionFactory(*client.factory())
    62     , m_backend(client.createPeerConnection(*this))
    6362    , m_createSessionDescriptionObserver(*this)
    6463    , m_setLocalSessionDescriptionObserver(*this)
     
    6665    , m_statsLogTimer(*this, &LibWebRTCMediaEndpoint::gatherStatsForLogging)
    6766{
    68     ASSERT(m_backend);
    6967    ASSERT(client.factory());
     68}
     69
     70bool 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));
    7077}
    7178
     
    767774void LibWebRTCMediaEndpoint::stop()
    768775{
     776    if (!m_backend)
     777        return;
     778
    769779    stopLoggingStats();
    770780
    771     ASSERT(m_backend);
    772781    m_backend->Close();
    773782    m_backend = nullptr;
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h

    r218973 r218994  
    6363    virtual ~LibWebRTCMediaEndpoint() { }
    6464
     65    bool setConfiguration(LibWebRTCProvider&, webrtc::PeerConnectionInterface::RTCConfiguration&&);
     66
    6567    webrtc::PeerConnectionInterface& backend() const { ASSERT(m_backend); return *m_backend.get(); }
    6668    void doSetLocalDescription(RTCSessionDescription&);
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp

    r218973 r218994  
    7272}
    7373
     74static 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
     86static 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
    7496static webrtc::PeerConnectionInterface::RTCConfiguration configurationFromMediaEndpointConfiguration(MediaEndpointConfiguration&& configuration)
    7597{
    7698    webrtc::PeerConnectionInterface::RTCConfiguration rtcConfiguration;
    7799
    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);
    87102
    88103    for (auto& server : configuration.iceServers) {
     
    96111
    97112    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;
    99115
    100116    return rtcConfiguration;
    101117}
    102118
    103 void LibWebRTCPeerConnectionBackend::setConfiguration(MediaEndpointConfiguration&& configuration)
    104 {
    105     m_endpoint->backend().SetConfiguration(configurationFromMediaEndpointConfiguration(WTFMove(configuration)));
     119bool LibWebRTCPeerConnectionBackend::setConfiguration(MediaEndpointConfiguration&& configuration)
     120{
     121    return m_endpoint->setConfiguration(libWebRTCProvider(m_peerConnection), configurationFromMediaEndpointConfiguration(WTFMove(configuration)));
    106122}
    107123
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h

    r218973 r218994  
    6161    void doStop() final;
    6262    std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) final;
    63     void setConfiguration(MediaEndpointConfiguration&&) final;
     63    bool setConfiguration(MediaEndpointConfiguration&&) final;
    6464    void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&) final;
    6565    Ref<RTCRtpReceiver> createReceiver(const String& transceiverMid, const String& trackKind, const String& trackId) final;
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp

    r218973 r218994  
    169169}
    170170
    171 static rtc::scoped_refptr<webrtc::PeerConnectionInterface> createActualPeerConnection(webrtc::PeerConnectionObserver& observer, std::unique_ptr<cricket::BasicPortAllocator>&& portAllocator)
     171static rtc::scoped_refptr<webrtc::PeerConnectionInterface> createActualPeerConnection(webrtc::PeerConnectionObserver& observer, std::unique_ptr<cricket::BasicPortAllocator>&& portAllocator, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration)
    172172{
    173173    ASSERT(staticFactoryAndThreads().factory);
    174174
    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
     178rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration)
    181179{
    182180    // Default WK1 implementation.
     
    188186    ASSERT(staticFactoryAndThreads().networkThreadWithSocketServer);
    189187
    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
     191rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, rtc::NetworkManager& networkManager, rtc::PacketSocketFactory& packetSocketFactory, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration)
    194192{
    195193    ASSERT(!staticFactoryAndThreads().networkThreadWithSocketServer);
     
    207205    });
    208206
    209     return createActualPeerConnection(observer, WTFMove(portAllocator));
     207    return createActualPeerConnection(observer, WTFMove(portAllocator), WTFMove(configuration));
    210208}
    211209
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h

    r218973 r218994  
    5353    static bool webRTCAvailable();
    5454#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&&);
    5656
    5757    WEBCORE_EXPORT webrtc::PeerConnectionFactoryInterface* factory();
     
    7070
    7171protected:
    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&&);
    7373
    7474    bool m_enableEnumeratingAllNetworkInterfaces { false };
  • trunk/Source/WebKit2/ChangeLog

    r218985 r218994  
     12017-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
    1102017-06-29  Ryosuke Niwa  <rniwa@webkit.org>
    211
  • trunk/Source/WebKit2/WebProcess/Network/webrtc/LibWebRTCProvider.cpp

    r218973 r218994  
    3535namespace WebKit {
    3636
    37 rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer)
     37rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration)
    3838{
    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));
    4040}
    4141
  • trunk/Source/WebKit2/WebProcess/Network/webrtc/LibWebRTCProvider.h

    r218973 r218994  
    3737
    3838private:
    39     rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&) final;
     39    rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&, webrtc::PeerConnectionInterface::RTCConfiguration&&) final;
    4040};
    4141#else
Note: See TracChangeset for help on using the changeset viewer.