Browse Source

include/playback.js: support binary (non-base64) data files.

Data files should now set the variable VNC_frame_encoding to either
"binary" or "base64". The python websockify recording mode adds this
automatically based on what is negotiated with the client being
recorded.
Joel Martin 12 years ago
parent
commit
e7e6660272
1 changed files with 14 additions and 2 deletions
  1. 14 2
      include/playback.js

+ 14 - 2
include/playback.js

@@ -79,10 +79,22 @@ queue_next_packet = function () {
     }
 };
 
+var bytes_processed = 0;
+
 do_packet = function () {
     //Util.Debug("Processing frame: " + frame_idx);
-    var frame = VNC_frame_data[frame_idx];
-    rfb.recv_message({'data' : frame.slice(frame.indexOf('{', 1) + 1)});
+    var frame = VNC_frame_data[frame_idx],
+        start = frame.indexOf('{', 1) + 1;
+    bytes_processed += frame.length - start;
+    if (VNC_frame_encoding === 'binary') {
+        var u8 = new Uint8Array(frame.length - start);
+        for (var i = 0; i < frame.length - start; i++) {
+            u8[i] = frame.charCodeAt(start + i);
+        }
+        rfb.recv_message({'data' : u8});
+    } else {
+        rfb.recv_message({'data' : frame.slice(start)});
+    }
     frame_idx += 1;
 
     queue_next_packet();