📄 qsdlwidget.cpp
字号:
OutputDebugString("Create client %dth\n", temp);
RetMDDEMO(temp)->clienthandle = MP4_ClientStart(&Clientinfo, InterReadDataCallBack);
OutputDebugString("<debug_info> ......clienthandle = %d, port = %d, ChannelHandle = %d\n",
RetMDDEMO(temp)->clienthandle, temp, RetMDDEMO(temp)->ChannelHandle);
if(RetMDDEMO(temp)->clienthandle == -1)
{
OutputErrorString("<demo_info> clientstart error:%x\n", MP4_ClientGetLastErrorNum());
MP4_ClientCleanup(); /* 注意一点就是当初始化失败的时候必须将checkbutton置为FALSE */
return -1;
}
RetMDDEMO(temp)->datasum = 0;
header_len = 0;
OutputDebugString("<demo_info> to start capture!\n");
MP4_ClientStartCaptureEx(RetMDDEMO(temp)->clienthandle, streamheader, &header_len);
if(header_len == 0)
{
OutputErrorString("<demo_info> have not get the stream header!\n");
return -1;
}
OutputDebugString("<demo_info> get the stream header!len:%d\n", header_len);
timer[temp]->start(200);
time[temp]->restart();
mddemoclass[temp]->StartStreamPlay(streamheader, header_len);
OutputDebugString("here now the Mp4 client run well, %x\n", MP4_ClientGetLastErrorNum());
}
}
else
{
if(RetMDDEMO(SelectPort)->bDisplayOpen)
mddemoclass[SelectPort]->StopPlay();
Clientinfo.m_bRemoteChannel = RetMDDEMO(SelectPort)->serverchan;
/*
* strcpy(Clientinfo.m_sIPAddress, RetMDDEMO(i)->serverip);
*/
Clientinfo.m_sIPAddress = RetMDDEMO(SelectPort)->serverip;
RetMDDEMO(SelectPort)->clienthandle = MP4_ClientStart(&Clientinfo, InterReadDataCallBack);
OutputDebugString("<debug_info> ......clienthandle = %d, port = %d, ChannelHandle = %d\n",
RetMDDEMO(SelectPort)->clienthandle, SelectPort,
RetMDDEMO(SelectPort)->ChannelHandle);
if(RetMDDEMO(SelectPort)->clienthandle == -1)
{
OutputErrorString("<demo_info> clientstart error:%x\n", MP4_ClientGetLastErrorNum());
MP4_ClientCleanup(); /* 注意一点就是当初始化失败的时候必须将checkbutton置为FALSE */
return -1;
}
RetMDDEMO(SelectPort)->datasum = 0;
header_len = 0;
OutputDebugString("<demo_info> to start capture!\n");
MP4_ClientStartCaptureEx(RetMDDEMO(SelectPort)->clienthandle, streamheader, &header_len);
if(header_len == 0)
{
OutputErrorString("<demo_info> have not get the stream header!\n");
return -1;
}
OutputDebugString("<demo_info> get the stream header!len:%d\n", header_len);
timer[SelectPort]->start(200);
time[SelectPort]->restart();
mddemoclass[SelectPort]->StartStreamPlay(streamheader, header_len);
}
RunStream = 1;
return 0;
}
/*
=======================================================================================================================
*
=======================================================================================================================
*/
void QSDLWidget::OpenVideoOut()
{
REGION_PARAM param[MAX_DISPLAY_REGION];
int i;
int retval;
memset(param, 0x0, sizeof(param));
for(i = 0; i < MAX_DISPLAY_REGION; i++)
{
param[i].r = i * 8 + 128;
param[i].g = i * 16;
param[i].b = i * 16;
}
/* to set the port 0 as the 4 cif windows */
param[0].left = 0;
param[0].top = 0;
param[0].width = 352;
param[0].height = 288;
param[1].left = 352;
param[1].top = 0;
param[1].width = 352;
param[1].height = 288;
param[2].left = 0;
param[2].top = 288;
param[2].width = 352;
param[2].height = 288;
param[3].left = 352;
param[3].top = 288;
param[3].width = 352;
param[3].height = 288;
SetDisplayRegion(0, 4, param, 0); /* here 4个视频输出(矩阵输出) */
/* to set the port1 as the 1 4Cif window */
param[0].left = 0;
param[0].top = 0;
param[0].width = 704;
param[0].height = 576;
SetDisplayRegion(1, 1, param, 0); /* here 1个视频输出 */
#ifdef DEBUG_OUT
param[0].left = 0;
param[0].top = 0;
param[0].width = 352;
param[0].height = 288;
param[1].left = 352;
param[1].top = 288;
param[1].width = 352;
param[1].height = 288;
retval = SetDisplayRegion(2, 2, param, 0); /* here 1个视频输出 */
if(retval < 0)
OutputErrorString("SetDisplayRegion error 1, error number 0x%x\n", GetLastErrorNum());
param[0].left = 352;
param[0].top = 0;
param[0].width = 352;
param[0].height = 288;
param[1].left = 0;
param[1].top = 288;
param[1].width = 352;
param[1].height = 288;
retval = SetDisplayRegion(3, 2, param, 0); /* here 1个视频输出 */
if(retval < 0)
OutputErrorString("SetDisplayRegion error 2, error number 0x%x\n", GetLastErrorNum());
#endif
retval = SetDecoderVideoOutput(0, 0, 1, 0, 0, 0);
if(retval < 0)
OutputErrorString("Video Out error 1, error number 0x%x\n", GetLastErrorNum());
retval = SetDecoderVideoOutput(1, 0, 1, 0, 1, 0);
if(retval < 0)
OutputErrorString("Video Out error 2, error number 0x%x\n", GetLastErrorNum());
retval = SetDecoderVideoOutput(2, 0, 1, 0, 2, 0);
if(retval < 0)
OutputErrorString("Video Out error 3, error number 0x%x\n", GetLastErrorNum());
/*
* Set the video from the last decode out to as the region4 in por0 and the whole
* port1
*/
SetDecoderVideoOutput(3, 0, 1, 0, 3, 0);
SetDecoderVideoOutput(3, 1, 1, 1, 0, 0);
#ifdef DEBUG_OUT
SetDecoderVideoOutput(4, 0, 1, 0, 0, 0);
SetDecoderVideoOutput(4, 1, 1, 0, 1, 0);
SetDecoderVideoOutput(5, 0, 1, 1, 0, 0);
SetDecoderVideoOutput(6, 0, 1, 1, 1, 0);
#endif
SetDecoderAudioOutput(0, 1, 0);
SetDecoderAudioOutput(1, 1, 1);
RunVideoOut = 1;
#ifdef RAWSTREAM /* start */
if(SetDisplayVideoCapture(1, 1, 25, 704, 576, imagebuf) < 0) /* 第一个参数是显示通道 */
OutputErrorString("<demo_info>.............. set the image stream capture failed!\n");
OutputErrorString("<demo_info> ................start image raw stream capture ok!\n");
#endif
}
/*
=======================================================================================================================
*
=======================================================================================================================
*/
void QSDLWidget::CloseVideoOut()
{
int i;
SetDecoderVideoOutput(0, 0, 0, 0, 0, 0);
SetDecoderVideoOutput(1, 0, 0, 0, 1, 0);
SetDecoderVideoOutput(2, 0, 0, 0, 2, 0);
SetDecoderVideoOutput(3, 0, 0, 0, 3, 0);
SetDecoderVideoOutput(3, 1, 0, 1, 0, 0);
#ifdef DEBUG_OUT
SetDecoderVideoOutput(4, 0, 0, 0, 0, 0);
SetDecoderVideoOutput(4, 1, 0, 0, 1, 0);
SetDecoderVideoOutput(5, 0, 0, 1, 0, 0);
SetDecoderVideoOutput(6, 0, 0, 1, 1, 0);
#endif
/* stop the audio out */
SetDecoderAudioOutput(0, 0, 0);
SetDecoderAudioOutput(1, 0, 1);
for(i = 0; i < GetDisplayChannelCount(); i++)
ClearDisplayRegion(i, 0xffff);
RunVideoOut = 0;
#ifdef RAWSTREAM /* stop */
if(SetDisplayVideoCapture(1, 0, 25, 704, 576, imagebuf) < 0)
OutputErrorString("<demo_info>.............. stop the image stream capture failed!\n");
OutputErrorString("<demo_info> ................stop image raw stream capture ok!\n");
#endif
}
/*
=======================================================================================================================
*
=======================================================================================================================
*/
QSDLWidget::~QSDLWidget()
{
int i;
int tempHandle;
#ifdef RAWSTREAM
if(!rawFile)
{
delete rawFile;
rawFile = NULL;
}
if(!imagebuf)
{
free(imagebuf);
imagebuf = NULL;
}
#endif
if(playSoundPort != -1)
StopSound();
FileStreamClose(DECODEFILE);
usleep(200);
OutputDebugString("ending Decode File\n");
FileStreamClose(DECODESTREAM);
usleep(100);
OutputDebugString("ending Decode Net Stream\n");
if(RunVideoOut)
CloseVideoOut();
RunVideoOut = 0;
if(mddemoclass)
{
for(i = 0; i < totalport; i++)
{
tempHandle = RetMDDEMO(i)->ChannelHandle;
delete mddemoclass[i];
mddemoclass[i] = NULL;
HW_ChannelClose(tempHandle);
}
free(mddemoclass);
mddemoclass = NULL;
}
if(timer)
{
for(i = 0; i < totalport; i++)
{
delete timer[i];
delete time[i];
}
free(timer);
free(time);
}
#ifdef CIRCLE
pthread_mutex_destroy(&mutex);
#endif
OutputDebugString("Before HW_ReleaseDecDevice\n");
HW_ReleaseDecDevice();
SDL_Quit();
}
/*
=======================================================================================================================
*
=======================================================================================================================
*/
inline MDDEMO* QSDLWidget::RetMDDEMO(int port)
{
if(port < 0 || port > totalport)
return NULL;
if(!mddemoclass || !(mddemoclass[port]) || !(mddemoclass[port]->mddemo))
return NULL;
return mddemoclass[port]->mddemo;
}
/*
=======================================================================================================================
*
=======================================================================================================================
*/
int QSDLWidget::GetChanNum()
{
int chan = 1;
if(totalport <= 4)
chan = 2;
else
{
if(totalport <= 9)
chan = 3;
else
{
if(totalport <= 16)
chan = 4;
else
{
if(totalport <= 25)
chan = 5;
else
chan = 6;
}
}
}
return chan;
}
/*
=======================================================================================================================
*
=======================================================================================================================
*/
int QSDLWidget::PtInRect(SDL_Rect rect, int x, int y)
{
if((x > rect.x) && (x < (rect.x + rect.w)) && (y > rect.y) && (y < (rect.y + rect.h)))
return 1;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -