From f29875a0a4fb3ddfa70620fbee5cb7c33f15a78d Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 10 Nov 2016 01:33:47 -0800 Subject: [PATCH] Revert "Remove MediaStreamTrack.getSources()." This reverts commit 3ea42b21339ebf028e0ff6e368ca60d463386dd2. This revert is temporary in order to give time to a performance test to be fixed. TBR=rbyers@chromium.org, hbos@chromium.org BUG=662414, 649710, 388194 Review-Url: https://codereview.chromium.org/2489823002 Cr-Commit-Position: refs/heads/master@{#431224} --- .../extensions/hangout_services_test.html | 14 +-- .../media_access/media_check_guest.html | 4 +- chrome/test/data/webrtc/media_devices.js | 14 ++- .../mock_web_media_stream_center.cc | 2 + .../test_runner/mock_web_user_media_client.cc | 39 +++++++ .../test_runner/mock_web_user_media_client.h | 1 + content/renderer/media/media_stream_center.cc | 2 + content/renderer/media/media_stream_center.h | 1 + .../renderer/media/user_media_client_impl.cc | 66 +++++++++++ .../renderer/media/user_media_client_impl.h | 8 ++ .../media/user_media_client_impl_unittest.cc | 55 +++++++++ content/test/data/media/getusermedia.html | 10 +- .../media_access/check/media_check_guest.html | 4 +- .../MediaStreamTrack-getSources-expected.txt | 19 +++ .../MediaStreamTrack-getSources.html | 60 ++++++++++ .../global-interface-listing-expected.txt | 1 + .../global-interface-listing-expected.txt | 1 + .../global-interface-listing-expected.txt | 1 + .../global-interface-listing-expected.txt | 1 + .../WebKit/Source/core/frame/Deprecation.cpp | 4 + .../WebKit/Source/core/frame/UseCounter.h | 1 + .../Source/modules/mediastream/BUILD.gn | 5 + .../modules/mediastream/MediaStreamTrack.cpp | 21 ++++ .../modules/mediastream/MediaStreamTrack.h | 4 + .../modules/mediastream/MediaStreamTrack.idl | 3 + .../MediaStreamTrackSourcesCallback.h | 42 +++++++ .../MediaStreamTrackSourcesCallback.idl | 29 +++++ .../MediaStreamTrackSourcesRequestImpl.cpp | 79 +++++++++++++ .../MediaStreamTrackSourcesRequestImpl.h | 67 +++++++++++ .../Source/modules/mediastream/SourceInfo.cpp | 76 ++++++++++++ .../Source/modules/mediastream/SourceInfo.h | 59 ++++++++++ .../Source/modules/mediastream/SourceInfo.idl | 34 ++++++ .../modules/mediastream/UserMediaClient.h | 2 + .../modules/mediastream/UserMediaController.h | 6 + .../Source/modules/modules_idl_files.gni | 2 + third_party/WebKit/Source/platform/BUILD.gn | 3 + .../WebMediaStreamTrackSourcesRequest.cpp | 59 ++++++++++ .../platform/exported/WebSourceInfo.cpp | 109 ++++++++++++++++++ .../mediastream/MediaStreamCenter.cpp | 1 + .../MediaStreamTrackSourcesRequest.h | 54 +++++++++ .../WebKit/Source/web/UserMediaClientImpl.cpp | 7 ++ .../WebKit/Source/web/UserMediaClientImpl.h | 1 + third_party/WebKit/public/BUILD.gn | 1 + .../WebMediaStreamTrackSourcesRequest.h | 75 ++++++++++++ .../WebKit/public/platform/WebSourceInfo.h | 77 +++++++++++++ .../WebKit/public/web/WebUserMediaClient.h | 2 + 46 files changed, 1108 insertions(+), 18 deletions(-) create mode 100644 third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getSources-expected.txt create mode 100644 third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getSources.html create mode 100644 third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesCallback.h create mode 100644 third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesCallback.idl create mode 100644 third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.cpp create mode 100644 third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.h create mode 100644 third_party/WebKit/Source/modules/mediastream/SourceInfo.cpp create mode 100644 third_party/WebKit/Source/modules/mediastream/SourceInfo.h create mode 100644 third_party/WebKit/Source/modules/mediastream/SourceInfo.idl create mode 100644 third_party/WebKit/Source/platform/exported/WebMediaStreamTrackSourcesRequest.cpp create mode 100644 third_party/WebKit/Source/platform/exported/WebSourceInfo.cpp create mode 100644 third_party/WebKit/Source/platform/mediastream/MediaStreamTrackSourcesRequest.h create mode 100644 third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h create mode 100644 third_party/WebKit/public/platform/WebSourceInfo.h diff --git a/chrome/test/data/extensions/hangout_services_test.html b/chrome/test/data/extensions/hangout_services_test.html index 8b9b9a73d6f9b3..ed1fcc57e42268 100644 --- a/chrome/test/data/extensions/hangout_services_test.html +++ b/chrome/test/data/extensions/hangout_services_test.html @@ -20,7 +20,7 @@ // Populates UI elements with initial contents. function populate() { populateSinks(); - navigator.mediaDevices.enumerateDevices().then(populateSources); + MediaStreamTrack.getSources(populateSources); } // Populates the select box with information on all sinks and the @@ -42,14 +42,14 @@ }); } -function populateSources(devices) { +function populateSources(sources) { var select = document.getElementById('selectSource'); - for (var i = 0; i < devices.length; ++i) { - var device = devices[i]; - if (device.kind == 'audioinput') { + for (var i = 0; i < sources.length; ++i) { + var source = sources[i]; + if (source.kind == 'audio') { var option = document.createElement('option'); - option.value = device.deviceId; - option.text = device.label + ' (' + device.deviceId + ')'; + option.value = source.id; + option.text = source.label + ' (' + source.id + ')'; select.add(option); } } diff --git a/chrome/test/data/extensions/platform_apps/web_view/media_access/media_check_guest.html b/chrome/test/data/extensions/platform_apps/web_view/media_access/media_check_guest.html index 85d72761bd7b22..07164c0df4b991 100644 --- a/chrome/test/data/extensions/platform_apps/web_view/media_access/media_check_guest.html +++ b/chrome/test/data/extensions/platform_apps/web_view/media_access/media_check_guest.html @@ -6,7 +6,7 @@ + + +

