示例#1
0
void DevChannelHK::onPreview(DWORD dwDataType, BYTE* pBuffer, DWORD dwBufSize) {
	//TimeTicker1(-1);
	switch (dwDataType) {
	case NET_DVR_SYSHEAD: { //系统头数据
		if (!PlayM4_GetPort(&m_iPlayHandle)) {  //获取播放库未使用的通道号
			WarnL << "PlayM4_GetPort:" << NET_DVR_GetLastError();
			break;
		}
		if (dwBufSize > 0) {
			if (!PlayM4_SetStreamOpenMode(m_iPlayHandle, STREAME_REALTIME)) { //设置实时流播放模式
				WarnL << "PlayM4_SetStreamOpenMode:" << NET_DVR_GetLastError();
				break;
			}
			if (!PlayM4_OpenStream(m_iPlayHandle, pBuffer, dwBufSize,
					1024 * 1024)) {  //打开流接口
				WarnL << "PlayM4_OpenStream:" << NET_DVR_GetLastError();
				break;
			}

			PlayM4_SetDecCallBackMend(m_iPlayHandle,
					[](int nPort,char * pBuf,int nSize,FRAME_INFO * pFrameInfo, void* nUser,int nReserved2) {
						DevChannelHK *chn=reinterpret_cast<DevChannelHK *>(nUser);
						if(chn->m_iPlayHandle!=nPort) {
							return;
						}
						chn->onGetDecData(pBuf,nSize,pFrameInfo);
					}, this);
			if (!PlayM4_Play(m_iPlayHandle, 0)) {  //播放开始
				WarnL << "PlayM4_Play:" << NET_DVR_GetLastError();
				break;
			}
			InfoL << "设置解码器成功!" << endl;
			//打开音频解码, 需要码流是复合流
			if (!PlayM4_PlaySoundShare(m_iPlayHandle)) {
				WarnL << "PlayM4_PlaySound:" << NET_DVR_GetLastError();
				break;
			}
		}
	}
		break;
	case NET_DVR_STREAMDATA: { //流数据(包括复合流或音视频分开的视频流数据)
		if (dwBufSize > 0 && m_iPlayHandle != -1) {
			if (!PlayM4_InputData(m_iPlayHandle, pBuffer, dwBufSize)) {
				WarnL << "PlayM4_InputData:" << NET_DVR_GetLastError();
				break;
			}
		}
	}
		break;
	case NET_DVR_AUDIOSTREAMDATA: { //音频数据
	}
		break;
	case NET_DVR_PRIVATE_DATA: { //私有数据,包括智能信息
	}
		break;
	default:
		break;
	}
}
示例#2
0
BOOL CPlayerHik::PlaySoundShare()
{
	return PlayM4_PlaySoundShare(m_nPort);

}