Changeset 127165 in webkit
- Timestamp:
- Aug 30, 2012 11:30:42 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 23 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r127164 r127165 1 2012-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 1 11 2012-08-30 'Pavel Feldman' <pfeldman@chromium.org> 2 12 -
trunk/LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt
r124193 r127165 8 8 PASS new webkitRTCPeerConnection(undefined); did not throw exception. 9 9 PASS new webkitRTCPeerConnection(undefined, undefined); did not throw exception. 10 PASS new webkitRTCPeerConnection(); threw exception TypeError: Not enough arguments. 11 PASS new webkitRTCPeerConnection(''); threw exception TypeError: Not an object.. 12 PASS new webkitRTCPeerConnection(null, ''); threw exception TypeError: Not an object.. 10 13 PASS new webkitRTCPeerConnection({iceServers:[]}, null); did not throw exception. 11 14 PASS new webkitRTCPeerConnection({iceServers:[{uri:'stun:foo.com'}]}, null); did not throw exception. 12 15 PASS new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'}]}, null); did not throw exception. 13 16 PASS 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..17 17 PASS new webkitRTCPeerConnection({fooServers:[]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. 18 18 PASS new webkitRTCPeerConnection({iceServers:true}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. … … 20 20 PASS new webkitRTCPeerConnection({iceServers:[{}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. 21 21 PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. 22 PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}}); did not throw exception. 23 PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}}); did not throw exception. 24 PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]}); did not throw exception. 25 PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0},{valid_and_supported_2:0}]}); did not throw exception. 26 PASS new webkitRTCPeerConnection(null, {optional:[{valid_but_unsupported_1:0},{valid_but_unsupported_2:0}]}); did not throw exception. 27 PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:66}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 28 PASS new webkitRTCPeerConnection(null, {mandatory:{invalid:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 29 PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 30 PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 31 PASS new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. 32 PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]}); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. 33 PASS new webkitRTCPeerConnection(null, {optional:[{invalid:0}]}); threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 22 34 PASS successfullyParsed is true 23 35 -
trunk/LayoutTests/fast/mediastream/RTCPeerConnection.html
r124193 r127165 12 12 shouldNotThrow("new webkitRTCPeerConnection(undefined);"); 13 13 shouldNotThrow("new webkitRTCPeerConnection(undefined, undefined);"); 14 shouldThrow("new webkitRTCPeerConnection();"); 15 shouldThrow("new webkitRTCPeerConnection('');"); 16 shouldThrow("new webkitRTCPeerConnection(null, '');"); 17 14 18 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]}, null);"); 15 19 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'stun:foo.com'}]}, null);"); 16 20 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'}]}, null);"); 17 21 shouldNotThrow("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, '');");22 22 shouldThrow("new webkitRTCPeerConnection({fooServers:[]}, null);"); 23 23 shouldThrow("new webkitRTCPeerConnection({iceServers:true}, null);"); … … 25 25 shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]}, null);"); 26 26 shouldThrow("new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null);"); 27 28 shouldNotThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}});"); 29 shouldNotThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}});"); 30 shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]});"); 31 shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0},{valid_and_supported_2:0}]});"); 32 shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_but_unsupported_1:0},{valid_but_unsupported_2:0}]});"); 33 shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:66}});"); 34 shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{invalid:1}});"); 35 shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1}});"); 36 shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}});"); 37 shouldThrow("new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}});"); 38 shouldThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]});"); 39 shouldThrow("new webkitRTCPeerConnection(null, {optional:[{invalid:0}]});"); 27 40 </script> 28 41 <script src="../js/resources/js-test-post.js"></script> -
trunk/Source/Platform/ChangeLog
r126838 r127165 1 2012-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 1 22 2012-08-27 Ian Vollick <vollick@chromium.org> 2 23 -
trunk/Source/Platform/Platform.gypi
r125219 r127165 81 81 'chromium/public/WebLayerTreeViewClient.h', 82 82 'chromium/public/WebLocalizedString.h', 83 'chromium/public/WebMediaConstraints.h', 83 84 'chromium/public/WebMediaHints.h', 84 85 'chromium/public/WebMediaStreamCenter.h', -
trunk/Source/Platform/chromium/public/WebMediaConstraints.h
r127164 r127165 29 29 */ 30 30 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 40 namespace WebCore { 41 class MediaConstraints; 42 } 33 43 34 44 namespace WebKit { 35 class WebRTCPeerConnectionHandlerClient;36 45 37 class Web RTCPeerConnectionHandler{46 class WebMediaConstraints { 38 47 public: 39 virtual ~WebRTCPeerConnectionHandler() { } 48 WebMediaConstraints() { } 49 WebMediaConstraints(const WebMediaConstraints& other) { assign(other); } 50 ~WebMediaConstraints() { reset(); } 40 51 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 73 private: 74 WebPrivatePtr<WebCore::MediaConstraints> m_private; 43 75 }; 44 76 45 77 } // namespace WebKit 46 78 47 #endif // Web RTCPeerConnectionHandler_h79 #endif // WebMediaConstraints_h -
trunk/Source/Platform/chromium/public/WebRTCPeerConnectionHandler.h
r126586 r127165 33 33 34 34 namespace WebKit { 35 class WebMediaConstraints; 36 class WebRTCConfiguration; 35 37 class WebRTCPeerConnectionHandlerClient; 36 38 … … 39 41 virtual ~WebRTCPeerConnectionHandler() { } 40 42 41 virtual bool initialize( ) = 0;43 virtual bool initialize(const WebRTCConfiguration&, const WebMediaConstraints&) = 0; 42 44 virtual void stop() = 0; 43 45 }; -
trunk/Source/WebCore/CMakeLists.txt
r127132 r127165 845 845 Modules/mediastream/IceCandidate.cpp 846 846 Modules/mediastream/LocalMediaStream.cpp 847 Modules/mediastream/MediaConstraintsImpl.cpp 847 848 Modules/mediastream/MediaStream.cpp 848 849 Modules/mediastream/MediaStreamEvent.cpp -
trunk/Source/WebCore/ChangeLog
r127163 r127165 1 2012-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 1 70 2012-08-24 Robert Hogan <robert@webkit.org> 2 71 -
trunk/Source/WebCore/GNUmakefile.list.am
r127132 r127165 1895 1895 Source/WebCore/Modules/mediastream/LocalMediaStream.cpp \ 1896 1896 Source/WebCore/Modules/mediastream/LocalMediaStream.h \ 1897 Source/WebCore/Modules/mediastream/MediaConstraintsImpl.cpp \ 1898 Source/WebCore/Modules/mediastream/MediaConstraintsImpl.h \ 1897 1899 Source/WebCore/Modules/mediastream/MediaStream.cpp \ 1898 1900 Source/WebCore/Modules/mediastream/MediaStream.h \ … … 4526 4528 Source/WebCore/platform/mediastream/IceOptions.cpp \ 4527 4529 Source/WebCore/platform/mediastream/IceOptions.h \ 4530 Source/WebCore/platform/mediastream/MediaConstraints.h \ 4528 4531 Source/WebCore/platform/mediastream/MediaHints.cpp \ 4529 4532 Source/WebCore/platform/mediastream/MediaHints.h \ -
trunk/Source/WebCore/Modules/mediastream/MediaConstraintsImpl.h
r127164 r127165 29 29 */ 30 30 31 #ifndef RTCPeerConnectionHandler_h32 #define RTCPeerConnectionHandler_h31 #ifndef MediaConstraintsImpl_h 32 #define MediaConstraintsImpl_h 33 33 34 34 #if ENABLE(MEDIA_STREAM) 35 35 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> 38 40 39 41 namespace WebCore { 42 class Dictionary; 40 43 41 class RTCPeerConnectionHandlerClient; 44 class MediaConstraintsImpl : public MediaConstraints { 45 public: 46 static PassRefPtr<MediaConstraintsImpl> create(const Dictionary&, ExceptionCode&); 47 virtual ~MediaConstraintsImpl(); 42 48 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; 47 51 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; 50 54 51 protected: 52 RTCPeerConnectionHandler() { } 55 private: 56 MediaConstraintsImpl() { } 57 bool initialize(const Dictionary&); 58 59 HashMap<String, String> m_mandatoryConstraints; 60 Vector<String> m_optionalConstraintNames; 61 Vector<String> m_optionalConstraintValues; 53 62 }; 54 63 … … 57 66 #endif // ENABLE(MEDIA_STREAM) 58 67 59 #endif // RTCPeerConnectionHandler_h 68 #endif // MediaConstraintsImpl_h 69 70 -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
r126586 r127165 38 38 #include "Event.h" 39 39 #include "ExceptionCode.h" 40 #include "MediaConstraintsImpl.h" 40 41 #include "RTCConfiguration.h" 41 42 #include "ScriptExecutionContext.h" … … 91 92 } 92 93 93 PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& , ExceptionCode& ec)94 PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode& ec) 94 95 { 95 96 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec); … … 97 98 return 0; 98 99 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)); 100 105 peerConnection->suspendIfNeeded(); 101 106 if (ec) … … 105 110 } 106 111 107 RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr<RTCConfiguration> , ExceptionCode& ec)112 RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionCode& ec) 108 113 : ActiveDOMObject(context, this) 109 114 , m_readyState(ReadyStateNew) 110 115 { 111 116 m_peerHandler = RTCPeerConnectionHandler::create(this); 112 if (!m_peerHandler || !m_peerHandler->initialize( ))117 if (!m_peerHandler || !m_peerHandler->initialize(configuration, constraints)) 113 118 ec = NOT_SUPPORTED_ERR; 114 119 } -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
r126586 r127165 43 43 44 44 namespace WebCore { 45 46 class MediaConstraints; 45 47 class RTCConfiguration; 46 48 … … 71 73 72 74 private: 73 RTCPeerConnection(ScriptExecutionContext*, PassRefPtr<RTCConfiguration>, ExceptionCode&);75 RTCPeerConnection(ScriptExecutionContext*, PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>, ExceptionCode&); 74 76 75 77 static PassRefPtr<RTCConfiguration> parseConfiguration(const Dictionary& configuration, ExceptionCode&); -
trunk/Source/WebCore/WebCore.gypi
r127132 r127165 445 445 'platform/mediastream/IceOptions.cpp', 446 446 'platform/mediastream/IceOptions.h', 447 'platform/mediastream/MediaConstraints.h', 447 448 'platform/mediastream/MediaHints.cpp', 448 449 'platform/mediastream/MediaHints.h', … … 1580 1581 'Modules/mediastream/LocalMediaStream.cpp', 1581 1582 'Modules/mediastream/LocalMediaStream.h', 1583 'Modules/mediastream/MediaConstraintsImpl.cpp', 1584 'Modules/mediastream/MediaConstraintsImpl.h', 1582 1585 'Modules/mediastream/MediaStream.cpp', 1583 1586 'Modules/mediastream/MediaStream.h', … … 8323 8326 'platform/chromium/support/WebICECandidateDescriptor.cpp', 8324 8327 'platform/chromium/support/WebICEOptions.cpp', 8328 'platform/chromium/support/WebMediaConstraints.cpp', 8325 8329 'platform/chromium/support/WebMediaHints.cpp', 8326 8330 'platform/chromium/support/WebMediaStreamComponent.cpp', -
trunk/Source/WebCore/bindings/js/Dictionary.cpp
r119484 r127165 80 80 } 81 81 82 bool 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 82 101 bool Dictionary::getWithUndefinedOrNullCheck(const String& propertyName, String& value) const 83 102 { -
trunk/Source/WebCore/bindings/js/Dictionary.h
r124626 r127165 61 61 bool isObject() const { return m_dictionary.isValid(); } 62 62 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; 64 65 bool getWithUndefinedOrNullCheck(const String& propertyName, String& value) const; 65 66 -
trunk/Source/WebCore/bindings/v8/Dictionary.cpp
r125481 r127165 495 495 } 496 496 497 bool 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 497 519 } // namespace WebCore -
trunk/Source/WebCore/bindings/v8/Dictionary.h
r125012 r127165 91 91 92 92 bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const; 93 bool getOwnPropertyNames(WTF::Vector<String>&) const; 93 94 94 95 bool getWithUndefinedOrNullCheck(const String&, String&) const; -
trunk/Source/WebCore/platform/chromium/support/WebMediaConstraints.cpp
r127164 r127165 33 33 #if ENABLE(MEDIA_STREAM) 34 34 35 #include "RTCPeerConnectionHandler.h"35 #include <public/WebMediaConstraints.h> 36 36 37 #include "RTCPeerConnectionHandlerClient.h" 38 #include <wtf/PassOwnPtr.h> 37 #include "MediaConstraints.h" 39 38 40 namespace WebCore { 39 using namespace WebCore; 41 40 42 // Dummy implementations below for ports that build with MEDIA_STREAM enabled by default. 41 namespace WebKit { 43 42 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() 43 WebMediaConstraints::WebMediaConstraints(const PassRefPtr<MediaConstraints>& constraints) 44 : m_private(constraints) 68 45 { 69 46 } 70 47 71 bool RTCPeerConnectionHandlerDummy::initialize()48 void WebMediaConstraints::assign(const WebMediaConstraints& other) 72 49 { 50 m_private = other.m_private; 51 } 52 53 void WebMediaConstraints::reset() 54 { 55 m_private.reset(); 56 } 57 58 bool WebMediaConstraints::isNull() const 59 { 60 return m_private.isNull(); 61 } 62 63 void 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 72 void 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 81 bool 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 } 73 89 return false; 74 90 } 75 91 76 void RTCPeerConnectionHandlerDummy::stop() 92 bool WebMediaConstraints::getOptionalConstraintValue(const WebString& name, WebString& value) const 77 93 { 94 ASSERT(!isNull()); 95 String result; 96 if (m_private->getOptionalConstraintValue(name, result)) { 97 value = result; 98 return true; 99 } 100 return false; 78 101 } 79 102 80 } // namespace Web Core103 } // namespace WebKit 81 104 82 105 #endif // ENABLE(MEDIA_STREAM) 106 -
trunk/Source/WebCore/platform/mediastream/MediaConstraints.h
r127164 r127165 29 29 */ 30 30 31 #ifndef RTCPeerConnectionHandler_h32 #define RTCPeerConnectionHandler_h31 #ifndef MediaConstraints_h 32 #define MediaConstraints_h 33 33 34 34 #if ENABLE(MEDIA_STREAM) 35 35 36 #include <wtf/ PassOwnPtr.h>37 #include <wtf/ PassRefPtr.h>36 #include <wtf/RefCounted.h> 37 #include <wtf/text/WTFString.h> 38 38 39 39 namespace WebCore { 40 40 41 class RTCPeerConnectionHandlerClient; 41 class MediaConstraints : public RefCounted<MediaConstraints> { 42 public: 43 virtual ~MediaConstraints() { } 42 44 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; 47 47 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; 50 50 51 51 protected: 52 RTCPeerConnectionHandler() { }52 MediaConstraints() { } 53 53 }; 54 54 … … 57 57 #endif // ENABLE(MEDIA_STREAM) 58 58 59 #endif // RTCPeerConnectionHandler_h59 #endif // MediaConstraints_h -
trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp
r126586 r127165 47 47 virtual ~RTCPeerConnectionHandlerDummy(); 48 48 49 virtual bool initialize( ) OVERRIDE;49 virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) OVERRIDE; 50 50 virtual void stop() OVERRIDE; 51 51 … … 69 69 } 70 70 71 bool RTCPeerConnectionHandlerDummy::initialize( )71 bool RTCPeerConnectionHandlerDummy::initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) 72 72 { 73 73 return false; -
trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h
r126586 r127165 39 39 namespace WebCore { 40 40 41 class MediaConstraints; 42 class RTCConfiguration; 41 43 class RTCPeerConnectionHandlerClient; 42 44 … … 46 48 virtual ~RTCPeerConnectionHandler() { } 47 49 48 virtual bool initialize( ) = 0;50 virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) = 0; 49 51 virtual void stop() = 0; 50 52 -
trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp
r126586 r127165 35 35 #include "RTCPeerConnectionHandlerChromium.h" 36 36 37 #include "MediaConstraints.h" 38 #include "RTCConfiguration.h" 37 39 #include "RTCPeerConnectionHandlerClient.h" 38 40 #include <public/Platform.h> 41 #include <public/WebMediaConstraints.h> 42 #include <public/WebRTCConfiguration.h> 39 43 #include <wtf/PassOwnPtr.h> 40 44 … … 56 60 } 57 61 58 bool RTCPeerConnectionHandlerChromium::initialize( )62 bool RTCPeerConnectionHandlerChromium::initialize(PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints) 59 63 { 60 64 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; 62 66 } 63 67 -
trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h
r126586 r127165 47 47 virtual ~RTCPeerConnectionHandlerChromium(); 48 48 49 virtual bool initialize( ) OVERRIDE;49 virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) OVERRIDE; 50 50 virtual void stop() OVERRIDE; 51 51 -
trunk/Tools/ChangeLog
r127137 r127165 1 2012-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 1 18 2012-08-30 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> 2 19 -
trunk/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp
r126586 r127165 34 34 #include "MockWebRTCPeerConnectionHandler.h" 35 35 36 #include <public/WebMediaConstraints.h> 36 37 #include <public/WebRTCPeerConnectionHandlerClient.h> 38 #include <public/WebString.h> 39 #include <public/WebVector.h> 37 40 38 41 using namespace WebKit; 39 42 40 MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient* )43 MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient* client) 41 44 { 42 45 } 43 46 44 bool MockWebRTCPeerConnectionHandler::initialize()47 static bool isSupportedConstraint(const WebString& constraint) 45 48 { 49 return constraint == "valid_and_supported_1" || constraint == "valid_and_supported_2"; 50 } 51 52 static bool isValidConstraint(const WebString& constraint) 53 { 54 return isSupportedConstraint(constraint) || constraint == "valid_but_unsupported_1" || constraint == "valid_but_unsupported_2"; 55 } 56 57 bool 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 46 85 return true; 47 86 } -
trunk/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h
r126586 r127165 43 43 explicit MockWebRTCPeerConnectionHandler(WebKit::WebRTCPeerConnectionHandlerClient*); 44 44 45 virtual bool initialize() OVERRIDE; 45 virtual bool initialize(const WebKit::WebRTCConfiguration&, const WebKit::WebMediaConstraints&) OVERRIDE; 46 46 47 virtual void stop() OVERRIDE; 47 48
Note: See TracChangeset
for help on using the changeset viewer.