1
0
mirror of https://github.com/rofafor/vdr-plugin-femon.git synced 2023-10-10 13:36:53 +02:00

Refactored configuration handling.

This commit is contained in:
Rolf Ahrenberg 2015-03-07 21:37:46 +02:00
parent 43a071c7fd
commit 6875f81c60
7 changed files with 253 additions and 136 deletions

45
femon.c
View File

@ -42,7 +42,7 @@ public:
virtual void Housekeeping(void);
virtual void MainThreadHook(void) {}
virtual cString Active(void) { return NULL; }
virtual const char *MainMenuEntry(void) { return (FemonConfig.hidemenu ? NULL : tr(MAINMENUENTRY)); }
virtual const char *MainMenuEntry(void) { return (FemonConfig.GetHideMenu() ? NULL : tr(MAINMENUENTRY)); }
virtual cOsdObject *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void);
virtual bool SetupParse(const char *nameP, const char *valueP);
@ -119,23 +119,36 @@ cMenuSetupPage *cPluginFemon::SetupMenu(void)
bool cPluginFemon::SetupParse(const char *nameP, const char *valueP)
{
// Parse your own setup parameters and store their values.
if (!strcasecmp(nameP, "HideMenu")) FemonConfig.hidemenu = atoi(valueP);
else if (!strcasecmp(nameP, "DisplayMode")) FemonConfig.displaymode = atoi(valueP);
else if (!strcasecmp(nameP, "Position")) FemonConfig.position = atoi(valueP);
else if (!strcasecmp(nameP, "Skin")) FemonConfig.skin = atoi(valueP);
else if (!strcasecmp(nameP, "Theme")) FemonConfig.theme = atoi(valueP);
else if (!strcasecmp(nameP, "Downscale")) FemonConfig.downscale = atoi(valueP);
else if (!strcasecmp(nameP, "RedLimit")) FemonConfig.redlimit = atoi(valueP);
else if (!strcasecmp(nameP, "GreenLimit")) FemonConfig.greenlimit = atoi(valueP);
else if (!strcasecmp(nameP, "UpdateInterval")) FemonConfig.updateinterval = atoi(valueP);
else if (!strcasecmp(nameP, "AnalStream")) FemonConfig.analyzestream = atoi(valueP);
else if (!strcasecmp(nameP, "CalcInterval")) FemonConfig.calcinterval = atoi(valueP);
else if (!strcasecmp(nameP, "UseSvdrp")) FemonConfig.usesvdrp = atoi(valueP);
else if (!strcasecmp(nameP, "ServerPort")) FemonConfig.svdrpport = atoi(valueP);
else if (!strcasecmp(nameP, "ServerIp")) strn0cpy(FemonConfig.svdrpip, valueP, sizeof(FemonConfig.svdrpip));
if (!strcasecmp(nameP, "HideMenu"))
FemonConfig.SetHideMenu(atoi(valueP));
else if (!strcasecmp(nameP, "DisplayMode"))
FemonConfig.SetDisplayMode(atoi(valueP));
else if (!strcasecmp(nameP, "Position"))
FemonConfig.SetPosition(atoi(valueP));
else if (!strcasecmp(nameP, "Skin"))
FemonConfig.SetSkin(atoi(valueP));
else if (!strcasecmp(nameP, "Theme"))
FemonConfig.SetTheme(atoi(valueP));
else if (!strcasecmp(nameP, "Downscale"))
FemonConfig.SetDownscale(atoi(valueP));
else if (!strcasecmp(nameP, "RedLimit"))
FemonConfig.SetRedLimit(atoi(valueP));
else if (!strcasecmp(nameP, "GreenLimit"))
FemonConfig.SetGreenLimit(atoi(valueP));
else if (!strcasecmp(nameP, "UpdateInterval"))
FemonConfig.SetUpdateInterval(atoi(valueP));
else if (!strcasecmp(nameP, "AnalStream"))
FemonConfig.SetAnalyzeStream(atoi(valueP));
else if (!strcasecmp(nameP, "CalcInterval"))
FemonConfig.SetCalcInterval(atoi(valueP));
else if (!strcasecmp(nameP, "UseSvdrp"))
FemonConfig.SetUseSvdrp(atoi(valueP));
else if (!strcasecmp(nameP, "ServerPort"))
FemonConfig.SetSvdrpPort(atoi(valueP));
else if (!strcasecmp(nameP, "ServerIp"))
FemonConfig.SetSvdrpIp(valueP);
else
return false;
if (FemonConfig.displaymode < 0 || FemonConfig.displaymode >= eFemonModeMaxNumber) FemonConfig.displaymode = 0;
return true;
}

View File

