#ifndef _OEMMPCTL_H_
#define _OEMMPCTL_H_
/******************************************************************************

   Copyright (c) 2005 by Sony Ericsson Mobile Communications(J).
                                            All Rights Reserved.

    [FileName]       OEMMPCtl.h

    [Outline]        OEMMPCtl define 

    [Author]         Zeyan Lu(NEU)
	
    [history]		05/18/05	Zeyan Lu(NEU)	ﾂ作・

******************************************************************************/
#include "ApiMultiMedia.h"
#include "AEE.h"
#include "AEE_OEM.h"

#include "ApiDlink.h"

//#ifdef ON
//	#undef ON
//#endif

//#ifdef OFF
//	#undef OFF
//#endif

#include "AEEMPCtl.h"
#include "BrewLogger.h"

//add by yinrf 2005/09/12
#include "OEMMpUtilAPI.h"
//end add by yinrf 2005/09/12

#ifndef WIN32
#include "Msg.h"
#endif

/*   add by Yin.R.F for OEM Log 2005/10/13 start   */
#ifndef WIN32
#include "..\..\src\dmss\siodef.h"
#endif//  defined win32
/*   add by Yin.R.F for OEM Log 2005/10/13 end   */

/*- 051004 --- Edit For UIQ7 by wangwb-- start --*/

/*  2005/10/06 change by yinrf for TRK NO. 195 start  */
//#include "KDDIAPPSTATE.BID"
#include "KDDICLSID_APPSTATE.BID"
/*  2005/10/06 change by yinrf for TRK NO. 195 end   */

/* [PTX808_BrewAVOEM] Du Yu Added 2006/2/1 [S]*/
#include "ApiBrewIMPCtl.h"
/* [PTX808_BrewAVOEM] Du Yu Added 2006/2/1 [E]*/


#include "IKDDIAPPSTATE.h"
/*- 051004 --- Edit For UIQ7 by wangwb-- start --*/
/*-------------------------------------------------------------------
      Type Declarations
-------------------------------------------------------------------*/
typedef struct _AEEMPCTLCallback
{
   int                  bInUse;     //Callback/Command availability
   AEECallback          cb;         //Pre-loaded and does not change
   int                   nCtrlLv;  // OEM control level 0:applet, 1: brew
   AEEMPCtlCmdNotify    cmdNotify;  //Callback cmd info
} AEEMPCTLCallback;

//start wwb
typedef enum 
{
   IMP_SEEKSTATE_IDLE,				//seekidle
   IMP_SEEKSTATE_START,				//seekstart
   IMP_SEEKSTATE_SEEKING			//seek in process
} SeekState;

/*- 050905 --- ADD For FF/REW -- Start --*/
typedef enum
{
    IMP_FFSTATE_FORWARDING,
		IMP_REWSTATE_REWINDING,  
		IMP_FFREWSTATE_READY
} FfRewState;
/*- 050905 --- ADD For FF/REW -- END --*/
//end wwb
/*050909 add for Competition Chiang  Start*/
typedef enum 
{
   IMP_COMPETITIONSTATE_IDLE,     //No Competition
   IMP_COMPETITIONSTATE_SUSPENDREQ,    //Requset to Suspend 
   IMP_COMPETITIONSTATE_SUSPENDING,    //Suspending
IMP_COMPETITIONSTATE_RESUMEREQ,       //Request to Resume
IMP_COMPETITIONSTATE_RESUMING   //Resuming
} CompetitionState;

typedef enum 
{
   IMP_CONTROLNOTIFYSUSPEND_IDLE,     //Normal IMP has not receive ControlNotify 
   IMP_CONTROLNOTIFYSUSPEND_NORMAL_STAY,     //Normal IMP has been notifyed to Suspend and waiting Normal IMP's answer 
   IMP_CONTROLNOTIFYSUSPEND_NORMAL_SUSPEND_DONE    //Normal IMP Suspend Success 
} ControlNotifySuspendState;
/*050909 add for Competition Chiang End*/

/*TRK3161 added by tianye [S] */
typedef struct
{
	char m_FileName[DLINK_FILENAME_MAX + 1];
	uint32 nFileSize;
}_S_CheckFileExist;
/*TRK3161 added by tianye [E] */

/*  PTX808 Add by Yin.R.F [B]  */
typedef enum
{
    FF_REQ,
    REW_REQ,
    DEFAULT_REQ
}FF_REW_REQ;

/* [PTX808_BrewAVOEM] Du Yu deleted 2006/02/03 [S]*/
// Move the definition to the ApiBrewIMPCtl.h
//typedef struct _IMPINSTANCEPARMS
//{
//    uint16           nVolum;
//    unsigned long    totalTime;
//    BrewOEM_IMPCTL_RepeatMod    repeatMod;
//    BrewOEM_IMPCTL_RandomMod    randomMod;
//}IMPInstanceParms;
/* [PTX808_BrewAVOEM] Du Yu deleted 2006/02/03 [E]*/

