Changeset 202048 in webkit


Ignore:
Timestamp:
Jun 14, 2016 9:41:18 AM (8 years ago)
Author:
adam.bergkvist@ericsson.com
Message:

WebRTC: Imlement MediaEndpointPeerConnection::addIceCandidate()
https://bugs.webkit.org/show_bug.cgi?id=158690

Reviewed by Eric Carlson.

Source/WebCore:

Implement MediaEndpointPeerConnection::addIceCandidate() that is the MediaEndpoint
implementation of RTCPeerConnection.addIceCandidate() [1].

[1] https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#dom-peerconnection-addicecandidate

Test: fast/mediastream/RTCPeerConnection-addIceCandidate.html

  • Modules/mediastream/MediaEndpointPeerConnection.cpp:

(WebCore::MediaEndpointPeerConnection::addIceCandidate):
(WebCore::MediaEndpointPeerConnection::addIceCandidateTask):
Implemented.

  • Modules/mediastream/MediaEndpointPeerConnection.h:
  • platform/mediastream/MediaEndpoint.h:

Use mid instead of mdescIndex to identify the target media description in the backend.

  • platform/mock/MockMediaEndpoint.cpp:

Update mock method signature accordingly.
(WebCore::MockMediaEndpoint::addRemoteCandidate):

  • platform/mock/MockMediaEndpoint.h:

LayoutTests:

Add test for RTCPeerConnection.addIceCandidate() that verifies:

  • Candidate line parsing
  • That a underlying media description can be identified using either sdpMid or sdpMLineIndex
  • That sdpMid takes precedence over sdpMLineIndex
  • fast/mediastream/RTCPeerConnection-addIceCandidate-expected.txt: Added.
  • fast/mediastream/RTCPeerConnection-addIceCandidate.html: Added.
  • platform/mac/TestExpectations:

