延迟X11VNC响应

时间:2017-09-08 15:47:06

标签: c x11 vnc tegra rfb-protocol

我一直在尝试编写一个简单的VNC查看器,它在nvidia Tegra K1主板上每30ms请求一次帧缓冲更新。

 // Data to be sent to the X11VNC server for requesting updates for 800x480 region.
unsigned char updateReqBuffer[] = {0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x20, 0x01, 0xE0};

/**************************/

//Requesting for frames
while(isConnected) // Runnning on a thread
{
    if(sockfd != -1) // sockfd is the x11vnc port(5900) 
        send(sockfd, updateReqBuffer, 10, 0);
    usleep(30000);
}

/**************************/

//Receiving framebuffer updates
while(isConnected) // Runnning on a thread
{
    // Read data from X11
    n = recv(sockfd, recvline, MAXLINE,0);
    if(n>0)
    {    
        sentSize += n;
        gettimeofday(&tmnow0, NULL);
        timeinfo0 = localtime (&tmnow0.tv_sec);
        strftime(buf0,30,"%Y:%m:%dT%H:%M:%S", timeinfo0);
        sprintf(usec_buf0,"%d",(int)(tmnow0.tv_usec / 1000));
        strcat(buf0, ".");    
        strcat(buf0,usec_buf0);     
        printf("Update received. Size: %d, TIME: %s\n", n, buf0);
    }
}

我能够收到数据。但我注意到每帧更新之间存在相当大的延迟超过100毫秒,这降低了每秒的总帧数。数据包大小4标记帧的开始。

Update received. Size: 4, TIME: 2017:09:08T14:45:53.543 //START OF FRAME
Update received. Size: 16304, TIME: 2017:09:08T14:45:53.544
Update received. Size: 16366, TIME: 2017:09:08T14:45:53.546
Update received. Size: 16, TIME: 2017:09:08T14:45:53.548
Update received. Size: 36738, TIME: 2017:09:08T14:45:53.548
Update received. Size: 15576, TIME: 2017:09:08T14:45:53.549
Update received. Size: 8854, TIME: 2017:09:08T14:45:53.549
Update received. Size: 6808, TIME: 2017:09:08T14:45:53.550
Update received. Size: 14691, TIME: 2017:09:08T14:45:53.551
Update received. Size: 8750, TIME: 2017:09:08T14:45:53.552
Update received. Size: 20602, TIME: 2017:09:08T14:45:53.553

Update received. Size: 4, TIME: 2017:09:08T14:45:53.662 //START OF FRAME
Update received. Size: 8881, TIME: 2017:09:08T14:45:53.663
Update received. Size: 2040, TIME: 2017:09:08T14:45:53.663
Update received. Size: 1052, TIME: 2017:09:08T14:45:53.663
Update received. Size: 15913, TIME: 2017:09:08T14:45:53.664
Update received. Size: 2055, TIME: 2017:09:08T14:45:53.665
Update received. Size: 1026, TIME: 2017:09:08T14:45:53.666
Update received. Size: 4496, TIME: 2017:09:08T14:45:53.669
Update received. Size: 6931, TIME: 2017:09:08T14:45:53.669

Update received. Size: 4, TIME: 2017:09:08T14:45:53.831 //START OF FRAME

当视频以全屏模式播放时,会拍摄此数据。

Q1:由于我每隔30ms请求更新一次,X11VNC不应该尽快向我发送更新吗?为什么每次更新之间都有100毫秒的延迟?

X11perf测试提供以下数据

ubuntu@tegra-ubuntu:~$ x11perf -getimage500 -shmget500
x11perf - X11 performance program, version 1.2
The X.Org Foundation server version 11501000 on :0
from tegra-ubuntu
Fri Sep  8 13:03:41 2017 
Sync time adjustment is 0.1022 msecs. 
   8000 reps @   1.1794 msec (   848.0/sec): ShmGetImage 500x500 square
   8000 reps @   1.2038 msec (   831.0/sec): ShmGetImage 500x500 square
   8000 reps @   1.2407 msec (   806.0/sec): ShmGetImage 500x500 square
   8000 reps @   1.2027 msec (   831.0/sec): ShmGetImage 500x500 square
   8000 reps @   1.1765 msec (   850.0/sec): ShmGetImage 500x500 square
  40000 trep @   1.2006 msec (   833.0/sec): ShmGetImage 500x500 square 

   1200 reps @   5.0762 msec (   197.0/sec): GetImage 500x500 square
   1200 reps @   5.0227 msec (   199.0/sec): GetImage 500x500 square
   1200 reps @   5.0323 msec (   199.0/sec): GetImage 500x500 square
   1200 reps @   5.0528 msec (   198.0/sec): GetImage 500x500 square
   1200 reps @   5.0278 msec (   199.0/sec): GetImage 500x500 square
   6000 trep @   5.0424 msec (   198.0/sec): GetImage 500x500 square

Q2:我错误地认为X11VNC能够检索和发送帧缓冲区更新,而不是我从上面的结果中获得的更新吗?如果是这样,我如何解释这些结果?

0 个答案:

没有答案