setPreviewFpsRange not working despite values being within getPreviewFpsRange's range

余生长醉 提交于 2019-11-30 10:34:18

Ahah! So as part of my search for answers I checked the operation of my Nexus 10 with my app. It turns out that the values that the getSupportedFpsRange function returns are ranges representing exact duples that may be input into setPreviewFpsRange and any other duples are unsupported (as far as I can tell, anyway.)

I discovered this because the Nexus 10 returns multiple duples from getSupportedFpsRange. I've duplicated the three devices' getSupportedFpsRange return values here.

Examples of supported range values

LG Nexus 4:

preview-fps-range-values=(5000,120000);

Motorola Atrix:

preview-fps-range-values=(10000,30000);

Samsung Nexus 10:

preview-fps-range-values=(15000,15000),(24000,24000),(25000,25000),(15000,30000),(30000,30000);

Conclusion

We cannot do

params.setPreviewFpsRange( 29000, 29000 );

to force the preview to be at 29fps unless the device already specifically supports that duple.

Of course, the original reason I was investigating this functionality was in the hopes of replicating the Nexus 4's silky smooth camera preview in my own app. This would seem to prove conclusively that, on the Nexus 4 at least, setPreviewFpsRange won't help with that.

Time to continue searching. (:

I found that if getSupportedPreviewFpsRange list has only one pair of supported values like (2000, 35000) which is 2fp to 35fps then it will accept any values between that range.

If list containt more pairs then you need to use one of them

List<int[]> fpsRange = param.getSupportedPreviewFpsRange();

if (fpsRange.size() == 1) {
    //fpsRange.get(0)[0] < CAMERA_PREVIEW_FPS < fpsRange.get(0)[1]
    param.setPreviewFpsRange(CAMERA_PREVIEW_FPS, CAMERA_PREVIEW_FPS);
} else {
    //pick first from list to limit framerate or last to maximize framerate
    param.setPreviewFpsRange(fpsRange.get(0)[0], fpsRange.get(0)[1]);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!