summaryrefslogtreecommitdiff
path: root/stvw_cfg.c
diff options
context:
space:
mode:
Diffstat (limited to 'stvw_cfg.c')
-rwxr-xr-xstvw_cfg.c166
1 files changed, 161 insertions, 5 deletions
diff --git a/stvw_cfg.c b/stvw_cfg.c
index 19f16c8..b3279b3 100755
--- a/stvw_cfg.c
+++ b/stvw_cfg.c
@@ -31,7 +31,7 @@
#include <cstdio>
#include <cstdlib>
-cSmartTvConfig::cSmartTvConfig(string d): mConfigDir(d), mLog(NULL), mCfgFile(NULL),
+cSmartTvConfig::cSmartTvConfig(): mConfigDir(""), mLog(NULL), mCfgFile(NULL), mUseVdrSetupConf(false),
mLogFile(), mMediaFolder(), mSegmentDuration(), mHasMinBufferTime(), mHasBitrateCorrection(),
mLiveChannels(), mGroupSep(IGNORE), mServerAddress(""), mServerPort(8000), mCmds(false), mUseStreamDev4Live(true),
mBuiltInLiveStartMode (4), mBuiltInLivePktBuf4Hd(150), mBuiltInLivePktBuf4Sd(75), mBuiltInLiveBufDur(0.6),
@@ -49,7 +49,91 @@ cSmartTvConfig::cSmartTvConfig(string d): mConfigDir(d), mLog(NULL), mCfgFile(NU
mHasMinBufferTime = 40;
mHasBitrateCorrection = 1.1;
mLiveChannels = 30;
+}
+
+cSmartTvConfig::~cSmartTvConfig() {
+}
+
+
+void cSmartTvConfig::Store(cPlugin *mPlugin) {
+ mPlugin->SetupStore("LiveChannels", mLiveChannels);
+ mPlugin->SetupStore("LogFile", mLogFile.c_str());
+ mPlugin->SetupStore("MediaFolder", mMediaFolder.c_str());
+ mPlugin->SetupStore("SegmentDuration", mSegmentDuration);
+ mPlugin->SetupStore("HasMinBufferTime", mHasMinBufferTime);
+ mPlugin->SetupStore("HasBitrateCorrection", mHasBitrateCorrection);
+ switch (mGroupSep) {
+ case EMPTYIGNORE:
+ mPlugin->SetupStore("GroupSeparators", "EmptyIgnore");
+ break;
+ case EMPTYFOLDERDOWN:
+ mPlugin->SetupStore("GroupSeparators", "EmptyFolderDown");
+ break;
+ }
+ mPlugin->SetupStore("ServerAddress", mServerAddress.c_str());
+ mPlugin->SetupStore("ServerPort", mServerPort);
+ mPlugin->SetupStore("Commands", (mCmds ? 1 : 0));
+ mPlugin->SetupStore("UseStreamDev4Live", (mUseStreamDev4Live ? 1 : 0));
+ mPlugin->SetupStore("BuiltInLiveBufDur", (mBuiltInLiveBufDur ? 1 : 0));
+ if (mAddCorsHeader)
+ mPlugin->SetupStore("CorsHeader", mCorsHeaderPyld.c_str());
+ else
+ mPlugin->SetupStore("CorsHeader");
+}
+
+bool cSmartTvConfig::SetupParse(const char *name, const char *value) {
+
+ if ( strcmp( name, "LiveChannels" ) == 0 )
+ mLiveChannels = atoi( value );
+ else if ( strcmp( name, "LogFile" ) == 0 )
+ mLogFile = string(value);
+ else if ( strcmp(name, "MediaFolder") == 0)
+ mMediaFolder = string (value);
+ else if (strcmp(name, "SegmentDuration") == 0)
+ mSegmentDuration = atoi(value);
+ else if (strcmp(name, "HasMinBufferTime") == 0)
+ mHasMinBufferTime = atoi(value);
+ else if (strcmp(name, "HasBitrateCorrection") == 0)
+ mHasBitrateCorrection = atof(value);
+ else if (strcmp(name, "GroupSeparators") == 0) {
+ if (strcmp (value, "EmptyIgnore") == 0) {
+ mGroupSep = EMPTYIGNORE;
+ }
+ else if ( strcmp(value, "EmptyFolderDown") == 0) {
+ mGroupSep = EMPTYFOLDERDOWN;
+ }
+ }
+ else if (strcmp(name, "ServerAddress") == 0)
+ mServerAddress = value;
+ else if (strcmp(name, "ServerPort") == 0) {
+ mServerPort = atoi(value);
+ }
+ else if (strcmp(name, "Commands") == 0) {
+ if (strcmp(value, "enable") == 0)
+ mCmds = true;
+ }
+ else if (strcmp(name, "UseStreamDev4Live") == 0) {
+ if (strcmp(value, "false") == 0)
+ mUseStreamDev4Live = false;
+ }
+ else if (strcmp(name, "BuiltInLiveBufDur") == 0) {
+ mBuiltInLiveBufDur = atoi(value) /1000.0;
+ if (mBuiltInLiveBufDur <= 0.0)
+ mBuiltInLiveBufDur = 0.5;
+ }
+ else if (strcmp(name, "CorsHeader") == 0) {
+ mAddCorsHeader = true;
+ mCorsHeaderPyld = value;
+ }
+ else
+ return false;
+ mUseVdrSetupConf = true;
+ return true;
+}
+
+void cSmartTvConfig::Initialize(string dir) {
+ mConfigDir = dir;
readConfig();
struct stat statbuf;
@@ -61,9 +145,6 @@ cSmartTvConfig::cSmartTvConfig(string d): mConfigDir(d), mLog(NULL), mCfgFile(NU
}
}
-cSmartTvConfig::~cSmartTvConfig() {
-}
-
void cSmartTvConfig::printConfig() {
mLog = Log::getInstance();
@@ -87,18 +168,35 @@ void cSmartTvConfig::printConfig() {
}
+
+//void cSmartTvConfig::readPluginConfig() {
+ /*
+ mPlugin = cPluginManager::GetPlugin("smarttvweb");
+
+ if (!mPlugin)
+ return;
+
+ mPlugin->SetupStore("LiveChannels", mLiveChannels);
+ */
+//}
+
void cSmartTvConfig::readConfig() {
string line;
char attr[200];
char value[200];
+ if (mUseVdrSetupConf) {
+ esyslog("SmartTvWeb: Using config from VDR setup");
+ return;
+ }
+
ifstream myfile ((mConfigDir +"/smarttvweb.conf").c_str());
if (!myfile.is_open()) {
#ifndef STANDALONE
esyslog ("ERROR in SmartTvWeb: Cannot open config file. Expecting %s", (mConfigDir +"/smarttvweb.conf").c_str() );
#else
- cout << "ERROR: Cannot open config file. Expecting "<< (mConfigDir +"/smarttvweb.conf") << endl;
+ cout << "ERROR in SmartTvWeb: Cannot open config file. Expecting "<< (mConfigDir +"/smarttvweb.conf") << endl;
#endif
return;
}
@@ -255,3 +353,61 @@ cResumes* cSmartTvConfig::readConfig(string f) {
return NULL;
}
*/
+
+cWidgetConfigBase::cWidgetConfigBase() {
+ mUseDefaultBuffer = false;
+ mTotalBufferSize = 3500000;
+ mInitialBufferSize = 1000000;
+ mPendingBufferSize = 500000;
+ mSkipDuration = 30;
+ mUsePdlForRecordings = true;
+ mFormat = "hls";
+ mLiveChannels = 20;
+ mDirectAccessTimeout = 2000;
+ mSortType = 0;
+ mPlayKeyBehavior = 0;
+ mShowInfoMsgs = true;
+ mWidgetdebug = false;
+}
+
+string cWidgetConfigBase::BoolLine(string name, bool val) {
+ string res = "<" + name + ">" ;
+ res += (val ? "true" : "false");
+ res += "</" + name + ">\r\n";
+ return res;
+}
+
+string cWidgetConfigBase::IntLine(string name, int val) {
+ snprintf(f, sizeof(f), "%d", val);
+ string res = "<" + name + ">";
+ res += f;
+ res += "</" + name + ">\r\n";
+ return res;
+}
+
+string cWidgetConfigBase::GetWidgetConf() {
+
+ string res = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+ res += "<config>\r\n";
+
+ res += BoolLine("useDefaultBuffer", mUseDefaultBuffer);
+ res += IntLine("totalBufferSize", mTotalBufferSize);
+ res += IntLine("initialBufferSize", mInitialBufferSize);
+ res += IntLine("pendingBufferSize", mPendingBufferSize);
+ res += IntLine("skipDuration", mSkipDuration);
+
+ res += BoolLine("usePdlForRecordings", mUsePdlForRecordings);
+
+ // snprintf(f, sizeof(f), "%s", mFormat);
+ res += "<format>" + mFormat + "</format>\r\n";
+
+ res += IntLine("liveChannels", mLiveChannels);
+ res += IntLine ("directAccessTimeout", mDirectAccessTimeout);
+ res += IntLine("sortType", mSortType);
+ res += IntLine ("playKeyBehavior", mPlayKeyBehavior);
+ res += BoolLine("showInfoMsgs", mShowInfoMsgs);
+ res += BoolLine("widgetdebug", mWidgetdebug);
+
+ res += "</config>";
+ return res;
+}