WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
147171
Fill vectors in UserMediaRequest with only UIDs of devices that satisfy constraints
https://bugs.webkit.org/show_bug.cgi?id=147171
Summary
Fill vectors in UserMediaRequest with only UIDs of devices that satisfy const...
Matthew Daiter
Reported
2015-07-21 16:25:28 PDT
We currently send a list of devices, no matter what, to Safari for requesting user media. There should be an easy way to create a list of only devices that can satisfy constraints.
Attachments
Patch
(11.22 KB, patch)
2015-07-21 16:48 PDT
,
Matthew Daiter
no flags
Details
Formatted Diff
Diff
Patch
(13.03 KB, patch)
2015-07-21 17:21 PDT
,
Matthew Daiter
no flags
Details
Formatted Diff
Diff
Patch
(13.38 KB, patch)
2015-07-21 18:06 PDT
,
Matthew Daiter
no flags
Details
Formatted Diff
Diff
Patch
(14.25 KB, patch)
2015-07-21 18:46 PDT
,
Matthew Daiter
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2015-07-21 16:26:11 PDT
<
rdar://problem/21931121
>
Matthew Daiter
Comment 2
2015-07-21 16:48:04 PDT
Created
attachment 257218
[details]
Patch
Darin Adler
Comment 3
2015-07-21 16:59:32 PDT
Comment on
attachment 257218
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=257218&action=review
Doesn’t build because you forgot to update the other implementations of MediaStreamCreationClient, specifically MockRealtimeMediaSourceCenter.
> Source/WebCore/Modules/mediastream/UserMediaRequest.cpp:126 > + for (auto audioTrack : audioTracks)
This will churn reference counts unnecessarily as we iterate each item and copy it into a RefPtr. To fix that, use auto& instead of auto.
> Source/WebCore/Modules/mediastream/UserMediaRequest.cpp:128 > + for (auto videoTrack : videoTracks)
Ditto.
> Source/WebCore/Modules/mediastream/UserMediaRequest.h:74 > + Vector<String> filteredListUIDsVideo() const { return m_filteredListUIDsVideo; } > + Vector<String> filteredListUIDsAudio() const { return m_filteredListUIDsAudio; }
It’s inefficient to copy these vectors just to return them. Please consider returning const Vector<String>& instead.
> Source/WebCore/platform/mediastream/MediaStreamCreationClient.h:41 > + virtual void constraintsValidated(Vector<RefPtr<RealtimeMediaSource>>, Vector<RefPtr<RealtimeMediaSource>>) = 0;
It’s inefficient to copy these vectors as part of calling this function. Please consider const Vector&. Also, it’s not clear what these two vectors represent, so these arguments need names.
> Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm:383 > + Vector<RefPtr<RealtimeMediaSource>> bestSourcesList = Vector<RefPtr<RealtimeMediaSource>>();
No need to do the "=" part here. Vectors are empty by default without any explicit initialization.
> Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm:389 > Vector<CaptureDevice>& devices = captureDeviceList(); > size_t count = devices.size();
This code should really use a modern for loop, like this: for (auto& device : captureDeviceList()) { Then below use “device” wherever the old code used “devices[i]”. Only issue is that we’d need to rename the local variables named device below.
> Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:102 > + // FIXME: consider the constraints when choosing among multiple devices. For now just select the first available
Please capitalize the sentence in a comment like this. The word "consider".
> Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:117 > + // FIXME: consider the constraints when choosing among multiple devices. For now just select the first available
Please capitalize the sentence in a comment like this. The word "consider".
Matthew Daiter
Comment 4
2015-07-21 17:21:33 PDT
Created
attachment 257221
[details]
Patch
Eric Carlson
Comment 5
2015-07-21 17:51:53 PDT
Comment on
attachment 257221
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=257221&action=review
Looks good overall, but it obviously needs to be rebased so it applies to trunk.
> Source/WebCore/Modules/mediastream/UserMediaRequest.h:74 > + const Vector<String>& deviceUIDsVideo() const { return m_deviceUIDsVideo; } > + const Vector<String>& deviceUIDsAudio() const { return m_deviceUIDsAudio; }
Nit: I think audioDeviceUIDs and videoDeviceUIDs would be better. Also for the instance variables.
Matthew Daiter
Comment 6
2015-07-21 17:52:44 PDT
Comment on
attachment 257221
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=257221&action=review
>> Source/WebCore/Modules/mediastream/UserMediaRequest.h:74 >> + const Vector<String>& deviceUIDsAudio() const { return m_deviceUIDsAudio; } > > Nit: I think audioDeviceUIDs and videoDeviceUIDs would be better. Also for the instance variables.
Fixed.
Matthew Daiter
Comment 7
2015-07-21 18:06:22 PDT
Created
attachment 257231
[details]
Patch
Matthew Daiter
Comment 8
2015-07-21 18:46:32 PDT
Created
attachment 257236
[details]
Patch
Eric Carlson
Comment 9
2015-07-22 06:51:00 PDT
Comment on
attachment 257236
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=257236&action=review
> Source/WebCore/Modules/mediastream/UserMediaRequest.h:80 > + virtual void constraintsValidated(const Vector<RefPtr<RealtimeMediaSource>>&, const Vector<RefPtr<RealtimeMediaSource>>&) override final;
As Darin noted earlier, it is not clear what these two vectors represent so these arguments need names.
WebKit Commit Bot
Comment 10
2015-07-22 11:10:28 PDT
Comment on
attachment 257236
[details]
Patch Clearing flags on attachment: 257236 Committed
r187168
: <
http://trac.webkit.org/changeset/187168
>
WebKit Commit Bot
Comment 11
2015-07-22 11:10:36 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.
Top of Page
Format For Printing
XML
Clone This Bug