
#include "PlaySdkM4Interface.h"

using namespace PlaySdkM4_INTERFACE;

namespace PlaySdkM4_INTERFACE
{
	HINSTANCE	hPlaySdkM4	= NULL;
	IMPLEMENT_FUNCTION(TC_CreateSystem);
	IMPLEMENT_FUNCTION(TC_DeleteSystem);

	IMPLEMENT_FUNCTION(TC_CreatePlayerFromFile);
	IMPLEMENT_FUNCTION(TC_DeletePlayer);

	IMPLEMENT_FUNCTION(TC_RegisterEventMsg);
	IMPLEMENT_FUNCTION(TC_RegisterNotifyPlayToEnd);
	IMPLEMENT_FUNCTION(TC_RegisterNotifyGetDecAV);
	IMPLEMENT_FUNCTION(TC_RegisterDrawFun);

	IMPLEMENT_FUNCTION(TC_SetPlayRect);
	IMPLEMENT_FUNCTION(TC_SetPlayRectEx);
	IMPLEMENT_FUNCTION(TC_Play);
	IMPLEMENT_FUNCTION(TC_Stop);
	IMPLEMENT_FUNCTION(TC_GoBegin);
	IMPLEMENT_FUNCTION(TC_GoEnd);
	IMPLEMENT_FUNCTION(TC_StepForward);
	IMPLEMENT_FUNCTION(TC_StepBackward);
	IMPLEMENT_FUNCTION(TC_FastForward);
	IMPLEMENT_FUNCTION(TC_SlowForward);
	IMPLEMENT_FUNCTION(TC_FastBackward);
	IMPLEMENT_FUNCTION(TC_PlayAudio);
	IMPLEMENT_FUNCTION(TC_StopAudio);
	IMPLEMENT_FUNCTION(TC_SetAudioVolume);
	IMPLEMENT_FUNCTION(TC_GetAudioVolume);
	IMPLEMENT_FUNCTION(TC_SetAudioVolumeEx);
	IMPLEMENT_FUNCTION(TC_GetAudioVolumeEx);
	IMPLEMENT_FUNCTION(TC_Seek);
	IMPLEMENT_FUNCTION(TC_SeekEx);

	IMPLEMENT_FUNCTION(TC_GetFrameRate);
	IMPLEMENT_FUNCTION(TC_GetPlayingFrameNum);
	IMPLEMENT_FUNCTION(TC_GetFrameCount);
	IMPLEMENT_FUNCTION(TC_GetBeginEnd);
	IMPLEMENT_FUNCTION(TC_GetFileName);

	IMPLEMENT_FUNCTION(TC_CapturePic);
	IMPLEMENT_FUNCTION(TC_CaptureBmpPic);

	IMPLEMENT_FUNCTION(TC_CreatePlayerFromStream);
	IMPLEMENT_FUNCTION(TC_CreatePlayerFromStreamEx);
	IMPLEMENT_FUNCTION(TC_PutStreamToPlayer);

	IMPLEMENT_FUNCTION(TC_StartMonitorCPU);
	IMPLEMENT_FUNCTION(TC_StopMonitorCPU);
	IMPLEMENT_FUNCTION(TC_GetVersion);

	//for vod
	IMPLEMENT_FUNCTION(TC_CreatePlayerFromVoD);
	IMPLEMENT_FUNCTION(TC_SetVoDPlayerOver);
	IMPLEMENT_FUNCTION(TC_SetCleanVoDBuffer);
	IMPLEMENT_FUNCTION(TC_GetPlayTime);
	IMPLEMENT_FUNCTION(TC_Pause);
	IMPLEMENT_FUNCTION(TC_GetVideoParam);

	//--------------> add 20100714 hyq
	IMPLEMENT_FUNCTION(TC_DrawRect);
	IMPLEMENT_FUNCTION(TC_ResetPlayWnd);
	IMPLEMENT_FUNCTION(TC_AddEZoom);
	IMPLEMENT_FUNCTION(TC_SetEZoom);
	IMPLEMENT_FUNCTION(TC_RemoveEZoom);
	IMPLEMENT_FUNCTION(TC_ResetEZoom);

