mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 17:31:11 +02:00
screenshot: allow screenshots using external utility; most code is taken from TangoCash
Origin commit data
------------------
Commit: 8a7faf424e
Author: vanhofen <vanhofen@gmx.de>
Date: 2019-12-26 (Thu, 26 Dec 2019)
Origin message was:
------------------
- screenshot: allow screenshots using external utility; most code is taken from TangoCash
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#include <hardware/video.h>
|
||||
#include <cs_api.h>
|
||||
#include <driver/screenshot.h>
|
||||
#include <system/helpers.h>
|
||||
#include <system/set_threadname.h>
|
||||
|
||||
extern "C" {
|
||||
@@ -59,26 +60,81 @@ CScreenShot::CScreenShot(const std::string fname, screenshot_format_t fmt)
|
||||
{
|
||||
format = fmt;
|
||||
filename = fname;
|
||||
pixel_data = NULL;
|
||||
fd = NULL;
|
||||
xres = 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;
|
||||
scs_thread = 0;
|
||||
pthread_mutex_init(&thread_mutex, NULL);
|
||||
pthread_mutex_init(&getData_mutex, NULL);
|
||||
get_video = g_settings.screenshot_video;
|
||||
get_osd = g_settings.screenshot_mode;
|
||||
scale_to_video = g_settings.screenshot_scale;
|
||||
#endif // SCREENSHOT_INTERNAL
|
||||
}
|
||||
|
||||
CScreenShot::~CScreenShot()
|
||||
{
|
||||
#if SCREENSHOT_INTERNAL
|
||||
pthread_mutex_destroy(&thread_mutex);
|
||||
pthread_mutex_destroy(&getData_mutex);
|
||||
#endif // SCREENSHOT_INTERNAL
|
||||
// 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
|
||||
|
||||
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,
|
||||
* with added date and time including msecs and suffix for selected format
|
||||
|
@@ -23,6 +23,14 @@
|
||||
#ifndef __screenshot_h_
|
||||
#define __screenshot_h_
|
||||
|
||||
#ifdef SCREENSHOT
|
||||
#if BOXMODEL_VUPLUS
|
||||
#define SCREENSHOT_EXTERNAL 1
|
||||
#else
|
||||
#define SCREENSHOT_INTERNAL 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
class CScreenShot
|
||||
@@ -37,13 +45,15 @@ class CScreenShot
|
||||
private:
|
||||
screenshot_format_t format;
|
||||
std::string filename;
|
||||
unsigned char * pixel_data;
|
||||
int xres;
|
||||
int yres;
|
||||
bool extra_osd;
|
||||
bool get_osd;
|
||||
bool get_video;
|
||||
bool scale_to_video;
|
||||
|
||||
#if SCREENSHOT_INTERNAL
|
||||
unsigned char * pixel_data;
|
||||
FILE *fd;
|
||||
pthread_t scs_thread;
|
||||
pthread_mutex_t thread_mutex;
|
||||
@@ -65,6 +75,7 @@ class CScreenShot
|
||||
#ifdef BOXMODEL_CS_HD2
|
||||
bool mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData);
|
||||
#endif
|
||||
#endif // SCREENSHOT_INTERNAL
|
||||
|
||||
public:
|
||||
CScreenShot(const std::string fname = "", screenshot_format_t fmt = CScreenShot::FORMAT_JPG);
|
||||
|
Reference in New Issue
Block a user