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:
|
|
|
|
int socketPortM;
|
|
|
|
int socketDescM;
|
|
|
|
struct sockaddr_in sockAddrM;
|
2016-12-11 00:18:12 +01:00
|
|
|
bool isMulticastM;
|
|
|
|
bool useSsmM;
|
|
|
|
in_addr_t streamAddrM;
|
|
|
|
in_addr_t sourceAddrM;
|
2017-11-18 22:32:57 +01:00
|
|
|
size_t rcvBufSizeM;
|
2017-11-19 14:25:31 +01:00
|
|
|
|
2016-12-11 00:18:12 +01:00
|
|
|
bool CheckAddress(const char *addrP, in_addr_t *inAddrP);
|
|
|
|
bool Join(void);
|
|
|
|
bool Leave(void);
|
2014-03-08 12:07:47 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
cSatipSocket();
|
2017-11-19 14:25:31 +01:00
|
|
|
explicit cSatipSocket(size_t rcvBufSizeP);
|
2014-11-16 09:31:34 +01:00
|
|
|
virtual ~cSatipSocket();
|
2016-04-11 22:02:12 +02:00
|
|
|
bool Open(const int portP = 0, const bool reuseP = false);
|
2016-12-11 00:18:12 +01:00
|
|
|
bool OpenMulticast(const int portP, const char *streamAddrP, const char *sourceAddrP);
|
2014-11-16 09:31:34 +01:00
|
|
|
virtual void Close(void);
|
2014-11-09 19:32:08 +01:00
|
|
|
int Fd(void) { return socketDescM; }
|
2014-03-08 12:07:47 +01:00
|
|
|
int Port(void) { return socketPortM; }
|
2016-12-11 00:18:12 +01:00
|
|
|
bool IsMulticast(void) { return isMulticastM; }
|
2014-03-08 12:07:47 +01:00
|
|
|
bool IsOpen(void) { return (socketDescM >= 0); }
|
|
|
|
bool Flush(void);
|
|
|
|
int Read(unsigned char *bufferAddrP, unsigned int bufferLenP);
|
2014-12-13 22:15:58 +01:00
|
|
|
int ReadMulti(unsigned char *bufferAddrP, unsigned int *elementRecvSizeP, unsigned int elementCountP, unsigned int elementBufferSizeP);
|
2014-03-08 12:07:47 +01:00
|
|
|
bool Write(const char *addrP, const unsigned char *bufferAddrP, unsigned int bufferLenP);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SATIP_SOCKET_H
|
|
|
|
|