WebKit Bugzilla
Attachment 371091 Details for
Bug 198421
: Allow resizing of camera video feeds to very small resolutions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-198421-20190531151738.patch (text/plain), 11.63 KB, created by
youenn fablet
on 2019-05-31 15:17:39 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-05-31 15:17:39 PDT
Size:
11.63 KB
patch
obsolete
>Subversion Revision: 245849 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 13c3e82503825c73e21ef1cadb04de2ba4124a78..d5b84be9fbd6c8ae2d2a24d5020acff3d45b0f13 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,23 @@ >+2019-05-31 Youenn Fablet <youenn@apple.com> >+ >+ Allow resizing of camera video feeds to very small resolutions >+ https://bugs.webkit.org/show_bug.cgi?id=198421 >+ >+ Reviewed by Alex Christensen. >+ >+ Before the patch, the minimum capture resolution was set to 120. >+ Since this is a bit arbitrary and there are some use cases for lower resolution, >+ We now allow down to 1x1 resolution. >+ >+ Test: fast/mediastream/getUserMedia-video-rescaling.html >+ >+ * platform/mediastream/RealtimeVideoSource.cpp: >+ (WebCore::RealtimeVideoSource::updateCapabilities): >+ Allow 1x1 when computing min/max resolutions. >+ (WebCore::RealtimeVideoSource::bestSupportedSizeAndFrameRate): >+ In case width and height are provided, we pick the closest preset that matches and resize accordingly. >+ If width or height is provided, we pick the closest preset tat matches and applies its aspect ratio. >+ > 2019-05-30 Youenn Fablet <youenn@apple.com> > > Fix AVVideoCaptureSource::setFrameRateWithPreset logging >diff --git a/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp b/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp >index f24e0080691caa9b1d735b612347e4ff4f4188b2..065006e34c340b523906c68eb77aedff45df451c 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp >@@ -177,12 +177,11 @@ void RealtimeVideoSource::updateCapabilities(RealtimeMediaSourceCapabilities& ca > } > > if (canResizeVideoFrames()) { >+ minimumWidth = 1; >+ minimumHeight = 1; > for (auto& size : standardVideoSizes()) { >- if (size.width() < minimumWidth || size.height() < minimumHeight) { >- minimumWidth = std::min(minimumWidth, size.width()); >- minimumHeight = std::min(minimumHeight, size.height()); >+ if (size.width() < minimumWidth || size.height() < minimumHeight) > minimumAspectRatio = std::min(minimumAspectRatio, static_cast<double>(size.width()) / size.height()); >- } > } > } > >@@ -307,13 +306,13 @@ Optional<RealtimeVideoSource::CaptureSizeAndFrameRate> RealtimeVideoSource::best > if (exactSizePreset || aspectRatioPreset) > continue; > >+ if ((requestedWidth && requestedWidth.value() > preset->size.width()) || (requestedHeight && requestedHeight.value() > preset->size.height())) >+ continue; >+ > if (requestedWidth && requestedHeight) { >- const auto& minStandardSize = standardVideoSizes()[0]; >- if (requestedWidth.value() >= minStandardSize.width() && requestedHeight.value() >= minStandardSize.height()) { >- if (!resizePreset || shouldUsePreset(*resizePreset, preset)) { >- resizePreset = &preset.get(); >- resizeSize = { requestedWidth.value(), requestedHeight.value() }; >- } >+ if (!resizePreset || shouldUsePreset(*resizePreset, preset)) { >+ resizePreset = &preset.get(); >+ resizeSize = { requestedWidth.value(), requestedHeight.value() }; > } > } else { > for (auto& standardSize : standardVideoSizes()) { >@@ -327,6 +326,14 @@ Optional<RealtimeVideoSource::CaptureSizeAndFrameRate> RealtimeVideoSource::best > resizeSize = standardSize; > } > } >+ >+ if (!resizePreset || shouldUsePreset(*resizePreset, preset)) { >+ resizePreset = &preset.get(); >+ if (requestedWidth) >+ resizeSize = { requestedWidth.value(), requestedWidth.value() * preset->size.height() / preset->size.width()}; >+ else >+ resizeSize = { requestedHeight.value() * preset->size.width() / preset->size.height(), requestedHeight.value() }; >+ } > } > } > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index f1bb8feb3dedaae5b34180c2c9d6252612ad9cf9..e882850c87de18f7f54a8d86a4e6c0db602718ba 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,19 @@ >+2019-05-31 Youenn Fablet <youenn@apple.com> >+ >+ Allow resizing of camera video feeds to very small resolutions >+ https://bugs.webkit.org/show_bug.cgi?id=198421 >+ >+ Reviewed by Alex Christensen. >+ >+ Update tests to expect 1x1 minimum capture resolution. >+ >+ * fast/mediastream/MediaStreamTrack-getCapabilities-expected.txt: >+ * fast/mediastream/apply-constraints-video-expected.txt: >+ * fast/mediastream/apply-constraints-video.html: >+ * fast/mediastream/get-user-media-constraints-expected.txt: >+ * fast/mediastream/getUserMedia-video-rescaling-expected.txt: Added. >+ * fast/mediastream/getUserMedia-video-rescaling.html: Added. >+ > 2019-05-29 Youenn Fablet <youenn@apple.com> > > Add an option to mute audio capture automatically when page is not visible >diff --git a/LayoutTests/fast/mediastream/MediaStreamTrack-getCapabilities-expected.txt b/LayoutTests/fast/mediastream/MediaStreamTrack-getCapabilities-expected.txt >index 43e9f4209feeb8a0b97078f76f33ec6b34a8640d..3e6064f2c11fb135c1becbdf4f487f6837e0bf2f 100644 >--- a/LayoutTests/fast/mediastream/MediaStreamTrack-getCapabilities-expected.txt >+++ b/LayoutTests/fast/mediastream/MediaStreamTrack-getCapabilities-expected.txt >@@ -8,8 +8,8 @@ video track capabilities: > capabilities.deviceId = <UUID> > capabilities.facingMode = [ user ] > capabilities.frameRate = { max: 30, min: 5 } >- capabilities.height = { max: 720, min: 112 } >- capabilities.width = { max: 1280, min: 112 } >+ capabilities.height = { max: 720, min: 1 } >+ capabilities.width = { max: 1280, min: 1 } > > audio track capabilities: > capabilities.deviceId = <UUID> >diff --git a/LayoutTests/fast/mediastream/apply-constraints-video-expected.txt b/LayoutTests/fast/mediastream/apply-constraints-video-expected.txt >index 37d3ee680269ab6ac9c67acb13fecc42679ab67d..16e37b064597140fcec7f2c1bcf446bf2a330395 100644 >--- a/LayoutTests/fast/mediastream/apply-constraints-video-expected.txt >+++ b/LayoutTests/fast/mediastream/apply-constraints-video-expected.txt >@@ -52,14 +52,14 @@ PASS settings['height'] is 720 > ** Constraint: {"width":5000} - ideal width is greater than track capability, should be clamped to the maximum value. > PASS settings['width'] is 1280 > >-** Constraint: {"width":100,"height":100,"frameRate":4} - all values are less than track capabilities, should be clamped to the minimum values. >-PASS settings['width'] is 112 >-PASS settings['height'] is 112 >+** Constraint: {"width":100,"height":100,"frameRate":4} - frameRate value is less than track capabilities, should be clamped to the minimum values. >+PASS settings['width'] is 100 >+PASS settings['height'] is 100 > PASS settings['frameRate'] is 5 > > ** Constraint: {"frameRate":20} - set frame rate, width and height should remain unchanged >-PASS settings['width'] is 112 >-PASS settings['height'] is 112 >+PASS settings['width'] is 100 >+PASS settings['height'] is 100 > PASS settings['frameRate'] is 20 > > ** Constraint: {"facingMode":"xnvironment","height":720} - illegal facing mode value should be ignored, height should change. >diff --git a/LayoutTests/fast/mediastream/apply-constraints-video.html b/LayoutTests/fast/mediastream/apply-constraints-video.html >index 02e112b4060b38b6e492e7eb442e18a4cea0823f..4f2b7f01e71dd7207f24911771c2d5ec125676cc 100644 >--- a/LayoutTests/fast/mediastream/apply-constraints-video.html >+++ b/LayoutTests/fast/mediastream/apply-constraints-video.html >@@ -55,14 +55,14 @@ > expected: { width: 1280}, > }, > { >- message: "all values are less than track capabilities, should be clamped to the minimum values.", >+ message: "frameRate value is less than track capabilities, should be clamped to the minimum values.", > constraint: { width: 100, height: 100, frameRate: 4 }, >- expected: { width: 112, height: 112, frameRate: 5 }, >+ expected: { width: 100, height: 100, frameRate: 5 }, > }, > { > message: "set frame rate, width and height should remain unchanged", >- constraint: { frameRate: 20 }, >- expected: { width: 112, height: 112, frameRate: 20 }, >+ constraint: { frameRate: 20 }, >+ expected: { width: 100, height: 100, frameRate: 20 }, > }, > { > message: "illegal facing mode value should be ignored, height should change.", >diff --git a/LayoutTests/fast/mediastream/get-user-media-constraints-expected.txt b/LayoutTests/fast/mediastream/get-user-media-constraints-expected.txt >index 856fcc5f9efa99acaeec1c64dc54998e2af7c353..473b66075f3a81712301ca3d1d3bc85bf7755d6c 100644 >--- a/LayoutTests/fast/mediastream/get-user-media-constraints-expected.txt >+++ b/LayoutTests/fast/mediastream/get-user-media-constraints-expected.txt >@@ -1,4 +1,4 @@ > > >-FAIL Ideal deviceId constraints promise_test: Unhandled rejection with value: object "Error: Invalid constraint" >+PASS Ideal deviceId constraints > >diff --git a/LayoutTests/fast/mediastream/getUserMedia-video-rescaling-expected.txt b/LayoutTests/fast/mediastream/getUserMedia-video-rescaling-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..6c95e527f4052009c504d0893d5c5b848c7ec4a0 >--- /dev/null >+++ b/LayoutTests/fast/mediastream/getUserMedia-video-rescaling-expected.txt >@@ -0,0 +1,6 @@ >+ >+ >+PASS wdith 100 height 100 video >+PASS width 100 video >+PASS height 100 video >+ >diff --git a/LayoutTests/fast/mediastream/getUserMedia-video-rescaling.html b/LayoutTests/fast/mediastream/getUserMedia-video-rescaling.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9f0409d5b05a181e195540ce625ac42ceb106d47 >--- /dev/null >+++ b/LayoutTests/fast/mediastream/getUserMedia-video-rescaling.html >@@ -0,0 +1,43 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Testing video capture resizing</title> >+ <script src="../../resources/testharness.js"></script> >+ <script src="../../resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <video id="video" autoplay=""></video> >+ <script> >+promise_test(async (test) => { >+ const localStream = await navigator.mediaDevices.getUserMedia({video: { width : { exact : 100 }, height : { exact : 100 }, facingMode: "environment" } }); >+ >+ video.srcObject = localStream; >+ await video.play(); >+ >+ assert_equals(video.videoWidth, 100, "width"); >+ assert_equals(video.videoHeight, 100, "height"); >+}, "wdith 100 height 100 video"); >+ >+promise_test(async (test) => { >+ const localStream = await navigator.mediaDevices.getUserMedia({video: { width : { exact : 100 }, facingMode: "environment" } }); >+ >+ video.srcObject = localStream; >+ await video.play(); >+ >+ assert_equals(video.videoWidth, 100, "width"); >+ assert_equals(video.videoHeight, 75, "height"); >+}, "width 100 video"); >+ >+promise_test(async (test) => { >+ const localStream = await navigator.mediaDevices.getUserMedia({video: { height : { exact : 100 }, facingMode: "environment" } }); >+ >+ video.srcObject = localStream; >+ await video.play(); >+ >+ assert_equals(video.videoWidth, 133, "width"); >+ assert_equals(video.videoHeight, 100, "height"); >+}, "height 100 video "); >+ </script> >+ </body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198421
:
371066
|
371076
|
371079
| 371091