static int tc_v4l2_video_get_capture_buffer_count(V4L2Source *vs) { struct v4l2_requestbuffers reqbuf; int err = 0; reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; reqbuf.memory = V4L2_MEMORY_MMAP; reqbuf.count = TC_V4L2_BUFFERS_NUM; err = v4l2_ioctl(vs->video_fd, VIDIOC_REQBUFS, &reqbuf); if (err < 0) { tc_log_perror(MOD_NAME, "VIDIOC_REQBUFS"); return TC_ERROR; } vs->buffers_count = TC_MIN(reqbuf.count, TC_V4L2_BUFFERS_NUM); if (vs->buffers_count < 2) { tc_log_error(MOD_NAME, "not enough buffers for capture"); return TC_ERROR; } if (verbose_flag > TC_INFO) { tc_log_info(MOD_NAME, "%i buffers available (maximum supported: %i)", vs->buffers_count, TC_V4L2_BUFFERS_NUM); } return TC_OK; }
static int modrequest_fill(TCFactory factory, ModRequest *mods, size_t maxmods, size_t *modnum, glob_t *globbuf) { char modstr[TC_BUF_MIN]; int i = 0, count = 0, lim = 0; if (!factory || !mods || !globbuf) { return TC_ERROR; } if (maxmods < globbuf->gl_pathc) { tc_log_warn(EXE, "found %u candidate modules, but " "only %u allowed (dropping remaining)", (unsigned)globbuf->gl_pathc, (unsigned)maxmods); } lim = TC_MIN(maxmods, globbuf->gl_pathc); for (i = 0; i < lim; i++) { int ret; ret = parse_path(globbuf->gl_pathv[i], modstr, TC_BUF_MIN); if (ret != 0) { tc_log_warn(EXE, "error while parsing '%s', skipping", globbuf->gl_pathv[i]); continue; } ret = modrequest_load(factory, &mods[i], modstr); if (ret != 0) { tc_log_warn(EXE, "error while loading '%s', skipping", modstr); continue; } count++; } if (modnum != NULL) { *modnum += count; } return TC_OK; }