+
+ + + diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/stable/webexposed/global-interface-listing-expected.txt index e80d54c860a0b3..2fc7626bafaa44 100644 --- a/third_party/WebKit/LayoutTests/platform/linux/virtual/stable/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/stable/webexposed/global-interface-listing-expected.txt @@ -3343,6 +3343,7 @@ interface MediaStreamEvent : Event getter stream method constructor interface MediaStreamTrack : EventTarget + static method getSources attribute @@toStringTag getter enabled getter id diff --git a/third_party/WebKit/LayoutTests/platform/win/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/platform/win/virtual/stable/webexposed/global-interface-listing-expected.txt index e80d54c860a0b3..2fc7626bafaa44 100644 --- a/third_party/WebKit/LayoutTests/platform/win/virtual/stable/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/platform/win/virtual/stable/webexposed/global-interface-listing-expected.txt @@ -3343,6 +3343,7 @@ interface MediaStreamEvent : Event getter stream method constructor interface MediaStreamTrack : EventTarget + static method getSources attribute @@toStringTag getter enabled getter id diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt index 8ed92d6f49a88f..10938d8e0fa0ac 100644 --- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt @@ -3400,6 +3400,7 @@ interface MediaStreamEvent : Event getter stream method constructor interface MediaStreamTrack : EventTarget + static method getSources attribute @@toStringTag getter enabled getter id diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt index 35a2e8af07ac8a..6fb3063b34fe62 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt @@ -3987,6 +3987,7 @@ interface MediaStreamEvent : Event getter stream method constructor interface MediaStreamTrack : EventTarget + static method getSources attribute @@toStringTag getter enabled getter id diff --git a/third_party/WebKit/Source/core/frame/Deprecation.cpp b/third_party/WebKit/Source/core/frame/Deprecation.cpp index 7cf0c1230c2725..0e1022e9d7dc83 100644 --- a/third_party/WebKit/Source/core/frame/Deprecation.cpp +++ b/third_party/WebKit/Source/core/frame/Deprecation.cpp @@ -402,6 +402,10 @@ String Deprecation::deprecationMessage(UseCounter::Feature feature) { return replacedBy("'Performance.onwebkitresourcetimingbufferfull'", "'Performance.onresourcetimingbufferfull'"); + case UseCounter::MediaStreamTrackGetSources: + return willBeRemoved("MediaStreamTrack.getSources", M56, + "4765305641369600"); + case UseCounter::WebAnimationHyphenatedProperty: return "Hyphenated property names in Web Animations keyframes are " "invalid and therefore ignored. Please use camelCase instead."; diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h index 66ba14dc97f261..8f30b764646842 100644 --- a/third_party/WebKit/Source/core/frame/UseCounter.h +++ b/third_party/WebKit/Source/core/frame/UseCounter.h @@ -362,6 +362,7 @@ class CORE_EXPORT UseCounter { UseAsm = 473, DOMWindowOpen = 475, DOMWindowOpenFeatures = 476, + MediaStreamTrackGetSources = 478, AspectRatioFlexItem = 479, DetailsElement = 480, DialogElement = 481, diff --git a/third_party/WebKit/Source/modules/mediastream/BUILD.gn b/third_party/WebKit/Source/modules/mediastream/BUILD.gn index d0787b607f3f37..006dd5c0403ffb 100644 --- a/third_party/WebKit/Source/modules/mediastream/BUILD.gn +++ b/third_party/WebKit/Source/modules/mediastream/BUILD.gn @@ -26,6 +26,9 @@ blink_modules_sources("mediastream") { "MediaStreamTrack.h", "MediaStreamTrackEvent.cpp", "MediaStreamTrackEvent.h", + "MediaStreamTrackSourcesCallback.h", + "MediaStreamTrackSourcesRequestImpl.cpp", + "MediaStreamTrackSourcesRequestImpl.h", "NavigatorMediaStream.cpp", "NavigatorMediaStream.h", "NavigatorUserMedia.cpp", @@ -34,6 +37,8 @@ blink_modules_sources("mediastream") { "NavigatorUserMediaError.h", "NavigatorUserMediaErrorCallback.h", "NavigatorUserMediaSuccessCallback.h", + "SourceInfo.cpp", + "SourceInfo.h", "URLMediaStream.cpp", "URLMediaStream.h", "UserMediaClient.h", diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp index 0e4d5d1bcbbe7e..9739d9229852de 100644 --- a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp +++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp @@ -33,11 +33,14 @@ #include "core/frame/Deprecation.h" #include "modules/mediastream/MediaConstraintsImpl.h" #include "modules/mediastream/MediaStream.h" +#include "modules/mediastream/MediaStreamTrackSourcesCallback.h" +#include "modules/mediastream/MediaStreamTrackSourcesRequestImpl.h" #include "modules/mediastream/MediaTrackSettings.h" #include "modules/mediastream/UserMediaController.h" #include "platform/mediastream/MediaStreamCenter.h" #include "platform/mediastream/MediaStreamComponent.h" #include "public/platform/WebMediaStreamTrack.h" +#include "public/platform/WebSourceInfo.h" #include "wtf/Assertions.h" #include @@ -128,6 +131,24 @@ String MediaStreamTrack::readyState() const { return String(); } +void MediaStreamTrack::getSources(ExecutionContext* context, + MediaStreamTrackSourcesCallback* callback, + ExceptionState& exceptionState) { + LocalFrame* frame = toDocument(context)->frame(); + UserMediaController* userMedia = UserMediaController::from(frame); + if (!userMedia) { + exceptionState.throwDOMException( + NotSupportedError, + "No sources controller available; is this a detached window?"); + return; + } + Deprecation::countDeprecation(context, + UseCounter::MediaStreamTrackGetSources); + MediaStreamTrackSourcesRequest* request = + MediaStreamTrackSourcesRequestImpl::create(*context, callback); + userMedia->requestSources(request); +} + void MediaStreamTrack::stopTrack(ExceptionState& exceptionState) { if (ended()) return; diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.h b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.h index f9cde577560948..a18b7f6d2e35f1 100644 --- a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.h +++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.h @@ -30,6 +30,7 @@ #include "core/dom/ActiveDOMObject.h" #include "modules/EventTargetModules.h" #include "modules/ModulesExport.h" +#include "modules/mediastream/SourceInfo.h" #include "platform/mediastream/MediaStreamDescriptor.h" #include "platform/mediastream/MediaStreamSource.h" #include "public/platform/WebMediaConstraints.h" @@ -68,6 +69,9 @@ class MODULES_EXPORT MediaStreamTrack : public EventTargetWithInlineData, String readyState() const; + static void getSources(ExecutionContext*, + MediaStreamTrackSourcesCallback*, + ExceptionState&); void stopTrack(ExceptionState&); virtual MediaStreamTrack* clone(ExecutionContext*); diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.idl b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.idl index f96f1b2cdc51d3..9a2b1c4ea8f84e 100644 --- a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.idl +++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.idl @@ -54,4 +54,7 @@ enum MediaStreamTrackState { // Non-standard APIs [MeasureAs=MediaStreamTrackRemote] readonly attribute boolean remote; + // TODO(guidou): Remove MediaStreamTrack.getSources(). + // https://crbug.com/649710 + [CallWith=ExecutionContext, RaisesException, DeprecateAs=MediaStreamTrackGetSources] static void getSources(MediaStreamTrackSourcesCallback callback); }; diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesCallback.h b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesCallback.h new file mode 100644 index 00000000000000..5d4b7239507c46 --- /dev/null +++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesCallback.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef MediaStreamTrackSourcesCallback_h +#define MediaStreamTrackSourcesCallback_h + +#include "modules/mediastream/SourceInfo.h" +namespace blink { + +class MediaStreamTrackSourcesCallback + : public GarbageCollectedFinalized { + public: + virtual ~MediaStreamTrackSourcesCallback() {} + DEFINE_INLINE_VIRTUAL_TRACE() {} + virtual void handleEvent(const SourceInfoVector&) = 0; +}; + +} // namespace blink + +#endif // MediaStreamTrackSourcesCallback_h diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesCallback.idl b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesCallback.idl new file mode 100644 index 00000000000000..9756e099b7c3b2 --- /dev/null +++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesCallback.idl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// TODO(guidou): Remove MediaStreamTrack.getSources(). https://crbug.com/649710 +callback interface MediaStreamTrackSourcesCallback { + void handleEvent(sequence sources); +}; diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.cpp b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.cpp new file mode 100644 index 00000000000000..1f5dfa7c86b3ae --- /dev/null +++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "modules/mediastream/MediaStreamTrackSourcesRequestImpl.h" + +#include "core/dom/ExecutionContext.h" +#include "core/dom/ExecutionContextTask.h" +#include "modules/mediastream/MediaStreamTrackSourcesCallback.h" +#include "platform/weborigin/SecurityOrigin.h" +#include "public/platform/WebSourceInfo.h" +#include "public/platform/WebTraceLocation.h" +#include "wtf/Functional.h" + +namespace blink { + +MediaStreamTrackSourcesRequestImpl* MediaStreamTrackSourcesRequestImpl::create( + ExecutionContext& context, + MediaStreamTrackSourcesCallback* callback) { + return new MediaStreamTrackSourcesRequestImpl(context, callback); +} + +MediaStreamTrackSourcesRequestImpl::MediaStreamTrackSourcesRequestImpl( + ExecutionContext& context, + MediaStreamTrackSourcesCallback* callback) + : m_callback(callback), m_executionContext(&context) {} + +MediaStreamTrackSourcesRequestImpl::~MediaStreamTrackSourcesRequestImpl() {} + +PassRefPtr MediaStreamTrackSourcesRequestImpl::origin() { + return m_executionContext->getSecurityOrigin()->isolatedCopy(); +} + +void MediaStreamTrackSourcesRequestImpl::requestSucceeded( + const WebVector& webSourceInfos) { + DCHECK(m_callback); + + for (size_t i = 0; i < webSourceInfos.size(); ++i) + m_sourceInfos.append(SourceInfo::create(webSourceInfos[i])); + m_executionContext->postTask( + BLINK_FROM_HERE, createCrossThreadTask( + &MediaStreamTrackSourcesRequestImpl::performCallback, + wrapCrossThreadPersistent(this))); +} + +void MediaStreamTrackSourcesRequestImpl::performCallback() { + m_callback->handleEvent(m_sourceInfos); + m_callback.clear(); +} + +DEFINE_TRACE(MediaStreamTrackSourcesRequestImpl) { + visitor->trace(m_callback); + visitor->trace(m_executionContext); + visitor->trace(m_sourceInfos); + MediaStreamTrackSourcesRequest::trace(visitor); +} + +} // namespace blink diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.h b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.h new file mode 100644 index 00000000000000..fe598035d3cb00 --- /dev/null +++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef MediaStreamTrackSourcesRequestImpl_h +#define MediaStreamTrackSourcesRequestImpl_h + +#include "modules/mediastream/SourceInfo.h" +#include "platform/mediastream/MediaStreamTrackSourcesRequest.h" + +namespace blink { + +class ExecutionContext; +class MediaStreamTrackSourcesCallback; +class SecurityOrigin; +class WebSourceInfo; +template +class WebVector; + +class MediaStreamTrackSourcesRequestImpl final + : public MediaStreamTrackSourcesRequest { + public: + static MediaStreamTrackSourcesRequestImpl* create( + ExecutionContext&, + MediaStreamTrackSourcesCallback*); + ~MediaStreamTrackSourcesRequestImpl(); + + PassRefPtr origin() override; + void requestSucceeded(const WebVector&) override; + + DECLARE_VIRTUAL_TRACE(); + + private: + MediaStreamTrackSourcesRequestImpl(ExecutionContext&, + MediaStreamTrackSourcesCallback*); + + void performCallback(); + + Member m_callback; + Member m_executionContext; + SourceInfoVector m_sourceInfos; +}; + +} // namespace blink + +#endif // MediaStreamTrackSourcesRequestImpl_h diff --git a/third_party/WebKit/Source/modules/mediastream/SourceInfo.cpp b/third_party/WebKit/Source/modules/mediastream/SourceInfo.cpp new file mode 100644 index 00000000000000..b8ec9acbd294aa --- /dev/null +++ b/third_party/WebKit/Source/modules/mediastream/SourceInfo.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "modules/mediastream/SourceInfo.h" + +#include "wtf/text/WTFString.h" + +namespace blink { + +SourceInfo* SourceInfo::create(const WebSourceInfo& webSourceInfo) { + DCHECK(!webSourceInfo.isNull()); + return new SourceInfo(webSourceInfo); +} + +SourceInfo::SourceInfo(const WebSourceInfo& webSourceInfo) + : m_webSourceInfo(webSourceInfo) {} + +String SourceInfo::id() const { + return m_webSourceInfo.id(); +} + +String SourceInfo::kind() const { + switch (m_webSourceInfo.kind()) { + case WebSourceInfo::SourceKindAudio: + return "audio"; + case WebSourceInfo::SourceKindVideo: + return "video"; + case WebSourceInfo::SourceKindNone: + return "none"; + } + + NOTREACHED(); + return String(); +} + +String SourceInfo::label() const { + return m_webSourceInfo.label(); +} + +String SourceInfo::facing() const { + switch (m_webSourceInfo.facing()) { + case WebSourceInfo::VideoFacingModeNone: + return String(); + case WebSourceInfo::VideoFacingModeUser: + return "user"; + case WebSourceInfo::VideoFacingModeEnvironment: + return "environment"; + } + + NOTREACHED(); + return String(); +} + +} // namespace blink diff --git a/third_party/WebKit/Source/modules/mediastream/SourceInfo.h b/third_party/WebKit/Source/modules/mediastream/SourceInfo.h new file mode 100644 index 00000000000000..f6a92be3d576fa --- /dev/null +++ b/third_party/WebKit/Source/modules/mediastream/SourceInfo.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SourceInfo_h +#define SourceInfo_h + +#include "bindings/core/v8/ScriptWrappable.h" +#include "public/platform/WebSourceInfo.h" +#include "wtf/Vector.h" + +namespace blink { + +class SourceInfo final : public GarbageCollectedFinalized, + public ScriptWrappable { + DEFINE_WRAPPERTYPEINFO(); + + public: + static SourceInfo* create(const WebSourceInfo&); + + String id() const; + String kind() const; + String label() const; + String facing() const; + + DEFINE_INLINE_TRACE() {} + + private: + explicit SourceInfo(const WebSourceInfo&); + + WebSourceInfo m_webSourceInfo; +}; + +typedef HeapVector> SourceInfoVector; + +} // namespace blink + +#endif // SourceInfo_h diff --git a/third_party/WebKit/Source/modules/mediastream/SourceInfo.idl b/third_party/WebKit/Source/modules/mediastream/SourceInfo.idl new file mode 100644 index 00000000000000..15a0e2e9cb7a73 --- /dev/null +++ b/third_party/WebKit/Source/modules/mediastream/SourceInfo.idl @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// TODO(guidou): Remove MediaStreamTrack.getSources(). https://crbug.com/649710 +[ + NoInterfaceObject +] interface SourceInfo { + readonly attribute DOMString id; + readonly attribute DOMString kind; + readonly attribute DOMString label; + readonly attribute DOMString facing; +}; diff --git a/third_party/WebKit/Source/modules/mediastream/UserMediaClient.h b/third_party/WebKit/Source/modules/mediastream/UserMediaClient.h index 70b8fe1d783751..43e5f19c3b6948 100644 --- a/third_party/WebKit/Source/modules/mediastream/UserMediaClient.h +++ b/third_party/WebKit/Source/modules/mediastream/UserMediaClient.h @@ -34,6 +34,7 @@ #include "modules/ModulesExport.h" #include "modules/mediastream/MediaDevicesRequest.h" #include "modules/mediastream/UserMediaRequest.h" +#include "platform/mediastream/MediaStreamTrackSourcesRequest.h" #include "wtf/Allocator.h" namespace blink { @@ -48,6 +49,7 @@ class UserMediaClient { virtual void requestUserMedia(UserMediaRequest*) = 0; virtual void cancelUserMediaRequest(UserMediaRequest*) = 0; virtual void requestMediaDevices(MediaDevicesRequest*) = 0; + virtual void requestSources(MediaStreamTrackSourcesRequest*) = 0; virtual void setMediaDeviceChangeObserver(MediaDevices*) = 0; virtual ~UserMediaClient() {} }; diff --git a/third_party/WebKit/Source/modules/mediastream/UserMediaController.h b/third_party/WebKit/Source/modules/mediastream/UserMediaController.h index 6ec50e82abb4c8..2d75eea0f29ea8 100644 --- a/third_party/WebKit/Source/modules/mediastream/UserMediaController.h +++ b/third_party/WebKit/Source/modules/mediastream/UserMediaController.h @@ -49,6 +49,7 @@ class UserMediaController final void requestUserMedia(UserMediaRequest*); void cancelUserMediaRequest(UserMediaRequest*); void requestMediaDevices(MediaDevicesRequest*); + void requestSources(MediaStreamTrackSourcesRequest*); void setMediaDeviceChangeObserver(MediaDevices*); static const char* supplementName(); @@ -77,6 +78,11 @@ inline void UserMediaController::requestMediaDevices( m_client->requestMediaDevices(request); } +inline void UserMediaController::requestSources( + MediaStreamTrackSourcesRequest* request) { + m_client->requestSources(request); +} + inline void UserMediaController::setMediaDeviceChangeObserver( MediaDevices* observer) { m_client->setMediaDeviceChangeObserver(observer); diff --git a/third_party/WebKit/Source/modules/modules_idl_files.gni b/third_party/WebKit/Source/modules/modules_idl_files.gni index 07b2c77d54b15d..6fe5468d0359bb 100644 --- a/third_party/WebKit/Source/modules/modules_idl_files.gni +++ b/third_party/WebKit/Source/modules/modules_idl_files.gni @@ -159,9 +159,11 @@ modules_idl_files = "mediastream/MediaStreamEvent.idl", "mediastream/MediaStreamTrack.idl", "mediastream/MediaStreamTrackEvent.idl", + "mediastream/MediaStreamTrackSourcesCallback.idl", "mediastream/NavigatorUserMediaError.idl", "mediastream/NavigatorUserMediaErrorCallback.idl", "mediastream/NavigatorUserMediaSuccessCallback.idl", + "mediastream/SourceInfo.idl", "netinfo/NetworkInformation.idl", "nfc/MessageCallback.idl", "nfc/NFC.idl", diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn index d30b517da7666c..49933c0e5c583c 100644 --- a/third_party/WebKit/Source/platform/BUILD.gn +++ b/third_party/WebKit/Source/platform/BUILD.gn @@ -524,6 +524,7 @@ component("platform") { "exported/WebMediaStream.cpp", "exported/WebMediaStreamSource.cpp", "exported/WebMediaStreamTrack.cpp", + "exported/WebMediaStreamTrackSourcesRequest.cpp", "exported/WebMemoryCoordinator.cpp", "exported/WebMessagePortChannelClient.cpp", "exported/WebMixedContent.cpp", @@ -553,6 +554,7 @@ component("platform") { "exported/WebServiceWorkerProxy.cpp", "exported/WebServiceWorkerRequest.cpp", "exported/WebServiceWorkerResponse.cpp", + "exported/WebSourceInfo.cpp", "exported/WebSpeechSynthesisUtterance.cpp", "exported/WebSpeechSynthesisVoice.cpp", "exported/WebSpeechSynthesizerClientImpl.cpp", @@ -1076,6 +1078,7 @@ component("platform") { "mediastream/MediaStreamDescriptor.h", "mediastream/MediaStreamSource.cpp", "mediastream/MediaStreamSource.h", + "mediastream/MediaStreamTrackSourcesRequest.h", "mediastream/MediaStreamWebAudioSource.cpp", "mediastream/MediaStreamWebAudioSource.h", "mhtml/ArchiveResource.cpp", diff --git a/third_party/WebKit/Source/platform/exported/WebMediaStreamTrackSourcesRequest.cpp b/third_party/WebKit/Source/platform/exported/WebMediaStreamTrackSourcesRequest.cpp new file mode 100644 index 00000000000000..128fbe40212d72 --- /dev/null +++ b/third_party/WebKit/Source/platform/exported/WebMediaStreamTrackSourcesRequest.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "public/platform/WebMediaStreamTrackSourcesRequest.h" + +#include "platform/mediastream/MediaStreamTrackSourcesRequest.h" +#include "platform/weborigin/SecurityOrigin.h" +#include "public/platform/WebSourceInfo.h" +#include "wtf/text/WTFString.h" + +namespace blink { + +WebMediaStreamTrackSourcesRequest::WebMediaStreamTrackSourcesRequest( + MediaStreamTrackSourcesRequest* request) + : m_private(request) {} + +void WebMediaStreamTrackSourcesRequest::assign( + const WebMediaStreamTrackSourcesRequest& other) { + m_private = other.m_private; +} + +void WebMediaStreamTrackSourcesRequest::reset() { + m_private.reset(); +} + +WebSecurityOrigin WebMediaStreamTrackSourcesRequest::origin() const { + ASSERT(m_private.get()); + return m_private->origin(); +} + +void WebMediaStreamTrackSourcesRequest::requestSucceeded( + const WebVector& sourceInfos) const { + ASSERT(m_private.get()); + m_private->requestSucceeded(sourceInfos); +} + +} // namespace blink diff --git a/third_party/WebKit/Source/platform/exported/WebSourceInfo.cpp b/third_party/WebKit/Source/platform/exported/WebSourceInfo.cpp new file mode 100644 index 00000000000000..e5f6cddad3a63d --- /dev/null +++ b/third_party/WebKit/Source/platform/exported/WebSourceInfo.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "public/platform/WebSourceInfo.h" + +#include "public/platform/WebString.h" +#include "wtf/PassRefPtr.h" +#include "wtf/RefCounted.h" + +namespace blink { + +class WebSourceInfoPrivate final : public RefCounted { + public: + static PassRefPtr create( + const WebString& id, + WebSourceInfo::SourceKind, + const WebString& label, + WebSourceInfo::VideoFacingMode); + + const WebString& id() const { return m_id; } + WebSourceInfo::SourceKind kind() const { return m_kind; } + const WebString& label() const { return m_label; } + WebSourceInfo::VideoFacingMode facing() const { return m_facing; } + + private: + WebSourceInfoPrivate(const WebString& id, + WebSourceInfo::SourceKind, + const WebString& label, + WebSourceInfo::VideoFacingMode); + + WebString m_id; + WebSourceInfo::SourceKind m_kind; + WebString m_label; + WebSourceInfo::VideoFacingMode m_facing; +}; + +PassRefPtr WebSourceInfoPrivate::create( + const WebString& id, + WebSourceInfo::SourceKind kind, + const WebString& label, + WebSourceInfo::VideoFacingMode facing) { + return adoptRef(new WebSourceInfoPrivate(id, kind, label, facing)); +} + +WebSourceInfoPrivate::WebSourceInfoPrivate( + const WebString& id, + WebSourceInfo::SourceKind kind, + const WebString& label, + WebSourceInfo::VideoFacingMode facing) + : m_id(id), m_kind(kind), m_label(label), m_facing(facing) {} + +void WebSourceInfo::assign(const WebSourceInfo& other) { + m_private = other.m_private; +} + +void WebSourceInfo::reset() { + m_private.reset(); +} + +void WebSourceInfo::initialize(const WebString& id, + WebSourceInfo::SourceKind kind, + const WebString& label, + WebSourceInfo::VideoFacingMode facing) { + m_private = WebSourceInfoPrivate::create(id, kind, label, facing); +} + +WebString WebSourceInfo::id() const { + ASSERT(!m_private.isNull()); + return m_private->id(); +} + +WebSourceInfo::SourceKind WebSourceInfo::kind() const { + ASSERT(!m_private.isNull()); + return m_private->kind(); +} + +WebString WebSourceInfo::label() const { + ASSERT(!m_private.isNull()); + return m_private->label(); +} + +WebSourceInfo::VideoFacingMode WebSourceInfo::facing() const { + ASSERT(!m_private.isNull()); + return m_private->facing(); +} + +} // namespace blink diff --git a/third_party/WebKit/Source/platform/mediastream/MediaStreamCenter.cpp b/third_party/WebKit/Source/platform/mediastream/MediaStreamCenter.cpp index 869d179d923f8b..b3aae6b33448e4 100644 --- a/third_party/WebKit/Source/platform/mediastream/MediaStreamCenter.cpp +++ b/third_party/WebKit/Source/platform/mediastream/MediaStreamCenter.cpp @@ -32,6 +32,7 @@ #include "platform/mediastream/MediaStreamCenter.h" #include "platform/mediastream/MediaStreamDescriptor.h" +#include "platform/mediastream/MediaStreamTrackSourcesRequest.h" #include "platform/mediastream/MediaStreamWebAudioSource.h" #include "public/platform/Platform.h" #include "public/platform/WebAudioSourceProvider.h" diff --git a/third_party/WebKit/Source/platform/mediastream/MediaStreamTrackSourcesRequest.h b/third_party/WebKit/Source/platform/mediastream/MediaStreamTrackSourcesRequest.h new file mode 100644 index 00000000000000..37f351ad3ccab2 --- /dev/null +++ b/third_party/WebKit/Source/platform/mediastream/MediaStreamTrackSourcesRequest.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef MediaStreamTrackSourcesRequest_h +#define MediaStreamTrackSourcesRequest_h + +#include "platform/heap/Handle.h" +#include "public/platform/WebVector.h" +#include "wtf/Forward.h" + +namespace blink { + +class SecurityOrigin; +class WebSourceInfo; + +class MediaStreamTrackSourcesRequest + : public GarbageCollectedFinalized { + public: + virtual ~MediaStreamTrackSourcesRequest() {} + + virtual PassRefPtr origin() = 0; + virtual void requestSucceeded(const WebVector&) = 0; + + DEFINE_INLINE_VIRTUAL_TRACE() {} + + protected: + MediaStreamTrackSourcesRequest() {} +}; + +} // namespace blink + +#endif // MediaStreamTrackSourcesRequest_h diff --git a/third_party/WebKit/Source/web/UserMediaClientImpl.cpp b/third_party/WebKit/Source/web/UserMediaClientImpl.cpp index 90f266283d0518..185f76125d1510 100644 --- a/third_party/WebKit/Source/web/UserMediaClientImpl.cpp +++ b/third_party/WebKit/Source/web/UserMediaClientImpl.cpp @@ -30,6 +30,7 @@ #include "web/UserMediaClientImpl.h" +#include "public/platform/WebMediaStreamTrackSourcesRequest.h" #include "public/web/WebFrameClient.h" #include "public/web/WebMediaDeviceChangeObserver.h" #include "public/web/WebMediaDevicesRequest.h" @@ -58,6 +59,12 @@ void UserMediaClientImpl::requestMediaDevices(MediaDevicesRequest* request) { m_client->requestMediaDevices(request); } +void UserMediaClientImpl::requestSources( + MediaStreamTrackSourcesRequest* request) { + if (m_client) + m_client->requestSources(request); +} + void UserMediaClientImpl::setMediaDeviceChangeObserver(MediaDevices* observer) { if (m_client) m_client->setMediaDeviceChangeObserver( diff --git a/third_party/WebKit/Source/web/UserMediaClientImpl.h b/third_party/WebKit/Source/web/UserMediaClientImpl.h index 36994c583f68b4..855ea71d0d8385 100644 --- a/third_party/WebKit/Source/web/UserMediaClientImpl.h +++ b/third_party/WebKit/Source/web/UserMediaClientImpl.h @@ -52,6 +52,7 @@ class UserMediaClientImpl final : public UserMediaClient { void requestUserMedia(UserMediaRequest*) override; void cancelUserMediaRequest(UserMediaRequest*) override; void requestMediaDevices(MediaDevicesRequest*) override; + void requestSources(MediaStreamTrackSourcesRequest*) override; void setMediaDeviceChangeObserver(MediaDevices*) override; private: diff --git a/third_party/WebKit/public/BUILD.gn b/third_party/WebKit/public/BUILD.gn index ea700035fa52f9..ec7c26225329d9 100644 --- a/third_party/WebKit/public/BUILD.gn +++ b/third_party/WebKit/public/BUILD.gn @@ -285,6 +285,7 @@ source_set("blink_headers") { "platform/WebSize.h", "platform/WebSourceBuffer.h", "platform/WebSourceBufferClient.h", + "platform/WebSourceInfo.h", "platform/WebSpeechSynthesisUtterance.h", "platform/WebSpeechSynthesisVoice.h", "platform/WebSpeechSynthesizer.h", diff --git a/third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h b/third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h new file mode 100644 index 00000000000000..b84dcab229e162 --- /dev/null +++ b/third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebMediaStreamTrackSourcesRequest_h +#define WebMediaStreamTrackSourcesRequest_h + +#include "WebCommon.h" +#include "WebNonCopyable.h" +#include "WebPrivatePtr.h" +#include "WebSecurityOrigin.h" +#include "WebVector.h" + +namespace blink { + +class MediaStreamTrackSourcesRequest; +class WebSourceInfo; + +class WebMediaStreamTrackSourcesRequest { + public: + WebMediaStreamTrackSourcesRequest() {} + WebMediaStreamTrackSourcesRequest( + const WebMediaStreamTrackSourcesRequest& other) { + assign(other); + } + ~WebMediaStreamTrackSourcesRequest() { reset(); } + + WebMediaStreamTrackSourcesRequest& operator=( + const WebMediaStreamTrackSourcesRequest& other) { + assign(other); + return *this; + } + + BLINK_PLATFORM_EXPORT void assign(const WebMediaStreamTrackSourcesRequest&); + + BLINK_PLATFORM_EXPORT void reset(); + bool isNull() const { return m_private.isNull(); } + + BLINK_PLATFORM_EXPORT WebSecurityOrigin origin() const; + BLINK_PLATFORM_EXPORT void requestSucceeded( + const WebVector&) const; + +#if INSIDE_BLINK + BLINK_PLATFORM_EXPORT WebMediaStreamTrackSourcesRequest( + MediaStreamTrackSourcesRequest*); +#endif + + private: + WebPrivatePtr m_private; +}; + +} // namespace blink + +#endif // WebMediaStreamTrackSourcesRequest_h diff --git a/third_party/WebKit/public/platform/WebSourceInfo.h b/third_party/WebKit/public/platform/WebSourceInfo.h new file mode 100644 index 00000000000000..7bf922ee47073b --- /dev/null +++ b/third_party/WebKit/public/platform/WebSourceInfo.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebSourceInfo_h +#define WebSourceInfo_h + +#include "WebCommon.h" +#include "WebNonCopyable.h" +#include "WebPrivatePtr.h" +#include "WebString.h" + +namespace blink { + +class WebSourceInfoPrivate; + +class WebSourceInfo { + public: + enum SourceKind { SourceKindNone, SourceKindAudio, SourceKindVideo }; + + enum VideoFacingMode { + VideoFacingModeNone, + VideoFacingModeUser, + VideoFacingModeEnvironment + }; + + WebSourceInfo() {} + WebSourceInfo(const WebSourceInfo& other) { assign(other); } + ~WebSourceInfo() { reset(); } + + WebSourceInfo& operator=(const WebSourceInfo& other) { + assign(other); + return *this; + } + + BLINK_PLATFORM_EXPORT void assign(const WebSourceInfo&); + + BLINK_PLATFORM_EXPORT void initialize(const WebString& id, + SourceKind, + const WebString& label, + VideoFacingMode); + BLINK_PLATFORM_EXPORT void reset(); + bool isNull() const { return m_private.isNull(); } + + BLINK_PLATFORM_EXPORT WebString id() const; + BLINK_PLATFORM_EXPORT SourceKind kind() const; + BLINK_PLATFORM_EXPORT WebString label() const; + BLINK_PLATFORM_EXPORT VideoFacingMode facing() const; + + private: + WebPrivatePtr m_private; +}; + +} // namespace blink + +#endif // WebSourceInfo_h diff --git a/third_party/WebKit/public/web/WebUserMediaClient.h b/third_party/WebKit/public/web/WebUserMediaClient.h index 1c7ba633551538..2a5055793efa21 100644 --- a/third_party/WebKit/public/web/WebUserMediaClient.h +++ b/third_party/WebKit/public/web/WebUserMediaClient.h @@ -34,6 +34,7 @@ namespace blink { class WebMediaDevicesRequest; +class WebMediaStreamTrackSourcesRequest; class WebUserMediaRequest; class WebMediaDeviceChangeObserver; @@ -44,6 +45,7 @@ class WebUserMediaClient { virtual void requestUserMedia(const WebUserMediaRequest&) = 0; virtual void cancelUserMediaRequest(const WebUserMediaRequest&) = 0; virtual void requestMediaDevices(const WebMediaDevicesRequest&) = 0; + virtual void requestSources(const WebMediaStreamTrackSourcesRequest&) = 0; virtual void setMediaDeviceChangeObserver( const WebMediaDeviceChangeObserver&) = 0; };