Title: [186608] trunk/Source/WebCore
Revision
186608
Author
commit-qu...@webkit.org
Date
2015-07-09 13:47:15 -0700 (Thu, 09 Jul 2015)

Log Message

Implementing platform-specific section of enumerateDevices
https://bugs.webkit.org/show_bug.cgi?id=146461
<rdar://problem/21614466>

Patch by Matthew Daiter <mdai...@apple.com> on 2015-07-09
Reviewed by Darin Adler.

* Modules/mediastream/MediaDeviceInfo.cpp: Changed access methods
(WebCore::MediaDeviceInfo::audioInputType): Added AtomicString
permanent refs
(WebCore::MediaDeviceInfo::audioOutputType): Ditto
(WebCore::MediaDeviceInfo::videoInputType): Ditto
* Modules/mediastream/MediaDeviceInfo.h: Changed String refs to values
(WebCore::MediaDeviceInfo::label): Ditto
(WebCore::MediaDeviceInfo::deviceId): Ditto
(WebCore::MediaDeviceInfo::groupId): Ditto
(WebCore::MediaDeviceInfo::kind): Ditto
* platform/mediastream/MediaDevicesPrivate.cpp: Implemented query for
available devices
(WebCore::MediaDevicesPrivate::MediaDevicesPrivate):
(WebCore::MediaDevicesPrivate::create):
(WebCore::MediaDevicesPrivate::availableMediaDevices):
* platform/mediastream/MediaDevicesPrivate.h:
(WebCore::MediaDevicesPrivate::~MediaDevicesPrivate):
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/MediaStreamTrackSourcesRequestClient.h: Needed
to tack on extra fields to hold data
(WebCore::TrackSourceInfo::create):
(WebCore::TrackSourceInfo::groupId):
(WebCore::TrackSourceInfo::deviceId):
(WebCore::TrackSourceInfo::TrackSourceInfo):
* platform/mediastream/mac/AVCaptureDeviceManager.mm:
(WebCore::AVCaptureDeviceManager::getSourcesInfo):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (186607 => 186608)


--- trunk/Source/WebCore/ChangeLog	2015-07-09 20:37:49 UTC (rev 186607)
+++ trunk/Source/WebCore/ChangeLog	2015-07-09 20:47:15 UTC (rev 186608)
@@ -1,3 +1,38 @@
+2015-07-09  Matthew Daiter  <mdai...@apple.com>
+
+        Implementing platform-specific section of enumerateDevices
+        https://bugs.webkit.org/show_bug.cgi?id=146461
+        <rdar://problem/21614466>
+
+        Reviewed by Darin Adler.
+
+        * Modules/mediastream/MediaDeviceInfo.cpp: Changed access methods
+        (WebCore::MediaDeviceInfo::audioInputType): Added AtomicString
+        permanent refs
+        (WebCore::MediaDeviceInfo::audioOutputType): Ditto
+        (WebCore::MediaDeviceInfo::videoInputType): Ditto
+        * Modules/mediastream/MediaDeviceInfo.h: Changed String refs to values
+        (WebCore::MediaDeviceInfo::label): Ditto
+        (WebCore::MediaDeviceInfo::deviceId): Ditto
+        (WebCore::MediaDeviceInfo::groupId): Ditto
+        (WebCore::MediaDeviceInfo::kind): Ditto
+        * platform/mediastream/MediaDevicesPrivate.cpp: Implemented query for
+        available devices
+        (WebCore::MediaDevicesPrivate::MediaDevicesPrivate):
+        (WebCore::MediaDevicesPrivate::create):
+        (WebCore::MediaDevicesPrivate::availableMediaDevices):
+        * platform/mediastream/MediaDevicesPrivate.h:
+        (WebCore::MediaDevicesPrivate::~MediaDevicesPrivate):
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mediastream/MediaStreamTrackSourcesRequestClient.h: Needed
+        to tack on extra fields to hold data
+        (WebCore::TrackSourceInfo::create):
+        (WebCore::TrackSourceInfo::groupId):
+        (WebCore::TrackSourceInfo::deviceId):
+        (WebCore::TrackSourceInfo::TrackSourceInfo):
+        * platform/mediastream/mac/AVCaptureDeviceManager.mm:
+        (WebCore::AVCaptureDeviceManager::getSourcesInfo):
+
 2015-07-09  Per Arne Vollan  <pe...@outlook.com>
 
         [Win] Add memory pressure handler.

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp (186607 => 186608)


--- trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp	2015-07-09 20:37:49 UTC (rev 186607)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp	2015-07-09 20:47:15 UTC (rev 186608)
@@ -30,6 +30,7 @@
 
 #include "ContextDestructionObserver.h"
 #include "ScriptWrappable.h"
+#include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
@@ -47,6 +48,24 @@
 {
 }
 
+const AtomicString& MediaDeviceInfo::audioInputType()
+{
+    static NeverDestroyed<AtomicString> audioinput("audioinput");
+    return audioinput;
+}
+
+const AtomicString& MediaDeviceInfo::audioOutputType()
+{
+    static NeverDestroyed<AtomicString> audiooutput("audiooutput");
+    return audiooutput;
+}
+
+const AtomicString& MediaDeviceInfo::videoInputType()
+{
+    static NeverDestroyed<AtomicString> videoinput("videoinput");
+    return videoinput;
+}
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.h (186607 => 186608)


--- trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.h	2015-07-09 20:37:49 UTC (rev 186607)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.h	2015-07-09 20:47:15 UTC (rev 186608)
@@ -42,18 +42,22 @@
     
     virtual ~MediaDeviceInfo() { }
     
-    const String& label() const {return m_label; }
-    const String& deviceId() const {return m_deviceId; }
-    const String& groupId() const {return m_groupId; }
-    const String& kind() const {return m_kind; }
-    
+    const String& label() const { return m_label; }
+    const String& deviceId() const { return m_deviceId; }
+    const String& groupId() const { return m_groupId; }
+    const String& kind() const { return m_kind; }
+
+    static const AtomicString& audioInputType();
+    static const AtomicString& audioOutputType();
+    static const AtomicString& videoInputType();
+
 private:
     MediaDeviceInfo(ScriptExecutionContext*, const String&, const String&, const String&, const String&);
 
-    const String& m_label;
-    const String& m_deviceId;
-    const String& m_groupId;
-    const String& m_kind;
+    const String m_label;
+    const String m_deviceId;
+    const String m_groupId;
+    const String m_kind;
 };
 
 }

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (186607 => 186608)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-07-09 20:37:49 UTC (rev 186607)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-07-09 20:47:15 UTC (rev 186608)
@@ -636,6 +636,8 @@
 		14FFE31D0AE1963300136BF5 /* HTMLFrameElementBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 14FFE31B0AE1963300136BF5 /* HTMLFrameElementBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14FFE31E0AE1963300136BF5 /* HTMLFrameElementBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FFE31C0AE1963300136BF5 /* HTMLFrameElementBase.cpp */; };
 		15145B901B3A1CE000662BF7 /* MediaDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 15145B8F1B3A1B3E00662BF7 /* MediaDeviceInfo.h */; };
+		152A29B41B4EF5B700B52AE0 /* MediaDevicesPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 152A29B21B4EF59600B52AE0 /* MediaDevicesPrivate.cpp */; };
+		152A29B51B4EF5BA00B52AE0 /* MediaDevicesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 152A29B31B4EF59600B52AE0 /* MediaDevicesPrivate.h */; };
 		15739BBA1B42012A00D258C1 /* JSMediaDevices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15739BB81B42012200D258C1 /* JSMediaDevices.cpp */; };
 		15739BBB1B42012D00D258C1 /* JSMediaDevices.h in Headers */ = {isa = PBXBuildFile; fileRef = 15739BB91B42012200D258C1 /* JSMediaDevices.h */; };
 		159AE82B1B3A402F0037478B /* MediaDeviceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 159AE82A1B3A402F0037478B /* MediaDeviceInfo.cpp */; };
