VideoCapturerHandle videoCapturerCreate()

in source/V4L2/V4L2VideoCapturer.c [50:77]


VideoCapturerHandle videoCapturerCreate(void)
{
    V4L2VideoCapturer* v4l2Handle = NULL;

    if (!(v4l2Handle = (V4L2VideoCapturer*) malloc(sizeof(V4L2VideoCapturer)))) {
        LOG("OOM");
        return NULL;
    }

    memset(v4l2Handle, 0, sizeof(V4L2VideoCapturer));

    v4l2Handle->privHandle = v4l2CapturerOpen("/dev/video0");

    if (!v4l2Handle->privHandle) {
        LOG("Failed to open /dev/video0");
        videoCapturerDestory((VideoCapturerHandle) v4l2Handle);
        return NULL;
    }

    // Now implementation supports H.264, 1080p, 720p, 480p, 360p and 320p
    v4l2Handle->capability.formats = (1 << (VID_FMT_H264 - 1));
    v4l2Handle->capability.resolutions =
        (1 << (VID_RES_1080P - 1)) | (1 << (VID_RES_720P - 1)) | (1 << (VID_RES_480P - 1)) | (1 << (VID_RES_360P - 1)) | (1 << (VID_RES_320P - 1));

    setStatus((VideoCapturerHandle) v4l2Handle, VID_CAP_STATUS_STREAM_OFF);

    return (VideoCapturerHandle) v4l2Handle;
}