Added server menu with list of clients. Connections can be terminated

with the "red" key. The former main menu action of suspending live TV
moved to the "blue" key.
This commit is contained in:
Frank Schmirler 2011-11-22 01:15:09 +01:00
parent ce1583a756
commit c652e8fa81
24 changed files with 221 additions and 49 deletions

View File

@ -23,7 +23,7 @@ SERVEROBJS = $(PLUGIN).o \
componentHTTP.o connectionHTTP.o menuHTTP.o \
componentIGMP.o connectionIGMP.o \
streamer.o livestreamer.o livefilter.o recplayer.o \
suspend.o setup.o
menu.o suspend.o setup.o
### The main target:

View File

@ -407,3 +407,6 @@ void cServerConnection::MainThreadHook()
{
m_SwitchLive->Switch();
}
cString cServerConnection::ToText() const
{ return cString::sprintf("%s\t%s:%d", Protocol(), RemoteIp().c_str(), RemotePort()); }

View File

@ -122,6 +122,9 @@ public:
/* This connections protocol name */
virtual const char* Protocol(void) const { return m_Protocol; }
/* Representation in menu */
virtual cString ToText(void) const;
/* std::map with additional information */
const tStrStrMap& Headers(void) const { return m_Headers; }
};

View File

@ -359,3 +359,8 @@ bool cConnectionHTTP::ProcessURI(const std::string& PathInfo)
return false;
}
cString cConnectionHTTP::ToText() const
{
cString str = cServerConnection::ToText();
return m_LiveStreamer ? cString::sprintf("%s\t%s", *str, *m_LiveStreamer->ToText()) : str;
}

View File

@ -47,6 +47,8 @@ public:
virtual void Attach(void) { if (m_LiveStreamer != NULL) m_LiveStreamer->Attach(); }
virtual void Detach(void) { if (m_LiveStreamer != NULL) m_LiveStreamer->Detach(); }
virtual cString ToText() const;
virtual bool CanAuthenticate(void);
virtual bool Command(char *Cmd);
@ -57,7 +59,7 @@ public:
inline bool cConnectionHTTP::Abort(void) const
{
return m_LiveStreamer && m_LiveStreamer->Abort();
return !IsOpen() || (m_LiveStreamer && m_LiveStreamer->Abort());
}
#endif // VDR_STREAMDEV_SERVERS_CONNECTIONVTP_H

View File

@ -71,3 +71,9 @@ void cConnectionIGMP::Stop()
DELETENULL(m_LiveStreamer);
}
}
cString cConnectionIGMP::ToText() const
{
cString str = cServerConnection::ToText();
return m_LiveStreamer ? cString::sprintf("%s\t%s", *str, *m_LiveStreamer->ToText()) : str;
}

View File

@ -28,6 +28,7 @@ public:
bool SetChannel(cChannel *Channel, in_addr_t Dst);
virtual void Welcome(void);
virtual cString ToText() const;
void Stop();
/* Not used here */
@ -41,7 +42,7 @@ public:
inline bool cConnectionIGMP::Abort(void) const
{
return !m_LiveStreamer || m_LiveStreamer->Abort();
return !IsOpen() || !m_LiveStreamer || m_LiveStreamer->Abort();
}
#endif // VDR_STREAMDEV_SERVERS_CONNECTIONIGMP_H

View File

@ -774,7 +774,7 @@ cConnectionVTP::~cConnectionVTP()
bool cConnectionVTP::Abort(void) const
{
return (m_LiveStreamer && m_LiveStreamer->Abort()) ||
return !IsOpen() || (m_LiveStreamer && m_LiveStreamer->Abort()) ||
(m_FilterStreamer && m_FilterStreamer->Abort());
}
@ -1811,3 +1811,14 @@ bool cConnectionVTP::Respond(int Code, const char *Message, ...)
Code < 0 ? -Code : Code,
Code < 0 ? '-' : ' ', *str);
}
cString cConnectionVTP::ToText() const
{
cString str = cServerConnection::ToText();
if (m_LiveStreamer)
return cString::sprintf("%s\t%s", *str, *m_LiveStreamer->ToText());
else if (m_RecPlayer)
return cString::sprintf("%s\t%s", *str, m_RecPlayer->getCurrentRecording()->Name());
else
return str;
}

View File

@ -53,6 +53,8 @@ public:
virtual void Welcome(void);
virtual void Reject(void);
virtual cString ToText() const;
virtual bool Abort(void) const;
virtual void Detach(void);
virtual void Attach(void);

View File

