mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Details coming soon.
This commit is contained in:
@@ -16,31 +16,9 @@ FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const u
|
||||
: Grabber("FRAMEBUFFERGRABBER", width, height)
|
||||
, _fbfd(0)
|
||||
, _fbp(0)
|
||||
, _fbDevice(device)
|
||||
, _fbDevice()
|
||||
{
|
||||
int result;
|
||||
struct fb_var_screeninfo vinfo;
|
||||
|
||||
// Check if the framebuffer device can be opened and display the current resolution
|
||||
_fbfd = open(QSTRING_CSTR(_fbDevice), O_RDONLY);
|
||||
if (_fbfd == 0)
|
||||
{
|
||||
Error(_log, "Error openning %s", QSTRING_CSTR(_fbDevice));
|
||||
}
|
||||
else
|
||||
{
|
||||
// get variable screen information
|
||||
result = ioctl (_fbfd, FBIOGET_VSCREENINFO, &vinfo);
|
||||
if (result != 0)
|
||||
{
|
||||
Error(_log, "Could not get screen information");
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(_log, "Display opened with resolution: %dx%d@%dbit", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
|
||||
}
|
||||
close(_fbfd);
|
||||
}
|
||||
setDevicePath(device);
|
||||
}
|
||||
|
||||
FramebufferFrameGrabber::~FramebufferFrameGrabber()
|
||||
@@ -63,7 +41,7 @@ int FramebufferFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
|
||||
bytesPerPixel = vinfo.bits_per_pixel / 8;
|
||||
capSize = vinfo.xres * vinfo.yres * bytesPerPixel;
|
||||
|
||||
|
||||
switch (vinfo.bits_per_pixel)
|
||||
{
|
||||
case 16: pixelFormat = PIXELFORMAT_BGR16; break;
|
||||
@@ -76,7 +54,7 @@ int FramebufferFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
}
|
||||
|
||||
/* map the device to memory */
|
||||
_fbp = (unsigned char*)mmap(0, capSize, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, _fbfd, 0);
|
||||
_fbp = (unsigned char*)mmap(0, capSize, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, _fbfd, 0);
|
||||
|
||||
_imageResampler.setHorizontalPixelDecimation(vinfo.xres/_width);
|
||||
_imageResampler.setVerticalPixelDecimation(vinfo.yres/_height);
|
||||
@@ -86,9 +64,41 @@ int FramebufferFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
vinfo.xres * bytesPerPixel,
|
||||
pixelFormat,
|
||||
image);
|
||||
|
||||
|
||||
munmap(_fbp, capSize);
|
||||
close(_fbfd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FramebufferFrameGrabber::setDevicePath(const QString& path)
|
||||
{
|
||||
if(_fbDevice != path)
|
||||
{
|
||||
_fbDevice = path;
|
||||
int result;
|
||||
struct fb_var_screeninfo vinfo;
|
||||
|
||||
// Check if the framebuffer device can be opened and display the current resolution
|
||||
_fbfd = open(QSTRING_CSTR(_fbDevice), O_RDONLY);
|
||||
if (_fbfd == 0)
|
||||
{
|
||||
Error(_log, "Error openning %s", QSTRING_CSTR(_fbDevice));
|
||||
}
|
||||
else
|
||||
{
|
||||
// get variable screen information
|
||||
result = ioctl (_fbfd, FBIOGET_VSCREENINFO, &vinfo);
|
||||
if (result != 0)
|
||||
{
|
||||
Error(_log, "Could not get screen information");
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(_log, "Display opened with resolution: %dx%d@%dbit", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
|
||||
}
|
||||
close(_fbfd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include <grabber/FramebufferWrapper.h>
|
||||
|
||||
FramebufferWrapper::FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority)
|
||||
: GrabberWrapper("FrameBuffer", &_grabber, grabWidth, grabHeight, updateRate_Hz, priority, hyperion::COMP_GRABBER)
|
||||
FramebufferWrapper::FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz)
|
||||
: GrabberWrapper("FrameBuffer", &_grabber, grabWidth, grabHeight, updateRate_Hz)
|
||||
, _grabber(device, grabWidth, grabHeight)
|
||||
{}
|
||||
|
||||
|
Reference in New Issue
Block a user