@ -7,26 +7,33 @@
#include <string.h>
#include "femontools.h"
#include "femonconfig.h"
cFemonConfig FemonConfig;
cFemonConfig::cFemonConfig(void)
cFemonConfig::cFemonConfig()
: traceModeM(eTraceModeNormal),
hideMenuM(0),
displayModeM(0),
skinM(0),
themeM(0),
positionM(1),
downscaleM(0),
redLimitM(33),
greenLimitM(66),
updateIntervalM(5),
analyzeStreamM(1),
calcIntervalM(20),
useSvdrpM(0),
svdrpPortM(6419)
{
hidemenu = 0;
displaymode = 0;
skin = 0;
theme = 0;
position = 1;
downscale = 0;
redlimit = 33;
greenlimit = 66;
updateinterval = 5;
analyzestream = 1;
calcinterval = 20;
usesvdrp = 0;
svdrpport = 6419;
strncpy(svdrpip, "0.0.0.0", sizeof(svdrpip));
SetSvdrpIp("0.0.0.0");
}
void cFemonConfig::SetSvdrpIp(const char *strP)
{
strn0cpy(svdrpIpM, strP, sizeof(svdrpIpM));
}
const cFemonTheme FemonTheme[eFemonThemeMaxNumber] =

View File

@ -19,24 +19,79 @@ enum eFemonModes
eFemonModeMaxNumber
};
struct cFemonConfig
class cFemonConfig
{
private:
unsigned int traceModeM;
int hideMenuM;
int displayModeM;
int skinM;
int themeM;
int positionM;
int downscaleM;
int redLimitM;
int greenLimitM;
int updateIntervalM;
int analyzeStreamM;
int calcIntervalM;
int useSvdrpM;
int svdrpPortM;
char svdrpIpM[MaxSvdrpIp + 1]; // must end with additional null
public:
cFemonConfig(void);
int hidemenu;
int displaymode;
int skin;
int theme;
int position;
int downscale;
int redlimit;
int greenlimit;
int updateinterval;
int analyzestream;
int calcinterval;
int usesvdrp;
int svdrpport;
char svdrpip[MaxSvdrpIp + 1]; // must end with additional null
enum eTraceMode {
eTraceModeNormal = 0x0000,
eTraceModeDebug1 = 0x0001,
eTraceModeDebug2 = 0x0002,
eTraceModeDebug3 = 0x0004,
eTraceModeDebug4 = 0x0008,
eTraceModeDebug5 = 0x0010,
eTraceModeDebug6 = 0x0020,
eTraceModeDebug7 = 0x0040,
eTraceModeDebug8 = 0x0080,
eTraceModeDebug9 = 0x0100,
eTraceModeDebug10 = 0x0200,
eTraceModeDebug11 = 0x0400,
eTraceModeDebug12 = 0x0800,
eTraceModeDebug13 = 0x1000,
eTraceModeDebug14 = 0x2000,
eTraceModeDebug15 = 0x4000,
eTraceModeDebug16 = 0x8000,
eTraceModeMask = 0xFFFF
};
cFemonConfig();
unsigned int GetTraceMode(void) const { return traceModeM; }
bool IsTraceMode(eTraceMode modeP) const { return (traceModeM & modeP); }
int GetHideMenu(void) const { return hideMenuM; }
int GetDisplayMode(void) const { return displayModeM; }
int GetSkin(void) const { return skinM; }
int GetTheme(void) const { return themeM; }
int GetPosition(void) const { return positionM; }
int GetDownscale(void) const { return downscaleM; }
int GetRedLimit(void) const { return redLimitM; }
int GetGreenLimit(void) const { return greenLimitM; }
int GetUpdateInterval(void) const { return updateIntervalM; }
int GetAnalyzeStream(void) const { return analyzeStreamM; }
int GetCalcInterval(void) const { return calcIntervalM; }
int GetUseSvdrp(void) const { return useSvdrpM; }
int GetSvdrpPort(void) const { return svdrpPortM; }
const char *GetSvdrpIp(void) const { return svdrpIpM; }
void SetTraceMode(unsigned int modeP) { traceModeM = (modeP & eTraceModeMask); }
void SetHideMenu(int hideMenuP) { hideMenuM = hideMenuP; }
void SetDisplayMode(int displayModeP) { if (displayModeM < 0 || displayModeM >= eFemonModeMaxNumber) displayModeM = 0; else displayModeM = displayModeP; }
void SetSkin(int skinP) { skinM = skinP; }
void SetTheme(int themeP) { themeM = themeP; }
void SetPosition(int positionP) { positionM = positionP; }
void SetDownscale(int downscaleP) { downscaleM = downscaleP; }
void SetRedLimit(int redLimitP) { redLimitM = redLimitP; }
void SetGreenLimit(int greenLimitP) { greenLimitM = greenLimitP; }
void SetUpdateInterval(int updateIntervalP) { updateIntervalM = updateIntervalP; }
void SetAnalyzeStream(int analyzeStreamP) { analyzeStreamM = analyzeStreamP; }
void SetCalcInterval(int calcIntervalP) { calcIntervalM = calcIntervalP; }
void SetUseSvdrp(int useSvdrpP) { useSvdrpM = useSvdrpP; }
void SetSvdrpPort(int svdrpPortP) { svdrpPortM = svdrpPortP; }
void SetSvdrpIp(const char *strP);
};
extern cFemonConfig FemonConfig;

View File

