RESOLVED FIXED 147117
Exposed method to query device by UID
https://bugs.webkit.org/show_bug.cgi?id=147117
Summary Exposed method to query device by UID
Matthew Daiter
Reported 2015-07-20 12:16:59 PDT
Needed for getting devices from Safari by UID.
Attachments
Patch (3.69 KB, patch)
2015-07-20 12:20 PDT, Matthew Daiter
no flags
Patch (3.88 KB, patch)
2015-07-20 16:48 PDT, Matthew Daiter
no flags
Patch (3.93 KB, patch)
2015-07-20 17:16 PDT, Matthew Daiter
no flags
Radar WebKit Bug Importer
Comment 1 2015-07-20 12:18:13 PDT
Matthew Daiter
Comment 2 2015-07-20 12:20:26 PDT
Eric Carlson
Comment 3 2015-07-20 13:51:08 PDT
Comment on attachment 257116 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=257116&action=review > Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.h:53 > + RefPtr<RealtimeMediaSource> sourceWithUID(String&, RealtimeMediaSource::Type, RefPtr<MediaConstraints>&&); Ref&& seems wrong unless you are passing ownership of the RefPtr (https://www.webkit.org/coding/RefPtr.html). Because this argument is optional (I think), it should be a MediaConstraints*. > Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm:427 > + AVCaptureDeviceType *device = [AVCaptureDevice deviceWithUniqueID:captureDevice.m_captureDeviceID]; > + ASSERT(device); captureDevice.m_captureDeviceID is set from device.uniqueID, so can you short circuit the lookup: if (captureDevice.m_captureDeviceID != deviceUID) continue; > Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm:436 > + 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; > + } Don't you also need to consider constraints: String invalidConstraint; AVCaptureDeviceManager::singleton().verifyConstraintsForMediaType(type, constraints, invalidConstraint); if (!invalidConstraint.isEmpty()) continue;
Matthew Daiter
Comment 4 2015-07-20 16:48:11 PDT
Matthew Daiter
Comment 5 2015-07-20 16:51:03 PDT
Comment on attachment 257116 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=257116&action=review >> Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.h:53 >> + RefPtr<RealtimeMediaSource> sourceWithUID(String&, RealtimeMediaSource::Type, RefPtr<MediaConstraints>&&); > > Ref&& seems wrong unless you are passing ownership of the RefPtr (https://www.webkit.org/coding/RefPtr.html). Because this argument is optional (I think), it should be a MediaConstraints*. The RefPtr.html page said that the methods should be implemented with a RefPtr or Ref reference reference in the place of a PassRefPtr. However, the argument could be a raw pointer instead. Fixed.
Eric Carlson
Comment 6 2015-07-20 17:07:54 PDT
(In reply to comment #5) > Comment on attachment 257116 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=257116&action=review > > >> Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.h:53 > >> + RefPtr<RealtimeMediaSource> sourceWithUID(String&, RealtimeMediaSource::Type, RefPtr<MediaConstraints>&&); > > > > Ref&& seems wrong unless you are passing ownership of the RefPtr (https://www.webkit.org/coding/RefPtr.html). Because this argument is optional (I think), it should be a MediaConstraints*. > > The RefPtr.html page said that the methods should be implemented with a > RefPtr or Ref reference reference in the place of a PassRefPtr. However, the > argument could be a raw pointer instead. > Fixed. Yes, but Ref&& should be used when passing ownership of an object: If a function does take ownership of an object, the argument should be a Ref&& or a RefPtr&&. This includes many setter functions.
Eric Carlson
Comment 7 2015-07-20 17:13:08 PDT
Comment on attachment 257145 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=257145&action=review > Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm:429 > + String invalidConstraints; > + AVCaptureDeviceManager::singleton().verifyConstraintsForMediaType(type, constraints, invalidConstraints); > + if (!invalidConstraints.isEmpty()) > + continue; This should be wrapped with a "if (constraints) { ... }" > Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm:434 > + if (captureDevice.m_captureDeviceID != deviceUID) > + continue; This is cheap, it should be done before the verifyConstraintsForMediaType() call
Matthew Daiter
Comment 8 2015-07-20 17:15:46 PDT
Comment on attachment 257145 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=257145&action=review >> Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm:429 >> + continue; > > This should be wrapped with a "if (constraints) { ... }" Fixed. >> Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm:434 >> + continue; > > This is cheap, it should be done before the verifyConstraintsForMediaType() call Fixed.
Matthew Daiter
Comment 9 2015-07-20 17:16:19 PDT
WebKit Commit Bot
Comment 10 2015-07-21 17:07:24 PDT
Comment on attachment 257152 [details] Patch Clearing flags on attachment: 257152 Committed r187140: <http://trac.webkit.org/changeset/187140>
WebKit Commit Bot
Comment 11 2015-07-21 17:07:27 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.