1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 16:23:25 +00:00

1. Added KVM Jumbo Support for Linux/FreeBSD/MacOS

2. Added compile switch for Jumbo eenable/disable
3. Updated Linux Mouse Cursor HAshing, so 32-bit and 64-bit interop
4. Updated KVM to fetch initial mouse cursor on connect
This commit is contained in:
Bryan Roe
2020-04-09 22:41:56 -07:00
parent aa48bfe70a
commit 7dd40ff52f
9 changed files with 274 additions and 124 deletions

View File

@@ -18,6 +18,12 @@ limitations under the License.
#include "meshcore/meshdefines.h"
#include "microstack/ILibParsers.h"
#if defined(JPEGMAXBUF)
#define MAX_TILE_SIZE JPEGMAXBUF
#else
#define MAX_TILE_SIZE 65500
#endif
extern int SCREEN_NUM;
extern int SCREEN_WIDTH;
extern int SCREEN_HEIGHT;
@@ -73,10 +79,14 @@ int calc_opt_compr_send(int x, int y, int captureWidth, int captureHeight, void*
write_JPEG_buffer(tilebuffer, captureWidth, captureHeight, COMPRESSION_QUALITY);
if (jpeg_buffer_length > 65500) {
#if MAX_TILE_SIZE > 0
if (jpeg_buffer_length > MAX_TILE_SIZE)
{
return jpeg_buffer_length;
}
else {
else
#endif
{
return 0;
}
}
@@ -230,12 +240,16 @@ int getTileAt(int x, int y, void** buffer, long long *bufferSize, void *desktop,
if (CRC != g_tileInfo[row][rightcol].crc || g_tileInfo[row][rightcol].flag == TILE_MARKED_NOT_SENT) { //If the tile has changed, increment the capturewidth.
g_tileInfo[row][rightcol].crc = CRC;
//Here we check whether the size of the coalesced bitmap is greater than the threshold (65500)
if ((captureWidth + TILE_WIDTH) * TILE_HEIGHT * 3 / COMPRESSION_RATIO > 65500) {
#if MAX_TILE_SIZE > 0
//Here we check whether the size of the coalesced bitmap is greater than the threshold (MAX_TILE_SIZE)
if ((captureWidth + TILE_WIDTH) * TILE_HEIGHT * 3 / COMPRESSION_RATIO > MAX_TILE_SIZE)
{
g_tileInfo[row][rightcol].flag = TILE_MARKED_NOT_SENT;
--rightcol;
break;
}
#endif
g_tileInfo[row][rightcol].flag = TILE_MARKED_NOT_SENT;
captureWidth += TILE_WIDTH;
@@ -250,7 +264,12 @@ int getTileAt(int x, int y, void** buffer, long long *bufferSize, void *desktop,
//int TOLERANCE = (rightcol - col) / 3;
// Now go to the bottom tiles, check if they have changed and record them
while ((botrow + 1 < TILE_HEIGHT_COUNT) && ((captureHeight + TILE_HEIGHT) * captureWidth * 3 / COMPRESSION_RATIO <= 65500)) {
#if MAX_TILE_SIZE > 0
while ((botrow + 1 < TILE_HEIGHT_COUNT) && ((captureHeight + TILE_HEIGHT) * captureWidth * 3 / COMPRESSION_RATIO <= MAX_TILE_SIZE))
#else
while ((botrow + 1 < TILE_HEIGHT_COUNT))
#endif
{
botrow++;
r_y = botrow * TILE_HEIGHT;
int fail = 0;
@@ -314,6 +333,9 @@ int getTileAt(int x, int y, void** buffer, long long *bufferSize, void *desktop,
int retval = 0;
int firstTime = 1;
#if MAX_TILE_SIZE == 0
retval = calc_opt_compr_send(x, y, captureWidth, captureHeight, desktop, desktopsize, buffer, bufferSize);
#else
//This loop is used to adjust the COMPRESSION_RATIO. This loop runs only once most of the time.
do {
//retval here is 0 if everything was good. It is > 0 if it contains the size of the jpeg that was created and not sent.
@@ -321,7 +343,7 @@ int getTileAt(int x, int y, void** buffer, long long *bufferSize, void *desktop,
if (retval != 0) {
if (firstTime) {
// Re-adjust the compression ratio.
COMPRESSION_RATIO = (int)(((double)COMPRESSION_RATIO/(double)retval) * 60000);//Magic number: 60000 ~= 65500
COMPRESSION_RATIO = (int)(((double)COMPRESSION_RATIO/(double)retval) * (0.92 * MAX_TILE_SIZE)); //Magic number: 92% of MAX_TILE_SIZE
if (COMPRESSION_RATIO <= 1) { COMPRESSION_RATIO = 2; }
firstTime = 0;
}
@@ -341,17 +363,34 @@ int getTileAt(int x, int y, void** buffer, long long *bufferSize, void *desktop,
}
} while (retval != 0);
#endif
//Set the flags to TILE_SENT
if (jpeg_buffer != NULL) {
*bufferSize = jpeg_buffer_length + 8;
if (jpeg_buffer != NULL)
{
*bufferSize = jpeg_buffer_length + (jpeg_buffer_length > 65500 ? 16 : 8);
*buffer = malloc(*bufferSize);
if (jpeg_buffer_length > 65500)
{
((unsigned short*)*buffer)[0] = (unsigned short)htons((unsigned short)MNG_JUMBO); // Write the type
((unsigned short*)*buffer)[1] = (unsigned short)htons((unsigned short)8); // Write the size
((unsigned int*)*buffer)[1] = (unsigned int)htonl(jpeg_buffer_length + 8); // Size of the Next Packet
((unsigned short*)*buffer)[4] = (unsigned short)htons((unsigned short)MNG_KVM_PICTURE); // Write the type
((unsigned short*)*buffer)[5] = 0; // RESERVED
((unsigned short*)*buffer)[6] = (unsigned short)htons((unsigned short)x); // X position
((unsigned short*)*buffer)[7] = (unsigned short)htons((unsigned short)y); // Y position
memcpy((char *)(*buffer) + 16, jpeg_buffer, jpeg_buffer_length);
}
else
{
((unsigned short*)*buffer)[0] = (unsigned short)htons((unsigned short)MNG_KVM_PICTURE); // Write the type
((unsigned short*)*buffer)[1] = (unsigned short)htons((unsigned short)*bufferSize); // Write the size
((unsigned short*)*buffer)[2] = (unsigned short)htons((unsigned short)x); // X position
((unsigned short*)*buffer)[3] = (unsigned short)htons((unsigned short)y); // Y position
memcpy((char *)(*buffer) + 8, jpeg_buffer, jpeg_buffer_length);
}
if ((*buffer = malloc(*bufferSize)) == NULL) ILIBCRITICALEXIT(254);
((unsigned short*)*buffer)[0] = (unsigned short)htons((unsigned short)MNG_KVM_PICTURE); // Write the type
((unsigned short*)*buffer)[1] = (unsigned short)htons((unsigned short)*bufferSize); // Write the size
((unsigned short*)*buffer)[2] = (unsigned short)htons((unsigned short)x); // X position
((unsigned short*)*buffer)[3] = (unsigned short)htons((unsigned short)y); // Y position
memcpy((char *)(*buffer) + 8, jpeg_buffer, jpeg_buffer_length);
free(jpeg_buffer);
jpeg_buffer = NULL;
jpeg_buffer_length = 0;