From 5cfa16c402d33451be993aa4bc7527e1b151442d Mon Sep 17 00:00:00 2001 From: Frank Schmirler Date: Thu, 7 Jun 2012 19:23:14 +0200 Subject: [PATCH] Added DeviceName() and DeviceType() to client device. The server IP and the number of the device used on the server are returned respectively. --- HISTORY | 3 +++ client/device.c | 21 +++++++++++++++++++-- client/device.h | 2 ++ client/socket.c | 8 ++++++-- client/socket.h | 3 ++- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/HISTORY b/HISTORY index 69c7643..00716f4 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,9 @@ VDR Plugin 'streamdev' Revision History --------------------------------------- +- Added DeviceName() and DeviceType() to client device. The server IP and the + number of the device used on the server are returned respectively. + 2012-05-29: Version 0.6.0 - Reimplemented some client device methods diff --git a/client/device.c b/client/device.c index 5c15a98..13c5aaa 100644 --- a/client/device.c +++ b/client/device.c @@ -318,17 +318,34 @@ void cStreamdevDevice::UpdatePriority(bool SwitchingChannels) { } } +cString cStreamdevDevice::DeviceName(void) const { + return StreamdevClientSetup.RemoteIp; +} + +cString cStreamdevDevice::DeviceType(void) const { + static int dev = -1; + static cString devType("STRDev"); + int d = -1; + if (ClientSocket.DataSocket(siLive) != NULL) + ClientSocket.GetSignal(NULL, NULL, &d); + if (d != dev) { + dev = d; + devType = d < 0 ? "STRDev" : *cString::sprintf("STRD%2d", d); + } + return devType; +} + int cStreamdevDevice::SignalStrength(void) const { int strength = -1; if (ClientSocket.DataSocket(siLive) != NULL) - ClientSocket.GetSignal(&strength, NULL); + ClientSocket.GetSignal(&strength, NULL, NULL); return strength; } int cStreamdevDevice::SignalQuality(void) const { int quality = -1; if (ClientSocket.DataSocket(siLive) != NULL) - ClientSocket.GetSignal(NULL, &quality); + ClientSocket.GetSignal(NULL, &quality, NULL); return quality; } diff --git a/client/device.h b/client/device.h index ff9092e..7096ad0 100644 --- a/client/device.h +++ b/client/device.h @@ -62,6 +62,8 @@ public: #else virtual bool IsTunedToTransponder(const cChannel *Channel); #endif + virtual cString DeviceName(void) const; + virtual cString DeviceType(void) const; virtual int SignalStrength(void) const; virtual int SignalQuality(void) const; diff --git a/client/socket.c b/client/socket.c index 4b58625..19a761a 100644 --- a/client/socket.c +++ b/client/socket.c @@ -29,6 +29,7 @@ cClientSocket::cClientSocket(void) m_LastSignalUpdate = 0; m_LastSignalStrength = -1; m_LastSignalQuality = -1; + m_LastDev = -1; Reset(); } @@ -291,7 +292,7 @@ bool cClientSocket::SetPriority(int Priority) { return Command(command, 220); } -bool cClientSocket::GetSignal(int *SignalStrength, int *SignalQuality) { +bool cClientSocket::GetSignal(int *SignalStrength, int *SignalQuality, int *Dev) { if (!CheckConnection()) return -1; CMD_LOCK; @@ -301,7 +302,8 @@ bool cClientSocket::GetSignal(int *SignalStrength, int *SignalQuality) { std::string buffer; std::string command("SGNL"); if (!Send(command) || !Receive(command, &code, &buffer) || code != 220 - || sscanf(buffer.c_str(), "%*d %*d %d:%d", &m_LastSignalStrength, &m_LastSignalQuality) != 2) { + || sscanf(buffer.c_str(), "%*d %d %d:%d", &m_LastDev, &m_LastSignalStrength, &m_LastSignalQuality) != 3) { + m_LastDev = -1; m_LastSignalStrength = -1; m_LastSignalQuality = -1; } @@ -311,6 +313,8 @@ bool cClientSocket::GetSignal(int *SignalStrength, int *SignalQuality) { *SignalStrength = m_LastSignalStrength; if (SignalQuality) *SignalQuality = m_LastSignalQuality; + if (Dev) + *Dev = m_LastDev; return 0; } diff --git a/client/socket.h b/client/socket.h index a4d4e35..69d45d6 100644 --- a/client/socket.h +++ b/client/socket.h @@ -28,6 +28,7 @@ private: time_t m_LastSignalUpdate; int m_LastSignalStrength; int m_LastSignalQuality; + int m_LastDev; protected: /* Send Command, and return true if the command results in Expected. Returns false on failure. */ @@ -57,7 +58,7 @@ public: bool SetPriority(int Priority); bool SetPid(int Pid, bool On); bool SetFilter(ushort Pid, uchar Tid, uchar Mask, bool On); - bool GetSignal(int *SignalStrength, int *SignalQuality); + bool GetSignal(int *SignalStrength, int *SignalQuality, int *Dev); bool CloseDvr(void); bool SuspendServer(void); bool Quit(void);