Changeset 201920 in webkit


Ignore:
Timestamp:
Jun 10, 2016 2:15:07 AM (8 years ago)
Author:
adam.bergkvist@ericsson.com
Message:

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

Reviewed by Eric Carlson.

Source/WebCore:

Add the MediaEndpointPeerConnection implementation of RTCPeerConnection.createAnswer [1].
createAnswer() creates a 'reply' to an remote offer set with setRemoteDescription(),
completes the offer/answer dialog and brings the RTCPeerConnection back to the 'stable'
signaling state.

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

Test: fast/mediastream/RTCPeerConnection-inspect-answer.html

  • Modules/mediastream/MediaEndpointPeerConnection.cpp:

(WebCore::MediaEndpointPeerConnection::createOfferTask):
Align creation of RTCSessionDescription with createAnswerTask.
(WebCore::MediaEndpointPeerConnection::createAnswer):
(WebCore::MediaEndpointPeerConnection::createAnswerTask):
Add Implementation.

  • Modules/mediastream/MediaEndpointPeerConnection.h:

LayoutTests:

Add test for RTCPeerConnection.createAnswer.

  • fast/mediastream/RTCPeerConnection-inspect-answer-expected.txt: Added.
  • fast/mediastream/RTCPeerConnection-inspect-answer.html: Added.

Generate two answers, one with audio only and a second with audio and video, and inspect
the result.

  • platform/mac/TestExpectations:

