#ifndef _OEMMPUTIL_H_
#define _OEMMPUTIL_H_
/*======================================================
FILE:  OEMMPUtil.h

SERVICES:
   OEM functions for supporting BREW MPUTIL
   Interface

GENERAL DESCRIPTION:
   This file provides the prorotypes of the functions
   that OEMs must provide in order to support the BREW
   MPUTIL interfaces

=====================================================*/
#include "ApiImage.h"
#include "MemMgr.h"
#include "AEE.h"
#include "AEE_OEM.h"
#include "OEMObjectMgr.h"
#include "MPUtil.h"
#include "OEMMPUtilDataCtrl.h"

#define		OEMMPUTIL_MMID_LENGTH	16
#define  	OEMMPUTIL_CB_MAX	12

extern void	OEMMPUTIL_Init			( void );
extern void*	OEMMPUTIL_New			( IMPUtil *pIMPUtil, uint32 *pnErr );
extern void	OEMMPUTIL_Free			( void * po );

extern int	OEMMPUTIL_RegisterNotify	( void * po, PFNMPUTILNOTIFY pfn, void * pUser);
extern int	OEMMPUTIL_SelectData		( void * po,int nSelectID, char* pcData, int* pnDataCount);
extern int	OEMMPUTIL_GetListCount		( void * po,int  nListID, int * pnListCount );
extern int	OEMMPUTIL_GetListData		( void * po,int  nListID, int32* pP1, int32* nP2 );
extern int	OEMMPUTIL_GetData		( void * po,int nDataID, int32* pP1, int32* nP2 );
extern int	OEMMPUTIL_SeekData		( void * po,AEEMPUtilSeekInfo * pSeekInfo );
extern int	OEMMPUTIL_UpdateData		( void * po,int nParamID,int nSetData);
/*@*/extern int	OEMMPUTIL_GetDecodeData		( void * po,AEEMPUtilDecodeDataInfo * pDecodeDataInfo );
extern int	OEMMPUTIL_DeleteData		( void * po );
extern int	OEMMPUTIL_SearchData		( void * po,AEEMPUtilMMID *pMmid, boolean *pbExist );
extern int	OEMMPUTIL_SearchPlayListData	( void * po,AEEMPUtilPlayList * pPlayList,int nListCount );
extern int	OEMMPUTIL_GetPlayListCount	( void * po,int * pnPlayListCount );
extern int	OEMMPUTIL_GetPlayListInfo	( void * po,int nPlayListNum, AEEMPUtilPlayListInfo * pPlayListInfo );
extern int	OEMMPUTIL_SetPlayListData	( void * po,int nPlayListNum,char * pData,
                                                  uint32 dwDataSize, char * pcFileName );
extern int	OEMMPUTIL_GetPlayListData	( void * po,int nPlayListNum,char * pData );
extern int	OEMMPUTIL_SetPlayOrder		( void * po,AEEMPUtilPlayOrder * pOrder );
extern int	OEMMPUTIL_GetLabelCount		( void * po,int  nListID, int nLanguageID, int * pnListCount );
extern int	OEMMPUTIL_GetLabelData		( void * po, int nNum, char* pcData);
extern int	OEMMPUTIL_SearchLabelData	( void * po,char * pcData,int32 * pnSeekData );
extern int	OEMMPUTIL_GetSpace		( void * po,int32 nPlayListNum, uint32 * pdwSize,
                                                  uint32 * pdwFileCount );
extern int	OEMMPUTIL_DeletePlayListData	( void * po, int nPlayListNum );
extern int	OEMMPUTIL_GetMemoryType		( void * po, int * pMemoryType );

extern	void	OEMMPUTIL_MSExtract		( void );

extern	void	OEMMPUTIL_CbInit		( void );
extern	struct _OEMMpUtilCb* OEMMPUTIL_CbAlloc	( void * po );
extern	void	OEMMPUTIL_CbFree		( struct _OEMMpUtilCb *pcb );
extern  void	OEMMPUTIL_CbCancel		( void * po ) ;