@ -460,6 +460,14 @@ void cStreamdevLiveStreamer::GetSignal(int *DevNum, int *Strength, int *Quality)
}
}
cString cStreamdevLiveStreamer::ToText() const
{
if (m_Device && m_Channel) {
return cString::sprintf("DVB%-2d %3d %s", m_Device->DeviceNumber() + 1, m_Channel->Number(), m_Channel->Name());
}
return cString("");
}
void cStreamdevLiveStreamer::StartReceiver(void)
{
if (m_NumPids > 0) {

View File

@ -40,6 +40,7 @@ public:
bool SetChannel(const cChannel *Channel, eStreamType StreamType, const int* Apid = NULL, const int* Dpid = NULL);
void SetPriority(int Priority);
void GetSignal(int *DevNum, int *Strength, int *Quality) const;
cString ToText() const;
virtual int Put(const uchar *Data, int Count);
virtual uchar *Get(int &Count);

67
server/menu.c Normal file
View File

@ -0,0 +1,67 @@
/*
* $Id: menu.c,v 1.10 2010/07/19 13:49:31 schmirl Exp $
*/
#include <vdr/menuitems.h>
#include <vdr/thread.h>
#include <vdr/player.h>
#include "server/menu.h"
#include "server/setup.h"
#include "server/server.h"
#include "server/suspend.h"
cStreamdevServerMenu::cStreamdevServerMenu(): cOsdMenu(tr("Streamdev Connections"), 4, 20) {
cThreadLock lock;
const cList<cServerConnection>& clients = cStreamdevServer::Clients(lock);
for (cServerConnection *s = clients.First(); s; s = clients.Next(s))
Add(new cOsdItem(s->ToText()));
SetHelpKeys();
Display();
}
cStreamdevServerMenu::~cStreamdevServerMenu() {
}
void cStreamdevServerMenu::SetHelpKeys() {
SetHelp(Count() ? tr("Disconnect") : NULL, NULL, NULL, StreamdevServerSetup.SuspendMode == smOffer ? tr("Suspend") : NULL);
}
eOSState cStreamdevServerMenu::Disconnect() {
cOsdItem *item = Get(Current());
if (item) {
cThreadLock lock;
const cList<cServerConnection>& clients = cStreamdevServer::Clients(lock);
const char *text = item->Text();
for (cServerConnection *s = clients.First(); s; s = clients.Next(s)) {
if (!strcmp(text, s->ToText())) {
s->Close();
Del(Current());
SetHelpKeys();
break;
}
}
}
return osContinue;
}
eOSState cStreamdevServerMenu::Suspend() {
if (StreamdevServerSetup.SuspendMode == smOffer && !cSuspendCtl::IsActive()) {
cControl::Launch(new cSuspendCtl);
return osBack;
}
return osContinue;
}
eOSState cStreamdevServerMenu::ProcessKey(eKeys Key) {
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case kRed: return Disconnect();
case kBlue: return Suspend();
case kOk: return osBack;
default: break;
}
}
return state;
}

24
server/menu.h Normal file
View File