@@ -7751,6 +7753,8 @@
 		14FFE31C0AE1963300136BF5 /* HTMLFrameElementBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLFrameElementBase.cpp; sourceTree = "<group>"; };
 		15145B8F1B3A1B3E00662BF7 /* MediaDeviceInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaDeviceInfo.h; sourceTree = "<group>"; };
 		15145B911B3A1D4C00662BF7 /* MediaDeviceInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaDeviceInfo.idl; sourceTree = "<group>"; };
+		152A29B21B4EF59600B52AE0 /* MediaDevicesPrivate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaDevicesPrivate.cpp; sourceTree = "<group>"; };
+		152A29B31B4EF59600B52AE0 /* MediaDevicesPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDevicesPrivate.h; sourceTree = "<group>"; };
 		15739BB81B42012200D258C1 /* JSMediaDevices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaDevices.cpp; sourceTree = "<group>"; };
 		15739BB91B42012200D258C1 /* JSMediaDevices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaDevices.h; sourceTree = "<group>"; };
 		159AE82A1B3A402F0037478B /* MediaDeviceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaDeviceInfo.cpp; sourceTree = "<group>"; };
@@ -14807,6 +14811,8 @@
 			children = (
 				0729B14D17CFCCA0004F1D60 /* mac */,
 				07221B9917CF0AD400848E51 /* MediaConstraints.h */,
+				152A29B21B4EF59600B52AE0 /* MediaDevicesPrivate.cpp */,
+				152A29B31B4EF59600B52AE0 /* MediaDevicesPrivate.h */,
 				070F549717F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h */,
 				07221BA017CF0AD400848E51 /* MediaStreamCreationClient.h */,
 				0711588F17DF633700EDFE2B /* MediaStreamPrivate.cpp */,
@@ -24202,6 +24208,7 @@
 				409EBDB116B7EE7100CBA3FC /* CSSFontFaceLoadEvent.h in Headers */,
 				A80E6CFD0A1989CA007FB8C5 /* CSSFontFaceRule.h in Headers */,
 				BC64B4D80CB4298A005F2B62 /* CSSFontFaceSource.h in Headers */,
+				152A29B51B4EF5BA00B52AE0 /* MediaDevicesPrivate.h in Headers */,
 				BC64B4DA0CB4298A005F2B62 /* CSSFontFaceSrcValue.h in Headers */,
 				83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */,
 				4A6E9FC413C17D1D0046A7F8 /* CSSFontFeatureValue.h in Headers */,
@@ -29167,6 +29174,7 @@
 				BCE0139A0C0BEF180043860A /* JSStyleSheet.cpp in Sources */,
 				BC98A27D0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp in Sources */,
 				A84EBD840CB8C97700079609 /* JSStyleSheetList.cpp in Sources */,
+				152A29B41B4EF5B700B52AE0 /* MediaDevicesPrivate.cpp in Sources */,
 				A84EBD780CB8C89200079609 /* JSStyleSheetListCustom.cpp in Sources */,
 				E1FF8F64180745D800132674 /* JSSubtleCrypto.cpp in Sources */,
 				E1FF8F681807460800132674 /* JSSubtleCryptoCustom.cpp in Sources */,

Copied: trunk/Source/WebCore/platform/mediastream/MediaDevicesPrivate.cpp (from rev 186607, trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp) (0 => 186608)


--- trunk/Source/WebCore/platform/mediastream/MediaDevicesPrivate.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/MediaDevicesPrivate.cpp	2015-07-09 20:47:15 UTC (rev 186608)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2015 Apple 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 APPLE, 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 APPLE 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 "MediaDevicesPrivate.h"
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "AVCaptureDeviceManager.h"
+#include "AVMediaCaptureSource.h"
+#include "MediaStreamTrackSourcesRequestClient.h"
+
+namespace WebCore {
+
+MediaDevicesPrivate::MediaDevicesPrivate()
+{
+}
+
+Vector<RefPtr<MediaDeviceInfo>> MediaDevicesPrivate::availableMediaDevices(ScriptExecutionContext& context)
+{
+    Vector<RefPtr<TrackSourceInfo>> capturedDevices = AVCaptureDeviceManager::singleton().getSourcesInfo("");
+    Vector<RefPtr<MediaDeviceInfo>> mediaDevicesInfo;
+    for (auto device : capturedDevices) {
+        TrackSourceInfo* trackInfo = device.get();
+        String deviceType = trackInfo->kind() == TrackSourceInfo::SourceKind::Audio ? MediaDeviceInfo::audioInputType() : MediaDeviceInfo::videoInputType();
+        mediaDevicesInfo.append(MediaDeviceInfo::create(&context, trackInfo->label(), trackInfo->deviceId(), trackInfo->groupId(), deviceType));
+    }
+    
+    return mediaDevicesInfo;
+}
+
+}
+
+#endif

