Skip to content

Commit

Permalink
Fix getUserMedia may get low FPS when the selected FPS is out of rang…
Browse files Browse the repository at this point in the history
…e of the camera FPS eg 31 fps is wanted, the supported range is [11,30] then the final FPS should be selected to be 30 instead of 11

Review URL: https://codereview.chromium.org/641293002

Cr-Commit-Position: refs/heads/master@{#301661}
  • Loading branch information
js0701 authored and Commit bot committed Oct 28, 2014
1 parent d971186 commit dffd2c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ Joel Stanley <joel@jms.id.au>
Johannes Rudolph <johannes.rudolph@googlemail.com>
John Yani <vanuan@gmail.com>
John Yoo <nearbyh13@gmail.com>
Johnson Lin <johnson.lin@intel.com>
Jonathan Frazer <listedegarde@gmail.com>
Jonathan Hacker <jhacker@arcanefour.com>
Jongsoo Lee <leejongsoo@gmail.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ public boolean allocate(int width, int height, int frameRate) {
Log.e(TAG, "allocate: no fps range found");
return false;
}
// API fps ranges are scaled up x1000 to avoid floating point.
int frameRateScaled = frameRate * 1000;
// Use the first range as the default chosen range.
int[] chosenFpsRange = listFpsRange.get(0);
int chosenFrameRate = (chosenFpsRange[0] + 999) / 1000;
int frameRateNearest = Math.abs(frameRateScaled - chosenFpsRange[0]) <
Math.abs(frameRateScaled - chosenFpsRange[1]) ?
chosenFpsRange[0] : chosenFpsRange[1];
int chosenFrameRate = (frameRateNearest + 999) / 1000;
int fpsRangeSize = Integer.MAX_VALUE;
// API fps ranges are scaled up x1000 to avoid floating point.
int frameRateScaled = frameRate * 1000;
for (int[] fpsRange : listFpsRange) {
if (fpsRange[0] <= frameRateScaled && frameRateScaled <= fpsRange[1]
&& (fpsRange[1] - fpsRange[0]) <= fpsRangeSize) {
Expand Down

0 comments on commit dffd2c3

Please sign in to comment.