Need suggestions for tile caching mechanism in VNC-like application

I am developing a “remote screencasting” application (like VNC, but not quite), where I transfer updated fragments of screen pixels across the network. I would like to implement a caching mechanism, and I would like to hear your recommendations ...

This is how I think it should be done. For each tile coordinate, there is a fixed size stack (cache) where I add updated tiles. When you save, I calculate some kind of checksum (probably CRC-16 will be sufficient, right?) Of tile data (i.e. pixels). When I receive a new tile (from a new screenshot of the desktop), I calculate its checksum and compare it with all the checksums of the elements in the stack of this tile coordinate. If the checksum is the same, instead of sending the tile, I send a special message, for example. "get snippet from cache at position X". This means that I need to have the same cache stacks on the server and on the client.

Here are my questions:

  • What should be the default stack size (depth)? Say, if the stack size is 5, this means that the last 5 fragments of the given coordinates will be saved, and a 5x resolution of the screen pixels will be the total cache size. For large screens, the raw RGB screen buffer will be approx. 5 megabytes, so having a 10-level stack means 50 MB of cache, right? So what should be the cache depth? I think maybe 10, but you need your suggestions.

  • I compress tiles in JPEG before sending over the network. Should I implement caching of JPEG fragments or raw RBG fragments before compression? A logical choice would be to cache the raw fragments, as this will avoid unnecessary JPEG encoding for the fragments that will be found in the cache. But saving RGB pixels will require a much larger cache size. So what is the best option - before or after compression?

  • Is the CRC-16 checksum enough to compare new screen screens with slabs on the cache stack? I mean, do I have to do byte comparisons for tiles when CRC matches or is it redundant? Is the probability of a collision low enough to be dropped?

  • In general, what do you think of the circuit that I described? What would you change in it? Any suggestions would be appreciated!

+3
3

, , , , .

. , .

, , , . , , . - , . , .

CRC16, , CRC , , , . , . .

JPEG - , , BITMAP JPEG, , , CRC . , , JPEG.

+1

. , murmur2 Jenkins. . . Spice (www.spice-space.org), , . , ( ).

+1

You can check the x11vnc cache .

0
source

All Articles