📄 qsdlwidget.cpp
字号:
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -