#ifndef AEEMPCTL_H
#define AEEMPCTL_H

/*============================================================================
FILE: AEEMpCtl.h

SERVICES:  BREW Interactive Multimedia Player Services

DESCRIPTION:
   This file defines an abstract interface for BREW Interactive Multimedia Player.

PUBLIC CLASSES:  Not Applicable

INITIALIZATION AND SEQUENCING REQUIREMENTS:  Not Applicable

============================================================================*/
/*===============================================================================
    INCLUDES AND VARIABLE DEFINITIONS
===============================================================================*/
/*-------------------------------------------------------------------
      Include Files
-------------------------------------------------------------------*/
#include "AEE.h"

/*-------------------------------------------------------------------
      Defines
-------------------------------------------------------------------*/

/*-------------------------------------------------------------------
      Type Declarations
-------------------------------------------------------------------*/
// Define interface pointers
typedef struct _IMPCtl    IMPCtl;

//===============================================================================
// FUNCTION DECLARATIONS and INLINE FUNCTION DEFINITIONS
//===============================================================================
//
// Command codes
//
// Command code is returned via registered callback function to
// indicate event type and to return data to client.
// AEEMpCtlCmdNotify::nCmd in the callback function contains the following
// command codes.
#define AEE_MPCTL_CMD_BASE             1      // Command base used by IMPCtl
#define AEE_MPCTL_CMD_USER_BASE        0x100  // Command base for derived class

#define AEE_MPCTL_CMD_SETMEDIAPARM     (AEE_MPCTL_CMD_BASE + 1)  // SetMediaParm()
#define AEE_MPCTL_CMD_GETMEDIAPARM     (AEE_MPCTL_CMD_BASE + 2)  // GetMediaParm()
#define AEE_MPCTL_CMD_PLAY             (AEE_MPCTL_CMD_BASE + 3)  // Play()
#define AEE_MPCTL_CMD_NOTIFY           (AEE_MPCTL_CMD_BASE + 4)  // PlayControl()


//
// Status codes
//
// Status code is returned via registered callback function to
// indicate event status and to return data to client.
// AEEMpCtlCmdNotify::nStatus in the callback function contains the following
// command codes.
//
#define AEE_MPCTL_STATUS_BASE           1      // Status used by IMPCtl
#define AEE_MPCTL_STATUS_USER_BASE      0x100  // Status base for derived class

#define AEE_MPCTL_STATUS_START          (AEE_MPCTL_STATUS_BASE+1)   // [Play] Playback has started
#define AEE_MPCTL_STATUS_DONE           (AEE_MPCTL_STATUS_BASE+2)   // [All cmd] Command completed
#define AEE_MPCTL_STATUS_PAUSE          (AEE_MPCTL_STATUS_BASE+3)   // [Play] Playback paused
#define AEE_MPCTL_STATUS_RESUME         (AEE_MPCTL_STATUS_BASE+4)   // [Play] Playback resumed
#define AEE_MPCTL_STATUS_FORWARD        (AEE_MPCTL_STATUS_BASE+5)   // [Play] FastForward has started
#define AEE_MPCTL_STATUS_REWIND         (AEE_MPCTL_STATUS_BASE+7)   // [Play] Rewind has started
#define AEE_MPCTL_STATUS_SEEK           (AEE_MPCTL_STATUS_BASE+9)   // [Play] Playback seek done
#define AEE_MPCTL_STATUS_TICK_UPDATE    (AEE_MPCTL_STATUS_BASE+10)  // [Play] Playback tick update
#define AEE_MPCTL_STATUS_ABORT          (AEE_MPCTL_STATUS_BASE+11)  // [All cmd] Command aborted


