Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: Source/platform/exported/WebMediaDeviceInfo.cpp

Issue 145583015: MediaStream API: Implement Navigator.getMediaDevices Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "public/platform/WebSourceInfo.h" 28 #include "public/platform/WebMediaDeviceInfo.h"
29 29
30 #include "public/platform/WebString.h" 30 #include "public/platform/WebString.h"
31 #include "wtf/PassRefPtr.h" 31 #include "wtf/PassRefPtr.h"
32 #include "wtf/RefCounted.h" 32 #include "wtf/RefCounted.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 class WebSourceInfoPrivate FINAL : public RefCounted<WebSourceInfoPrivate> { 36 class WebMediaDeviceInfoPrivate FINAL : public RefCounted<WebMediaDeviceInfoPriv ate> {
37 public: 37 public:
38 static PassRefPtr<WebSourceInfoPrivate> create(const WebString& id, WebSourc eInfo::SourceKind, const WebString& label, WebSourceInfo::VideoFacingMode); 38 static PassRefPtr<WebMediaDeviceInfoPrivate> create(const WebString& deviceI d, WebMediaDeviceInfo::MediaDeviceKind, const WebString& label, const WebString& groupId);
39 39
40 const WebString& id() const { return m_id; } 40 const WebString& deviceId() const { return m_deviceId; }
41 WebSourceInfo::SourceKind kind() const { return m_kind; } 41 WebMediaDeviceInfo::MediaDeviceKind kind() const { return m_kind; }
42 const WebString& label() const { return m_label; } 42 const WebString& label() const { return m_label; }
43 WebSourceInfo::VideoFacingMode facing() const { return m_facing; } 43 const WebString& groupId() const { return m_groupId; }
44 44
45 private: 45 private:
46 WebSourceInfoPrivate(const WebString& id, WebSourceInfo::SourceKind, const W ebString& label, WebSourceInfo::VideoFacingMode); 46 WebMediaDeviceInfoPrivate(const WebString& deviceId, WebMediaDeviceInfo::Med iaDeviceKind, const WebString& label, const WebString& groupId);
47 47
48 WebString m_id; 48 WebString m_deviceId;
49 WebSourceInfo::SourceKind m_kind; 49 WebMediaDeviceInfo::MediaDeviceKind m_kind;
50 WebString m_label; 50 WebString m_label;
51 WebSourceInfo::VideoFacingMode m_facing; 51 WebString m_groupId;
52 }; 52 };
53 53
54 PassRefPtr<WebSourceInfoPrivate> WebSourceInfoPrivate::create(const WebString& i d, WebSourceInfo::SourceKind kind, const WebString& label, WebSourceInfo::VideoF acingMode facing) 54 PassRefPtr<WebMediaDeviceInfoPrivate> WebMediaDeviceInfoPrivate::create(const We bString& deviceId, WebMediaDeviceInfo::MediaDeviceKind kind, const WebString& la bel, const WebString& groupId)
55 { 55 {
56 return adoptRef(new WebSourceInfoPrivate(id, kind, label, facing)); 56 return adoptRef(new WebMediaDeviceInfoPrivate(deviceId, kind, label, groupId ));
57 } 57 }
58 58
59 WebSourceInfoPrivate::WebSourceInfoPrivate(const WebString& id, WebSourceInfo::S ourceKind kind, const WebString& label, WebSourceInfo::VideoFacingMode facing) 59 WebMediaDeviceInfoPrivate::WebMediaDeviceInfoPrivate(const WebString& deviceId, WebMediaDeviceInfo::MediaDeviceKind kind, const WebString& label, const WebStrin g& groupId)
60 : m_id(id) 60 : m_deviceId(deviceId)
61 , m_kind(kind) 61 , m_kind(kind)
62 , m_label(label) 62 , m_label(label)
63 , m_facing(facing) 63 , m_groupId(groupId)
64 { 64 {
65 } 65 }
66 66
67 void WebSourceInfo::assign(const WebSourceInfo& other) 67 void WebMediaDeviceInfo::assign(const WebMediaDeviceInfo& other)
68 { 68 {
69 m_private = other.m_private; 69 m_private = other.m_private;
70 } 70 }
71 71
72 void WebSourceInfo::reset() 72 void WebMediaDeviceInfo::reset()
73 { 73 {
74 m_private.reset(); 74 m_private.reset();
75 } 75 }
76 76
77 void WebSourceInfo::initialize(const WebString& id, WebSourceInfo::SourceKind ki nd, const WebString& label, WebSourceInfo::VideoFacingMode facing) 77 void WebMediaDeviceInfo::initialize(const WebString& deviceId, WebMediaDeviceInf o::MediaDeviceKind kind, const WebString& label, const WebString& groupId)
78 { 78 {
79 m_private = WebSourceInfoPrivate::create(id, kind, label, facing); 79 m_private = WebMediaDeviceInfoPrivate::create(deviceId, kind, label, groupId );
80 } 80 }
81 81
82 WebString WebSourceInfo::id() const 82 WebString WebMediaDeviceInfo::deviceId() const
83 { 83 {
84 ASSERT(!m_private.isNull()); 84 ASSERT(!m_private.isNull());
85 return m_private->id(); 85 return m_private->deviceId();
86 } 86 }
87 87
88 WebSourceInfo::SourceKind WebSourceInfo::kind() const 88 WebMediaDeviceInfo::MediaDeviceKind WebMediaDeviceInfo::kind() const
89 { 89 {
90 ASSERT(!m_private.isNull()); 90 ASSERT(!m_private.isNull());
91 return m_private->kind(); 91 return m_private->kind();
92 } 92 }
93 93
94 WebString WebSourceInfo::label() const 94 WebString WebMediaDeviceInfo::label() const
95 { 95 {
96 ASSERT(!m_private.isNull()); 96 ASSERT(!m_private.isNull());
97 return m_private->label(); 97 return m_private->label();
98 } 98 }
99 99
100 WebSourceInfo::VideoFacingMode WebSourceInfo::facing() const 100 WebString WebMediaDeviceInfo::groupId() const
101 { 101 {
102 ASSERT(!m_private.isNull()); 102 ASSERT(!m_private.isNull());
103 return m_private->facing(); 103 return m_private->groupId();
104 } 104 }
105 105
106 } // namespace blink 106 } // namespace blink
107 107
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698