add lua screenshot; possible parameters: osd and video=[false|true] and name=picname in /tmp dir

Origin commit data
------------------
Branch: ni/coolstream
Commit: b2dfb7e0ab
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2021-08-01 (Sun, 01 Aug 2021)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Jacek Jendrzej
2021-08-01 15:17:05 +02:00
committed by vanhofen
parent 7524cae21e
commit 8f2592af9c
3 changed files with 38 additions and 2 deletions

View File

@@ -4,4 +4,4 @@
* to luainstance.h changes
*/
#define LUA_API_VERSION_MAJOR 1
#define LUA_API_VERSION_MINOR 91
#define LUA_API_VERSION_MINOR 92

View File

@@ -31,6 +31,7 @@
#include <zapit/zapit.h>
#include <hardware/video.h>
#include <neutrino.h>
#include <driver/screenshot.h>
#include "luainstance.h"
#include "lua_video.h"
@@ -70,6 +71,9 @@ void CLuaInstVideo::LuaVideoRegister(lua_State *L)
{ "getNeutrinoMode", CLuaInstVideo::getNeutrinoMode },
{ "setSinglePlay", CLuaInstVideo::setSinglePlay },
{ "__gc", CLuaInstVideo::VideoDelete },
#ifdef SCREENSHOT
{ "Screenshot", CLuaInstVideo::Screenshot },
#endif
{ NULL, NULL }
};
@@ -351,6 +355,36 @@ int CLuaInstVideo::VideoDelete(lua_State *L)
return 0;
}
#ifdef SCREENSHOT
int CLuaInstVideo::Screenshot(lua_State *L)
{
CLuaVideo *D = VideoCheckData(L, 1);
if (!D) return 0;
int numargs = lua_gettop(L);
if (numargs < 2) {
printf("CLuaInstVideo::%s: not enough arguments (%d, expected 1)\n", __func__, numargs-1);
return 0;
}
bool enableOSD = true;
bool enableVideo = true;
std::string filename = "screenshot";
tableLookup(L, "name", filename);
tableLookup(L, "osd", enableOSD);
tableLookup(L, "video", enableVideo);
CScreenShot * screenshot = new CScreenShot("/tmp/" + filename + ".png", (CScreenShot::screenshot_format_t)0 /*PNG*/);
if(screenshot){
screenshot->EnableOSD(enableOSD);
screenshot->EnableVideo(enableVideo);
if (!screenshot->StartSync()){
printf("CLuaInstVideo::%s: Error\n", __func__);
}
delete screenshot;
}
return 0;
}
#endif
/* --------------------------------------------------------------
deprecated functions

View File

@@ -65,7 +65,9 @@ class CLuaInstVideo
static int getNeutrinoMode(lua_State *L);
static int setSinglePlay(lua_State *L);
static int VideoDelete(lua_State *L);
#ifdef SCREENSHOT
static int Screenshot(lua_State *L);
#endif
static void videoFunctionDeprecated(lua_State *L, std::string oldFunc);
};