summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorschmirl <schmirl>2009-09-18 10:41:41 +0000
committerschmirl <schmirl>2009-09-18 10:41:41 +0000
commit1cf41fb16f8a0ea06fa0dd8cabadc8a3e3610dc6 (patch)
tree252d15da3ce3dbe8813a70854fe67537c5037c83 /server
parent6fb88f8d99af82c301ace0f0448eb7dbb964f2be (diff)
downloadvdr-plugin-streamdev-1cf41fb16f8a0ea06fa0dd8cabadc8a3e3610dc6.tar.gz
vdr-plugin-streamdev-1cf41fb16f8a0ea06fa0dd8cabadc8a3e3610dc6.tar.bz2
- cleaned up common.h / common.c
- dropped cStreamdevMenuSetupPage
Diffstat (limited to 'server')
-rw-r--r--server/connection.c59
-rw-r--r--server/connection.h4
-rw-r--r--server/livestreamer.c3
-rw-r--r--server/setup.c61
-rw-r--r--server/setup.h7
5 files changed, 114 insertions, 20 deletions
diff --git a/server/connection.c b/server/connection.c
index 74b2783..eccb3c4 100644
--- a/server/connection.c
+++ b/server/connection.c
@@ -1,5 +1,5 @@
/*
- * $Id: connection.c,v 1.12 2009/02/13 10:39:22 schmirl Exp $
+ * $Id: connection.c,v 1.13 2009/09/18 10:43:26 schmirl Exp $
*/
#include "server/connection.h"
@@ -27,6 +27,63 @@ cServerConnection::~cServerConnection()
{
}
+const cChannel* cServerConnection::ChannelFromString(const char *String, int *Apid) {
+ const cChannel *channel = NULL;
+ char *string = strdup(String);
+ char *ptr, *end;
+ int apididx = 0;
+
+ if ((ptr = strrchr(string, '+')) != NULL) {
+ *(ptr++) = '\0';
+ apididx = strtoul(ptr, &end, 10);
+ Dprintf("found apididx: %d\n", apididx);
+ }
+
+ if (isnumber(string)) {
+ int temp = strtol(String, NULL, 10);
+ if (temp >= 1 && temp <= Channels.MaxNumber())
+ channel = Channels.GetByNumber(temp);
+ } else {
+ channel = Channels.GetByChannelID(tChannelID::FromString(string));
+
+ if (channel == NULL) {
+ int i = 1;
+ while ((channel = Channels.GetByNumber(i, 1)) != NULL) {
+ if (String == channel->Name())
+ break;
+
+ i = channel->Number() + 1;
+ }
+ }
+ }
+
+ if (channel != NULL && apididx > 0) {
+ int apid = 0, index = 1;
+
+ for (int i = 0; channel->Apid(i) != 0; ++i, ++index) {
+ if (index == apididx) {
+ apid = channel->Apid(i);
+ break;
+ }
+ }
+
+ if (apid == 0) {
+ for (int i = 0; channel->Dpid(i) != 0; ++i, ++index) {
+ if (index == apididx) {
+ apid = channel->Dpid(i);
+ break;
+ }
+ }
+ }
+
+ if (Apid != NULL)
+ *Apid = apid;
+ }
+
+ free(string);
+ return channel;
+}
+
bool cServerConnection::Read(void)
{
int b;
diff --git a/server/connection.h b/server/connection.h
index 2c28a09..73cb3d5 100644
--- a/server/connection.h
+++ b/server/connection.h
@@ -1,5 +1,5 @@
/*
- * $Id: connection.h,v 1.7 2009/02/13 10:39:22 schmirl Exp $
+ * $Id: connection.h,v 1.8 2009/09/18 10:43:26 schmirl Exp $
*/
#ifndef VDR_STREAMDEV_SERVER_CONNECTION_H
@@ -41,6 +41,8 @@ protected:
virtual bool Respond(const char *Message, bool Last = true, ...);
//__attribute__ ((format (printf, 2, 4)));
+ static const cChannel *ChannelFromString(const char *String, int *Apid = NULL);
+
public:
/* If you derive, specify a short string such as HTTP for Protocol, which
will be displayed in error messages */
diff --git a/server/livestreamer.c b/server/livestreamer.c
index e86cd6b..7642f5f 100644
--- a/server/livestreamer.c
+++ b/server/livestreamer.c
@@ -495,8 +495,9 @@ bool cStreamdevLiveStreamer::SetChannel(const cChannel *Channel, eStreamType Str
case stTSPIDS:
Dprintf("pid streaming mode\n");
return true;
+ default:
+ return false;
}
- return false;
}
int cStreamdevLiveStreamer::Put(const uchar *Data, int Count)
diff --git a/server/setup.c b/server/setup.c
index 710b1fa..3d93b6b 100644
--- a/server/setup.c
+++ b/server/setup.c
@@ -1,5 +1,5 @@
/*
- * $Id: setup.c,v 1.6 2009/02/13 10:39:22 schmirl Exp $
+ * $Id: setup.c,v 1.7 2009/09/18 10:43:26 schmirl Exp $
*/
#include <vdr/menuitems.h>
@@ -45,35 +45,66 @@ bool cStreamdevServerSetup::SetupParse(const char *Name, const char *Value) {
return true;
}
+const char* cStreamdevServerMenuSetupPage::StreamTypes[st_Count - 1] = {
+ "TS",
+ "PES",
+ "PS",
+ "ES",
+ "Extern"
+};
+
+const char* cStreamdevServerMenuSetupPage::SuspendModes[sm_Count] = {
+ "Offer suspend mode",
+ "Always suspended",
+ "Never suspended"
+};
+
cStreamdevServerMenuSetupPage::cStreamdevServerMenuSetupPage(void) {
m_NewSetup = StreamdevServerSetup;
+ static const char* modes[sm_Count];
+ for (int i = 0; i < sm_Count; i++)
+ modes[i] = tr(SuspendModes[i]);
+
AddCategory (tr("Common Settings"));
- AddRangeEdit(tr("Maximum Number of Clients"), m_NewSetup.MaxClients, 0, 100);
- AddSuspEdit (tr("Suspend behaviour"), m_NewSetup.SuspendMode);
- AddBoolEdit (tr("Client may suspend"), m_NewSetup.AllowSuspend);
+ Add(new cMenuEditIntItem (tr("Maximum Number of Clients"), &m_NewSetup.MaxClients, 0, 100));
+
+ Add(new cMenuEditStraItem(tr("Suspend behaviour"), &m_NewSetup.SuspendMode, sm_Count, modes));
+ Add(new cMenuEditBoolItem(tr("Client may suspend"), &m_NewSetup.AllowSuspend));
AddCategory (tr("VDR-to-VDR Server"));
- AddBoolEdit (tr("Start VDR-to-VDR Server"), m_NewSetup.StartVTPServer);
- AddShortEdit(tr("VDR-to-VDR Server Port"), m_NewSetup.VTPServerPort);
- AddIpEdit (tr("Bind to IP"), m_NewSetup.VTPBindIP);
+ 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));
AddCategory (tr("HTTP Server"));
- AddBoolEdit (tr("Start HTTP Server"), m_NewSetup.StartHTTPServer);
- AddShortEdit(tr("HTTP Server Port"), m_NewSetup.HTTPServerPort);
- AddTypeEdit (tr("HTTP Streamtype"), m_NewSetup.HTTPStreamType);
- AddIpEdit (tr("Bind to IP"), m_NewSetup.HTTPBindIP);
+ Add(new cMenuEditBoolItem(tr("Start HTTP Server"), &m_NewSetup.StartHTTPServer));
+ Add(new cMenuEditIntItem (tr("HTTP Server Port"), &m_NewSetup.HTTPServerPort, 0, 65535));
+ Add(new cMenuEditStraItem(tr("HTTP Streamtype"), &m_NewSetup.HTTPStreamType, st_Count - 1, StreamTypes));
+ Add(new cMenuEditIpItem (tr("Bind to IP"), m_NewSetup.HTTPBindIP));
AddCategory (tr("Multicast Streaming Server"));
- AddBoolEdit (tr("Start IGMP Server"), m_NewSetup.StartIGMPServer);
- AddShortEdit(tr("Multicast Client Port"), m_NewSetup.IGMPClientPort);
- AddTypeEdit (tr("Multicast Streamtype"), m_NewSetup.IGMPStreamType);
- AddIpEdit (tr("Bind to IP"), m_NewSetup.IGMPBindIP);
+ Add(new cMenuEditBoolItem(tr("Start IGMP Server"), &m_NewSetup.StartIGMPServer));
+ Add(new cMenuEditIntItem (tr("Multicast Client Port"), &m_NewSetup.IGMPClientPort, 0, 65535));
+ Add(new cMenuEditStraItem(tr("Multicast Streamtype"), &m_NewSetup.IGMPStreamType, st_Count - 1, StreamTypes));
+ Add(new cMenuEditIpItem (tr("Bind to IP"), m_NewSetup.IGMPBindIP));
SetCurrent(Get(1));
}
cStreamdevServerMenuSetupPage::~cStreamdevServerMenuSetupPage() {
}
+void cStreamdevServerMenuSetupPage::AddCategory(const char *Title) {
+ char *buffer = NULL;
+
+ asprintf(&buffer, "--- %s -------------------------------------------------"
+ "---------------", Title );
+
+ cOsdItem *item = new cOsdItem(buffer);
+ free(buffer);
+ item->SetSelectable(false);
+ Add(item);
+}
+
void cStreamdevServerMenuSetupPage::Store(void) {
bool restart = false;
if (m_NewSetup.StartVTPServer != StreamdevServerSetup.StartVTPServer
diff --git a/server/setup.h b/server/setup.h
index d2b1592..d22ab34 100644
--- a/server/setup.h
+++ b/server/setup.h
@@ -1,5 +1,5 @@
/*
- * $Id: setup.h,v 1.2 2009/02/13 10:39:22 schmirl Exp $
+ * $Id: setup.h,v 1.3 2009/09/18 10:43:26 schmirl Exp $
*/
#ifndef VDR_STREAMDEV_SETUPSERVER_H
@@ -30,10 +30,13 @@ struct cStreamdevServerSetup {
extern cStreamdevServerSetup StreamdevServerSetup;
-class cStreamdevServerMenuSetupPage: public cStreamdevMenuSetupPage {
+class cStreamdevServerMenuSetupPage: public cMenuSetupPage {
private:
+ static const char* StreamTypes[];
+ static const char* SuspendModes[];
cStreamdevServerSetup m_NewSetup;
+ void AddCategory(const char *Title);
protected:
virtual void Store(void);