diff -p -up streamdev/server/connectionVTP.c.orig streamdev/server/connectionVTP.c --- streamdev/server/connectionVTP.c.orig 2010-02-14 22:14:50.847319931 +0200 +++ streamdev/server/connectionVTP.c 2010-02-14 22:15:01.917070948 +0200 @@ -8,6 +8,8 @@ #include "server/suspend.h" #include "setup.h" +#include "../services/femonservice.h" + #include <vdr/tools.h> #include <vdr/videodir.h> #include <vdr/menu.h> @@ -733,6 +735,102 @@ bool cLSTRHandler::Next(bool &Last) 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): @@ -750,7 +848,8 @@ cConnectionVTP::cConnectionVTP(void): m_LSTEHandler(NULL), m_LSTCHandler(NULL), m_LSTTHandler(NULL), - m_LSTRHandler(NULL) + m_LSTRHandler(NULL), + m_LSTQHandler(NULL) { } @@ -769,6 +868,7 @@ cConnectionVTP::~cConnectionVTP() delete m_LSTCHandler; delete m_LSTEHandler; delete m_LSTRHandler; + delete m_LSTQHandler; } inline bool cConnectionVTP::Abort(void) const @@ -824,6 +924,7 @@ bool cConnectionVTP::Command(char *Cmd) 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", @@ -1278,6 +1379,11 @@ bool cConnectionVTP::CmdLSTR(char *Optio 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 -p -up streamdev/server/connectionVTP.h.orig streamdev/server/connectionVTP.h --- streamdev/server/connectionVTP.h.orig 2010-02-14 22:14:50.853320401 +0200 +++ streamdev/server/connectionVTP.h 2010-02-14 22:14:50.999319746 +0200 @@ -13,6 +13,7 @@ class cLSTEHandler; class cLSTCHandler; class cLSTTHandler; class cLSTRHandler; +class cLSTQHandler; class cConnectionVTP: public cServerConnection , public cStatus { @@ -39,6 +40,7 @@ private: cLSTCHandler *m_LSTCHandler; cLSTTHandler *m_LSTTHandler; cLSTRHandler *m_LSTRHandler; + cLSTQHandler *m_LSTQHandler; protected: template<class cHandler> @@ -83,6 +85,7 @@ public: 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 -p -up streamdev/services/femonservice.h.orig streamdev/services/femonservice.h --- streamdev/services/femonservice.h.orig 2010-02-14 22:14:51.010367366 +0200 +++ streamdev/services/femonservice.h 2010-02-14 22:14:51.010367366 +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 <linux/dvb/frontend.h> + +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 +