Copied: trunk/Source/WebCore/platform/mediastream/MediaDevicesPrivate.h (from rev 186607, trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp) (0 => 186608)


--- trunk/Source/WebCore/platform/mediastream/MediaDevicesPrivate.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/MediaDevicesPrivate.h	2015-07-09 20:47:15 UTC (rev 186608)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2015 Apple 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 APPLE, 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 APPLE 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 MediaDevicesPrivate_h
+#define MediaDevicesPrivate_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "AVCaptureDeviceManager.h"
+#include "MediaDeviceInfo.h"
+
+#include <wtf/Forward.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class MediaDevicesPrivate : public std::unique_ptr<MediaDevicesPrivate> {
+public:
+    MediaDevicesPrivate();
+
+    virtual ~MediaDevicesPrivate() { }
+
+    virtual Vector<RefPtr<MediaDeviceInfo>> availableMediaDevices(ScriptExecutionContext&);
+};
+
+}
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // MediaDevicesPrivate_h

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackSourcesRequestClient.h (186607 => 186608)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackSourcesRequestClient.h	2015-07-09 20:37:49 UTC (rev 186607)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackSourcesRequestClient.h	2015-07-09 20:47:15 UTC (rev 186608)
@@ -29,6 +29,7 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include <wtf/PassRefPtr.h>
+#include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/AtomicString.h>
 
@@ -43,8 +44,15 @@
         return adoptRef(new TrackSourceInfo(id, kind, label));
     }
 
+    static Ref<TrackSourceInfo> create(const AtomicString& id, SourceKind kind, const AtomicString& label, const AtomicString& groupId, const AtomicString& deviceId)
+    {
+        return adoptRef(*new TrackSourceInfo(id, kind, label, groupId, deviceId));
+    }
+
     const AtomicString& id() const { return m_id; }
     const AtomicString& label() const { return m_label; }
+    const AtomicString& groupId() const { return m_groupId; }
+    const AtomicString& deviceId() const { return m_deviceId; }
     SourceKind kind() const { return m_kind; }
 
 private:
@@ -54,10 +62,21 @@
         , m_label(label)
     {
     }
-    
+
+    TrackSourceInfo(const AtomicString& id, SourceKind kind, const AtomicString& label, const AtomicString& groupId, const AtomicString& deviceId)
+        : m_id(id)
+        , m_kind(kind)
+        , m_label(label)
+        , m_groupId(groupId)
+        , m_deviceId(deviceId)
+    {
+    }
+
     AtomicString m_id;
     SourceKind m_kind;
     AtomicString m_label;
+    AtomicString m_groupId;
+    AtomicString m_deviceId;
 };
 
 class MediaStreamTrackSourcesRequestClient : public RefCounted<MediaStreamTrackSourcesRequestClient> {

Modified: trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm (186607 => 186608)


--- trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm	2015-07-09 20:37:49 UTC (rev 186607)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm	2015-07-09 20:47:15 UTC (rev 186608)
@@ -329,11 +329,11 @@
 
         if (!devices[i].m_enabled)
             continue;
-
+        // FIXME: Change groupID from localizedName to something more meaningful
         if (devices[i].m_videoSource)
-            sourcesInfo.append(TrackSourceInfo::create(devices[i].m_videoSourceId, TrackSourceInfo::Video, device.localizedName));
+            sourcesInfo.append(TrackSourceInfo::create(devices[i].m_videoSourceId, TrackSourceInfo::Video, device.localizedName, device.localizedName, devices[i].m_captureDeviceID));
         if (devices[i].m_audioSource)
-            sourcesInfo.append(TrackSourceInfo::create(devices[i].m_audioSourceId, TrackSourceInfo::Audio, device.localizedName));
+            sourcesInfo.append(TrackSourceInfo::create(devices[i].m_audioSourceId, TrackSourceInfo::Audio, device.localizedName, device.localizedName, devices[i].m_captureDeviceID));
     }
     
     LOG(Media, "AVCaptureDeviceManager::getSourcesInfo(%p), found %d active devices", this, sourcesInfo.size());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to