/*  PTX808 Add by Yin.R.F [E]  */



/*-------------------------------------------------------------------
      Macros Declarations
-------------------------------------------------------------------*/
//#define  IMPCTL_DEBUG
//#define  IMPCTL_BREWLOG

#ifdef IMPCTL_DEBUG

#ifdef IMPCTL_BREWLOG

/*  add by Yin.R.F for OEM Log 2005/10/13 Start     */
//#define IMPCTL_LOG(a,b,c,d) BREWLOG_OEM_MED(a,b,c,d)
#ifndef WIN32
#define IMPCTL_LOG(a,b,c,d) ( MSG_SP1(a,b,c,d),MSG_SP1("\n\r",0,0,0) )
#else
#define IMPCTL_LOG(a,b,c,d)
#endif
/*  add by Yin.R.F for OEM Log 2005/10/13 End      */

#else 
#define IMPCTL_LOG(a,b,c,d) MSG_HIGH(a,b,c,d) 
#endif

#endif

/*  add by Yin.R.F for OEM Layer 2005/10/13 Start   */
//#define	_OEM_Sequence
#if defined _OEM_Sequence

  #ifndef WIN32
    #define BREW_OEM_LAYER_HIGHLOG(a,b,c,d) MSG_HIGH(a,b,c,d)     
    #define BREW_OEM_LAYER_ERR_LOG(a,b,c,d) ERR(a,b,c,d)
    #define BREW_OEM_LAYER_LOG(a,b,c,d)     (MSG_SP1(a,b,c,d),MSG_SP1("\n\r",0,0,0))
  #else
    #define BREW_OEM_LAYER_LOG(a,b,c,d)
    #define BREW_OEM_LAYER_ERR_LOG(a,b,c,d)
    #define BREW_OEM_LAYER_HIGHLOG(a,b,c,d)
  #endif
#else
  #define BREW_OEM_LAYER_LOG(a,b,c,d)
  #define BREW_OEM_LAYER_ERR_LOG(a,b,c,d)
  #define BREW_OEM_LAYER_HIGHLOG(a,b,c,d)
#endif
/*  add by Yin.R.F for OEM Layer 2005/10/13 End     */

#define OEMMPCTL_MAX_CB_PLAY             			6		// simultaneous play cbs 
#define OEMMPCTL_MAX_CB_GETMEDIAPARM				2		// simultaneous parm get cbs 
#define OEMMPCTL_MAX_CB_SETMEDIAPARM				2		// simultaneous parm set cbs 
/*edit by wangwb for PTX805 TRK2613 20051202 [S]*/
//#define OEMMPCTL_MAX_CB_NOTIFY						2		// simultaneous parm set cbs 
#define OEMMPCTL_MAX_CB_NOTIFY						10		// simultaneous parm set cbs 
/*edit by wangwb for PTX805 TRK2613 20051202 [E]*/

#define OEMMPCTL_IsIdleState(p)             ((p)->m_nState == AEE_MPCTL_STATE_IDLE)
#define OEMMPCTL_IsReadyState(p)            ((p)->m_nState == AEE_MPCTL_STATE_READY)
#define OEMMPCTL_IsPlayState(p)             ((p)->m_nState == AEE_MPCTL_STATE_PLAY)
#define OEMMPCTL_IsPlayPauseState(p)        ((p)->m_nState == AEE_MPCTL_STATE_PLAY_PAUSE)
#define OEMMPCTL_IsStateChanging(p)         ((p)->m_bStateChanging)
#define OEMMPCTL_IsStatePauseOrResume(p)    ((p)->m_bStatePauseOrResume)
#define OEMMPCTL_IsPlayOn(p)                (OEMMPCTL_IsPlayState(p) || OEMMPCTL_IsPlayPauseState(p))
#define OEMMPCTL_IsSetInvalid(p)         (OEMMPCTL_IsPlayState(p) || OEMMPCTL_IsPlayPauseState(p) || (OEMMPCTL_IsReadyState(p) && OEMMPCTL_IsStateChanging(p)))
#define OEMMPCTL_IsPlayNormal(p)  ( ((p)->m_eCompetitionState == IMP_COMPETITIONSTATE_IDLE)&&( (p)->m_eControlNotifySuspend == IMP_CONTROLNOTIFYSUSPEND_IDLE))

#define CBLEVELBREW  0
#define CBLEVELOEM   1

/*******************************************************************/
/*                      add by yinrf 2005/09/10                    */
/*******************************************************************/
#define IMP_NORMAL_INSTANCE         0
#define OEMIMP_MAX_INSTANCE         2


