@4players/odin-plugin-web 1.0.0-alpha.6 → 1.0.0-alpha.8
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/{backend/lib → lib/plugin}/audioController.d.ts +3 -3
- package/{backend/lib → lib/plugin}/audioController.js +2 -2
- package/lib/wasm/index.js +19 -0
- package/{worker/lib → lib/worker}/common.d.ts +2 -1
- package/lib/worker/common.js +100 -0
- package/{worker/lib → lib/worker}/index.d.ts +1 -0
- package/lib/worker/index.js +2 -0
- package/{worker/lib → lib/worker}/messages.d.ts +1 -0
- package/lib/worker/messages.js +16 -0
- package/package.json +11 -12
- package/backend/lib/audioController.d.ts.map +0 -1
- package/backend/lib/audioController.js.map +0 -1
- package/backend/lib/config.d.ts.map +0 -1
- package/backend/lib/config.js.map +0 -1
- package/backend/lib/connectionPool.d.ts.map +0 -1
- package/backend/lib/connectionPool.js.map +0 -1
- package/backend/lib/index.d.ts.map +0 -1
- package/backend/lib/index.js.map +0 -1
- package/backend/lib/mainConnection.d.ts.map +0 -1
- package/backend/lib/mainConnection.js.map +0 -1
- package/backend/lib/roomConnection.d.ts.map +0 -1
- package/backend/lib/roomConnection.js.map +0 -1
- package/backend/lib/rpcConnection.d.ts.map +0 -1
- package/backend/lib/rpcConnection.js.map +0 -1
- package/backend/lib/token.d.ts.map +0 -1
- package/backend/lib/token.js.map +0 -1
- package/backend/package.json +0 -16
- package/wasm/lib/index.js +0 -19
- package/wasm/package.json +0 -14
- package/worker/lib/index.js +0 -2
- package/worker/package.json +0 -16
- /package/{backend/lib → lib/plugin}/config.d.ts +0 -0
- /package/{backend/lib → lib/plugin}/config.js +0 -0
- /package/{backend/lib → lib/plugin}/connectionPool.d.ts +0 -0
- /package/{backend/lib → lib/plugin}/connectionPool.js +0 -0
- /package/{backend/lib → lib/plugin}/index.d.ts +0 -0
- /package/{backend/lib → lib/plugin}/index.js +0 -0
- /package/{backend/lib → lib/plugin}/mainConnection.d.ts +0 -0
- /package/{backend/lib → lib/plugin}/mainConnection.js +0 -0
- /package/{backend/lib → lib/plugin}/roomConnection.d.ts +0 -0
- /package/{backend/lib → lib/plugin}/roomConnection.js +0 -0
- /package/{backend/lib → lib/plugin}/rpcConnection.d.ts +0 -0
- /package/{backend/lib → lib/plugin}/rpcConnection.js +0 -0
- /package/{backend/lib → lib/plugin}/token.d.ts +0 -0
- /package/{backend/lib → lib/plugin}/token.js +0 -0
- /package/{wasm/lib → lib/wasm}/index.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from '@4players/odin-common';
|
|
2
|
-
import type { OdinWasm } from '
|
|
2
|
+
import type { OdinWasm } from '../../lib/wasm';
|
|
3
3
|
import type { PlaybackId } from './index';
|
|
4
4
|
export declare const PlaybackPreload = 3;
|
|
5
5
|
export declare const DefaultRefreshRate = 250;
|
|
@@ -25,3 +25,4 @@ export declare class Packet {
|
|
|
25
25
|
constructor(mediaIds: number[], sequenceNumber: number, timeStamp: number, isEndOfSpurt: boolean, payload: Uint8Array);
|
|
26
26
|
toBytes(): Uint8Array;
|
|
27
27
|
}
|
|
28
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* eslint-disable no-redeclare */
|
|
2
|
+
import { failure, success } from '@4players/odin-common';
|
|
3
|
+
import * as msgpack from '@msgpack/msgpack';
|
|
4
|
+
export const PlaybackPreload = 3;
|
|
5
|
+
export const DefaultRefreshRate = 250;
|
|
6
|
+
export const VadPreload = 3;
|
|
7
|
+
export const MaxNumberOfDecoders = 512;
|
|
8
|
+
export const MinDBFs = -758.596;
|
|
9
|
+
export function malloc(wasm, element, length) {
|
|
10
|
+
let heap;
|
|
11
|
+
switch (element) {
|
|
12
|
+
case 'f32':
|
|
13
|
+
heap = wasm.HEAPF32;
|
|
14
|
+
break;
|
|
15
|
+
case 'u32':
|
|
16
|
+
heap = wasm.HEAPU32;
|
|
17
|
+
break;
|
|
18
|
+
case 'i32':
|
|
19
|
+
heap = wasm.HEAP32;
|
|
20
|
+
break;
|
|
21
|
+
case 'u8':
|
|
22
|
+
heap = wasm.HEAPU8;
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`allocating ${element} is not supported`);
|
|
26
|
+
}
|
|
27
|
+
const pointer = wasm._malloc(length * heap.BYTES_PER_ELEMENT);
|
|
28
|
+
if (pointer === 0 || pointer % heap.BYTES_PER_ELEMENT !== 0) {
|
|
29
|
+
throw new Error(`failed allocating a ${length} ${element} array`);
|
|
30
|
+
}
|
|
31
|
+
const start = pointer / heap.BYTES_PER_ELEMENT;
|
|
32
|
+
return heap.subarray(start, start + length);
|
|
33
|
+
}
|
|
34
|
+
export function free(wasm, array) {
|
|
35
|
+
wasm._free(array.byteOffset);
|
|
36
|
+
}
|
|
37
|
+
export function mergeIds(id) {
|
|
38
|
+
// connectionId is 21 Bits.
|
|
39
|
+
// mediaId is 32 Bits
|
|
40
|
+
return id.connectionId * 4294967296 + id.mediaId;
|
|
41
|
+
}
|
|
42
|
+
export class Packet {
|
|
43
|
+
static parse(bytes) {
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = msgpack.decode(bytes);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return failure('not valid msgpack');
|
|
50
|
+
}
|
|
51
|
+
if (!Array.isArray(parsed))
|
|
52
|
+
return failure('container must be an array');
|
|
53
|
+
if (parsed.length < 6)
|
|
54
|
+
return failure('missing fields');
|
|
55
|
+
if (parsed[0] !== 1)
|
|
56
|
+
return failure('unknown type');
|
|
57
|
+
if (!Array.isArray(parsed[1]))
|
|
58
|
+
return failure('media ids must be an array');
|
|
59
|
+
if (!parsed[1].every((entry) => typeof entry === 'number')) {
|
|
60
|
+
return failure('media ids must be numbers');
|
|
61
|
+
}
|
|
62
|
+
if (typeof parsed[2] !== 'number') {
|
|
63
|
+
return failure('sequence number must be a number');
|
|
64
|
+
}
|
|
65
|
+
if (typeof parsed[3] !== 'number') {
|
|
66
|
+
return failure('timestamp must be a number');
|
|
67
|
+
}
|
|
68
|
+
if (typeof parsed[4] !== 'number')
|
|
69
|
+
return failure('flags must be a number');
|
|
70
|
+
const mediaIds = parsed[1];
|
|
71
|
+
const sequenceNumber = parsed[2] >>> 0;
|
|
72
|
+
const timeStamp = parsed[3] >>> 0;
|
|
73
|
+
const flags = parsed[4];
|
|
74
|
+
const isEndOfSpurt = (flags & 0x01) !== 0;
|
|
75
|
+
const payload = parsed[parsed.length - 1];
|
|
76
|
+
if (!(payload instanceof Uint8Array)) {
|
|
77
|
+
return failure('payload must be bytes');
|
|
78
|
+
}
|
|
79
|
+
return success(new Packet(mediaIds, sequenceNumber, timeStamp, isEndOfSpurt, payload));
|
|
80
|
+
}
|
|
81
|
+
constructor(mediaIds, sequenceNumber, timeStamp, isEndOfSpurt, payload) {
|
|
82
|
+
this.mediaIds = mediaIds;
|
|
83
|
+
this.sequenceNumber = sequenceNumber;
|
|
84
|
+
this.timeStamp = timeStamp;
|
|
85
|
+
this.isEndOfSpurt = isEndOfSpurt;
|
|
86
|
+
this.payload = payload;
|
|
87
|
+
}
|
|
88
|
+
toBytes() {
|
|
89
|
+
const flags = Number(this.isEndOfSpurt);
|
|
90
|
+
return msgpack.encode([
|
|
91
|
+
1,
|
|
92
|
+
this.mediaIds,
|
|
93
|
+
this.sequenceNumber >>> 0,
|
|
94
|
+
this.timeStamp >>> 0,
|
|
95
|
+
flags,
|
|
96
|
+
this.payload,
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=common.js.map
|