@ -0,0 +1,24 @@
/*
* $Id: menu.h,v 1.4 2010/07/19 13:49:31 schmirl Exp $
*/
#ifndef VDR_STREAMDEV_MENU_H
#define VDR_STREAMDEV_MENU_H
#include <vdr/osdbase.h>
#include "connection.h"
class cStreamdevServerMenu: public cOsdMenu {
private:
void SetHelpKeys();
eOSState Disconnect();
eOSState Suspend();
protected:
virtual eOSState ProcessKey(eKeys Key);
public:
cStreamdevServerMenu();
virtual ~cStreamdevServerMenu();
};
#endif // VDR_STREAMDEV_MENU_H

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: streamdev 0.5.0\n"
"Report-Msgid-Bugs-To: <http://www.vdr-developer.org/mantisbt/>\n"
"POT-Creation-Date: 2010-06-14 13:06+0200\n"
"POT-Creation-Date: 2011-11-22 01:05+0100\n"
"PO-Revision-Date: 2008-03-30 02:11+0200\n"
"Last-Translator: Frank Schmirler <vdrdev@schmirler.de>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@ -21,8 +21,14 @@ msgstr "VDR Streaming Server"
msgid "Streaming active"
msgstr "Streamen im Gange"
msgid "Suspend Live TV"
msgstr "Live-TV pausieren"
msgid "Streamdev Connections"
msgstr "Streamdev Verbindungen"
msgid "Disconnect"
msgstr "Trennen"
msgid "Suspend"
msgstr "Pausieren"
msgid "Offer suspend mode"
msgstr "Pausieren anbieten"
@ -80,4 +86,3 @@ msgstr "Port des Multicast Clients"
msgid "Multicast Streamtype"
msgstr "Multicast Streamtyp"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: streamdev 0.5.0\n"
"Report-Msgid-Bugs-To: <http://www.vdr-developer.org/mantisbt/>\n"
"POT-Creation-Date: 2010-06-14 13:06+0200\n"
"POT-Creation-Date: 2011-11-22 01:05+0100\n"
"PO-Revision-Date: 2010-06-19 03:58+0100\n"
"Last-Translator: Javier Bradineras <jbradi@hotmail.com>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@ -21,8 +21,14 @@ msgstr "Servidor de transmisiones del VDR"
msgid "Streaming active"
msgstr "Trasmisión activa"
msgid "Suspend Live TV"
msgstr "Suspender TV en vivo"
msgid "Streamdev Connections"
msgstr ""
msgid "Disconnect"
msgstr ""
msgid "Suspend"
msgstr "Suspender"
msgid "Offer suspend mode"
msgstr "Ofrecer modo de suspensión"
@ -80,5 +86,3 @@ msgstr "Puerto del Cliente Multicast"
msgid "Multicast Streamtype"
msgstr "Tipo de flujo Multicast"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: streamdev 0.5.0\n"
"Report-Msgid-Bugs-To: <http://www.vdr-developer.org/mantisbt/>\n"
"POT-Creation-Date: 2010-06-14 13:06+0200\n"
"POT-Creation-Date: 2011-11-22 01:05+0100\n"
"PO-Revision-Date: 2008-03-30 02:11+0200\n"
"Last-Translator: Rolf Ahrenberg <rahrenbe@cc.hut.fi>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@ -21,8 +21,14 @@ msgstr "VDR-suoratoistopalvelin"
msgid "Streaming active"
msgstr "Suoratoistopalvelin aktiivinen"
msgid "Suspend Live TV"
msgstr "Pysäytä suora TV-lähetys"
msgid "Streamdev Connections"
msgstr ""
msgid "Disconnect"
msgstr ""
msgid "Suspend"
msgstr "Pysäytä"
msgid "Offer suspend mode"
msgstr "tyrkytä"
@ -80,4 +86,3 @@ msgstr "Multicast-portti"
msgid "Multicast Streamtype"
msgstr "Multicast-lähetysmuoto"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: streamdev 0.5.0\n"
"Report-Msgid-Bugs-To: <http://www.vdr-developer.org/mantisbt/>\n"
"POT-Creation-Date: 2010-06-14 13:06+0200\n"
"POT-Creation-Date: 2011-11-22 01:05+0100\n"
"PO-Revision-Date: 2008-03-30 02:11+0200\n"
"Last-Translator: micky979 <micky979@free.fr>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@ -21,8 +21,14 @@ msgstr "Serveur de streaming VDR"
msgid "Streaming active"
msgstr "Streaming actif"
msgid "Suspend Live TV"
msgstr "Suspendre Live TV"
msgid "Streamdev Connections"
msgstr ""
msgid "Disconnect"
msgstr ""
msgid "Suspend"
msgstr "Suspendre"
msgid "Offer suspend mode"
msgstr "Offrir le mode suspendre"
@ -80,4 +86,3 @@ msgstr ""
msgid "Multicast Streamtype"
msgstr ""

View File