typedef struct _OEMMPCTL 
{
    const VTBL(IMPCtl)*  pvt;

    AEECallback          m_cbSysObj; 			//AEEイベント通知用コールバック関数
    void*                m_pac;					// point to App Context
   
    uint32               m_nRefs;	    		// 参照カウンタ
    IShell*              m_pIShell;				// IShell Instance
    AEECLSID             m_clsSelf; 			//ClassＩＤ

    int                  m_nState;				//処理ステータス
    boolean              m_bStateChanging;		//処理ステータス
    boolean              m_bStatePauseOrResume; //Pause Or Resume のフラグ
    SeekState			 m_eSeekState;			//Seek の State
	/*050908 del 4 Competition Chiang Start*/
	CompetitionState m_eCompetitionState;//Competitionの state
	ControlNotifySuspendState m_eControlNotifySuspend;//ControlNotifySuspendの state
	/*050908 del 4 Competition Chiang End*/  
	boolean				 m_bBGM;				//BGM再生のフラグ
    boolean				 m_bReleaseCMD;			//リリースコマンドフラグ
    boolean				 m_bUserAbort;			//user stopコマンドフラグ
	boolean				 m_bUserstart;			//user startコマンドフラグ
    PFNMPCTLNOTIFY       m_pfnNotify;			//イベント通知用コールバック関数ポインタ
    void *               m_pUser;				//コールバック関数に渡されるユーザーデータのポインタ

    ST_MEDIA_RESOURCE	 res;					//現在の使用のリソースファイル

    AEEMPCTLCallback	m_cbPlay[OEMMPCTL_MAX_CB_PLAY];					//再生時のコールバック情報(ステータス、データサイズ等)を格納する変数
    AEEMPCTLCallback	m_cbGetMediaParm[OEMMPCTL_MAX_CB_GETMEDIAPARM];	//GetMediaParm時のコールバック情報を格納する変数
    AEEMPCTLCallback	m_cbSetMediaParm[OEMMPCTL_MAX_CB_SETMEDIAPARM];	// SetMediaParm時のコールバック情報を格納する変数
    AEEMPCTLCallback	m_cbNotify[OEMMPCTL_MAX_CB_NOTIFY];				//Notify時のコールバック情報を格納する変数
	
	uint16				m_CurrentVolume;		//現在のボリューム
   //uint16				m_CurrentDevice;		//現在の再生デバイス//Chiang Del for TRK 2295 051122
	boolean				m_CurrentMute;			//現在のミュート可否
	uint16				m_CurrentSurround;		//現在のサラウンド設定
	uint16				m_CurrentEqualizer;		//現在のコライザーの設定
	uint16				m_CurrentBass;			//現在の低音設定
	uint16				m_CurrentKeyTone;		//現在のkey音の設定
	AEEMPCtlSeekInfo	m_CurrentSeekInfo;		//現在のseek infoの設定
	uint32				m_CurrentType;			//現在のメディア―ファイル種別
	uint32				m_CurrentSize;			//現在のメディア―ファイルサイズ
	uint32				m_CurrentOffset;		//現在の3g2ファイルのオフセット
	uint32				m_CurrentDlinkID;		//現在のDlinkID
	uint32				m_CurrentFormat;		//現在のファイルフォーマット
	void*				m_CurrentpPath;			//現在のファイルパス
	unsigned long	    m_Passtime;

	/*- 050905 --- ADD For FF/REW -- Start --*/
	FfRewState          m_eFfRewState;          //FFREW sub state
    /*- 050905 --- ADD For FF/REW -- END -- */   
  /*- 051004 --- Edit For UIQ7 by wangwb-- start --*/ 
	IKDDIAppState       *m_pIAppState;// applet status
	/*- 051004 --- Edit For UIQ7 by wangwb-- end --*/

	uint8 *             m_pdataBuffer;			//luzy_t 2005/5/21
    uint32              m_pdataSize;			//luzy_t 2005/5/21
	IMPUtil *           m_pmd;					//luzy_t
    //add by yinrf 2005/09/09
    boolean             m_bVolumeUp;
    boolean             m_bVolumeDown;
    boolean             m_bEarPhone;
    /*  modified by Yin.R.F 2005/10/21 Start    */
    //int                 m_nFForREW_ON;
    //int                 m_nFForREW_OFF;
    uint16              m_nFForREW_ON;
    uint16              m_nFForREW_OFF;
    /*  modified by Yin.R.F 2005/10/21 End      */
    boolean             m_bManner;
    boolean           m_bLowBattery;
    boolean           m_bLowBatteryStay;
    //end add by yinrf 2005/09/09
    /*Chiang  4 trk 281  0510112[S]*/
    boolean           m_bPREVDATA;
    /*Chiang  4 trk 281  0510112[E]*/

    /*    I-Share TRK1986 add by Yin.R.F 2005/11/17 [B]    */
    boolean           m_bCloseFlag;
    /*    I-Share TRK1986 add by Yin.R.F 2005/11/17 [E]    */
    
    /*TRK3161 added by tianye [S] */
    _S_CheckFileExist m_stCheckFile; 
    /*TRK3161 added by tianye [E] */

    /*  PTX808 add by Yin.R.F [B]  */
	FF_REW_REQ        m_SaveFfRewREQ;
	boolean           m_bFForRewStartFlg;
    unsigned long     m_TotalTime;
    BrewOEM_IMPCTL_RepeatMod m_repeatMod;
    BrewOEM_IMPCTL_RandomMod m_randomMod;
	/*  PTX808 add by Yin.R.F [E]  */

	/* [PTX808_BrewAVOEM] Du Yu added 2006/2/1 [S]*/
	ST_EVENT_IMP_STATE		m_stIMPPlayStart;				// Struct for informing the start of playing
	ST_EVENT_IMP_STATE		m_stIMPPlayStop;				// Struct for informing the stop of player
	ST_EVENT_IMP_STATE		m_stIMPChangeRandomMode;		// Struct for informing the change of random mode
	ST_EVENT_IMP_STATE		m_stIMPChangeRepeatMode;		// Struct for informing the change of repeat mode
	ST_EVENT_IMP_STATE      m_stIMPChangeVol;
	boolean                 m_bPPActive;
	char                    m_FileTitle[257];
    ST_PPCTRL               m_PP_UseEvent;
    uint16                  m_CurrentHighPitchedSoundCorrection;
    boolean                 m_bUtilApiFlag;
	/* [PTX808_BrewAVOEM] Du Yu added 2006/2/1 [E]*/

} OEMMPCTL;

