]> Joshua Wise's Git repositories - netwatch.git/blobdiff - net/rfb.c
some changes for gcc4
[netwatch.git] / net / rfb.c
index 5fe1a1100cf36228f248cbadbc3a22ce3329264a..39efeff2355b7ea8f65d4fb154b197b40f903952 100644 (file)
--- 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);
This page took 0.027304 seconds and 4 git commands to generate.