瀏覽代碼

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 年之前
父節點
當前提交
e7e6660272
共有 1 個文件被更改,包括 14 次插入2 次删除
  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();