Changeset 116127 in webkit


Ignore:
Timestamp:
May 4, 2012 10:55:20 AM (12 years ago)
Author:
tommyw@google.com
Message:

MediaStream API: Make PeerConnection00's API fully compliant with the draft
https://bugs.webkit.org/show_bug.cgi?id=85491

Reviewed by Adam Barth.

Source/Platform:

  • chromium/public/WebPeerConnection00HandlerClient.h:

Source/WebCore:

Mainly making the relevant API's use objects (aka Dictionaries) instead of the temporary strings,
but also making a few API's exception aware and changing the name of a flag.

Test: fast/mediastream/peerconnection-iceoptions.html

  • Modules/mediastream/PeerConnection00.cpp:

(WebCore::PeerConnection00::createMediaHints):
(WebCore::PeerConnection00::createOffer):
(WebCore):
(WebCore::PeerConnection00::createAnswer):
(WebCore::PeerConnection00::createIceOptions):
(WebCore::PeerConnection00::createDefaultIceOptions):
(WebCore::PeerConnection00::startIce):
(WebCore::PeerConnection00::addStream):
(WebCore::PeerConnection00::changeReadyState):

  • Modules/mediastream/PeerConnection00.h:

(WebCore):
(PeerConnection00):

  • Modules/mediastream/PeerConnection00.idl:
  • platform/mediastream/chromium/PeerConnection00HandlerInternal.cpp:

(WebCore::PeerConnection00HandlerInternal::startIce):

Source/WebKit/chromium:

  • src/AssertMatchingEnums.cpp:

LayoutTests:

  • fast/mediastream/peerconnection-Attributes-expected.txt:
  • fast/mediastream/peerconnection-iceoptions-expected.txt: Added.
  • fast/mediastream/peerconnection-iceoptions.html: Added.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116122 r116127  
     12012-05-04  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Make PeerConnection00's API fully compliant with the draft
     4        https://bugs.webkit.org/show_bug.cgi?id=85491
     5
     6        Reviewed by Adam Barth.
     7
     8        * fast/mediastream/peerconnection-Attributes-expected.txt:
     9        * fast/mediastream/peerconnection-iceoptions-expected.txt: Added.
     10        * fast/mediastream/peerconnection-iceoptions.html: Added.
     11
    1122012-05-04  Zan Dobersek  <zandobersek@gmail.com>
    213
  • trunk/LayoutTests/fast/mediastream/peerconnection-Attributes-expected.txt

    r115810 r116127  
    88PASS typeof pc.close === 'function' is true
    99PASS pc.NEW === 0 is true
    10 FAIL pc.OPENING === 1 should be true. Was false.
     10PASS pc.OPENING === 1 is true
    1111PASS pc.ACTIVE === 2 is true
    1212PASS pc.CLOSED === 3 is true
  • trunk/Source/Platform/ChangeLog

    r115930 r116127  
     12012-05-04  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Make PeerConnection00's API fully compliant with the draft
     4        https://bugs.webkit.org/show_bug.cgi?id=85491
     5
     6        Reviewed by Adam Barth.
     7
     8        * chromium/public/WebPeerConnection00HandlerClient.h:
     9
    1102012-05-02  Dana Jansens  <danakj@chromium.org>
    211
  • trunk/Source/Platform/chromium/public/WebPeerConnection00HandlerClient.h

    r112784 r116127  
    4141    enum ReadyState {
    4242        ReadyStateNew = 0,
     43        ReadyStateOpening = 1,
     44        ReadyStateActive = 2,
     45        ReadyStateClosed = 3,
     46
     47        // DEPRECATED
    4348        ReadyStateNegotiating = 1,
    44         ReadyStateActive = 2,
    45         ReadyStateClosed = 3
    4649    };
    4750
  • trunk/Source/WebCore/ChangeLog

    r116125 r116127  
     12012-05-04  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Make PeerConnection00's API fully compliant with the draft
     4        https://bugs.webkit.org/show_bug.cgi?id=85491
     5
     6        Reviewed by Adam Barth.
     7
     8        Mainly making the relevant API's use objects (aka Dictionaries) instead of the temporary strings,
     9        but also making a few API's exception aware and changing the name of a flag.
     10
     11        Test: fast/mediastream/peerconnection-iceoptions.html
     12
     13        * Modules/mediastream/PeerConnection00.cpp:
     14        (WebCore::PeerConnection00::createMediaHints):
     15        (WebCore::PeerConnection00::createOffer):
     16        (WebCore):
     17        (WebCore::PeerConnection00::createAnswer):
     18        (WebCore::PeerConnection00::createIceOptions):
     19        (WebCore::PeerConnection00::createDefaultIceOptions):
     20        (WebCore::PeerConnection00::startIce):
     21        (WebCore::PeerConnection00::addStream):
     22        (WebCore::PeerConnection00::changeReadyState):
     23        * Modules/mediastream/PeerConnection00.h:
     24        (WebCore):
     25        (PeerConnection00):
     26        * Modules/mediastream/PeerConnection00.idl:
     27        * platform/mediastream/chromium/PeerConnection00HandlerInternal.cpp:
     28        (WebCore::PeerConnection00HandlerInternal::startIce):
     29
    1302012-05-04  David Tseng  <dtseng@google.com>
    231
  • trunk/Source/WebCore/Modules/mediastream/PeerConnection00.cpp

    r112513 r116127  
    9292}
    9393
    94 PassRefPtr<MediaHints> PeerConnection00::parseMediaHints(const String& mediaHints)
    95 {
    96     Vector<String> hintsList;
    97     mediaHints.split(",", hintsList);
     94PassRefPtr<MediaHints> PeerConnection00::createMediaHints(const Dictionary& dictionary)
     95{
    9896    bool audio = hasLocalAudioTrack();
    9997    bool video = hasLocalVideoTrack();
    100     for (Vector<String>::iterator i = hintsList.begin(); i != hintsList.end(); ++i) {
    101         if (*i == "audio")
    102             audio = true;
    103         else if (*i == "no_audio")
    104             audio = false;
    105         else if (*i == "video")
    106             video = true;
    107         else if (*i == "no_video")
    108             video = false;
    109     }
    110 
     98    dictionary.get("has_audio", audio);
     99    dictionary.get("has_video", audio);
    111100    return MediaHints::create(audio, video);
    112101}
    113102
    114 PassRefPtr<SessionDescription> PeerConnection00::createOffer()
    115 {
    116     return createOffer("");
    117 }
    118 
    119 PassRefPtr<SessionDescription> PeerConnection00::createOffer(const String& mediaHintsString)
    120 {
    121     RefPtr<MediaHints> mediaHints = parseMediaHints(mediaHintsString);
    122     RefPtr<SessionDescriptionDescriptor> descriptor = m_peerHandler->createOffer(mediaHints.release());
    123     if (!descriptor)
     103PassRefPtr<MediaHints> PeerConnection00::createMediaHints()
     104{
     105    bool audio = hasLocalAudioTrack();
     106    bool video = hasLocalVideoTrack();
     107    return MediaHints::create(audio, video);
     108}
     109
     110PassRefPtr<SessionDescription> PeerConnection00::createOffer(ExceptionCode& ec)
     111{
     112    return createOffer(createMediaHints(), ec);
     113}
     114
     115PassRefPtr<SessionDescription> PeerConnection00::createOffer(const Dictionary& dictionary, ExceptionCode& ec)
     116{
     117    return createOffer(createMediaHints(dictionary), ec);
     118}
     119
     120PassRefPtr<SessionDescription> PeerConnection00::createOffer(PassRefPtr<MediaHints> mediaHints, ExceptionCode& ec)
     121{
     122    RefPtr<SessionDescriptionDescriptor> descriptor = m_peerHandler->createOffer(mediaHints);
     123    if (!descriptor) {
     124        ec = SYNTAX_ERR;
    124125        return 0;
     126    }
    125127
    126128    return SessionDescription::create(descriptor.release());
    127129}
    128130
    129 PassRefPtr<SessionDescription> PeerConnection00::createAnswer(const String& offer)
    130 {
    131     return createAnswer(offer, "");
    132 }
    133 
    134 PassRefPtr<SessionDescription> PeerConnection00::createAnswer(const String& offer, const String& mediaHintsString)
    135 {
    136     RefPtr<MediaHints> mediaHints = parseMediaHints(mediaHintsString);
    137     RefPtr<SessionDescriptionDescriptor> descriptor = m_peerHandler->createAnswer(offer, mediaHints.release());
    138     if (!descriptor)
     131PassRefPtr<SessionDescription> PeerConnection00::createAnswer(const String& offer, ExceptionCode& ec)
     132{
     133    return createAnswer(offer, createMediaHints(), ec);
     134}
     135
     136PassRefPtr<SessionDescription> PeerConnection00::createAnswer(const String& offer, const Dictionary& dictionary, ExceptionCode& ec)
     137{
     138    return createAnswer(offer, createMediaHints(dictionary), ec);
     139}
     140
     141PassRefPtr<SessionDescription> PeerConnection00::createAnswer(const String& offer, PassRefPtr<MediaHints> hints, ExceptionCode& ec)
     142{
     143    RefPtr<SessionDescriptionDescriptor> descriptor = m_peerHandler->createAnswer(offer, hints);
     144    if (!descriptor) {
     145        ec = SYNTAX_ERR;
    139146        return 0;
     147    }
    140148
    141149    return SessionDescription::create(descriptor.release());
     
    216224}
    217225
    218 void PeerConnection00::startIce(ExceptionCode& ec)
    219 {
    220     startIce("", ec);
    221 }
    222 
    223 void PeerConnection00::startIce(const String& options, ExceptionCode& ec)
    224 {
    225     if (m_readyState == CLOSED) {
    226         ec = INVALID_STATE_ERR;
    227         return;
    228     }
     226PassRefPtr<IceOptions> PeerConnection00::createIceOptions(const Dictionary& dictionary, ExceptionCode& ec)
     227{
     228    String useCandidates = "";
     229    dictionary.get("use_candidates", useCandidates);
    229230
    230231    IceOptions::UseCandidatesOption option;
    231 
    232     if (options == "" || options == "all")
     232    if (useCandidates == "" || useCandidates == "all")
    233233        option = IceOptions::ALL;
    234     else if (options == "no_relay")
     234    else if (useCandidates == "no_relay")
    235235        option = IceOptions::NO_RELAY;
    236     else if (options == "only_relay")
     236    else if (useCandidates == "only_relay")
    237237        option = IceOptions::ONLY_RELAY;
    238238    else {
    239239        ec = TYPE_MISMATCH_ERR;
    240         return;
    241     }
    242 
    243     bool valid = m_peerHandler->startIce(IceOptions::create(option));
     240        return 0;
     241    }
     242
     243    return IceOptions::create(option);
     244}
     245
     246PassRefPtr<IceOptions> PeerConnection00::createDefaultIceOptions()
     247{
     248    return IceOptions::create(IceOptions::ALL);
     249}
     250
     251void PeerConnection00::startIce(ExceptionCode& ec)
     252{
     253    startIce(createDefaultIceOptions(), ec);
     254}
     255
     256void PeerConnection00::startIce(const Dictionary& dictionary, ExceptionCode& ec)
     257{
     258    RefPtr<IceOptions> iceOptions = createIceOptions(dictionary, ec);
     259    if (ec)
     260        return;
     261
     262    startIce(iceOptions.release(), ec);
     263}
     264
     265void PeerConnection00::startIce(PassRefPtr<IceOptions> iceOptions, ExceptionCode& ec)
     266{
     267    if (m_readyState == CLOSED) {
     268        ec = INVALID_STATE_ERR;
     269        return;
     270    }
     271
     272    bool valid = m_peerHandler->startIce(iceOptions);
    244273    if (!valid)
    245274        ec = SYNTAX_ERR;
     
    274303}
    275304
    276 void PeerConnection00::addStream(PassRefPtr<MediaStream> stream, ExceptionCode& ec)
    277 {
    278     String emptyHints;
    279     return addStream(stream, emptyHints, ec);
    280 }
    281 
    282 void PeerConnection00::addStream(PassRefPtr<MediaStream> prpStream, const String& mediaStreamHints, ExceptionCode& ec)
     305void PeerConnection00::addStream(PassRefPtr<MediaStream> prpStream, ExceptionCode& ec)
    283306{
    284307    RefPtr<MediaStream> stream = prpStream;
     
    298321    m_localStreams->append(stream);
    299322
    300     // FIXME: When the spec says what the mediaStreamHints should look like send it down.
    301323    m_peerHandler->addStream(stream->descriptor());
     324}
     325
     326void PeerConnection00::addStream(PassRefPtr<MediaStream> stream, const Dictionary& mediaStreamHints, ExceptionCode& ec)
     327{
     328    // FIXME: When the spec says what the mediaStreamHints should look like use it.
     329    addStream(stream, ec);
    302330}
    303331
     
    436464
    437465    switch (m_readyState) {
    438     case NEGOTIATING:
     466    case OPENING:
    439467        dispatchEvent(Event::create(eventNames().connectingEvent, false, false));
    440468        break;
  • trunk/Source/WebCore/Modules/mediastream/PeerConnection00.h

    r111876 r116127  
    3535
    3636#include "ActiveDOMObject.h"
     37#include "Dictionary.h"
    3738#include "EventTarget.h"
    3839#include "ExceptionBase.h"
     
    5051
    5152class MediaHints;
     53class IceOptions;
    5254
    5355// Note:
     
    6466    enum ReadyState {
    6567        NEW = 0,
    66         NEGOTIATING = 1,
     68        OPENING = 1,
    6769        ACTIVE = 2,
    6870        CLOSED = 3
     
    8890    ~PeerConnection00();
    8991
    90     PassRefPtr<SessionDescription> createOffer();
    91     PassRefPtr<SessionDescription> createOffer(const String& mediaHints);
    92     PassRefPtr<SessionDescription> createAnswer(const String& offer);
    93     PassRefPtr<SessionDescription> createAnswer(const String& offer, const String& mediaHints);
     92    PassRefPtr<SessionDescription> createOffer(ExceptionCode&);
     93    PassRefPtr<SessionDescription> createOffer(const Dictionary& mediaHints, ExceptionCode&);
     94    PassRefPtr<SessionDescription> createAnswer(const String& offer, ExceptionCode&);
     95    PassRefPtr<SessionDescription> createAnswer(const String& offer, const Dictionary& mediaHints, ExceptionCode&);
    9496
    9597    void setLocalDescription(int action, PassRefPtr<SessionDescription>, ExceptionCode&);
     
    99101
    100102    void startIce(ExceptionCode&);
    101     void startIce(const String& options, ExceptionCode&);
     103    void startIce(const Dictionary& iceOptions, ExceptionCode&);
    102104    void processIceMessage(PassRefPtr<IceCandidate>, ExceptionCode&);
    103105
     
    106108
    107109    void addStream(const PassRefPtr<MediaStream>, ExceptionCode&);
    108     void addStream(const PassRefPtr<MediaStream>, const String& mediaStreamHints, ExceptionCode&);
     110    void addStream(const PassRefPtr<MediaStream>, const Dictionary& mediaStreamHints, ExceptionCode&);
    109111    void removeStream(MediaStream*, ExceptionCode&);
    110112    MediaStreamList* localStreams() const;
     
    148150    void changeReadyState(ReadyState);
    149151    void changeIceState(IceState);
     152
    150153    bool hasLocalAudioTrack();
    151154    bool hasLocalVideoTrack();
    152     PassRefPtr<MediaHints> parseMediaHints(const String& mediaHintsString);
     155    PassRefPtr<MediaHints> createMediaHints(const Dictionary&);
     156    PassRefPtr<MediaHints> createMediaHints();
     157    PassRefPtr<IceOptions> createIceOptions(const Dictionary&, ExceptionCode&);
     158    PassRefPtr<IceOptions> createDefaultIceOptions();
     159    PassRefPtr<SessionDescription> createOffer(PassRefPtr<MediaHints>, ExceptionCode&);
     160    PassRefPtr<SessionDescription> createAnswer(const String& offer, PassRefPtr<MediaHints>, ExceptionCode&);
     161    void startIce(PassRefPtr<IceOptions>, ExceptionCode&);
    153162
    154163    RefPtr<IceCallback> m_iceCallback;
  • trunk/Source/WebCore/Modules/mediastream/PeerConnection00.idl

    r111876 r116127  
    3838        EventTarget
    3939    ] PeerConnection00 {
    40         // FIXME: Make mediaHints an object
    41         SessionDescription createOffer(in [Optional] DOMString mediaHints);
    42 
    43         // FIXME: Make mediaHints an object
    44         SessionDescription createAnswer(in DOMString offer, in [Optional] DOMString mediaHints);
     40        SessionDescription createOffer(in [Optional] Dictionary mediaHints)
     41            raises(DOMException);
     42        SessionDescription createAnswer(in DOMString offer, in [Optional] Dictionary mediaHints)
     43            raises(DOMException);
    4544
    4645        // Actions, for setLocalDescription/setRemoteDescription.
     
    5150        void setLocalDescription(in unsigned short action, in SessionDescription desc)
    5251            raises(DOMException);
    53 
    5452        void setRemoteDescription(in unsigned short action, in SessionDescription desc)
    5553            raises(DOMException);
    5654
    5755        readonly attribute SessionDescription localDescription;
    58 
    5956        readonly attribute SessionDescription remoteDescription;
    6057
    6158        const unsigned short NEW = 0;
    62         const unsigned short NEGOTIATING = 1;
     59        const unsigned short OPENING = 1;
    6360        const unsigned short ACTIVE = 2;
    6461        const unsigned short CLOSED = 3;
    6562        readonly attribute unsigned short readyState;
    6663
    67         // FIXME: Make iceOptions an object
    68         void startIce(in [Optional] DOMString iceOptions)
     64        void startIce(in [Optional] Dictionary iceOptions)
    6965            raises(DOMException);
    7066
     
    8177        readonly attribute unsigned short iceState;
    8278
    83         // FIXME: Make mediaStreamHints an object
    84         [StrictTypeChecking] void addStream(in MediaStream stream, in [Optional] DOMString mediaStreamHints)
     79        [StrictTypeChecking] void addStream(in MediaStream stream, in [Optional] Dictionary mediaStreamHints)
    8580            raises(DOMException);
    8681        [StrictTypeChecking] void removeStream(in MediaStream stream)
  • trunk/Source/WebCore/platform/mediastream/chromium/PeerConnection00HandlerInternal.cpp

    r112784 r116127  
    120120{
    121121    if (!m_webHandler)
    122         return false;
     122        return true;
    123123
    124124    return m_webHandler->startIce(iceOptions);
  • trunk/Source/WebKit/chromium/ChangeLog

    r116121 r116127  
     12012-05-04  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Make PeerConnection00's API fully compliant with the draft
     4        https://bugs.webkit.org/show_bug.cgi?id=85491
     5
     6        Reviewed by Adam Barth.
     7
     8        * src/AssertMatchingEnums.cpp:
     9
    1102012-05-04  Nate Chapin  <japhet@chromium.org>
    211
  • trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp

    r115291 r116127  
    548548
    549549COMPILE_ASSERT_MATCHING_ENUM(WebPeerConnection00HandlerClient::ReadyStateNew, PeerConnection00::NEW);
    550 COMPILE_ASSERT_MATCHING_ENUM(WebPeerConnection00HandlerClient::ReadyStateNegotiating, PeerConnection00::NEGOTIATING);
     550COMPILE_ASSERT_MATCHING_ENUM(WebPeerConnection00HandlerClient::ReadyStateOpening, PeerConnection00::OPENING);
     551COMPILE_ASSERT_MATCHING_ENUM(WebPeerConnection00HandlerClient::ReadyStateNegotiating, PeerConnection00::OPENING);
    551552COMPILE_ASSERT_MATCHING_ENUM(WebPeerConnection00HandlerClient::ReadyStateActive, PeerConnection00::ACTIVE);
    552553COMPILE_ASSERT_MATCHING_ENUM(WebPeerConnection00HandlerClient::ReadyStateClosed, PeerConnection00::CLOSED);
Note: See TracChangeset for help on using the changeset viewer.