Skip tests for mac that require building with WEB_RTC enabled.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r201919 r201920  
     12016-06-10  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Imlement MediaEndpointPeerConnection::createAnswer()
     4        https://bugs.webkit.org/show_bug.cgi?id=158566
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add test for RTCPeerConnection.createAnswer.
     9
     10        * fast/mediastream/RTCPeerConnection-inspect-answer-expected.txt: Added.
     11        * fast/mediastream/RTCPeerConnection-inspect-answer.html: Added.
     12        Generate two answers, one with audio only and a second with audio and video, and inspect
     13        the result.
     14        * platform/mac/TestExpectations:
     15        Skip tests for mac that require building with WEB_RTC enabled.
     16
    1172016-06-08  Sergio Villar Senin  <svillar@igalia.com>
    218
  • trunk/LayoutTests/platform/mac/TestExpectations

    r201902 r201920  
    194194fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html
    195195fast/mediastream/RTCTrackEvent-constructor.html
     196fast/mediastream/RTCPeerConnection-inspect-answer.html
    196197
    197198# Asserts in debug.
  • trunk/Source/WebCore/ChangeLog

    r201919 r201920  
     12016-06-10  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Imlement MediaEndpointPeerConnection::createAnswer()
     4        https://bugs.webkit.org/show_bug.cgi?id=158566
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add the MediaEndpointPeerConnection implementation of RTCPeerConnection.createAnswer [1].
     9        createAnswer() creates a 'reply' to an remote offer set with setRemoteDescription(),
     10        completes the offer/answer dialog and brings the RTCPeerConnection back to the 'stable'
     11        signaling state.
     12
     13        [1] https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#dom-rtcpeerconnection-createanswer
     14
     15        Test: fast/mediastream/RTCPeerConnection-inspect-answer.html
     16
     17        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
     18        (WebCore::MediaEndpointPeerConnection::createOfferTask):
     19        Align creation of RTCSessionDescription with createAnswerTask.
     20        (WebCore::MediaEndpointPeerConnection::createAnswer):
     21        (WebCore::MediaEndpointPeerConnection::createAnswerTask):
     22        Add Implementation.
     23        * Modules/mediastream/MediaEndpointPeerConnection.h:
     24
    1252016-06-08  Sergio Villar Senin  <svillar@igalia.com>
    226
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp

    r201851 r201920  
    192192    }
    193193
    194     String sdpString;
    195     SDPProcessor::Result result = m_sdpProcessor->generate(*configurationSnapshot, sdpString);
    196     if (result != SDPProcessor::Result::Success) {
    197         LOG_ERROR("SDPProcessor internal error");
    198         return;
    199     }
    200 
    201     promise.resolve(RTCSessionDescription::create(RTCSessionDescription::SdpType::Offer, sdpString));
     194    auto description = MediaEndpointSessionDescription::create(RTCSessionDescription::SdpType::Offer, WTFMove(configurationSnapshot));
     195    promise.resolve(*description->toRTCSessionDescription(*m_sdpProcessor));
    202196}
    203197
    204198void MediaEndpointPeerConnection::createAnswer(RTCAnswerOptions& options, SessionDescriptionPromise&& promise)
    205199{
    206     UNUSED_PARAM(options);
    207 
    208     notImplemented();
    209 
    210     promise.reject(NOT_SUPPORTED_ERR);
     200    runTask([this, protectedOptions = RefPtr<RTCAnswerOptions>(&options), protectedPromise = WTFMove(promise)]() mutable {
     201        createAnswerTask(*protectedOptions, protectedPromise);
     202    });
     203}
     204
     205void MediaEndpointPeerConnection::createAnswerTask(RTCAnswerOptions&, SessionDescriptionPromise& promise)
     206{
     207    ASSERT(!m_dtlsFingerprint.isEmpty());
     208
     209    if (m_client->internalSignalingState() == SignalingState::Closed)
     210        return;
     211
     212    if (!internalRemoteDescription()) {
     213        promise.reject(INVALID_STATE_ERR, "No remote description set");
     214        return;
     215    }
     216
     217    MediaEndpointSessionDescription* localDescription = internalLocalDescription();
     218    RefPtr<MediaEndpointSessionConfiguration> configurationSnapshot = localDescription ?
     219        localDescription->configuration()->clone() : MediaEndpointSessionConfiguration::create();
     220
     221    configurationSnapshot->setSessionVersion(m_sdpAnswerSessionVersion++);
     222
     223    auto transceivers = RtpTransceiverVector(m_client->getTransceivers());
     224    const MediaDescriptionVector& remoteMediaDescriptions = internalRemoteDescription()->configuration()->mediaDescriptions();
     225
     226    for (unsigned i = 0; i < remoteMediaDescriptions.size(); ++i) {
     227        PeerMediaDescription& remoteMediaDescription = *remoteMediaDescriptions[i];
     228
     229        RTCRtpTransceiver* transceiver = matchTransceiverByMid(transceivers, remoteMediaDescription.mid());
     230        if (!transceiver) {
     231            LOG_ERROR("Could not find a matching transceiver for remote description while creating answer");
     232            continue;
     233        }
     234
     235        if (i >= configurationSnapshot->mediaDescriptions().size()) {
     236            auto newMediaDescription = PeerMediaDescription::create();
     237
     238            RTCRtpSender& sender = *transceiver->sender();
     239            if (sender.track()) {
     240                if (sender.mediaStreamIds().size())
     241                    newMediaDescription->setMediaStreamId(sender.mediaStreamIds()[0]);
     242                newMediaDescription->setMediaStreamTrackId(sender.trackId());
     243                newMediaDescription->addSsrc(cryptographicallyRandomNumber());
     244            }
     245
     246            newMediaDescription->setMode(transceiver->directionString());
     247            newMediaDescription->setType(remoteMediaDescription.type());
     248            newMediaDescription->setMid(remoteMediaDescription.mid());
     249            newMediaDescription->setDtlsSetup(remoteMediaDescription.dtlsSetup() == "active" ? "passive" : "active");
     250            newMediaDescription->setDtlsFingerprintHashFunction(m_dtlsFingerprintFunction);
     251            newMediaDescription->setDtlsFingerprint(m_dtlsFingerprint);
     252            newMediaDescription->setCname(m_cname);
     253            newMediaDescription->setIceUfrag(m_iceUfrag);
     254            newMediaDescription->setIcePassword(m_icePassword);
     255
     256            configurationSnapshot->addMediaDescription(WTFMove(newMediaDescription));
     257        }
     258
     259        PeerMediaDescription& localMediaDescription = *configurationSnapshot->mediaDescriptions()[i];
     260
     261        localMediaDescription.setPayloads(remoteMediaDescription.payloads());
     262        localMediaDescription.setRtcpMux(remoteMediaDescription.rtcpMux());
     263
     264        if (!localMediaDescription.ssrcs().size())
     265            localMediaDescription.addSsrc(cryptographicallyRandomNumber());
     266
     267        if (localMediaDescription.dtlsSetup() == "actpass")
     268            localMediaDescription.setDtlsSetup("passive");
     269
     270        transceivers.removeFirst(transceiver);
     271    }
     272
     273    // Unassociated (non-stopped) transceivers need to be negotiated in a follow-up offer.
     274    if (hasUnassociatedTransceivers(transceivers))
     275        markAsNeedingNegotiation();
     276
     277    auto description = MediaEndpointSessionDescription::create(RTCSessionDescription::SdpType::Answer, WTFMove(configurationSnapshot));
     278    promise.resolve(*description->toRTCSessionDescription(*m_sdpProcessor));
    211279}
    212280
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h

    r201851 r201920  
    8888
    8989    void createOfferTask(RTCOfferOptions&, PeerConnection::SessionDescriptionPromise&);
     90    void createAnswerTask(RTCAnswerOptions&, PeerConnection::SessionDescriptionPromise&);
    9091
    9192    void setLocalDescriptionTask(RefPtr<RTCSessionDescription>&&, PeerConnection::VoidPromise&);
     
    121122    String m_dtlsFingerprintFunction;
    122123    unsigned m_sdpOfferSessionVersion { 0 };
     124    unsigned m_sdpAnswerSessionVersion { 0 };
    123125
    124126    RefPtr<MediaEndpointSessionDescription> m_currentLocalDescription;
Note: See TracChangeset for help on using the changeset viewer.