Skip to content

Commit

Permalink
add fourcc
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed May 22, 2020
1 parent 1d7b39c commit 283c43c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions inc/V4l2Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class V4l2Device
void queryFormat();

static std::string fourcc(unsigned int format);
static unsigned int fourcc(const char* format);

protected:
V4L2DeviceParameters m_params;
Expand Down
10 changes: 10 additions & 0 deletions src/V4l2Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ std::string V4l2Device::fourcc(unsigned int format) {
return std::string(formatArray, strlen(formatArray));
}

unsigned int V4l2Device::fourcc(const char* format) {
char fourcc[4];
memset(&fourcc, 0, sizeof(fourcc));
if (format != NULL)
{
strncpy(fourcc, format, 4);
}
return v4l2_fourcc(fourcc[0], fourcc[1], fourcc[2], fourcc[3]);
}

// -----------------------------------------
// V4L2Device
// -----------------------------------------
Expand Down

0 comments on commit 283c43c

Please sign in to comment.