diff -NaurwB streamdev-unpatched/server/connectionVTP.c streamdev/server/connectionVTP.c --- streamdev-unpatched/server/connectionVTP.c 2009-10-13 08:38:47.000000000 +0200 +++ streamdev/server/connectionVTP.c 2009-11-22 20:04:07.000000000 +0100 @@ -7,6 +7,8 @@ #include "server/suspend.h" #include "setup.h" +#include "../services/femonservice.h" + #include #include #include @@ -710,6 +712,102 @@ return false; } + +// --- cLSTQHandler ----------------------------------------------------------- + +class cLSTQHandler +{ +private: + enum eStates { Device, Status, Signal, SNR, BER, UNC, Video, + Audio, Dolby, EndQuality }; + cConnectionVTP *m_Client; + FemonService_v1_0 m_femon; + int m_Errno; + int m_Channel; + cString m_Error; + eStates m_State; +public: + cLSTQHandler(cConnectionVTP *Client, const char *Option); + ~cLSTQHandler(); + bool Next(bool &Last); +}; + +cLSTQHandler::cLSTQHandler(cConnectionVTP *Client, const char *Option): + m_Client(Client), + m_Errno(0), + m_State(Device), + m_Channel(-1) +{ +// if (*Option) { +// if (isnumber(Option)) { +// m_Channel = atoi(Option); +// } +// } + + cPlugin *p; + p = cPluginManager::CallFirstService("FemonService-v1.0", &m_femon); + if (!p) { + m_Errno = 550; + m_Error = cString::sprintf("No support for Signal Quality found"); + } +} + +cLSTQHandler::~cLSTQHandler() +{ +} + +bool cLSTQHandler::Next(bool &Last) +{ + if (*m_Error != NULL) { + Last = true; + cString str(m_Error); + m_Error = NULL; + return m_Client->Respond(m_Errno, "%s", *str); + } + + Last = false; + switch (m_State) { + case Device: + m_State = Status; + if (*m_femon.fe_name != NULL) + return m_Client->Respond(-215, "Device : %s", *m_femon.fe_name); + else + return m_Client->Respond(-215, "Device : "); + case Status: + m_State = Signal; + if (*m_femon.fe_status != NULL) + return m_Client->Respond(-215, "Status : %s", *m_femon.fe_status); + else + return m_Client->Respond(-215, "Status : "); + case Signal: + m_State = SNR; + return m_Client->Respond(-215, "Signal : %04X (%2d%%)", m_femon.fe_signal, m_femon.fe_signal / 655); + case SNR: + m_State = BER; + return m_Client->Respond(-215, "SNR : %04X (%2d%%)", m_femon.fe_snr, m_femon.fe_snr / 655); + case BER: + m_State = UNC; + return m_Client->Respond(-215, "BER : %08X", m_femon.fe_ber); + case UNC: + m_State = Video; + return m_Client->Respond(-215, "UNC : %08X", m_femon.fe_unc); + case Video: + m_State = Audio; + return m_Client->Respond(-215, "Video : %.2f Mbit/s", m_femon.video_bitrate); + case Audio: + m_State = Dolby; + return m_Client->Respond(-215, "Audio : %.0f kbit/s", m_femon.audio_bitrate); + case Dolby: + m_State = EndQuality; + return m_Client->Respond(-215, "Dolby : %.0f kbit/s", m_femon.dolby_bitrate); + case EndQuality: + Last = true; + return m_Client->Respond(215, "End of quality information"); + } + return false; +} + + // --- cConnectionVTP --------------------------------------------------------- cConnectionVTP::cConnectionVTP(void): @@ -727,7 +825,8 @@ m_LSTEHandler(NULL), m_LSTCHandler(NULL), m_LSTTHandler(NULL), - m_LSTRHandler(NULL) + m_LSTRHandler(NULL), + m_LSTQHandler(NULL) { } @@ -745,6 +844,7 @@ delete m_LSTCHandler; delete m_LSTEHandler; delete m_LSTRHandler; + delete m_LSTQHandler; delete m_RecPlayer; } @@ -801,6 +901,7 @@ else if (strcasecmp(Cmd, "LSTR") == 0) return CmdLSTR(param); else if (strcasecmp(Cmd, "LSTT") == 0) return CmdLSTT(param); else if (strcasecmp(Cmd, "LSTC") == 0) return CmdLSTC(param); + else if (strcasecmp(Cmd, "LSTQ") == 0) return CmdLSTQ(param); if (param == NULL) { esyslog("ERROR: streamdev: this seriously shouldn't happen at %s:%d", @@ -1268,6 +1369,11 @@ return CmdLSTX(m_LSTRHandler, Option); } +bool cConnectionVTP::CmdLSTQ(char *Option) +{ + return CmdLSTX(m_LSTQHandler, Option); +} + // Functions adopted from SVDRP #define INIT_WRAPPER() bool _res #define Reply(c,m...) _res = Respond(c,m) diff -NaurwB streamdev-unpatched/server/connectionVTP.h streamdev/server/connectionVTP.h --- streamdev-unpatched/server/connectionVTP.h 2009-07-01 12:46:16.000000000 +0200 +++ streamdev/server/connectionVTP.h 2009-11-22 16:08:51.000000000 +0100 @@ -11,6 +11,7 @@ class cLSTCHandler; class cLSTTHandler; class cLSTRHandler; +class cLSTQHandler; class cConnectionVTP: public cServerConnection { friend class cLSTEHandler; @@ -36,6 +37,7 @@ cLSTCHandler *m_LSTCHandler; cLSTTHandler *m_LSTTHandler; cLSTRHandler *m_LSTRHandler; + cLSTQHandler *m_LSTQHandler; protected: template @@ -72,6 +74,7 @@ bool CmdLSTC(char *Opts); bool CmdLSTT(char *Opts); bool CmdLSTR(char *Opts); + bool CmdLSTQ(char *Opts); // Commands adopted from SVDRP bool CmdSTAT(const char *Option); diff -NaurwB streamdev-unpatched/services/femonservice.h streamdev/services/femonservice.h --- streamdev-unpatched/services/femonservice.h 1970-01-01 01:00:00.000000000 +0100 +++ streamdev/services/femonservice.h 2009-10-01 03:20:00.000000000 +0200 @@ -0,0 +1,26 @@ +/* + * Frontend Status Monitor plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#ifndef __FEMONSERVICE_H +#define __FEMONSERVICE_H + +#include + +struct FemonService_v1_0 { + cString fe_name; + cString fe_status; + uint16_t fe_snr; + uint16_t fe_signal; + uint32_t fe_ber; + uint32_t fe_unc; + double video_bitrate; + double audio_bitrate; + double dolby_bitrate; + }; + +#endif //__FEMONSERVICE_H +