	IMPLEMENT_FUNCTION(TC_SearchVCAInfo);
	IMPLEMENT_FUNCTION(TC_GetBeginEndTimeStamp);

	IMPLEMENT_FUNCTION(TC_SetVideoDecryptKey);
	IMPLEMENT_FUNCTION(TC_GetVideoDecryptKey);
	IMPLEMENT_FUNCTION(TC_RegisterCommonEventCallBack);
	IMPLEMENT_FUNCTION(TC_RegisterCommonEventCallBackEx);

	IMPLEMENT_FUNCTION(TC_SetModeRule);

	IMPLEMENT_FUNCTION(TC_DrawPolygonOnLocalVideo);
	IMPLEMENT_FUNCTION(TC_RegisterPsPackCallBack);
	IMPLEMENT_FUNCTION(TC_DeletePlayerEx);

	IMPLEMENT_FUNCTION(TC_GetMarkInfo);
	IMPLEMENT_FUNCTION(TC_SetMarkInfo);
	IMPLEMENT_FUNCTION(TC_SeekMark);
	IMPLEMENT_FUNCTION(TC_StartCaptureFile);
	IMPLEMENT_FUNCTION(TC_StopCaptureFile);

	IMPLEMENT_FUNCTION(TC_SetStreamBufferSize);
	IMPLEMENT_FUNCTION(TC_SetFrameListBufferSize);
	IMPLEMENT_FUNCTION(TC_SetVerticalSync);

	IMPLEMENT_FUNCTION(TC_StartAudioCapture);
	IMPLEMENT_FUNCTION(TC_StopAudioCapture);
	IMPLEMENT_FUNCTION(TC_RegisterNotifyAudioCapture);

