Changeset 127165 in webkit


Ignore:
Timestamp:
Aug 30, 2012 11:30:42 AM (12 years ago)
Author:
tommyw@google.com
Message:

MediaStream API: Introduce MediaConstraints
https://bugs.webkit.org/show_bug.cgi?id=95198

Reviewed by Adam Barth.

Source/Platform:

Adds WebMediaConstraints.

  • Platform.gypi:
  • chromium/public/WebMediaConstraints.h: Copied from Source/Platform/chromium/public/WebRTCPeerConnectionHandler.h.

(WebCore):
(WebKit):
(WebMediaConstraints):
(WebKit::WebMediaConstraints::WebMediaConstraints):
(WebKit::WebMediaConstraints::~WebMediaConstraints):
(WebKit::WebMediaConstraints::operator=):

  • chromium/public/WebRTCPeerConnectionHandler.h:

(WebKit):
(WebRTCPeerConnectionHandler):

Source/WebCore:

This introduces MediaConstraints together with relevant infrastructure, a chromium mock and LayoutTests.

Patch covered by expanded existing tests.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Modules/mediastream/MediaConstraintsImpl.cpp: Added.

(WebCore):
(WebCore::MediaConstraintsImpl::create):
(WebCore::MediaConstraintsImpl::initialize):
(WebCore::MediaConstraintsImpl::~MediaConstraintsImpl):
(WebCore::MediaConstraintsImpl::getMandatoryConstraintNames):
(WebCore::MediaConstraintsImpl::getOptionalConstraintNames):
(WebCore::MediaConstraintsImpl::getMandatoryConstraintValue):
(WebCore::MediaConstraintsImpl::getOptionalConstraintValue):

  • Modules/mediastream/MediaConstraintsImpl.h: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h.

(WebCore):
(MediaConstraintsImpl):
(WebCore::MediaConstraintsImpl::MediaConstraintsImpl):

  • Modules/mediastream/RTCPeerConnection.cpp:

(WebCore::RTCPeerConnection::create):
(WebCore::RTCPeerConnection::RTCPeerConnection):

  • Modules/mediastream/RTCPeerConnection.h:

(WebCore):
(RTCPeerConnection):

  • WebCore.gypi:
  • bindings/js/Dictionary.cpp:

(WebCore::Dictionary::getOwnPropertyNames):
(WebCore):

  • bindings/js/Dictionary.h:

(Dictionary):

  • bindings/v8/Dictionary.cpp:

(WebCore::Dictionary::getOwnPropertyNames):
(WebCore):

  • bindings/v8/Dictionary.h:

(Dictionary):

  • platform/chromium/support/WebMediaConstraints.cpp: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp.

(WebKit):
(WebKit::WebMediaConstraints::WebMediaConstraints):
(WebKit::WebMediaConstraints::assign):
(WebKit::WebMediaConstraints::reset):
(WebKit::WebMediaConstraints::isNull):
(WebKit::WebMediaConstraints::getMandatoryConstraintNames):
(WebKit::WebMediaConstraints::getOptionalConstraintNames):
(WebKit::WebMediaConstraints::getMandatoryConstraintValue):
(WebKit::WebMediaConstraints::getOptionalConstraintValue):

  • platform/mediastream/MediaConstraints.h: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h.

(WebCore):
(MediaConstraints):
(WebCore::MediaConstraints::~MediaConstraints):
(WebCore::MediaConstraints::MediaConstraints):

  • platform/mediastream/RTCPeerConnectionHandler.cpp:

(RTCPeerConnectionHandlerDummy):
(WebCore::RTCPeerConnectionHandlerDummy::initialize):

  • platform/mediastream/RTCPeerConnectionHandler.h:

(WebCore):
(RTCPeerConnectionHandler):

  • platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:

(WebCore::RTCPeerConnectionHandlerChromium::initialize):

  • platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:

(RTCPeerConnectionHandlerChromium):

Tools:

Extending the MockWebRTCPeerConnectionHandler with MediaConstraints functionality.

  • DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp:

(MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler):
(isSupportedConstraint):
(isValidConstraint):
(MockWebRTCPeerConnectionHandler::initialize):

  • DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h:

(MockWebRTCPeerConnectionHandler):

LayoutTests:

  • fast/mediastream/RTCPeerConnection-expected.txt:
  • fast/mediastream/RTCPeerConnection.html:
