int USBGrabber::open(const char* aDevPath, size_t *aWidth, size_t *aHeight, uint32_t *aFormat) { if (mFd != 0) { error("Device already opened"); return 0; } // Open capture device mFd = v4l2_open(aDevPath, O_RDWR | O_NONBLOCK, 0); if (mFd < 0) { error("Cannot open capturer device\n"); return 0; } if (!validateCaptureDevice()) return 0; if (!initCaptureFormat()) return 0; if (!setCaptureFormat(aWidth, aHeight, aFormat)) return 0; if (!getCaptureInfo()) return 0; if (!initBuffers()) return 0; if (!startStreaming()) return 0; return 1; }
/*! * Start saving data. * * This first checks whether it needsNewCaptureInfo() and calls * getCaptureInfo() if necessary. * * \return whether any necessary capture info was successfully retrieved * and saving was successfully started. */ bool DataSink::start() { if (!needsNewCaptureInfo() || getCaptureInfo()) return startSaving(); return false; }