mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-01 09:51:22 +02:00
- screenshot: allow screenshots using external utility; most code is taken from TangoCash
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
#include <hardware/video.h>
|
#include <hardware/video.h>
|
||||||
#include <cs_api.h>
|
#include <cs_api.h>
|
||||||
#include <driver/screenshot.h>
|
#include <driver/screenshot.h>
|
||||||
|
#include <system/helpers.h>
|
||||||
#include <system/set_threadname.h>
|
#include <system/set_threadname.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -59,26 +60,81 @@ CScreenShot::CScreenShot(const std::string fname, screenshot_format_t fmt)
|
|||||||
{
|
{
|
||||||
format = fmt;
|
format = fmt;
|
||||||
filename = fname;
|
filename = fname;
|
||||||
pixel_data = NULL;
|
|
||||||
fd = NULL;
|
|
||||||
xres = 0;
|
xres = 0;
|
||||||
yres = 0;
|
yres = 0;
|
||||||
|
get_video = g_settings.screenshot_video;
|
||||||
|
get_osd = g_settings.screenshot_mode;
|
||||||
|
scale_to_video = g_settings.screenshot_scale;
|
||||||
|
#if SCREENSHOT_INTERNAL
|
||||||
|
pixel_data = NULL;
|
||||||
|
fd = NULL;
|
||||||
extra_osd = false;
|
extra_osd = false;
|
||||||
scs_thread = 0;
|
scs_thread = 0;
|
||||||
pthread_mutex_init(&thread_mutex, NULL);
|
pthread_mutex_init(&thread_mutex, NULL);
|
||||||
pthread_mutex_init(&getData_mutex, NULL);
|
pthread_mutex_init(&getData_mutex, NULL);
|
||||||
get_video = g_settings.screenshot_video;
|
#endif // SCREENSHOT_INTERNAL
|
||||||
get_osd = g_settings.screenshot_mode;
|
|
||||||
scale_to_video = g_settings.screenshot_scale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CScreenShot::~CScreenShot()
|
CScreenShot::~CScreenShot()
|
||||||
{
|
{
|
||||||
|
#if SCREENSHOT_INTERNAL
|
||||||
pthread_mutex_destroy(&thread_mutex);
|
pthread_mutex_destroy(&thread_mutex);
|
||||||
pthread_mutex_destroy(&getData_mutex);
|
pthread_mutex_destroy(&getData_mutex);
|
||||||
|
#endif // SCREENSHOT_INTERNAL
|
||||||
// printf("[CScreenShot::%s:%d] thread: %p\n", __func__, __LINE__, this);
|
// printf("[CScreenShot::%s:%d] thread: %p\n", __func__, __LINE__, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SCREENSHOT_EXTERNAL
|
||||||
|
bool CScreenShot::Start()
|
||||||
|
{
|
||||||
|
std::string cmd = find_executable("grab");
|
||||||
|
|
||||||
|
if (cmd.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
cmd += " ";
|
||||||
|
|
||||||
|
if (get_osd && !get_video)
|
||||||
|
cmd += "-o ";
|
||||||
|
else if (!get_osd && get_video)
|
||||||
|
cmd += "-v ";
|
||||||
|
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case FORMAT_PNG:
|
||||||
|
cmd += "-p ";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* fall through */
|
||||||
|
case FORMAT_JPG:
|
||||||
|
cmd += "-j 100 ";
|
||||||
|
break;
|
||||||
|
case FORMAT_BMP:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!scale_to_video)
|
||||||
|
cmd += "-d ";
|
||||||
|
|
||||||
|
if (xres)
|
||||||
|
cmd += "-w " + to_string(xres) + " ";
|
||||||
|
|
||||||
|
cmd += "'";
|
||||||
|
cmd += filename;
|
||||||
|
cmd += "'";
|
||||||
|
|
||||||
|
printf("[CScreenShot::%s:%d] Running %s\n", __func__, __LINE__, cmd.c_str());
|
||||||
|
system(cmd.c_str());
|
||||||
|
|
||||||
|
return (access(filename.c_str(), F_OK) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CScreenShot::StartSync()
|
||||||
|
{
|
||||||
|
return Start();
|
||||||
|
}
|
||||||
|
#else // SCREENSHOT_INTERNAL
|
||||||
|
|
||||||
#ifdef BOXMODEL_CS_HD2
|
#ifdef BOXMODEL_CS_HD2
|
||||||
|
|
||||||
bool CScreenShot::mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData)
|
bool CScreenShot::mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData)
|
||||||
@@ -468,6 +524,8 @@ bool CScreenShot::SaveBmp()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // SCREENSHOT_INTERNAL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create filename member from channel name and its current EPG data,
|
* create filename member from channel name and its current EPG data,
|
||||||
* with added date and time including msecs and suffix for selected format
|
* with added date and time including msecs and suffix for selected format
|
||||||
|
@@ -23,6 +23,14 @@
|
|||||||
#ifndef __screenshot_h_
|
#ifndef __screenshot_h_
|
||||||
#define __screenshot_h_
|
#define __screenshot_h_
|
||||||
|
|
||||||
|
#ifdef SCREENSHOT
|
||||||
|
#if BOXMODEL_VUPLUS
|
||||||
|
#define SCREENSHOT_EXTERNAL 1
|
||||||
|
#else
|
||||||
|
#define SCREENSHOT_INTERNAL 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
class CScreenShot
|
class CScreenShot
|
||||||
@@ -37,13 +45,15 @@ class CScreenShot
|
|||||||
private:
|
private:
|
||||||
screenshot_format_t format;
|
screenshot_format_t format;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
unsigned char * pixel_data;
|
|
||||||
int xres;
|
int xres;
|
||||||
int yres;
|
int yres;
|
||||||
bool extra_osd;
|
bool extra_osd;
|
||||||
bool get_osd;
|
bool get_osd;
|
||||||
bool get_video;
|
bool get_video;
|
||||||
bool scale_to_video;
|
bool scale_to_video;
|
||||||
|
|
||||||
|
#if SCREENSHOT_INTERNAL
|
||||||
|
unsigned char * pixel_data;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
pthread_t scs_thread;
|
pthread_t scs_thread;
|
||||||
pthread_mutex_t thread_mutex;
|
pthread_mutex_t thread_mutex;
|
||||||
@@ -65,6 +75,7 @@ class CScreenShot
|
|||||||
#ifdef BOXMODEL_CS_HD2
|
#ifdef BOXMODEL_CS_HD2
|
||||||
bool mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData);
|
bool mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData);
|
||||||
#endif
|
#endif
|
||||||
|
#endif // SCREENSHOT_INTERNAL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CScreenShot(const std::string fname = "", screenshot_format_t fmt = CScreenShot::FORMAT_JPG);
|
CScreenShot(const std::string fname = "", screenshot_format_t fmt = CScreenShot::FORMAT_JPG);
|
||||||
|
Reference in New Issue
Block a user