movieplayer arm: add option to play separate audio file

This commit is contained in:
Jacek Jendrzej
2019-11-03 18:42:05 +01:00
parent a603c5d8a4
commit fa951c883c
6 changed files with 39 additions and 15 deletions

View File

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

View File

@@ -182,6 +182,7 @@ int CLuaInstVideo::PlayFile(lua_State *L)
const char *info1 = "";
const char *info2 = "";
const char *fname;
const char *fname2 = "";
title = luaL_checkstring(L, 2);
fname = luaL_checkstring(L, 3);
@@ -189,14 +190,17 @@ int CLuaInstVideo::PlayFile(lua_State *L)
info1 = luaL_checkstring(L, 4);
if (numargs > 4)
info2 = luaL_checkstring(L, 5);
if (numargs > 5)
fname2 = luaL_checkstring(L, 6);
printf("CLuaInstVideo::%s: title %s file %s\n", __func__, title, fname);
std::string st(title);
std::string si1(info1);
std::string si2(info2);
std::string sf(fname);
std::string sf2(fname2);
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,sf2);
CMoviePlayerGui::getInstance().exec(NULL, "http_lua");
CMoviePlayerGui::getInstance().setLuaInfoFunc(L, false);
if (D != NULL && !D->infoFunc.empty())

View File

