in source/V4L2/V4L2VideoCapturer.c [103:159]
int videoCapturerSetFormat(VideoCapturerHandle handle, const VideoFormat format, const VideoResolution resolution)
{
V4L2_HANDLE_NULL_CHECK(handle);
V4L2_HANDLE_GET(handle);
V4L2_HANDLE_STATUS_CHECK(v4l2Handle, VID_CAP_STATUS_STREAM_OFF);
uint32_t width, height = 0;
switch (resolution) {
case VID_RES_1080P:
width = 1920;
height = 1080;
break;
case VID_RES_720P:
width = 1080;
height = 720;
break;
case VID_RES_480P:
width = 720;
height = 480;
break;
case VID_RES_360P:
width = 480;
height = 360;
break;
case VID_RES_320P:
width = 416;
height = 320;
break;
default:
LOG("Unsupported resolution %d", resolution);
return -EINVAL;
}
V4l2CapturerFormat privFormat = V4L2_CAP_FMT_H264;
switch (format) {
case VID_FMT_H264:
privFormat = V4L2_CAP_FMT_H264;
break;
default:
LOG("Unsupported format %d", format);
return -EINVAL;
break;
}
if (v4l2CapturerConfig(v4l2Handle->privHandle, width, height, privFormat, V4L2_TARGET_BITRATE)) {
LOG("Failed to config V4L2 Capturer");
return -EAGAIN;
}
v4l2Handle->format = format;
v4l2Handle->resolution = resolution;
return 0;
}