RESOLVED FIXED 164561
[MediaStream] apply constraints passed to getUserMedia()
https://bugs.webkit.org/show_bug.cgi?id=164561
Summary [MediaStream] apply constraints passed to getUserMedia()
Eric Carlson
Reported 2016-11-09 14:38:26 PST
Restructure the way constraints passed to getUserMedia() are applied.
Attachments
Proposed patch. (119.85 KB, patch)
2016-11-10 06:01 PST, Eric Carlson
no flags
Updated patch. (120.67 KB, patch)
2016-11-10 08:00 PST, Eric Carlson
youennf: review+
buildbot: commit-queue-
Archive of layout-test-results from ews104 for mac-yosemite-wk2 (1.08 MB, application/zip)
2016-11-10 09:05 PST, Build Bot
no flags
Patch for landing. (121.01 KB, patch)
2016-11-10 12:20 PST, Eric Carlson
no flags
Radar WebKit Bug Importer
Comment 1 2016-11-09 18:48:35 PST
Eric Carlson
Comment 2 2016-11-10 06:01:05 PST
Created attachment 294366 [details] Proposed patch.
WebKit Commit Bot
Comment 3 2016-11-10 06:02:08 PST
Attachment 294366 [details] did not pass style-queue: ERROR: Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp:47: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:55: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp:55: More than one command on the same line [whitespace/newline] [4] Total errors found: 3 in 38 files If any of these errors are false positives, please file a bug against check-webkit-style.
Sam Weinig
Comment 4 2016-11-10 07:04:12 PST
Comment on attachment 294366 [details] Proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=294366&action=review > Source/WebCore/platform/mediastream/MediaConstraints.h:279 > + value = m_ideal.value(); > + if (value < min) > + value = min; > + if (value > max) > + value = max; You could write this as value = std::max(max, std::min(min, m_ideal.value())); > Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:168 > + if (fitnessDistance(*widthConstraint) == std::numeric_limits<double>::infinity()) { We traditionally use isinf) to compare against infinity.
Eric Carlson
Comment 5 2016-11-10 08:00:21 PST
Created attachment 294372 [details] Updated patch.
WebKit Commit Bot
Comment 6 2016-11-10 08:01:08 PST
Attachment 294372 [details] did not pass style-queue: ERROR: Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp:47: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:55: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp:55: More than one command on the same line [whitespace/newline] [4] Total errors found: 3 in 38 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eric Carlson
Comment 7 2016-11-10 08:02:32 PST
(In reply to comment #4) > Comment on attachment 294366 [details] > Proposed patch. > > View in context: > https://bugs.webkit.org/attachment.cgi?id=294366&action=review > > > Source/WebCore/platform/mediastream/MediaConstraints.h:279 > > + value = m_ideal.value(); > > + if (value < min) > > + value = min; > > + if (value > max) > > + value = max; > > You could write this as value = std::max(max, std::min(min, > m_ideal.value())); > Fixed. > > Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:168 > > + if (fitnessDistance(*widthConstraint) == std::numeric_limits<double>::infinity()) { > > We traditionally use isinf) to compare against infinity. > Fixed.
Build Bot
Comment 8 2016-11-10 09:05:21 PST
Comment on attachment 294372 [details] Updated patch. Attachment 294372 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/2490805 New failing tests: fast/mediastream/apply-constraints-audio.html fast/mediastream/apply-constraints-advanced.html fast/mediastream/apply-constraints-video.html
Build Bot
Comment 9 2016-11-10 09:05:25 PST
Created attachment 294377 [details] Archive of layout-test-results from ews104 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
youenn fablet
Comment 10 2016-11-10 10:25:06 PST
Comment on attachment 294372 [details] Updated patch. r=me once bots are all happy. Some nits below. View in context: https://bugs.webkit.org/attachment.cgi?id=294372&action=review > Source/WebCore/platform/mediastream/CaptureDeviceManager.cpp:113 > + if (RealtimeMediaSource* mediaSource = createMediaSourceForCaptureDeviceWithConstraints(captureDevice, constraints, invalidConstraint)) I would use auto for mediaSource. It seems strange to retrieve a raw pointer also. Why createMediaSourceForCaptureDeviceWithConstraints is not returning a RefPtr<>? > Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:164 > + RealtimeMediaSourceCapabilities& capabilities = *this->capabilities(); We probably should return a RealtimeMediaSourceCapabilities& directly. Maybe add an ASSERT here in the meantime? > Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:199 > + // Each of the values is supported individually, see of they all can be applied at the same time. s/of/if/ > Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:587 > + { Why do we need that indenting? > Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:588 > + RealtimeMediaSourceCapabilities& capabilities = *this->capabilities(); ASSERT again? > Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:629 > void RealtimeMediaSource::applyConstraints(const MediaConstraints& constraints, SuccessHandler successHandler, FailureHandler failureHandler) It seems strange to pass callbacks. I was expecting applyConstraints to work asynchronously, but it seems everything is done synchronously. Can we simplify this? It seems this function could just return Optional<String> or String if a null string means no error? > Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:101 > + // FIXME: Actually apply constraints to newly created sources. two spaces after to
Eric Carlson
Comment 11 2016-11-10 12:20:37 PST
Created attachment 294397 [details] Patch for landing.
WebKit Commit Bot
Comment 12 2016-11-10 12:56:00 PST
Comment on attachment 294397 [details] Patch for landing. Clearing flags on attachment: 294397 Committed r208559: <http://trac.webkit.org/changeset/208559>
WebKit Commit Bot
Comment 13 2016-11-10 12:56:05 PST
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.