Skip to content

Commit

Permalink
Updated linux frame buffer enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
trcwm committed Jul 13, 2017
1 parent 48e7b01 commit 203bb32
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
63 changes: 38 additions & 25 deletions linux/platformcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
OpenPnp-Capture: a video capture subsystem.
Windows platform code
Linux platform code
Created by Niels Moseley on 7/6/17.
Copyright © 2017 Niels Moseley. All rights reserved.
Expand Down Expand Up @@ -45,8 +45,6 @@ bool PlatformContext::enumerateDevices()
{
int fd;
v4l2_capability video_cap;
//video_window video_win;
//video_picture video_pic;

LOG(LOG_INFO,"Enumerating devices\n");

Expand Down Expand Up @@ -113,31 +111,46 @@ bool PlatformContext::enumerateDevices()
platformDeviceInfo* dinfo = new platformDeviceInfo();
dinfo->m_name = std::string((const char*)video_cap.card);
dinfo->m_devicePath = std::string(fname);
m_devices.push_back(dinfo);
}


#if 0
if (ioctl(fd, VIDIOCGWIN, &video_win) == -1)
{
LOG(LOG_ERR, "enumerateDevices: Can't get window information\n");
}
else
{
LOG(LOG_INFO, "Current size:\t%d x %d\n", video_win.width, video_win.height);
}

// enumerate the frame formats
v4l2_fmtdesc fmtdesc;
uint32_t index = 0;
fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

bool tryMore = true;
while(tryMore)
{
fmtdesc.index = index;

// first we find the pixel format type / fourcc
if (ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc) == -1)
{
tryMore = false;
}
else
{
LOG(LOG_INFO, "Format %d\n", index);
LOG(LOG_INFO, " FOURCC = %s\n", fourCCToString(fmtdesc.pixelformat).c_str());

// .. then we enumerate all the frame buffer sizes for that
// pixel format type.
uint32_t frmindex = 0;
CapFormatInfo cinfo;
cinfo.fourcc = fmtdesc.pixelformat;
while(queryFrameSize(fd, frmindex, fmtdesc.pixelformat, &cinfo.width, &cinfo.height))
{
frmindex++;
dinfo->m_formats.push_back(cinfo);
LOG(LOG_INFO, " %d x %d\n", cinfo.width, cinfo.height);
}
}
index++;
}

if (ioctl(fd, VIDIOCGPICT, &video_pic) == -1)
{
LOG(LOG_ERR, "enumerateDevices: Can't get picture information");
}
else
{
printf("Current depth:\t%d\n", video_pic.depth);
m_devices.push_back(dinfo);
}
#endif

close(fd);
::close(fd);
}
return true;
}
2 changes: 1 addition & 1 deletion linux/platformstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
OpenPnp-Capture: a video capture subsystem.
Windows platform code
Linux platform code
Created by Niels Moseley on 7/6/17.
Copyright © 2017 Niels Moseley. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion linux/platformstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
OpenPnp-Capture: a video capture subsystem.
Windows platform code
Linux platform code
Created by Niels Moseley on 7/6/17.
Copyright © 2017 Niels Moseley. All rights reserved.
Expand Down

0 comments on commit 203bb32

Please sign in to comment.