2004-12-30 23:43:55 +01:00
|
|
|
/*
|
2010-12-02 09:57:17 +01:00
|
|
|
* $Id: socket.h,v 1.8 2010/08/18 10:26:55 schmirl Exp $
|
2004-12-30 23:43:55 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VDR_STREAMDEV_CLIENT_CONNECTION_H
|
|
|
|
#define VDR_STREAMDEV_CLIENT_CONNECTION_H
|
|
|
|
|
|
|
|
#include <tools/socket.h>
|
|
|
|
|
|
|
|
#include "common.h"
|
2012-03-03 23:24:30 +01:00
|
|
|
#include "client/setup.h"
|
2004-12-30 23:43:55 +01:00
|
|
|
|
2005-02-08 18:22:35 +01:00
|
|
|
#include <string>
|
|
|
|
|
2004-12-30 23:43:55 +01:00
|
|
|
#define CMD_LOCK cMutexLock CmdLock((cMutex*)&m_Mutex)
|
|
|
|
|
|
|
|
class cPES2TSRemux;
|
|
|
|
|
|
|
|
class cClientSocket: public cTBSocket {
|
|
|
|
private:
|
|
|
|
cTBSocket *m_DataSockets[si_Count];
|
|
|
|
cMutex m_Mutex;
|
2005-02-08 18:22:35 +01:00
|
|
|
char m_Buffer[BUFSIZ + 1]; // various uses
|
2012-04-21 22:28:58 +02:00
|
|
|
unsigned int m_ServerVersion;
|
2010-12-02 09:57:17 +01:00
|
|
|
bool m_Prio; // server supports command PRIO
|
2012-03-03 23:24:30 +01:00
|
|
|
bool m_Abort; // quit command pending
|
2004-12-30 23:43:55 +01:00
|
|
|
|
2011-07-06 09:13:50 +02:00
|
|
|
time_t m_LastSignalUpdate;
|
|
|
|
int m_LastSignalStrength;
|
|
|
|
int m_LastSignalQuality;
|
2012-06-07 19:23:14 +02:00
|
|
|
int m_LastDev;
|
2004-12-30 23:43:55 +01:00
|
|
|
protected:
|
|
|
|
/* Send Command, and return true if the command results in Expected.
|
2012-03-03 23:24:30 +01:00
|
|
|
Returns false on failure. */
|
|
|
|
bool Command(const std::string &Command, uint Expected);
|
2004-12-30 23:43:55 +01:00
|
|
|
|
2012-03-03 23:24:30 +01:00
|
|
|
/* Send the given command. Returns false on failure. */
|
|
|
|
bool Send(const std::string &Command);
|
|
|
|
|
|
|
|
/* Fetch results from an ongoing Command. The status code and the
|
|
|
|
buffer holding the server's response are stored in Code and Result
|
|
|
|
if non-NULL. Returns false on failure. */
|
|
|
|
bool Receive(const std::string &Command, uint *Code = NULL, std::string *Result = NULL, uint TimeoutMs = StreamdevClientSetup.Timeout * 1000);
|
2004-12-30 23:43:55 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
cClientSocket(void);
|
|
|
|
virtual ~cClientSocket();
|
|
|
|
|
|
|
|
void Reset(void);
|
|
|
|
|
|
|
|
bool CheckConnection(void);
|
|
|
|
bool ProvidesChannel(const cChannel *Channel, int Priority);
|
|
|
|
bool CreateDataConnection(eSocketId Id);
|
2007-04-24 12:57:34 +02:00
|
|
|
bool CloseDataConnection(eSocketId Id);
|
2004-12-30 23:43:55 +01:00
|
|
|
bool SetChannelDevice(const cChannel *Channel);
|
2010-12-02 09:57:17 +01:00
|
|
|
bool SupportsPrio() { return m_Prio; }
|
2012-04-21 22:28:58 +02:00
|
|
|
unsigned int ServerVersion() { return m_ServerVersion; }
|
2010-12-02 09:57:17 +01:00
|
|
|
bool SetPriority(int Priority);
|
2004-12-30 23:43:55 +01:00
|
|
|
bool SetPid(int Pid, bool On);
|
|
|
|
bool SetFilter(ushort Pid, uchar Tid, uchar Mask, bool On);
|
2012-06-07 19:23:14 +02:00
|
|
|
bool GetSignal(int *SignalStrength, int *SignalQuality, int *Dev);
|
2004-12-30 23:43:55 +01:00
|
|
|
bool CloseDvr(void);
|
|
|
|
bool SuspendServer(void);
|
|
|
|
bool Quit(void);
|
|
|
|
|
|
|
|
cTBSocket *DataSocket(eSocketId Id) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern class cClientSocket ClientSocket;
|
|
|
|
|
|
|
|
#endif // VDR_STREAMDEV_CLIENT_CONNECTION_H
|