#ifndef __RADIO_TRANSFER_H
#define __RADIO_TRANSFER_H

#include <linux/dvb/video.h>
#include <vdr/player.h>
#include <vdr/receiver.h>
#include <vdr/remux.h>
#include <vdr/ringbuffer.h>
#include <vdr/thread.h>
#include <vdr/device.h>

//Setup-Params
extern int S_RtFunc;
extern int S_RtOsdTitle;
extern int S_RtOsdTags;
extern int S_RtOsdPos;
extern int S_RtOsdRows;
extern int S_RtOsdLoop;
extern int S_RtOsdTO;
extern int S_RtBgCol;
extern int S_RtBgTra;
extern int S_RtFgCol;
extern int S_RtDispl;
#if VDRVERSNUM < 10332
extern eKeys RT_Userkey;
#endif
extern uint32_t rt_color[9];
extern int S_Verbose;
//Radiotext
#define RT_MEL 65
extern char RT_Text[5][RT_MEL];
extern char RTP_Artist[RT_MEL], RTP_Title[RT_MEL];
extern int RT_Info, RT_Index;
extern int RT_PTY;
extern struct tm *RTP_TitStart;
extern bool RT_OsdTO, RT_OsdOpen;


class cRadioTransfer : public cReceiver, public cPlayer, public cThread {
private:
  cRingBufferLinear *ringBuffer;
  cRemux *remux;
  bool active;
  const char *imagepath;
  void send_pes_packet(unsigned char *data, int len, int timestamp);
  void ShowImage (const char *file);
  //Radiotext
  void RadiotextCheckTS(uchar *Data, int Length);
  void RadiotextCheckPES(uchar *Data, int Length);
  void RadiotextDecode(uchar *Data, int Length);
  eTrackType audio_type;
  int audio_id;
protected:
  virtual void Activate(bool On);
  virtual void Receive(uchar *Data, int Length);
  virtual void Action(void);
public:
  cRadioTransfer(int VPid, const int *APids, const int *DPids, const int *SPids, const char *Image);
  virtual ~cRadioTransfer();
  virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId);
  };

class cRadioTransferControl : public cControl {
private:
  cRadioTransfer *transfer;
  static cDevice *receiverDevice;
public:
  cRadioTransferControl(cDevice *ReceiverDevice, int VPid, const int *APids, const int *DPids, const int *SPids, const char *Image);
  ~cRadioTransferControl();
  virtual void Hide(void) {}
  static cDevice *ReceiverDevice(void) { return receiverDevice; }
  };

class cRadioTextOsd : public cOsdObject {
private:
  cOsd *osd;
  const cFont *ftitel;
  const cFont *ftext;
  int fheight;
  int bheight;
  cChannel *channel;
  eKeys LastKey;
  bool autostart;
  int counter;
  cSkinDisplayChannel *chosd;
  cTimeMs osdtimer;
public:
  cRadioTextOsd();
  ~cRadioTextOsd();
  virtual void Hide(void);
  virtual void Show(void);
  virtual void ShowText(void);
  virtual eOSState ProcessKey(eKeys Key);
};

#endif //__RADIO_TRANSFER_H
