/**
 * @file IDVP2420DecSDK.h DVP2420 Decoding SDK header file
 *
 * @author Ellis Huang
 *
 */

#pragma once

// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the DVP2420DECSDK_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// DVP2420DECSDK_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef DVP2420DECSDK_EXPORTS
#define DVP2420DECSDK_API __declspec(dllexport)
#else
#define DVP2420DECSDK_API __declspec(dllimport)
#endif

typedef enum
{
	DEC_SUCCEEDED		= 1,
	DEC_FAILED			= 0,
	DEC_SDKINITFAILED	= -1,
	DEC_DEVINITFAILED	= -2,
	DEC_PARAMERROR		= -3,
	DEC_CHNUMERROR		= -4,
	DEC_MISSLOGFILE		= -5
} DecRes;

typedef void (*PDECFAILPROC)(int nChNum);	///< The Decoding Failed Process Callback function. This callback function is called when decoding process fails.
typedef void (*PDECENDOFFILEPROC)(int nChNum);	///< The Decoding EOF Process Callback function. This callback function is called when decoding process reaches END_OF_FILE.

/**
 * @brief IDVP2420DecSDK declaration
 *
 * IDVP2420DecSDK : About the implement, please refelence DVP2420DecSDK.cpp.
 *
 */
class DVP2420DECSDK_API IDVP2420DecSDK {
public:

	/**
	* @brief This function creates SDK instance.
	*
	* @param pp A pointer to the SDK instance.
	*
	* @return If function succeeded, function returns DEC_SUCCEEDED.
	*/
	virtual int DVP2420_CreateDecSDKInstence(void **pp);

	/**
	 * @brief This function initializes the SDK. This function must be called before other functions of the SDK.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_InitSDK() PURE;

	/**
	 * @brief This function closes up the SDK.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_CloseSDK() PURE;

	/**
	 * @brief This function initializes the chip on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_InitChips(int nChNum) PURE;

	/**
	 * @brief This function releases the chip on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_ReleaseChips(int nChNum) PURE;

	/**
	 * @brief This function gets the number of the chips. Two firmware files boot.sre and pscodec.sre will be used 
	 *		  by the library. Notes: Don't download the firmware into the chip when the encoding process is running in the chip.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_DownloadFW(int nChNum) PURE;

	/**
	 * @brief This function gets the number of the chips.
	 *
	 * @param pChipCnt An integer pointer to store the returned number of the chips.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int	DVP2420_GetChipCount(int *pChipCnt) PURE;

	/**
	 * @brief This function gets the version of the SDK.
	 *
	 * @return If function succeeded, funtion returns the version of the SDK. Otherwise, function returns -1.
     */
	virtual float DVP2420_GetSDKVersion() PURE;

	/**
	 * @brief This function starts to decode the video on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param lpcsFileName A NULL-terminated string for the decoded file name.
	 * @param hWnd Specifies the window handle of the display area.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_StartDecode(int nChNum, LPCSTR lpcsFileName, HWND hWnd) PURE;

	/**
	 * @brief This function stops to decode the video on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_StopDecode(int nChNum) PURE;

	/**
	 * @brief This function sets the video signal type for decoding.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param nSignalType A value to set the video signal type. (1: PAL, 2: NTSC)
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_SetSignalType(int nChNum, int nSignalType) PURE;

	/**
	 * @brief  This function sets the video MPEG standard for decoding.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param nMPEGType A value to set the video MPEG standard. (1: MPEG1, 2: MPEG2, 4: MPEG4)
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_SetMPEGType(int nChNum, int nMPEGType) PURE;

	/**
	 * @brief  This function gets the video resolution. The function only supports MPEG2 and MPEG4 file.
	 *
	 * @param lpcsFileName A NULL-terminated string for the decoded file name.
	 * @param pWidth An integer pointer to store the returned width of the video.
	 * @param pHeight An integer pointer to store the returned height of the video.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_GetVideoResolution(LPCSTR lpcsFileName, int *pWidth, int *pHeight) PURE;

	/**
	 * @brief  This function pauses or continues to play the video.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_Pause(int nChNum) PURE;

	/**
	 * @brief  This function speeds up to play the video. The function doubles the speed by one time, 3 times at most.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_Fast(int nChNum) PURE;

	/**
	 * @brief  This function rewinds to play the video. The function doubles the speed by one time, 3 times at most.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_Rewind(int nChNum) PURE;

	/**
	 * @brief  This function steps forward one frame of the video.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_SingleStep(int nChNum) PURE;

	/**
	 * @brief  This function seeks the video to the specified video file time.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_SetPlayPos(int nChNum, ULONG64 ulRefTime) PURE;

	/**
	 * @brief  This function gets the current frame number.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param pCurFrameNum An integer pointer to store the returned frame number.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_GetCurrentFrameNum(int nChNum, int *pCurFrameNum) PURE;

	/**
	 * @brief  This function gets the number of the total frames in the video file.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param pTotalFrame An integer pointer to store the returned number of the total frames.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_GetFileTotalFrames(int nChNum, int *pTotalFrame) PURE;

	/**
	 * @brief  This function gets the current played time of the video.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param lpPlayedTime A pointer to store the returned current video time.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_GetPlayedTime(int nChNum, ULONG64 *lpPlayedTime) PURE;

	/**
	 * @brief  This function gets the video file time.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param lpFileTime A pointer to store the returned video file time.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_GetFileTime(int nChNum, ULONG64 *lpFileTime) PURE;

	/**
	 * @brief This function registers the DecEndOfFile callback function.
	 *
	 * @param pDecEndOfFile A function pointer of the DecEndOfFile callback function.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_RegDecEndOfFileCB(PDECENDOFFILEPROC pDecEndOfFile) PURE;

	/**
	 * @brief This function registers the DecFail callback function.
	 *
	 * @param pDecFail A function pointer of the DecFail callback function.
	 *
	 * @return If function succeeded, function returns DEC_SUCCEEDED.
     */
	virtual int DVP2420_RegDecFailCB(PDECFAILPROC pDecFail) PURE;
};
