#ifndef _CUDACOREAPI_H_
#define _CUDACOREAPI_H_

#include "libvautil.h"
#include "CudaCoreTypes.h"

typedef int (*pCudaCoreStartup)();
typedef int (*pCudaCoreCleanup)();
typedef int (*pCudaCoreGetGpuCount)();
typedef CudaCoreContext (*pCudaCoreContextAlloc)(int _iGpuId);
typedef int (*pCudaCoreContextFree)(CudaCoreContext _pCtx);
typedef int (*pCudaCoreDecodeCreate)(CudaCoreContext _pCtx, CudaDecodeParam* _pParam);
typedef int (*pCudaCoreDecodeFrame)(CudaCoreContext _pCtx, CudaDecodeIn* _pIn, CudaDecodeOut* _pOut);
typedef int (*pCudaCoreDecodeDestroy)(CudaCoreContext _pCtx);
typedef ResourceHandle (*pCudaCoreRegistResource)(CudaCoreContext _pCtx, void* _pvSurface);
typedef int (*pCudaCoreUnRegistResource)(CudaCoreContext _pCtx, ResourceHandle _pHandle);
typedef int (*pCudaCoreDecodeCopytoResouce)(CudaCoreContext _pCtx, void* _pDevicePtr, ResourceHandle _pHandle);
typedef void* (*pCudaCoreDecodeGetFrame)(CudaCoreContext _pCtx, void* _pvDevicePtr);
typedef int (*pCudaCoreDecodeReleaseFrame)(CudaCoreContext _pCtx, void* _pvDevicePtr);
typedef int (*pCudaCoreGetAdapter)(CudaCoreContext _pCtx);
typedef void* (*pCudaCoreGetDeviceMem)(CudaCoreContext _pCtx, void* _pvDevicePtr, int _iLen); //¿½±´ÏÔ´æ
typedef int (*pCudaCoreReleaseMem)(CudaCoreContext _pCtx, void* _pvDevicePtr);
typedef int (*pCudaCoreMemcpy2D)(CudaCoreContext _pCtx, CudaCoreMem2D* _ptM2D);
typedef int (*pCudaCoreGetGpuID)(CudaCoreContext _pCtx);

class CLS_CudaDecApi
{
private:
	static CLS_CudaDecApi* m_pclsInstance;

	void* m_pvCudaCoreHandle;
	pCudaCoreStartup				m_pCudaCoreStartup;
	pCudaCoreCleanup				m_pCudaCoreCleanup;
	pCudaCoreGetGpuCount			m_pCudaCoreGetGpuCount;
	pCudaCoreContextAlloc			m_pCudaCoreContextAlloc;
	pCudaCoreContextFree			m_pCudaCoreContextFree;
	pCudaCoreDecodeCreate			m_pCudaCoreDecodeCreate;
	pCudaCoreDecodeFrame			m_pCudaCoreDecodeFrame;
	pCudaCoreDecodeDestroy			m_pCudaCoreDecodeDestroy;
	pCudaCoreRegistResource			m_pCudaCoreRegistResource;
	pCudaCoreUnRegistResource		m_pCudaCoreUnRegistResource;
	pCudaCoreDecodeCopytoResouce	m_pCudaCoreDecodeCopytoResouce;
	pCudaCoreDecodeGetFrame			m_pCudaCoreDecodeGetFrame;
	pCudaCoreDecodeReleaseFrame		m_pCudaCoreDecodeReleaseFrame;
	pCudaCoreGetAdapter				m_pCudaCoreGetAdapter;
	pCudaCoreGetDeviceMem			m_pCudaCoreGetDeviceMem;
	pCudaCoreReleaseMem				m_pCudaCoreReleaseMem;
	pCudaCoreMemcpy2D				m_pCudaCoreMemcpy2D;
	pCudaCoreGetGpuID				m_pCudaCoreGetGpuID;

public: 
	CLS_CudaDecApi();
	~CLS_CudaDecApi();

	static CLS_CudaDecApi* Instance(void);
	static void Destroy();

	int CudaCoreStartup();
	int CudaCoreCleanup();
	int CudaCoreGetGpuCount();
	CudaCoreContext CudaCoreContextAlloc(int _iGpuId);
	int CudaCoreContextFree(CudaCoreContext _pCtx);
	int CudaCoreDecodeCreate(CudaCoreContext _pCtx, CudaDecodeParam* _pParam);
	int CudaCoreDecodeFrame(CudaCoreContext _pCtx, CudaDecodeIn* _pIn, CudaDecodeOut* _pOut);
	int CudaCoreDecodeDestroy(CudaCoreContext _pCtx);
	ResourceHandle CudaCoreRegistResource(CudaCoreContext _pCtx, void* _pvSurface);
	int CudaCoreUnRegistResource(CudaCoreContext _pCtx, ResourceHandle _pHandle);
	int CudaCoreDecodeCopytoResouce(CudaCoreContext _pCtx, void* _pDevicePtr, ResourceHandle _pHandle);
	void* CudaCoreDecodeGetFrame(CudaCoreContext _pCtx, void* _pvDevicePtr);
	int CudaCoreDecodeReleaseFrame(CudaCoreContext _pCtx, void* _pvDevicePtr);
	int CudaCoreGetAdapter(CudaCoreContext _pCtx);
	void* CudaCoreGetDeviceMem(CudaCoreContext _pCtx, void* _pvDevicePtr, int _iLen); //¿½±´ÏÔ´æ
	int CudaCoreReleaseMem(CudaCoreContext _pCtx, void* _pvDevicePtr);
	int CudaCoreMemcpy2D(CudaCoreContext _pCtx, CudaCoreMem2D* _ptM2D);
	int CudaCoreGetGpuID(CudaCoreContext _pCtx);



	int	LoadLib();
	int	ReleaseLib();
};


#endif