//
// Media Control Parms
//
// Set/Get IMPCTL parms using IMPCTL_SetMediaParm()/IMPCTL_GetMediaParm().
// Setting/Getting media parms may result in async callback events. If
// this happens, then function will return MM_PENDIG status.
// In the callback, AEEMpCtlCmdNotify struct contains the following info:
//    nCmd     = AEE_MPCTL_CMD_SETMEDIAPARM/AEE_MPCTL_CMD_GETMEDIAPARM
//    nSubCmd  = AEE_MPCTL_PARM_XXXX (defined below)
//    nStatus  = AEE_MPCTL_STATUS_DONE/AEE_MPCTL_STATUS_ABORT
//    pCmdData = <context sensitive data> for AEE_MPCTL_STATUS_DONE / NULL for AEE_MPCTL_STATUS_ABORT
//    dwSize   = size of pCmdData for AEE_MPCTL_STATUS_DONE / 0 for AEE_MPCTL_STATUS_ABORT
//
#define AEE_MPCTL_PARM_MEDIA_DATA      0x00000001
#define AEE_MPCTL_PARM_VOLUME          0x00000002
#define AEE_MPCTL_PARM_MUTE            0x00000004
#define AEE_MPCTL_PARM_DEVICE          0x00000008
#define AEE_MPCTL_PARM_SURROUND        0x00000010
#define AEE_MPCTL_PARM_EQUALIZER       0x00000020
#define AEE_MPCTL_PARM_BASS            0x00000040
#define AEE_MPCTL_PARM_KEY_TONE        0x00000080
/*  PTX808 Add by Yin.R.F for SimplePlayer [B]  */
#define AEE_MPCTL_PARM_REPT            0X00000100
#define AEE_MPCTL_PARM_RANDOM          0x00000200
/*  PTX808 Add by Yin.R.F for SimplePlayer [E]  */
/*  PTX808 Add by Yu Ning for back to desktop [S]  */
#define AEE_MPCTL_PARM_BTDESKTOP	   0x00000400
/*  PTX808 Add by Yu Ning for back to desktop [E]  */

/* [PTX808_BrewAVOEM] Du Yu Added 2006/1/29 [S]*/
// For IMP App to suspend after started by simple player
#define AEE_MPCTL_PARM_SUSPEND	(0x00000800)
/* [PTX808_BrewAVOEM] Du Yu Added 2006/1/29 [E]*/

/*  PTX808 Add by Yin.R.F [S]  */
#define AEE_MPCTL_PARM_HIGHPITCHEDSOUNDCORRECTION    0x00001000
/*  PTX808 Add by Yin.R.F [E]  */

//
// Media States
//
#define AEE_MPCTL_STATE_IDLE            0                            // Initial state. Media needs to acquire AEEMediaData
#define AEE_MPCTL_STATE_READY           (AEE_MPCTL_STATE_IDLE  + 1)  // Ready state. Media acquired AEEMediaData
#define AEE_MPCTL_STATE_PLAY            (AEE_MPCTL_STATE_IDLE  + 2)  // Playback in progress
#define AEE_MPCTL_STATE_PLAY_PAUSE      (AEE_MPCTL_STATE_IDLE  + 3)  // Playback paused


//
// Media States
//
#define AEE_MPCTL_NOTIFY_BASE           1
#define AEE_MPCTL_NOTIFY_USER_BASE      0x100

#define AEE_MPCTL_NOTIFY_CMD_PLAY       (AEE_MPCTL_NOTIFY_BASE+1)
#define AEE_MPCTL_NOTIFY_CMD_STOP       (AEE_MPCTL_NOTIFY_BASE+2)
#define AEE_MPCTL_NOTIFY_CMD_CLOSE_APP  (AEE_MPCTL_NOTIFY_BASE+3)
#define AEE_MPCTL_NOTIFY_MANNER         (AEE_MPCTL_NOTIFY_BASE+4)
#define AEE_MPCTL_NOTIFY_CMD_VOLUME     (AEE_MPCTL_NOTIFY_BASE+5)
#define AEE_MPCTL_NOTIFY_EARPHONE       (AEE_MPCTL_NOTIFY_BASE+6)
#define AEE_MPCTL_NOTIFY_CMD_FORWARD    (AEE_MPCTL_NOTIFY_BASE+7)
#define AEE_MPCTL_NOTIFY_CMD_REWIND     (AEE_MPCTL_NOTIFY_BASE+8)
#define AEE_MPCTL_NOTIFY_KEY_CENTER     (AEE_MPCTL_NOTIFY_BASE+9)
#define AEE_MPCTL_NOTIFY_CMD_DISABLE    (AEE_MPCTL_NOTIFY_BASE+10)
#define AEE_MPCTL_NOTIFY_CMD_ENABLE     (AEE_MPCTL_NOTIFY_BASE+11)
#define AEE_MPCTL_NOTIFY_CMD_PREV_DATA  (AEE_MPCTL_NOTIFY_BASE+12)
#define AEE_MPCTL_NOTIFY_CMD_NEXT_DATA  (AEE_MPCTL_NOTIFY_BASE+13)
#define AEE_MPCTL_NOTIFY_CMD_REPEAT     (AEE_MPCTL_NOTIFY_BASE+14)
#define AEE_MPCTL_NOTIFY_CMD_RANDOM     (AEE_MPCTL_NOTIFY_BASE+15)
#define AEE_MPCTL_NOTIFY_CMD_PAUSE      (AEE_MPCTL_NOTIFY_BASE+16)
#define AEE_MPCTL_NOTIFY_CMD_RESUME     (AEE_MPCTL_NOTIFY_BASE+17)


