我尝试编写一个具有服务器端缩减能力的 vnc 服务器,它是一个源多流。
int main(int argc, char** argv)
{
...
rfbScreenInfoPtr rfbScreen_1080 = rfbGetScreen(&argc,argv,1920,1080,8,3,bpp);
rfbScreenInfoPtr rfbScreen_720 = rfbGetScreen(&argc,argv,1280,720,8,3,bpp);
rfbScreen_1080->frameBuffer = (char*)_aligned_malloc(1920*1080*bpp,256);
rfbScreen_720->frameBuffer = (char*)_aligned_malloc(1280*720*bpp,256);
rfbScreen_1080->progressiveSliceHeight = 1080/2;
rfbScreen_720->progressiveSliceHeight = 720/2;
rfbScreen_1080->cursor = rfbMakeXCursor(0,0,NULL,NULL);
rfbScreen_720->cursor = rfbMakeXCursor(0,0,NULL,NULL);
rfbScreen_1080->port = 5900;
rfbScreen_720->port = 5901;
rfbScreen_1080->alwaysShared = 1;
rfbScreen_720->alwaysShared = 1;
rfbInitServer(rfbScreen_1080);
rfbInitServer(rfbScreen_720);
int begin = clock();
while(rfbIsActive(rfbScreen_1080) || rfbIsActive(rfbScreen_720))
{
int end = clock();
if(end - begin >= UPDATE_INTERVAL)
{
//printf("%d\n",end-begin);
begin = clock()-(end - begin - UPDATE_INTERVAL);
CaptureScreen(rfbScreen_1080, rfbScreen_720);
rfbMarkRectAsModified(rfbScreen_1080,0,0,1920,1080);
rfbMarkRectAsModified(rfbScreen_720,0,0,1280,720);
}
rfbProcessEvents(rfbScreen_1080,40);
rfbProcessEvents(rfbScreen_720,40);
//Sleep(1);
}
...
}
void CaptureScreen(rfbScreenInfoPtr rfbScreen1, rfbScreenInfoPtr rfbScreen2)
{
//capture screen to bmp, resize and copy data to rfbScreen->frameBuffer;
}