// PTX808IMP_MSA mod 2006.1.17 yamamoto 再生状態管理 if1
extern void OEMMPUTIL_SetIsPlay(boolean IsPlay);
extern boolean OEMMPUTIL_GetIsPlay(void);
// PTX808IMP_MSA mod 2006.1.17 yamamoto 再生状態管理 endif
//PTX808_IMP_MSA add 2006.1.19 toida MSAグループ情報 if1
extern int	OEMMPUTIL_GetGroupInfo		( void * po, int nGroupNum, AEEMPUTILGroupInfo * pGroupInfo );
//PTX808_IMP_MSA add 2006.1.19 toida MSAグループ情報 endif

// ************マクロ定義**************
// EBADSTATE対応[S]05.10.16
// ステータスチェック
#define  OEMMPUTIL_STATUS_CHECK() { \
    OEMMPUtil  *_pCtx = gMpUtilList; \
    while ( NULL != _pCtx ) { \
        if ( FALSE != _pCtx->m_bIsPending ) { \
            BREWLOG_OEM_MED("EBADSTATE",0,0,0); \
            return EBADSTATE; \
        } \
        _pCtx = NEXT_NODE( _pCtx ); \
    } \
}
// MM_PENDINGリターン
#define  OEMMPUTIL_MM_PENDING_RETURN(_pCtx) _pCtx->m_bIsPending = TRUE; return MM_PENDING
// 状態クリア
#define  OEMMPUTIL_STATUS_CLEAR(_pCtx) _pCtx->m_bIsPending = FALSE
// EBADSTATE対応[E]05.10.16

// ************型定義**************
// MMID型
typedef char	OEMMPUTIL_MMID[OEMMPUTIL_MMID_LENGTH+1];

// CBデータ型
typedef struct _OEMMpUtilCb {
    boolean       	m_bIsUse;
    AEECallback   	m_cb;
    AEEObjectHandle	m_hObject;
    AEEMPUtilCmdNotify *m_pNotify;
    boolean             m_bCmdDataFree;
} OEMMpUtilCb;

// デコードデータ
typedef struct _OEMMpUtilDecode {
    struct _OEMMpUtilDecode  *m_pPrev;
    struct _OEMMpUtilDecode  *m_pNext;
    
    DECODE_ID                 m_Id;
// PTX805 TRK762[S]
//    void                    * m_pInDataBuff;
    MEM_MGR_ID                m_nInDataId;
    MEM_MGR_ID                m_nOutDataId;
// PTX805 TRK762[E]
    void                    * m_pOutDataBuff;
    AEEObjectHandle           m_hObject;
    AEEMPUtilDecodeDataInfo * m_pDecodeDataInfo;
    RESIZE_BREW               m_Resize;
    long                      m_cbDecodeSize;
    int                       m_cbReason;
} OEMMpUtilDecode;

// MPUTIL OEMコンテキスト型
typedef struct _OEMMPUtil {
    struct _OEMMPUtil *next;

    IMPUtil         * m_pIMPUtil;
    void            * m_pac;   // app context
    AEEObjectHandle   m_hObject;
    
    void  * m_pMMIDList;        // 絞込みMMIDリスト
    int     m_nListNum;         // リスト数
    int     m_nCurrent;         // カレント位置

    S_SelectTable    m_sSelectTable;
    // 2005.09.03 matsumi S_PlayListTable  m_sPlayListTable;
    int              m_nLabelCountID;
    
    PFNMPUTILNOTIFY  m_pfn;
    void           * m_pUser;

    // EBADSTATE対応[S]05.10.16
    boolean          m_bIsPending;
    // EBADSTATE対応[E]05.10.16
    // 805 TRK2720[S]
    boolean          m_IsWaitMSMount; // マウント完了待ち
    // 805 TRK2720[S]
} OEMMPUtil;

#endif // _OEMMPUTIL_H_
