From: tommyw@google.com Date: Thu, 2 Feb 2012 20:53:58 +0000 (+0000) Subject: [chromium] MediaStream API: Adding the embedding code for MediaStreamCenter X-Git-Tag: 070512121124~13931 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0a87f619d8ddb33dbe065d0ab76e973efe8e2fa;p=profile%2Fivi%2Fwebkit-efl.git [chromium] MediaStream API: Adding the embedding code for MediaStreamCenter https://bugs.webkit.org/show_bug.cgi?id=73130 Reviewed by Darin Fisher. Source/WebCore: Tests for the Media Stream API will be provided by the bug 56587, pending enough landed code. * mediastream/UserMediaClient.h: (UserMediaClient): * mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::didCompleteQuery): * mediastream/UserMediaRequest.h: (UserMediaRequest): (WebCore::UserMediaRequest::audio): (WebCore::UserMediaRequest::video): (WebCore::UserMediaRequest::cameraPreferenceUser): (WebCore::UserMediaRequest::cameraPreferenceEnvironment): * platform/mediastream/MediaStreamCenter.cpp: (WebCore): (WebCore::MediaStreamCenter::queryMediaStreamSources): * platform/mediastream/MediaStreamCenter.h: (WebCore): (MediaStreamSourcesQueryClient): (MediaStreamCenter): Source/WebKit/chromium: * WebKit.gyp: * bridge/MediaStreamCenter.cpp: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. (WebCore): (WebCore::MediaStreamCenter::MediaStreamCenter): (WebCore::MediaStreamCenter::~MediaStreamCenter): (WebCore::MediaStreamCenter::queryMediaStreamSources): (WebCore::MediaStreamCenter::didSetMediaStreamTrackEnabled): (WebCore::MediaStreamCenter::didStopLocalMediaStream): (WebCore::MediaStreamCenter::didConstructMediaStream): * bridge/MediaStreamCenterInternal.cpp: Added. (WebCore): (WebCore::MediaStreamCenterInternal::MediaStreamCenterInternal): (WebCore::MediaStreamCenterInternal::~MediaStreamCenterInternal): (WebCore::MediaStreamCenterInternal::queryMediaStreamSources): (WebCore::MediaStreamCenterInternal::didSetMediaStreamTrackEnabled): (WebCore::MediaStreamCenterInternal::didStopLocalMediaStream): (WebCore::MediaStreamCenterInternal::didConstructMediaStream): (WebCore::MediaStreamCenterInternal::stopLocalMediaStream): * bridge/MediaStreamCenterInternal.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. (WebKit): (WebCore): (MediaStreamCenterInternal): * public/platform/WebKitPlatformSupport.h: (WebKit): (WebKit::WebKitPlatformSupport::createMediaStreamCenter): * public/platform/WebMediaStreamCenter.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. (WebKit): (WebMediaStreamCenter): (WebKit::WebMediaStreamCenter::~WebMediaStreamCenter): * public/platform/WebMediaStreamCenterClient.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. (WebKit): (WebMediaStreamCenterClient): (WebKit::WebMediaStreamCenterClient::~WebMediaStreamCenterClient): * public/platform/WebMediaStreamComponent.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. (WebCore): (WebKit): (WebMediaStreamComponent): (WebKit::WebMediaStreamComponent::WebMediaStreamComponent): (WebKit::WebMediaStreamComponent::~WebMediaStreamComponent): (WebKit::WebMediaStreamComponent::isNull): * public/platform/WebMediaStreamDescriptor.h: (WebKit): (WebMediaStreamDescriptor): * public/platform/WebMediaStreamSourcesRequest.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. (WebCore): (WebKit): (WebMediaStreamSourcesRequest): (WebKit::WebMediaStreamSourcesRequest::WebMediaStreamSourcesRequest): (WebKit::WebMediaStreamSourcesRequest::~WebMediaStreamSourcesRequest): (WebKit::WebMediaStreamSourcesRequest::isNull): * src/UserMediaClientImpl.h: (UserMediaClientImpl): * src/WebMediaStreamComponent.cpp: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. (WebKit): (WebKit::WebMediaStreamComponent::WebMediaStreamComponent): (WebKit::WebMediaStreamComponent::operator=): (WebKit::WebMediaStreamComponent::reset): (WebKit::WebMediaStreamComponent::operator PassRefPtr): (WebKit::WebMediaStreamComponent::operator MediaStreamComponent*): (WebKit::WebMediaStreamComponent::isEnabled): (WebKit::WebMediaStreamComponent::source): * src/WebMediaStreamDescriptor.cpp: (WebKit::WebMediaStreamDescriptor::WebMediaStreamDescriptor): (WebKit): (WebKit::WebMediaStreamDescriptor::audioSources): (WebKit::WebMediaStreamDescriptor::videoSources): * src/WebMediaStreamSourcesRequest.cpp: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. (WebKit): (WebKit::WebMediaStreamSourcesRequest::WebMediaStreamSourcesRequest): (WebKit::WebMediaStreamSourcesRequest::reset): (WebKit::WebMediaStreamSourcesRequest::audio): (WebKit::WebMediaStreamSourcesRequest::video): (WebKit::WebMediaStreamSourcesRequest::didCompleteQuery): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106581 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index a92efb1..a7f420e 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,30 @@ +2012-02-02 Tommy Widenflycht + + [chromium] MediaStream API: Adding the embedding code for MediaStreamCenter + https://bugs.webkit.org/show_bug.cgi?id=73130 + + Reviewed by Darin Fisher. + + Tests for the Media Stream API will be provided by the bug 56587, pending enough landed code. + + * mediastream/UserMediaClient.h: + (UserMediaClient): + * mediastream/UserMediaRequest.cpp: + (WebCore::UserMediaRequest::didCompleteQuery): + * mediastream/UserMediaRequest.h: + (UserMediaRequest): + (WebCore::UserMediaRequest::audio): + (WebCore::UserMediaRequest::video): + (WebCore::UserMediaRequest::cameraPreferenceUser): + (WebCore::UserMediaRequest::cameraPreferenceEnvironment): + * platform/mediastream/MediaStreamCenter.cpp: + (WebCore): + (WebCore::MediaStreamCenter::queryMediaStreamSources): + * platform/mediastream/MediaStreamCenter.h: + (WebCore): + (MediaStreamSourcesQueryClient): + (MediaStreamCenter): + 2012-02-02 Raymond Toy Constant values to set "distanceModel" are undefined diff --git a/Source/WebCore/mediastream/UserMediaClient.h b/Source/WebCore/mediastream/UserMediaClient.h index ce67433..c8e2952 100644 --- a/Source/WebCore/mediastream/UserMediaClient.h +++ b/Source/WebCore/mediastream/UserMediaClient.h @@ -42,7 +42,7 @@ class UserMediaClient { public: virtual void pageDestroyed() = 0; - virtual void requestUserMedia(PassRefPtr, const MediaStreamSourceVector&, const MediaStreamSourceVector&) = 0; + virtual void requestUserMedia(PassRefPtr, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources) = 0; virtual void cancelUserMediaRequest(UserMediaRequest*) = 0; protected: diff --git a/Source/WebCore/mediastream/UserMediaRequest.cpp b/Source/WebCore/mediastream/UserMediaRequest.cpp index f875d37..faf3d4d 100644 --- a/Source/WebCore/mediastream/UserMediaRequest.cpp +++ b/Source/WebCore/mediastream/UserMediaRequest.cpp @@ -71,7 +71,7 @@ void UserMediaRequest::start() MediaStreamCenter::instance().queryMediaStreamSources(this); } -void UserMediaRequest::mediaStreamSourcesQueryCompleted(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources) +void UserMediaRequest::didCompleteQuery(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources) { if (m_client) m_client->requestUserMedia(this, audioSources, videoSources); diff --git a/Source/WebCore/mediastream/UserMediaRequest.h b/Source/WebCore/mediastream/UserMediaRequest.h index 90d5527..a71b5e9 100644 --- a/Source/WebCore/mediastream/UserMediaRequest.h +++ b/Source/WebCore/mediastream/UserMediaRequest.h @@ -51,21 +51,21 @@ public: static PassRefPtr create(ScriptExecutionContext*, UserMediaClient*, const String& options, PassRefPtr, PassRefPtr); ~UserMediaRequest(); - bool audio() const { return m_audio; } - bool video() const { return m_video; } - - bool cameraPreferenceUser() const { return m_cameraPreferenceUser; } - bool cameraPreferenceEnvironment() const { return m_cameraPreferenceEnvironment; } - NavigatorUserMediaSuccessCallback* successCallback() const { return m_successCallback.get(); } NavigatorUserMediaErrorCallback* errorCallback() const { return m_errorCallback.get(); } void start(); - void mediaStreamSourcesQueryCompleted(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources); void succeed(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources); void fail(); + // MediaStreamSourcesQueryClient + virtual bool audio() const { return m_audio; } + virtual bool video() const { return m_video; } + virtual bool cameraPreferenceUser() const { return m_cameraPreferenceUser; } + virtual bool cameraPreferenceEnvironment() const { return m_cameraPreferenceEnvironment; } + virtual void didCompleteQuery(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources); + // ContextDestructionObserver virtual void contextDestroyed(); diff --git a/Source/WebCore/platform/mediastream/MediaStreamCenter.cpp b/Source/WebCore/platform/mediastream/MediaStreamCenter.cpp index 9203ce3..abccf5b 100644 --- a/Source/WebCore/platform/mediastream/MediaStreamCenter.cpp +++ b/Source/WebCore/platform/mediastream/MediaStreamCenter.cpp @@ -55,8 +55,9 @@ void MediaStreamCenter::endLocalMediaStream(MediaStreamDescriptor* streamDescrip streamDescriptor->setEnded(); } -// FIXME: remove when real implementations are available -// Empty implementations for ports that build with MEDIA_STREAM enabled by default. +#if !PLATFORM(CHROMIUM) + +// Empty implementations for ports that build with MEDIA_STREAM enabled by default, but haven't yet implemented MediaStreamCenter. MediaStreamCenter::MediaStreamCenter() { @@ -69,7 +70,7 @@ MediaStreamCenter::~MediaStreamCenter() void MediaStreamCenter::queryMediaStreamSources(PassRefPtr client) { MediaStreamSourceVector audioSources, videoSources; - client->mediaStreamSourcesQueryCompleted(audioSources, videoSources); + client->didCompleteQuery(audioSources, videoSources); } void MediaStreamCenter::didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*) @@ -84,6 +85,8 @@ void MediaStreamCenter::didConstructMediaStream(MediaStreamDescriptor*) { } +#endif // !PLATFORM(CHROMIUM) + } // namespace WebCore #endif // ENABLE(MEDIA_STREAM) diff --git a/Source/WebCore/platform/mediastream/MediaStreamCenter.h b/Source/WebCore/platform/mediastream/MediaStreamCenter.h index 7d98fc5..a37d66a 100644 --- a/Source/WebCore/platform/mediastream/MediaStreamCenter.h +++ b/Source/WebCore/platform/mediastream/MediaStreamCenter.h @@ -38,6 +38,10 @@ namespace WebCore { +#if PLATFORM(CHROMIUM) +class MediaStreamCenterInternal; +#endif + class MediaStreamComponent; class MediaStreamDescriptor; @@ -47,8 +51,10 @@ public: virtual bool audio() const = 0; virtual bool video() const = 0; + virtual bool cameraPreferenceUser() const = 0; + virtual bool cameraPreferenceEnvironment() const = 0; - virtual void mediaStreamSourcesQueryCompleted(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources) = 0; + virtual void didCompleteQuery(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources) = 0; }; class MediaStreamCenter { @@ -73,6 +79,10 @@ public: private: MediaStreamCenter(); + +#if PLATFORM(CHROMIUM) + OwnPtr m_private; +#endif }; } // namespace WebCore diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index e7b53c7..6b2f63d 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,84 @@ +2012-02-02 Tommy Widenflycht + + [chromium] MediaStream API: Adding the embedding code for MediaStreamCenter + https://bugs.webkit.org/show_bug.cgi?id=73130 + + Reviewed by Darin Fisher. + + * WebKit.gyp: + * bridge/MediaStreamCenter.cpp: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. + (WebCore): + (WebCore::MediaStreamCenter::MediaStreamCenter): + (WebCore::MediaStreamCenter::~MediaStreamCenter): + (WebCore::MediaStreamCenter::queryMediaStreamSources): + (WebCore::MediaStreamCenter::didSetMediaStreamTrackEnabled): + (WebCore::MediaStreamCenter::didStopLocalMediaStream): + (WebCore::MediaStreamCenter::didConstructMediaStream): + * bridge/MediaStreamCenterInternal.cpp: Added. + (WebCore): + (WebCore::MediaStreamCenterInternal::MediaStreamCenterInternal): + (WebCore::MediaStreamCenterInternal::~MediaStreamCenterInternal): + (WebCore::MediaStreamCenterInternal::queryMediaStreamSources): + (WebCore::MediaStreamCenterInternal::didSetMediaStreamTrackEnabled): + (WebCore::MediaStreamCenterInternal::didStopLocalMediaStream): + (WebCore::MediaStreamCenterInternal::didConstructMediaStream): + (WebCore::MediaStreamCenterInternal::stopLocalMediaStream): + * bridge/MediaStreamCenterInternal.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. + (WebKit): + (WebCore): + (MediaStreamCenterInternal): + * public/platform/WebKitPlatformSupport.h: + (WebKit): + (WebKit::WebKitPlatformSupport::createMediaStreamCenter): + * public/platform/WebMediaStreamCenter.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. + (WebKit): + (WebMediaStreamCenter): + (WebKit::WebMediaStreamCenter::~WebMediaStreamCenter): + * public/platform/WebMediaStreamCenterClient.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. + (WebKit): + (WebMediaStreamCenterClient): + (WebKit::WebMediaStreamCenterClient::~WebMediaStreamCenterClient): + * public/platform/WebMediaStreamComponent.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. + (WebCore): + (WebKit): + (WebMediaStreamComponent): + (WebKit::WebMediaStreamComponent::WebMediaStreamComponent): + (WebKit::WebMediaStreamComponent::~WebMediaStreamComponent): + (WebKit::WebMediaStreamComponent::isNull): + * public/platform/WebMediaStreamDescriptor.h: + (WebKit): + (WebMediaStreamDescriptor): + * public/platform/WebMediaStreamSourcesRequest.h: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. + (WebCore): + (WebKit): + (WebMediaStreamSourcesRequest): + (WebKit::WebMediaStreamSourcesRequest::WebMediaStreamSourcesRequest): + (WebKit::WebMediaStreamSourcesRequest::~WebMediaStreamSourcesRequest): + (WebKit::WebMediaStreamSourcesRequest::isNull): + * src/UserMediaClientImpl.h: + (UserMediaClientImpl): + * src/WebMediaStreamComponent.cpp: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. + (WebKit): + (WebKit::WebMediaStreamComponent::WebMediaStreamComponent): + (WebKit::WebMediaStreamComponent::operator=): + (WebKit::WebMediaStreamComponent::reset): + (WebKit::WebMediaStreamComponent::operator PassRefPtr): + (WebKit::WebMediaStreamComponent::operator MediaStreamComponent*): + (WebKit::WebMediaStreamComponent::isEnabled): + (WebKit::WebMediaStreamComponent::source): + * src/WebMediaStreamDescriptor.cpp: + (WebKit::WebMediaStreamDescriptor::WebMediaStreamDescriptor): + (WebKit): + (WebKit::WebMediaStreamDescriptor::audioSources): + (WebKit::WebMediaStreamDescriptor::videoSources): + * src/WebMediaStreamSourcesRequest.cpp: Copied from Source/WebKit/chromium/src/UserMediaClientImpl.h. + (WebKit): + (WebKit::WebMediaStreamSourcesRequest::WebMediaStreamSourcesRequest): + (WebKit::WebMediaStreamSourcesRequest::reset): + (WebKit::WebMediaStreamSourcesRequest::audio): + (WebKit::WebMediaStreamSourcesRequest::video): + (WebKit::WebMediaStreamSourcesRequest::didCompleteQuery): + 2012-02-02 Sheriff Bot Unreviewed. Rolled DEPS. diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index 1dc2957..68c9bb2 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -91,6 +91,9 @@ 'WEBKIT_IMPLEMENTATION=1', ], 'sources': [ + 'bridge/MediaStreamCenter.cpp', + 'bridge/MediaStreamCenterInternal.cpp', + 'bridge/MediaStreamCenterInternal.h', 'bridge/PeerConnectionHandler.cpp', 'bridge/PeerConnectionHandlerInternal.cpp', 'bridge/PeerConnectionHandlerInternal.h', @@ -312,8 +315,11 @@ 'public/platform/WebLayerTreeView.h', 'public/platform/WebLayerTreeViewClient.h', 'public/platform/WebLocalizedString.h', + 'public/platform/WebMediaStreamCenter.h', + 'public/platform/WebMediaStreamComponent.h', 'public/platform/WebMediaStreamDescriptor.h', 'public/platform/WebMediaStreamSource.h', + 'public/platform/WebMediaStreamSourcesRequest.h', 'public/platform/WebNonCopyable.h', 'public/platform/WebPeerConnectionHandler.h', 'public/platform/WebPeerConnectionHandlerClient.h', @@ -597,9 +603,11 @@ 'src/WebMediaElement.cpp', 'src/WebMediaPlayerClientImpl.cpp', 'src/WebMediaPlayerClientImpl.h', + 'src/WebMediaStreamComponent.cpp', 'src/WebMediaStreamDescriptor.cpp', 'src/WebMediaStreamRegistry.cpp', 'src/WebMediaStreamSource.cpp', + 'src/WebMediaStreamSourcesRequest.cpp', 'src/WebNamedNodeMap.cpp', 'src/WebNetworkStateNotifier.cpp', 'src/WebNode.cpp', diff --git a/Source/WebKit/chromium/bridge/MediaStreamCenter.cpp b/Source/WebKit/chromium/bridge/MediaStreamCenter.cpp new file mode 100644 index 0000000..99f636d --- /dev/null +++ b/Source/WebKit/chromium/bridge/MediaStreamCenter.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "config.h" + +#if ENABLE(MEDIA_STREAM) + +#include "MediaStreamCenter.h" + +#include "MediaStreamCenterInternal.h" +#include "MediaStreamDescriptor.h" +#include + +namespace WebCore { + +MediaStreamCenter::MediaStreamCenter() + : m_private(adoptPtr(new MediaStreamCenterInternal(this))) +{ +} + +MediaStreamCenter::~MediaStreamCenter() +{ +} + +void MediaStreamCenter::queryMediaStreamSources(PassRefPtr client) +{ + m_private->queryMediaStreamSources(client); +} + +void MediaStreamCenter::didSetMediaStreamTrackEnabled(MediaStreamDescriptor* stream, MediaStreamComponent* component) +{ + m_private->didSetMediaStreamTrackEnabled(stream, component); +} + +void MediaStreamCenter::didStopLocalMediaStream(MediaStreamDescriptor* stream) +{ + m_private->didStopLocalMediaStream(stream); +} + +void MediaStreamCenter::didConstructMediaStream(MediaStreamDescriptor* stream) +{ + m_private->didConstructMediaStream(stream); +} + +} // namespace WebCore + +#endif // ENABLE(MEDIA_STREAM) diff --git a/Source/WebKit/chromium/bridge/MediaStreamCenterInternal.cpp b/Source/WebKit/chromium/bridge/MediaStreamCenterInternal.cpp new file mode 100644 index 0000000..a8693b4 --- /dev/null +++ b/Source/WebKit/chromium/bridge/MediaStreamCenterInternal.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "config.h" + +#if ENABLE(MEDIA_STREAM) + +#include "MediaStreamCenterInternal.h" + +#include "MediaStreamCenter.h" +#include "MediaStreamComponent.h" +#include "MediaStreamSource.h" +#include "WebKit.h" +#include "platform/WebKitPlatformSupport.h" +#include "platform/WebMediaStreamCenter.h" +#include "platform/WebMediaStreamComponent.h" +#include "platform/WebMediaStreamDescriptor.h" +#include "platform/WebMediaStreamSourcesRequest.h" +#include + +namespace WebCore { + +MediaStreamCenterInternal::MediaStreamCenterInternal(MediaStreamCenter* owner) + : m_private(adoptPtr(WebKit::webKitPlatformSupport()->createMediaStreamCenter(this))) + , m_owner(owner) +{ +} + +MediaStreamCenterInternal::~MediaStreamCenterInternal() +{ +} + +void MediaStreamCenterInternal::queryMediaStreamSources(PassRefPtr client) +{ + // FIXME: Remove this "short-circuit" and forward to m_private when Chrome has implemented WebMediaStreamCenter. + MediaStreamSourceVector audioSources, videoSources; + client->didCompleteQuery(audioSources, videoSources); +} + +void MediaStreamCenterInternal::didSetMediaStreamTrackEnabled(MediaStreamDescriptor* stream, MediaStreamComponent* component) +{ + if (m_private) { + if (component->enabled()) + m_private->didEnableMediaStreamTrack(stream, component); + else + m_private->didDisableMediaStreamTrack(stream, component); + } +} + +void MediaStreamCenterInternal::didStopLocalMediaStream(MediaStreamDescriptor* stream) +{ + if (m_private) + m_private->didStopLocalMediaStream(stream); +} + +void MediaStreamCenterInternal::didConstructMediaStream(MediaStreamDescriptor* stream) +{ + if (m_private) + m_private->didConstructMediaStream(stream); +} + +void MediaStreamCenterInternal::stopLocalMediaStream(const WebKit::WebMediaStreamDescriptor& stream) +{ + m_owner->endLocalMediaStream(stream); +} + +} // namespace WebCore + +#endif // ENABLE(MEDIA_STREAM) diff --git a/Source/WebKit/chromium/bridge/MediaStreamCenterInternal.h b/Source/WebKit/chromium/bridge/MediaStreamCenterInternal.h new file mode 100644 index 0000000..f5c3d8a --- /dev/null +++ b/Source/WebKit/chromium/bridge/MediaStreamCenterInternal.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 MediaStreamCenterInternal_h +#define MediaStreamCenterInternal_h + +#if ENABLE(MEDIA_STREAM) + +#include "platform/WebMediaStreamCenterClient.h" +#include +#include + +namespace WebKit { +class WebMediaStreamCenter; +} + +namespace WebCore { + +class MediaStreamCenter; +class MediaStreamComponent; +class MediaStreamDescriptor; +class MediaStreamSourcesQueryClient; + +class MediaStreamCenterInternal : public WebKit::WebMediaStreamCenterClient { +public: + explicit MediaStreamCenterInternal(MediaStreamCenter*); + ~MediaStreamCenterInternal(); + + void queryMediaStreamSources(PassRefPtr); + void didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*); + void didStopLocalMediaStream(MediaStreamDescriptor*); + void didConstructMediaStream(MediaStreamDescriptor*); + + // From WebKit::WebMediaStreamCenterClient. + virtual void stopLocalMediaStream(const WebKit::WebMediaStreamDescriptor&); + +private: + OwnPtr m_private; + MediaStreamCenter* m_owner; +}; + +} // namespace WebCore + +#endif // ENABLE(MEDIA_STREAM) + +#endif // MediaStreamCenterInternal_h diff --git a/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h b/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h index 0acc9ea..54795fa 100644 --- a/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h +++ b/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h @@ -61,6 +61,8 @@ class WebFileUtilities; class WebGraphicsContext3D; class WebIDBFactory; // FIXME: Does this belong in platform? class WebIDBKey; // FIXME: Does this belong in platform? +class WebMediaStreamCenter; +class WebMediaStreamCenterClient; class WebMessagePortChannel; // FIXME: Does this belong in platform? class WebMimeRegistry; class WebPeerConnectionHandler; @@ -337,6 +339,7 @@ public: // May return null if WebRTC functionality is not avaliable or out of resources. virtual WebPeerConnectionHandler* createPeerConnectionHandler(WebPeerConnectionHandlerClient*) { return 0; } + virtual WebMediaStreamCenter* createMediaStreamCenter(WebMediaStreamCenterClient*) { return 0; } virtual void didStartWorkerRunLoop(const WebWorkerRunLoop&) { } virtual void didStopWorkerRunLoop(const WebWorkerRunLoop&) { } diff --git a/Source/WebKit/chromium/public/platform/WebMediaStreamCenter.h b/Source/WebKit/chromium/public/platform/WebMediaStreamCenter.h new file mode 100644 index 0000000..8381a9a --- /dev/null +++ b/Source/WebKit/chromium/public/platform/WebMediaStreamCenter.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 WebMediaStreamCenter_h +#define WebMediaStreamCenter_h + +namespace WebKit { + +class WebMediaStreamComponent; +class WebMediaStreamDescriptor; +class WebMediaStreamSourcesRequest; + +class WebMediaStreamCenter { +public: + virtual ~WebMediaStreamCenter() { } + + virtual void queryMediaStreamSources(const WebMediaStreamSourcesRequest&) = 0; + virtual void didEnableMediaStreamTrack(const WebMediaStreamDescriptor&, const WebMediaStreamComponent&) = 0; + virtual void didDisableMediaStreamTrack(const WebMediaStreamDescriptor&, const WebMediaStreamComponent&) = 0; + virtual void didStopLocalMediaStream(const WebMediaStreamDescriptor&) = 0; + virtual void didConstructMediaStream(const WebMediaStreamDescriptor&) = 0; +}; + +} // namespace WebKit + +#endif // WebMediaStreamCenter_h + diff --git a/Source/WebKit/chromium/public/platform/WebMediaStreamCenterClient.h b/Source/WebKit/chromium/public/platform/WebMediaStreamCenterClient.h new file mode 100644 index 0000000..8a0825f --- /dev/null +++ b/Source/WebKit/chromium/public/platform/WebMediaStreamCenterClient.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 WebMediaStreamCenterClient_h +#define WebMediaStreamCenterClient_h + +namespace WebKit { + +class WebMediaStreamDescriptor; + +class WebMediaStreamCenterClient { +public: + virtual ~WebMediaStreamCenterClient() { } + + virtual void stopLocalMediaStream(const WebMediaStreamDescriptor&) = 0; +}; + +} // namespace WebKit + +#endif // WebMediaStreamCenterClient_h diff --git a/Source/WebKit/chromium/public/platform/WebMediaStreamComponent.h b/Source/WebKit/chromium/public/platform/WebMediaStreamComponent.h new file mode 100644 index 0000000..bee1855 --- /dev/null +++ b/Source/WebKit/chromium/public/platform/WebMediaStreamComponent.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 WebMediaStreamComponent_h +#define WebMediaStreamComponent_h + +#include "WebCommon.h" +#include "WebNonCopyable.h" +#include "WebPrivatePtr.h" + +namespace WebCore { +class MediaStreamComponent; +} + +namespace WebKit { + +class WebMediaStreamSource; +class WebString; + +class WebMediaStreamComponent { +public: + WebMediaStreamComponent() { } + ~WebMediaStreamComponent() { reset(); } + + WEBKIT_EXPORT void reset(); + bool isNull() const { return m_private.isNull(); } + + WEBKIT_EXPORT WebMediaStreamSource source() const; + WEBKIT_EXPORT bool isEnabled() const; + +#if WEBKIT_IMPLEMENTATION + WebMediaStreamComponent(WebCore::MediaStreamComponent*); + WebMediaStreamComponent& operator=(WebCore::MediaStreamComponent*); + operator WTF::PassRefPtr() const; + operator WebCore::MediaStreamComponent*() const; +#endif + +private: + WebPrivatePtr m_private; +}; + +} // namespace WebKit + +#endif // WebMediaStreamComponent_h diff --git a/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h b/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h index ff8bd19..4923c97 100644 --- a/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h +++ b/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h @@ -36,6 +36,7 @@ class MediaStreamDescriptor; namespace WebKit { +class WebMediaStreamComponent; class WebMediaStreamSource; class WebString; @@ -65,10 +66,11 @@ public: // DEPRECATED WEBKIT_EXPORT void sources(WebVector&) const; - WEBKIT_EXPORT void audioSources(WebVector&) const; - WEBKIT_EXPORT void videoSources(WebVector&) const; + WEBKIT_EXPORT void audioSources(WebVector&) const; + WEBKIT_EXPORT void videoSources(WebVector&) const; #if WEBKIT_IMPLEMENTATION + WebMediaStreamDescriptor(WebCore::MediaStreamDescriptor*); WebMediaStreamDescriptor(const WTF::PassRefPtr&); operator WTF::PassRefPtr() const; operator WebCore::MediaStreamDescriptor*() const; diff --git a/Source/WebKit/chromium/public/platform/WebMediaStreamSourcesRequest.h b/Source/WebKit/chromium/public/platform/WebMediaStreamSourcesRequest.h new file mode 100644 index 0000000..7fcc7c2 --- /dev/null +++ b/Source/WebKit/chromium/public/platform/WebMediaStreamSourcesRequest.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 WebMediaStreamSourcesRequest_h +#define WebMediaStreamSourcesRequest_h + +#include "WebCommon.h" +#include "WebPrivatePtr.h" + +namespace WebCore { +class MediaStreamSourcesQueryClient; +} + +namespace WebKit { + +class WebMediaStreamSource; +template class WebVector; + +class WebMediaStreamSourcesRequest { +public: + WebMediaStreamSourcesRequest() { } + ~WebMediaStreamSourcesRequest() { reset(); } + + WEBKIT_EXPORT void reset(); + bool isNull() const { return m_private.isNull(); } + + WEBKIT_EXPORT bool audio() const; + WEBKIT_EXPORT bool video() const; + + WEBKIT_EXPORT void didCompleteQuery(const WebVector& audioSources, const WebVector& videoSources) const; + +#if WEBKIT_IMPLEMENTATION + WebMediaStreamSourcesRequest(const WTF::PassRefPtr&); +#endif + +private: + WebPrivatePtr m_private; +}; + +} // namespace WebKit + +#endif // WebMediaStreamSourcesRequest_h diff --git a/Source/WebKit/chromium/src/UserMediaClientImpl.h b/Source/WebKit/chromium/src/UserMediaClientImpl.h index f087123..f6ab041 100644 --- a/Source/WebKit/chromium/src/UserMediaClientImpl.h +++ b/Source/WebKit/chromium/src/UserMediaClientImpl.h @@ -50,7 +50,7 @@ public: // WebCore::UserMediaClient ---------------------------------------------- virtual void pageDestroyed(); - virtual void requestUserMedia(PassRefPtr, const WebCore::MediaStreamSourceVector&, const WebCore::MediaStreamSourceVector&); + virtual void requestUserMedia(PassRefPtr, const WebCore::MediaStreamSourceVector& audioSources, const WebCore::MediaStreamSourceVector& videoSources); virtual void cancelUserMediaRequest(WebCore::UserMediaRequest*); private: diff --git a/Source/WebKit/chromium/src/WebMediaStreamComponent.cpp b/Source/WebKit/chromium/src/WebMediaStreamComponent.cpp new file mode 100644 index 0000000..644bcf7 --- /dev/null +++ b/Source/WebKit/chromium/src/WebMediaStreamComponent.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "config.h" + +#if ENABLE(MEDIA_STREAM) + +#include "platform/WebMediaStreamComponent.h" + +#include "MediaStreamComponent.h" +#include "platform/WebMediaStreamSource.h" +#include "platform/WebString.h" +#include + +using namespace WebCore; + +namespace WebKit { + +WebMediaStreamComponent::WebMediaStreamComponent(WebCore::MediaStreamComponent* mediaStreamComponent) + : m_private(mediaStreamComponent) +{ +} + +WebMediaStreamComponent& WebMediaStreamComponent::operator=(WebCore::MediaStreamComponent* mediaStreamComponent) +{ + m_private = mediaStreamComponent; + return *this; +} + +void WebMediaStreamComponent::reset() +{ + m_private.reset(); +} + +WebMediaStreamComponent::operator PassRefPtr() const +{ + return m_private.get(); +} + +WebMediaStreamComponent::operator MediaStreamComponent*() const +{ + return m_private.get(); +} + +bool WebMediaStreamComponent::isEnabled() const +{ + ASSERT(!m_private.isNull()); + return m_private.get()->enabled(); +} + +WebMediaStreamSource WebMediaStreamComponent::source() const +{ + ASSERT(!m_private.isNull()); + return WebMediaStreamSource(m_private.get()->source()); +} + +} // namespace WebKit + +#endif // ENABLE(MEDIA_STREAM) + diff --git a/Source/WebKit/chromium/src/WebMediaStreamDescriptor.cpp b/Source/WebKit/chromium/src/WebMediaStreamDescriptor.cpp index 7daf329..9faa4fd 100644 --- a/Source/WebKit/chromium/src/WebMediaStreamDescriptor.cpp +++ b/Source/WebKit/chromium/src/WebMediaStreamDescriptor.cpp @@ -37,6 +37,7 @@ #include "MediaStreamComponent.h" #include "MediaStreamDescriptor.h" #include "MediaStreamSource.h" +#include "platform/WebMediaStreamComponent.h" #include "platform/WebMediaStreamSource.h" #include "platform/WebString.h" #include @@ -50,6 +51,11 @@ WebMediaStreamDescriptor::WebMediaStreamDescriptor(const PassRefPtr& webSourc webSources.swap(result); } -void WebMediaStreamDescriptor::audioSources(WebVector& webSources) const +void WebMediaStreamDescriptor::audioSources(WebVector& webSources) const { size_t numberOfSources = m_private->numberOfAudioComponents(); - WebVector result(numberOfSources); + WebVector result(numberOfSources); for (size_t i = 0; i < numberOfSources; ++i) - result[i] = m_private->audioComponent(i)->source(); + result[i] = m_private->audioComponent(i); webSources.swap(result); } -void WebMediaStreamDescriptor::videoSources(WebVector& webSources) const +void WebMediaStreamDescriptor::videoSources(WebVector& webSources) const { size_t numberOfSources = m_private->numberOfVideoComponents(); - WebVector result(numberOfSources); + WebVector result(numberOfSources); for (size_t i = 0; i < numberOfSources; ++i) - result[i] = m_private->videoComponent(i)->source(); + result[i] = m_private->videoComponent(i); webSources.swap(result); } diff --git a/Source/WebKit/chromium/src/WebMediaStreamSourcesRequest.cpp b/Source/WebKit/chromium/src/WebMediaStreamSourcesRequest.cpp new file mode 100644 index 0000000..ea88680 --- /dev/null +++ b/Source/WebKit/chromium/src/WebMediaStreamSourcesRequest.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2012 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "config.h" + +#if ENABLE(MEDIA_STREAM) + +#include "platform/WebMediaStreamSourcesRequest.h" + +#include "MediaStreamCenter.h" +#include "MediaStreamSource.h" +#include "platform/WebMediaStreamSource.h" +#include "platform/WebVector.h" +#include + +using namespace WebCore; + +namespace WebKit { + +WebMediaStreamSourcesRequest::WebMediaStreamSourcesRequest(const PassRefPtr& queryClient) + : m_private(queryClient) +{ +} + +void WebMediaStreamSourcesRequest::reset() +{ + m_private.reset(); +} + +bool WebMediaStreamSourcesRequest::audio() const +{ + ASSERT(!isNull()); + return m_private->audio(); +} + +bool WebMediaStreamSourcesRequest::video() const +{ + ASSERT(!isNull()); + return m_private->video(); +} + +void WebMediaStreamSourcesRequest::didCompleteQuery(const WebVector& audioSources, const WebVector& videoSources) const +{ + ASSERT(!isNull()); + MediaStreamSourceVector audio; + for (size_t i = 0; i < audioSources.size(); ++i) { + MediaStreamSource* curr = audioSources[i]; + audio.append(curr); + } + MediaStreamSourceVector video; + for (size_t i = 0; i < videoSources.size(); ++i) { + MediaStreamSource* curr = videoSources[i]; + video.append(curr); + } + m_private->didCompleteQuery(audio, video); +} + +} // namespace WebKit + +#endif // ENABLE(MEDIA_STREAM) +