//
// Mute
//
#define AEE_MPCTL_MUTE_OFF            FALSE
#define AEE_MPCTL_MUTE_ON             TRUE

//
// Deviece Type
//
#define AEE_MPCTL_DEVICE_UNKNOWN            0x00000000  // Unknown device
#define AEE_MPCTL_DEVICE_HANDSET            0x00000001  // Handset
#define AEE_MPCTL_DEVICE_HFK                0x00000002  // Hands Free Kit (HFK)
#define AEE_MPCTL_DEVICE_HEADSET            0x00000004  // Headset
#define AEE_MPCTL_DEVICE_AHFK               0x00000008  // Analog HFK
#define AEE_MPCTL_DEVICE_SDAC               0x00000010  // Stereo DAC
#define AEE_MPCTL_DEVICE_TTY_HFK            0x00000020  // TTY HFK
#define AEE_MPCTL_DEVICE_TTY_HEADSET        0x00000040  // TTY Headset
#define AEE_MPCTL_DEVICE_CURRENT            0x00000080  // Currently selected device
#define AEE_MPCTL_DEVICE_SPEAKER            0x00000100  // Built-In Speaker device


//
// Seek Type
//
#define AEE_MPCTL_SEEK_CURRENT            0
#define AEE_MPCTL_SEEK_START             (AEE_MPCTL_SEEK_CURRENT  + 1)
#define AEE_MPCTL_SEEK_END               (AEE_MPCTL_SEEK_CURRENT  + 2)


//
// Key Tone
//
#define AEE_MPCTL_KEY_TONE_ENABLE            FALSE
#define AEE_MPCTL_KEY_TONE_DISABLE           TRUE


//
// Media States
//
enum {
   AEE_MPCTL_FORWARD_OFF = 0,
   AEE_MPCTL_FORWARD_1_ON
};

/*  PTX808 Add by Yin.R.F for SimplePlayer [B]  */
typedef enum
{
    IMP_PLAY_REPEAT,
    IMP_PLAY_REPEAT_ST,
    IMP_PLAY_REPEAT_DEFAULT
}BrewOEM_IMPCTL_RepeatMod;

typedef enum
{
    IMP_PLAY_RANDOM_ON,
    IMP_PLAY_RANDOM_OFF
}BrewOEM_IMPCTL_RandomMod;
/*  PTX808 Add by Yin.R.F for SimplePlayer [E]  */

//
// Media States
//
enum {
   AEE_MPCTL_REWIND_OFF = 0,
   AEE_MPCTL_REWIND_1_ON
};


// IMPCTL Initialization.
extern void IMPCTL_Init(IShell * ps);
// Constructor and destructor
extern int IMPCTL_New(IShell * ps, AEECLSID cls, void ** ppif);

typedef struct _AEEMPCtlCmdNotify
{
   IMPCtl *    pIMPCtl;    // Pointer to IMPCtl
   int         nCmd;       // Command code
   int         nSubCmd;    // Sub command code, if any or 0
   int         nStatus;    // Status code
   void *      pCmdData;   // Contains one of the values listed above
   uint32      dwSize;     // Size of pCmdData

} AEEMPCtlCmdNotify;

