Skip to content

Commit

Permalink
Merge pull request #353 from metalefty/v0.10-h264-fps
Browse files Browse the repository at this point in the history
[v0.10] Use per-codec frame capture interval passed from xrdp
  • Loading branch information
metalefty authored Nov 20, 2024
2 parents 5af24ba + 9525b61 commit c2ab702
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 41 deletions.
2 changes: 2 additions & 0 deletions module/rdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ struct _rdpRec
CARD32 last_event_time_ms;
CARD32 last_wheel_time_ms;

CARD32 msFrameInterval;

int conNumber;

struct _rdpCounts counts;
Expand Down
91 changes: 50 additions & 41 deletions module/rdpClientCon.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,47 +776,57 @@ rdpClientConResizeAllMemoryAreas(rdpPtr dev, rdpClientCon *clientCon)
clientCon->rdp_height = height;

/* Set the capture parameters */
if ((clientCon->client_info.capture_code == CC_SUF_RFX) || /* RFX */
(clientCon->client_info.capture_code == CC_GFX_PRO))
switch(clientCon->client_info.capture_code)
{
LLOGLN(0, ("rdpClientConProcessMsgClientInfo: got RFX capture"));
/* RFX capture needs fixed-size rectangles */
clientCon->cap_width = RDPALIGN(width, XRDP_RFX_ALIGN);
clientCon->cap_height = RDPALIGN(height, XRDP_RFX_ALIGN);
LLOGLN(0, (" cap_width %d cap_height %d",
clientCon->cap_width, clientCon->cap_height));
case CC_SUF_RFX: /* RFX */
case CC_GFX_PRO:
LLOGLN(0, ("rdpClientConProcessMsgClientInfo: got RFX capture"));
/* RFX capture needs fixed-size rectangles */
clientCon->cap_width = RDPALIGN(width, XRDP_RFX_ALIGN);
clientCon->cap_height = RDPALIGN(height, XRDP_RFX_ALIGN);
LLOGLN(0, (" cap_width %d cap_height %d",
clientCon->cap_width, clientCon->cap_height));

bytes = clientCon->cap_width * clientCon->cap_height *
clientCon->rdp_Bpp;
bytes = clientCon->cap_width * clientCon->cap_height *
clientCon->rdp_Bpp;

clientCon->shmem_lineBytes = clientCon->rdp_Bpp * clientCon->cap_width;
clientCon->cap_stride_bytes = clientCon->cap_width * 4;
shmemstatus = SHM_RFX_ACTIVE_PENDING;
}
else if ((clientCon->client_info.capture_code == CC_SUF_A2) || /* H264 */
(clientCon->client_info.capture_code == CC_GFX_A2))
{
LLOGLN(0, ("rdpClientConProcessMsgClientInfo: got H264 capture"));
clientCon->cap_width = width;
clientCon->cap_height = height;
clientCon->shmem_lineBytes = clientCon->rdp_Bpp * clientCon->cap_width;
clientCon->cap_stride_bytes = clientCon->cap_width * 4;
shmemstatus = SHM_RFX_ACTIVE_PENDING;

bytes = clientCon->cap_width * clientCon->cap_height * 2;
dev->msFrameInterval = clientCon->client_info.rfx_frame_interval;
break;
case CC_SUF_A2: /* H264 */
case CC_GFX_A2:
LLOGLN(0, ("rdpClientConProcessMsgClientInfo: got H264 capture"));
clientCon->cap_width = width;
clientCon->cap_height = height;

clientCon->shmem_lineBytes = clientCon->rdp_Bpp * clientCon->cap_width;
clientCon->cap_stride_bytes = clientCon->cap_width * 4;
shmemstatus = SHM_H264_ACTIVE_PENDING;
}
else
{
clientCon->cap_width = width;
clientCon->cap_height = height;
bytes = clientCon->cap_width * clientCon->cap_height * 2;

bytes = width * height * clientCon->rdp_Bpp;
clientCon->shmem_lineBytes = clientCon->rdp_Bpp * clientCon->cap_width;
clientCon->cap_stride_bytes = clientCon->cap_width * 4;
shmemstatus = SHM_H264_ACTIVE_PENDING;

clientCon->shmem_lineBytes = clientCon->rdp_Bpp * clientCon->cap_width;
clientCon->cap_stride_bytes = clientCon->cap_width * clientCon->rdp_Bpp;
shmemstatus = SHM_ACTIVE_PENDING;
dev->msFrameInterval = clientCon->client_info.h264_frame_interval;
break;
default:
LLOGLN(0, ("rdpClientConProcessMsgClientInfo: got normal capture"));
clientCon->cap_width = width;
clientCon->cap_width = width;
clientCon->cap_height = height;

bytes = width * height * clientCon->rdp_Bpp;

clientCon->shmem_lineBytes = clientCon->rdp_Bpp * clientCon->cap_width;
clientCon->cap_stride_bytes = clientCon->cap_width * clientCon->rdp_Bpp;
shmemstatus = SHM_ACTIVE_PENDING;

dev->msFrameInterval = clientCon->client_info.normal_frame_interval;
break;
}