@ -29,14 +29,14 @@
#define OSDSYMBOL(id) femonSymbols.Get(id)
#define OSDSPACING femonSymbols.GetSpacing()
#define OSDROUNDING femonSymbols.GetRounding()
#define IS_OSDROUNDING (FemonConfig.skin == eFemonSkinElchi)
#define IS_OSDROUNDING (FemonConfig.GetSkin() == eFemonSkinElchi)
#define IS_OSDRESOLUTION(r1, r2) (abs(r1 - r2) < 20)
#define OSDINFOWIN_Y(offset) (FemonConfig.position ? (OSDHEIGHT - OSDINFOHEIGHT + offset) : offset)
#define OSDINFOWIN_Y(offset) (FemonConfig.GetPosition() ? (OSDHEIGHT - OSDINFOHEIGHT + offset) : offset)
#define OSDINFOWIN_X(col) ((col == 4) ? int(round(OSDWIDTH * 0.76)) : \
(col == 3) ? int(round(OSDWIDTH * 0.51)) : \
(col == 2) ? int(round(OSDWIDTH * 0.26)) : \
int(round(OSDWIDTH * 0.025)))
#define OSDSTATUSWIN_Y(offset) (FemonConfig.position ? offset : (OSDHEIGHT - OSDSTATUSHEIGHT + offset))
#define OSDSTATUSWIN_Y(offset) (FemonConfig.GetPosition() ? offset : (OSDHEIGHT - OSDSTATUSHEIGHT + offset))
#define OSDSTATUSWIN_X(col) ((col == 7) ? int(round(OSDWIDTH * 0.79)) : \
(col == 6) ? int(round(OSDWIDTH * 0.68)) : \
(col == 5) ? int(round(OSDWIDTH * 0.46)) : \
@ -52,39 +52,39 @@
x -= bm->Width() + spacing; \
y = (OSDROWHEIGHT - bm->Height()) / 2; \
if (y < 0) y = 0; \
osdM->DrawBitmap(x, OSDSTATUSWIN_Y(offset) + y, *bm, FemonTheme[FemonConfig.theme].clrTitleText, FemonTheme[FemonConfig.theme].clrTitleBackground); \
osdM->DrawBitmap(x, OSDSTATUSWIN_Y(offset) + y, *bm, FemonTheme[FemonConfig.GetTheme()].clrTitleText, FemonTheme[FemonConfig.GetTheme()].clrTitleBackground); \
}
#define OSDDRAWSTATUSFRONTEND(column, bitmap, status) \
osdM->DrawBitmap(OSDSTATUSWIN_XSYMBOL(column, x), OSDSTATUSWIN_Y(offset) + y, bitmap, (frontendStatusM & status) ? FemonTheme[FemonConfig.theme].clrActiveText : FemonTheme[FemonConfig.theme].clrRed, FemonTheme[FemonConfig.theme].clrBackground)
osdM->DrawBitmap(OSDSTATUSWIN_XSYMBOL(column, x), OSDSTATUSWIN_Y(offset) + y, bitmap, (frontendStatusM & status) ? FemonTheme[FemonConfig.GetTheme()].clrActiveText : FemonTheme[FemonConfig.GetTheme()].clrRed, FemonTheme[FemonConfig.GetTheme()].clrBackground)
#define OSDDRAWSTATUSVALUES(label1, label2, label3, label4, label5, label6, label7) \
osdM->DrawText(OSDSTATUSWIN_X(1), OSDSTATUSWIN_Y(offset), label1, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(2), OSDSTATUSWIN_Y(offset), label2, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(3), OSDSTATUSWIN_Y(offset), label3, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(4), OSDSTATUSWIN_Y(offset), label4, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(5), OSDSTATUSWIN_Y(offset), label5, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(6), OSDSTATUSWIN_Y(offset), label6, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(7), OSDSTATUSWIN_Y(offset), label7, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM)
osdM->DrawText(OSDSTATUSWIN_X(1), OSDSTATUSWIN_Y(offset), label1, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(2), OSDSTATUSWIN_Y(offset), label2, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(3), OSDSTATUSWIN_Y(offset), label3, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(4), OSDSTATUSWIN_Y(offset), label4, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(5), OSDSTATUSWIN_Y(offset), label5, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(6), OSDSTATUSWIN_Y(offset), label6, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDSTATUSWIN_X(7), OSDSTATUSWIN_Y(offset), label7, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM)
#define OSDDRAWSTATUSBAR(value) \
if (value > 0) { \
int barvalue = OSDBARWIDTH(value); \
osdM->DrawRectangle(0, OSDSTATUSWIN_Y(offset) + 3, min(OSDBARWIDTH(FemonConfig.redlimit), barvalue), OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT - 3, FemonTheme[FemonConfig.theme].clrRed); \
if (barvalue > OSDBARWIDTH(FemonConfig.redlimit)) \
osdM->DrawRectangle(OSDBARWIDTH(FemonConfig.redlimit), OSDSTATUSWIN_Y(offset) + 3, min((OSDWIDTH * FemonConfig.greenlimit / 100), barvalue), OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT - 3, FemonTheme[FemonConfig.theme].clrYellow); \
if (barvalue > OSDBARWIDTH(FemonConfig.greenlimit)) \
osdM->DrawRectangle(OSDBARWIDTH(FemonConfig.greenlimit), OSDSTATUSWIN_Y(offset) + 3, barvalue, OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT - 3, FemonTheme[FemonConfig.theme].clrGreen); \
osdM->DrawRectangle(0, OSDSTATUSWIN_Y(offset) + 3, min(OSDBARWIDTH(FemonConfig.GetRedLimit()), barvalue), OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT - 3, FemonTheme[FemonConfig.GetTheme()].clrRed); \
if (barvalue > OSDBARWIDTH(FemonConfig.GetRedLimit())) \
osdM->DrawRectangle(OSDBARWIDTH(FemonConfig.GetRedLimit()), OSDSTATUSWIN_Y(offset) + 3, min((OSDWIDTH * FemonConfig.GetGreenLimit() / 100), barvalue), OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT - 3, FemonTheme[FemonConfig.GetTheme()].clrYellow); \
if (barvalue > OSDBARWIDTH(FemonConfig.GetGreenLimit())) \
osdM->DrawRectangle(OSDBARWIDTH(FemonConfig.GetGreenLimit()), OSDSTATUSWIN_Y(offset) + 3, barvalue, OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT - 3, FemonTheme[FemonConfig.GetTheme()].clrGreen); \
}
#define OSDDRAWSTATUSTITLEBAR(title) \
osdM->DrawRectangle(0, OSDSTATUSWIN_Y(offset), OSDWIDTH, OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT - 1, FemonTheme[FemonConfig.theme].clrTitleBackground); \
osdM->DrawText(OSDSTATUSWIN_X(1), OSDSTATUSWIN_Y(offset), title, FemonTheme[FemonConfig.theme].clrTitleText, FemonTheme[FemonConfig.theme].clrTitleBackground, fontM); \
osdM->DrawRectangle(0, OSDSTATUSWIN_Y(offset), OSDWIDTH, OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT - 1, FemonTheme[FemonConfig.GetTheme()].clrTitleBackground); \
osdM->DrawText(OSDSTATUSWIN_X(1), OSDSTATUSWIN_Y(offset), title, FemonTheme[FemonConfig.GetTheme()].clrTitleText, FemonTheme[FemonConfig.GetTheme()].clrTitleBackground, fontM); \
if (IS_OSDROUNDING) { \
osdM->DrawEllipse(0, OSDSTATUSWIN_Y(0), OSDROUNDING, OSDSTATUSWIN_Y(OSDROUNDING), clrTransparent, -2); \
osdM->DrawEllipse(OSDWIDTH - OSDROUNDING, OSDSTATUSWIN_Y(0), OSDWIDTH, OSDSTATUSWIN_Y(OSDROUNDING), clrTransparent, -1); \
} \
osdM->DrawRectangle(0, OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT, OSDWIDTH, OSDSTATUSWIN_Y(offset) + OSDSTATUSHEIGHT - 1, FemonTheme[FemonConfig.theme].clrBackground)
osdM->DrawRectangle(0, OSDSTATUSWIN_Y(offset) + OSDROWHEIGHT, OSDWIDTH, OSDSTATUSWIN_Y(offset) + OSDSTATUSHEIGHT - 1, FemonTheme[FemonConfig.GetTheme()].clrBackground)
#define OSDDRAWSTATUSBOTTOMBAR() \
if (IS_OSDROUNDING) { \
@ -96,32 +96,32 @@
osdM->DrawRectangle(0, OSDSTATUSWIN_Y(0), OSDWIDTH, OSDSTATUSWIN_Y(OSDSTATUSHEIGHT) - 1, clrTransparent)
#define OSDDRAWINFOLEFT(label, value) \
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDINFOWIN_X(2), OSDINFOWIN_Y(offset), value, FemonTheme[FemonConfig.theme].clrActiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM)
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDINFOWIN_X(2), OSDINFOWIN_Y(offset), value, FemonTheme[FemonConfig.GetTheme()].clrActiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM)
#define OSDDRAWINFORIGHT(label, value) \
osdM->DrawText(OSDINFOWIN_X(3), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDINFOWIN_X(4), OSDINFOWIN_Y(offset), value, FemonTheme[FemonConfig.theme].clrActiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM)
osdM->DrawText(OSDINFOWIN_X(3), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDINFOWIN_X(4), OSDINFOWIN_Y(offset), value, FemonTheme[FemonConfig.GetTheme()].clrActiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM)
#define OSDDRAWINFOACTIVE(label, value) \
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.theme].clrActiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDINFOWIN_X(3), OSDINFOWIN_Y(offset), value, FemonTheme[FemonConfig.theme].clrActiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM)
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.GetTheme()].clrActiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDINFOWIN_X(3), OSDINFOWIN_Y(offset), value, FemonTheme[FemonConfig.GetTheme()].clrActiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM)
#define OSDDRAWINFOINACTIVE(label, value) \
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.theme].clrInactiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM); \
osdM->DrawText(OSDINFOWIN_X(3), OSDINFOWIN_Y(offset), value, FemonTheme[FemonConfig.theme].clrActiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM)
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.GetTheme()].clrInactiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM); \
osdM->DrawText(OSDINFOWIN_X(3), OSDINFOWIN_Y(offset), value, FemonTheme[FemonConfig.GetTheme()].clrActiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM)
#define OSDDRAWINFOLINE(label) \
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.theme].clrActiveText, FemonTheme[FemonConfig.theme].clrBackground, fontM)
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), label, FemonTheme[FemonConfig.GetTheme()].clrActiveText, FemonTheme[FemonConfig.GetTheme()].clrBackground, fontM)
#define OSDDRAWINFOTITLEBAR(title) \
osdM->DrawRectangle(0, OSDINFOWIN_Y(offset), OSDWIDTH, OSDINFOWIN_Y(offset) + OSDROWHEIGHT - 1, FemonTheme[FemonConfig.theme].clrTitleBackground); \
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), title, FemonTheme[FemonConfig.theme].clrTitleText, FemonTheme[FemonConfig.theme].clrTitleBackground, fontM); \
osdM->DrawRectangle(0, OSDINFOWIN_Y(offset), OSDWIDTH, OSDINFOWIN_Y(offset) + OSDROWHEIGHT - 1, FemonTheme[FemonConfig.GetTheme()].clrTitleBackground); \
osdM->DrawText(OSDINFOWIN_X(1), OSDINFOWIN_Y(offset), title, FemonTheme[FemonConfig.GetTheme()].clrTitleText, FemonTheme[FemonConfig.GetTheme()].clrTitleBackground, fontM); \
if (IS_OSDROUNDING) { \
osdM->DrawEllipse(0, OSDINFOWIN_Y(0), OSDROUNDING, OSDINFOWIN_Y(OSDROUNDING), clrTransparent, -2); \
osdM->DrawEllipse(OSDWIDTH - OSDROUNDING, OSDINFOWIN_Y(0), OSDWIDTH, OSDINFOWIN_Y(OSDROUNDING), clrTransparent, -1); \
} \
osdM->DrawRectangle(0, OSDINFOWIN_Y(offset) + OSDROWHEIGHT, OSDWIDTH, OSDINFOWIN_Y(offset) + OSDINFOHEIGHT - 1, FemonTheme[FemonConfig.theme].clrBackground)
osdM->DrawRectangle(0, OSDINFOWIN_Y(offset) + OSDROWHEIGHT, OSDWIDTH, OSDINFOWIN_Y(offset) + OSDINFOHEIGHT - 1, FemonTheme[FemonConfig.GetTheme()].clrBackground)
#define OSDDRAWINFOBOTTOMBAR() \
if (IS_OSDROUNDING) { \
@ -187,11 +187,11 @@ cFemonOsd::cFemonOsd()
frontendNameM(""),
frontendStatusValidM(false),
deviceSourceM(DEVICESOURCE_DVBAPI),
displayModeM(FemonConfig.displaymode),
osdWidthM(cOsd::OsdWidth() * (100 - FemonConfig.downscale) / 100),
osdHeightM(cOsd::OsdHeight() * (100 - FemonConfig.downscale) / 100),
osdLeftM(cOsd::OsdLeft() + (cOsd::OsdWidth() * FemonConfig.downscale / 200)),
osdTopM(cOsd::OsdTop() + (cOsd::OsdHeight() * FemonConfig.downscale / 200)),
displayModeM(FemonConfig.GetDisplayMode()),
osdWidthM(cOsd::OsdWidth() * (100 - FemonConfig.GetDownscale()) / 100),
osdHeightM(cOsd::OsdHeight() * (100 - FemonConfig.GetDownscale()) / 100),
osdLeftM(cOsd::OsdLeft() + (cOsd::OsdWidth() * FemonConfig.GetDownscale() / 200)),
osdTopM(cOsd::OsdTop() + (cOsd::OsdHeight() * FemonConfig.GetDownscale() / 200)),
inputTimeM(0),
sleepM(),
mutexM()
@ -706,7 +706,7 @@ void cFemonOsd::Action(void)
}
DrawInfoWindow();
DrawStatusWindow();
sleepM.Wait(max((int)(100 * FemonConfig.updateinterval - t.Elapsed()), 3));
sleepM.Wait(max((int)(100 * FemonConfig.GetUpdateInterval() - t.Elapsed()), 3));
}
}
@ -730,7 +730,7 @@ void cFemonOsd::Show(void)
frontendM = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1;
if (frontendM >= 0) {
if (ioctl(frontendM, FE_GET_INFO, &frontendInfoM) < 0) {
if (!FemonConfig.usesvdrp)
if (!FemonConfig.GetUseSvdrp())
error("cFemonOsd::Show() cannot read frontend info.");
close(frontendM);
frontendM = -1;
@ -738,7 +738,7 @@ void cFemonOsd::Show(void)
return;
}
}
else if (FemonConfig.usesvdrp) {
else if (FemonConfig.GetUseSvdrp()) {
if (!SvdrpConnect() || !SvdrpTune())
return;
}
@ -758,8 +758,8 @@ void cFemonOsd::Show(void)
osdM->SetAreas(Areas1, sizeof(Areas1) / sizeof(tArea));
}
else {
tArea Areas2[] = { { 0, OSDSTATUSWIN_Y(0), OSDWIDTH - 1, OSDSTATUSWIN_Y(0) + OSDSTATUSHEIGHT - 1, FemonTheme[FemonConfig.theme].bpp },
{ 0, OSDINFOWIN_Y(0), OSDWIDTH - 1, OSDINFOWIN_Y(0) + OSDROWHEIGHT - 1, FemonTheme[FemonConfig.theme].bpp },
tArea Areas2[] = { { 0, OSDSTATUSWIN_Y(0), OSDWIDTH - 1, OSDSTATUSWIN_Y(0) + OSDSTATUSHEIGHT - 1, FemonTheme[FemonConfig.GetTheme()].bpp },
{ 0, OSDINFOWIN_Y(0), OSDWIDTH - 1, OSDINFOWIN_Y(0) + OSDROWHEIGHT - 1, FemonTheme[FemonConfig.GetTheme()].bpp },
{ 0, OSDINFOWIN_Y(OSDROWHEIGHT), OSDWIDTH - 1, OSDINFOWIN_Y(0) + OSDINFOHEIGHT - 1, 2 } };
osdM->SetAreas(Areas2, sizeof(Areas2) / sizeof(tArea));
}
@ -770,7 +770,7 @@ void cFemonOsd::Show(void)
receiverM->Deactivate();
DELETENULL(receiverM);
}
if (FemonConfig.analyzestream && channel) {
if (FemonConfig.GetAnalyzeStream() && channel) {
receiverM = new cFemonReceiver(channel, IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0);
cDevice::ActualDevice()->AttachReceiver(receiverM);
}
@ -795,7 +795,7 @@ void cFemonOsd::ChannelSwitch(const cDevice * deviceP, int channelNumberP, bool
return;
}
if (channel && FemonConfig.analyzestream) {
if (channel && FemonConfig.GetAnalyzeStream()) {
deviceSourceM = DEVICESOURCE_DVBAPI;
if (channel->IsSourceType('I'))
deviceSourceM = DEVICESOURCE_IPTV;
@ -813,7 +813,7 @@ void cFemonOsd::ChannelSwitch(const cDevice * deviceP, int channelNumberP, bool
frontendM = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1;
if (frontendM >= 0) {
if (ioctl(frontendM, FE_GET_INFO, &frontendInfoM) < 0) {
if (!FemonConfig.usesvdrp)
if (!FemonConfig.GetUseSvdrp())
error("cFemonOsd::ChannelSwitch() cannot read frontend info.");
close(frontendM);
frontendM = -1;
@ -821,7 +821,7 @@ void cFemonOsd::ChannelSwitch(const cDevice * deviceP, int channelNumberP, bool
return;
}
}
else if (FemonConfig.usesvdrp) {
else if (FemonConfig.GetUseSvdrp()) {
if (!SvdrpConnect() || !SvdrpTune())
return;
}
@ -849,7 +849,7 @@ void cFemonOsd::SetAudioTrack(int indexP, const char * const *tracksP)
receiverM->Deactivate();
DELETENULL(receiverM);
}
if (FemonConfig.analyzestream) {
if (FemonConfig.GetAnalyzeStream()) {
const cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
if (channel) {
receiverM = new cFemonReceiver(channel, IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0);
@ -950,8 +950,8 @@ bool cFemonOsd::SvdrpConnect(void)
if (svdrpConnectionM.handle < 0) {
svdrpPluginM = cPluginManager::GetPlugin(SVDRPPLUGIN);
if (svdrpPluginM) {
svdrpConnectionM.serverIp = FemonConfig.svdrpip;
svdrpConnectionM.serverPort = (unsigned short)FemonConfig.svdrpport;
svdrpConnectionM.serverIp = FemonConfig.GetSvdrpIp();
svdrpConnectionM.serverPort = (unsigned short)FemonConfig.GetSvdrpPort();
svdrpConnectionM.shared = true;
svdrpPluginM->Service("SvdrpConnection-v1.0", &svdrpConnectionM);
if (svdrpConnectionM.handle >= 0) {

View File

@ -232,7 +232,7 @@ void cFemonReceiver::Action(void)
// calculate bitrates
timeout = double(calcPeriod.Elapsed());
if (activeM && (timeout >= (100.0 * FemonConfig.calcinterval))) {
if (activeM && (timeout >= (100.0 * FemonConfig.GetCalcInterval()))) {
// TS packet 188 bytes - 4 byte header; MPEG standard defines 1Mbit = 1000000bit
// PES headers should be compensated!
videoBitRateM = (1000.0 * 8.0 * 184.0 * videoPacketCountM) / timeout;

View File

@ -11,8 +11,23 @@
#include "femonsetup.h"
cMenuFemonSetup::cMenuFemonSetup()
: hideMenuM(FemonConfig.GetHideMenu()),
displayModeM(FemonConfig.GetDisplayMode()),
skinM(FemonConfig.GetSkin()),
themeM(FemonConfig.GetTheme()),
positionM(FemonConfig.GetPosition()),
downscaleM(FemonConfig.GetDownscale()),
redLimitM(FemonConfig.GetRedLimit()),
greenLimitM(FemonConfig.GetGreenLimit()),
updateIntervalM(FemonConfig.GetUpdateInterval()),
analyzeStreamM(FemonConfig.GetAnalyzeStream()),
calcIntervalM(FemonConfig.GetCalcInterval()),
useSvdrpM(FemonConfig.GetUseSvdrp()),
svdrpPortM(FemonConfig.GetSvdrpPort())
{
debug("%s()\n", __PRETTY_FUNCTION__);
strn0cpy(svdrpIpM, FemonConfig.GetSvdrpIp(), sizeof(svdrpIpM));
dispModesM[eFemonModeBasic] = tr("basic");
dispModesM[eFemonModeTransponder] = tr("transponder");
dispModesM[eFemonModeStream] = tr("stream");
@ -32,7 +47,6 @@ cMenuFemonSetup::cMenuFemonSetup()
themesM[eFemonThemeSilverGreen] = tr("SilverGreen");
themesM[eFemonThemePearlHD] = tr("PearlHD");
dataM = FemonConfig;
SetMenuCategory(mcSetupPlugins);
Setup();
}
@ -44,49 +58,49 @@ void cMenuFemonSetup::Setup(void)
Clear();
helpM.Clear();
Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &dataM.hidemenu));
Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &hideMenuM));
helpM.Append(tr("Define whether the main menu entry is hidden."));
Add(new cMenuEditStraItem(tr("Default display mode"), &dataM.displaymode, eFemonModeMaxNumber, dispModesM));
Add(new cMenuEditStraItem(tr("Default display mode"), &displayModeM, eFemonModeMaxNumber, dispModesM));
helpM.Append(tr("Define the default display mode at startup."));
Add(new cMenuEditStraItem(trVDR("Setup.OSD$Skin"), &dataM.skin, eFemonSkinMaxNumber, skinsM));
Add(new cMenuEditStraItem(trVDR("Setup.OSD$Skin"), &skinM, eFemonSkinMaxNumber, skinsM));
helpM.Append(tr("Define the used OSD skin."));
Add(new cMenuEditStraItem(trVDR("Setup.OSD$Theme"), &dataM.theme, eFemonThemeMaxNumber, themesM));
Add(new cMenuEditStraItem(trVDR("Setup.OSD$Theme"), &themeM, eFemonThemeMaxNumber, themesM));
helpM.Append(tr("Define the used OSD theme."));
Add(new cMenuEditBoolItem(tr("Position"), &dataM.position, trVDR("bottom"), trVDR("top")));
Add(new cMenuEditBoolItem(tr("Position"), &positionM, trVDR("bottom"), trVDR("top")));
helpM.Append(tr("Define the position of OSD."));
Add(new cMenuEditIntItem(tr("Downscale OSD size [%]"), &dataM.downscale, 0, 20));
Add(new cMenuEditIntItem(tr("Downscale OSD size [%]"), &downscaleM, 0, 20));
helpM.Append(tr("Define the downscale ratio for OSD size."));
Add(new cMenuEditIntItem(tr("Red limit [%]"), &dataM.redlimit, 1, 50));
Add(new cMenuEditIntItem(tr("Red limit [%]"), &redLimitM, 1, 50));
helpM.Append(tr("Define a limit for red bar, which is used to indicate a bad signal."));
Add(new cMenuEditIntItem(tr("Green limit [%]"), &dataM.greenlimit, 51, 100));
Add(new cMenuEditIntItem(tr("Green limit [%]"), &greenLimitM, 51, 100));
helpM.Append(tr("Define a limit for green bar, which is used to indicate a good signal."));
Add(new cMenuEditIntItem(tr("OSD update interval [0.1s]"), &dataM.updateinterval, 1, 100));
Add(new cMenuEditIntItem(tr("OSD update interval [0.1s]"), &updateIntervalM, 1, 100));
helpM.Append(tr("Define an interval for OSD updates. The smaller interval generates higher CPU load."));
Add(new cMenuEditBoolItem(tr("Analyze stream"), &dataM.analyzestream));
Add(new cMenuEditBoolItem(tr("Analyze stream"), &analyzeStreamM));
helpM.Append(tr("Define whether the DVB stream is analyzed and bitrates calculated."));
if (FemonConfig.analyzestream) {
Add(new cMenuEditIntItem(tr("Calculation interval [0.1s]"), &dataM.calcinterval, 1, 100));
if (analyzeStreamM) {
Add(new cMenuEditIntItem(tr("Calculation interval [0.1s]"), &calcIntervalM, 1, 100));
helpM.Append(tr("Define an interval for calculation. The bigger interval generates more stable values."));
}
Add(new cMenuEditBoolItem(tr("Use SVDRP service"), &dataM.usesvdrp));
Add(new cMenuEditBoolItem(tr("Use SVDRP service"), &useSvdrpM));
helpM.Append(tr("Define whether the SVDRP service is used in client/server setups."));
if (dataM.usesvdrp) {
Add(new cMenuEditIntItem(tr("SVDRP service port"), &dataM.svdrpport, 1, 65535));
if (useSvdrpM) {
Add(new cMenuEditIntItem(tr("SVDRP service port"), &svdrpPortM, 1, 65535));
helpM.Append(tr("Define the port number of SVDRP service."));
Add(new cMenuEditStrItem(tr("SVDRP service IP"), dataM.svdrpip, sizeof(dataM.svdrpip), ".1234567890"));
Add(new cMenuEditStrItem(tr("SVDRP service IP"), svdrpIpM, sizeof(svdrpIpM), ".1234567890"));
helpM.Append(tr("Define the IP address of SVDRP service."));
}
@ -97,34 +111,49 @@ void cMenuFemonSetup::Setup(void)
void cMenuFemonSetup::Store(void)
{
debug("%s()\n", __PRETTY_FUNCTION__);
FemonConfig = dataM;
SetupStore("HideMenu", FemonConfig.hidemenu);
SetupStore("DisplayMode", FemonConfig.displaymode);
SetupStore("Skin", FemonConfig.skin);
SetupStore("Theme", FemonConfig.theme);
SetupStore("Position", FemonConfig.position);
SetupStore("Downscale", FemonConfig.downscale);
SetupStore("RedLimit", FemonConfig.redlimit);
SetupStore("GreenLimit", FemonConfig.greenlimit);
SetupStore("UpdateInterval", FemonConfig.updateinterval);
SetupStore("AnalStream", FemonConfig.analyzestream);
SetupStore("CalcInterval", FemonConfig.calcinterval);
SetupStore("UseSvdrp", FemonConfig.usesvdrp);
SetupStore("ServerPort", FemonConfig.svdrpport);
SetupStore("ServerIp", FemonConfig.svdrpip);
// Store values into setup.conf
SetupStore("HideMenu", hideMenuM);
SetupStore("DisplayMode", displayModeM);
SetupStore("Skin", skinM);
SetupStore("Theme", themeM);
SetupStore("Position", positionM);
SetupStore("Downscale", downscaleM);
SetupStore("RedLimit", redLimitM);
SetupStore("GreenLimit", greenLimitM);
SetupStore("UpdateInterval", updateIntervalM);
SetupStore("AnalStream", analyzeStreamM);
SetupStore("CalcInterval", calcIntervalM);
SetupStore("UseSvdrp", useSvdrpM);
SetupStore("ServerPort", svdrpPortM);
SetupStore("ServerIp", svdrpIpM);
// Update global config
FemonConfig.SetHideMenu(hideMenuM);
FemonConfig.SetDisplayMode(displayModeM);
FemonConfig.SetSkin(skinM);
FemonConfig.SetTheme(themeM);
FemonConfig.SetPosition(positionM);
FemonConfig.SetDownscale(downscaleM);
FemonConfig.SetRedLimit(redLimitM);
FemonConfig.SetGreenLimit(greenLimitM);
FemonConfig.SetUpdateInterval(updateIntervalM);
FemonConfig.SetAnalyzeStream(analyzeStreamM);
FemonConfig.SetCalcInterval(calcIntervalM);
FemonConfig.SetUseSvdrp(useSvdrpM);
FemonConfig.SetSvdrpPort(svdrpPortM);
FemonConfig.SetSvdrpIp(svdrpIpM);
}
eOSState cMenuFemonSetup::ProcessKey(eKeys Key)
eOSState cMenuFemonSetup::ProcessKey(eKeys keyP)
{
int oldUsesvdrp = dataM.usesvdrp;
int oldAnalyzestream = dataM.analyzestream;
int oldUseSvdrp = useSvdrpM;
int oldAnalyzeStream = analyzeStreamM;
eOSState state = cMenuSetupPage::ProcessKey(Key);
eOSState state = cMenuSetupPage::ProcessKey(keyP);
if (Key != kNone && (dataM.analyzestream != oldAnalyzestream || dataM.usesvdrp != oldUsesvdrp))
if (keyP != kNone && (analyzeStreamM != oldAnalyzeStream || useSvdrpM != oldUseSvdrp))
Setup();
if ((Key == kInfo) && (state == osUnknown) && (Current() < helpM.Size()))
if ((keyP == kInfo) && (state == osUnknown) && (Current() < helpM.Size()))
return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), helpM[Current()]));
return state;

View File

@ -13,8 +13,21 @@ private:
const char *dispModesM[eFemonModeMaxNumber];
const char *skinsM[eFemonSkinMaxNumber];
const char *themesM[eFemonThemeMaxNumber];
cFemonConfig dataM;
cVector<const char*> helpM;
int hideMenuM;
int displayModeM;
int skinM;
int themeM;
int positionM;
int downscaleM;
int redLimitM;
int greenLimitM;
int updateIntervalM;
int analyzeStreamM;
int calcIntervalM;
int useSvdrpM;
int svdrpPortM;
char svdrpIpM[MaxSvdrpIp + 1]; // must end with additional null
void Setup(void);
protected: