void CRealPlayMgr::FreeRealPlayEx(IVS_ULONG ulHandle)
{
    BP_DBG_LOG("Free Real PlayEx", "Free Handle %u", ulHandle);

	CRealPlay *pRealPlay = NULL;
	
	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	HandleRealPlayMapIter iter = m_HanleRealPlayMap.find(ulHandle);
	if (iter != m_HanleRealPlayMap.end())
	{
		pRealPlay = iter->second;
		m_HanleRealPlayMap.erase(iter++);
	}
	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);

	if (NULL == pRealPlay)
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "FreeRealPlayEx", "pRealPlay = NULL");
		return;
	}

	if (0 == pRealPlay->PutRef())
	{
		BP_DBG_LOG("Free Real PlayEx", "Delete Handle %u", ulHandle);
	    IVS_DELETE(pRealPlay);
	}
}
Ejemplo n.º 2
0
/*******************************************************************************
  Function:       CNVSTimer::clearTimer
  Description:    删除定时器里面所有的TimerItem
  Calls:            
  Called By:      
  Input:         无 
  Output:         无 
  Return:         
*******************************************************************************/
void CNVSTimer::clearTimer( )
{
    CTimerItem *pTimerItem = NULL;

    if(VOS_OK != VOS_MutexLock(m_pMutexListOfTrigger))
    {
        return;
    };
    ListOfTriggerIte itListOfTrigger = m_plistTrigger->begin();
    ListOfTriggerIte itCurrentTrigger = m_plistTrigger->begin();
    while(itListOfTrigger != m_plistTrigger->end())
    {
        pTimerItem = (*itListOfTrigger).second;//lint !e64
        itCurrentTrigger = itListOfTrigger;
        ++itListOfTrigger;
        (void)(m_plistTrigger->erase(itCurrentTrigger));

        IVS_RUN_LOG_ERR("ClearTimer erase pTimerItem(0x%x)", pTimerItem);
            
        continue;
    }

    VOS_DELETE(m_plistTrigger);
    (void)VOS_MutexUnlock(m_pMutexListOfTrigger);
    
}
IVS_ULONG CRealPlayMgr::GetPlayHandlebyRtspHandleEx(int iRtspHandle)
{
	IVS_ULONG ulPlayHandle = 0;

    (void)VOS_MutexLock(m_pHanleRealPlayMutex);
	
	HandleRealPlayMapIter iter = m_HanleRealPlayMap.begin();
	HandleRealPlayMapIter iterEnd = m_HanleRealPlayMap.end();
	for (; iter != iterEnd; iter++)
	{
		CRealPlay* pRealPlay = iter->second;
		if (NULL == pRealPlay)
		{
			continue;
		}

		if (iRtspHandle == pRealPlay->GetRtspHandle())
		{
			ulPlayHandle = iter->first;
			(void)pRealPlay->GetRef();
			break;
		}
	}

	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
	return ulPlayHandle;
}
// 移除解码器信息
IVS_VOID CSDKDecoderMgr::RemoveDecoderInfo()
{
	(void)VOS_MutexLock(m_pDecoderInfoMapMutex);
	try
	{
		for(SDK_DECODER_INFO_MAP::iterator ite=m_decoderInfoMap.begin();ite!=m_decoderInfoMap.end();ite++)
		{
			SDK_DECODER_INFO* pInfo = dynamic_cast<SDK_DECODER_INFO*>(ite->second);//lint !e611
			if(NULL!=pInfo)
			{
				if(pInfo->bOnline)
				{
					//////////////////////////////////////////////////////////////////////////
					//2013-1-28 高书明 先屏蔽HWPuSDK相关函数,与BP的dll冲突
					//(void)IVS_PU_Logout(pInfo->ulIdentifyID);
					//////////////////////////////////////////////////////////////////////////
					pInfo->bOnline = FALSE;
					pInfo->ulIdentifyID = 0;
				}
				IVS_DELETE(pInfo);
			}
		}
		m_decoderInfoMap.clear();
	}
	catch(...)
	{
		m_decoderInfoMap.clear();
	}

	(void)VOS_MutexUnlock(m_pDecoderInfoMapMutex);
}
//获取通道号(如果失败返回-1);
IVS_UINT32 CRealPlayMgr::GetPlayerChannelByHandle(IVS_ULONG ulHandle)
{
	IVS_DEBUG_TRACE("");
	IVS_UINT32 uiChannel = SDK_INVALID_HANDLE;

	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	CRealPlay *pRealPlay = NULL;
	HandleRealPlayMapIter realplayIter;

	//查找空闲对象;
	for (realplayIter = m_HanleRealPlayMap.begin(); realplayIter != m_HanleRealPlayMap.end(); realplayIter++)
	{
		if (realplayIter->first == ulHandle)
		{
            pRealPlay = dynamic_cast<CRealPlay*>(realplayIter->second);//lint !e611
			if (NULL != pRealPlay)
			{
				uiChannel = pRealPlay->GetPlayerChannel();
			}
			break;
		}
	}
	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);

	return uiChannel;
}
Ejemplo n.º 6
0
void TimerMgr::uninit()
{
	if (NULL != m_mutex)
	{
		(void)VOS_MutexLock(m_mutex);
	}
	m_bStop = true;
	m_TimerMap.clear();
	if (NULL != m_mutex)
	{
		(void)VOS_MutexUnlock(m_mutex);
	}
	
	if(VOS_NULL != m_threadHandle)
	{
		(void)VOS_ThreadJoin(m_threadHandle);
		m_threadHandle = NULL;
	}
	if (VOS_NULL != m_mutex)
	{
		(void)VOS_DestroyMutex(m_mutex);
		m_mutex = NULL;
	}
	m_TimerCBFunc = NULL;
}
Ejemplo n.º 7
0
unsigned long __stdcall TimerMgr::threadproc(void *para)
{
	TimerMgr* pMgr=(TimerMgr*)para;
	while (!instance().m_bStop)
	{
		(void)VOS_MutexLock(instance().m_mutex);
		TIMER_MAP::iterator itor = instance().m_TimerMap.begin();
		for (; instance().m_TimerMap.end() != itor; itor++)
		{
			if (0 == --(itor->second.left))
			{
				itor->second.left = itor->second.elapse;
				if(NULL != pMgr->m_TimerCBFunc)
				{
					pMgr->m_TimerCBFunc(itor->first);
				}

			}
		}
		(void)VOS_MutexUnlock(instance().m_mutex);
		Sleep(1000);

	}

	return 1;
}
Ejemplo n.º 8
0
/*******************************************************************************
  Function:       CNVSTimer::cancelTimer()
  Description:    注销定时器
  Calls:            
  Called By:      
  Input:          pTrigger: 超时处理对象实例
  Output:         无 
  Return:         
  VOS_SUCCESS: init success
  VOS_FAIL: init fail 
*******************************************************************************/
long CNVSTimer::cancelTimer(ITrigger *pTrigger)
{
    if(NULL == pTrigger)
    {
        IVS_RUN_LOG_ERR("NVSTimer CancelTimer: pTrigger is NULL");
        return VOS_FAIL;
    };

    //加锁(如果和mainloop不是同一线程不需要加锁)
    VOS_BOOLEAN bNeedLock = VOS_FALSE;
    VOS_BOOLEAN bLocked = VOS_FALSE;
    if (NULL == m_pVosThread)
    {
        bNeedLock = VOS_TRUE;
    }
    else
    {
        if(VOS_pthread_self() != m_pVosThread->pthead)
        {
            bNeedLock = VOS_TRUE;
        }
    }
    
    if(VOS_TRUE == bNeedLock)
    {
        if (VOS_OK != VOS_MutexLock(m_pMutexListOfTrigger))
        {
            IVS_RUN_LOG_ERR("NVSTimer CancelTimer: get lock failed");
        }
        else
        {
            bLocked = VOS_TRUE;
        }
    }
 
    if(pTrigger->m_pTimerItem != NULL)
    {
        pTrigger->m_pTimerItem->m_bRemoved = VOS_TRUE;
        pTrigger->m_pTimerItem->m_pTrigger = NULL;
        pTrigger->m_pTimerItem = NULL;
    }

    IVS_DBG_LOG("NVSTimer CancelTimer set m_bRemoved=VOS_TRUE"
                "  pTimerItem(0x%x) pTrigger(0x%x) .\n", pTrigger->m_pTimerItem, pTrigger);

    
    //解锁(如果不是同一线程)
    if(VOS_TRUE == bLocked)
    {
        if (VOS_OK != VOS_MutexUnlock(m_pMutexListOfTrigger))
        {
            IVS_RUN_LOG_ERR("NVSTimer CancelTimer: release lock failed");
        }
    }        
    
    return VOS_SUCCESS;
};
Ejemplo n.º 9
0
void CPlayback::DoFrameCallBack(IVS_INT32 iStreamType, IVS_VOID* pFrameInfo)
{
    (void)VOS_MutexLock(m_pPlayBackFrameDecoderCBMutex);
    if (NULL != m_fPlayBackCallBackFrame)
    {
        m_fPlayBackCallBackFrame(m_ulHandle, (unsigned int)iStreamType, pFrameInfo, m_pPlayBackUserDataFrame);
    }
    (void)VOS_MutexUnlock(m_pPlayBackFrameDecoderCBMutex);
}
Ejemplo n.º 10
0
void CPlayback::DoRawFrameCallBack(IVS_RAW_FRAME_INFO* pstRawFrameInfo, IVS_CHAR* pFrame, IVS_UINT32 uFrameSize)
{
    (void)VOS_MutexLock(m_pPlayBackRawCBMutex);
    if (NULL != m_fPlayBackCallBackRaw)
    {
        m_fPlayBackCallBackRaw(m_ulHandle, pstRawFrameInfo, pFrame, uFrameSize, m_pPlayBackUserDataRaw);
    }
    (void)VOS_MutexUnlock(m_pPlayBackRawCBMutex);
}
CRealPlay *CRealPlayMgr::GetRealPlay(IVS_ULONG ulHandle)
{
	CRealPlay *pRealPlay = NULL;
	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	HandleRealPlayMapIter iter = m_HanleRealPlayMap.find(ulHandle);
	if (iter != m_HanleRealPlayMap.end())
	{
		pRealPlay = iter->second;
	}
	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
	return pRealPlay;
}
//获取空闲的realplay对象;
CRealPlay *CRealPlayMgr::GetFreeRealPlay(IVS_ULONG& ulHandle)
{
	IVS_DEBUG_TRACE("");
	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	CRealPlay *pRealPlay = NULL;
	HandleRealPlayMapIter realplayIter = m_HanleRealPlayMap.begin();
    HandleRealPlayMapIter realplayIterEnd = m_HanleRealPlayMap.end();

	//查找空闲对象;
	for (; realplayIter != realplayIterEnd; realplayIter++)
	{
        pRealPlay = dynamic_cast<CRealPlay*>(realplayIter->second);//lint !e611
		if (NULL != pRealPlay)
		{
			if (pRealPlay->GetStatus() == MEDIA_STATUS_FREE)
			{
				break;
			}
		}
		pRealPlay = NULL;
	}

	if (NULL != pRealPlay)
	{
		m_HanleRealPlayMap.erase(realplayIter);
	}
	else
	{
		pRealPlay = IVS_NEW((CRealPlay*&)pRealPlay);
		if (NULL == pRealPlay)
		{
			BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get Free RealPlay", "create real play error");
			(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
			return NULL;
		}
	}

	//初始化realplay对象;
	pRealPlay->SetUserMgr(m_pUserMgr);
	pRealPlay->SetStatus(MEDIA_STATUS_BUSY);

	//插入列表;
    ulHandle = (unsigned long)pRealPlay;
	(void)m_HanleRealPlayMap.insert(std::make_pair(ulHandle, pRealPlay));

	pRealPlay->SetHandle(ulHandle);

	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
	return pRealPlay;
}
Ejemplo n.º 13
0
void TimerMgr::killtimer(unsigned int timerId)
{
	INFO_LOG("killtimer:id=%d",timerId);
	if (NULL == m_mutex)
	{
		ERROR_LOG("m_mutex is NULL");
		return;
	}
	(void)VOS_MutexLock(m_mutex);
	TIMER_MAP::iterator itor = m_TimerMap.find(timerId);
	if (m_TimerMap.end() != itor)
	{
		m_TimerMap.erase(itor);
	}
	(void)VOS_MutexUnlock(m_mutex);
}
void CRealPlayMgr::FreeRealPlay(IVS_ULONG ulHandle)
{
	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	HandleRealPlayMapIter iter = m_HanleRealPlayMap.find(ulHandle);
	HandleRealPlayMapIter iterEnd = m_HanleRealPlayMap.end();
	if (iter != iterEnd)
	{
		CRealPlay* pRealPlay = dynamic_cast<CRealPlay*>(iter->second);//lint !e611
		if (NULL != pRealPlay)
		{
			IVS_DELETE(pRealPlay);
		}
		m_HanleRealPlayMap.erase(iter++);
	}
	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
}
Ejemplo n.º 15
0
int CPlayback::StartPlatformPlayBackCB(const IVS_CHAR* pDomainCode,const IVS_CHAR* pNVRCode,const char* pCameraCode,
                                       unsigned int uiProtocolType,
                                       const TIME_SPAN_INTERNAL& stTimeSpanInter,
                                       PlayBackCallBackRaw fPlayBackCallBackRaw,
                                       void* pUserData,
                                       float fSpeed)
{
    CLockGuard lock(m_pMediaMutex);

    IVS_MEDIA_PARA stMediaPara;
    InitMediaPara(stMediaPara);
    stMediaPara.ProtocolType = static_cast<IVS_PROTOCOL_TYPE>(uiProtocolType);//此处转换肯定正确,前面已做检查;

    START_PLAY_PARAM stParam;
    stParam.enServiceType = SERVICE_TYPE_PLAYBACK;
    if(NULL != pDomainCode && SERVICE_TYPE_DISASTEBACKUP_PLAYBACK != stParam.enServiceType)
    {
        stParam.enServiceType = SERVICE_TYPE_BACKUPRECORD_PLAYBACK;
    }
    stParam.fSpeed = fSpeed;
    stParam.cbRtspDataCallBack = g_fRtspDataCallBack;
    stParam.cbNetDataCallBack = g_fNetDataCallBack;
    //开始回放;
    int iRet = StartPlay(pDomainCode,pNVRCode,&stMediaPara, pCameraCode, stTimeSpanInter, stParam, NULL);
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet,"Start Platform Or Backup Play Back", "Start play error.");
        return iRet;
    }

    SetServiceType(stParam.enServiceType);

    (void)IVS_PLAY_SetPlaySpeed(m_ulPlayerChannel,   m_fSpeed);//lint !e747

    m_iStartType = PLAY_TYPE_CB;
    (void)VOS_MutexLock(m_pPlayBackRawCBMutex);
    m_fPlayBackCallBackRaw = fPlayBackCallBackRaw;
    m_pPlayBackUserDataRaw = pUserData;
    (void)VOS_MutexUnlock(m_pPlayBackRawCBMutex);
    iRet = IVS_PLAY_SetRawFrameCallBack(m_ulPlayerChannel, g_fReassmCallBack, this);

    return IVS_SUCCEED;
}
// 是否包含该登录信息解码器
IVS_BOOL CSDKDecoderMgr::IsIncludeID(IVS_ULONG ulIdentifyID)
{
	IVS_BOOL bFind = FALSE;
	(void)VOS_MutexLock(m_pDecoderInfoMapMutex);
	for(SDK_DECODER_INFO_MAP::iterator ite=m_decoderInfoMap.begin();ite!=m_decoderInfoMap.end();ite++)
	{
		SDK_DECODER_INFO* pInfo = dynamic_cast<SDK_DECODER_INFO*>(ite->second);//lint !e611
		if(NULL!=pInfo)
		{
			if(ulIdentifyID==pInfo->ulIdentifyID)
			{
				bFind = TRUE;
				break;
			}
		}
	}
	(void)VOS_MutexUnlock(m_pDecoderInfoMapMutex);
	return bFind;
}
//关闭所有实况;
void CRealPlayMgr::StopAllRealPlay()
{
	IVS_DEBUG_TRACE("");
	(void)VOS_MutexLock(m_pHanleRealPlayMutex);

	CRealPlay *pRealPlay = NULL;
	HandleRealPlayMapIter realplayIter = m_HanleRealPlayMap.begin();
	HandleRealPlayMapIter realplayIterEnd = m_HanleRealPlayMap.end();

	//查找空闲对象;
	for (;realplayIter != realplayIterEnd; realplayIter++)
	{
		pRealPlay = dynamic_cast<CRealPlay*>(realplayIter->second);//lint !e611
		if (NULL != pRealPlay)
		{
			try
			{
				if (pRealPlay->GetStatus() == MEDIA_STATUS_BUSY)
				{
					(void)pRealPlay->StopRealPlay();
				}
			}
			catch(...)
			{
				BP_RUN_LOG_ERR(IVS_FAIL, "StopAllRealPlay", "Delete realplay[%lu] failed.", pRealPlay);
			}

			try
			{
				IVS_DELETE(pRealPlay);
			}
			catch(...)
			{
				BP_RUN_LOG_ERR(IVS_FAIL, "StopAllRealPlay", "Delete realplay[%lu] failed.", pRealPlay);
			}
			
		}
		pRealPlay = NULL;
	}
	m_HanleRealPlayMap.clear();
	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
}
//根据句柄获取realplay;
CMediaBase *CRealPlayMgr::GetMediaBase(IVS_ULONG ulHandle)
{
	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	CMediaBase *pRealPlay = NULL;
	HandleRealPlayMapIter realplayIter = m_HanleRealPlayMap.begin();
    HandleRealPlayMapIter realplayIterEnd = m_HanleRealPlayMap.end();

	//查找空闲对象;
	for (; realplayIter != realplayIterEnd; realplayIter++)
	{
		if (realplayIter->first == ulHandle)
		{
            pRealPlay = realplayIter->second;
			break;
		}
	}

	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
	return pRealPlay;
}
Ejemplo n.º 19
0
//根据资源ID到map表中去遍历获取到资源对应的语言
bool CI18N::GetResourceLanguage(const std::string& strResource,std::string& strLanguage)
{
	bool bRet = false;
	MAP_RESOURCE_TO_LANGUAGE_ITER IpIter;
	(void)VOS_MutexLock(m_pMutexLock);

	IpIter = m_mapResource2Language.find(strResource);
	if (IpIter != m_mapResource2Language.end())
	{
		//找到了
		strLanguage = static_cast<std::string>(IpIter->second);
		bRet = true;
	}
	else
	{
		//没找到
		strLanguage = "";
	}
	(void)VOS_MutexUnlock(m_pMutexLock);
	return bRet;
}
Ejemplo n.º 20
0
CTelepresenceMgr::~CTelepresenceMgr(void)
{
	VOS_MutexLock(m_pChannelMapMutex);
	try
	{
		TP_PLAY_CHANNEL_MAP::iterator iter = m_channelMap.begin();
		TP_PLAY_CHANNEL_MAP::iterator iter_end = m_channelMap.end();
		for(; iter!=iter_end; iter++)
		{
			CTPPlayChannel* pChannel = dynamic_cast<CTPPlayChannel*>(iter->second);//lint !e611
			IVS_DELETE(pChannel);
		}
	}
	catch (...)
	{
	}
	(void)VOS_MutexUnlock(m_pChannelMapMutex);
	(void)VOS_DestroyMutex(m_pChannelMapMutex);
	m_pChannelMapMutex = NULL;
	m_pUserMgr = NULL;
}
// 断连通知
IVS_VOID CSDKDecoderMgr::NotifyDisConnect(IVS_ULONG ulIdentifyID)
{
	std::string strDecoderId;
	(void)VOS_MutexLock(m_pDecoderInfoMapMutex);
	for(SDK_DECODER_INFO_MAP::iterator ite=m_decoderInfoMap.begin();ite!=m_decoderInfoMap.end();ite++)
	{
		SDK_DECODER_INFO* pInfo = dynamic_cast<SDK_DECODER_INFO*>(ite->second);//lint !e611
		if(NULL!=pInfo)
		{
			if(ulIdentifyID==pInfo->ulIdentifyID)
			{
				strDecoderId = pInfo->szDecoderID;
				pInfo->bOnline = FALSE;
				pInfo->ulIdentifyID = 0;
				break;
			}
		}
	}
	(void)VOS_MutexUnlock(m_pDecoderInfoMapMutex);
	if(NULL!=m_pCallBackFun && NULL!=m_pUserData && strDecoderId.length()>0)
	{			
		CUMW_NOTIFY_INFO stNotifyInfo = {0};
		CUMW_NOTIFY_REMOTE_DECODER_OFF_LINE_INFO* pstOffline = IVS_NEW(pstOffline);
		if(NULL!=pstOffline)
		{
			stNotifyInfo.ulNotifyType = CUMW_NOTIFY_TYPE_REMOTE_DECODER_DISCONNECT;
			stNotifyInfo.pNotifyInfo = pstOffline;
			stNotifyInfo.ulNotifyInfoLen = sizeof(CUMW_NOTIFY_REMOTE_DECODER_OFF_LINE_INFO);
			if(CToolsHelp::Strncpy(pstOffline->szDecoderID, sizeof(pstOffline->szDecoderID), strDecoderId.c_str(), strDecoderId.length()))
			{
				(void)m_pCallBackFun(&stNotifyInfo, m_pUserData);
			}
			else
			{
				BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Decoder disconnect", "Copy Decoder ID Failed");
			}
			IVS_DELETE(pstOffline);
		}
	}
}
//根据句柄获取CameraCode;
void CRealPlayMgr::GetCameraCodeByHandle(IVS_ULONG ulHandle, std::string& strCameraCode)
{
	//char *pCameraCode = NULL;
	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	CRealPlay *pRealPlay = NULL;
	HandleRealPlayMapIter realplayIter = m_HanleRealPlayMap.find(ulHandle);
	if (realplayIter != m_HanleRealPlayMap.end())
	{
		pRealPlay = dynamic_cast<CRealPlay*>(realplayIter->second); //lint !e611
		// mod by z00193167 未释放锁
		if (NULL == pRealPlay)
		{
			(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
			return;
		}
		strCameraCode = pRealPlay->GetCameraCode();
		(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
		return;
	}

	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);
}
Ejemplo n.º 23
0
void TimerMgr::settimer(unsigned int timerId, unsigned int elapse)
{
	INFO_LOG("settimer:id=%d",timerId);
	if (NULL == m_mutex)
	{
		ERROR_LOG("m_mutex is NULL");
		return;
	}

	(void)VOS_MutexLock(m_mutex);
	if (m_TimerMap.end() != m_TimerMap.find(timerId))
	{
		(void)VOS_MutexUnlock(m_mutex);
		return;
	}

	TIMER_DATA timer_data;
	timer_data.elapse = elapse;
	timer_data.left = elapse;
	(void)m_TimerMap.insert(std::make_pair(timerId, timer_data));
	(void)VOS_MutexUnlock(m_mutex);
}
IVS_INT32 CSDKDecoderMgr::CleanupSDK()
{
	if(!m_bInit)
	{
		return IVS_TVWALL_INIT_NO;
	}
	m_bThreadExit = TRUE;
	m_bInit = FALSE;
	VOS_ThreadJoin(m_pVosThread);
	if(NULL!=m_pVosThread)
	{
		VOS_free(m_pVosThread);
		m_pVosThread = NULL;
	}
	//清除登录信息
	(void)VOS_MutexLock(m_pDecoderInfoMapMutex);
	for(SDK_DECODER_INFO_MAP::iterator ite=m_decoderInfoMap.begin();ite!=m_decoderInfoMap.end();ite++)
	{
		SDK_DECODER_INFO* pInfo = dynamic_cast<SDK_DECODER_INFO*>(ite->second);//lint !e611
		if(NULL!=pInfo)
		{
			//////////////////////////////////////////////////////////////////////////
			//2013-1-28 高书明 先屏蔽HWPuSDK相关函数,与BP的dll冲突
			//(void)IVS_PU_Logout(pInfo->ulIdentifyID);
			//////////////////////////////////////////////////////////////////////////
			pInfo->bOnline = FALSE;
			pInfo->ulIdentifyID = 0;
		}
	}
	(void)VOS_MutexUnlock(m_pDecoderInfoMapMutex);
	m_pCallBackFun = NULL;
	m_pUserData = NULL;
	//////////////////////////////////////////////////////////////////////////
	//2013-1-28 高书明 先屏蔽HWPuSDK相关函数,与BP的dll冲突
	//BOOL bSucc = IVS_PU_Cleanup();
	//return bSucc ? IVS_SUCCEED:IVS_FAIL;
	return IVS_FAIL;
	//////////////////////////////////////////////////////////////////////////
}
Ejemplo n.º 25
0
bool CI18N::SetLanguage(const std::string& strLanguageXMLPath)
{
    BP_RUN_LOG_INF("load language xml failed","strLanguageXMLPath %s", strLanguageXMLPath.c_str());
	CXml xml;
	if (!xml.Load(strLanguageXMLPath.c_str(), TIXML_ENCODING_UTF8))
	{
		//表示加载资源XML不成功
		BP_RUN_LOG_ERR(IVS_FAIL,"load language xml failed","NA");
		return false;
	}

	//如果加载成功了,就遍历xml将所有的资源和语言绑定并加入map表
	if (!xml.FindElemEx("Content"))
	{
		//没找到第一个结点
		return false;
	}

	//先进行清除
	Clear();

	do 
	{
		// 获取当前结点
		const char* ResourceNode = xml.GetElem();
		// 获取当前结点的值
		const char* ResourceNodeValue = xml.GetElemValue();
		// 转换编码,防止乱码
		char* xml2ANSI = CToolsHelp::UTF8ToANSI(ResourceNodeValue);
		//把结点和值绑定进行插入
		(void)VOS_MutexLock(m_pMutexLock);
		(void)m_mapResource2Language.insert(std::make_pair(ResourceNode, xml2ANSI));
		(void)VOS_MutexUnlock(m_pMutexLock);
		free(xml2ANSI);
	} while (xml.NextElem());

	return true;
}
CRealPlay *CRealPlayMgr::GetFreeRealPlayEx(IVS_ULONG& ulHandle)
{
	CRealPlay *pRealPlay = NULL;
	pRealPlay = IVS_NEW((CRealPlay*&)pRealPlay);
	if (NULL == pRealPlay)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get Free RealPlayEx", "create real play error");
		return NULL;
	}

	BP_DBG_LOG("Get Free RealPlayEx", "CreateHandle %u", (unsigned long)pRealPlay);
	
	ulHandle = (unsigned long)pRealPlay;
	pRealPlay->SetHandle(ulHandle);
	pRealPlay->SetUserMgr(m_pUserMgr);

	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	(void)m_HanleRealPlayMap.insert(std::make_pair(ulHandle, pRealPlay));
	(void)pRealPlay->GetRef();
	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);

	return pRealPlay;
}
Ejemplo n.º 27
0
//停止所有播放
void CTelepresenceMgr::StopAllPlayByIP()
{
	IVS_DEBUG_TRACE("");
	VOS_MutexLock(m_pChannelMapMutex);

	TP_PLAY_CHANNEL_MAP::iterator iter = m_channelMap.begin();
	TP_PLAY_CHANNEL_MAP::iterator iter_end = m_channelMap.end();
	try
	{
		for(; iter!=iter_end; iter++)
		{
			CTPPlayChannel* pPlayChannel = dynamic_cast<CTPPlayChannel*>(iter->second);//lint !e611
			pPlayChannel->StopPlayByIP();
			IVS_DELETE(pPlayChannel);
		}
	}
	catch (...)
	{
	}

	m_channelMap.clear();
	VOS_MutexUnlock(m_pChannelMapMutex);
}
//检查窗口是否存在;
IVS_ULONG CRealPlayMgr::GetHandleByHwnd(HWND hWnd)
{
    IVS_ULONG ulHandle = SDK_INVALID_HANDLE;

	(void)VOS_MutexLock(m_pHanleRealPlayMutex);
	CRealPlay *pRealPlay = NULL;
	HandleRealPlayMapIter realplayIter = m_HanleRealPlayMap.begin();
    HandleRealPlayMapIter realplayIterEnd = m_HanleRealPlayMap.end();

	//查找空闲对象;
	for (;realplayIter != realplayIterEnd; realplayIter++)
	{
        pRealPlay = dynamic_cast<CRealPlay*>(realplayIter->second);//lint !e611
		if (NULL != pRealPlay && pRealPlay->IsExistHWnd(hWnd))
		{
			ulHandle = realplayIter->first;
			break;
		}
	}
	(void)VOS_MutexUnlock(m_pHanleRealPlayMutex);

	return ulHandle;
}//lint !e818
Ejemplo n.º 29
0
/*******************************************************************************
  Function:       CNVSTimer::registerTimer()
  Description:    注册定时器
  Calls:            
  Called By:      
  Input:          pTrigger: 超时处理对象实例, void *pArg: 超时处理参数, 
                  nScales: 超时事件(以init时指定的scale为单位)
                  enStyle: 检测类型    enOneShot: 触发一次, enRepeated: 循环触发
  Output:         无 
  Return:         
  VOS_SUCCESS: init success
  VOS_FAIL: init fail 
*******************************************************************************/
long CNVSTimer::registerTimer(ITrigger *pTrigger, void *pArg, ULONG nScales, 
    TriggerStyle enStyle)
{
    if (NULL == pTrigger )
    {
        IVS_RUN_LOG_ERR("NVSTimer RegisterTimer: pTrigger is NULL");
        return VOS_FAIL;
    }

    if (0 == nScales )
    {
        IVS_RUN_LOG_ERR("NVSTimer RegisterTimer: nScales is zero");
        return VOS_FAIL;
    }    

    if(  VOS_TRUE == m_bExit)
    {
        IVS_RUN_LOG_ERR("NVSTimer RegisterTimer: bExit is VOS_TRUE, thread exit");
        return VOS_FAIL;
    }
    
    CTimerItem *pTimerItem = NULL;
    (void)VOS_NEW(pTimerItem);
    if (NULL == pTimerItem )
    {
        IVS_RUN_LOG_ERR("NVSTimer RegisterTimer: new pTimerItem fail");
        return VOS_FAIL;
    }
    
    pTrigger->m_pTimerItem = pTimerItem;

    pTimerItem->m_pTrigger = pTrigger;
    pTimerItem->m_pArg = pArg;
    pTimerItem->m_ulInitialScales = nScales;
    pTimerItem->m_ullCurScales = m_ullRrsAbsTimeScales + nScales;
    pTimerItem->m_enStyle = enStyle;
    //BEGIN V100R001C05 ADD 2010-02-03 ligengqiang l00124479 for 合入朱玉军解决的黄石解码器下线问题 NP-231 
    pTimerItem->m_ulBaseTimeTicks = VOS_GetTicks();
    //END   V100R001C05 ADD 2010-02-03 ligengqiang l00124479 for 合入朱玉军解决的黄石解码器下线问题 NP-231 

    //加锁(如果和mainloop不是同一线程不需要加锁)
    VOS_BOOLEAN bNeedLock = VOS_FALSE;
    VOS_BOOLEAN bLocked = VOS_FALSE;
    if (NULL == m_pVosThread)
    {
        bNeedLock = VOS_TRUE;
    }
    else
    {
        if(VOS_pthread_self() != m_pVosThread->pthead)
        {
            bNeedLock = VOS_TRUE;
        }
    }
    
    if(VOS_TRUE == bNeedLock)
    {
        if (VOS_OK != VOS_MutexLock(m_pMutexListOfTrigger))
        {
            IVS_RUN_LOG_ERR("NVSTimer RegisterTimer: get lock failed");
        }
        else
        {
            bLocked = VOS_TRUE;
        }
    }
   
    (void)(m_plistTrigger->insert(ListOfTriggerPair(pTimerItem->m_ullCurScales, pTimerItem)));

    //解锁
    if(VOS_TRUE == bLocked)
    {
        if (VOS_OK != VOS_MutexUnlock(m_pMutexListOfTrigger))
        {
            IVS_RUN_LOG_ERR("NVSTimer RegisterTimer: release lock failed",
                _TIMER_FL_);
        }
    } 
    
    return VOS_SUCCESS;
};
Ejemplo n.º 30
0
/*******************************************************************************
  Function:       CNVSTimer::mainLoop()
  Description:    线程执行的定时检测主循环
  Calls:            
  Called By:      
  Input:          无
  Output:         无 
  Return:         无
*******************************************************************************/
void CNVSTimer::mainLoop()
{
    ULONGLONG ullCurrentScales = 0;
    while(VOS_FALSE == m_bExit)
    {

#ifdef WIN32
        Sleep(m_ulTimerScale);
#else
        struct timeval tv;
        tv.tv_sec = (long)(m_ulTimerScale/TIMER_SECOND_IN_MS);
        tv.tv_usec = (m_ulTimerScale%TIMER_SECOND_IN_MS)*TIMER_MS_IN_US;
        (void)select(0, VOS_NULL, VOS_NULL, VOS_NULL, &tv);
#endif        
        
        //加锁       
        CTimerItem *pTimerItem = NULL;
        ITrigger *pTrigger = NULL;
        ++m_ullRrsAbsTimeScales ;//内部时间基准增加一个刻度
        ullCurrentScales = m_ullRrsAbsTimeScales;

        if(VOS_OK != VOS_MutexLock(m_pMutexListOfTrigger))
        {
            break;
        };
        ListOfTriggerIte itListOfTrigger = m_plistTrigger->begin();
        ListOfTriggerIte itCurrentTrigger = m_plistTrigger->begin();
        while(itListOfTrigger != m_plistTrigger->end())
        {
            pTimerItem = (*itListOfTrigger).second;//lint !e64
            if(NULL == pTimerItem)
            {
                IVS_RUN_LOG_ERR("pTimerItem is NULL.");
                itCurrentTrigger = itListOfTrigger;
                ++itListOfTrigger;
                (void)(m_plistTrigger->erase(itCurrentTrigger));
                continue;
            }
            
            pTrigger = (ITrigger *)pTimerItem->m_pTrigger;
            
            //如果定时器已注销,删除定时器,继续查找下一个
            if((NULL == pTrigger) || (VOS_TRUE == pTimerItem->m_bRemoved))
            {
                IVS_RUN_LOG_ERR("Timer(0x%x) removed.", pTimerItem);
                itCurrentTrigger = itListOfTrigger;
                ++itListOfTrigger;
                (void)(m_plistTrigger->erase(itCurrentTrigger));
                VOS_DELETE(pTimerItem);
                continue;
            };

            //BEGIN V100R001C05 ADD 2010-02-03 ligengqiang l00124479 for 合入朱玉军解决的黄石解码器下线问题 NP-231 
            ULONG ulTimeTickInterval = VOS_GetTicks() - pTimerItem->m_ulBaseTimeTicks;
            if (ulTimeTickInterval < pTimerItem->m_ulInitialScales * m_ulTimerScale)
            {
                ++itListOfTrigger;
                continue;
            }
            pTimerItem->m_ulBaseTimeTicks = VOS_GetTicks();
            //END   V100R001C05 ADD 2010-02-03 ligengqiang l00124479 for 合入朱玉军解决的黄石解码器下线问题 NP-231 
            
            itCurrentTrigger = itListOfTrigger;
            ++itListOfTrigger;
            (void)(m_plistTrigger->erase(itCurrentTrigger));

            //触发trigger的onTrigger操作
            pTrigger->onTrigger(pTimerItem->m_pArg, 
                ullCurrentScales, pTimerItem->m_enStyle);

            //如果只触发一次,删除定时器
            if(enOneShot == pTimerItem->m_enStyle)
            {
                IVS_RUN_LOG_ERR("Timer(0x%x) remove trigger once timer.",pTimerItem);
                //防止pTrigger->onTrigger后删除定时器
                pTrigger->m_pTimerItem = NULL;
                VOS_DELETE(pTimerItem);
                continue;
            }

            //对于重复触发定时器,需要修改下次超时事件,重新加入multimap
            pTimerItem->m_ullCurScales = ullCurrentScales 
                + pTimerItem->m_ulInitialScales;
            (void)(m_plistTrigger->insert(ListOfTriggerPair(pTimerItem->m_ullCurScales, 
                pTimerItem)));
        };
        (void)VOS_MutexUnlock(m_pMutexListOfTrigger);
    }

    return;
}