Commit 5a3e352f authored by dscho's avatar dscho

rename tight-1.c into encodingstest.c, fixing it in the process. It now

passes all encodings except corre (broken) and zrle (not yet implemented
in libvncclient)
parent b583cf53
...@@ -6,8 +6,10 @@ endif ...@@ -6,8 +6,10 @@ endif
copyrecttest_LDADD=$(LDADD) -lm copyrecttest_LDADD=$(LDADD) -lm
noinst_PROGRAMS=tight-1 cargstest copyrecttest $(BACKGROUND_TEST) noinst_PROGRAMS=encodingstest cargstest copyrecttest $(BACKGROUND_TEST)
LDADD = ../libvncserver/libvncserver.a ../libvncclient/libvncclient.a LDADD = ../libvncserver/libvncserver.a ../libvncclient/libvncclient.a
test: encodingstest cargstest copyrecttest
./encodingstest && ./cargstest
#include <time.h> #include <time.h>
#include <stdarg.h>
#include <rfb/rfb.h> #include <rfb/rfb.h>
#include <rfb/rfbclient.h> #include <rfb/rfbclient.h>
#ifndef LIBVNCSERVER_HAVE_LIBTHREAD #ifndef LIBVNCSERVER_HAVE_LIBPTHREAD
//#error This test need pthread support (otherwise the client blocks the client) #error This test need pthread support (otherwise the client blocks the client)
#endif #endif
//#define ALL_AT_ONCE #define ALL_AT_ONCE
//#define VERY_VERBOSE //#define VERY_VERBOSE
MUTEX(frameBufferMutex); MUTEX(frameBufferMutex);
...@@ -15,12 +16,14 @@ typedef struct { int id; char* str; } encoding_t; ...@@ -15,12 +16,14 @@ typedef struct { int id; char* str; } encoding_t;
encoding_t testEncodings[]={ encoding_t testEncodings[]={
{ rfbEncodingRaw, "raw" }, { rfbEncodingRaw, "raw" },
{ rfbEncodingRRE, "rre" }, { rfbEncodingRRE, "rre" },
{ rfbEncodingCoRRE, "corre" }, /* TODO: fix corre */
/* { rfbEncodingCoRRE, "corre" }, */
{ rfbEncodingHextile, "hextile" }, { rfbEncodingHextile, "hextile" },
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
{ rfbEncodingZlib, "zlib" }, { rfbEncodingZlib, "zlib" },
{ rfbEncodingZlibHex, "zlibhex" }, { rfbEncodingZlibHex, "zlibhex" },
{ rfbEncodingZRLE, "zrle" }, /* TODO: implement ZRLE decoding */
/* { rfbEncodingZRLE, "zrle" }, */
#ifdef LIBVNCSERVER_HAVE_LIBJPEG #ifdef LIBVNCSERVER_HAVE_LIBJPEG
{ rfbEncodingTight, "tight" }, { rfbEncodingTight, "tight" },
#endif #endif
...@@ -126,10 +129,14 @@ static void update(rfbClient* client,int x,int y,int w,int h) { ...@@ -126,10 +129,14 @@ static void update(rfbClient* client,int x,int y,int w,int h) {
clientData* cd=(clientData*)client->clientData; clientData* cd=(clientData*)client->clientData;
int maxDelta=0; int maxDelta=0;
/* TODO: check if dimensions match with marked rectangle */ #ifndef VERY_VERBOSE
static const char* progress="|/-\\";
static int counter=0;
#ifdef VERY_VERBOSE if(++counter>sizeof(progress)) counter=0;
rfbLog("Got update (encoding=%s): (%d,%d)-(%d,%d)\n", fprintf(stderr,"%c\r",progress[counter]);
#else
rfbClientLog("Got update (encoding=%s): (%d,%d)-(%d,%d)\n",
testEncodings[cd->encodingIndex].str, testEncodings[cd->encodingIndex].str,
x,y,x+w,y+h); x,y,x+w,y+h);
#endif #endif
...@@ -137,7 +144,7 @@ static void update(rfbClient* client,int x,int y,int w,int h) { ...@@ -137,7 +144,7 @@ static void update(rfbClient* client,int x,int y,int w,int h) {
/* only check if this was the last update */ /* only check if this was the last update */
if(x+w!=lastUpdateRect.x2 || y+h!=lastUpdateRect.y2) { if(x+w!=lastUpdateRect.x2 || y+h!=lastUpdateRect.y2) {
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
rfbLog("Waiting (%d!=%d or %d!=%d)\n", rfbClientLog("Waiting (%d!=%d or %d!=%d)\n",
x+w,lastUpdateRect.x2,y+h,lastUpdateRect.y2); x+w,lastUpdateRect.x2,y+h,lastUpdateRect.y2);
#endif #endif
return; return;
...@@ -160,11 +167,11 @@ static void* clientLoop(void* data) { ...@@ -160,11 +167,11 @@ static void* clientLoop(void* data) {
sleep(1); sleep(1);
rfbLog("Starting client (encoding %s, display %s)\n", rfbClientLog("Starting client (encoding %s, display %s)\n",
testEncodings[cd->encodingIndex].str, testEncodings[cd->encodingIndex].str,
cd->display); cd->display);
if(!rfbInitClient(client,&argc,argv)) { if(!rfbInitClient(client,&argc,argv)) {
rfbLog("Had problems starting client (encoding %s)\n", rfbClientErr("Had problems starting client (encoding %s)\n",
testEncodings[cd->encodingIndex].str); testEncodings[cd->encodingIndex].str);
updateStatistics(cd->encodingIndex,TRUE); updateStatistics(cd->encodingIndex,TRUE);
return 0; return 0;
...@@ -197,6 +204,10 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) { ...@@ -197,6 +204,10 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) {
cd->display=(char*)malloc(6); cd->display=(char*)malloc(6);
sprintf(cd->display,":%d",server->port-5900); sprintf(cd->display,":%d",server->port-5900);
lastUpdateRect.x1=lastUpdateRect.y1=0;
lastUpdateRect.x2=server->width;
lastUpdateRect.y2=server->height;
pthread_create(&clientThread,NULL,clientLoop,(void*)client); pthread_create(&clientThread,NULL,clientLoop,(void*)client);
} }
...@@ -246,13 +257,40 @@ static void idle(rfbScreenInfo* server) ...@@ -246,13 +257,40 @@ static void idle(rfbScreenInfo* server)
UNLOCK(frameBufferMutex); UNLOCK(frameBufferMutex);
} }
//TODO: pthread'ize the client. otherwise server and client block each /* log function (to show what messages are from the client) */
//other
void
rfbTestLog(const char *format, ...)
{
va_list args;
char buf[256];
time_t log_clock;
if(!rfbEnableClientLogging)
return;
va_start(args, format);
time(&log_clock);
strftime(buf, 255, "%d/%m/%Y %X (client) ", localtime(&log_clock));
fprintf(stderr,buf);
vfprintf(stderr, format, args);
fflush(stderr);
va_end(args);
}
/* the main function */
int main(int argc,char** argv) int main(int argc,char** argv)
{ {
int i,j; int i,j;
time_t t; time_t t;
rfbClientLog=rfbTestLog;
rfbClientErr=rfbTestLog;
/* Initialize server */ /* Initialize server */
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,width,height,8,3,4); rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,width,height,8,3,4);
...@@ -304,3 +342,4 @@ int main(int argc,char** argv) ...@@ -304,3 +342,4 @@ int main(int argc,char** argv)
return(0); return(0);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment