mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-21 09:33:01 +08:00
working on yuv
This commit is contained in:
parent
74c53f17ae
commit
c8b681b84c
BIN
LibYUV.wasm
Normal file
BIN
LibYUV.wasm
Normal file
Binary file not shown.
@ -6,6 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<script src="node_modules/ogv/dist/ogv.js"></script>
|
<script src="node_modules/ogv/dist/ogv.js"></script>
|
||||||
<script src="./yuv-canvas-1.2.6.js"></script>
|
<script src="./yuv-canvas-1.2.6.js"></script>
|
||||||
|
<script src="./LibYUV.js"></script>
|
||||||
<title>Vite App</title>
|
<title>Vite App</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "web_hbb",
|
"name": "web_hbb",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "curl -O https://raw.githubusercontent.com/rgov/js-theora-decoder/main/yuv-canvas-1.2.6.js && vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
|
@ -215,11 +215,11 @@ export default class Connection {
|
|||||||
this.handleVideoFrame(msg?.videoFrame!);
|
this.handleVideoFrame(msg?.videoFrame!);
|
||||||
} else if (msg?.clipboard) {
|
} else if (msg?.clipboard) {
|
||||||
const cb = msg?.clipboard;
|
const cb = msg?.clipboard;
|
||||||
if (cb.compress) cb.content = globals.decompress(cb.content)!;
|
if (cb.compress) cb.content = await globals.decompress(cb.content)!;
|
||||||
globals.pushEvent("clipboard", cb);
|
globals.pushEvent("clipboard", cb);
|
||||||
} else if (msg?.cursorData) {
|
} else if (msg?.cursorData) {
|
||||||
const cd = msg?.cursorData;
|
const cd = msg?.cursorData;
|
||||||
cd.colors = globals.decompress(cd.colors)!;
|
cd.colors = await globals.decompress(cd.colors)!;
|
||||||
globals.pushEvent("cursor_data", cd);
|
globals.pushEvent("cursor_data", cd);
|
||||||
} else if (msg?.cursorId) {
|
} else if (msg?.cursorId) {
|
||||||
globals.pushEvent("cursor_id", { id: msg?.cursorId });
|
globals.pushEvent("cursor_id", { id: msg?.cursorId });
|
||||||
|
@ -2,8 +2,10 @@ import Connection from "./connection";
|
|||||||
import _sodium from "libsodium-wrappers";
|
import _sodium from "libsodium-wrappers";
|
||||||
import * as zstd from 'zstddec';
|
import * as zstd from 'zstddec';
|
||||||
import { CursorData } from "./message";
|
import { CursorData } from "./message";
|
||||||
|
import { loadOpus, loadVp9 } from "./codec";
|
||||||
|
|
||||||
const decompressor = new zstd.ZSTDDecoder();
|
var decompressor;
|
||||||
|
var wasmDsp;
|
||||||
|
|
||||||
var currentFrame = undefined;
|
var currentFrame = undefined;
|
||||||
var events = [];
|
var events = [];
|
||||||
@ -122,7 +124,7 @@ export function decrypt(signed, nonce, key) {
|
|||||||
return sodium.crypto_secretbox_open_easy(signed, makeOnce(nonce), key);
|
return sodium.crypto_secretbox_open_easy(signed, makeOnce(nonce), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function decompress(compressedArray) {
|
export async function decompress(compressedArray) {
|
||||||
const MAX = 1024 * 1024 * 64;
|
const MAX = 1024 * 1024 * 64;
|
||||||
const MIN = 1024 * 1024;
|
const MIN = 1024 * 1024;
|
||||||
let n = 30 * compressedArray.length;
|
let n = 30 * compressedArray.length;
|
||||||
@ -133,6 +135,9 @@ export function decompress(compressedArray) {
|
|||||||
n = MIN;
|
n = MIN;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (!decompressor) {
|
||||||
|
await initZstd();
|
||||||
|
}
|
||||||
return decompressor.decode(compressedArray, n);
|
return decompressor.decode(compressedArray, n);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('decompress failed: ' + e);
|
console.error('decompress failed: ' + e);
|
||||||
@ -267,6 +272,24 @@ window.getByName = (name, arg) => {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
window.init = () => {
|
window.init = async () => {
|
||||||
decompressor.init();
|
await initZstd();
|
||||||
|
}
|
||||||
|
|
||||||
|
function I420ToARGB(yuvbuffer) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initZstd() {
|
||||||
|
loadOpus(() => { });
|
||||||
|
loadVp9(() => { });
|
||||||
|
fetch('./LibYUV.wasm').then(res => res.arrayBuffer()).then((buffer) => {
|
||||||
|
LibYUV['wasmBinary'] = buffer;
|
||||||
|
window.wasmDsp = wasmDsp = LibYUV({ wasmBinary: LibYUV.wasmBinary });
|
||||||
|
console.log('libyuv ready');
|
||||||
|
});
|
||||||
|
const tmp = new zstd.ZSTDDecoder();
|
||||||
|
await tmp.init();
|
||||||
|
console.log('zstd ready');
|
||||||
|
decompressor = tmp;
|
||||||
}
|
}
|
1234
yuv-canvas-1.2.6.js
Normal file
1234
yuv-canvas-1.2.6.js
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user