Use clampTo in AVVideoCaptureSource::setSizeAndFrameRateWithPreset
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 May 2019 02:57:03 +0000 (02:57 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 May 2019 02:57:03 +0000 (02:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197704

Reviewed by Alex Christensen.

Use clampTo as suggested in bug 196214 review.
No change of behavior.

* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::setSizeAndFrameRateWithPreset):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245217 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm

index 2958afd..1e21209 100644 (file)
@@ -1,5 +1,18 @@
 2019-05-12  Youenn Fablet  <youenn@apple.com>
 
+        Use clampTo in AVVideoCaptureSource::setSizeAndFrameRateWithPreset
+        https://bugs.webkit.org/show_bug.cgi?id=197704
+
+        Reviewed by Alex Christensen.
+
+        Use clampTo as suggested in bug 196214 review.
+        No change of behavior.
+
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::setSizeAndFrameRateWithPreset):
+
+2019-05-12  Youenn Fablet  <youenn@apple.com>
+
         Use the main screen for screen capture
         https://bugs.webkit.org/show_bug.cgi?id=197804
         <rdar://problem/47671383>
index 106734f..a537643 100644 (file)
@@ -326,10 +326,7 @@ void AVVideoCaptureSource::setSizeAndFrameRateWithPreset(IntSize requestedSize,
             if (!frameRateRange)
                 return;
 
-            if (requestedFrameRate < frameRateRange.minFrameRate)
-                requestedFrameRate = frameRateRange.minFrameRate;
-            else if (requestedFrameRate > frameRateRange.maxFrameRate)
-                requestedFrameRate = frameRateRange.maxFrameRate;
+            requestedFrameRate = clampTo(requestedFrameRate, frameRateRange.minFrameRate, frameRateRange.maxFrameRate);
 
             ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "setting frame rate to ", requestedFrameRate);
             [device() setActiveVideoMinFrameDuration: CMTimeMake(1, requestedFrameRate)];