Title: [187140] trunk/Source/WebCore
Revision
187140
Author
commit-qu...@webkit.org
Date
2015-07-21 17:06:05 -0700 (Tue, 21 Jul 2015)

Log Message

Exposed method to query device by UID
https://bugs.webkit.org/show_bug.cgi?id=147117
<rdar://problem/21904678>

Patch by Matthew Daiter <mdai...@apple.com> on 2015-07-21
Reviewed by Eric Carlson.

* platform/mediastream/mac/AVCaptureDeviceManager.h: Added method to
query device by UID
* platform/mediastream/mac/AVCaptureDeviceManager.mm: Ditto
(WebCore::AVCaptureDeviceManager::sourceWithUID): Ditto

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (187139 => 187140)


--- trunk/Source/WebCore/ChangeLog	2015-07-22 00:01:46 UTC (rev 187139)
+++ trunk/Source/WebCore/ChangeLog	2015-07-22 00:06:05 UTC (rev 187140)
@@ -1,3 +1,16 @@
+2015-07-21  Matthew Daiter  <mdai...@apple.com>
+
+        Exposed method to query device by UID
+        https://bugs.webkit.org/show_bug.cgi?id=147117
+        <rdar://problem/21904678>
+
+        Reviewed by Eric Carlson.
+
+        * platform/mediastream/mac/AVCaptureDeviceManager.h: Added method to
+        query device by UID
+        * platform/mediastream/mac/AVCaptureDeviceManager.mm: Ditto
+        (WebCore::AVCaptureDeviceManager::sourceWithUID): Ditto
+
 2015-07-21  Benjamin Poulain  <benja...@webkit.org>
 
         [Content Extensions] Use a jump table when consecutive transitions have different targets

Modified: trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.h (187139 => 187140)


--- trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.h	2015-07-22 00:01:46 UTC (rev 187139)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.h	2015-07-22 00:06:05 UTC (rev 187140)
@@ -50,6 +50,7 @@
     Vector<RefPtr<TrackSourceInfo>> getSourcesInfo(const String&);
     bool verifyConstraintsForMediaType(RealtimeMediaSource::Type, MediaConstraints*, String&);
     RefPtr<RealtimeMediaSource> bestSourceForTypeAndConstraints(RealtimeMediaSource::Type, PassRefPtr<MediaConstraints>);
+    RefPtr<RealtimeMediaSource> sourceWithUID(String&, RealtimeMediaSource::Type, MediaConstraints*);
 
     enum ValidConstraints { Width = 0, Height, FrameRate, FacingMode, Gain };
     static const Vector<AtomicString>& validConstraintNames();

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


--- trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm	2015-07-22 00:01:46 UTC (rev 187139)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm	2015-07-22 00:06:05 UTC (rev 187140)
@@ -413,6 +413,41 @@
     return 0;
 }
 
+RefPtr<RealtimeMediaSource> AVCaptureDeviceManager::sourceWithUID(String &deviceUID, RealtimeMediaSource::Type type, MediaConstraints* constraints)
+{
+    if (!isAvailable())
+        return 0;
+    
+    Vector<CaptureDevice>& devices = captureDeviceList();
+    for (auto captureDevice : devices) {
+        if (!captureDevice.m_enabled)
+            continue;
+
+        if (captureDevice.m_captureDeviceID != deviceUID)
+            continue;
+        if (constraints) {
+            String invalidConstraints;
+            AVCaptureDeviceManager::singleton().verifyConstraintsForMediaType(type, constraints, invalidConstraints);
+            if (!invalidConstraints.isEmpty())
+                continue;
+        }
+        
+        AVCaptureDeviceType *device = [AVCaptureDevice deviceWithUniqueID:captureDevice.m_captureDeviceID];
+        ASSERT(device);
+        if (type == RealtimeMediaSource::Type::Audio && !captureDevice.m_audioSourceId.isEmpty()) {
+            captureDevice.m_audioSource = AVAudioCaptureSource::create(device, captureDevice.m_audioSourceId, constraints);
+            return captureDevice.m_audioSource;
+        }
+        if (type == RealtimeMediaSource::Type::Video && !captureDevice.m_videoSourceId.isEmpty()) {
+            captureDevice.m_videoSource = AVVideoCaptureSource::create(device, captureDevice.m_videoSourceId, constraints);
+            return captureDevice.m_videoSource;
+        }
+    }
+    
+    return nullptr;
+
+}
+
 void AVCaptureDeviceManager::registerForDeviceNotifications()
 {
     [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get() selector:@selector(deviceConnected:) name:AVCaptureDeviceWasConnectedNotification object:nil];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to