mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
implement set videomode via json api (#457)
* implement set videomode via json api * refactor grabbers: - new base class - move shared code to base class * fix osx * rework all cmakelist files with auto file collection. except leddevices (need further restructuring) * store current video and grabbing mode * add json stuff * remove grabbingmode - we do not want to expose it
This commit is contained in:
@@ -31,10 +31,8 @@
|
||||
#endif
|
||||
|
||||
AmlogicGrabber::AmlogicGrabber(const unsigned width, const unsigned height)
|
||||
: _width(qMax(160u, width)) // Minimum required width or height is 160
|
||||
, _height(qMax(160u, height))
|
||||
: Grabber("AMLOGICGRABBER", qMax(160u, width), qMax(160u, height)) // Minimum required width or height is 160
|
||||
, _amlogicCaptureDev(-1)
|
||||
, _log(Logger::getInstance("AMLOGICGRABBER"))
|
||||
{
|
||||
Debug(_log, "constructed(%d x %d)",_width,_height);
|
||||
}
|
||||
@@ -51,24 +49,13 @@ AmlogicGrabber::~AmlogicGrabber()
|
||||
}
|
||||
}
|
||||
|
||||
void AmlogicGrabber::setVideoMode(const VideoMode videoMode)
|
||||
{
|
||||
switch (videoMode) {
|
||||
case VIDEO_3DSBS:
|
||||
//vc_dispmanx_rect_set(&_rectangle, 0, 0, _width/2, _height);
|
||||
break;
|
||||
case VIDEO_3DTAB:
|
||||
//vc_dispmanx_rect_set(&_rectangle, 0, 0, _width, _height/2);
|
||||
break;
|
||||
case VIDEO_2D:
|
||||
default:
|
||||
//vc_dispmanx_rect_set(&_rectangle, 0, 0, _width, _height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool AmlogicGrabber::isVideoPlaying()
|
||||
{
|
||||
|
||||
// TODO crop resulting image accroding member _videoMode
|
||||
// TODO add croping
|
||||
|
||||
const QString videoDevice = "/dev/amvideo";
|
||||
|
||||
// Open the video device
|
||||
@@ -97,7 +84,7 @@ bool AmlogicGrabber::isVideoPlaying()
|
||||
int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
|
||||
{
|
||||
// resize the given image if needed
|
||||
if (image.width() != _width || image.height() != _height)
|
||||
if (image.width() != (unsigned)_width || image.height() != (unsigned)_height)
|
||||
{
|
||||
image.resize(_width, _height);
|
||||
}
|
||||
|
@@ -4,26 +4,14 @@ INCLUDE (CheckIncludeFiles)
|
||||
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic)
|
||||
|
||||
SET(AmlogicHEADERS
|
||||
${CURRENT_HEADER_DIR}/AmlogicGrabber.h
|
||||
${CURRENT_HEADER_DIR}/AmlogicWrapper.h
|
||||
)
|
||||
|
||||
SET(AmlogicSOURCES
|
||||
${CURRENT_SOURCE_DIR}/AmlogicWrapper.cpp
|
||||
${CURRENT_SOURCE_DIR}/AmlogicGrabber.cpp
|
||||
)
|
||||
FILE ( GLOB AmlogicSOURCES "${CURRENT_HEADER_DIR}/Amlogic*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
|
||||
|
||||
CHECK_INCLUDE_FILES ("amcodec/amports/amstream.h" HAVE_AML_HEADER)
|
||||
IF (${HAVE_AML_HEADER})
|
||||
ADD_DEFINITIONS( -DHAVE_AML_HEADER )
|
||||
ENDIF()
|
||||
|
||||
|
||||
add_library(amlogic-grabber
|
||||
${AmlogicHEADERS}
|
||||
${AmlogicSOURCES}
|
||||
)
|
||||
add_library(amlogic-grabber ${AmlogicSOURCES} )
|
||||
|
||||
target_link_libraries(amlogic-grabber
|
||||
hyperion
|
||||
|
@@ -1,4 +1,3 @@
|
||||
|
||||
# Find the BCM-package (VC control)
|
||||
find_package(BCM REQUIRED)
|
||||
include_directories(${BCM_INCLUDE_DIRS})
|
||||
@@ -7,20 +6,9 @@ include_directories(${BCM_INCLUDE_DIRS})
|
||||
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/dispmanx)
|
||||
|
||||
SET(DispmanxGrabberHEADERS
|
||||
${CURRENT_HEADER_DIR}/DispmanxWrapper.h
|
||||
${CURRENT_HEADER_DIR}/DispmanxFrameGrabber.h
|
||||
)
|
||||
FILE ( GLOB DispmanxGrabberSOURCES "${CURRENT_HEADER_DIR}/Dispmanx*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
|
||||
|
||||
SET(DispmanxGrabberSOURCES
|
||||
${CURRENT_SOURCE_DIR}/DispmanxWrapper.cpp
|
||||
${CURRENT_SOURCE_DIR}/DispmanxFrameGrabber.cpp
|
||||
)
|
||||
|
||||
add_library(dispmanx-grabber
|
||||
${DispmanxGrabberHEADERS}
|
||||
${DispmanxGrabberSOURCES}
|
||||
)
|
||||
add_library(dispmanx-grabber ${DispmanxGrabberSOURCES} )
|
||||
|
||||
target_link_libraries(dispmanx-grabber
|
||||
hyperion
|
||||
|
@@ -6,20 +6,13 @@
|
||||
// Local includes
|
||||
#include "grabber/DispmanxFrameGrabber.h"
|
||||
|
||||
DispmanxFrameGrabber::DispmanxFrameGrabber(const unsigned width, const unsigned height) :
|
||||
_vc_display(0),
|
||||
_vc_resource(0),
|
||||
_vc_flags(0),
|
||||
_width(width),
|
||||
_height(height),
|
||||
_videoMode(VIDEO_2D),
|
||||
_cropLeft(0),
|
||||
_cropRight(0),
|
||||
_cropTop(0),
|
||||
_cropBottom(0),
|
||||
_captureBuffer(new ColorRgba[0]),
|
||||
_captureBufferSize(0),
|
||||
_log(Logger::getInstance("DISPMANXGRABBER"))
|
||||
DispmanxFrameGrabber::DispmanxFrameGrabber(const unsigned width, const unsigned height)
|
||||
: Grabber("DISPMANXGRABBER", width, height)
|
||||
, _vc_display(0)
|
||||
, _vc_resource(0)
|
||||
, _vc_flags(0)
|
||||
, _captureBuffer(new ColorRgba[0])
|
||||
, _captureBufferSize(0)
|
||||
{
|
||||
// Initiase BCM
|
||||
bcm_host_init();
|
||||
@@ -71,14 +64,9 @@ void DispmanxFrameGrabber::setFlags(const int vc_flags)
|
||||
_vc_flags = vc_flags;
|
||||
}
|
||||
|
||||
void DispmanxFrameGrabber::setVideoMode(const VideoMode videoMode)
|
||||
{
|
||||
_videoMode = videoMode;
|
||||
}
|
||||
|
||||
void DispmanxFrameGrabber::setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom)
|
||||
{
|
||||
if (cropLeft + cropRight >= _width || cropTop + cropBottom >= _height)
|
||||
if (cropLeft + cropRight >= (unsigned)_width || cropTop + cropBottom >= (unsigned)_height)
|
||||
{
|
||||
Error(_log, "Rejecting invalid crop values: left: %d, right: %d, top: %d, bottom: %d", cropLeft, cropRight, cropTop, cropBottom);
|
||||
return;
|
||||
|
@@ -1,26 +1,10 @@
|
||||
|
||||
# Find the BCM-package (VC control)
|
||||
# find_package(BCM REQUIRED)
|
||||
# include_directories(${BCM_INCLUDE_DIRS})
|
||||
|
||||
# Define the current source locations
|
||||
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/framebuffer)
|
||||
|
||||
SET(FramebufferGrabberHEADERS
|
||||
${CURRENT_HEADER_DIR}/FramebufferFrameGrabber.h
|
||||
${CURRENT_HEADER_DIR}/FramebufferWrapper.h
|
||||
)
|
||||
FILE ( GLOB FramebufferGrabberSOURCES "${CURRENT_HEADER_DIR}/Framebuffer*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
|
||||
|
||||
SET(FramebufferGrabberSOURCES
|
||||
${CURRENT_SOURCE_DIR}/FramebufferWrapper.cpp
|
||||
${CURRENT_SOURCE_DIR}/FramebufferFrameGrabber.cpp
|
||||
)
|
||||
|
||||
add_library(framebuffer-grabber
|
||||
${FramebufferGrabberHEADERS}
|
||||
${FramebufferGrabberSOURCES}
|
||||
)
|
||||
add_library(framebuffer-grabber ${FramebufferGrabberSOURCES} )
|
||||
|
||||
target_link_libraries(framebuffer-grabber
|
||||
hyperion
|
||||
|
@@ -12,14 +12,11 @@
|
||||
// Local includes
|
||||
#include <grabber/FramebufferFrameGrabber.h>
|
||||
|
||||
FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height) :
|
||||
_fbfd(0),
|
||||
_fbp(0),
|
||||
_fbDevice(device),
|
||||
_width(width),
|
||||
_height(height),
|
||||
_imgResampler(new ImageResampler()),
|
||||
_log(Logger::getInstance("FRAMEBUFFERGRABBER"))
|
||||
FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height)
|
||||
: Grabber("FRAMEBUFFERGRABBER", width, height)
|
||||
, _fbfd(0)
|
||||
, _fbp(0)
|
||||
, _fbDevice(device)
|
||||
{
|
||||
int result;
|
||||
struct fb_var_screeninfo vinfo;
|
||||
@@ -48,12 +45,6 @@ FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const u
|
||||
|
||||
FramebufferFrameGrabber::~FramebufferFrameGrabber()
|
||||
{
|
||||
delete _imgResampler;
|
||||
}
|
||||
|
||||
void FramebufferFrameGrabber::setVideoMode(const VideoMode videoMode)
|
||||
{
|
||||
_imgResampler->set3D(videoMode);
|
||||
}
|
||||
|
||||
void FramebufferFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
@@ -93,9 +84,9 @@ void FramebufferFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
/* map the device to memory */
|
||||
_fbp = (unsigned char*)mmap(0, capSize, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, _fbfd, 0);
|
||||
|
||||
_imgResampler->setHorizontalPixelDecimation(vinfo.xres/_width);
|
||||
_imgResampler->setVerticalPixelDecimation(vinfo.yres/_height);
|
||||
_imgResampler->processImage(_fbp,
|
||||
_imageResampler.setHorizontalPixelDecimation(vinfo.xres/_width);
|
||||
_imageResampler.setVerticalPixelDecimation(vinfo.yres/_height);
|
||||
_imageResampler.processImage(_fbp,
|
||||
vinfo.xres,
|
||||
vinfo.yres,
|
||||
vinfo.xres * bytesPerPixel,
|
||||
|
@@ -2,20 +2,9 @@
|
||||
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/osx)
|
||||
|
||||
SET(OsxGrabberHEADERS
|
||||
${CURRENT_HEADER_DIR}/OsxWrapper.h
|
||||
${CURRENT_HEADER_DIR}/OsxFrameGrabber.h
|
||||
)
|
||||
FILE ( GLOB OsxGrabberSOURCES "${CURRENT_HEADER_DIR}/Osx*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
|
||||
|
||||
SET(OsxGrabberSOURCES
|
||||
${CURRENT_SOURCE_DIR}/OsxWrapper.cpp
|
||||
${CURRENT_SOURCE_DIR}/OsxFrameGrabber.cpp
|
||||
)
|
||||
|
||||
add_library(osx-grabber
|
||||
${OsxGrabberHEADERS}
|
||||
${OsxGrabberSOURCES}
|
||||
)
|
||||
add_library(osx-grabber ${OsxGrabberSOURCES} )
|
||||
|
||||
target_link_libraries(osx-grabber
|
||||
hyperion
|
||||
|
@@ -5,12 +5,9 @@
|
||||
// Local includes
|
||||
#include <grabber/OsxFrameGrabber.h>
|
||||
|
||||
OsxFrameGrabber::OsxFrameGrabber(const unsigned display, const unsigned width, const unsigned height) :
|
||||
_screenIndex(display),
|
||||
_width(width),
|
||||
_height(height),
|
||||
_imgResampler(new ImageResampler()),
|
||||
_log(Logger::getInstance("OSXGRABBER"))
|
||||
OsxFrameGrabber::OsxFrameGrabber(const unsigned display, const unsigned width, const unsigned height)
|
||||
: Grabber("OSXGRABBER", width, height)
|
||||
, _screenIndex(display)
|
||||
{
|
||||
CGImageRef image;
|
||||
CGDisplayCount displayCount;
|
||||
@@ -36,12 +33,6 @@ OsxFrameGrabber::OsxFrameGrabber(const unsigned display, const unsigned width, c
|
||||
|
||||
OsxFrameGrabber::~OsxFrameGrabber()
|
||||
{
|
||||
delete _imgResampler;
|
||||
}
|
||||
|
||||
void OsxFrameGrabber::setVideoMode(const VideoMode videoMode)
|
||||
{
|
||||
_imgResampler->set3D(videoMode);
|
||||
}
|
||||
|
||||
void OsxFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
@@ -53,7 +44,7 @@ void OsxFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
|
||||
dispImage = CGDisplayCreateImage(_display);
|
||||
|
||||
// dsiplay lost, use main
|
||||
// display lost, use main
|
||||
if (dispImage == NULL && _display)
|
||||
{
|
||||
dispImage = CGDisplayCreateImage(kCGDirectMainDisplay);
|
||||
@@ -69,9 +60,9 @@ void OsxFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
dspWidth = CGImageGetWidth(dispImage);
|
||||
dspHeight = CGImageGetHeight(dispImage);
|
||||
|
||||
_imgResampler->setHorizontalPixelDecimation(dspWidth/_width);
|
||||
_imgResampler->setVerticalPixelDecimation(dspHeight/_height);
|
||||
_imgResampler->processImage( pImgData,
|
||||
_imageResampler.setHorizontalPixelDecimation(dspWidth/_width);
|
||||
_imageResampler.setVerticalPixelDecimation(dspHeight/_height);
|
||||
_imageResampler.processImage( pImgData,
|
||||
dspWidth,
|
||||
dspHeight,
|
||||
CGImageGetBytesPerRow(dispImage),
|
||||
|
@@ -2,21 +2,9 @@
|
||||
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/v4l2)
|
||||
|
||||
SET(V4L2_HEADERS
|
||||
${CURRENT_HEADER_DIR}/V4L2Grabber.h
|
||||
${CURRENT_HEADER_DIR}/V4L2Wrapper.h
|
||||
${CURRENT_HEADER_DIR}/VideoStandard.h
|
||||
)
|
||||
FILE ( GLOB V4L2_SOURCES "${CURRENT_HEADER_DIR}/V4L2*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
|
||||
|
||||
SET(V4L2_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/V4L2Grabber.cpp
|
||||
${CURRENT_SOURCE_DIR}/V4L2Wrapper.cpp
|
||||
)
|
||||
|
||||
add_library(v4l2-grabber
|
||||
${V4L2_HEADERS}
|
||||
${V4L2_SOURCES}
|
||||
)
|
||||
add_library(v4l2-grabber ${V4L2_SOURCES} )
|
||||
|
||||
target_link_libraries(v4l2-grabber
|
||||
hyperion
|
||||
|
@@ -33,15 +33,14 @@ V4L2Grabber::V4L2Grabber(const QString & device
|
||||
, int horizontalPixelDecimation
|
||||
, int verticalPixelDecimation
|
||||
)
|
||||
: _deviceName(device)
|
||||
: Grabber("V4L2:"+device, width, height)
|
||||
, _deviceName(device)
|
||||
, _input(input)
|
||||
, _videoStandard(videoStandard)
|
||||
, _ioMethod(IO_METHOD_MMAP)
|
||||
, _fileDescriptor(-1)
|
||||
, _buffers()
|
||||
, _pixelFormat(pixelFormat)
|
||||
, _width(width)
|
||||
, _height(height)
|
||||
, _lineLength(-1)
|
||||
, _frameByteSize(-1)
|
||||
, _frameDecimation(qMax(1, frameDecimation))
|
||||
@@ -56,8 +55,6 @@ V4L2Grabber::V4L2Grabber(const QString & device
|
||||
, _y_frac_max(0.75)
|
||||
, _currentFrame(0)
|
||||
, _streamNotifier(nullptr)
|
||||
, _imageResampler()
|
||||
, _log(Logger::getInstance("V4L2:"+device))
|
||||
, _initialized(false)
|
||||
, _deviceAutoDiscoverEnabled(false)
|
||||
|
||||
@@ -188,11 +185,6 @@ void V4L2Grabber::setCropping(int cropLeft, int cropRight, int cropTop, int crop
|
||||
_imageResampler.setCropping(cropLeft, cropRight, cropTop, cropBottom);
|
||||
}
|
||||
|
||||
void V4L2Grabber::set3D(VideoMode mode)
|
||||
{
|
||||
_imageResampler.set3D(mode);
|
||||
}
|
||||
|
||||
void V4L2Grabber::setSignalThreshold(double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, int noSignalCounterThreshold)
|
||||
{
|
||||
_noSignalThresholdColor.red = uint8_t(255*redSignalThreshold);
|
||||
|
@@ -15,7 +15,8 @@ V4L2Wrapper::V4L2Wrapper(const QString &device,
|
||||
double redSignalThreshold,
|
||||
double greenSignalThreshold,
|
||||
double blueSignalThreshold,
|
||||
const int priority)
|
||||
const int priority,
|
||||
bool useGrabbingMode)
|
||||
: GrabberWrapper("V4L2:"+device, priority, hyperion::COMP_V4L)
|
||||
, _timeout_ms(1000)
|
||||
, _grabber(device,
|
||||
@@ -42,6 +43,10 @@ V4L2Wrapper::V4L2Wrapper(const QString &device,
|
||||
|
||||
QObject::connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection);
|
||||
|
||||
if (!useGrabbingMode)
|
||||
{
|
||||
disconnect(_hyperion, SIGNAL(grabbingMode(GrabbingMode)), this, 0);
|
||||
}
|
||||
// send color data to Hyperion using a queued connection to handle the data over to the main event loop
|
||||
// QObject::connect(
|
||||
// this, SIGNAL(emitColors(int,std::vector<ColorRgb>,int)),
|
||||
@@ -80,9 +85,9 @@ void V4L2Wrapper::setSignalDetectionOffset(double verticalMin, double horizontal
|
||||
}
|
||||
|
||||
|
||||
void V4L2Wrapper::set3D(VideoMode mode)
|
||||
void V4L2Wrapper::setVideoMode(VideoMode mode)
|
||||
{
|
||||
_grabber.set3D(mode);
|
||||
_grabber.setVideoMode(mode);
|
||||
}
|
||||
|
||||
void V4L2Wrapper::newFrame(const Image<ColorRgb> &image)
|
||||
|
@@ -5,27 +5,14 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/x11)
|
||||
# Find X11
|
||||
find_package(X11 REQUIRED)
|
||||
|
||||
include_directories(
|
||||
${X11_INCLUDES}
|
||||
)
|
||||
include_directories( ${X11_INCLUDES} )
|
||||
|
||||
SET(X11_HEADERS
|
||||
${CURRENT_HEADER_DIR}/X11Wrapper.h
|
||||
${CURRENT_HEADER_DIR}/X11Grabber.h
|
||||
)
|
||||
FILE ( GLOB X11_SOURCES "${CURRENT_HEADER_DIR}/X11*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
|
||||
|
||||
SET(X11_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/X11Grabber.cpp
|
||||
${CURRENT_SOURCE_DIR}/X11Wrapper.cpp
|
||||
)
|
||||
|
||||
add_library(x11-grabber
|
||||
${X11_HEADERS}
|
||||
${X11_SOURCES}
|
||||
)
|
||||
add_library(x11-grabber ${X11_SOURCES} )
|
||||
|
||||
target_link_libraries(x11-grabber
|
||||
hyperion
|
||||
${X11_LIBRARIES}
|
||||
${X11_Xrender_LIB}
|
||||
${X11_LIBRARIES}
|
||||
${X11_Xrender_LIB}
|
||||
)
|
||||
|
@@ -2,12 +2,8 @@
|
||||
#include <grabber/X11Grabber.h>
|
||||
|
||||
X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation)
|
||||
: _imageResampler()
|
||||
: Grabber("X11GRABBER", 0, 0, cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _useXGetImage(useXGetImage)
|
||||
, _cropLeft(cropLeft)
|
||||
, _cropRight(cropRight)
|
||||
, _cropTop(cropTop)
|
||||
, _cropBottom(cropBottom)
|
||||
, _x11Display(nullptr)
|
||||
, _pixmap(None)
|
||||
, _srcFormat(nullptr)
|
||||
@@ -18,10 +14,7 @@ X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropT
|
||||
, _verticalDecimation(verticalPixelDecimation)
|
||||
, _screenWidth(0)
|
||||
, _screenHeight(0)
|
||||
, _croppedWidth(0)
|
||||
, _croppedHeight(0)
|
||||
, _image(0,0)
|
||||
, _log(Logger::getInstance("X11GRABBER"))
|
||||
{
|
||||
_imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XRender, XShmGetImage or XGetImage
|
||||
memset(&_pictAttr, 0, sizeof(_pictAttr));
|
||||
@@ -37,11 +30,6 @@ X11Grabber::~X11Grabber()
|
||||
}
|
||||
}
|
||||
|
||||
void X11Grabber::setVideoMode(const VideoMode videoMode)
|
||||
{
|
||||
_imageResampler.set3D(videoMode);
|
||||
}
|
||||
|
||||
void X11Grabber::freeResources()
|
||||
{
|
||||
// Cleanup allocated resources of the X11 grab
|
||||
@@ -66,7 +54,7 @@ void X11Grabber::setupResources()
|
||||
{
|
||||
_xImage = XShmCreateImage(_x11Display, _windowAttr.visual,
|
||||
_windowAttr.depth, ZPixmap, NULL, &_shminfo,
|
||||
_croppedWidth, _croppedHeight);
|
||||
_width, _height);
|
||||
_shminfo.shmid = shmget(IPC_PRIVATE, _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777);
|
||||
_xImage->data = (char*)shmat(_shminfo.shmid,0,0);
|
||||
_shminfo.shmaddr = _xImage->data;
|
||||
@@ -77,11 +65,11 @@ void X11Grabber::setupResources()
|
||||
{
|
||||
if(_XShmPixmapAvailable)
|
||||
{
|
||||
_pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _croppedWidth, _croppedHeight, _windowAttr.depth);
|
||||
_pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _width, _height, _windowAttr.depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pixmap = XCreatePixmap(_x11Display, _window, _croppedWidth, _croppedHeight, _windowAttr.depth);
|
||||
_pixmap = XCreatePixmap(_x11Display, _window, _width, _height, _windowAttr.depth);
|
||||
}
|
||||
_srcFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
|
||||
_dstFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
|
||||
@@ -168,8 +156,8 @@ Image<ColorRgb> & X11Grabber::grab()
|
||||
0, // mask_y
|
||||
0, // dst_x
|
||||
0, // dst_y
|
||||
_croppedWidth, // width
|
||||
_croppedHeight); // height
|
||||
_width, // width
|
||||
_height); // height
|
||||
|
||||
XSync(_x11Display, False);
|
||||
|
||||
@@ -179,7 +167,7 @@ Image<ColorRgb> & X11Grabber::grab()
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
|
||||
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _width, _height, AllPlanes, ZPixmap);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -189,7 +177,7 @@ Image<ColorRgb> & X11Grabber::grab()
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
|
||||
_xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _width, _height, AllPlanes, ZPixmap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,8 +234,8 @@ int X11Grabber::grabFrame(Image<ColorRgb> & image)
|
||||
0, // mask_y
|
||||
0, // dst_x
|
||||
0, // dst_y
|
||||
_croppedWidth, // width
|
||||
_croppedHeight); // height
|
||||
_width, // width
|
||||
_height); // height
|
||||
|
||||
XSync(_x11Display, False);
|
||||
|
||||
@@ -257,7 +245,7 @@ int X11Grabber::grabFrame(Image<ColorRgb> & image)
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
|
||||
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _width, _height, AllPlanes, ZPixmap);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -267,7 +255,7 @@ int X11Grabber::grabFrame(Image<ColorRgb> & image)
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
|
||||
_xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _width, _height, AllPlanes, ZPixmap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,11 +297,11 @@ int X11Grabber::updateScreenDimensions()
|
||||
// Image scaling is performed by XRender when available, otherwise by ImageResampler
|
||||
if (_XRenderAvailable && !_useXGetImage)
|
||||
{
|
||||
_croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
_width = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
? ((_screenWidth - _cropLeft - _cropRight) / _horizontalDecimation)
|
||||
: _screenWidth / _horizontalDecimation;
|
||||
|
||||
_croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
_height = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
? ((_screenHeight - _cropTop - _cropBottom) / _verticalDecimation)
|
||||
: _screenHeight / _verticalDecimation;
|
||||
|
||||
@@ -321,18 +309,18 @@ int X11Grabber::updateScreenDimensions()
|
||||
}
|
||||
else
|
||||
{
|
||||
_croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
_width = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
? (_screenWidth - _cropLeft - _cropRight)
|
||||
: _screenWidth;
|
||||
|
||||
_croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
_height = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
? (_screenHeight - _cropTop - _cropBottom)
|
||||
: _screenHeight;
|
||||
|
||||
Info(_log, "Using XGetImage for grabbing");
|
||||
}
|
||||
|
||||
_image.resize(_croppedWidth, _croppedHeight);
|
||||
_image.resize(_width, _height);
|
||||
setupResources();
|
||||
|
||||
return 1;
|
||||
|
@@ -1,3 +1,4 @@
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
|
Reference in New Issue
Block a user