#ifndef __MCASTRECEIVER_H
#define __MCASTRECEIVER_H

#include <vdr/thread.h>
#include <vdr/receiver.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>

#include <netinet/in.h>
#include <arpa/inet.h>

#ifdef DEBUG
#define Dprintf(x...) printf(x);
#else
#define Dprintf(x...) ;
#endif

class cMCastReceiver : public cReceiver, public cThread {
private:
  bool   m_Active;
  int    m_Sock;
  int    m_Vpid;
  int    m_Apid;
  unsigned char m_Packet[1500];
  int    m_Packets;
  socklen_t iSockLen;
  struct sockaddr_in send_sin;
  unsigned char tspid0[188*2];
  unsigned char * tspid1;   
  in_addr_t mcastip;
  unsigned int mcastport;
  in_addr_t mcastintf;
  
  bool WantsPid(int Pid);
    
protected:
  virtual void Activate(bool On);
  virtual void Receive(uchar *Data, int Length);
  virtual void Action(void);

public:
  cMCastReceiver(int Ca, int Vpid, const int Apid[], const int Dpid[], in_addr_t tmcastip, unsigned int tmcastport, in_addr_t tmcastintf);
  virtual ~cMCastReceiver();

  };

#endif //__MCASTRECEIVER_H