Location:
trunk
Files:
1 added
23 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r127164 r127165  
     12012-08-30  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Introduce MediaConstraints
     4        https://bugs.webkit.org/show_bug.cgi?id=95198
     5
     6        Reviewed by Adam Barth.
     7
     8        * fast/mediastream/RTCPeerConnection-expected.txt:
     9        * fast/mediastream/RTCPeerConnection.html:
     10
    1112012-08-30  'Pavel Feldman'  <pfeldman@chromium.org>
    212
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt

    r124193 r127165  
    88PASS new webkitRTCPeerConnection(undefined); did not throw exception.
    99PASS new webkitRTCPeerConnection(undefined, undefined); did not throw exception.
     10PASS new webkitRTCPeerConnection(); threw exception TypeError: Not enough arguments.
     11PASS new webkitRTCPeerConnection(''); threw exception TypeError: Not an object..
     12PASS new webkitRTCPeerConnection(null, ''); threw exception TypeError: Not an object..
    1013PASS new webkitRTCPeerConnection({iceServers:[]}, null); did not throw exception.
    1114PASS new webkitRTCPeerConnection({iceServers:[{uri:'stun:foo.com'}]}, null); did not throw exception.
    1215PASS new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'}]}, null); did not throw exception.
    1316PASS new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'},{uri:'stun:bar.com'}]}, null); did not throw exception.
    14 PASS new webkitRTCPeerConnection(); threw exception TypeError: Not enough arguments.
    15 PASS new webkitRTCPeerConnection(''); threw exception TypeError: Not an object..
    16 PASS new webkitRTCPeerConnection(null, ''); threw exception TypeError: Not an object..
    1717PASS new webkitRTCPeerConnection({fooServers:[]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    1818PASS new webkitRTCPeerConnection({iceServers:true}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     
    2020PASS new webkitRTCPeerConnection({iceServers:[{}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    2121PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     22PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}}); did not throw exception.
     23PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}}); did not throw exception.
     24PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]}); did not throw exception.
     25PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0},{valid_and_supported_2:0}]}); did not throw exception.
     26PASS new webkitRTCPeerConnection(null, {optional:[{valid_but_unsupported_1:0},{valid_but_unsupported_2:0}]}); did not throw exception.
     27PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:66}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     28PASS new webkitRTCPeerConnection(null, {mandatory:{invalid:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     29PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     30PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
     31PASS new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     32PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     33PASS new webkitRTCPeerConnection(null, {optional:[{invalid:0}]}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
    2234PASS successfullyParsed is true
    2335
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection.html

    r124193 r127165  
    1212shouldNotThrow("new webkitRTCPeerConnection(undefined);");
    1313shouldNotThrow("new webkitRTCPeerConnection(undefined, undefined);");
     14shouldThrow("new webkitRTCPeerConnection();");
     15shouldThrow("new webkitRTCPeerConnection('');");
     16shouldThrow("new webkitRTCPeerConnection(null, '');");
     17
    1418shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]}, null);");
    1519shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'stun:foo.com'}]}, null);");
    1620shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'}]}, null);");
    1721shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'},{uri:'stun:bar.com'}]}, null);");
    18 
    19 shouldThrow("new webkitRTCPeerConnection();");
    20 shouldThrow("new webkitRTCPeerConnection('');");
    21 shouldThrow("new webkitRTCPeerConnection(null, '');");
    2222shouldThrow("new webkitRTCPeerConnection({fooServers:[]}, null);");
    2323shouldThrow("new webkitRTCPeerConnection({iceServers:true}, null);");
     
    2525shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]}, null);");
    2626shouldThrow("new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null);");
     27
     28shouldNotThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}});");
     29shouldNotThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}});");
     30shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]});");
     31shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0},{valid_and_supported_2:0}]});");
     32shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_but_unsupported_1:0},{valid_but_unsupported_2:0}]});");
     33shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:66}});");
     34shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{invalid:1}});");
     35shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1}});");
     36shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}});");
     37shouldThrow("new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}});");
     38shouldThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]});");
     39shouldThrow("new webkitRTCPeerConnection(null, {optional:[{invalid:0}]});");
    2740</script>
    2841<script src="../js/resources/js-test-post.js"></script>
  • trunk/Source/Platform/ChangeLog

    r126838 r127165  
     12012-08-30  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Introduce MediaConstraints
     4        https://bugs.webkit.org/show_bug.cgi?id=95198
     5
     6        Reviewed by Adam Barth.
     7
     8        Adds WebMediaConstraints.
     9
     10        * Platform.gypi:
     11        * chromium/public/WebMediaConstraints.h: Copied from Source/Platform/chromium/public/WebRTCPeerConnectionHandler.h.
     12        (WebCore):
     13        (WebKit):
     14        (WebMediaConstraints):
     15        (WebKit::WebMediaConstraints::WebMediaConstraints):
     16        (WebKit::WebMediaConstraints::~WebMediaConstraints):
     17        (WebKit::WebMediaConstraints::operator=):
     18        * chromium/public/WebRTCPeerConnectionHandler.h:
     19        (WebKit):
     20        (WebRTCPeerConnectionHandler):
     21
    1222012-08-27  Ian Vollick  <vollick@chromium.org>
    223
  • trunk/Source/Platform/Platform.gypi

    r125219 r127165  
    8181            'chromium/public/WebLayerTreeViewClient.h',
    8282            'chromium/public/WebLocalizedString.h',
     83            'chromium/public/WebMediaConstraints.h',
    8384            'chromium/public/WebMediaHints.h',
    8485            'chromium/public/WebMediaStreamCenter.h',
  • trunk/Source/Platform/chromium/public/WebMediaConstraints.h

    r127164 r127165  
    2929 */
    3030
    31 #ifndef WebRTCPeerConnectionHandler_h
    32 #define WebRTCPeerConnectionHandler_h
     31#ifndef WebMediaConstraints_h
     32#define WebMediaConstraints_h
     33
     34#include "WebCommon.h"
     35#include "WebNonCopyable.h"
     36#include "WebPrivatePtr.h"
     37#include "WebString.h"
     38#include "WebVector.h"
     39
     40namespace WebCore {
     41class MediaConstraints;
     42}
    3343
    3444namespace WebKit {
    35 class WebRTCPeerConnectionHandlerClient;
    3645
    37 class WebRTCPeerConnectionHandler {
     46class WebMediaConstraints {
    3847public:
    39     virtual ~WebRTCPeerConnectionHandler() { }
     48    WebMediaConstraints() { }
     49    WebMediaConstraints(const WebMediaConstraints& other) { assign(other); }
     50    ~WebMediaConstraints() { reset(); }
    4051
    41     virtual bool initialize() = 0;
    42     virtual void stop() = 0;
     52    WebMediaConstraints& operator=(const WebMediaConstraints& other)
     53    {
     54        assign(other);
     55        return *this;
     56    }
     57
     58    WEBKIT_EXPORT void assign(const WebMediaConstraints&);
     59
     60    WEBKIT_EXPORT void reset();
     61    bool isNull() const;
     62
     63    WEBKIT_EXPORT void getMandatoryConstraintNames(WebVector<WebString>& names) const;
     64    WEBKIT_EXPORT void getOptionalConstraintNames(WebVector<WebString>& names) const;
     65
     66    WEBKIT_EXPORT bool getMandatoryConstraintValue(const WebString& name, WebString& value) const;
     67    WEBKIT_EXPORT bool getOptionalConstraintValue(const WebString& name, WebString& value) const;
     68
     69#if WEBKIT_IMPLEMENTATION
     70    WebMediaConstraints(const WTF::PassRefPtr<WebCore::MediaConstraints>&);
     71#endif
     72
     73private:
     74    WebPrivatePtr<WebCore::MediaConstraints> m_private;
    4375};
    4476
    4577} // namespace WebKit
    4678
    47 #endif // WebRTCPeerConnectionHandler_h
     79#endif // WebMediaConstraints_h
  • trunk/Source/Platform/chromium/public/WebRTCPeerConnectionHandler.h

    r126586 r127165  
    3333
    3434namespace WebKit {
     35class WebMediaConstraints;
     36class WebRTCConfiguration;
    3537class WebRTCPeerConnectionHandlerClient;
    3638
     
    3941    virtual ~WebRTCPeerConnectionHandler() { }
    4042
    41     virtual bool initialize() = 0;
     43    virtual bool initialize(const WebRTCConfiguration&, const WebMediaConstraints&) = 0;
    4244    virtual void stop() = 0;
    4345};
  • trunk/Source/WebCore/CMakeLists.txt

    r127132 r127165  
    845845    Modules/mediastream/IceCandidate.cpp
    846846    Modules/mediastream/LocalMediaStream.cpp
     847    Modules/mediastream/MediaConstraintsImpl.cpp
    847848    Modules/mediastream/MediaStream.cpp
    848849    Modules/mediastream/MediaStreamEvent.cpp
  • trunk/Source/WebCore/ChangeLog

    r127163 r127165  
     12012-08-30  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Introduce MediaConstraints
     4        https://bugs.webkit.org/show_bug.cgi?id=95198
     5
     6        Reviewed by Adam Barth.
     7
     8        This introduces MediaConstraints together with relevant infrastructure, a chromium mock and LayoutTests.
     9
     10        Patch covered by expanded existing tests.
     11
     12        * CMakeLists.txt:
     13        * GNUmakefile.list.am:
     14        * Modules/mediastream/MediaConstraintsImpl.cpp: Added.
     15        (WebCore):
     16        (WebCore::MediaConstraintsImpl::create):
     17        (WebCore::MediaConstraintsImpl::initialize):
     18        (WebCore::MediaConstraintsImpl::~MediaConstraintsImpl):
     19        (WebCore::MediaConstraintsImpl::getMandatoryConstraintNames):
     20        (WebCore::MediaConstraintsImpl::getOptionalConstraintNames):
     21        (WebCore::MediaConstraintsImpl::getMandatoryConstraintValue):
     22        (WebCore::MediaConstraintsImpl::getOptionalConstraintValue):
     23        * Modules/mediastream/MediaConstraintsImpl.h: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h.
     24        (WebCore):
     25        (MediaConstraintsImpl):
     26        (WebCore::MediaConstraintsImpl::MediaConstraintsImpl):
     27        * Modules/mediastream/RTCPeerConnection.cpp:
     28        (WebCore::RTCPeerConnection::create):
     29        (WebCore::RTCPeerConnection::RTCPeerConnection):
     30        * Modules/mediastream/RTCPeerConnection.h:
     31        (WebCore):
     32        (RTCPeerConnection):
     33        * WebCore.gypi:
     34        * bindings/js/Dictionary.cpp:
     35        (WebCore::Dictionary::getOwnPropertyNames):
     36        (WebCore):
     37        * bindings/js/Dictionary.h:
     38        (Dictionary):
     39        * bindings/v8/Dictionary.cpp:
     40        (WebCore::Dictionary::getOwnPropertyNames):
     41        (WebCore):
     42        * bindings/v8/Dictionary.h:
     43        (Dictionary):
     44        * platform/chromium/support/WebMediaConstraints.cpp: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp.
     45        (WebKit):
     46        (WebKit::WebMediaConstraints::WebMediaConstraints):
     47        (WebKit::WebMediaConstraints::assign):
     48        (WebKit::WebMediaConstraints::reset):
     49        (WebKit::WebMediaConstraints::isNull):
     50        (WebKit::WebMediaConstraints::getMandatoryConstraintNames):
     51        (WebKit::WebMediaConstraints::getOptionalConstraintNames):
     52        (WebKit::WebMediaConstraints::getMandatoryConstraintValue):
     53        (WebKit::WebMediaConstraints::getOptionalConstraintValue):
     54        * platform/mediastream/MediaConstraints.h: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h.
     55        (WebCore):
     56        (MediaConstraints):
     57        (WebCore::MediaConstraints::~MediaConstraints):
     58        (WebCore::MediaConstraints::MediaConstraints):
     59        * platform/mediastream/RTCPeerConnectionHandler.cpp:
     60        (RTCPeerConnectionHandlerDummy):
     61        (WebCore::RTCPeerConnectionHandlerDummy::initialize):
     62        * platform/mediastream/RTCPeerConnectionHandler.h:
     63        (WebCore):
     64        (RTCPeerConnectionHandler):
     65        * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:
     66        (WebCore::RTCPeerConnectionHandlerChromium::initialize):
     67        * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:
     68        (RTCPeerConnectionHandlerChromium):
     69
    1702012-08-24  Robert Hogan  <robert@webkit.org>
    271
  • trunk/Source/WebCore/GNUmakefile.list.am

    r127132 r127165  
    18951895        Source/WebCore/Modules/mediastream/LocalMediaStream.cpp \
    18961896        Source/WebCore/Modules/mediastream/LocalMediaStream.h \
     1897        Source/WebCore/Modules/mediastream/MediaConstraintsImpl.cpp \
     1898        Source/WebCore/Modules/mediastream/MediaConstraintsImpl.h \
    18971899        Source/WebCore/Modules/mediastream/MediaStream.cpp \
    18981900        Source/WebCore/Modules/mediastream/MediaStream.h \
     
    45264528        Source/WebCore/platform/mediastream/IceOptions.cpp \
    45274529        Source/WebCore/platform/mediastream/IceOptions.h \
     4530        Source/WebCore/platform/mediastream/MediaConstraints.h \
    45284531        Source/WebCore/platform/mediastream/MediaHints.cpp \
    45294532        Source/WebCore/platform/mediastream/MediaHints.h \
  • trunk/Source/WebCore/Modules/mediastream/MediaConstraintsImpl.h

    r127164 r127165  
    2929 */
    3030
    31 #ifndef RTCPeerConnectionHandler_h
    32 #define RTCPeerConnectionHandler_h
     31#ifndef MediaConstraintsImpl_h
     32#define MediaConstraintsImpl_h
    3333
    3434#if ENABLE(MEDIA_STREAM)
    3535
    36 #include <wtf/PassOwnPtr.h>
    37 #include <wtf/PassRefPtr.h>
     36#include "ExceptionBase.h"
     37#include "MediaConstraints.h"
     38#include <wtf/HashMap.h>
     39#include <wtf/Vector.h>
    3840
    3941namespace WebCore {
     42class Dictionary;
    4043
    41 class RTCPeerConnectionHandlerClient;
     44class MediaConstraintsImpl : public MediaConstraints {
     45public:
     46    static PassRefPtr<MediaConstraintsImpl> create(const Dictionary&, ExceptionCode&);
     47    virtual ~MediaConstraintsImpl();
    4248
    43 class RTCPeerConnectionHandler {
    44 public:
    45     static PassOwnPtr<RTCPeerConnectionHandler> create(RTCPeerConnectionHandlerClient*);
    46     virtual ~RTCPeerConnectionHandler() { }
     49    virtual void getMandatoryConstraintNames(Vector<String>& names) const OVERRIDE;
     50    virtual void getOptionalConstraintNames(Vector<String>& names) const OVERRIDE;
    4751
    48     virtual bool initialize() = 0;
    49     virtual void stop() = 0;
     52    virtual bool getMandatoryConstraintValue(const String& name, String& value) const OVERRIDE;
     53    virtual bool getOptionalConstraintValue(const String& name, String& value) const OVERRIDE;
    5054
    51 protected:
    52     RTCPeerConnectionHandler() { }
     55private:
     56    MediaConstraintsImpl() { }
     57    bool initialize(const Dictionary&);
     58
     59    HashMap<String, String> m_mandatoryConstraints;
     60    Vector<String> m_optionalConstraintNames;
     61    Vector<String> m_optionalConstraintValues;
    5362};
    5463
     
    5766#endif // ENABLE(MEDIA_STREAM)
    5867
    59 #endif // RTCPeerConnectionHandler_h
     68#endif // MediaConstraintsImpl_h
     69
     70
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

    r126586 r127165  
    3838#include "Event.h"
    3939#include "ExceptionCode.h"
     40#include "MediaConstraintsImpl.h"
    4041#include "RTCConfiguration.h"
    4142#include "ScriptExecutionContext.h"
     
    9192}
    9293
    93 PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary&, ExceptionCode& ec)
     94PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode& ec)
    9495{
    9596    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
     
    9798        return 0;
    9899
    99     RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(context, configuration.release(), ec));
     100    RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaConstraints, ec);
     101    if (ec)
     102        return 0;
     103
     104    RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(context, configuration.release(), constraints.release(), ec));
    100105    peerConnection->suspendIfNeeded();
    101106    if (ec)
     
    105110}
    106111
    107 RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr<RTCConfiguration>, ExceptionCode& ec)
     112RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionCode& ec)
    108113    : ActiveDOMObject(context, this)
    109114    , m_readyState(ReadyStateNew)
    110115{
    111116    m_peerHandler = RTCPeerConnectionHandler::create(this);
    112     if (!m_peerHandler || !m_peerHandler->initialize())
     117    if (!m_peerHandler || !m_peerHandler->initialize(configuration, constraints))
    113118        ec = NOT_SUPPORTED_ERR;
    114119}
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h

    r126586 r127165  
    4343
    4444namespace WebCore {
     45
     46class MediaConstraints;
    4547class RTCConfiguration;
    4648
     
    7173
    7274private:
    73     RTCPeerConnection(ScriptExecutionContext*, PassRefPtr<RTCConfiguration>, ExceptionCode&);
     75    RTCPeerConnection(ScriptExecutionContext*, PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>, ExceptionCode&);
    7476
    7577    static PassRefPtr<RTCConfiguration> parseConfiguration(const Dictionary& configuration, ExceptionCode&);
  • trunk/Source/WebCore/WebCore.gypi

    r127132 r127165  
    445445            'platform/mediastream/IceOptions.cpp',
    446446            'platform/mediastream/IceOptions.h',
     447            'platform/mediastream/MediaConstraints.h',
    447448            'platform/mediastream/MediaHints.cpp',
    448449            'platform/mediastream/MediaHints.h',
     
    15801581            'Modules/mediastream/LocalMediaStream.cpp',
    15811582            'Modules/mediastream/LocalMediaStream.h',
     1583            'Modules/mediastream/MediaConstraintsImpl.cpp',
     1584            'Modules/mediastream/MediaConstraintsImpl.h',
    15821585            'Modules/mediastream/MediaStream.cpp',
    15831586            'Modules/mediastream/MediaStream.h',
     
    83238326            'platform/chromium/support/WebICECandidateDescriptor.cpp',
    83248327            'platform/chromium/support/WebICEOptions.cpp',
     8328            'platform/chromium/support/WebMediaConstraints.cpp',
    83258329            'platform/chromium/support/WebMediaHints.cpp',
    83268330            'platform/chromium/support/WebMediaStreamComponent.cpp',
  • trunk/Source/WebCore/bindings/js/Dictionary.cpp

    r119484 r127165  
    8080}
    8181
     82bool Dictionary::getOwnPropertyNames(WTF::Vector<String>& names) const
     83{
     84    if (!m_dictionary.isValid())
     85        return false;
     86
     87    JSObject* object =  m_dictionary.initializerObject();
     88    ExecState* exec = m_dictionary.execState();
     89
     90    PropertyNameArray propertyNames(exec);
     91    JSObject::getOwnPropertyNames(object, exec, propertyNames, ExcludeDontEnumProperties);
     92    for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != propertyNames.end(); it++) {
     93        String stringKey = ustringToString(it->ustring());
     94        if (!stringKey.isEmpty())
     95            names.append(stringKey);
     96    }
     97
     98    return true;
     99}
     100
    82101bool Dictionary::getWithUndefinedOrNullCheck(const String& propertyName, String& value) const
    83102{
  • trunk/Source/WebCore/bindings/js/Dictionary.h

    r124626 r127165  
    6161    bool isObject() const { return m_dictionary.isValid(); }
    6262    bool isUndefinedOrNull() const { return !m_dictionary.isValid(); }
    63     bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const;
     63    bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const;
     64    bool getOwnPropertyNames(Vector<String>&) const;
    6465    bool getWithUndefinedOrNullCheck(const String& propertyName, String& value) const;
    6566
  • trunk/Source/WebCore/bindings/v8/Dictionary.cpp

    r125481 r127165  
    495495}
    496496
     497bool Dictionary::getOwnPropertyNames(WTF::Vector<String>& names) const
     498{
     499    if (!isObject())
     500        return false;
     501
     502    v8::Handle<v8::Object> options = m_options->ToObject();
     503    if (options.IsEmpty())
     504        return false;
     505
     506    v8::Local<v8::Array> properties = options->GetOwnPropertyNames();
     507    if (properties.IsEmpty())
     508        return true;
     509    for (uint32_t i = 0; i < properties->Length(); ++i) {
     510        v8::Local<v8::String> key = properties->Get(i)->ToString();
     511        if (!options->Has(key))
     512            continue;
     513        names.append(toWebCoreString(key));
     514    }
     515
     516    return true;
     517}
     518
    497519} // namespace WebCore
  • trunk/Source/WebCore/bindings/v8/Dictionary.h

    r125012 r127165  
    9191
    9292    bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const;
     93    bool getOwnPropertyNames(WTF::Vector<String>&) const;
    9394
    9495    bool getWithUndefinedOrNullCheck(const String&, String&) const;
  • trunk/Source/WebCore/platform/chromium/support/WebMediaConstraints.cpp

    r127164 r127165  
    3333#if ENABLE(MEDIA_STREAM)
    3434
    35 #include "RTCPeerConnectionHandler.h"
     35#include <public/WebMediaConstraints.h>
    3636
    37 #include "RTCPeerConnectionHandlerClient.h"
    38 #include <wtf/PassOwnPtr.h>
     37#include "MediaConstraints.h"
    3938
    40 namespace WebCore {
     39using namespace WebCore;
    4140
    42 // Dummy implementations below for ports that build with MEDIA_STREAM enabled by default.
     41namespace WebKit {
    4342
    44 class RTCPeerConnectionHandlerDummy : public RTCPeerConnectionHandler {
    45 public:
    46     RTCPeerConnectionHandlerDummy(RTCPeerConnectionHandlerClient*);
    47     virtual ~RTCPeerConnectionHandlerDummy();
    48 
    49     virtual bool initialize() OVERRIDE;
    50     virtual void stop() OVERRIDE;
    51 
    52 private:
    53     RTCPeerConnectionHandlerClient* m_client;
    54 };
    55 
    56 PassOwnPtr<RTCPeerConnectionHandler> RTCPeerConnectionHandler::create(RTCPeerConnectionHandlerClient* client)
    57 {
    58     return adoptPtr(new RTCPeerConnectionHandlerDummy(client));
    59 }
    60 
    61 RTCPeerConnectionHandlerDummy::RTCPeerConnectionHandlerDummy(RTCPeerConnectionHandlerClient* client)
    62     : m_client(client)
    63 {
    64     ASSERT(m_client);
    65 }
    66 
    67 RTCPeerConnectionHandlerDummy::~RTCPeerConnectionHandlerDummy()
     43WebMediaConstraints::WebMediaConstraints(const PassRefPtr<MediaConstraints>& constraints)
     44    : m_private(constraints)
    6845{
    6946}
    7047
    71 bool RTCPeerConnectionHandlerDummy::initialize()
     48void WebMediaConstraints::assign(const WebMediaConstraints& other)
    7249{
     50    m_private = other.m_private;
     51}
     52
     53void WebMediaConstraints::reset()
     54{
     55    m_private.reset();
     56}
     57
     58bool WebMediaConstraints::isNull() const
     59{
     60    return m_private.isNull();
     61}
     62
     63void WebMediaConstraints::getMandatoryConstraintNames(WebVector<WebString>& names) const
     64{
     65    ASSERT(!isNull());
     66    Vector<String> constraintNames;
     67    m_private->getMandatoryConstraintNames(constraintNames);
     68    WebVector<WebString> result(constraintNames);
     69    names.swap(result);
     70}
     71
     72void WebMediaConstraints::getOptionalConstraintNames(WebVector<WebString>& names) const
     73{
     74    ASSERT(!isNull());
     75    Vector<String> constraintNames;
     76    m_private->getOptionalConstraintNames(constraintNames);
     77    WebVector<WebString> result(constraintNames);
     78    names.swap(result);
     79}
     80
     81bool WebMediaConstraints::getMandatoryConstraintValue(const WebString& name, WebString& value) const
     82{
     83    ASSERT(!isNull());
     84    String result;
     85    if (m_private->getMandatoryConstraintValue(name, result)) {
     86        value = result;
     87        return true;
     88    }
    7389    return false;
    7490}
    7591
    76 void RTCPeerConnectionHandlerDummy::stop()
     92bool WebMediaConstraints::getOptionalConstraintValue(const WebString& name, WebString& value) const
    7793{
     94    ASSERT(!isNull());
     95    String result;
     96    if (m_private->getOptionalConstraintValue(name, result)) {
     97        value = result;
     98        return true;
     99    }
     100    return false;
    78101}
    79102
    80 } // namespace WebCore
     103} // namespace WebKit
    81104
    82105#endif // ENABLE(MEDIA_STREAM)
     106
  • trunk/Source/WebCore/platform/mediastream/MediaConstraints.h

    r127164 r127165  
    2929 */
    3030
    31 #ifndef RTCPeerConnectionHandler_h
    32 #define RTCPeerConnectionHandler_h
     31#ifndef MediaConstraints_h
     32#define MediaConstraints_h
    3333
    3434#if ENABLE(MEDIA_STREAM)
    3535
    36 #include <wtf/PassOwnPtr.h>
    37 #include <wtf/PassRefPtr.h>
     36#include <wtf/RefCounted.h>
     37#include <wtf/text/WTFString.h>
    3838
    3939namespace WebCore {
    4040
    41 class RTCPeerConnectionHandlerClient;
     41class MediaConstraints : public RefCounted<MediaConstraints> {
     42public:
     43    virtual ~MediaConstraints() { }
    4244
    43 class RTCPeerConnectionHandler {
    44 public:
    45     static PassOwnPtr<RTCPeerConnectionHandler> create(RTCPeerConnectionHandlerClient*);
    46     virtual ~RTCPeerConnectionHandler() { }
     45    virtual void getMandatoryConstraintNames(Vector<String>& names) const = 0;
     46    virtual void getOptionalConstraintNames(Vector<String>& names) const = 0;
    4747
    48     virtual bool initialize() = 0;
    49     virtual void stop() = 0;
     48    virtual bool getMandatoryConstraintValue(const String& name, String& value) const = 0;
     49    virtual bool getOptionalConstraintValue(const String& name, String& value) const = 0;
    5050
    5151protected:
    52     RTCPeerConnectionHandler() { }
     52    MediaConstraints() { }
    5353};
    5454
     
    5757#endif // ENABLE(MEDIA_STREAM)
    5858
    59 #endif // RTCPeerConnectionHandler_h
     59#endif // MediaConstraints_h
  • trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp

    r126586 r127165  
    4747    virtual ~RTCPeerConnectionHandlerDummy();
    4848
    49     virtual bool initialize() OVERRIDE;
     49    virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) OVERRIDE;
    5050    virtual void stop() OVERRIDE;
    5151
     
    6969}
    7070
    71 bool RTCPeerConnectionHandlerDummy::initialize()
     71bool RTCPeerConnectionHandlerDummy::initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>)
    7272{
    7373    return false;
  • trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h

    r126586 r127165  
    3939namespace WebCore {
    4040
     41class MediaConstraints;
     42class RTCConfiguration;
    4143class RTCPeerConnectionHandlerClient;
    4244
     
    4648    virtual ~RTCPeerConnectionHandler() { }
    4749
    48     virtual bool initialize() = 0;
     50    virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) = 0;
    4951    virtual void stop() = 0;
    5052
  • trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp

    r126586 r127165  
    3535#include "RTCPeerConnectionHandlerChromium.h"
    3636
     37#include "MediaConstraints.h"
     38#include "RTCConfiguration.h"
    3739#include "RTCPeerConnectionHandlerClient.h"
    3840#include <public/Platform.h>
     41#include <public/WebMediaConstraints.h>
     42#include <public/WebRTCConfiguration.h>
    3943#include <wtf/PassOwnPtr.h>
    4044
     
    5660}
    5761
    58 bool RTCPeerConnectionHandlerChromium::initialize()
     62bool RTCPeerConnectionHandlerChromium::initialize(PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints)
    5963{
    6064    m_webHandler = adoptPtr(WebKit::Platform::current()->createRTCPeerConnectionHandler(this));
    61     return m_webHandler ? m_webHandler->initialize() : false;
     65    return m_webHandler ? m_webHandler->initialize(configuration, constraints) : false;
    6266}
    6367
  • trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h

    r126586 r127165  
    4747    virtual ~RTCPeerConnectionHandlerChromium();
    4848
    49     virtual bool initialize() OVERRIDE;
     49    virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) OVERRIDE;
    5050    virtual void stop() OVERRIDE;
    5151
  • trunk/Tools/ChangeLog

    r127137 r127165  
     12012-08-30  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Introduce MediaConstraints
     4        https://bugs.webkit.org/show_bug.cgi?id=95198
     5
     6        Reviewed by Adam Barth.
     7
     8        Extending the MockWebRTCPeerConnectionHandler with MediaConstraints functionality.
     9
     10        * DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp:
     11        (MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler):
     12        (isSupportedConstraint):
     13        (isValidConstraint):
     14        (MockWebRTCPeerConnectionHandler::initialize):
     15        * DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h:
     16        (MockWebRTCPeerConnectionHandler):
     17
    1182012-08-30  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    219
  • trunk/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp

    r126586 r127165  
    3434#include "MockWebRTCPeerConnectionHandler.h"
    3535
     36#include <public/WebMediaConstraints.h>
    3637#include <public/WebRTCPeerConnectionHandlerClient.h>
     38#include <public/WebString.h>
     39#include <public/WebVector.h>
    3740
    3841using namespace WebKit;
    3942
    40 MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient*)
     43MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient* client)
    4144{
    4245}
    4346
    44 bool MockWebRTCPeerConnectionHandler::initialize()
     47static bool isSupportedConstraint(const WebString& constraint)
    4548{
     49    return constraint == "valid_and_supported_1" || constraint == "valid_and_supported_2";
     50}
     51
     52static bool isValidConstraint(const WebString& constraint)
     53{
     54    return isSupportedConstraint(constraint) || constraint == "valid_but_unsupported_1" || constraint == "valid_but_unsupported_2";
     55}
     56
     57bool MockWebRTCPeerConnectionHandler::initialize(const WebRTCConfiguration&, const WebMediaConstraints& constraints)
     58{
     59    WebVector<WebString> mandatoryConstraintNames;
     60    constraints.getMandatoryConstraintNames(mandatoryConstraintNames);
     61    if (mandatoryConstraintNames.size()) {
     62        for (size_t i = 0; i < mandatoryConstraintNames.size(); ++i) {
     63            if (!isSupportedConstraint(mandatoryConstraintNames[i]))
     64                return false;
     65            WebString value;
     66            constraints.getMandatoryConstraintValue(mandatoryConstraintNames[i], value);
     67            if (value != "1")
     68                return false;
     69        }
     70    }
     71
     72    WebVector<WebString> optionalConstraintNames;
     73    constraints.getOptionalConstraintNames(optionalConstraintNames);
     74    if (optionalConstraintNames.size()) {
     75        for (size_t i = 0; i < optionalConstraintNames.size(); ++i) {
     76            if (!isValidConstraint(optionalConstraintNames[i]))
     77                return false;
     78            WebString value;
     79            constraints.getOptionalConstraintValue(optionalConstraintNames[i], value);
     80            if (value != "0")
     81                return false;
     82        }
     83    }
     84
    4685    return true;
    4786}
  • trunk/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h

    r126586 r127165  
    4343    explicit MockWebRTCPeerConnectionHandler(WebKit::WebRTCPeerConnectionHandlerClient*);
    4444
    45     virtual bool initialize() OVERRIDE;
     45    virtual bool initialize(const WebKit::WebRTCConfiguration&, const WebKit::WebMediaConstraints&) OVERRIDE;
     46
    4647    virtual void stop() OVERRIDE;
    4748
Note: See TracChangeset for help on using the changeset viewer.