Skip to content

Commit

Permalink
Refactor C++ code #61, (check ffpmeg and v4l2-ctl utility explicitly…
Browse files Browse the repository at this point in the history
… and provide appropriate error log feedback in case of problems).
  • Loading branch information
vmdocua committed Dec 27, 2023
1 parent 33c35f3 commit d4e3aad
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Capture/videocapture/VideoCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,24 @@ bool checkOutDir(bool verbose, const std::string& outDir) {
return true;
}

int checkSystem(bool verbose) {
// check ffmpeg
std::string ffmpeg = exec(false, "which ffmpeg");
if( ffmpeg.empty() ) {
_ERROR("ffmpeg program not found. Please make sure ffmpeg package is installed.");
return EX_UNAVAILABLE;
}

// check v4l2-ctl
std::string v4l2ctl = exec(false, "which v4l2-ctl");
if( v4l2ctl.empty() ) {
_ERROR("v4l2-ctl program not found. Please make sure v4l-utils package is installed.");
return EX_UNAVAILABLE;
}

return EX_OK;
}

bool findTargetVideoDevice(const AppConfig& cfg,
const AppOpts& opts,
VideoDevice& vd) {
Expand Down Expand Up @@ -655,7 +673,7 @@ int main(int argc, char* argv[]) {
bool verbose = opts.verbose;

if( res1==1 ) return EX_OK; // help message
if( res1!=0 ) return res1;
if( res1!=EX_OK ) return res1;

_VERBOSE("Config file: " << opts.configPath);

Expand All @@ -671,6 +689,12 @@ int main(int argc, char* argv[]) {
return EX_CANTCREAT;
}

const int res2 = checkSystem(verbose);
if( res2!=EX_OK ) {
// problem with system configuration and installed packages
return res2;
}

// calculated options
VideoDevice targetDev;
std::string targetBusInfo;
Expand Down

0 comments on commit d4e3aad

Please sign in to comment.