示例#1
0
/*----------------------------------
函数功能:开始播放实时流媒体
调用参数:
返回参数:
函数说明:
-----------------------------------*/
_EXT_C_DEVCAM_API BOOL CAM_StartStreamPlay(CommonParam *commonParam,long channel){
	if (commonParam == NULL){
		commonParam->devError = PlayError;
		return FALSE;
	}

	if(commonParam->deviceType == NET_NVR_SERIAL){
		commonParam->cameraParam[channel].frameBufferSize = commonParam->cameraParam[channel].frameWidth * commonParam->cameraParam[channel].frameHeight * 3 / 2;
		commonParam->cameraParam[channel].frameBuffer = new unsigned char[commonParam->cameraParam[channel].frameBufferSize];
		commonParam->cameraParam[channel].JPEGSize = commonParam->cameraParam[channel].frameWidth * commonParam->cameraParam[channel].frameHeight * 3 / 2;
		commonParam->cameraParam[channel].JPEGBuffer = new unsigned char[commonParam->cameraParam[channel].JPEGSize];
		memset(commonParam->cameraParam[channel].frameBuffer,0,commonParam->cameraParam[channel].frameBufferSize);
		memset(commonParam->cameraParam[channel].JPEGBuffer,0,commonParam->cameraParam[channel].JPEGSize);
		commonParam->cameraParam[channel].playHandle = CLIENT_RealPlay(commonParam->loginID,channel,commonParam->cameraParam[channel].playHwnd);
		CLIENT_SetRealDataCallBackEx(commonParam->cameraParam[channel].playHandle,RealDataCallBack,(DWORD)commonParam->cameraParam[channel].frameBuffer,4);
	}

	if(commonParam->deviceType == NET_IPC_SERIAL){
		commonParam->frameBufferSize = commonParam->frameWidth * commonParam->frameHeight * 3 / 2;
		commonParam->frameBuffer = new unsigned char[commonParam->frameBufferSize];

		commonParam->JPEGSize = commonParam->frameWidth * commonParam->frameHeight * 3 / 2;
		commonParam->JPEGBuffer = new unsigned char[commonParam->JPEGSize];

		memset(commonParam->frameBuffer,0,commonParam->frameBufferSize);
		memset(commonParam->JPEGBuffer,0,commonParam->JPEGSize);

		commonParam->playHandle = CLIENT_RealPlay(commonParam->loginID,commonParam->channelNo,commonParam->playHwnd);
		if(!CLIENT_SetRealDataCallBackEx(commonParam->playHandle,RealDataCallBack,(DWORD)commonParam->frameBuffer,4)){
			return FALSE;
		}
	}

	return TRUE;
}
示例#2
0
文件: Preview.cpp 项目: mk-z/Scan
void CPreview::OnSelchangePreviewCmbChannel() 
{
	// TODO: Add your control notification handler code here
	CDemoIVSPCDlg* pMainDlg = (CDemoIVSPCDlg*)GetParent();
	if (!pMainDlg)
	{
		return;
	}	

	if (pMainDlg->GetRealPlayHandle())
	{
		::CLIENT_StopRealPlay(pMainDlg->GetRealPlayHandle());

		g_PlayAPI.PLAY_Stop(g_nPlayPort);
		g_PlayAPI.PLAY_CloseStream(g_nPlayPort);

		pMainDlg->SetRealPlayHandel(0);
		pMainDlg->SetCurrentChannel(-1);
		pMainDlg->m_pdlgConfig->UninitConfigDlg();
	}

	LLONG m_lPlayID = 0;
	HWND hWnd = GetDlgItem(IDC_PREVIEW_STATIC_PREVIEW)->GetSafeHwnd();
	NET_DEVICEINFO* pDevInfo = pMainDlg->GetDevInfo();
	int nChnCount = 0;
	if (pDevInfo)
	{
		nChnCount = pDevInfo->byChanNum;
	}


	//Enable stream
	BOOL bOpenRet = g_PlayAPI.PLAY_OpenStream(g_nPlayPort, 0, 0, 1024 * 900);
	if(bOpenRet)
	{
		BOOL bRet = g_PlayAPI.PLAY_SetIVSCallBack(g_nPlayPort, GetIvsInfoProc, (DWORD)this);
		if (!bRet)
		{
			MessageBox(ConvertString(_T("Fail to Set IVS Callback!")), ConvertString("Prompt"));
		}
		
		CFG_ANALYSERULES_INFO* pRule 
			= (CFG_ANALYSERULES_INFO*)pMainDlg->GetAnalyseRulesInfo(m_cmbChannel.GetCurSel());
		if (pRule)
		{
			DRAW_Reset(g_nPreviewDrawPort, DRAW_RULE);
			int iErr = DRAW_InputRuleData(g_nPreviewDrawPort, 0, (unsigned char*)pRule, 0);
			if (iErr < 0)
			{
				MessageBox(ConvertString(_T("Fail to Input RuleData!")), ConvertString("Prompt"));
			}
		}
		
		DRAW_SetPen(g_nPreviewDrawPort, DRAW_RULE, DRAW_PEN_SOLID, 1, RGB(0, 255, 0));
		bRet = g_PlayAPI.PLAY_RigisterDrawFun(g_nPlayPort, DrawIvsInfoPreviewProc, (DWORD)this);
		if (!bRet)
		{
			MessageBox(ConvertString(_T("Fail to RigisterDrawFun!")), ConvertString("Prompt"));
		}
		//Begin play 
		BOOL bPlayRet = g_PlayAPI.PLAY_Play(g_nPlayPort, hWnd);
		if(bPlayRet)
		{
			//Real-time play 
			m_lPlayID = CLIENT_RealPlay(pMainDlg->GetLoginHandle(), m_cmbChannel.GetCurSel(), 0);
			if(0 != m_lPlayID)
			{
				CLIENT_SetRealDataCallBackEx(m_lPlayID, RealDataCallBackEx, (LDWORD)this, 0x1f);
			}
			else
			{
				g_PlayAPI.PLAY_Stop(g_nPlayPort);
				g_PlayAPI.PLAY_CloseStream(g_nPlayPort);
				int x = ::CLIENT_GetLastError();
				MessageBox(ConvertString(_T("Fail to realplay!")), ConvertString("Prompt"));
			}
		}
		else
		{
			g_PlayAPI.PLAY_CloseStream(g_nPlayPort);
			MessageBox(ConvertString(_T("Fail to play!")), ConvertString("Prompt"));
		}
	}
	else
	{
		MessageBox(ConvertString(_T("Fail to OpenStream!")), ConvertString("Prompt"));
	}
	//////////////////////////////////////////////////////////////////////////
	//Çл»Ô¤ÀÀÊÓƵͼÏñ

 	pMainDlg->SetRealPlayHandel(m_lPlayID);
	pMainDlg->SetCurrentChannel(m_cmbChannel.GetCurSel());
	pMainDlg->EnableLoginWindow(LoginOpenView);
	pMainDlg->m_pdlgConfig->InitConfigDlg(m_cmbChannel.GetCurSel());
	Invalidate(FALSE);

}
示例#3
0
文件: Preview.cpp 项目: mk-z/Scan
//////////////////////////////////////////////////////////////////////////
//º¯Êý£º
//ÃèÊö£ºshow preview
//²ÎÊý£º
//·µ»Ø£º
//////////////////////////////////////////////////////////////////////////
void CPreview::ShowPreview(LONG lLoginHanlde, int nChannel)
{
	if (!lLoginHanlde || nChannel < 0)
	{
		return;
	}

	CDemoIVSPCDlg* pMainDlg = (CDemoIVSPCDlg*)GetParent();
	if (pMainDlg)
	{
		if (pMainDlg->GetLoginHandle())
		{
			if (pMainDlg->GetRealPlayHandle())
			{
				::CLIENT_StopRealPlay(pMainDlg->GetRealPlayHandle());
				pMainDlg->SetRealPlayHandel(0);
				
				g_PlayAPI.PLAY_Stop(g_nPlayPort);
				g_PlayAPI.PLAY_CloseStream(g_nPlayPort);
			}
			
			LLONG m_lPlayID = 0;
			HWND hWnd = GetDlgItem(IDC_PREVIEW_STATIC_PREVIEW)->GetSafeHwnd();
			NET_DEVICEINFO* pDevInfo = pMainDlg->GetDevInfo();
			int nChnCount = 0;
			if (pDevInfo)
			{
				nChnCount = pDevInfo->byChanNum;
			}
			
			CFG_ANALYSERULES_INFO* pRule
				= (CFG_ANALYSERULES_INFO*)pMainDlg->GetAnalyseRulesInfo(m_cmbChannel.GetCurSel());
			if (!pRule)
			{
				return;
			}

			//Enable stream
			BOOL bOpenRet = g_PlayAPI.PLAY_OpenStream(g_nPlayPort, 0, 0, 1024 * 900);
			if(bOpenRet)
			{
				BOOL bRet = g_PlayAPI.PLAY_SetIVSCallBack(g_nPlayPort, GetIvsInfoProc, (DWORD)this);
				
				DRAW_Reset(g_nPreviewDrawPort, DRAW_RULE);
				DRAW_InputRuleData(g_nPreviewDrawPort, 0, (unsigned char*)pRule, 0);
				DRAW_SetPen(g_nPreviewDrawPort, DRAW_RULE, DRAW_PEN_SOLID, 1, RGB(0, 255, 0));

				bRet = g_PlayAPI.PLAY_RigisterDrawFun(g_nPlayPort, DrawIvsInfoPreviewProc, (DWORD)this);
				if (!bRet)
				{
					MessageBox(ConvertString("PLAY_RigisterDrawFun failed!"), ConvertString("Prompt"));
				}
				//Begin play 
				BOOL bPlayRet = g_PlayAPI.PLAY_Play(g_nPlayPort, hWnd);
				if(bPlayRet)
				{
					//Real-time play 
					m_lPlayID = CLIENT_RealPlay(pMainDlg->GetLoginHandle(), nChannel, 0);
					if(m_lPlayID)
					{
						pMainDlg->SetRealPlayHandel(m_lPlayID);
						CLIENT_SetRealDataCallBackEx(m_lPlayID, RealDataCallBackEx, (LDWORD)this, 0x1f);
					}
					else
					{
						g_PlayAPI.PLAY_Stop(g_nPlayPort);
						g_PlayAPI.PLAY_CloseStream(g_nPlayPort);
						int x = ::CLIENT_GetLastError();
						MessageBox(ConvertString("Fail to play!"), ConvertString("Prompt"));
					}
				}
				else
				{
					g_PlayAPI.PLAY_CloseStream(g_nPlayPort);
				}
			}
		}
	}
}