typedef void (*PFNMPCTLNOTIFY)(void * pUser, AEEMPCtlCmdNotify * pCmdNotify);

typedef struct _AEEMPCtlSurroundInfo {
   int       nItem;
   char   ** pName;
} AEEMPCtlSurroundInfo;


typedef struct _AEEMPCtlEqualizerInfo {
   int       nItem;
   char   ** pName;
} AEEMPCtlEqualizerInfo;


typedef struct _AEEMPCtlBassInfo {
    int       nItem;
    char   ** pName;
} AEEMPCtlBassInfo;

/*  PTX808 Add by Yin.R.F [S]  */
typedef struct _AEEMPCtlHighPitchedSoundCorrectionInfo {
    int       nItem;
    char   ** pName;
} AEEMPCtlHighPitchedSoundCorrectionInfo;
/*  PTX808 Add by Yin.R.F [E]  */


typedef struct _AEEMPCtlDeviceInfo {
   uint32                         dwParm;
   uint32                         dwDevice;
   uint16                         wVolLevel;
   AEEMPCtlSurroundInfo   *       pSurround;
   AEEMPCtlEqualizerInfo  *       pEqualizer;
   AEEMPCtlBassInfo       *       pBass;
   AEEMPCtlHighPitchedSoundCorrectionInfo*  pHighPitchedSoundCorrection;
   boolean                        bLargeStorage;
} AEEMPCtlDeviceInfo;


typedef struct _AEEMPCtlSeekInfo {
    int    nPosition;
    int32  nSeekTime;
} AEEMPCtlSeekInfo;

// IMPCtl Initialization.
extern void IMPCtl_Init (IShell * ps);
// Constructor and destructor
extern int  IMPCtl_New  (IShell * ps, AEECLSID cls, void ** ppif);


//-------------------------------------------------------------------
// Interface Definitions - C Style
//-------------------------------------------------------------------
/*===========================================================================

                      IEXTDISPCTL INTERFACE

===========================================================================*/
#define INHERIT_IMPCtl(iname) \
   INHERIT_IBase(iname);\
   \
   int               (*RegisterNotify)(iname * po, PFNMPCTLNOTIFY pfnNotify, void * pUser);\
   \
   int               (*GetDeviceInfo)(iname * po, AEEMPCtlDeviceInfo ** ppDeviceInfo);\
   \
   int               (*SetMediaParm)(iname * po, int32 nParamID, int32 p1, int32 p2);\
   int               (*GetMediaParm)(iname * po, int32 nParamID, int32 * pP1, int32 * pP2);\
   \
   int               (*GetState)(iname * po, boolean * pbnStateChanging);\
   \
   int               (*Play)(iname * po);\
   int               (*Stop)(iname * po);\
   int               (*Pause)(iname * po);\
   int               (*Resume)(iname * po);\
   int               (*Seek)(iname * po, AEEMPCtlSeekInfo * pSeekInfo);\
   int               (*PlayForward)(iname * po, int nFoward);\
   int               (*PlayRewind)(iname * po, int nRewind);\
   \
   int               (*PlayBGM)(iname * po);\
   int               (*PlayControl)(iname * po, boolean bStop);\
   int               (*ControlNotify)(iname * po, boolean bResult)

QINTERFACE(IMPCtl)
{
   INHERIT_IMPCtl(IMPCtl);
};

#define IMPCTL_AddRef(p)                          GET_PVTBL(p, IMPCtl)->AddRef(p)
#define IMPCTL_Release(p)                         GET_PVTBL(p, IMPCtl)->Release(p)

#define IMPCTL_RegisterNotify(p, f, pd)           GET_PVTBL(p, IMPCtl)->RegisterNotify(p, f, pd)

#define IMPCTL_GetDeviceInfo(p, ppd)              GET_PVTBL(p, IMPCtl)->GetDeviceInfo(p, ppd)