@@ -845,8 +845,11 @@ bool CMoviePlayerGui::StartWebtv(void)
clearSubtitle();
playback->Open(is_file_player ? PLAYMODE_FILE : PLAYMODE_TS);
#if HAVE_ARM_HARDWARE
bool res = playback->Start(file_name, cookie_header, second_file_name);//url with cookies and optional second audio file
#else
bool res = playback->Start((char *) file_name.c_str(), cookie_header);//url with cookies
#endif
if (res)
playback->SetSpeed(1);
if (!res) {
@@ -962,7 +965,7 @@ bool CMoviePlayerGui::luaGetUrl(const std::string &script, const std::string &fi
bool haveurl = false;
if ( !root.isObject() ) {
for (Json::Value::iterator it = root.begin(); it != root.end(); ++it) {
info.url=""; info.name=""; info.header=""; info.bandwidth = 1; info.resolution=""; info.res1 = 1;
info.url=""; info.url2=""; info.name=""; info.header=""; info.bandwidth = 1; info.resolution=""; info.res1 = 1;
tmp = "0";
Json::Value object_it = *it;
for (Json::Value::iterator iti = object_it.begin(); iti != object_it.end(); iti++) {
@@ -970,6 +973,9 @@ bool CMoviePlayerGui::luaGetUrl(const std::string &script, const std::string &fi
if (name=="url") {
info.url = (*iti).asString();
haveurl = true;
//url2 for separate audio file
} else if (name=="url2") {
info.url2 = (*iti).asString();
} else if (name=="name") {
info.name = (*iti).asString();
}
@@ -994,12 +1000,15 @@ bool CMoviePlayerGui::luaGetUrl(const std::string &script, const std::string &fi
}
if (root.isObject()) {
for (Json::Value::iterator it = root.begin(); it != root.end(); ++it) {
info.url=""; info.name=""; info.header=""; info.bandwidth = 1; info.resolution=""; info.res1 = 1;
info.url=""; info.url2=""; info.name=""; info.header=""; info.bandwidth = 1; info.resolution=""; info.res1 = 1;
tmp = "0";
std::string name = it.name();
if (name=="url") {
info.url = (*it).asString();
haveurl = true;
//url2 for separate audio file
} else if (name=="url2") {
info.url2 = (*it).asString();
} else if (name=="name") {
info.name = (*it).asString();
} else if (name=="header") {
@@ -1060,6 +1069,7 @@ bool CMoviePlayerGui::selectLivestream(std::vector<livestream_info_t> &streamLis
_info = &(streamList[i]);
if (_info->res1 == _res) {
info->url = _info->url;
info->url2 = _info->url2;
info->name = _info->name;
info->header = _info->header;
info->resolution = _info->resolution;
@@ -1091,7 +1101,7 @@ bool CMoviePlayerGui::selectLivestream(std::vector<livestream_info_t> &streamLis
return false;
}
bool CMoviePlayerGui::getLiveUrl(const std::string &url, const std::string &script, std::string &realUrl, std::string &_pretty_name, std::string &info1, std::string &info2, std::string &header)
bool CMoviePlayerGui::getLiveUrl(const std::string &url, const std::string &script, std::string &realUrl, std::string &_pretty_name, std::string &info1, std::string &info2, std::string &header, std::string &url2)
{
std::vector<livestream_info_t> liveStreamList;
livestream_info_t info;
@@ -1172,6 +1182,9 @@ bool CMoviePlayerGui::getLiveUrl(const std::string &url, const std::string &scri
if (!info.header.empty()) {
header = info.header;
}
if (!info.url2.empty()) {
url2 = info.url2;
}
#if 0
if (!info.resolution.empty())
@@ -1226,9 +1239,11 @@ bool CMoviePlayerGui::PlayBackgroundStart(const std::string &file, const std::st
}
std::string realUrl;
std::string Url2;
std::string _pretty_name = name;
cookie_header.clear();
if (!getLiveUrl(file, script, realUrl, _pretty_name, livestreamInfo1, livestreamInfo2, cookie_header)) {
second_file_name.clear();
if (!getLiveUrl(file, script, realUrl, _pretty_name, livestreamInfo1, livestreamInfo2, cookie_header,Url2)) {
return false;
}
@@ -1240,6 +1255,7 @@ bool CMoviePlayerGui::PlayBackgroundStart(const std::string &file, const std::st
instance_bg->is_file_player = true;
instance_bg->isHTTP = true;
instance_bg->file_name = realUrl;
instance_bg->second_file_name = Url2;
instance_bg->pretty_name = _pretty_name;
instance_bg->cookie_header = cookie_header;
@@ -1363,9 +1379,11 @@ bool CMoviePlayerGui::PlayFileStart(void)
if (is_audio_playing)
frameBuffer->showFrame("mp3.jpg");
#if HAVE_ARM_HARDWARE
bool res = playback->Start((char *) file_name.c_str(), vpid, vtype, currentapid, currentac3, duration,"",second_file_name);
#else
bool res = playback->Start((char *) file_name.c_str(), vpid, vtype, currentapid, currentac3, duration);
#endif
if (thrStartHint) {
showStartingHint = false;
pthread_join(thrStartHint, NULL);

View File

@@ -100,6 +100,7 @@ class CMoviePlayerGui : public CMenuTarget
typedef struct livestream_info_t
{
std::string url;
std::string url2;//separate audio file
std::string name;
std::string resolution;
std::string header;//cookie
@@ -115,6 +116,7 @@ class CMoviePlayerGui : public CMenuTarget
int m_ThisMode;
std::string file_name;
std::string second_file_name;//separate audio file for ARM BOX
std::string pretty_name;
std::string cookie_header;
std::string info_1, info_2;
@@ -261,7 +263,7 @@ class CMoviePlayerGui : public CMenuTarget
void deleteTimeshift() { timeshift_deletion = true; }
int file_prozent;
cPlayback *getPlayback() { return playback; }
void SetFile(std::string &name, std::string &file, std::string info1="", std::string info2="") { pretty_name = name; file_name = file; info_1 = info1; info_2 = info2; }
void SetFile(std::string &name, std::string &file, std::string info1="", std::string info2="", std::string file2="") { pretty_name = name; file_name = file; info_1 = info1; info_2 = info2; second_file_name = file2; }
bool PlayBackgroundStart(const std::string &file, const std::string &name, t_channel_id chan, const std::string &script="");
void stopPlayBack(void);
void stopTimeshift(void);
@@ -283,7 +285,7 @@ class CMoviePlayerGui : public CMenuTarget
bool getBlockedFromPlugin() { return blockedFromPlugin; };
void setLuaInfoFunc(lua_State* L, bool func) { luaState = L; haveLuaInfoFunc = func; };
void getLivestreamInfo(std::string *i1, std::string *i2) { *i1=livestreamInfo1; *i2=livestreamInfo2; };
bool getLiveUrl(const std::string &url, const std::string &script, std::string &realUrl, std::string &_pretty_name, std::string &info1, std::string &info2, std::string &header);
bool getLiveUrl(const std::string &url, const std::string &script, std::string &realUrl, std::string &_pretty_name, std::string &info1, std::string &info2, std::string &header, std::string &url2);
bool IsAudioPlaying() { return is_audio_playing; };
void showMovieInfo();
};