vdr-plugin-streamdev/client/socket.h

60 lines
1.7 KiB
C
Raw Normal View History

2004-12-30 23:43:55 +01:00
/*
* $Id: socket.h,v 1.7 2010/06/08 05:55:17 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"
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
2004-12-30 23:43:55 +01:00
protected:
/* Send Command, and return true if the command results in Expected.
Returns false on failure, setting errno appropriately if it has been
a system failure. If Expected is zero, returns immediately after
sending the command. */
2005-02-08 18:22:35 +01:00
bool Command(const std::string &Command, uint Expected = 0, uint TimeoutMs = 1500);
2004-12-30 23:43:55 +01:00
/* Fetch results from an ongoing Command called with Expected == 0. Returns
true if the response has the code Expected, returning an internal buffer
in the array pointer pointed to by Result. Returns false on failure,
setting errno appropriately if it has been a system failure. */
2005-02-08 18:22:35 +01:00
bool Expect(uint Expected, std::string *Result = NULL, uint TimeoutMs = 1500);
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);
bool CloseDataConnection(eSocketId Id);
2004-12-30 23:43:55 +01:00
bool SetChannelDevice(const cChannel *Channel);
bool SetPid(int Pid, bool On);
bool SetFilter(ushort Pid, uchar Tid, uchar Mask, bool On);
bool CloseDvr(void);
bool SuspendServer(void);
bool Quit(void);
cTBSocket *DataSocket(eSocketId Id) const;
};
extern class cClientSocket ClientSocket;
#endif // VDR_STREAMDEV_CLIENT_CONNECTION_H