/*
 * extb plugin to VDR (C++)
 *
 * (C) 2004 Andreas Brachold <vdr04-at-deltab-dot-de>
 *
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
 */

#ifndef ___LEDS_EXTB_H___
#define ___LEDS_EXTB_H___

#include "lirc.h"
#include "setup.h"
#include <vdr/status.h>


class cExtBoardIO : public cLirc
{
//LED///////////////////////////////////////////////////////////////////////////  
  static const char * m_szLED_ON [LED_CNT];
  static const char * m_szLED_OFF[LED_CNT];
  static const char * m_szLED_FLASH[LED_CNT];
  static const char * m_szOutput_ON [OUT_CNT];
  static const char * m_szOutput_OFF[OUT_CNT];
  
  enum eLEDState {
    eLED_Unset,
    eLED_Off,
    eLED_On,
    eLED_Flashing
  } m_eLastSendLEDState[LED_CNT]; //-1 Unset, OFF, ON, Flashing

  int   m_nLastSendOutputState[OUT_CNT];
  
  int   m_nCardIsRecording[4];
  
  enum  {eReplayNone,eReplayVDR,eReplayDVD,eReplayMP3} m_eReplay;
  enum  {eDVDNone,eDVDAC3,eDVDDTS,eDVDPCM,eDVDMP2}     m_eDVDAudio;
  enum  {eDVDVideoNone,eDVDVideo4_3,eDVDVideo16_9}     m_eDVDVideo;
  enum  {eMP3Shuffle = 0x0001, eMP3Loop = 0x0002 };
  unsigned int m_nMP3;

  enum  {
    eHasCA         = 0x0001, 
    eHasVpid       = 0x0002,
    eHasDpid       = 0x0004,
    eHasApid       = 0x0008,
    eHasTpid       = 0x0010,
    eIsRadio       = 0x0020,
    eIsSourceSat   = 0x0100,
    eIsSourceCable = 0x0200,
    eIsSourceTerr  = 0x0400,
    eIsSatVPolar   = 0x1000,
    eIsSatHPolar   = 0x2000
  };
  unsigned int m_nChannel;

  bool m_bCutting;
  
  enum {
    eOsdActive        = 0x0001,
    eOsdMessage       = 0x0002,
    eOsdHelpKeyRed    = 0x0010,
    eOsdHelpKeyGreen  = 0x0020,
    eOsdHelpKeyYellow = 0x0040,
    eOsdHelpKeyBlue   = 0x0080
  };
  unsigned int m_nOsdMode;
protected:
  bool ShouldOn(int nModes) const;
public:  
  void Recording(const cDevice *pDevice, const char *szName, const char *szFileName, bool bOn);
  void Replaying(const cControl *pControl, const char *szName, const char *szFileName, bool bOn);
  void Channel(int nChannelNumber);
  void Update(bool bForce, unsigned int nMSDelay = 200);
//AUDIO/////////////////////////////////////////////////////////////////////////
private:
  static const char * m_szAnalog[2];
  static const char * m_szDigital[2];
  static const char * m_szAnalogAndDigital[2];
  int   m_nLastVolume;
protected:
  bool IsMute(void) const { return 0 == m_nLastVolume;}
  void SendMute(unsigned int nMuteMode,bool bMute);
public:
  bool Volume(int nVolume, bool bAbsolute);
  void StatusMessage(const char *szMessage);  
  void OsdHelpKeys(bool bRed, bool bGreen, bool bYellow, bool bBlue, unsigned int nMSDelay);
  void OsdActive(bool bActive, unsigned int nMSDelay);
///////////////////////////////////////////////////////////////////////////////
public:  
  cExtBoardIO();
};

#endif  //___LEDS_EXTB_H___
