#ifndef __SUBTITLES_RECEIVER_H
#define __SUBTITLES_RECEIVER_H

#include "dec.h"
#include "viewer.h"
#include <vdr/receiver.h>
#include <vdr/ringbuffer.h>

class cSynchronizer;
class cMutex;

class cSubtitlesReceiver : public cReceiver, public cThread {

private:
  SubtitlesViewer viewer;
  cSynchronizer* syncer;
  cMutex* mutex;
  cDecoder* decoder;
  int subPid,priority;
  bool subscribed;

  cRingBufferLinear *ringBuffer;
  bool active;
  uint64_t clearTime;

  void processTSPacket(const uchar* Data);

protected:
  virtual void Activate(bool On);
  virtual void Receive(uchar *Data, int Length);
  virtual void Action( void );

 public:
  cSubtitlesReceiver(int SubPid, int Priority);
  ~cSubtitlesReceiver();

};

#endif