	HRESULT	LoadPlaySdkM4()
	{
		if (hPlaySdkM4)
			return	S_FALSE;
		else
		{
			hPlaySdkM4=::LoadLibrary(".\\Bin_Release_V4.0\\PlaySdkM4.dll");
			if (!hPlaySdkM4)
				return	E_FAIL;
		}

		TC_CreateSystem            = (pTC_CreateSystem)           GetProcAddress(hPlaySdkM4, "TC_CreateSystem");
		TC_DeleteSystem            = (pTC_DeleteSystem)           GetProcAddress(hPlaySdkM4, "TC_DeleteSystem");

		TC_CreatePlayerFromFile    = (pTC_CreatePlayerFromFile)   GetProcAddress(hPlaySdkM4, "TC_CreatePlayerFromFile");
		TC_DeletePlayer            = (pTC_DeletePlayer)           GetProcAddress(hPlaySdkM4, "TC_DeletePlayer");

		TC_RegisterEventMsg        = (pTC_RegisterEventMsg)       GetProcAddress(hPlaySdkM4, "TC_RegisterEventMsg");
		TC_RegisterNotifyPlayToEnd = (pTC_RegisterNotifyPlayToEnd)GetProcAddress(hPlaySdkM4, "TC_RegisterNotifyPlayToEnd");
		TC_RegisterNotifyGetDecAV  = (pTC_RegisterNotifyGetDecAV) GetProcAddress(hPlaySdkM4, "TC_RegisterNotifyGetDecAV");

		TC_RegisterDrawFun         = (pTC_RegisterDrawFun)        GetProcAddress(hPlaySdkM4, "TC_RigisterDrawFun");

		TC_SetPlayRect             = (pTC_SetPlayRect)            GetProcAddress(hPlaySdkM4, "TC_SetPlayRect");
		TC_SetPlayRectEx           = (pTC_SetPlayRectEx)          GetProcAddress(hPlaySdkM4, "TC_SetPlayRectEx");
		TC_Play				       = (pTC_Play)				      GetProcAddress(hPlaySdkM4, "TC_Play");
		TC_Stop                    = (pTC_Stop)                   GetProcAddress(hPlaySdkM4, "TC_Stop");
		TC_GoBegin                 = (pTC_GoBegin)                GetProcAddress(hPlaySdkM4, "TC_GoBegin");
		TC_GoEnd				   = (pTC_GoEnd)                  GetProcAddress(hPlaySdkM4, "TC_GoEnd");
		TC_StepForward             = (pTC_StepForward)            GetProcAddress(hPlaySdkM4, "TC_StepForward");
		TC_StepBackward            = (pTC_StepBackward)           GetProcAddress(hPlaySdkM4, "TC_StepBackward");
		TC_FastForward             = (pTC_FastForward)            GetProcAddress(hPlaySdkM4, "TC_FastForward");
		TC_SlowForward             = (pTC_SlowForward)            GetProcAddress(hPlaySdkM4, "TC_SlowForward");
		TC_FastBackward            = (pTC_FastBackward)           GetProcAddress(hPlaySdkM4, "TC_FastBackward");
		TC_PlayAudio               = (pTC_PlayAudio)              GetProcAddress(hPlaySdkM4, "TC_PlayAudio");
		TC_StopAudio               = (pTC_StopAudio)              GetProcAddress(hPlaySdkM4, "TC_StopAudio");
		TC_SetAudioVolume          = (pTC_SetAudioVolume)         GetProcAddress(hPlaySdkM4, "TC_SetAudioVolume");
		TC_GetAudioVolume          = (pTC_GetAudioVolume)         GetProcAddress(hPlaySdkM4, "TC_GetAudioVolume");
		TC_SetAudioVolumeEx        = (pTC_SetAudioVolumeEx)       GetProcAddress(hPlaySdkM4, "TC_SetAudioVolumeEx");
		TC_GetAudioVolumeEx        = (pTC_GetAudioVolumeEx)       GetProcAddress(hPlaySdkM4, "TC_GetAudioVolumeEx");
		TC_Seek                    = (pTC_Seek)                   GetProcAddress(hPlaySdkM4, "TC_Seek");
		TC_SeekEx                  = (pTC_SeekEx)                 GetProcAddress(hPlaySdkM4, "TC_SeekEx");
		TC_GetFrameRate            = (pTC_GetFrameRate)           GetProcAddress(hPlaySdkM4, "TC_GetFrameRate");
		TC_GetPlayingFrameNum      = (pTC_GetPlayingFrameNum)     GetProcAddress(hPlaySdkM4, "TC_GetPlayingFrameNum");
		TC_GetFrameCount           = (pTC_GetFrameCount)          GetProcAddress(hPlaySdkM4, "TC_GetFrameCount");
		TC_GetBeginEnd             = (pTC_GetBeginEnd)            GetProcAddress(hPlaySdkM4, "TC_GetBeginEnd");
		TC_GetFileName             = (pTC_GetFileName)            GetProcAddress(hPlaySdkM4, "TC_GetFileName");
		TC_CapturePic              = (pTC_CapturePic)             GetProcAddress(hPlaySdkM4, "TC_CapturePic");
		TC_CaptureBmpPic           = (pTC_CaptureBmpPic)          GetProcAddress(hPlaySdkM4, "TC_CaptureBmpPic");
		TC_CreatePlayerFromStream  = (pTC_CreatePlayerFromStream) GetProcAddress(hPlaySdkM4, "TC_CreatePlayerFromStream");
		TC_CreatePlayerFromStreamEx= (pTC_CreatePlayerFromStreamEx)GetProcAddress(hPlaySdkM4, "TC_CreatePlayerFromStreamEx");
		TC_PutStreamToPlayer       = (pTC_PutStreamToPlayer)      GetProcAddress(hPlaySdkM4, "TC_PutStreamToPlayer");
		TC_StartMonitorCPU         = (pTC_StartMonitorCPU)        GetProcAddress(hPlaySdkM4, "TC_StartMonitorCPU");
		TC_StopMonitorCPU          = (pTC_StopMonitorCPU)         GetProcAddress(hPlaySdkM4, "TC_StopMonitorCPU");

		TC_GetVersion              = (pTC_GetVersion)             GetProcAddress(hPlaySdkM4, "TC_GetVersion");

		// for vod
		TC_CreatePlayerFromVoD     = (pTC_CreatePlayerFromVoD)    GetProcAddress(hPlaySdkM4, "TC_CreatePlayerFromVoD");
		TC_SetVoDPlayerOver        = (pTC_SetVoDPlayerOver )      GetProcAddress(hPlaySdkM4, "TC_SetVoDPlayerOver");
		TC_SetCleanVoDBuffer       = (pTC_SetCleanVoDBuffer)      GetProcAddress(hPlaySdkM4, "TC_SetCleanVoDBuffer");

		TC_GetPlayTime             = (pTC_GetPlayTime)			  GetProcAddress(hPlaySdkM4, "TC_GetPlayTime");

		TC_Pause                   = (pTC_Pause)                  GetProcAddress(hPlaySdkM4, "TC_Pause");

		TC_GetVideoParam           = (pTC_GetVideoParam)		  GetProcAddress(hPlaySdkM4, "TC_GetVideoParam");

		TC_DrawRect                = (pTC_DrawRect)				  GetProcAddress(hPlaySdkM4, "TC_DrawRect");
		TC_SetEZoom                = (pTC_SetEZoom)			      GetProcAddress(hPlaySdkM4, "TC_SetEZoom");
		TC_ResetEZoom              = (pTC_ResetEZoom)             GetProcAddress(hPlaySdkM4, "TC_ResetEZoom");
		TC_AddEZoom				   = (pTC_AddEZoom)				  GetProcAddress(hPlaySdkM4, "TC_AddEZoom");
		TC_RemoveEZoom             = (pTC_RemoveEZoom)			  GetProcAddress(hPlaySdkM4, "TC_RemoveEZoom");
		TC_ResetPlayWnd            = (pTC_ResetPlayWnd)			  GetProcAddress(hPlaySdkM4, "TC_ResetPlayWnd");

		TC_SearchVCAInfo           = (pTC_SearchVCAInfo)		  GetProcAddress(hPlaySdkM4, "TC_SearchVCAInfo");
		TC_GetBeginEndTimeStamp    = (pTC_GetBeginEndTimeStamp)   GetProcAddress(hPlaySdkM4, "TC_GetBeginEndTimeStamp");

		EXPORT_FUNCTION(hPlaySdkM4, TC_SetVideoDecryptKey);
		EXPORT_FUNCTION(hPlaySdkM4, TC_GetVideoDecryptKey);
		EXPORT_FUNCTION(hPlaySdkM4, TC_RegisterCommonEventCallBack);
		EXPORT_FUNCTION(hPlaySdkM4, TC_RegisterCommonEventCallBackEx);
		EXPORT_FUNCTION(hPlaySdkM4, TC_SetModeRule);
		EXPORT_FUNCTION(hPlaySdkM4, TC_DrawPolygonOnLocalVideo);
		EXPORT_FUNCTION(hPlaySdkM4, TC_RegisterPsPackCallBack);
		EXPORT_FUNCTION(hPlaySdkM4, TC_DeletePlayerEx);

		EXPORT_FUNCTION(hPlaySdkM4, TC_GetMarkInfo);
		EXPORT_FUNCTION(hPlaySdkM4, TC_SetMarkInfo);
		EXPORT_FUNCTION(hPlaySdkM4, TC_SeekMark);
		EXPORT_FUNCTION(hPlaySdkM4, TC_StartCaptureFile);
		EXPORT_FUNCTION(hPlaySdkM4, TC_StopCaptureFile);

		EXPORT_FUNCTION(hPlaySdkM4, TC_SetVerticalSync);

		EXPORT_FUNCTION(hPlaySdkM4, TC_StartAudioCapture);
		EXPORT_FUNCTION(hPlaySdkM4, TC_StopAudioCapture);
		EXPORT_FUNCTION(hPlaySdkM4, TC_RegisterNotifyAudioCapture);

		return S_OK;
	}

	void FreePlaySdkM4()
	{
		if(hPlaySdkM4)
		{
			::FreeLibrary(hPlaySdkM4);
			hPlaySdkM4 = NULL;
		}
	}

}
