示例#1
0
void CSingleCamDlg::OnBnClickedBtnStopcam()//停止
{

	NET_DVR_StopRealPlay(lRealHandle1);
	NET_DVR_StopRealPlay(lRealHandle2);

	//释放播放库资源
	PlayM4_Stop(nPort1);
	PlayM4_CloseStream(nPort1);
	PlayM4_FreePort(nPort1);
	PlayM4_Stop(nPort2);
	PlayM4_CloseStream(nPort2);
	PlayM4_FreePort(nPort2);
	GetDlgItem(IDC_BTN_Login)->EnableWindow(TRUE);  //登录按钮失效
	GetDlgItem(IDC_BTN_PlayCam)->EnableWindow(TRUE);  //播放按钮 有效
	GetDlgItem(IDC_BTN_StopCam)->EnableWindow(FALSE);  //停止按钮 失效
	GetDlgItem(IDC_BTN_SavePicture)->EnableWindow(FALSE); // 抓图按钮 失效
	GetDlgItem(IDC_BTN_SavePicture2)->EnableWindow(FALSE); // 抓图按钮 失效
	GetDlgItem(IDC_BTN_StopSave)->EnableWindow(FALSE); // 停止抓图按钮 失效
}
示例#2
0
MainWindow::~MainWindow()
{
    // 停止解码
    PlayM4_Stop(lPort);

    //关闭流,回收源数据缓冲
    PlayM4_CloseStream(lPort);

    //释放播放库端口号
    PlayM4_FreePort(lPort);

    NET_DVR_StopRealPlay(lRealPlayHandle);
    //注销用户
    NET_DVR_Logout(lUserID);
    //释放SDK资源
    NET_DVR_Cleanup();
    delete ui;
}
示例#3
0
VOID CPlayer::StopMonitor( )
{
	TRACE(_T("(MTVideo)停止监视 开始\r\n"));
    m_exit = true;
    m_comSocket.Close();
    //TRACE(_T("(MTVideo)停止监视 将执行WaitForSingleObject dvrIP = %s channel = %d m_PlayHandle = %d m_index_MTManager = %d\r\n",
	//	m_UniSDKCltInfo.connInfo.ip, m_UniSDKCltInfo.channel, m_PlayHandle, m_index_MTManager);
    DWORD dwret = WaitForSingleObject( m_hExitEvent, WAIT_THREAD_EXIT_MAX_TIME );
    if(dwret == WAIT_TIMEOUT)
    {
        TRACE(_T("(MTVideo)!!!!!停止监视时 WaitFor退出信号超时 \r\n"));
    }
    
	BOOL bret =  PlayM4_Stop(m_index);
	
	int nErr = 0;
	if (!bret)
	{
		nErr =  PlayM4_GetLastError(m_index);
		//string strErr = GetPlayMp4LastErrorStr( nErr );
		//TRACE_SDK_ERROR("执行 CHKSeries::CloseStream 中  PlayM4_Stop 函数 Fail nErr = %d strErr = %s\r\n\r\n", nErr, strErr.c_str() );
		//return -nErr;
	}
	
	
	bret =  PlayM4_CloseStream( m_index);
	if (!bret)
	{
		nErr =  PlayM4_GetLastError(m_index);
		//string strErr = GetPlayMp4LastErrorStr( nErr );
		//TRACE_SDK_ERROR("执行 CHKSeries::CloseStream 中  PlayM4_CloseStream 函数 Fail nErr = %d strErr = %s\r\n\r\n", nErr, strErr.c_str() );
		//return -nErr;
	}
	
	
    //TRACE(_T("(MTVideo)停止监视成功 DvrIP = %s channnel = %d m_PlayHandle = %d m_index_MTManager = %d\r\n",
	//	m_UniSDKCltInfo.connInfo.ip, m_UniSDKCltInfo.channel, m_PlayHandle, m_index_MTManager);
	NAME(PlayM4_FreePort)(m_index);
	m_index = -1;
    m_PlayHandle = -1;
	memset(&m_rcRenderRect, 0, sizeof(RECT));
	m_hRenderWnd = NULL;
}
示例#4
0
void CHaikangSDK::StopPlay(int screenNo)
{

	//关闭预览
	NET_DVR_StopRealPlay(m_RealHandle[screenNo]);
	//注销用户
	NET_DVR_Logout_V30(m_LoginHandle[screenNo]);
	
	PlayM4_Stop(m_lPort[screenNo]);
	PlayM4_CloseStream(m_lPort[screenNo]);
	PlayM4_FreePort(m_lPort[screenNo]);

	m_LoginHandle[screenNo] = -1;
	m_lPort[screenNo]=-1;
#if OPEN_CARDETECT_CODE 	
	//停止识别
	if(false == DlgMain->DlgScreen.m_videoInfo[screenNo].enableDetect)
		DlgMain->DlgScreen.CarDetect[screenNo].Stop();
#endif

}
示例#5
0
int CPlayer::ReStartMonitor()
{
	m_comSocket.Close();
	m_streamParser.ClearBuf();//清除缓冲
	memset(&m_rcRenderRect, 0, sizeof(RECT));
	if( m_comSocket.Connect(m_clientInfo.connInfo.ip, m_clientInfo.connInfo.port) < 0 )
    {
        m_comSocket.Close();
        return HHV_ERROR_CONNECT;
    }
	int	streamHeaderSize = 4*1024;
	memset( m_streamHeader, 0x00, sizeof(m_streamHeader) );

    int ret = MonitorStartCmdMT(m_comSocket.m_hSocket, &m_clientInfo, m_streamHeader, streamHeaderSize);
    if( ret < 0 )
    {
        m_comSocket.Close();
        return ret;
    }

	PlayM4_Stop(m_index);
	PlayM4_CloseStream( m_index);
	ResetBuf();

	//mode- 流模式(1-实时流/2-文件流)
	int nErr = 0;
	m_playType = STREAME_REALTIME;
	BOOL  bret =  PlayM4_SetStreamOpenMode(m_index, m_playType);
    bret =  PlayM4_OpenStream( m_index, (BYTE*)m_streamHeader, streamHeaderSize, 600*1024);
	if (!bret)
	{
		m_comSocket.Close();
		nErr =  PlayM4_GetLastError(m_index);

		return -nErr;
	}

	m_disconnection = false;
	if( ! PlayM4_RigisterDrawFun( m_index, MP4SDKDrawFun, (DWORD)this) )
	{
		m_comSocket.Close();
		nErr =  PlayM4_GetLastError(m_index);
		//TRACE_SDK_ERROR("执行 CHKSeries::RegisterDrawFun 中  PlayM4_RigisterDrawFun 函数 Fail nErr = %d strErr = %s\r\n\r\n", nErr, strErr.c_str() );
		return -nErr;
	}

	bret =  PlayM4_Play(m_index, m_hWnd);
	if (!bret)
	{
		nErr =  PlayM4_GetLastError(m_index);
		//string strErr = GetPlayMp4LastErrorStr( nErr );
		//TRACE_SDK_ERROR("执行 CHKSeries::OpenStream 中  PlayM4_Play 函数 Fail nErr = %d strErr = %s\r\n\r\n", nErr, strErr.c_str() );
		return -nErr;
	}

	m_hRenderWnd = m_hWnd;
	ResizeMonitorWindow();

    //memcpy(&m_clientInfo, clientInfo, sizeof(UNISDK_CLIENT_INFO));
    //开启线程, 接收视频流
    m_exit = false;
    UINT threadid(0);
    m_Thread = (HANDLE)_beginthreadex( NULL, 4*1024*1024, DecoderRoutine, this, 0, &threadid ); 
    if(m_Thread <= 0)
    {
        TRACE(_T("(MTVideo)!!!!!!开辟接受数据线程失败!m_Thread:%d errno:%d _doserrno:%d \r\n"),
            m_Thread, errno, _doserrno);
        SetEvent( m_hExitEvent );
    }
	
    CloseHandle( m_Thread );
  //
  //  TRACE(_T("(MTVideo)监视成功结束 m_PlayHandle = %d dvrIP = %s channel = %d\r\n"),
		//m_PlayHandle, m_clientInfo.connInfo.ip, clientInfo->channel);
    return m_index;
}
示例#6
0
void CALLBACK g_RealDataCallBack_V30(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer,DWORD dwBufSize,void* dwUser)
{
	CHaikangSDK *HaikangSDK = (CHaikangSDK *)dwUser;
	int screenNo = DlgMain->DlgScreen.m_video.m_haikang.GetHandleWindID(lRealHandle);
	LONG lPort = HaikangSDK->m_lPort[screenNo];
	CWnd* pWnd=NULL;
	switch (dwDataType)
	{
	case NET_DVR_SYSHEAD: //系统头
		
			if (PlayM4_GetPort(&lPort))  //获取播放库未使用的通道号
			{
				DlgMain->DlgScreen.m_video.m_haikang.m_lPort[screenNo] = lPort;
			}
	
		//m_iPort = lPort; //第一次回调的是系统头,将获取的播放库port号赋值给全局port,下次回调数据时即使用此port号播放
		if (dwBufSize > 0)
		{
			if (!PlayM4_SetStreamOpenMode(lPort, STREAME_REALTIME))  //设置实时流播放模式
			{
				PlayM4_FreePort(lPort);
				break;
			}

			if (!PlayM4_OpenStream(lPort, pBuffer, dwBufSize, 1920*1080*3)) //打开流接口
			{
				PlayM4_FreePort(lPort);
				break;
			}

			if (!PlayM4_SetDisplayCallBack(lPort, RemoteDisplayCBFun))
			{
				PlayM4_CloseStream(lPort);
				PlayM4_FreePort(lPort);
				break;
			}
			if(DlgSetSystem.m_display_preview)
			{
				pWnd= DlgMain->DlgScreen.m_screenPannel.GetPage(screenNo);
				if (!pWnd)
				{
					PlayM4_CloseStream(lPort);
					PlayM4_FreePort(lPort);
					return;
				}
				if (!PlayM4_Play(lPort, pWnd->m_hWnd)) //播放开始
				{
					PlayM4_CloseStream(lPort);
					PlayM4_FreePort(lPort);
					break;
				}
			}
			else
			{

				if (!PlayM4_Play(lPort,NULL)) //播放开始
				{
					PlayM4_CloseStream(lPort);
					PlayM4_FreePort(lPort);
					break;
				}
			}
		}
		break;
	case NET_DVR_STREAMDATA:   //码流数据
		if (dwBufSize > 0 && lPort != -1)
		{
			if (!PlayM4_InputData(lPort, pBuffer, dwBufSize))
			{
				break;
			} 
		}
		break;
	}
}