Skip to content

Commit

Permalink
add lua screenshot; possible parameters: osd and video=[false|true] a…
Browse files Browse the repository at this point in the history
…nd name=picname in /tmp dir
  • Loading branch information
satbaby committed Aug 1, 2021
1 parent f3edaf1 commit 391197a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/gui/lua/lua_api_version.h
Expand Up @@ -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
34 changes: 34 additions & 0 deletions src/gui/lua/lua_video.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }
};

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/gui/lua/lua_video.h
Expand Up @@ -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);
};

Expand Down

0 comments on commit 391197a

Please sign in to comment.