2011-8-11 10:53:13
现在搭一个环境测试一下
多次点播不出图像的问题
刚收到数据的时候写下了文件
FILE * output1 = fopen("D:\\amplesky\\software_ps\\web\\log\\OUT1.mp4", "w+b");
if (output1 != NULL)
{
fwrite(&pTmpBuffer[hdr],sizeof(char),1,output1);
}
只针对单个源的测试
if(lpReqTCP->iStreamType == STREAM_VIDEO)
{
bool needIframe =false;
this0->m_iFrameNum = 0;
if(!this0->OpenDeviceChannel(lpReqTCP->iChannel - 1))
{
needIframe = true;
AMP_STRU_REPLY_TCP_PREVIEW_EX sReplyTCP;
memset(&sReplyTCP, 0, sizeof(AMP_STRU_REPLY_TCP_PREVIEW_EX));
sReplyTCP.iErrorCode = AMP_NETSDK_NOERROR;
memcpy(&(sReplyTCP.sHeader), &(this0->m_channel[lpReqTCP->iChannel-1].m_sHeader), sizeof(TSTREAM_HEADER));
char tmp[512];
sprintf(tmp,"AMP_REPLY_TCP_PREVIEW already open recv tickcount %d \n",GetTickCount());
AMP_PS_DEBUG(tmp);
SendMessageToDevice(acceptsocket, AMP_REPLY_TCP_PREVIEW, sizeof(AMP_STRU_REPLY_TCP_PREVIEW_EX), &sReplyTCP);
EnterCriticalSection(&this0->m_channel[lpReqTCP->iChannel-1].m_csVideoSocket);
this0->m_channel[lpReqTCP->iChannel-1].m_setVideoSendSocket.insert(acceptsocket);
LeaveCriticalSection(&this0->m_channel[lpReqTCP->iChannel-1].m_csVideoSocket);
}
//现在测试一下
//EnterCriticalSection(&this0->m_channel[lpReqTCP->iChannel-1].m_csVideoSocket);
//this0->m_channel[lpReqTCP->iChannel-1].m_setVideoSendSocket.insert(acceptsocket);
//LeaveCriticalSection(&this0->m_channel[lpReqTCP->iChannel-1].m_csVideoSocket);
if (needIframe)
{
this0->m_needIframe = true;
}
}
else
{
AMP_STRU_REPLY_TCP_PREVIEW sReplyTCP;
memset(&sReplyTCP, 0, sizeof(AMP_STRU_REPLY_TCP_PREVIEW));
sReplyTCP.iErrorCode = AMP_NETSDK_NOERROR;
SendMessageToDevice(acceptsocket, AMP_REPLY_TCP_PREVIEW, sizeof(AMP_STRU_REPLY_TCP_PREVIEW), &sReplyTCP);
EnterCriticalSection(&this0->m_channel[lpReqTCP->iChannel-1].m_csAudioSocket);
this0->m_channel[lpReqTCP->iChannel-1].m_setAudioSendSocket.insert(acceptsocket);
LeaveCriticalSection(&this0->m_channel[lpReqTCP->iChannel-1].m_csAudioSocket);
}
只有视频才会向3G设备请求
OpenDeviceChannel
只是在没有对讲且没有视频socket的时候,才会向3G设备请求
CloseDeviceChannel
也就是说打开和关闭都是在没有视频socket的情况下才会进行
那么在什么情况下调用呢?
对方是怎么关闭的?
打开是直接建立socket thread 在各自socket上发送请求
关闭是直接关闭socket,线程退出 在命令通道上发送关闭请求
对这边有影响么?
设备回应
LPAMP_STRU_REPLY_TCP_PREVIEW_EX lpReplyTCP = (LPAMP_STRU_REPLY_TCP_PREVIEW_EX)lpPDU->iMessageBody;
this0->SendMessageToNETSDK(acceptsocket, AMP_REPLY_TCP_PREVIEW, sizeof(AMP_STRU_REPLY_TCP_PREVIEW_EX), lpReplyTCP);
if(ntohl(lpReplyTCP->iErrorCode == AMP_PROXY_NOERROR))
{
this0->SetStreamHeader(acceptsocket, ntohl(lpReplyTCP->iChannel) - 1, &(lpReplyTCP->sHeader));
}
设备回应 相当重要的一个东西就是编码头了
m_mapSocketInfo 存放了所有的接受socket
并且存放了所有的socket上存放的信息类型
bool bRet = false;
EnterCriticalSection(&m_csLockSocket);
std::map<SOCKET, int>::iterator iterSocket = m_mapSocketInfo.begin();
while (iterSocket != m_mapSocketInfo.end())
{
if(iMessType == iterSocket->second + 1)
{
// AMP_PS_DEBUG("SendMessageToDevice\n");
SendMessageToDevice(iterSocket->first, iMessType, uiMessLen, pMessBody);
#ifdef _DEBUG
char tmp[512];
sprintf(tmp,"op = %d, last op = %d\n", iMessType, iterSocket->second);
AMP_PS_DEBUG(tmp);
#endif
if (iMessType == AMP_REPLY_TCP_PREVIEW)
{
#ifdef _DEBUG
char tmp[512];
sprintf(tmp,"AMP_REPLY_TCP_PREVIEW op = %d, last op = %d\n", iMessType, iterSocket->second);
AMP_PS_DEBUG(tmp);
#endif
EnterCriticalSection(&m_channel[0].m_csVideoSocket);
m_channel[0].m_setVideoSendSocket.insert(iterSocket->first);
LeaveCriticalSection(&m_channel[0].m_csVideoSocket);
}
iterSocket->second = iMessType;
bRet = true;
break;
}
iterSocket++;
}
LeaveCriticalSection(&m_csLockSocket);