mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
CLuaInstVideo: Add script function 'setInfoFunc()'...
...for displaying information in the movieplayer - Set Lua api version to 1.36
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <system/debug.h>
|
#include <system/debug.h>
|
||||||
#include <gui/movieplayer.h>
|
#include <gui/movieplayer.h>
|
||||||
|
#include <gui/widget/messagebox.h>
|
||||||
#include <zapit/zapit.h>
|
#include <zapit/zapit.h>
|
||||||
#include <video.h>
|
#include <video.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
@@ -58,6 +59,7 @@ void CLuaInstVideo::LuaVideoRegister(lua_State *L)
|
|||||||
{ "ShowPicture", CLuaInstVideo::ShowPicture },
|
{ "ShowPicture", CLuaInstVideo::ShowPicture },
|
||||||
{ "StopPicture", CLuaInstVideo::StopPicture },
|
{ "StopPicture", CLuaInstVideo::StopPicture },
|
||||||
{ "PlayFile", CLuaInstVideo::PlayFile },
|
{ "PlayFile", CLuaInstVideo::PlayFile },
|
||||||
|
{ "setInfoFunc", CLuaInstVideo::setInfoFunc },
|
||||||
{ "zapitStopPlayBack", CLuaInstVideo::zapitStopPlayBack },
|
{ "zapitStopPlayBack", CLuaInstVideo::zapitStopPlayBack },
|
||||||
{ "channelRezap", CLuaInstVideo::channelRezap },
|
{ "channelRezap", CLuaInstVideo::channelRezap },
|
||||||
{ "createChannelIDfromUrl", CLuaInstVideo::createChannelIDfromUrl },
|
{ "createChannelIDfromUrl", CLuaInstVideo::createChannelIDfromUrl },
|
||||||
@@ -170,13 +172,56 @@ int CLuaInstVideo::PlayFile(lua_State *L)
|
|||||||
std::string si1(info1);
|
std::string si1(info1);
|
||||||
std::string si2(info2);
|
std::string si2(info2);
|
||||||
std::string sf(fname);
|
std::string sf(fname);
|
||||||
|
if (D != NULL && !D->infoFunc.empty())
|
||||||
|
CMoviePlayerGui::getInstance().setLuaInfoFunc(L, true);
|
||||||
CMoviePlayerGui::getInstance().SetFile(st, sf, si1, si2);
|
CMoviePlayerGui::getInstance().SetFile(st, sf, si1, si2);
|
||||||
CMoviePlayerGui::getInstance().exec(NULL, "http_lua");
|
CMoviePlayerGui::getInstance().exec(NULL, "http_lua");
|
||||||
|
CMoviePlayerGui::getInstance().setLuaInfoFunc(L, false);
|
||||||
int ret = CMoviePlayerGui::getInstance().getKeyPressed();
|
int ret = CMoviePlayerGui::getInstance().getKeyPressed();
|
||||||
lua_pushinteger(L, ret);
|
lua_pushinteger(L, ret);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CLuaInstVideo::setInfoFunc(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
D->infoFunc = luaL_checkstring(L, 2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CLuaInstVideo::execLuaInfoFunc(lua_State *L, int xres, int yres, int aspectRatio, int framerate)
|
||||||
|
{
|
||||||
|
CLuaVideo *D = VideoCheckData(L, 1);
|
||||||
|
if (!D) return false;
|
||||||
|
|
||||||
|
lua_getglobal(L, D->infoFunc.c_str());
|
||||||
|
lua_pushinteger(L, (lua_Integer)xres);
|
||||||
|
lua_pushinteger(L, (lua_Integer)yres);
|
||||||
|
lua_pushinteger(L, (lua_Integer)aspectRatio);
|
||||||
|
lua_pushinteger(L, (lua_Integer)framerate);
|
||||||
|
int status = lua_pcall(L, 4, 0, 0);
|
||||||
|
if (status) {
|
||||||
|
char msg[1024];
|
||||||
|
lua_Debug ar;
|
||||||
|
lua_getstack(L, 1, &ar);
|
||||||
|
lua_getinfo(L, "Sl", &ar);
|
||||||
|
memset(msg, '\0', sizeof(msg));
|
||||||
|
snprintf(msg, sizeof(msg)-1, "[%s:%d] error running function '%s': %s", ar.short_src, ar.currentline, D->infoFunc.c_str(), lua_tostring(L, -1));
|
||||||
|
fprintf(stderr, "[CLuaInstVideo::%s:%d] %s\n", __func__, __LINE__, msg);
|
||||||
|
DisplayErrorMessage(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int CLuaInstVideo::zapitStopPlayBack(lua_State *L)
|
int CLuaInstVideo::zapitStopPlayBack(lua_State *L)
|
||||||
{
|
{
|
||||||
/* workaround for deprecated functions */
|
/* workaround for deprecated functions */
|
||||||
|
@@ -24,7 +24,8 @@ class CLuaVideo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool singlePlay;
|
bool singlePlay;
|
||||||
CLuaVideo() { singlePlay=false; };
|
std::string infoFunc;
|
||||||
|
CLuaVideo() { singlePlay=false; infoFunc=""; };
|
||||||
~CLuaVideo() {};
|
~CLuaVideo() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ class CLuaInstVideo
|
|||||||
static CLuaInstVideo* getInstance();
|
static CLuaInstVideo* getInstance();
|
||||||
static void LuaVideoRegister(lua_State *L);
|
static void LuaVideoRegister(lua_State *L);
|
||||||
static int channelRezap(lua_State *L);
|
static int channelRezap(lua_State *L);
|
||||||
|
static bool execLuaInfoFunc(lua_State *L, int xres, int yres, int aspectRatio, int framerate);
|
||||||
|
|
||||||
/* deprecated functions */
|
/* deprecated functions */
|
||||||
static int setBlank_old(lua_State *L);
|
static int setBlank_old(lua_State *L);
|
||||||
@@ -53,6 +55,7 @@ class CLuaInstVideo
|
|||||||
static int ShowPicture(lua_State *L);
|
static int ShowPicture(lua_State *L);
|
||||||
static int StopPicture(lua_State *L);
|
static int StopPicture(lua_State *L);
|
||||||
static int PlayFile(lua_State *L);
|
static int PlayFile(lua_State *L);
|
||||||
|
static int setInfoFunc(lua_State *L);
|
||||||
static int zapitStopPlayBack(lua_State *L);
|
static int zapitStopPlayBack(lua_State *L);
|
||||||
static int createChannelIDfromUrl(lua_State *L);
|
static int createChannelIDfromUrl(lua_State *L);
|
||||||
static int getNeutrinoMode(lua_State *L);
|
static int getNeutrinoMode(lua_State *L);
|
||||||
|
@@ -32,7 +32,7 @@ extern "C" {
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define LUA_API_VERSION_MAJOR 1
|
#define LUA_API_VERSION_MAJOR 1
|
||||||
#define LUA_API_VERSION_MINOR 35
|
#define LUA_API_VERSION_MINOR 36
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void LuaInstRegisterFunctions(lua_State *L, bool fromThreads=false);
|
void LuaInstRegisterFunctions(lua_State *L, bool fromThreads=false);
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
#include <gui/plugins.h>
|
#include <gui/plugins.h>
|
||||||
#include <gui/videosettings.h>
|
#include <gui/videosettings.h>
|
||||||
#include <gui/streaminfo2.h>
|
#include <gui/streaminfo2.h>
|
||||||
|
#include <gui/lua/lua_video.h>
|
||||||
#include <gui/screensaver.h>
|
#include <gui/screensaver.h>
|
||||||
#include <driver/screenshot.h>
|
#include <driver/screenshot.h>
|
||||||
#include <driver/volume.h>
|
#include <driver/volume.h>
|
||||||
@@ -190,6 +191,7 @@ void CMoviePlayerGui::Init(void)
|
|||||||
filelist_it = filelist.end();
|
filelist_it = filelist.end();
|
||||||
keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL;
|
keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL;
|
||||||
isLuaPlay = false;
|
isLuaPlay = false;
|
||||||
|
haveLuaInfoFunc = false;
|
||||||
blockedFromPlugin = false;
|
blockedFromPlugin = false;
|
||||||
m_screensaver = false;
|
m_screensaver = false;
|
||||||
m_idletime = time(NULL);
|
m_idletime = time(NULL);
|
||||||
@@ -309,6 +311,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey)
|
|||||||
isLuaPlay = true;
|
isLuaPlay = true;
|
||||||
is_file_player = true;
|
is_file_player = true;
|
||||||
PlayFile();
|
PlayFile();
|
||||||
|
haveLuaInfoFunc = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
@@ -1725,14 +1728,25 @@ void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int /*position*/)
|
|||||||
cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */
|
cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (msg == NeutrinoMessages::SHOW_EPG && p_movie_info) {
|
} else if (msg == NeutrinoMessages::SHOW_EPG && (p_movie_info || (isLuaPlay && haveLuaInfoFunc))) {
|
||||||
CTimeOSD::mode m_mode = FileTime.getMode();
|
CTimeOSD::mode m_mode = FileTime.getMode();
|
||||||
bool restore = FileTime.IsVisible();
|
bool restore = FileTime.IsVisible();
|
||||||
if (restore)
|
if (restore)
|
||||||
FileTime.kill();
|
FileTime.kill();
|
||||||
InfoClock->enableInfoClock(false);
|
InfoClock->enableInfoClock(false);
|
||||||
|
|
||||||
cMovieInfo.showMovieInfo(*p_movie_info);
|
if (isLuaPlay && haveLuaInfoFunc) {
|
||||||
|
int xres = 0, yres = 0, aspectRatio = 0, framerate = -1;
|
||||||
|
if (!videoDecoder->getBlank()) {
|
||||||
|
videoDecoder->getPictureInfo(xres, yres, framerate);
|
||||||
|
if (yres == 1088)
|
||||||
|
yres = 1080;
|
||||||
|
aspectRatio = videoDecoder->getAspectRatio();
|
||||||
|
}
|
||||||
|
CLuaInstVideo::getInstance()->execLuaInfoFunc(luaState, xres, yres, aspectRatio, framerate);
|
||||||
|
}
|
||||||
|
else if (p_movie_info)
|
||||||
|
cMovieInfo.showMovieInfo(*p_movie_info);
|
||||||
|
|
||||||
InfoClock->enableInfoClock(true);
|
InfoClock->enableInfoClock(true);
|
||||||
if (restore) {
|
if (restore) {
|
||||||
|
@@ -53,6 +53,12 @@
|
|||||||
#include <OpenThreads/Thread>
|
#include <OpenThreads/Thread>
|
||||||
#include <OpenThreads/Condition>
|
#include <OpenThreads/Condition>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
#include <lualib.h>
|
||||||
|
}
|
||||||
|
|
||||||
class CMoviePlayerGui : public CMenuTarget
|
class CMoviePlayerGui : public CMenuTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -91,6 +97,8 @@ class CMoviePlayerGui : public CMenuTarget
|
|||||||
CMoviePlayerGui::state playstate;
|
CMoviePlayerGui::state playstate;
|
||||||
int keyPressed;
|
int keyPressed;
|
||||||
bool isLuaPlay;
|
bool isLuaPlay;
|
||||||
|
bool haveLuaInfoFunc;
|
||||||
|
lua_State* luaState;
|
||||||
bool blockedFromPlugin;
|
bool blockedFromPlugin;
|
||||||
int speed;
|
int speed;
|
||||||
int startposition;
|
int startposition;
|
||||||
@@ -230,6 +238,7 @@ class CMoviePlayerGui : public CMenuTarget
|
|||||||
void restoreNeutrino();
|
void restoreNeutrino();
|
||||||
void setBlockedFromPlugin(bool b) { blockedFromPlugin = b; };
|
void setBlockedFromPlugin(bool b) { blockedFromPlugin = b; };
|
||||||
bool getBlockedFromPlugin() { return blockedFromPlugin; };
|
bool getBlockedFromPlugin() { return blockedFromPlugin; };
|
||||||
|
void setLuaInfoFunc(lua_State* L, bool func) { luaState = L; haveLuaInfoFunc = func; };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user