@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: streamdev 0.5.0\n"
"Report-Msgid-Bugs-To: <http://www.vdr-developer.org/mantisbt/>\n"
"POT-Creation-Date: 2010-06-14 13:06+0200\n"
"POT-Creation-Date: 2011-11-22 01:05+0100\n"
"PO-Revision-Date: 2010-06-19 03:58+0100\n"
"Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@ -23,8 +23,14 @@ msgstr "Server trasmissione VDR"
msgid "Streaming active"
msgstr "Trasmissione attiva"
msgid "Suspend Live TV"
msgstr "Sospendi TV dal vivo"
msgid "Streamdev Connections"
msgstr ""
msgid "Disconnect"
msgstr ""
msgid "Suspend"
msgstr "Sospendi"
msgid "Offer suspend mode"
msgstr "Offri mod. sospensione"
@ -82,4 +88,3 @@ msgstr "Porta Client Multicast"
msgid "Multicast Streamtype"
msgstr "Tipo flusso Multicast"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: streamdev 0.5.0\n"
"Report-Msgid-Bugs-To: <http://www.vdr-developer.org/mantisbt/>\n"
"POT-Creation-Date: 2010-06-14 13:06+0200\n"
"POT-Creation-Date: 2011-11-22 01:05+0100\n"
"PO-Revision-Date: 2009-11-26 21:57+0200\n"
"Last-Translator: Valdemaras Pipiras <varas@ambernet.lt>\n"
"Language-Team: Lietuvių\n"
@ -21,8 +21,14 @@ msgstr "VDR transliavimo serveris"
msgid "Streaming active"
msgstr "Transliavimas vyksta"
msgid "Suspend Live TV"
msgstr "Pristabdyti Live TV"
msgid "Streamdev Connections"
msgstr ""
msgid "Disconnect"
msgstr ""
msgid "Suspend"
msgstr "Pristabdyti"
msgid "Offer suspend mode"
msgstr "Klausti dėl sustabdymo"
@ -80,4 +86,3 @@ msgstr "Multicast kliento portas"
msgid "Multicast Streamtype"
msgstr "Multicast transliavimo tipas"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: streamdev 0.5.0\n"
"Report-Msgid-Bugs-To: <http://www.vdr-developer.org/mantisbt/>\n"
"POT-Creation-Date: 2010-06-14 13:06+0200\n"
"POT-Creation-Date: 2011-11-22 01:05+0100\n"
"PO-Revision-Date: 2008-06-26 15:36+0100\n"
"Last-Translator: Oleg Roitburd <oleg@roitburd.de>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@ -21,8 +21,14 @@ msgstr "VDR Streaming
msgid "Streaming active"
msgstr "ÁâàØÜØÝÓ ÐÚâØÒÕÝ"
msgid "Suspend Live TV"
msgstr "¾áâÐÝÞÒÚÐ Live TV"
msgid "Streamdev Connections"
msgstr ""
msgid "Disconnect"
msgstr ""
msgid "Suspend"
msgstr "¾áâÐÝÞÒÚÐ"
msgid "Offer suspend mode"
msgstr "¿àÕÔÛÐÓÐâì ÞáâÐÝÞÒÚã"
@ -80,4 +86,3 @@ msgstr ""
msgid "Multicast Streamtype"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: streamdev_SK\n"
"Report-Msgid-Bugs-To: <http://www.vdr-developer.org/mantisbt/>\n"
"POT-Creation-Date: 2010-06-14 13:06+0200\n"
"POT-Creation-Date: 2011-11-22 01:05+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Milan Hrala <hrala.milan@gmail.com>\n"
"Language-Team: Slovak <hrala.milan@gmail.com>\n"
@ -23,8 +23,14 @@ msgstr "VDR pr
msgid "Streaming active"
msgstr "streamovanie aktivne"
msgid "Suspend Live TV"
msgstr "Pozastavenie živého vysielania"
msgid "Streamdev Connections"
msgstr ""
msgid "Disconnect"
msgstr ""
msgid "Suspend"
msgstr "Pozastavenie"
msgid "Offer suspend mode"
msgstr "Výber re¾ímu pozastavenia"
@ -82,4 +88,3 @@ msgstr "Port klienta Multicast"
msgid "Multicast Streamtype"
msgstr "Multicast typ streamu"

View File

@ -178,9 +178,8 @@ void cStreamdevServer::Action(void)
}
}
void cStreamdevServer::MainThreadHook(void)
const cList<cServerConnection>& cStreamdevServer::Clients(cThreadLock& Lock)
{
cThreadLock lock(m_Instance);
for (cServerConnection *s = m_Clients.First(); s; s = m_Clients.Next(s))
s->MainThreadHook();
Lock.Lock(m_Instance);
return m_Clients;
}

View File

@ -36,7 +36,8 @@ public:
static void Initialize(void);
static void Destruct(void);
static bool Active(void);
static void MainThreadHook(void);
static const cList<cServerConnection>& Clients(cThreadLock& Lock);
};
inline bool cStreamdevServer::Active(void)

View File

@ -9,9 +9,9 @@
#include <getopt.h>
#include <vdr/tools.h>
#include "streamdev-server.h"
#include "server/menu.h"
#include "server/setup.h"
#include "server/server.h"
#include "server/suspend.h"
#if !defined(APIVERSNUM) || APIVERSNUM < 10516
#error "VDR-1.5.16 API version or greater is required!"
@ -119,20 +119,20 @@ cString cPluginStreamdevServer::Active(void)
const char *cPluginStreamdevServer::MainMenuEntry(void)
{
if (StreamdevServerSetup.SuspendMode == smOffer && !cSuspendCtl::IsActive())
return tr("Suspend Live TV");
return NULL;
return tr("Streamdev Connections");
}
cOsdObject *cPluginStreamdevServer::MainMenuAction(void)
{
cControl::Launch(new cSuspendCtl);
return NULL;
return new cStreamdevServerMenu();
}
void cPluginStreamdevServer::MainThreadHook(void)
{
cStreamdevServer::MainThreadHook();
cThreadLock lock;
const cList<cServerConnection>& clients = cStreamdevServer::Clients(lock);
for (cServerConnection *s = clients.First(); s; s = clients.Next(s))
s->MainThreadHook();
}
cMenuSetupPage *cPluginStreamdevServer::SetupMenu(void)