📄 qsdlwidget.cpp
字号:
dsdemoclass[SelectPort]->SetMaxBpsMode();}void QSDLWidget::BitRateAllSet(int MaxBps, BitrateControlType_t brc){ int temp = SelectPort; int port; for (port = 0; port < GetTotalChannels(); port++) { SelectPort = port; BitRateSet(MaxBps, brc); } SelectPort = temp;}int QSDLWidget::AllRecordStatus(){ int port; for (port = 0; port < GetTotalChannels(); port++) { if (!(DSCLASSDEMO(port)->record_flag)) { return 0; } } return 1;}void QSDLWidget::RecordAllSet(bool on){ OutputDebugString("Beginning Record.........\n"); int temp = SelectPort; int port; if ( on ) { for(port = 0; port < GetTotalChannels(); port++) { SelectPort = port; if(!(DSCLASSDEMO(SelectPort)->record_flag)) RecordSet(TRUE); } } else { for(port = 0; port < GetTotalChannels(); port++) { SelectPort = port; if(DSCLASSDEMO(SelectPort)->record_flag) RecordSet(FALSE); } } SelectPort = temp;}void QSDLWidget::RecordSet( bool on){ if ( on ) { Qtloop[SelectPort]->start(1000 * TIMECONST); if ( !(DSCLASSDEMO(SelectPort)->net_flag) ) { timer[SelectPort] -> start(200); time[SelectPort] -> restart(); DSCLASSDEMO(SelectPort)->countdays = 0; } dsdemoclass[SelectPort]->CreateFiles(); if ( !DSCLASSDEMO(SelectPort)->net_flag ) dsdemoclass[SelectPort]->StartCapture(); DSCLASSDEMO(SelectPort)->record_flag = 1; } else { OutputDebugString("in RecordSet false \n"); Qtloop[SelectPort]->stop(); if (!(DSCLASSDEMO(SelectPort)->net_flag) ) { timer[SelectPort] ->stop(); emit audioChange(SelectPort, (float)0.0); emit videoChange(SelectPort, (float)0.0); emit totalChange(SelectPort, 0); emit bitRateChange(SelectPort, 0); emit countChange(0); dsdemoclass[SelectPort]->StopCapture(); //if(StopVideoCapture(DSCLASSDEMO(SelectPort)->ChannelHandle) < 0) // printf("record_callback: StopvideoCapture(port %d) failed\n", SelectPort); } dsdemoclass[SelectPort]->end_record(); DSCLASSDEMO(SelectPort)->bit_rate_size = 0; DSCLASSDEMO(SelectPort)->count = 0; DSCLASSDEMO(SelectPort)->record_flag = 0; DSCLASSDEMO(SelectPort)->Maxcount =0; DSCLASSDEMO(SelectPort)->filehead_flag = 0; }}void QSDLWidget::RecordSubAllSet(bool on){ int temp = SelectPort; int port; if ( on ) { for(port = 0; port < GetTotalChannels(); port++) { SelectPort = port; if(!(DSCLASSDEMO(SelectPort)->cifqcif_flag)) RecordSubSet(TRUE); } } else { for(port = 0; port < GetTotalChannels(); port++) { SelectPort = port; if(DSCLASSDEMO(SelectPort)->cifqcif_flag) RecordSubSet(FALSE); } } SelectPort = temp;}void QSDLWidget::RecordSubSet(bool on){ if ( on ) { if (DSCLASSDEMO(SelectPort)->cifqcif_flag == 0) { DSCLASSDEMO(SelectPort)->cifqcif_flag = 1; dsdemoclass[SelectPort]->CreateCifQcifFiles(); dsdemoclass[SelectPort]-> StartSubCapture(); //if( DSCLASSDEMO(SelectPort)-> cifqciffilehead_flag == 0 && (DSCLASSDEMO(SelectPort)->cifqciffile_head[0]!=0)) // (DSCLASSDEMO(SelectPort)-> cifqcif_fd)->writeBlock(DSCLASSDEMO(SelectPort)->cifqciffile_head, 40); } } else { if (DSCLASSDEMO(SelectPort)->cifqcif_flag) { dsdemoclass[SelectPort]->end_subrecord(); dsdemoclass[SelectPort]-> StopSubCapture(); DSCLASSDEMO(SelectPort)->cifqcif_flag = 0; DSCLASSDEMO(SelectPort)-> cifqciffilehead_flag = 0; } }}void QSDLWidget::GetBmpPicture(int count){ int size; unsigned char imagebuf[704 * 576 * 2]; char savepath[10] = "."; QFile *temp; char qsFile[40]; sprintf(qsFile, "%s/BMP_P%02dC%02d.bmp", savepath, SelectPort, count); GetOriginalImage(DSCLASSDEMO(SelectPort) -> ChannelHandle, imagebuf, &size); temp = new QFile(qsFile); temp->open(IO_ReadWrite | IO_Truncate ); delete temp; if(size == 704 * 576 * 2) //PAL SaveYUVToBmpFile(qsFile, imagebuf, 704, 576); if(size == 704 * 480 * 2) //NTSC SaveYUVToBmpFile(qsFile, imagebuf, 704, 480); }void QSDLWidget::GetJpegPicture(int count, int quality) { long unsigned int size = 704 * 576 * 2; unsigned char *imagebuf; char savepath[10] = "."; char qsFile[40]; imagebuf = new unsigned char[size]; QFile *temp; sprintf(qsFile, "%s/Jpeg_P%02dC%02d.jpg", savepath, SelectPort, count); GetJpegImage(DSCLASSDEMO(SelectPort) -> ChannelHandle, imagebuf, &size, quality); temp = new QFile(qsFile); temp->open( IO_WriteOnly | IO_Truncate ); temp->writeBlock((char *)imagebuf, size); delete temp; delete imagebuf;}void QSDLWidget::GetBmpAllPicture(int count){ int temp = SelectPort; int port; for (port = 0; port < GetTotalChannels(); port++) { SelectPort = port; GetBmpPicture(count); } SelectPort = temp;}void QSDLWidget::GetJpegAllPicture(int count, int quality){ int temp = SelectPort; int port; for (port = 0; port < GetTotalChannels(); port++) { SelectPort = port; OutputDebugString("start get port%2d jpeg picture\n", port); GetJpegPicture(count, quality); } SelectPort = temp; OutputDebugString("end GetJpegAllPicture\n");}void QSDLWidget::start_capture_callback(int port){ int totalport; totalport = GetTotalChannels(); if(( port < totalport) && (!(DSCLASSDEMO(port)->record_flag))) //fixed at 2004.11.11 { OutputDebugString("start capture callback\n"); dsdemoclass[port]->StartCapture(); }}void QSDLWidget::stop_capture_callback(int port) { int totalport; totalport = GetTotalChannels(); if(( port < totalport) && (!(DSCLASSDEMO(port)->record_flag))) // fixed at 2004.11.11 { OutputDebugString("in stop_capture_callback\n"); dsdemoclass[port]->StopCapture(); emit audioChange(port,(float)0.0); emit videoChange(port, (float)0.0); emit totalChange(port, 0); emit bitRateChange(port, 0); emit countChange(0); } DSCLASSDEMO(port)->net_head_flag = 0; DSCLASSDEMO(port)->subchan_net_head_flag = 0;}void QSDLWidget::message_callback(char *buf, int length){ OutputDebugString("Get a message from client: length = %d, message = %s\n",length, buf); }int QSDLWidget::check_IP_callback(int channel, char *sIP){ OutputErrorString("Check IP: channel = %d, IP= %s\n", channel, sIP); return 0;}int QSDLWidget::check_password_callback(char *username, int namelen, char *password, int passlen){ OutputErrorString("Check password: username = %s, namelen = %d, password = %s, passname = %d\n", username, namelen, password, passlen); return 0;}int QSDLWidget::checkIpAndPass(int channel, char *username, int namelen, char *password, int passlen, char *sIP){ OutputDebugString("Check IP: channel = %d, IP= %s; username = %s, namelen = %d, password = %s, passname = %d\n", channel, sIP, username, namelen, password, passlen); checkpass[channel] = 1; return 0;}void QSDLWidget::disconnect_callback(int nport, char* sIP){ OutputErrorString("the client from ip %s to channel %d disconnect!\n", sIP,nport); checkpass[nport] = 0;}void QSDLWidget::NetTransferSet(bool on){ int port; SERVER_VIDEOINFO videoinfo; int totalport; totalport = GetTotalChannels(); memset(&videoinfo, 0, sizeof(SERVER_VIDEOINFO)); if ( on ) { for(port = 0; port < totalport; port++) MP4_ServerSetBufNum(port, 60); MP4_ServerSetStart(InterStart); MP4_ServerSetStop(InterStop); MP4_ServerSetMessage(InterMessage); MP4_ServerSetNetPort(5050, 6050); videoinfo.m_channum = totalport; for (port = 0; port < totalport; port++) { if (!(DSCLASSDEMO(port)->record_flag)) { timer[port] -> start(200); time[port] -> restart(); DSCLASSDEMO(SelectPort)->countdays = 0; } } if ( MP4_ServerStart(&videoinfo) < 0 ) { for(port = 0; port < totalport; port++) { if ((timer[port] -> isActive())&&(!(DSCLASSDEMO(port)->record_flag))) timer[port]->stop(); DSCLASSDEMO(port)->net_flag = 0; OutputErrorString("because of MP4_ServerStart failed, so stop the timer! \n"); } } else { for ( port =0; port < totalport; port++) DSCLASSDEMO(port)->net_flag = 1; MP4_ServerCheckIP(InterIP); MP4_ServerCheckPassword(InterPassword); MP4_ServerCheckIPandPassword(InterCheck); MP4_ServerDisconnectEvent(InterDisconnect); } } else { for (port = 0; port < totalport; port++) { if (!(DSCLASSDEMO(port)->record_flag)) timer[port]->stop(); DSCLASSDEMO(port)->net_flag = 0; } MP4_ServerStop(); OutputDebugString("After MP4_serverStop() func, totalport = %d\n", totalport); }}void QSDLWidget::MotionSet(bool on){ if( on ) { OutputDebugString("<demo_info> start chan%d 's motion detection!\n", SelectPort); if (!(DSCLASSDEMO(SelectPort)->motion_flag)) { dsdemoclass[SelectPort]->SetupMotion(); DSCLASSDEMO(SelectPort)->motion_flag = 1; } } else // stop motion detect { if ( DSCLASSDEMO(SelectPort)->motion_flag ) { dsdemoclass[SelectPort]->DestoryMotion(); DSCLASSDEMO(SelectPort)->motion_flag = 0; } } }void QSDLWidget::MotionAllSet(bool on){ int temp = SelectPort; int port; for (port = 0; port < GetTotalChannels(); port++) { SelectPort = port; MotionSet(on); } SelectPort = temp;}void QSDLWidget::MotionSenSet(int value){ DSCLASSDEMO(SelectPort) -> motionSens = value; AdjustMotionDetectPrecision( DSCLASSDEMO(SelectPort)->ChannelHandle, value, 2, 0); StartMotionDetection(DSCLASSDEMO(SelectPort)->ChannelHandle);}void QSDLWidget::MotionSenAllSet(int value){ int temp = SelectPort; int port; for (port = 0; port < GetTotalChannels(); port++) { SelectPort = port; MotionSenSet(value); } SelectPort = temp;}void QSDLWidget::AudioSet(bool on){ int ret; int temp; ret = GetTotalChannels(); if ( on ) { for (temp = 0; temp < ret; temp++) { if ( DSCLASSDEMO(temp)->audio_flag ) break; } if (temp != ret) { SetAudioPreview(DSCLASSDEMO(temp)->ChannelHandle, 0); DSCLASSDEMO(temp)->audio_flag = 0; } ret = SetAudioPreview(DSCLASSDEMO(SelectPort)->ChannelHandle, 1); if(ret < 0) { OutputErrorString("Audio preview error \n"); return; } DSCLASSDEMO(SelectPort)->audio_flag = 1; } else { SetAudioPreview(DSCLASSDEMO(SelectPort)->ChannelHandle, 0); DSCLASSDEMO(SelectPort)->audio_flag = 0; }}void QSDLWidget::PreviewAllSet(bool on){ int tempport = SelectPort; int port; if (FullArea) PreviewSet(on); else { for (port = 0; port < GetTotalChannels(); port++) { SelectPort = port; PreviewSet(on); } } SelectPort = tempport;}void QSDLWidget::PreviewSet(bool on){ int port; int totalport; totalport = GetTotalChannels(); if ( on ) { if ( FullArea ) { OutputDebugString("debug here FULL\n"); if(!(DSCLASSDEMO(SelectPort)->bPreviewOpen)) { #ifdef USE_PREVIEW_TIMER dsdemoclass[SelectPort]-> SetPreview(0);#else dsdemoclass[SelectPort]-> SetPreview(1);#endif } } else { OutputDebugString("debug here\n"); if(!(DSCLASSDEMO(SelectPort)->bPreviewOpen)) { OutputDebugString("PreviewSet:Port%d=%d\n", SelectPort, DSCLASSDEMO(SelectPort)->bPreviewOpen);#ifdef USE_PREVIEW_TIMER dsdemoclass[SelectPort]-> SetPreview(0);#else dsdemoclass[SelectPort]-> SetPreview(1);#endif } for(port = 0; port < totalport; port++) { if(!(DSCLASSDEMO(port)->bPreviewOpen)) { QPainter Qp; Qp.begin(this); Qp.eraseRect((DSCLASSDEMO(SelectPort)->dstRect).x, (DSCLASSDEMO(SelectPort)->dstRect).y, (DSCLASSDEMO(SelectPort)->dstRect).w, (DSCLASSDEMO(SelectPort)->dstRect).h); Qp.end(); } } } } else { if ( FullArea ) { if(DSCLASSDEMO(SelectPort)->bPreviewOpen) dsdemoclass[SelectPort]-> StopPreview(); QPainter Qp; Qp.begin(this); Qp.eraseRect(WIN_L, WIN_T, WIN_W, WIN_H); Qp.end(); } else { if(DSCLASSDEMO(SelectPort)->bPreviewOpen) dsdemoclass[SelectPort]-> StopPreview(); for(port = 0; port < totalport; port++) { if(!(DSCLASSDEMO(port)->bPreviewOpen)) { QPainter Qp; Qp.begin(this); Qp.eraseRect((DSCLASSDEMO(SelectPort)->dstRect).x, (DSCLASSDEMO(SelectPort)->dstRect).y, (DSCLASSDEMO(SelectPort)->dstRect).w, (DSCLASSDEMO(SelectPort)->dstRect).h); Qp.end(); } } } }}void QSDLWidget::StringToClientSet(bool on){ int port; char messagebuf[256]; if ((!(DSCLASSDEMO(SelectPort)->net_flag)) && on ) { emit noNet(); return; } if ( on ) { for( port = 0; port < 2; port++) /* test the string to client */ { sprintf(messagebuf, "server message to client, no.%d!\n", port); if(MP4_ServerStringToClient("192.0.4.166", messagebuf, strlen(messagebuf))) OutputErrorString("return bad value : %d\n", MP4_ServerGetLastErrorNum()); OutputDebugString("<demo_info> have send the len %d message to client!\n", strlen(messagebuf)); } }}void QSDLWidget::BrightnessSet(int value){ dsdemoclass[SelectPort]->SetBrightScale(value);}void QSDLWidget::BrightnessAllSet(int value){ int temp = SelectPort; int port; for (port = 0; port < GetTotalChannels(); port++) { SelectPort = port; BrightnessSet(value); } SelectPort = temp;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -