2014-03-08 12:07:47 +01:00
|
|
|
/*
|
|
|
|
* socket.h: SAT>IP plugin for the Video Disk Recorder
|
|
|
|
*
|
|
|
|
* See the README file for copyright information and how to reach the author.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SATIP_SOCKET_H
|
|
|
|
#define __SATIP_SOCKET_H
|
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
class cSatipSocket {
|
|
|
|
private:
|
2014-03-30 13:56:11 +02:00
|
|
|
enum {
|
|
|
|
eReportIntervalS = 300 // in seconds
|
|
|
|
};
|
2014-03-08 12:07:47 +01:00
|
|
|
int socketPortM;
|
|
|
|
int socketDescM;
|
|
|
|
struct sockaddr_in sockAddrM;
|
2014-03-30 13:56:11 +02:00
|
|
|
time_t lastErrorReportM;
|
|
|
|
int packetErrorsM;
|
2014-03-23 16:59:08 +01:00
|
|
|
int sequenceNumberM;
|
2014-11-09 22:56:15 +01:00
|
|
|
bool waitM;
|
2014-03-08 12:07:47 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
cSatipSocket();
|
|
|
|
~cSatipSocket();
|
2014-11-09 22:56:15 +01:00
|
|
|
bool Open(const int portP = 0, bool waitP = false);
|
2014-03-08 12:07:47 +01:00
|
|
|
void Close(void);
|
|
|
|
int Port(void) { return socketPortM; }
|
|
|
|
bool IsOpen(void) { return (socketDescM >= 0); }
|
|
|
|
bool Flush(void);
|
|
|
|
int Read(unsigned char *bufferAddrP, unsigned int bufferLenP);
|
|
|
|
int ReadVideo(unsigned char *bufferAddrP, unsigned int bufferLenP);
|
|
|
|
int ReadApplication(unsigned char *bufferAddrP, unsigned int bufferLenP);
|
|
|
|
bool Write(const char *addrP, const unsigned char *bufferAddrP, unsigned int bufferLenP);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SATIP_SOCKET_H
|
|
|
|
|