x1ongzhu пре 2 година
родитељ
комит
32544933c8
2 измењених фајлова са 25 додато и 28 уклоњено
  1. 10 2
      lib/keyboard.js
  2. 15 26
      lib/parsec.js

+ 10 - 2
lib/keyboard.js

@@ -122,12 +122,12 @@ $(".logs-toggle").click(function () {
     } else {
         $(".logs-window").show();
         $(".logs-window .logs").html(atob(localStorage.getItem("./log.txt")));
-        $('.logs-window').scrollTop($('.logs-window')[0].scrollHeight);
+        $(".logs-window").scrollTop($(".logs-window")[0].scrollHeight);
         timer = setTimeout(() => {
             $(".logs-window .logs").html(
                 atob(localStorage.getItem("./log.txt"))
             );
-            $('.logs-window').scrollTop($('.logs-window')[0].scrollHeight);
+            $(".logs-window").scrollTop($(".logs-window")[0].scrollHeight);
         }, 1000);
     }
 });
@@ -250,3 +250,11 @@ $(".virtual-keyboard-window,.keyboard-toggle").bind(
         event.stopPropagation();
     }
 );
+
+function saveCanvas(n) {
+    if (n == undefined) n = 0;
+    var canvas = document.getElementsByTagName("canvas")[n];
+    var dataURL = canvas.toDataURL("image/png");
+    var newTab = window.open("about:blank", "image from canvas");
+    newTab.document.write("<img src='" + dataURL + "' alt='from canvas'/>");
+}

+ 15 - 26
lib/parsec.js

@@ -1,6 +1,7 @@
 "use strict";
 var h;
 var counter = 0;
+var resizeFlag = true;
 function n(a) {
     var b = 0;
     return function () {
@@ -762,12 +763,16 @@ function na(a) {
                     a.f.decodeLatency =
                         0.9 * a.f.decodeLatency +
                         0.1 * (performance.now() - b.timestamp / 1e3);
-                    a.c.width = Math.round(
-                        document.body.clientWidth * window.devicePixelRatio
-                    );
-                    a.c.height = Math.round(
-                        document.body.clientHeight * window.devicePixelRatio
-                    );
+                    if (resizeFlag) {
+                        a.c.width = Math.round(
+                            document.body.clientWidth * window.devicePixelRatio
+                        );
+                        a.c.height = Math.round(
+                            document.body.clientHeight * window.devicePixelRatio
+                        );
+                        resizeFlag = false;
+                    }
+
                     var d = b.displayWidth / b.displayHeight,
                         f = 0,
                         g = 0;
@@ -780,6 +785,7 @@ function na(a) {
                         f = (a.c.width - l) / 2;
                     } else (l = a.c.width), (d = a.c.width / d), (g = (a.c.height - d) / 2);
                     if (counter === 0) {
+                        console.log(a);
                         a.l.drawImage(
                             b,
                             0,
@@ -791,20 +797,8 @@ function na(a) {
                             l,
                             d
                         );
-                        console.log(
-                            "draw canvas",
-                            0,
-                            0,
-                            a.f.frameWidth,
-                            a.f.frameHeight,
-                            f,
-                            g,
-                            l,
-                            d
-                        );
-                       
                     }
-                    counter = (counter + 1) % 50;
+                    counter = (counter + 1) % 10;
                     b.close();
                 });
             },
@@ -945,7 +939,7 @@ Parsec.prototype.clientNewAttempt = function (a) {
                 "configured" != b.i.state &&
                     b.i.configure({
                         codec: "avc1.42001e",
-                        hardwareAcceleration: "prefer-hardware",
+                        hardwareAcceleration: "prefer-software",
                         optimizeForLatency: !0,
                     });
                 c = new EncodedVideoChunk({
@@ -954,12 +948,7 @@ Parsec.prototype.clientNewAttempt = function (a) {
                     timestamp: 1e3 * performance.now(),
                     duration: 0,
                 });
-                try {
-                    console.log("video decode");
-                    b.i.decode(c);
-                } catch (e) {
-                    console.trace(e);
-                }
+                b.i.decode(c);
             });
             V(b.b, "audio", 2, null, function (c) {
                 "configured" != b.g.state &&