-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MediaStream API: Patch #1 of implementing navigator.getMediaDevices
The deprecated MediaStreamTrack.getSources() will be removed later. This patch contains almost everything except .idl files which means that this is "dead" code which will not affect anything. Patch 2 will introduce mock support for getMediaDevices. And finally the third patch will add tests and idl files. BUG=338511 Review URL: https://codereview.chromium.org/135363004 git-svn-id: svn://svn.chromium.org/blink/trunk@166370 bbb929c8-8fbe-4397-9dbb-9b2b20218538
- Loading branch information
1 parent
3f17e66
commit f3dea58
Showing
19 changed files
with
748 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (C) 2014 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 "config.h" | ||
#include "modules/mediastream/MediaDeviceInfo.h" | ||
|
||
#include "wtf/text/WTFString.h" | ||
|
||
namespace WebCore { | ||
|
||
PassRefPtr<MediaDeviceInfo> MediaDeviceInfo::create(const blink::WebMediaDeviceInfo& webMediaDeviceInfo) | ||
{ | ||
ASSERT(!webMediaDeviceInfo.isNull()); | ||
return adoptRef(new MediaDeviceInfo(webMediaDeviceInfo)); | ||
} | ||
|
||
MediaDeviceInfo::MediaDeviceInfo(const blink::WebMediaDeviceInfo& webMediaDeviceInfo) | ||
: m_webMediaDeviceInfo(webMediaDeviceInfo) | ||
{ | ||
} | ||
|
||
String MediaDeviceInfo::deviceId() const | ||
{ | ||
return m_webMediaDeviceInfo.deviceId(); | ||
} | ||
|
||
String MediaDeviceInfo::kind() const | ||
{ | ||
switch (m_webMediaDeviceInfo.kind()) { | ||
case blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput: | ||
return "audioinput"; | ||
case blink::WebMediaDeviceInfo::MediaDeviceKindAudioOutput: | ||
return "audiooutput"; | ||
case blink::WebMediaDeviceInfo::MediaDeviceKindVideoInput: | ||
return "videoinput"; | ||
} | ||
|
||
ASSERT_NOT_REACHED(); | ||
return String(); | ||
} | ||
|
||
String MediaDeviceInfo::label() const | ||
{ | ||
return m_webMediaDeviceInfo.label(); | ||
} | ||
|
||
String MediaDeviceInfo::groupId() const | ||
{ | ||
return m_webMediaDeviceInfo.groupId(); | ||
} | ||
|
||
} // namespace WebCore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2014 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 MediaDeviceInfo_h | ||
#define MediaDeviceInfo_h | ||
|
||
#include "public/platform/WebMediaDeviceInfo.h" | ||
#include "wtf/PassRefPtr.h" | ||
#include "wtf/RefCounted.h" | ||
#include "wtf/Vector.h" | ||
|
||
namespace WebCore { | ||
|
||
class MediaDeviceInfo : public RefCounted<MediaDeviceInfo> { | ||
public: | ||
static PassRefPtr<MediaDeviceInfo> create(const blink::WebMediaDeviceInfo&); | ||
|
||
String deviceId() const; | ||
String kind() const; | ||
String label() const; | ||
String groupId() const; | ||
|
||
private: | ||
explicit MediaDeviceInfo(const blink::WebMediaDeviceInfo&); | ||
|
||
blink::WebMediaDeviceInfo m_webMediaDeviceInfo; | ||
}; | ||
|
||
typedef Vector<RefPtr<MediaDeviceInfo> > MediaDeviceInfoVector; | ||
|
||
} // namespace WebCore | ||
|
||
#endif // MediaDeviceInfo_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2014 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 MediaDeviceInfoCallback_h | ||
#define MediaDeviceInfoCallback_h | ||
|
||
#include "modules/mediastream/MediaDeviceInfo.h" | ||
|
||
namespace WebCore { | ||
|
||
class MediaDeviceInfoCallback { | ||
public: | ||
virtual ~MediaDeviceInfoCallback() { } | ||
virtual void handleEvent(const MediaDeviceInfoVector&) = 0; | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
#endif // MediaDeviceInfoCallback_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (C) 2014 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 "config.h" | ||
|
||
#include "modules/mediastream/MediaDevicesRequest.h" | ||
|
||
#include "bindings/v8/ExceptionState.h" | ||
#include "core/dom/Document.h" | ||
#include "modules/mediastream/UserMediaController.h" | ||
|
||
namespace WebCore { | ||
|
||
PassRefPtr<MediaDevicesRequest> MediaDevicesRequest::create(ExecutionContext* context, UserMediaController* controller, PassOwnPtr<MediaDeviceInfoCallback> callback, ExceptionState& exceptionState) | ||
{ | ||
RefPtr<MediaDevicesRequest> request = adoptRef(new MediaDevicesRequest(context, controller, callback)); | ||
request->suspendIfNeeded(); | ||
return request.release(); | ||
} | ||
|
||
MediaDevicesRequest::MediaDevicesRequest(ExecutionContext* context, UserMediaController* controller, PassOwnPtr<MediaDeviceInfoCallback> callback) | ||
: ActiveDOMObject(context) | ||
, m_controller(controller) | ||
, m_callback(callback) | ||
{ | ||
} | ||
|
||
MediaDevicesRequest::~MediaDevicesRequest() | ||
{ | ||
} | ||
|
||
Document* MediaDevicesRequest::ownerDocument() | ||
{ | ||
if (ExecutionContext* context = executionContext()) { | ||
return toDocument(context); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void MediaDevicesRequest::start() | ||
{ | ||
if (m_controller) | ||
m_controller->requestMediaDevices(this); | ||
} | ||
|
||
void MediaDevicesRequest::succeed(const MediaDeviceInfoVector& mediaDevices) | ||
{ | ||
if (!executionContext() || !m_callback) | ||
return; | ||
|
||
m_callback->handleEvent(mediaDevices); | ||
} | ||
|
||
void MediaDevicesRequest::stop() | ||
{ | ||
m_callback.clear(); | ||
m_controller = 0; | ||
} | ||
|
||
} // namespace WebCore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) 2014 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 MediaDevicesRequest_h | ||
#define MediaDevicesRequest_h | ||
|
||
#include "core/dom/ActiveDOMObject.h" | ||
#include "modules/mediastream/MediaDeviceInfo.h" | ||
#include "modules/mediastream/MediaDeviceInfoCallback.h" | ||
#include "wtf/PassOwnPtr.h" | ||
#include "wtf/PassRefPtr.h" | ||
#include "wtf/RefCounted.h" | ||
|
||
namespace WebCore { | ||
|
||
class Document; | ||
class ExceptionState; | ||
class MediaStreamDescriptor; | ||
class UserMediaController; | ||
|
||
class MediaDevicesRequest FINAL : public RefCounted<MediaDevicesRequest>, public ActiveDOMObject { | ||
public: | ||
static PassRefPtr<MediaDevicesRequest> create(ExecutionContext*, UserMediaController*, PassOwnPtr<MediaDeviceInfoCallback>, ExceptionState&); | ||
virtual ~MediaDevicesRequest(); | ||
|
||
MediaDeviceInfoCallback* callback() const { return m_callback.get(); } | ||
Document* ownerDocument(); | ||
|
||
void start(); | ||
|
||
void succeed(const MediaDeviceInfoVector&); | ||
|
||
// ActiveDOMObject | ||
virtual void stop() OVERRIDE; | ||
|
||
private: | ||
MediaDevicesRequest(ExecutionContext*, UserMediaController*, PassOwnPtr<MediaDeviceInfoCallback>); | ||
|
||
UserMediaController* m_controller; | ||
|
||
OwnPtr<MediaDeviceInfoCallback> m_callback; | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
#endif // MediaDevicesRequest_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.