📄 dsdemo.cpp
字号:
(dsdemo->cifqcif_fd)->writeBlock(dsdemo->cifqciffile_head, 40); pthread_mutex_unlock(&(dsdemo->minor_start)); OutputDebugString("create cifqcif file%02d\n", SignPort);}void Dsclass::CreateImageStreamFiles(){ char savepath[10] = "."; QString qsFile; QFile *temp; pthread_mutex_lock(&(dsdemo->imagefile_fd_start)); end_imagestream(); qsFile.sprintf("%s/imagefileP%02dC%02d.yuv", savepath, SignPort, dsdemo->count); temp = new QFile(qsFile); temp ->open(IO_ReadWrite | IO_Truncate ); dsdemo->imagefile_fd = temp; pthread_mutex_unlock(&(dsdemo->imagefile_fd_start));}void Dsclass::StopCapture(){ StopVideoCapture(dsdemo->ChannelHandle); dsdemo -> bit_rate_size = 0;}void Dsclass::StopSubCapture(){ StopSubVideoCapture(dsdemo->ChannelHandle);}void Dsclass::StartCapture(){ int retval; dsdemo->bit_rate_size = 0; retval = StartVideoCapture(dsdemo->ChannelHandle); if(retval < 0) { dsdemo->record_flag = 0; OutputErrorString("<demo_info> StartVideoCapture failed. \n"); return; } OutputErrorString("<demo_info> StartVideoCapture Successful. \n");}void Dsclass::StartSubCapture(){ int retval; retval = StartSubVideoCapture(dsdemo->ChannelHandle); OutputDebugString("start port%02d \n", SignPort); if(retval < 0) { dsdemo->cifqcif_flag = 0; OutputErrorString("<demo_info> StartVideoCapture failed. \n"); return; } }void Dsclass::end_record(){ if(dsdemo->record_fd != NULL ) { delete (dsdemo->record_fd); dsdemo->record_fd = NULL; } if(dsdemo->index_fd != NULL) { delete (dsdemo->index_fd); dsdemo->index_fd = NULL; }}void Dsclass::end_subrecord(){ if(dsdemo->cifqcif_fd != NULL ) { delete (dsdemo->cifqcif_fd); dsdemo->cifqcif_fd = NULL; }}void Dsclass::end_imagestream(){ if(dsdemo->imagefile_fd != NULL ) { delete (dsdemo->imagefile_fd); dsdemo->imagefile_fd = NULL; }}void Dsclass::GetImage(){ int retval = 0; int size; //;= 384 * 288 *2; char filename[100]; int VideoHeight; unsigned char *imagebuf; static int image_count = 0;#ifdef YUVFILE int fid;#endif VideoHeight = GetVideoHeight(); imagebuf = (unsigned char *)malloc(704 * VideoHeight *2); memset(imagebuf, 0x0, 704 * VideoHeight *2); retval = GetOriginalImage(dsdemo->ChannelHandle, imagebuf, &size); if(retval < 0) { OutputErrorString("<demo_info> GetOriginalImage error and return %d\n", retval); } else {#ifdef BMPFILE sprintf(filename, "cap%d%d.bmp", SignPort, image_count); OutputDebugString("GetOriginalImage OK size = %d\n", size); if(size == 704 * 576 * 2) // PAL SaveYUVToBmpFile(filename, imagebuf, 704, 576); if(size == 704 * 480 * 2) // NTSC SaveYUVToBmpFile(filename, imagebuf, 704, 480);#endif#ifdef YUVFILE sprintf(filename, "cap%d.yuv", SignPort); if((fid = open(filename, O_WRONLY | O_CREAT | O_TRUNC , 0777)) < 0) { perror("get image:"); } OutputDebugString("GetOriginalImage OK size = %d\n", size); write(fid, imagebuf, size); close(fid);#endif } free(imagebuf); imagebuf = NULL;}void Dsclass::SetFrameIQuantVal(int number){ (dsdemo -> frameinfo).IQuantVal = number; SetDefaultQuant(dsdemo->ChannelHandle, (dsdemo -> frameinfo).IQuantVal, (dsdemo -> frameinfo).BQuantVal, (dsdemo -> frameinfo).PQuantVal); SetupSubChannel(dsdemo->ChannelHandle, 1); SetDefaultQuant(dsdemo->ChannelHandle, (dsdemo -> frameinfo).IQuantVal, (dsdemo -> frameinfo).BQuantVal, (dsdemo -> frameinfo).PQuantVal); SetupSubChannel(dsdemo->ChannelHandle, 0);}void Dsclass::SetFrameBQuantVal(int number){ (dsdemo -> frameinfo).BQuantVal = number; SetDefaultQuant(dsdemo->ChannelHandle, (dsdemo -> frameinfo).IQuantVal, (dsdemo -> frameinfo).BQuantVal, (dsdemo -> frameinfo).PQuantVal); SetupSubChannel(dsdemo->ChannelHandle, 1); SetDefaultQuant(dsdemo->ChannelHandle, (dsdemo -> frameinfo).IQuantVal, (dsdemo -> frameinfo).BQuantVal, (dsdemo -> frameinfo).PQuantVal); SetupSubChannel(dsdemo->ChannelHandle, 0);}void Dsclass::SetFramePQuantVal(int number){ (dsdemo -> frameinfo).PQuantVal = number; SetDefaultQuant(dsdemo->ChannelHandle, (dsdemo -> frameinfo).IQuantVal, (dsdemo -> frameinfo).BQuantVal, (dsdemo -> frameinfo).PQuantVal); SetupSubChannel(dsdemo->ChannelHandle, 1); SetDefaultQuant(dsdemo->ChannelHandle, (dsdemo -> frameinfo).IQuantVal, (dsdemo -> frameinfo).BQuantVal, (dsdemo -> frameinfo).PQuantVal); SetupSubChannel(dsdemo->ChannelHandle, 0);}void Dsclass::SetFrameKeyFrameI(int number){ (dsdemo -> frameinfo).KeyFrameIntervals = number; SetIBPMode(dsdemo->ChannelHandle, (dsdemo -> frameinfo).KeyFrameIntervals,(dsdemo -> frameinfo).BFrames, 0, (dsdemo -> frameinfo).FrameRate); SetupSubChannel(dsdemo->ChannelHandle, 1); SetIBPMode(dsdemo->ChannelHandle, (dsdemo -> frameinfo).KeyFrameIntervals,(dsdemo -> frameinfo).BFrames, 0, (dsdemo -> frameinfo).FrameRate); SetupSubChannel(dsdemo->ChannelHandle, 0);}void Dsclass::SetFrameBFrames(int number){ (dsdemo -> frameinfo).BFrames = number; SetIBPMode(dsdemo->ChannelHandle, (dsdemo -> frameinfo).KeyFrameIntervals,(dsdemo -> frameinfo).BFrames, 0, (dsdemo -> frameinfo).FrameRate); SetupSubChannel(dsdemo->ChannelHandle, 1); SetIBPMode(dsdemo->ChannelHandle, (dsdemo -> frameinfo).KeyFrameIntervals,(dsdemo -> frameinfo).BFrames, 0, (dsdemo -> frameinfo).FrameRate); SetupSubChannel(dsdemo->ChannelHandle, 0);}void Dsclass::SetFrameFrameRate(int number){ (dsdemo -> frameinfo).FrameRate = number; SetIBPMode(dsdemo->ChannelHandle, (dsdemo -> frameinfo).KeyFrameIntervals,(dsdemo -> frameinfo).BFrames, 0, (dsdemo -> frameinfo).FrameRate); SetupSubChannel(dsdemo->ChannelHandle, 1); SetIBPMode(dsdemo->ChannelHandle, (dsdemo -> frameinfo).KeyFrameIntervals,(dsdemo -> frameinfo).BFrames, 0, (dsdemo -> frameinfo).FrameRate); SetupSubChannel(dsdemo->ChannelHandle, 0);}void Dsclass::SetOsdTranslucent(unsigned short Translucent){ (dsdemo -> osdinfo).Translucent = Translucent; SetOsddemo();}void Dsclass::SetOsdBrightness(int Brightness){ (dsdemo -> osdinfo).Brightness = Brightness; SetOsddemo();}void Dsclass::SetOsdPosX(unsigned short PosX){ (dsdemo -> osdinfo).PosX = PosX; SetOsddemo();}void Dsclass::SetOsdPosY(unsigned short PosY){ (dsdemo -> osdinfo).PosY = PosY; SetOsddemo();}void Dsclass::SetLogoTranslucent(unsigned short Translucent){ (dsdemo -> logoinfo).Translucent = Translucent; SetDsLogo();}void Dsclass::SetLogoPosX(unsigned short PosX){ (dsdemo -> logoinfo).PosX = PosX; SetDsLogo();}void Dsclass::SetLogoPosY(unsigned short PosY){ (dsdemo -> logoinfo).PosY = PosY; SetDsLogo();}void Dsclass::SetBrightScale(const int brightness){ (dsdemo->v_info).Brightness = brightness; SetVideoPara(dsdemo->ChannelHandle, (dsdemo->v_info).Brightness, (dsdemo->v_info).Contrast, (dsdemo->v_info).Saturation, (dsdemo->v_info).Hue); }void Dsclass::SetContrastScale(const int contrast){ (dsdemo->v_info).Contrast = contrast; SetVideoPara(dsdemo->ChannelHandle, (dsdemo->v_info).Brightness, (dsdemo->v_info).Contrast, (dsdemo->v_info).Saturation, (dsdemo->v_info).Hue); }void Dsclass::SetSaturationScale(const int saturation){ (dsdemo->v_info).Saturation = saturation; SetVideoPara(dsdemo->ChannelHandle, (dsdemo->v_info).Brightness, (dsdemo->v_info).Contrast, (dsdemo->v_info).Saturation, (dsdemo->v_info).Hue); }void Dsclass::SetHueScale(const int hue){ (dsdemo->v_info).Hue = hue; SetVideoPara(dsdemo->ChannelHandle, (dsdemo->v_info).Brightness, (dsdemo->v_info).Contrast, (dsdemo->v_info).Saturation, (dsdemo->v_info).Hue); }void Dsclass::SetMask(){ int i; RECT *tempmask = dsdemo-> maskRect; for (i = 0; i < 5; i++) { if (!(tempmask[i].RectTop || tempmask[i].RectBottom || tempmask[i].RectLeft || tempmask[i].RectRight )) break; } SetupMask(dsdemo->ChannelHandle, dsdemo->maskRect, i); }/***************************************************************************/Dsclass::~Dsclass(){ #ifdef LOGO if (logoptr) free(logoptr);#endif sem_destroy(dsdemo->previewconf.SyncSem); if (dsdemo -> maskRect) { free(dsdemo -> maskRect); dsdemo -> maskRect = NULL; } pthread_mutex_destroy(&(dsdemo->major_start)); pthread_mutex_destroy(&(dsdemo->minor_start)); pthread_mutex_destroy(&(dsdemo->imagefile_fd_start)); if (dsdemo) { free(dsdemo); dsdemo = NULL; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -