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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 2958afd..1e21209 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -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>
diff --git a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
index 106734f..a537643 100644
--- a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
+++ b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
@@ -326,10 +326,7 @@
             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)];