LLOGLN(0, (" msFrameInterval %ld", (long)dev->msFrameInterval));
rdpClientConAllocateSharedMemory(clientCon, bytes);

if (clientCon->client_info.capture_format != 0)
Expand Down Expand Up @@ -2539,7 +2549,7 @@ rdpClientConScheduleDeferredUpdate(rdpPtr dev)
{
dev->sendUpdateScheduled = TRUE;
dev->sendUpdateTimer =
TimerSet(dev->sendUpdateTimer, 0, 40,
TimerSet(dev->sendUpdateTimer, 0, dev->msFrameInterval,
rdpClientConDeferredUpdateCallback, dev);
}
}
Expand Down Expand Up @@ -2658,15 +2668,15 @@ rdpClientConSendPaintRectShmFd(rdpPtr dev, rdpClientCon *clientCon,
out_uint32_le(s, clientCon->rect_id);
out_uint32_le(s, id->shmem_bytes);
out_uint32_le(s, id->shmem_offset);
if (capture_code == CC_SUF_RFX) /* rfx */
{
if (capture_code == CC_SUF_RFX) /* rfx */
{
out_uint16_le(s, id->left);
out_uint16_le(s, id->top);
out_uint16_le(s, id->width);
out_uint16_le(s, id->height);
}
else
{
}
else
{
out_uint16_le(s, 0);
out_uint16_le(s, 0);
out_uint16_le(s, clientCon->cap_width);
Expand Down Expand Up @@ -2981,7 +2991,6 @@ rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg)


/******************************************************************************/
#define MIN_MS_BETWEEN_FRAMES 40
#define MIN_MS_TO_WAIT_FOR_MORE_UPDATES 4
#define UPDATE_RETRY_TIMEOUT 200 // After this number of retries, give up and perform the capture anyway. This prevents an infinite loop.
static void
Expand All @@ -3000,7 +3009,7 @@ rdpScheduleDeferredUpdate(rdpClientCon *clientCon)
for more changes before sending an update. Always waiting the longer
delay would introduce unnecessarily much latency. */
msToWait = MIN_MS_TO_WAIT_FOR_MORE_UPDATES;
minNextUpdateTime = clientCon->lastUpdateTime + MIN_MS_BETWEEN_FRAMES;
minNextUpdateTime = clientCon->lastUpdateTime + clientCon->dev->msFrameInterval;
/* the first check is to gracefully handle the infrequent case of
the time wrapping around */
if(clientCon->lastUpdateTime < curTime &&
Expand Down
2 changes: 2 additions & 0 deletions module/rdpClientCon.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ struct _rdpClientCon
int updateScheduled; /* boolean */
int updateRetries;

CARD32 msFrameInterval;

RegionPtr dirtyRegion;

int num_rfx_crcs_alloc[16];
Expand Down

0 comments on commit c2ab702

Please sign in to comment.