From 8f2592af9c3e3c331446e490d090cdc13732b9d0 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sun, 1 Aug 2021 15:17:05 +0200 Subject: [PATCH] add lua screenshot; possible parameters: osd and video=[false|true] and name=picname in /tmp dir Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b2dfb7e0ab86f039585bb05ec710ea9865ac2d2d Author: Jacek Jendrzej Date: 2021-08-01 (Sun, 01 Aug 2021) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/lua/lua_api_version.h | 2 +- src/gui/lua/lua_video.cpp | 34 ++++++++++++++++++++++++++++++++++ src/gui/lua/lua_video.h | 4 +++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/gui/lua/lua_api_version.h b/src/gui/lua/lua_api_version.h index 746b9d31c..481614a99 100644 --- a/src/gui/lua/lua_api_version.h +++ b/src/gui/lua/lua_api_version.h @@ -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 diff --git a/src/gui/lua/lua_video.cpp b/src/gui/lua/lua_video.cpp index dfd2de27d..bdf7414e8 100644 --- a/src/gui/lua/lua_video.cpp +++ b/src/gui/lua/lua_video.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #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 diff --git a/src/gui/lua/lua_video.h b/src/gui/lua/lua_video.h index 4cfe08e03..55d94da12 100644 --- a/src/gui/lua/lua_video.h +++ b/src/gui/lua/lua_video.h @@ -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); };