Fix frame rate selection for Android camera.
- Android camera supports multiple fps values for a single video resolution - change video source default video format selection to pick up best available fps. - Change fps range calculation to better match target fps value. BUG=2622 R=tkchin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/15339004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7142 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -28,6 +28,7 @@
|
||||
#include "talk/app/webrtc/videosource.h"
|
||||
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "talk/app/webrtc/mediaconstraintsinterface.h"
|
||||
#include "talk/session/media/channelmanager.h"
|
||||
@ -254,11 +255,15 @@ const cricket::VideoFormat& GetBestCaptureFormat(
|
||||
|
||||
std::vector<cricket::VideoFormat>::const_iterator it = formats.begin();
|
||||
std::vector<cricket::VideoFormat>::const_iterator best_it = formats.begin();
|
||||
int best_diff = abs(default_area - it->width* it->height);
|
||||
int best_diff_area = std::abs(default_area - it->width * it->height);
|
||||
int64 best_diff_interval = kDefaultFormat.interval;
|
||||
for (; it != formats.end(); ++it) {
|
||||
int diff = abs(default_area - it->width* it->height);
|
||||
if (diff < best_diff) {
|
||||
best_diff = diff;
|
||||
int diff_area = std::abs(default_area - it->width * it->height);
|
||||
int64 diff_interval = std::abs(kDefaultFormat.interval - it->interval);
|
||||
if (diff_area < best_diff_area ||
|
||||
(diff_area == best_diff_area && diff_interval < best_diff_interval)) {
|
||||
best_diff_area = diff_area;
|
||||
best_diff_interval = diff_interval;
|
||||
best_it = it;
|
||||
}
|
||||
}
|
||||
|
@ -234,14 +234,20 @@ void DeviceInfoAndroid::GetMFpsRange(const char* deviceUniqueIdUTF8,
|
||||
const AndroidCameraInfo* info = FindCameraInfoByName(deviceUniqueIdUTF8);
|
||||
if (info == NULL)
|
||||
return;
|
||||
// Rely on CameraParameters.getSupportedPreviewFpsRange() to sort its return
|
||||
// value (per its documentation) and return the first (most flexible) range
|
||||
// whose high end is at least as high as that requested.
|
||||
int desired_mfps = max_fps_to_match * 1000;
|
||||
int best_diff_mfps = 0;
|
||||
LOG(LS_INFO) << "Search for best target mfps " << desired_mfps;
|
||||
// Search for best fps range with preference shifted to constant fps modes.
|
||||
for (size_t i = 0; i < info->mfpsRanges.size(); ++i) {
|
||||
if (info->mfpsRanges[i].second / 1000 >= max_fps_to_match) {
|
||||
int diff_mfps = abs(info->mfpsRanges[i].first - desired_mfps) +
|
||||
abs(info->mfpsRanges[i].second - desired_mfps) +
|
||||
(info->mfpsRanges[i].second - info->mfpsRanges[i].first) / 2;
|
||||
LOG(LS_INFO) << "Fps range " << info->mfpsRanges[i].first << ":" <<
|
||||
info->mfpsRanges[i].second << ". Distance: " << diff_mfps;
|
||||
if (i == 0 || diff_mfps < best_diff_mfps) {
|
||||
best_diff_mfps = diff_mfps;
|
||||
*min_mfps = info->mfpsRanges[i].first;
|
||||
*max_mfps = info->mfpsRanges[i].second;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user