X-Git-Url: http://git.joshuawise.com/netwatch.git/blobdiff_plain/b496c2b16e66ba34a8725fb49a1bf27f0588939c..8ba7e5b28a7f23ebf2423df41379516c8cbac6b5:/net/rfb.c?ds=sidebyside diff --git a/net/rfb.c b/net/rfb.c index 5fe1a11..39efeff 100644 --- a/net/rfb.c +++ b/net/rfb.c @@ -6,6 +6,7 @@ #include "../aseg-paging/keyboard.h" #include "lwip/tcp.h" +#include "lwip/stats.h" #include "rfb.h" @@ -16,9 +17,9 @@ #define POINTER_EVENT 5 #define CLIENT_CUT_TEXT 6 -#define RFB_BUF_SIZE 64 +#define RFB_BUF_SIZE 512 -#define SCREEN_CHUNKS_X 16 +#define SCREEN_CHUNKS_X 4 #define SCREEN_CHUNKS_Y 8 struct pixel_format { @@ -115,7 +116,7 @@ struct rfb_state { SST_SENDING } send_state; - uint32_t checksums[SCREEN_CHUNKS_Y][SCREEN_CHUNKS_X]; + uint32_t checksums[SCREEN_CHUNKS_X][SCREEN_CHUNKS_Y]; uint32_t chunk_xnum; uint32_t chunk_ynum; @@ -165,6 +166,7 @@ static void send_fsm(struct tcp_pcb *pcb, struct rfb_state *state) { struct update_header hdr; int lines_left; char * lptr; + uint32_t checksum; int totaldim; err_t err; @@ -198,10 +200,6 @@ static void send_fsm(struct tcp_pcb *pcb, struct rfb_state *state) { lines_left = state->chunk_height - state->chunk_lindex; if (lines_left == 0) { - outputf("RFB: (%d [%d], %d [%d]), advancing", - state->chunk_xnum, state->chunk_xpos, - state->chunk_ynum, state->chunk_ypos); - /* Advance to the next chunk if necessary. If * state->chunk_height is zero, then we are * arriving here for the first time from @@ -218,11 +216,10 @@ static void send_fsm(struct tcp_pcb *pcb, struct rfb_state *state) { if (state->chunk_ynum == SCREEN_CHUNKS_Y) { state->send_state = SST_IDLE; + outputf("RFB: Screen update done! %d", state->update_requested); break; } - outputf("RFB send: sending header"); - /* Calculate the width and height for this chunk, remembering * that if SCREEN_CHUNKS_[XY] do not evenly divide the width and * height, we may need to have shorter chunks at the edge of @@ -247,15 +244,29 @@ static void send_fsm(struct tcp_pcb *pcb, struct rfb_state *state) { state->chunk_height -= (totaldim - fb->curmode.yres); } + if (fb->checksum_rect) { + checksum = fb->checksum_rect(state->chunk_xpos, state->chunk_ypos, + state->chunk_width, state->chunk_height); + + if (checksum == state->checksums[state->chunk_xnum][state->chunk_ynum]) { + state->chunk_lindex = state->chunk_height; + continue; + } else { + state->checksums[state->chunk_xnum][state->chunk_ynum] = checksum; + } + } +/* + outputf("RFB send: sending header"); +*/ /* Send a header */ hdr.msgtype = 0; + state->chunk_lindex = 0; hdr.nrects = htons(1); hdr.xpos = htons(state->chunk_xpos); hdr.ypos = htons(state->chunk_ypos); hdr.width = htons(state->chunk_width); hdr.height= htons(state->chunk_height); hdr.enctype = htonl(0); - state->chunk_lindex = 0; lines_left = state->chunk_height; err = tcp_write(pcb, &hdr, sizeof(hdr), TCP_WRITE_FLAG_COPY); @@ -273,12 +284,6 @@ static void send_fsm(struct tcp_pcb *pcb, struct rfb_state *state) { } do { - outputf("RFB: (%d [%d], %d [%d]), %d x %d, line %d", - state->chunk_xnum, state->chunk_xpos, - state->chunk_ynum, state->chunk_ypos, - state->chunk_width, state->chunk_height, - state->chunk_lindex); - lptr = fb->fbaddr + (fb->curmode.xres * fb->curmode.bytestride * (state->chunk_ypos + state->chunk_lindex)) @@ -300,7 +305,6 @@ static void send_fsm(struct tcp_pcb *pcb, struct rfb_state *state) { if (err != ERR_MEM) outputf("RFB: send error %d", err); - outputf("RFB: that's all for now"); break; } @@ -322,6 +326,16 @@ static err_t rfb_sent(void *arg, struct tcp_pcb *pcb, uint16_t len) { return ERR_OK; } +static err_t rfb_poll(void *arg, struct tcp_pcb *pcb) { + struct rfb_state *state = arg; + state->update_requested = 1; + send_fsm(pcb, state); +/* + stats_display(); +*/ + return ERR_OK; +} + static void close_conn(struct tcp_pcb *pcb, struct rfb_state *state) { tcp_arg(pcb, NULL); tcp_sent(pcb, NULL); @@ -591,9 +605,9 @@ static err_t rfb_accept(void *arg, struct tcp_pcb *pcb, err_t err) { tcp_arg(pcb, state); tcp_recv(pcb, rfb_recv); tcp_sent(pcb, rfb_sent); + tcp_poll(pcb, rfb_poll, 1); /* tcp_err(pcb, rfb_err); - tcp_poll(pcb, rfb_poll, 2); */ tcp_write(pcb, "RFB 003.008\n", 12, 0); tcp_output(pcb);