Changeset 198325 in webkit


Ignore:
Timestamp:
Mar 17, 2016 3:52:20 AM (8 years ago)
Author:
adam.bergkvist@ericsson.com
Message:

WebRTC: Update RTCIceCandidate
https://bugs.webkit.org/show_bug.cgi?id=155535

Reviewed by Eric Carlson.

Source/WebCore:

Update the RTCIceCandidate constructor procedure to match the WebRTC 1.0 specification [1].
In short: The "candidate" init dictionary member is required. At least one of the dictionary
members "sdpMid" and "sdpMLine" needs to be present; the corresponding attribute of the
other, is initialized to null.

[1] https://w3c.github.io/webrtc-pc/archives/20160215/webrtc.html

Tests: Updated fast/mediastream/RTCIceCandidate.htm

  • Modules/mediastream/RTCIceCandidate.cpp:

(WebCore::RTCIceCandidate::create):
(WebCore::RTCIceCandidate::RTCIceCandidate):

  • Modules/mediastream/RTCIceCandidate.h:

(WebCore::RTCIceCandidate::sdpMLineIndex):
(WebCore::RTCIceCandidate::setSdpMLineIndex):

  • Modules/mediastream/RTCIceCandidate.idl:
  • bindings/js/JSRTCIceCandidateCustom.cpp:

(WebCore::JSRTCIceCandidate::sdpMid):
(WebCore::JSRTCIceCandidate::sdpMLineIndex):

LayoutTests:

RTCIceCandidate.html is updated to test the new construction behavior and the nullable
attributes. The remaining updated tests simply construct an RTCIceCandidate to be used for
test purposes.

  • fast/mediastream/RTCIceCandidate-expected.txt:
  • fast/mediastream/RTCIceCandidate.html:
  • fast/mediastream/RTCPeerConnection-closed-state.html:
  • fast/mediastream/RTCPeerConnection-overloaded-operations-expected.txt:
  • fast/mediastream/RTCPeerConnection-overloaded-operations-params-expected.txt:
  • fast/mediastream/RTCPeerConnection-overloaded-operations-params.html:
  • fast/mediastream/RTCPeerConnection-overloaded-operations.html:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r198324 r198325  
     12016-03-17  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Update RTCIceCandidate
     4        https://bugs.webkit.org/show_bug.cgi?id=155535
     5
     6        Reviewed by Eric Carlson.
     7
     8        RTCIceCandidate.html is updated to test the new construction behavior and the nullable
     9        attributes. The remaining updated tests simply construct an RTCIceCandidate to be used for
     10        test purposes.
     11
     12        * fast/mediastream/RTCIceCandidate-expected.txt:
     13        * fast/mediastream/RTCIceCandidate.html:
     14        * fast/mediastream/RTCPeerConnection-closed-state.html:
     15        * fast/mediastream/RTCPeerConnection-overloaded-operations-expected.txt:
     16        * fast/mediastream/RTCPeerConnection-overloaded-operations-params-expected.txt:
     17        * fast/mediastream/RTCPeerConnection-overloaded-operations-params.html:
     18        * fast/mediastream/RTCPeerConnection-overloaded-operations.html:
     19
    1202016-03-17  Skachkov Oleksandr  <gskachkov@gmail.com>
    221
  • trunk/LayoutTests/fast/mediastream/RTCIceCandidate-expected.txt

    r164941 r198325  
    88PASS candidate.sdpMid is "bar"
    99PASS candidate.sdpMLineIndex is 6
    10 PASS new RTCIceCandidate({}); did not throw exception.
    11 PASS new RTCIceCandidate({candidate:"foo"}); did not throw exception.
    12 PASS new RTCIceCandidate({sdpMid:"bar"}); did not throw exception.
    13 PASS new RTCIceCandidate({sdpMLineIndex:6}); did not throw exception.
    14 PASS new RTCIceCandidate({candidate:"foo", sdpMid:"bar", sdpMLineIndex:"a"}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    15 PASS new RTCIceCandidate({sdpMid:"bar", sdpMLineIndex:"a"}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    16 PASS new RTCIceCandidate({candidate:"foo", sdpMLineIndex:"a"}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    17 PASS new RTCIceCandidate({sdpMLineIndex:"a"}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    18 PASS new RTCIceCandidate({candidate:"", sdpMid:"bar", sdpMLineIndex:6}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    19 PASS new RTCIceCandidate({candidate:"", sdpMLineIndex:6}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    20 PASS new RTCIceCandidate({candidate:"", sdpMid:"bar"}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    21 PASS new RTCIceCandidate({candidate:""}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    22 PASS new RTCIceCandidate({candidate:"foo", sdpMid:"", sdpMLineIndex:6}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    23 PASS new RTCIceCandidate({sdpMid:"", sdpMLineIndex:6}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    24 PASS new RTCIceCandidate({candidate:"foo", sdpMid:""}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    25 PASS new RTCIceCandidate({sdpMid:""}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
    26 PASS new RTCIceCandidate({candidate:"", sdpMid:"", sdpMLineIndex:"a"}); threw exception TypeError: Invalid RTCIceCandidate constructor arguments.
     10
     11Dictionary member 'candidate' is required.
     12PASS new RTCIceCandidate({}); threw exception TypeError: Error creating RTCIceCandidate.
     13PASS new RTCIceCandidate({sdpMid:"bar", sdpMLineIndex:6}); threw exception TypeError: Error creating RTCIceCandidate.
     14PASS new RTCIceCandidate({sdpMid:"bar"}); threw exception TypeError: Error creating RTCIceCandidate.
     15PASS new RTCIceCandidate({sdpMLineIndex:6}); threw exception TypeError: Error creating RTCIceCandidate.
     16
     17One of the 'sdpMid' or 'sdpMLineIndex' members must be present.
     18PASS new RTCIceCandidate({candidate:"foo"}); threw exception TypeError: Error creating RTCIceCandidate.
     19
     20When one of the 'sdpMid' or 'sdpMLineIndex' members is set, the other must be null.
     21PASS candidate = new RTCIceCandidate({candidate:"foo", sdpMid:"bar"}); did not throw exception.
     22PASS candidate.sdpMid is "bar"
     23PASS candidate.sdpMLineIndex is null
     24PASS candidate = new RTCIceCandidate({candidate:"foo", sdpMLineIndex:6}); did not throw exception.
     25PASS candidate.sdpMid is null
     26PASS candidate.sdpMLineIndex is 6
     27
     28Some bad input
     29PASS new RTCIceCandidate({candidate:"foo", sdpMLineIndex:"a"}); threw exception TypeError: Error creating RTCIceCandidate.
     30PASS new RTCIceCandidate({candidate:"foo", sdpMLineIndex:-1}); threw exception TypeError: Error creating RTCIceCandidate.
     31PASS new RTCIceCandidate({candidate:"foo", sdpMLineIndex:65536}); threw exception TypeError: Error creating RTCIceCandidate.
    2732PASS new RTCIceCandidate(5); threw exception TypeError: Optional RTCIceCandidate constructor argument must be a valid Dictionary.
    2833PASS new RTCIceCandidate("foobar"); threw exception TypeError: Optional RTCIceCandidate constructor argument must be a valid Dictionary.
  • trunk/LayoutTests/fast/mediastream/RTCIceCandidate.html

    r164941 r198325  
    55    </head>
    66    <body>
    7         <p id="description"></p>
    8         <div id="console"></div>
    97        <script>
    108            description("Tests RTCIceCandidate.");
     
    1614            shouldBe('candidate.sdpMid', '"bar"');
    1715            shouldBe('candidate.sdpMLineIndex', '6');
     16            debug("");
    1817
    19             shouldNotThrow('new RTCIceCandidate({});');
    20             shouldNotThrow('new RTCIceCandidate({candidate:"foo"});');
    21             shouldNotThrow('new RTCIceCandidate({sdpMid:"bar"});');
    22             shouldNotThrow('new RTCIceCandidate({sdpMLineIndex:6});');
     18            debug("Dictionary member 'candidate' is required.");
     19            shouldThrow('new RTCIceCandidate({});');
     20            shouldThrow('new RTCIceCandidate({sdpMid:"bar", sdpMLineIndex:6});');
     21            shouldThrow('new RTCIceCandidate({sdpMid:"bar"});');
     22            shouldThrow('new RTCIceCandidate({sdpMLineIndex:6});');
     23            debug("");
    2324
    24             shouldThrow('new RTCIceCandidate({candidate:"foo", sdpMid:"bar", sdpMLineIndex:"a"});');
    25             shouldThrow('new RTCIceCandidate({sdpMid:"bar", sdpMLineIndex:"a"});');
     25            debug("One of the 'sdpMid' or 'sdpMLineIndex' members must be present.");
     26            shouldThrow('new RTCIceCandidate({candidate:"foo"});');
     27            debug("");
     28
     29            debug("When one of the 'sdpMid' or 'sdpMLineIndex' members is set, the other must be null.");
     30            shouldNotThrow('candidate = new RTCIceCandidate({candidate:"foo", sdpMid:"bar"});');
     31            shouldBe('candidate.sdpMid', '"bar"');
     32            shouldBe('candidate.sdpMLineIndex', 'null');
     33            shouldNotThrow('candidate = new RTCIceCandidate({candidate:"foo", sdpMLineIndex:6});');
     34            shouldBe('candidate.sdpMid', 'null');
     35            shouldBe('candidate.sdpMLineIndex', '6');
     36            debug("");
     37
     38            debug("Some bad input");
    2639            shouldThrow('new RTCIceCandidate({candidate:"foo", sdpMLineIndex:"a"});');
    27             shouldThrow('new RTCIceCandidate({sdpMLineIndex:"a"});');
    28 
    29             shouldThrow('new RTCIceCandidate({candidate:"", sdpMid:"bar", sdpMLineIndex:6});');
    30             shouldThrow('new RTCIceCandidate({candidate:"", sdpMLineIndex:6});');
    31             shouldThrow('new RTCIceCandidate({candidate:"", sdpMid:"bar"});');
    32             shouldThrow('new RTCIceCandidate({candidate:""});');
    33 
    34             shouldThrow('new RTCIceCandidate({candidate:"foo", sdpMid:"", sdpMLineIndex:6});');
    35             shouldThrow('new RTCIceCandidate({sdpMid:"", sdpMLineIndex:6});');
    36             shouldThrow('new RTCIceCandidate({candidate:"foo", sdpMid:""});');
    37             shouldThrow('new RTCIceCandidate({sdpMid:""});');
    38 
    39             shouldThrow('new RTCIceCandidate({candidate:"", sdpMid:"", sdpMLineIndex:"a"});');
    40 
     40            shouldThrow('new RTCIceCandidate({candidate:"foo", sdpMLineIndex:-1});');
     41            shouldThrow('new RTCIceCandidate({candidate:"foo", sdpMLineIndex:65536});');
    4142            shouldThrow('new RTCIceCandidate(5);');
    4243            shouldThrow('new RTCIceCandidate("foobar");');
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-closed-state.html

    r194112 r198325  
    2323
    2424            var desc = new RTCSessionDescription({ "type": "offer" });
    25             var candidate = new RTCIceCandidate({ "sdpMLineIndex": 0 });
     25            var candidate = new RTCIceCandidate({ "candidate": "foo", "sdpMLineIndex": 0 });
    2626
    2727            navigator.mediaDevices.getUserMedia({ "video": true }).then(function (s) {
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-overloaded-operations-expected.txt

    r192575 r198325  
    3030PASS result = pc.setRemoteDescription(desc, emptyFunc, emptyFunc) did not throw exception.
    3131PASS result is undefined.
    32 PASS candidate = new RTCIceCandidate({}); did not throw exception.
    3332PASS result = pc.addIceCandidate(candidate) did not throw exception.
    3433PASS result is an instance of Promise
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-overloaded-operations-params-expected.txt

    r192575 r198325  
    8080PASS pc.setRemoteDescription(1, emptyFunc, emptyFunc) threw exception TypeError: Argument 1 ('description') to RTCPeerConnection.setRemoteDescription must be an instance of RTCSessionDescription.
    8181
    82 PASS candidate = new RTCIceCandidate({}); did not throw exception.
    8382PASS pc.addIceCandidate(candidate) did not throw exception.
    8483PASS pc.addIceCandidate(candidate, emptyFunc, emptyFunc) did not throw exception.
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-overloaded-operations-params.html

    r192575 r198325  
    8282
    8383            // Test addIceCandidate()
    84             shouldNotThrow("candidate = new RTCIceCandidate({});");
     84            candidate = new RTCIceCandidate({ "candidate": "foo", "sdpMid": "bar" });
    8585
    8686            shouldNotThrow("pc.addIceCandidate(candidate)");
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-overloaded-operations.html

    r192575 r198325  
    4848
    4949            // Test addIceCandidate()
    50             shouldNotThrow("candidate = new RTCIceCandidate({});");
     50            candidate = new RTCIceCandidate({ "candidate": "foo", "sdpMid": "bar" });
    5151
    5252            shouldNotThrow("result = pc.addIceCandidate(candidate)");
  • trunk/Source/WebCore/ChangeLog

    r198316 r198325  
     12016-03-17  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Update RTCIceCandidate
     4        https://bugs.webkit.org/show_bug.cgi?id=155535
     5
     6        Reviewed by Eric Carlson.
     7
     8        Update the RTCIceCandidate constructor procedure to match the WebRTC 1.0 specification [1].
     9        In short: The "candidate" init dictionary member is required. At least one of the dictionary
     10        members "sdpMid" and "sdpMLine" needs to be present; the corresponding attribute of the
     11        other, is initialized to null.
     12
     13        [1] https://w3c.github.io/webrtc-pc/archives/20160215/webrtc.html
     14
     15        Tests: Updated fast/mediastream/RTCIceCandidate.htm
     16
     17        * Modules/mediastream/RTCIceCandidate.cpp:
     18        (WebCore::RTCIceCandidate::create):
     19        (WebCore::RTCIceCandidate::RTCIceCandidate):
     20        * Modules/mediastream/RTCIceCandidate.h:
     21        (WebCore::RTCIceCandidate::sdpMLineIndex):
     22        (WebCore::RTCIceCandidate::setSdpMLineIndex):
     23        * Modules/mediastream/RTCIceCandidate.idl:
     24        * bindings/js/JSRTCIceCandidateCustom.cpp:
     25        (WebCore::JSRTCIceCandidate::sdpMid):
     26        (WebCore::JSRTCIceCandidate::sdpMLineIndex):
     27
    1282016-03-16  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
    229
  • trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp

    r192464 r198325  
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
    33 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
    4  * Copyright (C) 2015 Ericsson AB. All rights reserved.
     4 * Copyright (C) 2015, 2016 Ericsson AB. All rights reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    4545{
    4646    String candidate;
    47     bool ok = dictionary.get("candidate", candidate);
    48     if (ok && candidate.isEmpty()) {
    49         ec = TYPE_MISMATCH_ERR;
     47    if (!dictionary.get("candidate", candidate)) {
     48        ec = TypeError;
    5049        return nullptr;
    5150    }
    5251
    5352    String sdpMid;
    54     ok = dictionary.get("sdpMid", sdpMid);
    55     if (ok && sdpMid.isEmpty()) {
    56         ec = TYPE_MISMATCH_ERR;
    57         return nullptr;
     53    dictionary.get("sdpMid", sdpMid);
     54
     55    Optional<unsigned short> sdpMLineIndex;
     56    String sdpMLineIndexString;
     57
     58    if (dictionary.get("sdpMLineIndex", sdpMLineIndexString)) {
     59        bool intConversionOk;
     60        unsigned result = sdpMLineIndexString.toUIntStrict(&intConversionOk);
     61        if (!intConversionOk || result > USHRT_MAX) {
     62            ec = TypeError;
     63            return nullptr;
     64        }
     65        sdpMLineIndex = result;
    5866    }
    5967
    60     String tempLineIndex;
    61     unsigned short sdpMLineIndex = 0;
    62     // First we check if the property exists in the Dictionary.
    63     ok = dictionary.get("sdpMLineIndex", tempLineIndex);
    64     // Then we try to convert it to a number and check if it was successful.
    65     if (ok) {
    66         bool intConversionOk;
    67         sdpMLineIndex = tempLineIndex.toUIntStrict(&intConversionOk);
    68         if (!intConversionOk) {
    69             ec = TYPE_MISMATCH_ERR;
    70             return nullptr;
    71         }
     68    if (sdpMid.isNull() && !sdpMLineIndex) {
     69        ec = TypeError;
     70        return nullptr;
    7271    }
    7372
     
    7574}
    7675
    77 Ref<RTCIceCandidate> RTCIceCandidate::create(const String& candidate, const String& sdpMid, unsigned short sdpMLineIndex)
     76Ref<RTCIceCandidate> RTCIceCandidate::create(const String& candidate, const String& sdpMid, Optional<unsigned short> sdpMLineIndex)
    7877{
    7978    return adoptRef(*new RTCIceCandidate(candidate, sdpMid, sdpMLineIndex));
    8079}
    8180
    82 RTCIceCandidate::RTCIceCandidate(const String& candidate, const String& sdpMid, unsigned short sdpMLineIndex)
     81RTCIceCandidate::RTCIceCandidate(const String& candidate, const String& sdpMid, Optional<unsigned short> sdpMLineIndex)
    8382    : m_candidate(candidate)
    8483    , m_sdpMid(sdpMid)
  • trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.h

    r192464 r198325  
    3636#include "ExceptionBase.h"
    3737#include "ScriptWrappable.h"
     38#include <wtf/Optional.h>
    3839#include <wtf/RefCounted.h>
    3940#include <wtf/RefPtr.h>
     
    4849public:
    4950    static RefPtr<RTCIceCandidate> create(const Dictionary&, ExceptionCode&);
    50     static Ref<RTCIceCandidate> create(const String& candidate, const String& sdpMid, unsigned short sdpMLineIndex);
     51    static Ref<RTCIceCandidate> create(const String& candidate, const String& sdpMid, Optional<unsigned short> sdpMLineIndex);
    5152    virtual ~RTCIceCandidate() { }
    5253
     
    5758    void setSdpMid(const String& sdpMid) { m_sdpMid = sdpMid; }
    5859
    59     unsigned short sdpMLineIndex() const { return m_sdpMLineIndex; }
    60     void setSdpMLineIndex(unsigned short sdpMLineIndex) { m_sdpMLineIndex = sdpMLineIndex; }
     60    Optional<unsigned short> sdpMLineIndex() const { return m_sdpMLineIndex; }
     61    void setSdpMLineIndex(Optional<unsigned short> sdpMLineIndex) { m_sdpMLineIndex = sdpMLineIndex; }
    6162
    6263private:
    63     explicit RTCIceCandidate(const String& candidate, const String& sdpMid, unsigned short sdpMLineIndex);
     64    explicit RTCIceCandidate(const String& candidate, const String& sdpMid, Optional<unsigned short> sdpMLineIndex);
    6465
    6566    String m_candidate;
    6667    String m_sdpMid;
    67     unsigned short m_sdpMLineIndex;
     68    Optional<unsigned short> m_sdpMLineIndex;
    6869};
    6970
  • trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.idl

    r192464 r198325  
    3636] interface RTCIceCandidate {
    3737    attribute DOMString candidate;
    38     attribute DOMString sdpMid;
    39     attribute unsigned short sdpMLineIndex;
     38    [CustomGetter] attribute DOMString sdpMid;
     39    [CustomGetter] attribute unsigned short sdpMLineIndex;
    4040};
    4141
  • trunk/Source/WebCore/bindings/js/JSRTCIceCandidateCustom.cpp

    r170167 r198325  
    11/*
    22 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
     3 * Copyright (C) 2016 Ericsson AB. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    6667}
    6768
     69JSValue JSRTCIceCandidate::sdpMid(ExecState& state) const
     70{
     71    return jsOwnedStringOrNull(&state, wrapped().sdpMid());
     72}
     73
     74JSValue JSRTCIceCandidate::sdpMLineIndex(ExecState&) const
     75{
     76    Optional<unsigned short> index = wrapped().sdpMLineIndex();
     77    return index ? JSValue(index.value()) : jsNull();
     78}
     79
    6880} // namespace WebCore
    6981
Note: See TracChangeset for help on using the changeset viewer.