예제 #1
0
BOOL Camera::DataHandler1(VideoFrame& frame)
{
	//VDC_DEBUG( "%s  %d\n",__FUNCTION__, frame.dataLen);
	Lock();
	/* Frist cache the info frame */
	if (frame.streamType == VIDEO_STREAM_INFO)
	{
		memcpy(&m_infoData, frame.dataBuf, sizeof(InfoFrame));
		m_bGotInfoData = TRUE;
	}
	
	/* 1. Send to network client */
	CameraDataCallbackMap::iterator it = m_DataMap.begin();

	for(; it!=m_DataMap.end(); ++it)
	{
	    void *pParam = (*it).first;
	    CameraDataCallbackFunctionPtr pFunc = (*it).second;
	    if (pFunc)
	    {
	        pFunc(frame, pParam);
	    }
	}

	m_cRecordWrapper.PushAFrame(frame);

	/* Call the Sub DataHandler if there has no sub stream */
	if (m_param.m_bHasSubStream == FALSE)
	{
		SubDataHandler1(frame);
	}
	UnLock();
	return TRUE;
}
예제 #2
0
BOOL Device::DataHandler1(VideoFrame& frame)
{
	Lock();
	/* Frist cache the info frame */
	if (frame.streamType == VIDEO_STREAM_INFO)
	{
		memcpy(&m_infoData, frame.dataBuf, sizeof(InfoFrame));
		m_bGotInfoData = TRUE;
	}
	
	/* 1. Send to network client */
	DeviceDataCallbackMap::iterator it = m_DataMap.begin();

	for(; it!=m_DataMap.end(); ++it)
	{
	    void *pParam = (*it).first;
	    DeviceDataCallbackFunctionPtr pFunc = (*it).second;
	    if (pFunc)
	    {
	        pFunc(frame, pParam);
	    }
	}

	/* 2. Send to Record */
	if (m_param.m_Conf.data.conf.Recording == 1)
	{
		if (m_pRecord == NULL)
		{
		    m_pRecord = m_pVdb.StartRecord(m_param.m_Conf.data.conf.nId, (int)(frame.secs), R_MANUAL);
		}
		
		//VDC_DEBUG("Recording Size %d stream %d frame %d (%d, %d)\n", frame.dataLen,      
		// 	frame.streamType, frame.frameType, frame.secs, frame.msecs);
		
		/* Just skip the info stream for recording */
		if (m_pRecord != NULL 
		&& frame.streamType != VIDEO_STREAM_INFO && m_pRecord->PushAFrame(&frame) == MF_WRTIE_REACH_END)
		{
			u32 endTime = m_pRecord->GetEndTime();
			if (endTime != 0)
			{
				m_pVdb.FinishRecord(m_pRecord);
			}
		    	delete m_pRecord;
		    	m_pRecord = m_pVdb.StartRecord(m_param.m_Conf.data.conf.nId, (int)(frame.secs), 1);
			if (m_pRecord != NULL)
			{
			       m_pRecord->PushAFrame(&frame);	 
			}
		}
	}
	
	/* 2. Send to Hdfs Record */
	if (m_param.m_Conf.data.conf.HdfsRecording == 1)
	{
		if (m_pHdfsRecord == NULL)
		{
			m_pHdfsRecord = m_pVHdfsdb.StartRecord(
				m_param.m_Conf.data.conf.nId, m_param.m_Conf.data.conf.Name);
		}
		if (m_pHdfsRecord != NULL)
		{
			m_pHdfsRecord->PushAFrame(&frame);
		}
	}
	/* Call the Sub DataHandler if there has no sub stream */
	if (m_param.m_bHasSubStream == FALSE)
	{
		SubDataHandler1(frame);
	}
	UnLock();
	return TRUE;
}