Android->media:get best framerate and set video record
This commit is contained in:
@ -525,6 +525,59 @@ status_t CameraSource::init(
|
||||
return err;
|
||||
}
|
||||
|
||||
int split(char dst[][4], char* str, const char* spl)
|
||||
{
|
||||
int n = 0;
|
||||
char *result = NULL;
|
||||
char src[70];
|
||||
strcpy(src,str);
|
||||
result = strtok(src, spl);
|
||||
|
||||
while( result != NULL )
|
||||
{
|
||||
strcpy(dst[n++], result);
|
||||
result = strtok(NULL, spl);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int getValueMax(int arry[],int n)
|
||||
{
|
||||
int max = arry[0];
|
||||
int i = 0;
|
||||
for(i ; i < n ; i++)
|
||||
{
|
||||
if(max < arry[i])
|
||||
max = arry[i];
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
int getBestFrameRate(char *str)
|
||||
{
|
||||
int num = 0;
|
||||
int value[10];
|
||||
char dst[10][4];
|
||||
int i = 0;
|
||||
num = split(dst,str,",");
|
||||
|
||||
for(i ; i<num ; i++)
|
||||
{
|
||||
value[i] = atoi(dst[i]);
|
||||
}
|
||||
|
||||
if(num == 1)
|
||||
{
|
||||
return value[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return getValueMax(value,num);
|
||||
}
|
||||
}
|
||||
|
||||
status_t CameraSource::initWithCameraAccess(
|
||||
const sp<ICamera>& camera,
|
||||
const sp<ICameraRecordingProxy>& proxy,
|
||||
@ -536,8 +589,7 @@ status_t CameraSource::initWithCameraAccess(
|
||||
bool storeMetaDataInVideoBuffers) {
|
||||
ALOGV("initWithCameraAccess");
|
||||
status_t err = OK;
|
||||
|
||||
frameRate = 30;
|
||||
|
||||
|
||||
if ((err = isCameraAvailable(camera, proxy, cameraId,
|
||||
clientName, clientUid)) != OK) {
|
||||
@ -549,6 +601,18 @@ status_t CameraSource::initWithCameraAccess(
|
||||
return err;
|
||||
}
|
||||
|
||||
const char* supportedFrameRates1 =
|
||||
params.get(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES);
|
||||
|
||||
if(supportedFrameRates1 != NULL)
|
||||
{
|
||||
frameRate = getBestFrameRate((char *)supportedFrameRates1);
|
||||
}
|
||||
else
|
||||
{
|
||||
frameRate = 30;
|
||||
}
|
||||
ALOGD("frameRate:%d\n",frameRate);
|
||||
// Set the camera to use the requested video frame size
|
||||
// and/or frame rate.
|
||||
if ((err = configureCamera(¶ms,
|
||||
|
||||
Reference in New Issue
Block a user