📄 dsdemo.cpp
字号:
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 + -