Refactor/Create APT/DNF Repository (#1648)

This commit is contained in:
Paulchen-Panther
2023-11-16 21:05:56 +01:00
committed by GitHub
parent c9518db597
commit 91270966f9
165 changed files with 1918 additions and 2924 deletions

View File

@@ -1,39 +1,39 @@
if (ENABLE_AMLOGIC)
if(ENABLE_AMLOGIC)
add_subdirectory(amlogic)
endif (ENABLE_AMLOGIC)
if (ENABLE_DISPMANX)
if(ENABLE_DISPMANX)
add_subdirectory(dispmanx)
endif (ENABLE_DISPMANX)
if (ENABLE_FB)
if(ENABLE_FB)
add_subdirectory(framebuffer)
endif (ENABLE_FB)
if (ENABLE_OSX)
if(ENABLE_OSX)
add_subdirectory(osx)
endif(ENABLE_OSX)
if (ENABLE_V4L2 OR ENABLE_MF)
if(ENABLE_V4L2 OR ENABLE_MF)
add_subdirectory(video)
endif ()
endif()
if (ENABLE_X11)
if(ENABLE_X11)
add_subdirectory(x11)
endif(ENABLE_X11)
if (ENABLE_XCB)
if(ENABLE_XCB)
add_subdirectory(xcb)
endif(ENABLE_XCB)
if (ENABLE_QT)
if(ENABLE_QT)
add_subdirectory(qt)
endif(ENABLE_QT)
if (ENABLE_DX)
if(ENABLE_DX)
add_subdirectory(directx)
endif(ENABLE_DX)
if (ENABLE_AUDIO)
if(ENABLE_AUDIO)
add_subdirectory(audio)
endif()

View File

@@ -20,7 +20,7 @@
// Local includes
#include <utils/Logger.h>
#include <grabber/AmlogicGrabber.h>
#include <grabber/amlogic/AmlogicGrabber.h>
#include "Amvideocap.h"
// Constants

View File

@@ -1,4 +1,4 @@
#include <grabber/AmlogicWrapper.h>
#include <grabber/amlogic/AmlogicWrapper.h>
AmlogicWrapper::AmlogicWrapper(int pixelDecimation, int updateRate_Hz)
: GrabberWrapper("Amlogic", &_grabber, updateRate_Hz)

View File

@@ -1,13 +1,15 @@
INCLUDE (CheckIncludeFiles)
# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic)
FILE ( GLOB AmlogicSOURCES "${CURRENT_HEADER_DIR}/Amlogic*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library(amlogic-grabber ${AmlogicSOURCES} )
add_library(amlogic-grabber
${CMAKE_SOURCE_DIR}/include/grabber/amlogic/AmlogicGrabber.h
${CMAKE_SOURCE_DIR}/include/grabber/amlogic/AmlogicWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic/AmlogicGrabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic/AmlogicWrapper.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic/Amvideocap.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic/ion.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic/meson_ion.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic/IonBuffer.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic/IonBuffer.cpp
)
target_link_libraries(amlogic-grabber
hyperion
${QT_LIBRARIES})
)

View File

@@ -1,4 +1,4 @@
#include <grabber/AudioGrabber.h>
#include <grabber/audio/AudioGrabber.h>
#include <math.h>
#include <QImage>
#include <QObject>

View File

@@ -1,11 +1,31 @@
#include <grabber/AudioGrabberLinux.h>
#include <grabber/audio/AudioGrabberLinux.h>
#include <alsa/asoundlib.h>
#include <QJsonObject>
#include <QJsonArray>
typedef void* (*THREADFUNCPTR)(void*);
static void * AudioThreadRunner(void* params)
{
AudioGrabberLinux* This = static_cast<AudioGrabberLinux*>(params);
Debug(This->getLog(), "Audio Thread Started");
snd_pcm_sframes_t framesAvailable = 0;
while (This->_isRunning.load(std::memory_order_acquire))
{
snd_pcm_wait(This->_captureDevice, 1000);
if ((framesAvailable = snd_pcm_avail(This->_captureDevice)) > 0)
This->processAudioBuffer(framesAvailable);
sched_yield();
}
Debug(This->getLog(), "Audio Thread Shutting Down");
return nullptr;
}
AudioGrabberLinux::AudioGrabberLinux()
: AudioGrabber()
@@ -121,7 +141,7 @@ bool AudioGrabberLinux::configureCaptureInterface()
snd_pcm_close(_captureDevice);
return false;
}
if ((error = snd_pcm_hw_params_set_access(_captureDevice, _captureDeviceConfig, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
{
Error(_log, "Failed to configure interleaved mode: %s", snd_strerror(error));
@@ -129,7 +149,7 @@ bool AudioGrabberLinux::configureCaptureInterface()
snd_pcm_close(_captureDevice);
return false;
}
if ((error = snd_pcm_hw_params_set_format(_captureDevice, _captureDeviceConfig, SND_PCM_FORMAT_S16_LE)) < 0)
{
Error(_log, "Failed to configure capture format: %s", snd_strerror(error));
@@ -169,7 +189,7 @@ bool AudioGrabberLinux::configureCaptureInterface()
snd_pcm_close(_captureDevice);
return false;
}
return true;
}
@@ -189,11 +209,6 @@ bool AudioGrabberLinux::start()
_isRunning.store(true, std::memory_order_release);
pthread_attr_t threadAttributes;
int threadPriority = 1;
sched_param schedulerParameter;
schedulerParameter.sched_priority = threadPriority;
if (pthread_attr_init(&threadAttributes) != 0)
{
Debug(_log, "Failed to create thread attributes");
@@ -201,7 +216,7 @@ bool AudioGrabberLinux::start()
return false;
}
if (pthread_create(&_audioThread, &threadAttributes, static_cast<THREADFUNCPTR>(&AudioThreadRunner), static_cast<void*>(this)) != 0)
if (pthread_create(&_audioThread, &threadAttributes, &AudioThreadRunner, static_cast<void*>(this)) != 0)
{
Debug(_log, "Failed to create audio capture thread");
stop();
@@ -239,7 +254,7 @@ void AudioGrabberLinux::processAudioBuffer(snd_pcm_sframes_t frames)
ssize_t bytes = snd_pcm_frames_to_bytes(_captureDevice, frames);
int16_t * buffer = static_cast<int16_t*>(calloc(static_cast<size_t>(bytes / 2), sizeof(int16_t)));
if (frames == 0)
{
buffer[0] = 0;
@@ -293,25 +308,3 @@ QString AudioGrabberLinux::getDeviceName(const QString& devicePath) const
return _deviceProperties.value(devicePath).name;
}
static void * AudioThreadRunner(void* params)
{
AudioGrabberLinux* This = static_cast<AudioGrabberLinux*>(params);
Debug(This->getLog(), "Audio Thread Started");
snd_pcm_sframes_t framesAvailable = 0;
while (This->_isRunning.load(std::memory_order_acquire))
{
snd_pcm_wait(This->_captureDevice, 1000);
if ((framesAvailable = snd_pcm_avail(This->_captureDevice)) > 0)
This->processAudioBuffer(framesAvailable);
sched_yield();
}
Debug(This->getLog(), "Audio Thread Shutting Down");
return nullptr;
}

View File

@@ -1,4 +1,4 @@
#include <grabber/AudioGrabberWindows.h>
#include <grabber/audio/AudioGrabberWindows.h>
#include <climits>
@@ -71,7 +71,7 @@ bool AudioGrabberWindows::configureCaptureInterface()
notificationSize -= notificationSize % audioFormat.nBlockAlign;
bufferCaptureSize = notificationSize * AUDIO_NOTIFICATION_COUNT;
DSCBUFFERDESC bufferDesc;
bufferDesc.dwSize = sizeof(DSCBUFFERDESC);
bufferDesc.dwFlags = 0;
@@ -80,7 +80,7 @@ bool AudioGrabberWindows::configureCaptureInterface()
bufferDesc.lpwfxFormat = &audioFormat;
bufferDesc.dwFXCount = 0;
bufferDesc.lpDSCFXDesc = NULL;
// Create Capture Device's Buffer
LPDIRECTSOUNDCAPTUREBUFFER preBuffer;
if (FAILED(recordingDevice->CreateCaptureBuffer(&bufferDesc, &preBuffer, NULL)))
@@ -101,7 +101,7 @@ bool AudioGrabberWindows::configureCaptureInterface()
}
preBuffer->Release();
// Create Notifications
LPDIRECTSOUNDNOTIFY8 notify;
@@ -112,7 +112,7 @@ bool AudioGrabberWindows::configureCaptureInterface()
recordingBuffer->Release();
return false;
}
// Create Events
notificationEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
@@ -133,11 +133,11 @@ bool AudioGrabberWindows::configureCaptureInterface()
positionNotify[i].dwOffset = (notificationSize * i) + notificationSize - 1;
positionNotify[i].hEventNotify = notificationEvent;
}
// Set Notifications
notify->SetNotificationPositions(AUDIO_NOTIFICATION_COUNT, positionNotify);
notify->Release();
return true;
}
@@ -162,12 +162,12 @@ bool AudioGrabberWindows::start()
}
Info(_log, "Capture audio from %s", QSTRING_CSTR(getDeviceName(_device)));
if (!this->configureCaptureInterface())
{
return false;
}
if (FAILED(recordingBuffer->Start(DSCBSTART_LOOPING)))
{
Error(_log, "Failed starting audio capture from '%s'", QSTRING_CSTR(getDeviceName(_device)));
@@ -214,7 +214,7 @@ void AudioGrabberWindows::stop()
{
Error(_log, "Audio capture failed to stop: '%s'", QSTRING_CSTR(getDeviceName(_device)));
}
if (FAILED(recordingBuffer->Release()))
{
Error(_log, "Failed to release recording buffer: '%s'", QSTRING_CSTR(getDeviceName(_device)));
@@ -306,7 +306,7 @@ void AudioGrabberWindows::processAudioBuffer()
// Buffer wrapped around, read second position
if (capturedAudio2 != NULL)
{
{
bufferCapturePosition += capturedAudio2Length;
bufferCapturePosition %= bufferCaptureSize; // Circular Buffer
}
@@ -318,13 +318,13 @@ void AudioGrabberWindows::processAudioBuffer()
{
CopyMemory(readBuffer + capturedAudioLength, capturedAudio2, capturedAudio2Length);
}
// Release Buffer Lock
recordingBuffer->Unlock(capturedAudio, capturedAudioLength, capturedAudio2, capturedAudio2Length);
// Process Audio Frame
this->processAudioFrame(readBuffer, frameSize);
delete[] readBuffer;
}

View File

@@ -1,4 +1,4 @@
#include <grabber/AudioWrapper.h>
#include <grabber/audio/AudioWrapper.h>
#include <hyperion/GrabberWrapper.h>
#include <QObject>
#include <QMetaType>

View File

@@ -1,35 +1,38 @@
# Define the current source locations
SET( CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber )
SET( CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/audio )
if (WIN32)
add_definitions(-DUNICODE -D_UNICODE)
FILE ( GLOB AUDIO_GRABBER_SOURCES "${CURRENT_HEADER_DIR}/Audio*Windows.h" "${CURRENT_HEADER_DIR}/AudioGrabber.h" "${CURRENT_HEADER_DIR}/AudioWrapper.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*Windows.cpp" "${CURRENT_SOURCE_DIR}/AudioGrabber.cpp" "${CURRENT_SOURCE_DIR}/AudioWrapper.cpp")
elseif(${CMAKE_SYSTEM} MATCHES "Linux")
FILE ( GLOB AUDIO_GRABBER_SOURCES "${CURRENT_HEADER_DIR}/Audio*Linux.h" "${CURRENT_HEADER_DIR}/AudioGrabber.h" "${CURRENT_HEADER_DIR}/AudioWrapper.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*Linux.cpp" "${CURRENT_SOURCE_DIR}/AudioGrabber.cpp" "${CURRENT_SOURCE_DIR}/AudioWrapper.cpp")
elseif (APPLE)
#TODO
#FILE ( GLOB AUDIO_GRABBER_SOURCES "${CURRENT_HEADER_DIR}/Audio*Apple.h" "${CURRENT_HEADER_DIR}/AudioGrabber.h" "${CURRENT_HEADER_DIR}/AudioWrapper.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*Apple.cpp" "${CURRENT_SOURCE_DIR}/AudioGrabber.cpp" "${CURRENT_SOURCE_DIR}/AudioWrapper.cpp")
if(WIN32)
add_definitions(-DUNICODE -D_UNICODE)
set(AUDIO_GRABBER_SOURCES
${CMAKE_SOURCE_DIR}/include/grabber/audio/AudioGrabberWindows.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/audio/AudioGrabberWindows.cpp
)
elseif(CMAKE_HOST_UNIX AND NOT APPLE)
set(AUDIO_GRABBER_SOURCES
${CMAKE_SOURCE_DIR}/include/grabber/audio/AudioGrabberLinux.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/audio/AudioGrabberLinux.cpp
)
endif()
add_library( audio-grabber ${AUDIO_GRABBER_SOURCES} )
add_library(audio-grabber
${CMAKE_SOURCE_DIR}/include/grabber/audio/AudioGrabber.h
${CMAKE_SOURCE_DIR}/include/grabber/audio/AudioWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/audio/AudioGrabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/audio/AudioWrapper.cpp
${AUDIO_GRABBER_SOURCES}
)
set(AUDIO_LIBS hyperion)
if (WIN32)
set(AUDIO_LIBS ${AUDIO_LIBS} DSound)
elseif(${CMAKE_SYSTEM} MATCHES "Linux")
find_package(ALSA REQUIRED)
if (ALSA_FOUND)
include_directories(${ALSA_INCLUDE_DIRS})
set(AUDIO_LIBS ${AUDIO_LIBS} ${ALSA_LIBRARIES})
endif(ALSA_FOUND)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(AUDIO_LIBS ${AUDIO_LIBS} Threads::Threads) # PRIVATE
if(WIN32)
set(AUDIO_LIBS DSound)
elseif(CMAKE_HOST_UNIX AND NOT APPLE)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(ALSA REQUIRED)
find_package(Threads REQUIRED)
set(AUDIO_LIBS ${ALSA_LIBRARIES} Threads::Threads)
endif()
target_link_libraries(audio-grabber
hyperion
${AUDIO_LIBS}
)
target_link_libraries(audio-grabber ${AUDIO_LIBS} ${QT_LIBRARIES})
if(CMAKE_HOST_UNIX AND NOT APPLE)
target_include_directories(audio-grabber PUBLIC ${ALSA_INCLUDE_DIRS})
endif()

View File

@@ -1,14 +1,17 @@
# Define the current source locations
SET( CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber )
SET( CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/directx )
find_package(DirectX9 REQUIRED)
include_directories(${DIRECTX9_INCLUDE_DIRS})
FILE ( GLOB DIRECTX_GRAB_SOURCES "${CURRENT_HEADER_DIR}/DirectX*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library( directx-grabber ${DIRECTX_GRAB_SOURCES} )
add_library(directx-grabber
${CMAKE_SOURCE_DIR}/include/grabber/directx/DirectXGrabber.h
${CMAKE_SOURCE_DIR}/include/grabber/directx/DirectXWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/directx/DirectXGrabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/directx/DirectXWrapper.cpp
)
target_link_libraries(directx-grabber
hyperion
${DIRECTX9_LIBRARIES}
hyperion
${DIRECTX9_LIBRARIES}
)
target_include_directories(directx-grabber PUBLIC
${DIRECTX9_INCLUDE_DIRS}
)

View File

@@ -1,5 +1,5 @@
#include <windows.h>
#include <grabber/DirectXGrabber.h>
#include <grabber/directx/DirectXGrabber.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib,"d3dx9.lib")

View File

@@ -1,4 +1,4 @@
#include <grabber/DirectXWrapper.h>
#include <grabber/directx/DirectXWrapper.h>
DirectXWrapper::DirectXWrapper( int updateRate_Hz,
int display,

View File

@@ -1,5 +1,5 @@
# Find the BCM-package (VC control)
if( "${PLATFORM}" MATCHES rpi)
if("${PLATFORM}" MATCHES rpi)
find_package(BCM)
if(BCM_FOUND)
add_definitions(-DBCM_FOUND)
@@ -9,21 +9,20 @@ else()
set(BCM_LIBRARY "")
endif()
# Define the current source locations
set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/dispmanx)
add_library(dispmanx-grabber
${CMAKE_SOURCE_DIR}/include/grabber/dispmanx/DispmanxFrameGrabber.h
${CMAKE_SOURCE_DIR}/include/grabber/dispmanx/DispmanxWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/dispmanx/DispmanxWrapper.cpp
)
FILE ( GLOB DispmanxGrabberSOURCES "${CURRENT_HEADER_DIR}/Dispmanx*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library(dispmanx-grabber ${DispmanxGrabberSOURCES})
add_definitions(-DBCM_LIBRARY="${BCM_LIBRARY}")
target_link_libraries(dispmanx-grabber
hyperion
${CMAKE_DL_LIBS}
)
target_include_directories(dispmanx-grabber PUBLIC
${BCM_INCLUDE_DIR}
)
target_link_libraries(dispmanx-grabber
hyperion
${QT_LIBRARIES}
${CMAKE_DL_LIBS}
)

View File

@@ -16,7 +16,7 @@ namespace {
} //End of constants
// Local includes
#include "grabber/DispmanxFrameGrabber.h"
#include "grabber/dispmanx/DispmanxFrameGrabber.h"
DispmanxFrameGrabber::DispmanxFrameGrabber()
: Grabber("DISPMANXGRABBER")

View File

@@ -1,4 +1,4 @@
#include <grabber/DispmanxWrapper.h>
#include <grabber/dispmanx/DispmanxWrapper.h>
DispmanxWrapper::DispmanxWrapper( int updateRate_Hz,
int pixelDecimation

View File

@@ -1,11 +1,10 @@
# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/framebuffer)
FILE ( GLOB FramebufferGrabberSOURCES "${CURRENT_HEADER_DIR}/Framebuffer*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library(framebuffer-grabber ${FramebufferGrabberSOURCES} )
add_library(framebuffer-grabber
${CMAKE_SOURCE_DIR}/include/grabber/framebuffer/FramebufferFrameGrabber.h
${CMAKE_SOURCE_DIR}/include/grabber/framebuffer/FramebufferWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/framebuffer/FramebufferWrapper.cpp
)
target_link_libraries(framebuffer-grabber
hyperion
${QT_LIBRARIES})
)

View File

@@ -28,7 +28,7 @@ const char DISCOVERY_FILEPATTERN[] = "fb?";
} //End of constants
// Local includes
#include <grabber/FramebufferFrameGrabber.h>
#include <grabber/framebuffer/FramebufferFrameGrabber.h>
FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device)
: Grabber("FRAMEBUFFERGRABBER")

View File

@@ -1,4 +1,4 @@
#include <grabber/FramebufferWrapper.h>
#include <grabber/framebuffer/FramebufferWrapper.h>
FramebufferWrapper::FramebufferWrapper( int updateRate_Hz,
const QString & device,

View File

@@ -1,11 +1,10 @@
# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/osx)
FILE ( GLOB OsxGrabberSOURCES "${CURRENT_HEADER_DIR}/Osx*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library(osx-grabber ${OsxGrabberSOURCES} )
add_library(osx-grabber
${CMAKE_SOURCE_DIR}/include/grabber/osx/OsxFrameGrabber.h
${CMAKE_SOURCE_DIR}/include/grabber/osx/OsxWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/osx/OsxFrameGrabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/osx/OsxWrapper.cpp
)
target_link_libraries(osx-grabber
hyperion
${QT_LIBRARIES})
)

View File

@@ -3,7 +3,7 @@
#include <iostream>
// Local includes
#include <grabber/OsxFrameGrabber.h>
#include <grabber/osx/OsxFrameGrabber.h>
//Qt
#include <QJsonObject>

View File

@@ -1,159 +0,0 @@
#ifndef __APPLE__
#include <grabber/OsxFrameGrabberMock.h>
unsigned __osx_frame_counter = 0;
const int __screenWidth = 800;
const int __screenHeight = 600;
CGError CGGetActiveDisplayList(uint32_t maxDisplays, CGDirectDisplayID *activeDisplays, uint32_t *displayCount)
{
if (maxDisplays == 0 || activeDisplays == nullptr)
{
*displayCount = 2;
}
else
{
displayCount = &maxDisplays;
if (activeDisplays != nullptr)
{
for (CGDirectDisplayID i = 0; i < maxDisplays; ++i)
{
activeDisplays[i] = i;
}
}
else
{
return kCGErrorFailure;
}
}
return kCGErrorSuccess;
}
CGImageRef CGDisplayCreateImage(CGDirectDisplayID display)
{
CGImageRef image = new CGImage(__screenWidth / (display+1), __screenHeight / (display+1));
return image;
}
void CGImageRelease(CGImageRef image)
{
delete image;
}
CGImageRef CGImageGetDataProvider(CGImageRef image)
{
__osx_frame_counter++;
if (__osx_frame_counter > 100)
{
__osx_frame_counter = 0;
}
ColorRgb color[4] = {ColorRgb::RED, ColorRgb::BLUE, ColorRgb::GREEN, ColorRgb::WHITE};
if (__osx_frame_counter < 25)
{
color[0] = ColorRgb::WHITE;
color[1] = ColorRgb::RED;
color[2] = ColorRgb::BLUE;
color[3] = ColorRgb::GREEN;
}
else if(__osx_frame_counter < 50)
{
color[1] = ColorRgb::WHITE;
color[2] = ColorRgb::RED;
color[3] = ColorRgb::BLUE;
color[0] = ColorRgb::GREEN;
}
else if(__osx_frame_counter < 75)
{
color[2] = ColorRgb::WHITE;
color[3] = ColorRgb::RED;
color[0] = ColorRgb::BLUE;
color[1] = ColorRgb::GREEN;
}
unsigned w = image->width();
unsigned h = image->height();
for (unsigned y=0; y<h; y++)
{
for (unsigned x=0; x<w; x++)
{
unsigned id = 0;
if (x < w/2 && y < h/2) id = 1;
if (x < w/2 && y >= h/2) id = 2;
if (x >= w/2 && y < h/2) id = 3;
image->memptr()[y*w + x] = color[id];
}
}
return image;
}
CFDataRef CGDataProviderCopyData(CGImageRef image)
{
const unsigned indexMax = image->width() * image->height() * CGImageGetBitsPerPixel(image);
CFDataRef data = new CFData[indexMax];
int lineLength = CGImageGetBytesPerRow(image);
for (unsigned y=0; y<image->height(); y++)
{
for (unsigned x=0; x<image->width(); x++)
{
int index = lineLength * y + x * CGImageGetBitsPerPixel(image);
data[index ] = (*image)(x,y).blue;
data[index+1] = (*image)(x,y).green;
data[index+2] = (*image)(x,y).red;
data[index+3] = 0;
}
}
return data;
}
unsigned char* CFDataGetBytePtr(CFDataRef imgData)
{
return imgData;
}
unsigned CGImageGetWidth(CGImageRef image)
{
return image->width();
}
unsigned CGImageGetHeight(CGImageRef image)
{
return image->height();
}
unsigned CGImageGetBytesPerRow(CGImageRef image)
{
return image->width()*CGImageGetBitsPerPixel(image);
}
unsigned CGImageGetBitsPerPixel(CGImageRef)
{
return 4;
}
void CFRelease(CFDataRef imgData)
{
delete imgData;
}
CGDisplayModeRef CGDisplayCopyDisplayMode(CGDirectDisplayID display)
{
return nullptr;
}
CGRect CGDisplayBounds(CGDirectDisplayID display)
{
CGRect rect;
rect.size.width = __screenWidth / (display+1);
rect.size.height = __screenHeight / (display+1);
return rect;
}
void CGDisplayModeRelease(CGDisplayModeRef mode)
{
}
#endif

View File

@@ -1,4 +1,4 @@
#include <grabber/OsxWrapper.h>
#include <grabber/osx/OsxWrapper.h>
OsxWrapper::OsxWrapper( int updateRate_Hz,
int display,

View File

@@ -1,13 +1,10 @@
# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/qt)
FILE ( GLOB QT_GRAB_SOURCES "${CURRENT_HEADER_DIR}/Qt*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library(qt-grabber ${QT_GRAB_SOURCES} )
add_library(qt-grabber
${CMAKE_SOURCE_DIR}/include/grabber/qt/QtGrabber.h
${CMAKE_SOURCE_DIR}/include/grabber/qt/QtWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/qt/QtGrabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/qt/QtWrapper.cpp
)
target_link_libraries(qt-grabber
hyperion
${QT_LIBRARIES}
)

View File

@@ -1,5 +1,5 @@
// proj
#include <grabber/QtGrabber.h>
#include <grabber/qt/QtGrabber.h>
// qt
#include <QPixmap>
@@ -226,7 +226,7 @@ int QtGrabber::grabFrame(Image<ColorRgb>& image)
QPixmap originalPixmap = grabWindow(0, _src_x, _src_y, _src_x_max, _src_y_max);
#else
QPixmap originalPixmap = _screen->grabWindow(0, _src_x, _src_y, _src_x_max, _src_y_max);
#endif
#endif
if (originalPixmap.isNull())
{
rc = -1;

View File

@@ -1,4 +1,4 @@
#include <grabber/QtWrapper.h>
#include <grabber/qt/QtWrapper.h>
QtWrapper::QtWrapper( int updateRate_Hz,
int display,

View File

@@ -1,33 +1,38 @@
# Common cmake definition for external video grabber
# Add Turbo JPEG library
if (ENABLE_V4L2 OR ENABLE_MF)
find_package(TurboJPEG)
if (TURBOJPEG_FOUND)
add_definitions(-DHAVE_TURBO_JPEG)
message( STATUS "Using Turbo JPEG library: ${TurboJPEG_LIBRARY}")
include_directories(${TurboJPEG_INCLUDE_DIRS})
else ()
message( STATUS "Turbo JPEG library not found, MJPEG camera format won't work.")
endif ()
endif()
set(MF-grabber mediafoundation)
set(V4L2-grabber v4l2)
# Define the wrapper/header/source locations and collect them
SET(WRAPPER_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/video)
SET(HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
if (ENABLE_MF)
if(ENABLE_MF)
project(mf-grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/video/mediafoundation)
FILE (GLOB SOURCES "${WRAPPER_DIR}/*.cpp" "${HEADER_DIR}/Video*.h" "${HEADER_DIR}/MF*.h" "${HEADER_DIR}/Encoder*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp")
set(grabber_project MF)
set(MediaFoundationSourceReaderCallBack ${CMAKE_SOURCE_DIR}/libsrc/grabber/video/mediafoundation/MFSourceReaderCB.h)
elseif(ENABLE_V4L2)
project(v4l2-grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/video/v4l2)
FILE (GLOB SOURCES "${WRAPPER_DIR}/*.cpp" "${HEADER_DIR}/Video*.h" "${HEADER_DIR}/V4L2*.h" "${HEADER_DIR}/Encoder*.h" "${CURRENT_SOURCE_DIR}/*.cpp")
set(grabber_project V4L2)
endif()
add_library(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} hyperion ${QT_LIBRARIES})
add_library(${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/include/grabber/video/EncoderThread.h
${CMAKE_SOURCE_DIR}/include/grabber/video/VideoWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/video/EncoderThread.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/video/VideoWrapper.cpp
${CMAKE_SOURCE_DIR}/include/grabber/video/${${grabber_project}-grabber}/${grabber_project}Grabber.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/video/${${grabber_project}-grabber}/${grabber_project}Grabber.cpp
${MediaFoundationSourceReaderCallBack}
)
if(TURBOJPEG_FOUND)
target_link_libraries(${PROJECT_NAME} ${TurboJPEG_LIBRARY})
target_link_libraries(${PROJECT_NAME} hyperion)
# Add Turbo JPEG library
if(ENABLE_V4L2 OR ENABLE_MF)
find_package(TurboJPEG)
if(TURBOJPEG_FOUND)
add_definitions(-DHAVE_TURBO_JPEG)
message(STATUS "Using Turbo JPEG library: ${TurboJPEG_LIBRARY}")
target_link_libraries(${PROJECT_NAME} ${TurboJPEG_LIBRARY})
target_include_directories(${PROJECT_NAME} PUBLIC ${TurboJPEG_INCLUDE_DIRS})
else ()
message(STATUS "Turbo JPEG library not found, MJPEG camera format won't work.")
endif()
endif()

View File

@@ -1,4 +1,4 @@
#include "grabber/EncoderThread.h"
#include "grabber/video/EncoderThread.h"
#include <QDebug>

View File

@@ -1,6 +1,6 @@
#include <QMetaType>
#include <grabber/VideoWrapper.h>
#include <grabber/video/VideoWrapper.h>
// qt includes
#include <QTimer>

View File

@@ -1,5 +1,5 @@
#include "MFSourceReaderCB.h"
#include "grabber/MFGrabber.h"
#include "grabber/video/mediafoundation/MFGrabber.h"
// Constants
namespace { const bool verbose = false; }
@@ -537,7 +537,7 @@ void MFGrabber::process_image(const void *frameImageBuffer, int size)
Error(_log, "Frame too small: %d != %d", size, _frameByteSize);
else if (_threadManager != nullptr)
{
for (unsigned long i = 0; i < _threadManager->_threadCount; i++)
for (int i = 0; i < _threadManager->_threadCount; i++)
{
if (!_threadManager->_threads[i]->isBusy())
{

View File

@@ -19,7 +19,7 @@
#pragma comment (lib, "strmiids.lib")
#pragma comment (lib, "wmcodecdspuuid.lib")
#include <grabber/MFGrabber.h>
#include <grabber/video/mediafoundation/MFGrabber.h>
#define SAFE_RELEASE(x) if(x) { x->Release(); x = nullptr; }

View File

@@ -23,7 +23,7 @@
#include <QFileInfo>
#include <QSet>
#include "grabber/V4L2Grabber.h"
#include "grabber/video/v4l2/V4L2Grabber.h"
#define CLEAR(x) memset(&(x), 0, sizeof(x))

View File

@@ -1,24 +1,23 @@
# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/x11)
# Find X11
find_package(X11 REQUIRED)
include_directories( ${X11_INCLUDES} )
if(APPLE)
include_directories("/opt/X11/include")
endif(APPLE)
FILE ( GLOB X11_SOURCES "${CURRENT_HEADER_DIR}/X11*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library(x11-grabber ${X11_SOURCES} )
add_library(x11-grabber
${CMAKE_SOURCE_DIR}/include/grabber/x11/X11Grabber.h
${CMAKE_SOURCE_DIR}/include/grabber/x11/X11Wrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/x11/X11Grabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/x11/X11Wrapper.cpp
)
target_link_libraries(x11-grabber
hyperion
${X11_LIBRARIES}
${X11_Xrandr_LIB}
${X11_Xrender_LIB}
${QT_LIBRARIES}
)
if(APPLE)
list(APPEND X11_INCLUDES "/opt/X11/include")
endif()
target_include_directories(x11-grabber PUBLIC
${X11_INCLUDES}
)

View File

@@ -1,5 +1,5 @@
#include <utils/Logger.h>
#include <grabber/X11Grabber.h>
#include <grabber/x11/X11Grabber.h>
#include <xcb/randr.h>
#include <xcb/xcb_event.h>

View File

@@ -1,4 +1,4 @@
#include <grabber/X11Wrapper.h>
#include <grabber/x11/X11Wrapper.h>
X11Wrapper::X11Wrapper( int updateRate_Hz,
int pixelDecimation,

View File

@@ -1,23 +1,19 @@
# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/xcb)
find_package(XCB COMPONENTS SHM IMAGE RENDER RANDR REQUIRED)
include_directories(${XCB_INCLUDE_DIRS})
FILE (GLOB XCB_SOURCES "${CURRENT_HEADER_DIR}/Xcb*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library(xcb-grabber ${XCB_SOURCES})
add_library(xcb-grabber
${CMAKE_SOURCE_DIR}/include/grabber/xcb/XcbGrabber.h
${CMAKE_SOURCE_DIR}/include/grabber/xcb/XcbWrapper.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/xcb/XcbCommandExecutor.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/xcb/XcbCommands.h
${CMAKE_SOURCE_DIR}/libsrc/grabber/xcb/XcbGrabber.cpp
${CMAKE_SOURCE_DIR}/libsrc/grabber/xcb/XcbWrapper.cpp
)
target_link_libraries(xcb-grabber
hyperion
${XCB_LIBRARIES}
${QT_LIBRARIES}
)
if (NOT APPLE)
target_link_libraries(
xcb-grabber
)
endif()
target_include_directories(xcb-grabber PUBLIC
${XCB_INCLUDE_DIRS}
)

View File

@@ -1,5 +1,5 @@
#include <utils/Logger.h>
#include <grabber/XcbGrabber.h>
#include <grabber/xcb/XcbGrabber.h>
#include "XcbCommands.h"
#include "XcbCommandExecutor.h"

View File

@@ -1,4 +1,4 @@
#include <grabber/XcbWrapper.h>
#include <grabber/xcb/XcbWrapper.h>
XcbWrapper::XcbWrapper( int updateRate_Hz,
int pixelDecimation,