/*******************************************************************/
/*                  end add by yinrf 2005/09/10                    */
/*******************************************************************/

//**********************************************************************
//	Functions
//**********************************************************************
uint32  OEMMPCTL_AddRef( IMPCtl * pIMPCtl );
uint32  OEMMPCTL_Release( IMPCtl * pIMPCtl );
int OEMMPCTL_Init();
IBase * OEMMPCTL_New(IShell * ps, AEECLSID cls, const void * pVtbl);
int OEMMPCTL_RegisterNotify(IMPCtl * pIMPCtl,PFNMPCTLNOTIFY  pfnNotify,void * pUser );


int OEMMPCTL_GetDeviceInfo( IMPCtl * pIMPCtl, AEEMPCtlDeviceInfo ** ppDeviceInfo );
int OEMMPCTL_SetMediaParm( IMPCtl * pIMPCtl,int32 nParamID,int32 p1,int32 p2 );
int OEMMPCTL_GetMediaParm(IMPCtl * pIMPCtl,int32 nParamID,int32 * pP1,int32 * pP2 );
int OEMMPCTL_GetState( IMPCtl * pIMPCtl, boolean * pbnStateChanging );
int OEMMPCTL_Play( IMPCtl * pIMPCtl );
int OEMMPCTL_Stop( IMPCtl * pIMPCtl );
int OEMMPCTL_Pause( IMPCtl * pIMPCtl );
int OEMMPCTL_Resume( IMPCtl * pIMPCtl );
int OEMMPCTL_Seek( IMPCtl * pIMPCtl, AEEMPCtlSeekInfo * pSeekInfo );
int OEMMPCTL_PlayForward( IMPCtl * pIMPCtl, int nFoward );
int OEMMPCTL_PlayRewind( IMPCtl * pIMPCtl, int nRewind );
int OEMMPCTL_PlayBGM( IMPCtl * pIMPCtl );
int OEMMPCTL_PlayControl( IMPCtl * pIMPCtl, boolean bStop );
int OEMMPCTL_ControlNotify( IMPCtl * pIMPCtl, boolean bResult );

//add by yinrf 2005/09/12
AEEMPCTLCallback * OEMMPCTL_AllocCallback(AEEMPCTLCallback * pcb, int nMax, int nCmd, int nSubCmd);
//end add by yinrf 2005/09/12

/*    I-Share TRK1986 add by Yin.R.F 2005/11/17 [B]    */
void ApiOEMMPCTL_SetCloseFlg(OEMMPCTL* pIMP,boolean parm);
boolean ApiOEMMPCTL_GetCloseFlg(OEMMPCTL* pIMP);
/*    I-Share TRK1986 add by Yin.R.F 2005/11/17 [E]    */

/*  PTX808 Add by Yin.R.F for get file's title [B]  */
int ApiOEMMPCTL_GetFileInfo( IMPCtl * pIMPCtl , void * pInfo );
/*  PTX808 Add by Yin.R.F for get file's title [B]  */

#endif // _OEMMPCTL_H_

