@supraio/client-daemon-js 0.0.0-mznacl.302 → 0.0.0-mznacldate1212.297
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/daemon.html +1 -1
- package/daemon.js +16559 -17058
- package/daemon.js.map +4 -4
- package/go/go.d.ts +1 -0
- package/nacl-decoder.d.ts +153 -0
- package/nacl-decoder.js +393 -0
- package/nacl-decoder.nmf +14 -0
- package/nacl-decoder.pexe +0 -0
- package/nacl-decoder.po +0 -0
- package/nacl-decoder_armv7.nexe +0 -0
- package/nacl-decoder_i686.nexe +0 -0
- package/nacl-decoder_x86-64.nexe +0 -0
- package/package.json +2 -4
- package/screen/plain.d.ts +6 -0
- package/screen/wasm.d.ts +7 -0
- package/screen.html +2 -1
- package/screen.js +16587 -17250
- package/screen.js.map +4 -4
- package/sdk.d.ts +2 -5
- package/sdk.js +16593 -17253
- package/sdk.js.map +4 -4
- package/supra-client-daemon.js +1527 -1070
- package/supra-client-daemon.js.map +1 -1
- package/supra-client-daemon.wasm +0 -0
- package/supra-client-screen.js +1874 -1566
- package/supra-client-screen.js.map +1 -1
- package/supra-client-screen.wasm +0 -0
- package/screen/h264decoder.d.ts +0 -8
- package/screen/nacldecoder.d.ts +0 -8
package/go/go.d.ts
CHANGED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
declare function createNaClModule(): {
|
|
2
|
+
listenerEl: HTMLDivElement;
|
|
3
|
+
naclModuleEl: HTMLEmbedElement & {
|
|
4
|
+
postMessage(message: string | ArrayBuffer): void;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
declare const listenerEl: HTMLDivElement, naclModuleEl: HTMLEmbedElement & {
|
|
8
|
+
postMessage(message: string | ArrayBuffer): void;
|
|
9
|
+
};
|
|
10
|
+
declare const messageListeners: Set<(message: NaClToJSMessage) => void>;
|
|
11
|
+
declare function handleMessage(event: MessageEvent): void;
|
|
12
|
+
declare function handleLoad(event: Event): void;
|
|
13
|
+
declare function handleCrash(event: Event): void;
|
|
14
|
+
declare enum JSToNaClMessageType {
|
|
15
|
+
Render = 0,
|
|
16
|
+
Initialize = 1,
|
|
17
|
+
Decode = 2,
|
|
18
|
+
GetPicture = 3,
|
|
19
|
+
Flush = 4,
|
|
20
|
+
Reset = 5,
|
|
21
|
+
RecyclePicture = 6
|
|
22
|
+
}
|
|
23
|
+
declare enum NaClToJSMessageType {
|
|
24
|
+
RenderResult = 0,
|
|
25
|
+
InitializeResult = 1,
|
|
26
|
+
DecodeResult = 2,
|
|
27
|
+
GetPictureResult = 3,
|
|
28
|
+
FlushResult = 4,
|
|
29
|
+
ResetResult = 5,
|
|
30
|
+
UnknownDataType = 254,
|
|
31
|
+
UnknownMessageType = 255
|
|
32
|
+
}
|
|
33
|
+
interface JSToNaClMessage {
|
|
34
|
+
type: JSToNaClMessageType;
|
|
35
|
+
payload?: ArrayBuffer;
|
|
36
|
+
}
|
|
37
|
+
interface NaClToJSMessage {
|
|
38
|
+
type: NaClToJSMessageType;
|
|
39
|
+
payload: ArrayBuffer;
|
|
40
|
+
}
|
|
41
|
+
declare function convertMessageToArrayBuffer(message: JSToNaClMessage): ArrayBuffer;
|
|
42
|
+
declare function convertArrayBufferToMessage(arrayBuffer: ArrayBuffer): NaClToJSMessage;
|
|
43
|
+
declare function sendMessageWithoutResult(message: JSToNaClMessage): void;
|
|
44
|
+
declare function sendMessageWithResult(message: JSToNaClMessage, resultMessageType: NaClToJSMessageType): Promise<NaClToJSMessage>;
|
|
45
|
+
interface Graphics3DContext {
|
|
46
|
+
alphaSize?: number;
|
|
47
|
+
blueSize?: number;
|
|
48
|
+
greenSize?: number;
|
|
49
|
+
redSize?: number;
|
|
50
|
+
depthSize?: number;
|
|
51
|
+
stencilSize?: number;
|
|
52
|
+
samples?: number;
|
|
53
|
+
sampleBuffers?: number;
|
|
54
|
+
none?: boolean;
|
|
55
|
+
height?: number;
|
|
56
|
+
width?: number;
|
|
57
|
+
fullscreenSamsung?: boolean;
|
|
58
|
+
swapBehavior?: number;
|
|
59
|
+
bufferPreserved?: boolean;
|
|
60
|
+
bufferDestroyed?: boolean;
|
|
61
|
+
gpuPreference?: "lowPower" | "performance";
|
|
62
|
+
singleBuffer?: boolean;
|
|
63
|
+
}
|
|
64
|
+
declare enum VideoProfile {
|
|
65
|
+
H264Baseline = 0,
|
|
66
|
+
H264Main = 1,
|
|
67
|
+
H264Extended = 2,
|
|
68
|
+
H264High = 3,
|
|
69
|
+
H264High10Profile = 4,
|
|
70
|
+
H264High422Profile = 5,
|
|
71
|
+
H264High444PredictiveProfile = 6,
|
|
72
|
+
H264ScalableBaseline = 7,
|
|
73
|
+
H264ScalableHigh = 8,
|
|
74
|
+
H264StereoHigh = 9,
|
|
75
|
+
H264MultiviewHigh = 10,
|
|
76
|
+
VP8Any = 11,
|
|
77
|
+
VP9Any = 12,
|
|
78
|
+
Max = 12
|
|
79
|
+
}
|
|
80
|
+
declare enum HWAcceleration {
|
|
81
|
+
Only = 0,
|
|
82
|
+
WithFallback = 1,
|
|
83
|
+
None = 2,
|
|
84
|
+
Last = 2
|
|
85
|
+
}
|
|
86
|
+
interface InitializeArgs {
|
|
87
|
+
graphics3DContext: Graphics3DContext;
|
|
88
|
+
profile: VideoProfile;
|
|
89
|
+
acceleration: HWAcceleration;
|
|
90
|
+
minPictureCount: number;
|
|
91
|
+
}
|
|
92
|
+
declare enum ResultStatus {
|
|
93
|
+
Ok = 0,
|
|
94
|
+
OkCompletionPending = -1,
|
|
95
|
+
ErrorFailed = -2,
|
|
96
|
+
ErrorAborted = -3,
|
|
97
|
+
ErrorBadArgument = -4,
|
|
98
|
+
ErrorBadResource = -5,
|
|
99
|
+
ErrorNoInit = -6,
|
|
100
|
+
ErrorNoAccess = -7,
|
|
101
|
+
ErrorNoMemory = -8,
|
|
102
|
+
ErrorNoSpace = -9,
|
|
103
|
+
ErrorNoQuota = -10,
|
|
104
|
+
ErrorInProgress = -11,
|
|
105
|
+
ErrorNotSupported = -12,
|
|
106
|
+
ErrorBlocksMainThread = -13
|
|
107
|
+
}
|
|
108
|
+
interface DecodeArgs {
|
|
109
|
+
decodeId: number;
|
|
110
|
+
data: ArrayBuffer;
|
|
111
|
+
}
|
|
112
|
+
declare enum GLTexture {
|
|
113
|
+
Texture2D = 3553,
|
|
114
|
+
TextureRectangleARB = 34037,
|
|
115
|
+
TextureExternal = 36197
|
|
116
|
+
}
|
|
117
|
+
interface VideoPicture {
|
|
118
|
+
decodeId: number;
|
|
119
|
+
textureId: number;
|
|
120
|
+
textureTarget: GLTexture;
|
|
121
|
+
textureSize: {
|
|
122
|
+
width: number;
|
|
123
|
+
height: number;
|
|
124
|
+
};
|
|
125
|
+
visibleRect: {
|
|
126
|
+
x: number;
|
|
127
|
+
y: number;
|
|
128
|
+
width: number;
|
|
129
|
+
height: number;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
interface IVideoDecoder {
|
|
133
|
+
initialize(args: InitializeArgs): Promise<ResultStatus>;
|
|
134
|
+
decode(args: DecodeArgs): Promise<ResultStatus>;
|
|
135
|
+
getPicture(): Promise<VideoPicture>;
|
|
136
|
+
recyclePicture(picture: VideoPicture): void;
|
|
137
|
+
flush(): Promise<ResultStatus>;
|
|
138
|
+
reset(): Promise<ResultStatus>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Wrapper over pp::VideoDecoder
|
|
142
|
+
* See https://chromium.googlesource.com/chromium/src/+/master/ppapi/cpp/video_decoder.h
|
|
143
|
+
*/
|
|
144
|
+
declare class NaClDecoder implements IVideoDecoder {
|
|
145
|
+
constructor();
|
|
146
|
+
initialize(args: InitializeArgs): Promise<number>;
|
|
147
|
+
decode(args: DecodeArgs): Promise<number>;
|
|
148
|
+
getPicture(): Promise<VideoPicture>;
|
|
149
|
+
recyclePicture(picture: VideoPicture): void;
|
|
150
|
+
flush(): Promise<number>;
|
|
151
|
+
reset(): Promise<number>;
|
|
152
|
+
render(picture: VideoPicture): Promise<void>;
|
|
153
|
+
}
|
package/nacl-decoder.js
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
38
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39
|
+
if (!m) return o;
|
|
40
|
+
var i = m.call(o), r, ar = [], e;
|
|
41
|
+
try {
|
|
42
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43
|
+
}
|
|
44
|
+
catch (error) { e = { error: error }; }
|
|
45
|
+
finally {
|
|
46
|
+
try {
|
|
47
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
48
|
+
}
|
|
49
|
+
finally { if (e) throw e.error; }
|
|
50
|
+
}
|
|
51
|
+
return ar;
|
|
52
|
+
};
|
|
53
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
+
if (ar || !(i in from)) {
|
|
56
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
+
ar[i] = from[i];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
+
};
|
|
62
|
+
// Initialization
|
|
63
|
+
function isNaClSupported() {
|
|
64
|
+
return navigator.mimeTypes["application/x-nacl"] !== undefined;
|
|
65
|
+
}
|
|
66
|
+
if (isNaClSupported()) {
|
|
67
|
+
function createNaClModule() {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
if (!isNaClSupported()) {
|
|
70
|
+
throw new Error("NaCl is not supported in this browser.");
|
|
71
|
+
}
|
|
72
|
+
var listenerEl = document.createElement("div");
|
|
73
|
+
listenerEl.setAttribute("id", "listener");
|
|
74
|
+
listenerEl.addEventListener("message", handleMessage, true);
|
|
75
|
+
listenerEl.addEventListener("load", handleLoad, true);
|
|
76
|
+
listenerEl.addEventListener("crash", handleCrash, true);
|
|
77
|
+
document.body.appendChild(listenerEl);
|
|
78
|
+
var baseHref = (_b = (_a = document.getElementsByTagName("base")[0]) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : location.href;
|
|
79
|
+
var nmpPath = new URL("nacl-decoder.nmf", baseHref).href;
|
|
80
|
+
var naclModuleEl = document.createElement("embed");
|
|
81
|
+
naclModuleEl.setAttribute("width", "1920");
|
|
82
|
+
naclModuleEl.setAttribute("height", "1080");
|
|
83
|
+
naclModuleEl.setAttribute("src", nmpPath);
|
|
84
|
+
naclModuleEl.setAttribute("type", "application/x-nacl");
|
|
85
|
+
naclModuleEl.setAttribute("id", "nacl_module");
|
|
86
|
+
listenerEl.appendChild(naclModuleEl);
|
|
87
|
+
return {
|
|
88
|
+
listenerEl: listenerEl,
|
|
89
|
+
naclModuleEl: naclModuleEl,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
var _a = createNaClModule(), listenerEl = _a.listenerEl, naclModuleEl_1 = _a.naclModuleEl;
|
|
93
|
+
// Bridge logic
|
|
94
|
+
var messageListeners_1 = new Set();
|
|
95
|
+
function handleMessage(event) {
|
|
96
|
+
if (!(event.data instanceof ArrayBuffer)) {
|
|
97
|
+
throw new Error("Unexpected message data type. Only ArrayBuffer is supported.");
|
|
98
|
+
}
|
|
99
|
+
var message = convertArrayBufferToMessage(event.data);
|
|
100
|
+
messageListeners_1.forEach(function (listener) { return listener(message); });
|
|
101
|
+
}
|
|
102
|
+
function handleLoad(event) {
|
|
103
|
+
console.log("nacl load", event);
|
|
104
|
+
}
|
|
105
|
+
function handleCrash(event) {
|
|
106
|
+
console.log("nacl crash", event);
|
|
107
|
+
}
|
|
108
|
+
// Helpers
|
|
109
|
+
var JSToNaClMessageType = void 0;
|
|
110
|
+
(function (JSToNaClMessageType) {
|
|
111
|
+
JSToNaClMessageType[JSToNaClMessageType["Render"] = 0] = "Render";
|
|
112
|
+
JSToNaClMessageType[JSToNaClMessageType["Initialize"] = 1] = "Initialize";
|
|
113
|
+
JSToNaClMessageType[JSToNaClMessageType["Decode"] = 2] = "Decode";
|
|
114
|
+
JSToNaClMessageType[JSToNaClMessageType["GetPicture"] = 3] = "GetPicture";
|
|
115
|
+
JSToNaClMessageType[JSToNaClMessageType["Flush"] = 4] = "Flush";
|
|
116
|
+
JSToNaClMessageType[JSToNaClMessageType["Reset"] = 5] = "Reset";
|
|
117
|
+
JSToNaClMessageType[JSToNaClMessageType["RecyclePicture"] = 6] = "RecyclePicture";
|
|
118
|
+
})(JSToNaClMessageType || (JSToNaClMessageType = {}));
|
|
119
|
+
var NaClToJSMessageType = void 0;
|
|
120
|
+
(function (NaClToJSMessageType) {
|
|
121
|
+
NaClToJSMessageType[NaClToJSMessageType["RenderResult"] = 0] = "RenderResult";
|
|
122
|
+
NaClToJSMessageType[NaClToJSMessageType["InitializeResult"] = 1] = "InitializeResult";
|
|
123
|
+
NaClToJSMessageType[NaClToJSMessageType["DecodeResult"] = 2] = "DecodeResult";
|
|
124
|
+
NaClToJSMessageType[NaClToJSMessageType["GetPictureResult"] = 3] = "GetPictureResult";
|
|
125
|
+
NaClToJSMessageType[NaClToJSMessageType["FlushResult"] = 4] = "FlushResult";
|
|
126
|
+
NaClToJSMessageType[NaClToJSMessageType["ResetResult"] = 5] = "ResetResult";
|
|
127
|
+
NaClToJSMessageType[NaClToJSMessageType["UnknownDataType"] = 254] = "UnknownDataType";
|
|
128
|
+
NaClToJSMessageType[NaClToJSMessageType["UnknownMessageType"] = 255] = "UnknownMessageType";
|
|
129
|
+
})(NaClToJSMessageType || (NaClToJSMessageType = {}));
|
|
130
|
+
function convertMessageToArrayBuffer(message) {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
var arrayBuffer = new ArrayBuffer(1 + ((_b = (_a = message.payload) === null || _a === void 0 ? void 0 : _a.byteLength) !== null && _b !== void 0 ? _b : 0));
|
|
133
|
+
var uint8Array = new Uint8Array(arrayBuffer);
|
|
134
|
+
uint8Array[0] = message.type;
|
|
135
|
+
if (message.payload) {
|
|
136
|
+
uint8Array.set(new Uint8Array(message.payload), 1);
|
|
137
|
+
}
|
|
138
|
+
return arrayBuffer;
|
|
139
|
+
}
|
|
140
|
+
function convertArrayBufferToMessage(arrayBuffer) {
|
|
141
|
+
var uint8Array = new Uint8Array(arrayBuffer);
|
|
142
|
+
var type = uint8Array[0];
|
|
143
|
+
var payload = arrayBuffer.slice(1);
|
|
144
|
+
return { type: type, payload: payload };
|
|
145
|
+
}
|
|
146
|
+
function sendMessageWithoutResult(message) {
|
|
147
|
+
naclModuleEl_1.postMessage(convertMessageToArrayBuffer(message));
|
|
148
|
+
}
|
|
149
|
+
function sendMessageWithResult(message, resultMessageType) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var arrayBuffer;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
arrayBuffer = convertMessageToArrayBuffer(message);
|
|
154
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
155
|
+
// TODO add timeout
|
|
156
|
+
var listener = function (message) {
|
|
157
|
+
if (message.type !== resultMessageType) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
messageListeners_1.delete(listener);
|
|
161
|
+
resolve(message);
|
|
162
|
+
};
|
|
163
|
+
messageListeners_1.add(listener);
|
|
164
|
+
naclModuleEl_1.postMessage(arrayBuffer);
|
|
165
|
+
})];
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
var VideoProfile = void 0;
|
|
170
|
+
(function (VideoProfile) {
|
|
171
|
+
VideoProfile[VideoProfile["H264Baseline"] = 0] = "H264Baseline";
|
|
172
|
+
VideoProfile[VideoProfile["H264Main"] = 1] = "H264Main";
|
|
173
|
+
VideoProfile[VideoProfile["H264Extended"] = 2] = "H264Extended";
|
|
174
|
+
VideoProfile[VideoProfile["H264High"] = 3] = "H264High";
|
|
175
|
+
VideoProfile[VideoProfile["H264High10Profile"] = 4] = "H264High10Profile";
|
|
176
|
+
VideoProfile[VideoProfile["H264High422Profile"] = 5] = "H264High422Profile";
|
|
177
|
+
VideoProfile[VideoProfile["H264High444PredictiveProfile"] = 6] = "H264High444PredictiveProfile";
|
|
178
|
+
VideoProfile[VideoProfile["H264ScalableBaseline"] = 7] = "H264ScalableBaseline";
|
|
179
|
+
VideoProfile[VideoProfile["H264ScalableHigh"] = 8] = "H264ScalableHigh";
|
|
180
|
+
VideoProfile[VideoProfile["H264StereoHigh"] = 9] = "H264StereoHigh";
|
|
181
|
+
VideoProfile[VideoProfile["H264MultiviewHigh"] = 10] = "H264MultiviewHigh";
|
|
182
|
+
VideoProfile[VideoProfile["VP8Any"] = 11] = "VP8Any";
|
|
183
|
+
VideoProfile[VideoProfile["VP9Any"] = 12] = "VP9Any";
|
|
184
|
+
VideoProfile[VideoProfile["Max"] = 12] = "Max";
|
|
185
|
+
})(VideoProfile || (VideoProfile = {}));
|
|
186
|
+
var HWAcceleration = void 0;
|
|
187
|
+
(function (HWAcceleration) {
|
|
188
|
+
HWAcceleration[HWAcceleration["Only"] = 0] = "Only";
|
|
189
|
+
HWAcceleration[HWAcceleration["WithFallback"] = 1] = "WithFallback";
|
|
190
|
+
HWAcceleration[HWAcceleration["None"] = 2] = "None";
|
|
191
|
+
HWAcceleration[HWAcceleration["Last"] = 2] = "Last";
|
|
192
|
+
})(HWAcceleration || (HWAcceleration = {}));
|
|
193
|
+
var ResultStatus = void 0;
|
|
194
|
+
(function (ResultStatus) {
|
|
195
|
+
ResultStatus[ResultStatus["Ok"] = 0] = "Ok";
|
|
196
|
+
ResultStatus[ResultStatus["OkCompletionPending"] = -1] = "OkCompletionPending";
|
|
197
|
+
ResultStatus[ResultStatus["ErrorFailed"] = -2] = "ErrorFailed";
|
|
198
|
+
ResultStatus[ResultStatus["ErrorAborted"] = -3] = "ErrorAborted";
|
|
199
|
+
ResultStatus[ResultStatus["ErrorBadArgument"] = -4] = "ErrorBadArgument";
|
|
200
|
+
ResultStatus[ResultStatus["ErrorBadResource"] = -5] = "ErrorBadResource";
|
|
201
|
+
ResultStatus[ResultStatus["ErrorNoInit"] = -6] = "ErrorNoInit";
|
|
202
|
+
ResultStatus[ResultStatus["ErrorNoAccess"] = -7] = "ErrorNoAccess";
|
|
203
|
+
ResultStatus[ResultStatus["ErrorNoMemory"] = -8] = "ErrorNoMemory";
|
|
204
|
+
ResultStatus[ResultStatus["ErrorNoSpace"] = -9] = "ErrorNoSpace";
|
|
205
|
+
ResultStatus[ResultStatus["ErrorNoQuota"] = -10] = "ErrorNoQuota";
|
|
206
|
+
ResultStatus[ResultStatus["ErrorInProgress"] = -11] = "ErrorInProgress";
|
|
207
|
+
ResultStatus[ResultStatus["ErrorNotSupported"] = -12] = "ErrorNotSupported";
|
|
208
|
+
ResultStatus[ResultStatus["ErrorBlocksMainThread"] = -13] = "ErrorBlocksMainThread";
|
|
209
|
+
// TODO add all errors from pp_errors.h
|
|
210
|
+
})(ResultStatus || (ResultStatus = {}));
|
|
211
|
+
var GLTexture = void 0;
|
|
212
|
+
(function (GLTexture) {
|
|
213
|
+
GLTexture[GLTexture["Texture2D"] = 3553] = "Texture2D";
|
|
214
|
+
GLTexture[GLTexture["TextureRectangleARB"] = 34037] = "TextureRectangleARB";
|
|
215
|
+
GLTexture[GLTexture["TextureExternal"] = 36197] = "TextureExternal";
|
|
216
|
+
})(GLTexture || (GLTexture = {}));
|
|
217
|
+
// Implementation
|
|
218
|
+
/**
|
|
219
|
+
* Wrapper over pp::VideoDecoder
|
|
220
|
+
* See https://chromium.googlesource.com/chromium/src/+/master/ppapi/cpp/video_decoder.h
|
|
221
|
+
*/
|
|
222
|
+
var NaClDecoder = /** @class */ (function () {
|
|
223
|
+
function NaClDecoder() {
|
|
224
|
+
}
|
|
225
|
+
NaClDecoder.prototype.initialize = function (args) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
+
var message, resultMessage, resultStatus;
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
switch (_a.label) {
|
|
230
|
+
case 0:
|
|
231
|
+
message = {
|
|
232
|
+
type: JSToNaClMessageType.Initialize,
|
|
233
|
+
payload: new Uint8Array(__spreadArray([
|
|
234
|
+
args.profile,
|
|
235
|
+
args.acceleration
|
|
236
|
+
], __read(new Uint8Array(new Uint32Array([args.minPictureCount]).buffer)), false)).buffer,
|
|
237
|
+
};
|
|
238
|
+
return [4 /*yield*/, sendMessageWithResult(message, NaClToJSMessageType.InitializeResult)];
|
|
239
|
+
case 1:
|
|
240
|
+
resultMessage = _a.sent();
|
|
241
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
242
|
+
return [2 /*return*/, resultStatus];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
NaClDecoder.prototype.decode = function (args) {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
249
|
+
var message, resultMessage, resultStatus;
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
switch (_a.label) {
|
|
252
|
+
case 0:
|
|
253
|
+
if (!(args.data instanceof ArrayBuffer)) {
|
|
254
|
+
throw new Error("Unexpected data type. Only ArrayBuffer is supported.");
|
|
255
|
+
}
|
|
256
|
+
message = {
|
|
257
|
+
type: JSToNaClMessageType.Decode,
|
|
258
|
+
// TODO decodeId (not used in the NaCl module now)
|
|
259
|
+
payload: args.data,
|
|
260
|
+
};
|
|
261
|
+
return [4 /*yield*/, sendMessageWithResult(message, NaClToJSMessageType.DecodeResult)];
|
|
262
|
+
case 1:
|
|
263
|
+
resultMessage = _a.sent();
|
|
264
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
265
|
+
return [2 /*return*/, resultStatus];
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
NaClDecoder.prototype.getPicture = function () {
|
|
271
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
+
var message, resultMessage, resultFirstUInt32Array, resultSecondInt32Array, picture;
|
|
273
|
+
return __generator(this, function (_a) {
|
|
274
|
+
switch (_a.label) {
|
|
275
|
+
case 0:
|
|
276
|
+
message = {
|
|
277
|
+
type: JSToNaClMessageType.GetPicture,
|
|
278
|
+
};
|
|
279
|
+
return [4 /*yield*/, sendMessageWithResult(message, NaClToJSMessageType.GetPictureResult)];
|
|
280
|
+
case 1:
|
|
281
|
+
resultMessage = _a.sent();
|
|
282
|
+
resultFirstUInt32Array = new Uint32Array(resultMessage.payload.slice(0, 12));
|
|
283
|
+
resultSecondInt32Array = new Int32Array(resultMessage.payload.slice(12, 24));
|
|
284
|
+
picture = {
|
|
285
|
+
decodeId: resultFirstUInt32Array[0],
|
|
286
|
+
textureId: resultFirstUInt32Array[1],
|
|
287
|
+
textureTarget: resultFirstUInt32Array[2],
|
|
288
|
+
textureSize: {
|
|
289
|
+
width: resultSecondInt32Array[0],
|
|
290
|
+
height: resultSecondInt32Array[1],
|
|
291
|
+
},
|
|
292
|
+
visibleRect: {
|
|
293
|
+
x: resultSecondInt32Array[2],
|
|
294
|
+
y: resultSecondInt32Array[3],
|
|
295
|
+
width: resultSecondInt32Array[4],
|
|
296
|
+
height: resultSecondInt32Array[5],
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
return [2 /*return*/, picture];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
};
|
|
304
|
+
NaClDecoder.prototype.recyclePicture = function (picture) {
|
|
305
|
+
var firstUint32Array = new Uint32Array([
|
|
306
|
+
picture.decodeId,
|
|
307
|
+
picture.textureId,
|
|
308
|
+
picture.textureTarget,
|
|
309
|
+
]);
|
|
310
|
+
var secondInt32Array = new Int32Array([
|
|
311
|
+
picture.textureSize.width,
|
|
312
|
+
picture.textureSize.height,
|
|
313
|
+
picture.visibleRect.x,
|
|
314
|
+
picture.visibleRect.y,
|
|
315
|
+
picture.visibleRect.width,
|
|
316
|
+
picture.visibleRect.height,
|
|
317
|
+
]);
|
|
318
|
+
var message = {
|
|
319
|
+
type: JSToNaClMessageType.RecyclePicture,
|
|
320
|
+
payload: new Uint8Array(__spreadArray(__spreadArray([], __read(new Uint8Array(firstUint32Array.buffer)), false), __read(new Uint8Array(secondInt32Array.buffer)), false)).buffer,
|
|
321
|
+
};
|
|
322
|
+
sendMessageWithoutResult(message);
|
|
323
|
+
};
|
|
324
|
+
NaClDecoder.prototype.flush = function () {
|
|
325
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
326
|
+
var message, resultMessage, resultStatus;
|
|
327
|
+
return __generator(this, function (_a) {
|
|
328
|
+
switch (_a.label) {
|
|
329
|
+
case 0:
|
|
330
|
+
message = {
|
|
331
|
+
type: JSToNaClMessageType.Flush,
|
|
332
|
+
};
|
|
333
|
+
return [4 /*yield*/, sendMessageWithResult(message, NaClToJSMessageType.FlushResult)];
|
|
334
|
+
case 1:
|
|
335
|
+
resultMessage = _a.sent();
|
|
336
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
337
|
+
return [2 /*return*/, resultStatus];
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
NaClDecoder.prototype.reset = function () {
|
|
343
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
344
|
+
var message, resultMessage, resultStatus;
|
|
345
|
+
return __generator(this, function (_a) {
|
|
346
|
+
switch (_a.label) {
|
|
347
|
+
case 0:
|
|
348
|
+
message = {
|
|
349
|
+
type: JSToNaClMessageType.Reset,
|
|
350
|
+
};
|
|
351
|
+
return [4 /*yield*/, sendMessageWithResult(message, NaClToJSMessageType.ResetResult)];
|
|
352
|
+
case 1:
|
|
353
|
+
resultMessage = _a.sent();
|
|
354
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
355
|
+
return [2 /*return*/, resultStatus];
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
NaClDecoder.prototype.render = function (picture) {
|
|
361
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
362
|
+
var firstUint32Array, secondInt32Array, message;
|
|
363
|
+
return __generator(this, function (_a) {
|
|
364
|
+
switch (_a.label) {
|
|
365
|
+
case 0:
|
|
366
|
+
firstUint32Array = new Uint32Array([
|
|
367
|
+
picture.decodeId,
|
|
368
|
+
picture.textureId,
|
|
369
|
+
picture.textureTarget,
|
|
370
|
+
]);
|
|
371
|
+
secondInt32Array = new Int32Array([
|
|
372
|
+
picture.textureSize.width,
|
|
373
|
+
picture.textureSize.height,
|
|
374
|
+
picture.visibleRect.x,
|
|
375
|
+
picture.visibleRect.y,
|
|
376
|
+
picture.visibleRect.width,
|
|
377
|
+
picture.visibleRect.height,
|
|
378
|
+
]);
|
|
379
|
+
message = {
|
|
380
|
+
type: JSToNaClMessageType.Render,
|
|
381
|
+
payload: new Uint8Array(__spreadArray(__spreadArray([], __read(new Uint8Array(firstUint32Array.buffer)), false), __read(new Uint8Array(secondInt32Array.buffer)), false)).buffer,
|
|
382
|
+
};
|
|
383
|
+
return [4 /*yield*/, sendMessageWithResult(message, NaClToJSMessageType.RenderResult)];
|
|
384
|
+
case 1:
|
|
385
|
+
_a.sent();
|
|
386
|
+
return [2 /*return*/];
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
return NaClDecoder;
|
|
392
|
+
}());
|
|
393
|
+
}
|
package/nacl-decoder.nmf
ADDED
|
Binary file
|
package/nacl-decoder.po
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supraio/client-daemon-js",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-mznacldate1212.297",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "sdk.js",
|
|
6
|
-
"types": "sdk.d.ts",
|
|
7
6
|
"scripts": {
|
|
8
7
|
"build-daemon": "esbuild --bundle --sourcemap --define:'process.env.VERSION'=\\\"$VERSION\\\" --target=chrome79,firefox86,edge89 --outfile=dist/daemon.js daemon.ts",
|
|
9
8
|
"build-screen": "esbuild --bundle --sourcemap --define:'process.env.VERSION'=\\\"$VERSION\\\" --target=chrome79,firefox86,edge89 --outfile=dist/screen.js screen.ts",
|
|
@@ -14,14 +13,13 @@
|
|
|
14
13
|
"lint": "eslint \"**/*.ts\""
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|
|
17
|
-
"@signageos/nacl-decoder": "^0.0.6",
|
|
18
16
|
"@types/dropboxjs": "0.0.29",
|
|
19
17
|
"@types/filesystem": "0.0.29",
|
|
20
18
|
"@types/node": "14.14.34",
|
|
21
19
|
"@typescript-eslint/eslint-plugin": "^4.17.0",
|
|
22
20
|
"@typescript-eslint/parser": "^4.17.0",
|
|
23
21
|
"browserfs": "1.4.3",
|
|
24
|
-
"esbuild": "
|
|
22
|
+
"esbuild": "0.9.2",
|
|
25
23
|
"eslint": "7.22.0",
|
|
26
24
|
"h264decoder": "git+https://github.com/misak113/h264decoder.git#master",
|
|
27
25
|
"querystring": "0.2.1",
|
package/screen/plain.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { IScreenOptions } from "./options";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
/** Make it global accessible for x264/nacldecoder/nacldecoder.go */
|
|
5
|
+
naclDecoder?: NaClDecoder;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
2
8
|
export declare function startPlainScreen(options?: IScreenOptions): Promise<void>;
|
package/screen/wasm.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import '../go/go';
|
|
2
|
+
import { H264Decoder } from 'h264decoder';
|
|
2
3
|
import { IScreenOptions } from './options';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
/** Make it global accessible for x264/decode_wasm.go */
|
|
7
|
+
h264Decoder: H264Decoder;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
3
10
|
export declare function startWasmScreen(options?: IScreenOptions): Promise<void>;
|
package/screen.html
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
<link rel="stylesheet" href="screen.css"></link>
|
|
6
6
|
</head>
|
|
7
7
|
<body>
|
|
8
|
-
<script type="text/javascript" src="
|
|
8
|
+
<script type="text/javascript" src="nacl-decoder.js"></script>
|
|
9
|
+
<script type="text/javascript" src="screen.js?v=0.0.0-mznacldate1212.297"></script>
|
|
9
10
|
</body>
|
|
10
11
|
</html>
|