The mac port is not building with WEB_RTC yet.

Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202043 r202048  
     12016-06-14  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Imlement MediaEndpointPeerConnection::addIceCandidate()
     4        https://bugs.webkit.org/show_bug.cgi?id=158690
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add test for RTCPeerConnection.addIceCandidate() that verifies:
     9        - Candidate line parsing
     10        - That a underlying media description can be identified using either sdpMid or sdpMLineIndex
     11        - That sdpMid takes precedence over sdpMLineIndex
     12
     13        * fast/mediastream/RTCPeerConnection-addIceCandidate-expected.txt: Added.
     14        * fast/mediastream/RTCPeerConnection-addIceCandidate.html: Added.
     15        * platform/mac/TestExpectations:
     16        The mac port is not building with WEB_RTC yet.
     17
    1182016-06-14  Adam Bergkvist  <adam.bergkvist@ericsson.com>
    219
  • trunk/LayoutTests/platform/mac/TestExpectations

    r202043 r202048  
    176176fast/mediastream/RTCPeerConnection-have-remote-pranswer.html
    177177fast/mediastream/RTCPeerConnection-ice.html
     178fast/mediastream/RTCPeerConnection-addIceCandidate.html
    178179fast/mediastream/RTCPeerConnection-localDescription.html
    179180fast/mediastream/RTCPeerConnection-onnegotiationneeded.html
  • trunk/Source/WebCore/ChangeLog

    r202044 r202048  
     12016-06-14  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Imlement MediaEndpointPeerConnection::addIceCandidate()
     4        https://bugs.webkit.org/show_bug.cgi?id=158690
     5
     6        Reviewed by Eric Carlson.
     7
     8        Implement MediaEndpointPeerConnection::addIceCandidate() that is the MediaEndpoint
     9        implementation of RTCPeerConnection.addIceCandidate() [1].
     10
     11        [1] https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#dom-peerconnection-addicecandidate
     12
     13        Test: fast/mediastream/RTCPeerConnection-addIceCandidate.html
     14
     15        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
     16        (WebCore::MediaEndpointPeerConnection::addIceCandidate):
     17        (WebCore::MediaEndpointPeerConnection::addIceCandidateTask):
     18        Implemented.
     19        * Modules/mediastream/MediaEndpointPeerConnection.h:
     20        * platform/mediastream/MediaEndpoint.h:
     21        Use mid instead of mdescIndex to identify the target media description in the backend.
     22        * platform/mock/MockMediaEndpoint.cpp:
     23        Update mock method signature accordingly.
     24        (WebCore::MockMediaEndpoint::addRemoteCandidate):
     25        * platform/mock/MockMediaEndpoint.h:
     26
    1272016-06-14  Zalan Bujtas  <zalan@apple.com>
    228
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp

    r202026 r202048  
    3939#include "MediaStreamTrack.h"
    4040#include "PeerMediaDescription.h"
     41#include "RTCIceCandidate.h"
    4142#include "RTCOfferAnswerOptions.h"
    4243#include "RTCRtpTransceiver.h"
     
    600601void MediaEndpointPeerConnection::addIceCandidate(RTCIceCandidate& rtcCandidate, PeerConnection::VoidPromise&& promise)
    601602{
    602     UNUSED_PARAM(rtcCandidate);
    603 
    604     notImplemented();
    605 
    606     promise.reject(NOT_SUPPORTED_ERR);
     603    runTask([this, protectedCandidate = RefPtr<RTCIceCandidate>(&rtcCandidate), protectedPromise = WTFMove(promise)]() mutable {
     604        addIceCandidateTask(*protectedCandidate, protectedPromise);
     605    });
     606}
     607
     608void MediaEndpointPeerConnection::addIceCandidateTask(RTCIceCandidate& rtcCandidate, PeerConnection::VoidPromise& promise)
     609{
     610    if (m_client->internalSignalingState() == SignalingState::Closed)
     611        return;
     612
     613    if (!internalRemoteDescription()) {
     614        promise.reject(INVALID_STATE_ERR, "No remote description set");
     615        return;
     616    }
     617
     618    const MediaDescriptionVector& remoteMediaDescriptions = internalRemoteDescription()->configuration()->mediaDescriptions();
     619    PeerMediaDescription* targetMediaDescription = nullptr;
     620
     621    // When identifying the target media description, sdpMid takes precedence over sdpMLineIndex
     622    // if both are present.
     623    if (!rtcCandidate.sdpMid().isNull()) {
     624        const String& mid = rtcCandidate.sdpMid();
     625        for (auto& description : remoteMediaDescriptions) {
     626            if (description->mid() == mid) {
     627                targetMediaDescription = description.get();
     628                break;
     629            }
     630        }
     631
     632        if (!targetMediaDescription) {
     633            promise.reject(OperationError, "sdpMid did not match any media description");
     634            return;
     635        }
     636    } else if (rtcCandidate.sdpMLineIndex()) {
     637        unsigned short sdpMLineIndex = rtcCandidate.sdpMLineIndex().value();
     638        if (sdpMLineIndex >= remoteMediaDescriptions.size()) {
     639            promise.reject(OperationError, "sdpMLineIndex is out of range");
     640            return;
     641        }
     642        targetMediaDescription = remoteMediaDescriptions[sdpMLineIndex].get();
     643    } else {
     644        ASSERT_NOT_REACHED();
     645        return;
     646    }
     647
     648    RefPtr<IceCandidate> candidate;
     649    SDPProcessor::Result result = m_sdpProcessor->parseCandidateLine(rtcCandidate.candidate(), candidate);
     650    if (result != SDPProcessor::Result::Success) {
     651        if (result == SDPProcessor::Result::ParseError)
     652            promise.reject(OperationError, "Invalid candidate content");
     653        else
     654            LOG_ERROR("SDPProcessor internal error");
     655        return;
     656    }
     657
     658    targetMediaDescription->addIceCandidate(candidate.copyRef());
     659
     660    m_mediaEndpoint->addRemoteCandidate(*candidate, targetMediaDescription->mid(), targetMediaDescription->iceUfrag(),
     661        targetMediaDescription->icePassword());
     662
     663    promise.resolve(nullptr);
    607664}
    608665
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h

    r202026 r202048  
    9393    void setRemoteDescriptionTask(RefPtr<RTCSessionDescription>&&, PeerConnection::VoidPromise&);
    9494
     95    void addIceCandidateTask(RTCIceCandidate&, PeerConnection::VoidPromise&);
     96
    9597    void replaceTrackTask(RTCRtpSender&, const String& mid, RefPtr<MediaStreamTrack>&&, PeerConnection::VoidPromise&);
    9698
  • trunk/Source/WebCore/platform/mediastream/MediaEndpoint.h

    r202026 r202048  
    8181    virtual UpdateResult updateSendConfiguration(MediaEndpointSessionConfiguration*, const RealtimeMediaSourceMap&, bool isInitiator) = 0;
    8282
    83     virtual void addRemoteCandidate(IceCandidate&, unsigned mdescIndex, const String& ufrag, const String& password) = 0;
     83    virtual void addRemoteCandidate(IceCandidate&, const String& mid, const String& ufrag, const String& password) = 0;
    8484
    8585    virtual Ref<RealtimeMediaSource> createMutedRemoteSource(const String& mid, RealtimeMediaSource::Type) = 0;
  • trunk/Source/WebCore/platform/mock/MockMediaEndpoint.cpp

    r202026 r202048  
    174174}
    175175
    176 void MockMediaEndpoint::addRemoteCandidate(IceCandidate& candidate, unsigned mdescIndex, const String& ufrag, const String& password)
     176void MockMediaEndpoint::addRemoteCandidate(IceCandidate& candidate, const String& mid, const String& ufrag, const String& password)
    177177{
    178178    UNUSED_PARAM(candidate);
    179     UNUSED_PARAM(mdescIndex);
     179    UNUSED_PARAM(mid);
    180180    UNUSED_PARAM(ufrag);
    181181    UNUSED_PARAM(password);
  • trunk/Source/WebCore/platform/mock/MockMediaEndpoint.h

    r202026 r202048  
    5555    UpdateResult updateSendConfiguration(MediaEndpointSessionConfiguration*, const RealtimeMediaSourceMap&, bool isInitiator) override;
    5656
    57     void addRemoteCandidate(IceCandidate&, unsigned mdescIndex, const String& ufrag, const String& password) override;
     57    void addRemoteCandidate(IceCandidate&, const String& mid, const String& ufrag, const String& password) override;
    5858
    5959    Ref<RealtimeMediaSource> createMutedRemoteSource(const String& mid, RealtimeMediaSource::Type) override;
Note: See TracChangeset for help on using the changeset viewer.