mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 15:02:50 +02:00
Merge branch 'master' into pu/fb-setmode
Conflicts:
src/driver/screenshot.h
src/driver/screenshot.cpp
acinclude.m4
Origin commit data
------------------
Branch: ni/coolstream
Commit: e83a255e95
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2017-03-17 (Fri, 17 Mar 2017)
Origin message was:
------------------
Merge branch 'master' into pu/fb-setmode
Conflicts:
src/driver/screenshot.h
src/driver/screenshot.cpp
acinclude.m4
------------------
This commit was generated by Migit
This commit is contained in:
@@ -29,11 +29,6 @@ if test "$enable_reschange" = "yes"; then
|
||||
AC_DEFINE(ENABLE_CHANGE_OSD_RESOLUTION,1,[enable change the osd resolution])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(tmsdk,
|
||||
AS_HELP_STRING(--enable-tmsdk, compile inside sdk),
|
||||
,[enable_tmsdk=no])
|
||||
AM_CONDITIONAL(ENABLE_TMSDK,test "$enable_tmsdk" = "yes")
|
||||
|
||||
AC_MSG_CHECKING(target)
|
||||
|
||||
if test "$TARGET" = "native"; then
|
||||
|
@@ -145,14 +145,12 @@ if BOXTYPE_COOL
|
||||
neutrino_LDADD += \
|
||||
$(top_builddir)/lib/hardware/coolstream/libhwcaps.a
|
||||
neutrino_LDADD += -lcoolstream-mt -lca-sc
|
||||
if ENABLE_TMSDK
|
||||
else
|
||||
|
||||
if BOXMODEL_CS_HD2
|
||||
neutrino_LDADD += -lca-ci -llnxtmvssUsr -llnxUKAL -llnxplatUsr -llnxtmasUsr -llnxdvbciUsr -llnxpvrUsr -llnxcssUsr -llnxnotifyqUsr -ltmpvrDataManager-cst -ltmpvrIndexStorage -llnxscsUsr
|
||||
else
|
||||
neutrino_LDADD += -lnxp
|
||||
endif
|
||||
endif
|
||||
|
||||
if BOXMODEL_CS_HD2
|
||||
neutrino_LDADD += -liconv
|
||||
@@ -166,5 +164,4 @@ bin_PROGRAMS += rcsim
|
||||
rcsim_SOURCES = rcsim.c rcsim.h
|
||||
bin_PROGRAMS += mdev_helper
|
||||
mdev_helper_SOURCES = mdev_helper.cpp
|
||||
|
||||
endif
|
||||
|
@@ -2,6 +2,7 @@
|
||||
Neutrino-GUI - DBoxII-Project
|
||||
|
||||
Copyright (C) 2011 CoolStream International Ltd
|
||||
Copyright (C) 2017 M. Liebmann (micha-bbg)
|
||||
|
||||
parts based on AiO Screengrabber (C) Seddi seddi@ihad.tv
|
||||
|
||||
@@ -62,6 +63,9 @@ CScreenShot::CScreenShot(const std::string fname, screenshot_format_t fmt)
|
||||
xres = 0;
|
||||
yres = 0;
|
||||
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;
|
||||
@@ -69,6 +73,9 @@ CScreenShot::CScreenShot(const std::string fname, screenshot_format_t fmt)
|
||||
|
||||
CScreenShot::~CScreenShot()
|
||||
{
|
||||
pthread_mutex_destroy(&thread_mutex);
|
||||
pthread_mutex_destroy(&getData_mutex);
|
||||
// printf("[CScreenShot::%s:%d] thread: %p\n", __func__, __LINE__, this);
|
||||
}
|
||||
|
||||
#ifdef BOXMODEL_CS_HD2
|
||||
@@ -122,19 +129,17 @@ bool CScreenShot::GetData()
|
||||
extra_osd = true;
|
||||
screenBuf = new fb_pixel_t[_xres*_yres*sizeof(fb_pixel_t)];
|
||||
if (screenBuf == NULL) {
|
||||
printf("[%s:%s:%d] memory error\n", __path_file__, __func__, __LINE__);
|
||||
printf("[CScreenShot::%s:%d] memory error\n", __func__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
printf("\n[%s:%s:%d] Read osd screen...", __path_file__, __func__, __LINE__);
|
||||
printf("\n[CScreenShot::%s:%d] Read osd screen...", __func__, __LINE__);
|
||||
frameBuffer->SaveScreen(0, 0, _xres, _yres, screenBuf);
|
||||
printf(" done.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static OpenThreads::Mutex mutex;
|
||||
bool res = false;
|
||||
|
||||
mutex.lock();
|
||||
pthread_mutex_lock(&getData_mutex);
|
||||
|
||||
#ifdef BOXMODEL_CS_HD1
|
||||
CFrameBuffer::getInstance()->setActive(false);
|
||||
@@ -147,7 +152,8 @@ bool CScreenShot::GetData()
|
||||
uint32_t memSize = xres * yres * sizeof(fb_pixel_t) * 2;
|
||||
pixel_data = (uint8_t*)cs_malloc_uncached(memSize);
|
||||
if (pixel_data == NULL) {
|
||||
printf("[%s:%s:%d] memory error\n", __path_file__, __func__, __LINE__);
|
||||
printf("[CScreenShot::%s:%d] memory error\n", __func__, __LINE__);
|
||||
pthread_mutex_unlock(&getData_mutex);
|
||||
return false;
|
||||
}
|
||||
memset(pixel_data, 0, memSize);
|
||||
@@ -166,56 +172,92 @@ bool CScreenShot::GetData()
|
||||
CFrameBuffer::getInstance()->add_gxa_sync_marker();
|
||||
CFrameBuffer::getInstance()->setActive(true);
|
||||
#endif
|
||||
mutex.unlock();
|
||||
pthread_mutex_unlock(&getData_mutex);
|
||||
if (!res) {
|
||||
printf("CScreenShot::Start: GetScreenImage failed\n");
|
||||
printf("[CScreenShot::%s:%d] GetScreenImage failed\n", __func__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef BOXMODEL_CS_HD2
|
||||
if (extra_osd && screenBuf) {
|
||||
printf("[%s:%s:%d] Merge osd screen to screenshot...", __path_file__, __func__, __LINE__);
|
||||
printf("[CScreenShot::%s:%d] Merge osd screen to screenshot...", __func__, __LINE__);
|
||||
mergeOsdScreen(_xres, _yres, screenBuf);
|
||||
delete[] screenBuf;
|
||||
printf(" done.\n \n");
|
||||
}
|
||||
#endif
|
||||
printf("CScreenShot::GetData: data: %p %d x %d\n", pixel_data, xres, yres);
|
||||
printf("[CScreenShot::%s:%d] data: %p %d x %d\n", __func__, __LINE__, pixel_data, xres, yres);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CScreenShot::startThread()
|
||||
{
|
||||
if (!scs_thread) {
|
||||
void *ptr = static_cast<void*>(this);
|
||||
int res = pthread_create(&scs_thread, NULL, initThread, ptr);
|
||||
if (res != 0) {
|
||||
printf("[CScreenShot::%s:%d] ERROR! pthread_create\n", __func__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
pthread_detach(scs_thread);
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void* CScreenShot::initThread(void *arg)
|
||||
{
|
||||
CScreenShot *scs = static_cast<CScreenShot*>(arg);
|
||||
pthread_cleanup_push(cleanupThread, scs);
|
||||
// printf("[CScreenShot::%s:%d] thread: %p\n", __func__, __LINE__, scs);
|
||||
|
||||
scs->runThread();
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
|
||||
pthread_exit(0);
|
||||
|
||||
pthread_cleanup_pop(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* thread function to save data asynchroniosly. delete itself after saving */
|
||||
void CScreenShot::runThread()
|
||||
{
|
||||
pthread_mutex_lock(&thread_mutex);
|
||||
printf("[CScreenShot::%s:%d] save to %s format %d\n", __func__, __LINE__, filename.c_str(), format);
|
||||
|
||||
bool ret = SaveFile();
|
||||
|
||||
printf("[CScreenShot::%s:%d] %s finished: %d\n", __func__, __LINE__, filename.c_str(), ret);
|
||||
pthread_mutex_unlock(&thread_mutex);
|
||||
}
|
||||
|
||||
void CScreenShot::cleanupThread(void *arg)
|
||||
{
|
||||
CScreenShot *scs = static_cast<CScreenShot*>(arg);
|
||||
// printf("[CScreenShot::%s:%d] thread: %p\n", __func__, __LINE__, scs);
|
||||
delete scs;
|
||||
}
|
||||
|
||||
/* start ::run in new thread to save file in selected format */
|
||||
bool CScreenShot::Start()
|
||||
{
|
||||
bool ret = false;
|
||||
if(GetData())
|
||||
ret = (start() == 0);
|
||||
if (GetData())
|
||||
ret = startThread();
|
||||
else
|
||||
delete this;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* thread function to save data asynchroniosly. delete itself after saving */
|
||||
void CScreenShot::run()
|
||||
{
|
||||
printf("CScreenShot::run save to %s format %d\n", filename.c_str(), format);
|
||||
detach();
|
||||
setCancelModeDisable();
|
||||
setSchedulePriority(THREAD_PRIORITY_MIN);
|
||||
bool ret = SaveFile();
|
||||
printf("CScreenShot::run: %s finished: %d\n", filename.c_str(), ret);
|
||||
delete this;
|
||||
}
|
||||
|
||||
/* save file in sync mode, return true if save ok, or false */
|
||||
bool CScreenShot::StartSync()
|
||||
{
|
||||
bool ret = false;
|
||||
printf("CScreenShot::StartSync save to %s format %d\n", filename.c_str(), format);
|
||||
if(GetData())
|
||||
printf("[CScreenShot::%s:%d] save to %s format %d\n", __func__, __LINE__, filename.c_str(), format);
|
||||
if (GetData())
|
||||
ret = SaveFile();
|
||||
|
||||
printf("CScreenShot::StartSync: %s finished: %d\n", filename.c_str(), ret);
|
||||
printf("[CScreenShot::%s:%d] %s finished: %d\n", __func__, __LINE__, filename.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -309,7 +351,7 @@ bool CScreenShot::SavePng()
|
||||
|
||||
free(row_pointers);
|
||||
fclose(fd);
|
||||
TIMER_STOP(filename.c_str());
|
||||
TIMER_STOP(("[CScreenShot::SavePng] " + filename).c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -349,7 +391,7 @@ bool CScreenShot::SaveJpg()
|
||||
int xres2 = xres1+2;
|
||||
for (int x = 0; x < xres; x++) {
|
||||
int x2 = x*3;
|
||||
memmove(pixel_data + x2 + xres1, pixel_data + x*4 + y*xres*4, 3);
|
||||
memcpy(pixel_data + x2 + xres1, pixel_data + x*4 + y*xres*4, 3);
|
||||
SWAP(pixel_data[x2 + xres1], pixel_data[x2 + xres2]);
|
||||
}
|
||||
}
|
||||
@@ -390,7 +432,7 @@ bool CScreenShot::SaveJpg()
|
||||
jpeg_finish_compress(&cinfo);
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
fclose(fd);
|
||||
TIMER_STOP(filename.c_str());
|
||||
TIMER_STOP(("[CScreenShot::SaveJpg] " + filename).c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -423,7 +465,7 @@ bool CScreenShot::SaveBmp()
|
||||
fwrite(pixel_data+(y*xres*4),xres*4,1,fd);
|
||||
}
|
||||
fclose(fd);
|
||||
TIMER_STOP(filename.c_str());
|
||||
TIMER_STOP(("[CScreenShot::SaveBmp] " + filename).c_str());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
Neutrino-GUI - DBoxII-Project
|
||||
|
||||
Copyright (C) 2011 CoolStream International Ltd
|
||||
Copyright (C) 2017 M. Liebmann (micha-bbg)
|
||||
|
||||
License: GPLv2
|
||||
|
||||
@@ -22,9 +23,9 @@
|
||||
#ifndef __screenshot_h_
|
||||
#define __screenshot_h_
|
||||
|
||||
#include <OpenThreads/Thread>
|
||||
#include <pthread.h>
|
||||
|
||||
class CScreenShot : public OpenThreads::Thread
|
||||
class CScreenShot
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
@@ -44,6 +45,9 @@ class CScreenShot : public OpenThreads::Thread
|
||||
bool get_video;
|
||||
bool scale_to_video;
|
||||
FILE *fd;
|
||||
pthread_t scs_thread;
|
||||
pthread_mutex_t thread_mutex;
|
||||
pthread_mutex_t getData_mutex;
|
||||
|
||||
bool GetData();
|
||||
bool OpenFile();
|
||||
@@ -52,7 +56,12 @@ class CScreenShot : public OpenThreads::Thread
|
||||
bool SavePng();
|
||||
bool SaveJpg();
|
||||
bool SaveBmp();
|
||||
void run();
|
||||
|
||||
bool startThread();
|
||||
static void* initThread(void *arg);
|
||||
void runThread();
|
||||
static void cleanupThread(void *arg);
|
||||
|
||||
#ifdef BOXMODEL_CS_HD2
|
||||
bool mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user