#ifndef VDR_EM84XX_DEVICE_H
#define VDR_EM84XX_DEVICE_H

#include <vdr/device.h>

class cThreadEm84xx;

class cDeviceEm84xx: public cDevice {
public:
   static bool Initialize(void);
   static void Destruct(void);
   static cDeviceEm84xx* GetInstance(void);

private:
   static cDeviceEm84xx* mInstance;

   cThreadEm84xx *mThread;
   bool           mIsOpen;

   bool      mInputAspectRatio169;
   bool      mOutputAspectRatio169;
   int       mOutputHandle43on169;
   int       mOutputHandle169on43;
   bool      mAspectRatioDataChanged;
   bool      mSpdifForward;

   ePlayMode    mPlayMode;

   bool     mAc3;

protected:
   virtual void MakePrimaryDevice(bool On);

   virtual bool HasDecoder(void) const { return true;}
   virtual bool CanReplay(void) const { return true;}
   virtual bool SetPlayMode(ePlayMode PlayMode);
   virtual int PlayVideo(const uchar *Data, int Length);
#if VDRVERSNUM >= 10342
   virtual int PlayAudio(const uchar *Data, int Length, uchar Id);
#else
   virtual int PlayAudio(const uchar *Data, int Length);
#endif

   virtual int64_t GetSTC(void);
   virtual void TrickSpeed(int Speed);
   virtual void Clear(void);
   virtual void Play(void);
   virtual void Freeze(void);
   virtual void Mute(void);
   virtual void StillPicture(const uchar *Data, int Length);
   virtual bool Poll(cPoller &Poller, int TimeoutMs = 0);
   virtual bool Flush(int TimeoutMs = 0);

   virtual void SetVideoFormat(bool VideoFormat16_9);
   virtual eVideoSystem GetVideoSystem(void);

   virtual void SetAudioTrackDevice(eTrackType Type);
   virtual int GetAudioChannelDevice(void);
   virtual void SetAudioChannelDevice(int AudioChannel);
   virtual void SetVolumeDevice(int Volume);
   virtual void SetDigitalAudioDevice(bool On);

   void Open(void);
   void Close(void);

   void GetAspectRatioVideoData(const uchar* Data, /*uint32_t*/ int Length);

public:
   cDeviceEm84xx(void);
   virtual ~cDeviceEm84xx();

   void SwitchAspectRatio(bool Is169);
   void SetOutputAspectRatio(bool Is169);
   void SetOutputHandle43on169(int Handle);
   void SetOutputHandle169on43(int Handle);
   void SetAudioOutput(bool EnableSpdifForward);
};

#endif // VDR_EM84XX_DEVICE_H