#define IMPCTL_SetMediaParm(p, c, p1, p2)         GET_PVTBL(p, IMPCtl)->SetMediaParm(p, c, p1, p2)
#define IMPCTL_GetMediaParm(p, c, pp1, pp2)       GET_PVTBL(p, IMPCtl)->GetMediaParm(p, c, pp1, pp2)

#define IMPCTL_GetState(p, pb)                    GET_PVTBL(p, IMPCtl)->GetState(p, pb)

#define IMPCTL_Play(p)                            GET_PVTBL(p, IMPCtl)->Play(p)
#define IMPCTL_Stop(p)                            GET_PVTBL(p, IMPCtl)->Stop(p)
#define IMPCTL_Pause(p)                           GET_PVTBL(p, IMPCtl)->Pause(p)
#define IMPCTL_Resume(p)                          GET_PVTBL(p, IMPCtl)->Resume(p)
#define IMPCTL_Seek(p, s)                         GET_PVTBL(p, IMPCtl)->Seek(p, s)
#define IMPCTL_PlayForward(p, c)                  GET_PVTBL(p, IMPCtl)->PlayForward(p, c)
#define IMPCTL_PlayRewind(p, c)                   GET_PVTBL(p, IMPCtl)->PlayRewind(p, c)

#define IMPCTL_PlayBGM(p)                         GET_PVTBL(p, IMPCtl)->PlayBGM(p)
#define IMPCTL_PlayControl(p, b)                  GET_PVTBL(p, IMPCtl)->PlayControl(p, b)
#define IMPCTL_ControlNotify(p, b)                GET_PVTBL(p, IMPCtl)->ControlNotify(p, b)

// Commonly used API to set/get IMPCTL parm
#define IMPCTL_SetMediaData(p, p1)                IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_MEDIA_DATA, (int32)(p1), 0)
#define IMPCTL_GetMediaData(p, pP1)               IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_MEDIA_DATA, (int32 *)(pP1), 0)

#define IMPCTL_SetVolume(p, w)                    IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_VOLUME, (int32)(w), 0)
#define IMPCTL_GetVolume(p, pw)                   IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_VOLUME, (int32 *)(pw), 0)

#define IMPCTL_SetMute(p, b)                      IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_MUTE, (int32)(b), 0)
#define IMPCTL_GetMute(p, pb)                     IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_MUTE, (int32 *)(pb), 0)

#define IMPCTL_SetDevice(p, w)                    IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_DEVICE, (int32)(w), 0)
#define IMPCTL_GetDevice(p, pw)                   IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_DEVICE, (int32 *)(pw), 0)

#define IMPCTL_SetSurround(p, w)                  IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_SURROUND, (int32)(w), 0)
#define IMPCTL_GetSurround(p, pw)                 IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_SURROUND, (int32 *)(pw), 0)

#define IMPCTL_SetEqualizer(p, w)                 IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_EQUALIZER, (int32)(w), 0)
#define IMPCTL_GetEqualizer(p, pw)                IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_EQUALIZER, (int32 *)(pw), 0)

#define IMPCTL_SetBass(p, w)                      IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_BASS, (int32)(w), 0)
#define IMPCTL_GetBass(p, pw)                     IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_BASS, (int32 *)(pw), 0)

// [PTX808_IMPAPP] Yu Ning 2006/02/16 Added [S]
#define IMPCTL_SetHighPitchedSoundCorrection(p, w)     IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_HIGHPITCHEDSOUNDCORRECTION, (int32)(w), 0)
#define IMPCTL_GetHighPitchedSoundCorrection(p, pw)    IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_HIGHPITCHEDSOUNDCORRECTION, (int32 *)(pw), 0)
// [PTX808_IMPAPP] Yu Ning 2006/02/16 Added [E]

#define IMPCTL_SetKeyTone(p, b)                   IMPCTL_SetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_KEY_TONE,(int32)(b), 0)
#define IMPCTL_GetKeyTone(p, pb)                  IMPCTL_GetMediaParm((IMPCtl *)(p), AEE_MPCTL_PARM_KEY_TONE,(int32 *)(pb), 0)



#endif // AEEMPCTL_H
