2004-12-30 23:43:55 +01:00
|
|
|
/*
|
2010-12-02 09:57:17 +01:00
|
|
|
* $Id: setup.c,v 1.10 2010/07/19 13:49:31 schmirl Exp $
|
2004-12-30 23:43:55 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <vdr/menuitems.h>
|
|
|
|
|
|
|
|
#include "server/setup.h"
|
|
|
|
#include "server/server.h"
|
|
|
|
|
|
|
|
cStreamdevServerSetup StreamdevServerSetup;
|
|
|
|
|
|
|
|
cStreamdevServerSetup::cStreamdevServerSetup(void) {
|
2011-12-08 13:07:17 +01:00
|
|
|
HideMenuEntry = false;
|
2004-12-30 23:43:55 +01:00
|
|
|
MaxClients = 5;
|
2013-11-02 16:58:17 +01:00
|
|
|
StartSuspended = ssAuto;
|
2004-12-30 23:43:55 +01:00
|
|
|
StartVTPServer = true;
|
|
|
|
VTPServerPort = 2004;
|
2012-03-31 16:19:44 +02:00
|
|
|
VTPPriority = 0;
|
2011-12-11 17:03:09 +01:00
|
|
|
LoopPrevention = false;
|
2004-12-30 23:43:55 +01:00
|
|
|
StartHTTPServer = true;
|
|
|
|
HTTPServerPort = 3000;
|
2012-03-31 16:19:44 +02:00
|
|
|
HTTPPriority = 0;
|
2009-01-16 12:35:43 +01:00
|
|
|
HTTPStreamType = stTS;
|
2009-02-13 11:39:20 +01:00
|
|
|
StartIGMPServer = false;
|
|
|
|
IGMPClientPort = 1234;
|
2012-03-31 16:19:44 +02:00
|
|
|
IGMPPriority = 0;
|
2009-02-13 11:39:20 +01:00
|
|
|
IGMPStreamType = stTS;
|
2004-12-30 23:43:55 +01:00
|
|
|
AllowSuspend = false;
|
|
|
|
strcpy(VTPBindIP, "0.0.0.0");
|
|
|
|
strcpy(HTTPBindIP, "0.0.0.0");
|
2009-02-13 11:39:20 +01:00
|
|
|
strcpy(IGMPBindIP, "0.0.0.0");
|
2004-12-30 23:43:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cStreamdevServerSetup::SetupParse(const char *Name, const char *Value) {
|
2011-12-08 13:07:17 +01:00
|
|
|
if (strcmp(Name, "HideMenuEntry") == 0) HideMenuEntry = atoi(Value);
|
|
|
|
else if (strcmp(Name, "MaxClients") == 0) MaxClients = atoi(Value);
|
2013-11-02 16:58:17 +01:00
|
|
|
else if (strcmp(Name, "StartSuspended") == 0) StartSuspended = atoi(Value);
|
2004-12-30 23:43:55 +01:00
|
|
|
else if (strcmp(Name, "StartServer") == 0) StartVTPServer = atoi(Value);
|
|
|
|
else if (strcmp(Name, "ServerPort") == 0) VTPServerPort = atoi(Value);
|
2012-03-31 16:19:44 +02:00
|
|
|
else if (strcmp(Name, "VTPPriority") == 0) VTPPriority = atoi(Value);
|
2004-12-30 23:43:55 +01:00
|
|
|
else if (strcmp(Name, "VTPBindIP") == 0) strcpy(VTPBindIP, Value);
|
2011-12-11 17:03:09 +01:00
|
|
|
else if (strcmp(Name, "LoopPrevention") == 0) LoopPrevention = atoi(Value);
|
2004-12-30 23:43:55 +01:00
|
|
|
else if (strcmp(Name, "StartHTTPServer") == 0) StartHTTPServer = atoi(Value);
|
|
|
|
else if (strcmp(Name, "HTTPServerPort") == 0) HTTPServerPort = atoi(Value);
|
2012-03-31 16:19:44 +02:00
|
|
|
else if (strcmp(Name, "HTTPPriority") == 0) HTTPPriority = atoi(Value);
|
2004-12-30 23:43:55 +01:00
|
|
|
else if (strcmp(Name, "HTTPStreamType") == 0) HTTPStreamType = atoi(Value);
|
|
|
|
else if (strcmp(Name, "HTTPBindIP") == 0) strcpy(HTTPBindIP, Value);
|
2009-02-13 11:39:20 +01:00
|
|
|
else if (strcmp(Name, "StartIGMPServer") == 0) StartIGMPServer = atoi(Value);
|
|
|
|
else if (strcmp(Name, "IGMPClientPort") == 0) IGMPClientPort = atoi(Value);
|
2012-03-31 16:19:44 +02:00
|
|
|
else if (strcmp(Name, "IGMPPriority") == 0) IGMPPriority = atoi(Value);
|
2009-02-13 11:39:20 +01:00
|
|
|
else if (strcmp(Name, "IGMPStreamType") == 0) IGMPStreamType = atoi(Value);
|
|
|
|
else if (strcmp(Name, "IGMPBindIP") == 0) strcpy(IGMPBindIP, Value);
|
2004-12-30 23:43:55 +01:00
|
|
|
else if (strcmp(Name, "AllowSuspend") == 0) AllowSuspend = atoi(Value);
|
|
|
|
else return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-18 12:41:41 +02:00
|
|
|
const char* cStreamdevServerMenuSetupPage::StreamTypes[st_Count - 1] = {
|
|
|
|
"TS",
|
|
|
|
"PES",
|
|
|
|
"PS",
|
|
|
|
"ES",
|
2010-12-02 09:57:17 +01:00
|
|
|
"EXT"
|
2009-09-18 12:41:41 +02:00
|
|
|
};
|
|
|
|
|
2004-12-30 23:43:55 +01:00
|
|
|
cStreamdevServerMenuSetupPage::cStreamdevServerMenuSetupPage(void) {
|
|
|
|
m_NewSetup = StreamdevServerSetup;
|
|
|
|
|
2010-12-02 09:57:17 +01:00
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
cStreamdevServerMenuSetupPage::~cStreamdevServerMenuSetupPage() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void cStreamdevServerMenuSetupPage::Set(void) {
|
2013-11-02 16:58:17 +01:00
|
|
|
static const char *StartSuspendedItems[ss_Count] =
|
|
|
|
{
|
|
|
|
trVDR("no"),
|
|
|
|
trVDR("yes"),
|
|
|
|
trVDR("auto")
|
|
|
|
};
|
|
|
|
|
2010-12-02 09:57:17 +01:00
|
|
|
int current = Current();
|
|
|
|
Clear();
|
2004-12-30 23:43:55 +01:00
|
|
|
AddCategory (tr("Common Settings"));
|
2011-12-08 13:07:17 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Hide Mainmenu Entry"), &m_NewSetup.HideMenuEntry));
|
2013-11-02 16:58:17 +01:00
|
|
|
Add(new cMenuEditStraItem(tr("Start with Live TV suspended"), &m_NewSetup.StartSuspended, ss_Count, StartSuspendedItems));
|
2009-09-18 12:41:41 +02:00
|
|
|
Add(new cMenuEditIntItem (tr("Maximum Number of Clients"), &m_NewSetup.MaxClients, 0, 100));
|
|
|
|
|
2004-12-30 23:43:55 +01:00
|
|
|
|
|
|
|
AddCategory (tr("VDR-to-VDR Server"));
|
2009-09-18 12:41:41 +02:00
|
|
|
Add(new cMenuEditBoolItem(tr("Start VDR-to-VDR Server"), &m_NewSetup.StartVTPServer));
|
|
|
|
Add(new cMenuEditIntItem (tr("VDR-to-VDR Server Port"), &m_NewSetup.VTPServerPort, 0, 65535));
|
|
|
|
Add(new cMenuEditIpItem (tr("Bind to IP"), m_NewSetup.VTPBindIP));
|
2012-03-31 16:19:44 +02:00
|
|
|
Add(new cMenuEditIntItem (tr("Legacy Client Priority"), &m_NewSetup.VTPPriority, MINPRIORITY, MAXPRIORITY));
|
|
|
|
Add(new cMenuEditBoolItem(tr("Client may suspend"), &m_NewSetup.AllowSuspend));
|
2011-12-11 17:03:09 +01:00
|
|
|
if (cPluginManager::CallFirstService(LOOP_PREVENTION_SERVICE))
|
|
|
|
Add(new cMenuEditBoolItem(tr("Loop Prevention"), &m_NewSetup.LoopPrevention));
|
2004-12-30 23:43:55 +01:00
|
|
|
|
|
|
|
AddCategory (tr("HTTP Server"));
|
2009-09-18 12:41:41 +02:00
|
|
|
Add(new cMenuEditBoolItem(tr("Start HTTP Server"), &m_NewSetup.StartHTTPServer));
|
|
|
|
Add(new cMenuEditIntItem (tr("HTTP Server Port"), &m_NewSetup.HTTPServerPort, 0, 65535));
|
|
|
|
Add(new cMenuEditIpItem (tr("Bind to IP"), m_NewSetup.HTTPBindIP));
|
2012-03-31 16:19:44 +02:00
|
|
|
Add(new cMenuEditIntItem (tr("Priority"), &m_NewSetup.HTTPPriority, MINPRIORITY, MAXPRIORITY));
|
|
|
|
Add(new cMenuEditStraItem(tr("HTTP Streamtype"), &m_NewSetup.HTTPStreamType, st_Count - 1, StreamTypes));
|
|
|
|
|
2009-02-13 11:39:20 +01:00
|
|
|
AddCategory (tr("Multicast Streaming Server"));
|
2009-09-18 12:41:41 +02:00
|
|
|
Add(new cMenuEditBoolItem(tr("Start IGMP Server"), &m_NewSetup.StartIGMPServer));
|
|
|
|
Add(new cMenuEditIntItem (tr("Multicast Client Port"), &m_NewSetup.IGMPClientPort, 0, 65535));
|
|
|
|
Add(new cMenuEditIpItem (tr("Bind to IP"), m_NewSetup.IGMPBindIP));
|
2012-03-31 16:19:44 +02:00
|
|
|
Add(new cMenuEditIntItem (tr("Priority"), &m_NewSetup.IGMPPriority, MINPRIORITY, MAXPRIORITY));
|
|
|
|
Add(new cMenuEditStraItem(tr("Multicast Streamtype"), &m_NewSetup.IGMPStreamType, st_Count - 1, StreamTypes));
|
2010-12-02 09:57:17 +01:00
|
|
|
SetCurrent(Get(current));
|
|
|
|
Display();
|
2004-12-30 23:43:55 +01:00
|
|
|
}
|
|
|
|
|
2009-09-18 12:41:41 +02:00
|
|
|
void cStreamdevServerMenuSetupPage::AddCategory(const char *Title) {
|
|
|
|
|
2009-10-13 08:38:47 +02:00
|
|
|
cString str = cString::sprintf("--- %s -------------------------------------------------"
|
2009-09-18 12:41:41 +02:00
|
|
|
"---------------", Title );
|
|
|
|
|
2009-10-13 08:38:47 +02:00
|
|
|
cOsdItem *item = new cOsdItem(*str);
|
2009-09-18 12:41:41 +02:00
|
|
|
item->SetSelectable(false);
|
|
|
|
Add(item);
|
|
|
|
}
|
|
|
|
|
2004-12-30 23:43:55 +01:00
|
|
|
void cStreamdevServerMenuSetupPage::Store(void) {
|
|
|
|
bool restart = false;
|
|
|
|
if (m_NewSetup.StartVTPServer != StreamdevServerSetup.StartVTPServer
|
|
|
|
|| m_NewSetup.VTPServerPort != StreamdevServerSetup.VTPServerPort
|
|
|
|
|| strcmp(m_NewSetup.VTPBindIP, StreamdevServerSetup.VTPBindIP) != 0
|
|
|
|
|| m_NewSetup.StartHTTPServer != StreamdevServerSetup.StartHTTPServer
|
|
|
|
|| m_NewSetup.HTTPServerPort != StreamdevServerSetup.HTTPServerPort
|
2009-02-13 11:39:20 +01:00
|
|
|
|| strcmp(m_NewSetup.HTTPBindIP, StreamdevServerSetup.HTTPBindIP) != 0
|
|
|
|
|| m_NewSetup.StartIGMPServer != StreamdevServerSetup.StartIGMPServer
|
|
|
|
|| m_NewSetup.IGMPClientPort != StreamdevServerSetup.IGMPClientPort
|
|
|
|
|| strcmp(m_NewSetup.IGMPBindIP, StreamdevServerSetup.IGMPBindIP) != 0) {
|
2004-12-30 23:43:55 +01:00
|
|
|
restart = true;
|
2005-05-09 22:22:29 +02:00
|
|
|
cStreamdevServer::Destruct();
|
2004-12-30 23:43:55 +01:00
|
|
|
}
|
|
|
|
|
2011-12-08 13:07:17 +01:00
|
|
|
SetupStore("HideMenuEntry", m_NewSetup.HideMenuEntry);
|
2004-12-30 23:43:55 +01:00
|
|
|
SetupStore("MaxClients", m_NewSetup.MaxClients);
|
2013-11-02 16:58:17 +01:00
|
|
|
SetupStore("StartSuspended", m_NewSetup.StartSuspended);
|
2004-12-30 23:43:55 +01:00
|
|
|
SetupStore("StartServer", m_NewSetup.StartVTPServer);
|
|
|
|
SetupStore("ServerPort", m_NewSetup.VTPServerPort);
|
|
|
|
SetupStore("VTPBindIP", m_NewSetup.VTPBindIP);
|
2012-03-31 16:19:44 +02:00
|
|
|
SetupStore("VTPPriority", m_NewSetup.VTPPriority);
|
2011-12-11 17:03:09 +01:00
|
|
|
SetupStore("LoopPrevention", m_NewSetup.LoopPrevention);
|
2004-12-30 23:43:55 +01:00
|
|
|
SetupStore("StartHTTPServer", m_NewSetup.StartHTTPServer);
|
|
|
|
SetupStore("HTTPServerPort", m_NewSetup.HTTPServerPort);
|
|
|
|
SetupStore("HTTPBindIP", m_NewSetup.HTTPBindIP);
|
2012-03-31 16:19:44 +02:00
|
|
|
SetupStore("HTTPPriority", m_NewSetup.HTTPPriority);
|
|
|
|
SetupStore("HTTPStreamType", m_NewSetup.HTTPStreamType);
|
2009-02-13 11:39:20 +01:00
|
|
|
SetupStore("StartIGMPServer", m_NewSetup.StartIGMPServer);
|
|
|
|
SetupStore("IGMPClientPort", m_NewSetup.IGMPClientPort);
|
|
|
|
SetupStore("IGMPBindIP", m_NewSetup.IGMPBindIP);
|
2012-03-31 16:19:44 +02:00
|
|
|
SetupStore("IGMPPriority", m_NewSetup.IGMPPriority);
|
|
|
|
SetupStore("IGMPStreamType", m_NewSetup.IGMPStreamType);
|
2004-12-30 23:43:55 +01:00
|
|
|
SetupStore("AllowSuspend", m_NewSetup.AllowSuspend);
|
|
|
|
|
|
|
|
StreamdevServerSetup = m_NewSetup;
|
|
|
|
|
|
|
|
if (restart)
|
2005-05-09 22:22:29 +02:00
|
|
|
cStreamdevServer::Initialize();
|
2004-12-30 23:43:55 +01:00
|
|
|
}
|