@4players/odin-common 2.16.1 → 2.17.0
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/eslint.config.mjs +30 -0
- package/lib/cjs/index.js +2 -1
- package/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/cjs/utility/codec.js +119 -0
- package/lib/cjs/utility/log.js +0 -2
- package/lib/cjs/utility/result.js +4 -1
- package/lib/cjs/utility/sleep.js +0 -1
- package/lib/esm/index.js +3 -2
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/esm/utility/codec.js +115 -0
- package/lib/esm/utility/log.js +0 -2
- package/lib/esm/utility/result.js +3 -1
- package/lib/esm/utility/sleep.js +0 -1
- package/lib/index.d.ts +2 -1
- package/lib/rpc/commands.d.ts +12 -12
- package/lib/rpc/notifications.d.ts +80 -80
- package/lib/schema/message.d.ts +3 -3
- package/lib/schema/peer.d.ts +6 -6
- package/lib/schema/room.d.ts +56 -56
- package/lib/schema/serialization.d.ts +1 -1
- package/lib/utility/codec.d.ts +16 -0
- package/lib/utility/result.d.ts +1 -0
- package/package.json +12 -12
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import tseslint from 'typescript-eslint';
|
|
2
|
+
|
|
3
|
+
export default tseslint.config({
|
|
4
|
+
plugins: { '@typescript-eslint': tseslint.plugin },
|
|
5
|
+
languageOptions: {
|
|
6
|
+
parser: tseslint.parser,
|
|
7
|
+
parserOptions: { ecmaVersion: 12, sourceType: 'module' },
|
|
8
|
+
},
|
|
9
|
+
files: ['**/src/*.ts'],
|
|
10
|
+
ignores: ['**/lib/*.ts', '**/lib/**/*.ts'],
|
|
11
|
+
rules: {
|
|
12
|
+
camelcase: 'off',
|
|
13
|
+
'comma-dangle': [
|
|
14
|
+
'error',
|
|
15
|
+
{
|
|
16
|
+
arrays: 'always-multiline',
|
|
17
|
+
objects: 'always-multiline',
|
|
18
|
+
imports: 'always-multiline',
|
|
19
|
+
exports: 'always-multiline',
|
|
20
|
+
functions: 'never',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
'no-unused-vars': 'off',
|
|
24
|
+
'no-use-before-define': 'off',
|
|
25
|
+
'space-before-function-paren': [
|
|
26
|
+
'error',
|
|
27
|
+
{ anonymous: 'always', named: 'never', asyncArrow: 'always' },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
});
|
package/lib/cjs/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.zod = void 0;
|
|
18
|
+
exports.zod = require("zod");
|
|
18
19
|
__exportStar(require("./schema/serialization"), exports);
|
|
19
20
|
__exportStar(require("./schema/token"), exports);
|
|
20
21
|
__exportStar(require("./schema/room"), exports);
|
|
@@ -26,6 +27,7 @@ __exportStar(require("./rpc/commands"), exports);
|
|
|
26
27
|
__exportStar(require("./rpc/notifications"), exports);
|
|
27
28
|
__exportStar(require("./utility/base64"), exports);
|
|
28
29
|
__exportStar(require("./utility/bytearray"), exports);
|
|
30
|
+
__exportStar(require("./utility/codec"), exports);
|
|
29
31
|
__exportStar(require("./utility/iterable"), exports);
|
|
30
32
|
__exportStar(require("./utility/environment"), exports);
|
|
31
33
|
__exportStar(require("./utility/json"), exports);
|
|
@@ -39,4 +41,3 @@ __exportStar(require("./utility/uuid"), exports);
|
|
|
39
41
|
__exportStar(require("./utility/validation"), exports);
|
|
40
42
|
__exportStar(require("./utility/log"), exports);
|
|
41
43
|
__exportStar(require("./plugin/api"), exports);
|
|
42
|
-
exports.zod = require("zod");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.
|
|
1
|
+
{"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/codec.spec.ts","../../src/utility/codec.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.7.3"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VideoCodec = void 0;
|
|
4
|
+
const sdp_transform_1 = require("sdp-transform");
|
|
5
|
+
const result_1 = require("./result");
|
|
6
|
+
const validCodecs = ['VP8', 'VP9', 'AV1', 'H264'];
|
|
7
|
+
class VideoCodec {
|
|
8
|
+
constructor(codec) {
|
|
9
|
+
this.codec = codec;
|
|
10
|
+
this.channels = 0;
|
|
11
|
+
this.clockRate = 90000;
|
|
12
|
+
}
|
|
13
|
+
valid() {
|
|
14
|
+
return validCodecs.includes(this.codec);
|
|
15
|
+
}
|
|
16
|
+
supported() {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
if (typeof RTCRtpReceiver === 'undefined' ||
|
|
19
|
+
typeof RTCRtpReceiver.getCapabilities === 'undefined') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const expectedMimeType = (0, result_1.unwrapOr)(this.mimeType(), '').toLowerCase();
|
|
23
|
+
const expectedFmtpLine = new Set((0, result_1.unwrapOr)(this.sdpFmtpLine(), '')
|
|
24
|
+
.split(';')
|
|
25
|
+
.map((arg) => arg.trim().toLowerCase()));
|
|
26
|
+
return ((_c = (_b = (_a = RTCRtpReceiver.getCapabilities('video')) === null || _a === void 0 ? void 0 : _a.codecs) === null || _b === void 0 ? void 0 : _b.some((c) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const actualMimeType = c.mimeType.toLowerCase();
|
|
29
|
+
const actualFmtpLine = new Set(((_a = c.sdpFmtpLine) !== null && _a !== void 0 ? _a : '')
|
|
30
|
+
.split(';')
|
|
31
|
+
.map((arg) => arg.trim().toLowerCase()));
|
|
32
|
+
console.log(actualMimeType, actualFmtpLine);
|
|
33
|
+
if (expectedMimeType !== actualMimeType)
|
|
34
|
+
return false;
|
|
35
|
+
if (expectedFmtpLine.size !== actualFmtpLine.size)
|
|
36
|
+
return false;
|
|
37
|
+
for (let item of expectedFmtpLine) {
|
|
38
|
+
if (!actualFmtpLine.has(item))
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
})) !== null && _c !== void 0 ? _c : false);
|
|
43
|
+
}
|
|
44
|
+
filterSdp(description) {
|
|
45
|
+
if (!this.valid()) {
|
|
46
|
+
return description;
|
|
47
|
+
}
|
|
48
|
+
const sdp = (0, sdp_transform_1.parse)(description);
|
|
49
|
+
const payload = (0, result_1.unwrap)(this.payloadType());
|
|
50
|
+
const config = (0, result_1.unwrap)(this.sdpFmtpLine());
|
|
51
|
+
sdp.media = sdp.media.map((media) => {
|
|
52
|
+
media.payloads = '';
|
|
53
|
+
media.rtp = [];
|
|
54
|
+
media.fmtp = [];
|
|
55
|
+
media.rtcpFb = [];
|
|
56
|
+
media.payloads = String(payload);
|
|
57
|
+
media.rtp.push({ payload, codec: this.codec, rate: this.clockRate });
|
|
58
|
+
if (this.sdpFmtpLine()) {
|
|
59
|
+
media.fmtp.push({ payload, config });
|
|
60
|
+
}
|
|
61
|
+
media.rtcpFb.push({ payload, type: 'goog-remb' });
|
|
62
|
+
media.rtcpFb.push({ payload, type: 'transport-cc' });
|
|
63
|
+
media.rtcpFb.push({ payload, type: 'ccm', subtype: 'fir' });
|
|
64
|
+
media.rtcpFb.push({ payload, type: 'nack' });
|
|
65
|
+
media.rtcpFb.push({ payload, type: 'nack', subtype: 'pli' });
|
|
66
|
+
return media;
|
|
67
|
+
});
|
|
68
|
+
return (0, sdp_transform_1.write)(sdp);
|
|
69
|
+
}
|
|
70
|
+
payloadType() {
|
|
71
|
+
switch (this.codec) {
|
|
72
|
+
case 'VP8':
|
|
73
|
+
return (0, result_1.success)(96);
|
|
74
|
+
case 'VP9':
|
|
75
|
+
return (0, result_1.success)(98);
|
|
76
|
+
case 'AV1':
|
|
77
|
+
return (0, result_1.success)(41);
|
|
78
|
+
case 'H264':
|
|
79
|
+
return (0, result_1.success)(102);
|
|
80
|
+
default:
|
|
81
|
+
return (0, result_1.failure)('invalid video codec');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
mimeType() {
|
|
85
|
+
switch (this.codec) {
|
|
86
|
+
case 'VP8':
|
|
87
|
+
return (0, result_1.success)('video/VP8');
|
|
88
|
+
case 'VP9':
|
|
89
|
+
return (0, result_1.success)('video/VP9');
|
|
90
|
+
case 'AV1':
|
|
91
|
+
return (0, result_1.success)('video/AV1');
|
|
92
|
+
case 'H264':
|
|
93
|
+
return (0, result_1.success)('video/H264');
|
|
94
|
+
default:
|
|
95
|
+
return (0, result_1.failure)('invalid video codec');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
sdpFmtpLine() {
|
|
99
|
+
switch (this.codec) {
|
|
100
|
+
case 'VP8':
|
|
101
|
+
return (0, result_1.success)('');
|
|
102
|
+
case 'VP9':
|
|
103
|
+
return (0, result_1.success)(
|
|
104
|
+
// using high-bit-depth variant profile
|
|
105
|
+
'profile-id=2');
|
|
106
|
+
case 'AV1':
|
|
107
|
+
return (0, result_1.success)(
|
|
108
|
+
// using baseline profile (https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters)
|
|
109
|
+
'level-idx=5;profile=0;tier=0');
|
|
110
|
+
case 'H264':
|
|
111
|
+
return (0, result_1.success)(
|
|
112
|
+
// using baseline profile
|
|
113
|
+
'level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f');
|
|
114
|
+
default:
|
|
115
|
+
return (0, result_1.failure)('invalid video codec');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.VideoCodec = VideoCodec;
|
package/lib/cjs/utility/log.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-dupe-class-members */
|
|
3
|
-
/* eslint-disable no-redeclare */
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
exports.LogHandler = exports.PRETTY_FORMATTER = exports.DEFAULT_FORMATTER = exports.Logger = exports.LogFunctions = exports.LogSymbols = exports.LogLevelNames = exports.LogLevels = exports.LogVerbosity = void 0;
|
|
6
4
|
exports.getLevelByName = getLevelByName;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-redeclare */
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.assert = assert;
|
|
5
4
|
exports.fail = fail;
|
|
6
5
|
exports.success = success;
|
|
7
6
|
exports.failure = failure;
|
|
8
7
|
exports.unwrap = unwrap;
|
|
8
|
+
exports.unwrapOr = unwrapOr;
|
|
9
9
|
function assert(condition, message) {
|
|
10
10
|
if (!condition) {
|
|
11
11
|
fail(message);
|
|
@@ -26,3 +26,6 @@ function unwrap(result) {
|
|
|
26
26
|
}
|
|
27
27
|
return result.value;
|
|
28
28
|
}
|
|
29
|
+
function unwrapOr(result, fallback) {
|
|
30
|
+
return result.type === 'Success' ? result.value : fallback;
|
|
31
|
+
}
|
package/lib/cjs/utility/sleep.js
CHANGED
package/lib/esm/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as zod_1 from 'zod';
|
|
2
|
+
export { zod_1 as zod };
|
|
1
3
|
export * from './schema/serialization';
|
|
2
4
|
export * from './schema/token';
|
|
3
5
|
export * from './schema/room';
|
|
@@ -9,6 +11,7 @@ export * from './rpc/commands';
|
|
|
9
11
|
export * from './rpc/notifications';
|
|
10
12
|
export * from './utility/base64';
|
|
11
13
|
export * from './utility/bytearray';
|
|
14
|
+
export * from './utility/codec';
|
|
12
15
|
export * from './utility/iterable';
|
|
13
16
|
export * from './utility/environment';
|
|
14
17
|
export * from './utility/json';
|
|
@@ -22,5 +25,3 @@ export * from './utility/uuid';
|
|
|
22
25
|
export * from './utility/validation';
|
|
23
26
|
export * from './utility/log';
|
|
24
27
|
export * from './plugin/api';
|
|
25
|
-
import * as zod_1 from 'zod';
|
|
26
|
-
export { zod_1 as zod };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.
|
|
1
|
+
{"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/codec.spec.ts","../../src/utility/codec.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.7.3"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { parse, write } from 'sdp-transform';
|
|
2
|
+
import { failure, success, unwrap, unwrapOr } from './result';
|
|
3
|
+
const validCodecs = ['VP8', 'VP9', 'AV1', 'H264'];
|
|
4
|
+
export class VideoCodec {
|
|
5
|
+
constructor(codec) {
|
|
6
|
+
this.codec = codec;
|
|
7
|
+
this.channels = 0;
|
|
8
|
+
this.clockRate = 90000;
|
|
9
|
+
}
|
|
10
|
+
valid() {
|
|
11
|
+
return validCodecs.includes(this.codec);
|
|
12
|
+
}
|
|
13
|
+
supported() {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
if (typeof RTCRtpReceiver === 'undefined' ||
|
|
16
|
+
typeof RTCRtpReceiver.getCapabilities === 'undefined') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const expectedMimeType = unwrapOr(this.mimeType(), '').toLowerCase();
|
|
20
|
+
const expectedFmtpLine = new Set(unwrapOr(this.sdpFmtpLine(), '')
|
|
21
|
+
.split(';')
|
|
22
|
+
.map((arg) => arg.trim().toLowerCase()));
|
|
23
|
+
return ((_c = (_b = (_a = RTCRtpReceiver.getCapabilities('video')) === null || _a === void 0 ? void 0 : _a.codecs) === null || _b === void 0 ? void 0 : _b.some((c) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const actualMimeType = c.mimeType.toLowerCase();
|
|
26
|
+
const actualFmtpLine = new Set(((_a = c.sdpFmtpLine) !== null && _a !== void 0 ? _a : '')
|
|
27
|
+
.split(';')
|
|
28
|
+
.map((arg) => arg.trim().toLowerCase()));
|
|
29
|
+
console.log(actualMimeType, actualFmtpLine);
|
|
30
|
+
if (expectedMimeType !== actualMimeType)
|
|
31
|
+
return false;
|
|
32
|
+
if (expectedFmtpLine.size !== actualFmtpLine.size)
|
|
33
|
+
return false;
|
|
34
|
+
for (let item of expectedFmtpLine) {
|
|
35
|
+
if (!actualFmtpLine.has(item))
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
})) !== null && _c !== void 0 ? _c : false);
|
|
40
|
+
}
|
|
41
|
+
filterSdp(description) {
|
|
42
|
+
if (!this.valid()) {
|
|
43
|
+
return description;
|
|
44
|
+
}
|
|
45
|
+
const sdp = parse(description);
|
|
46
|
+
const payload = unwrap(this.payloadType());
|
|
47
|
+
const config = unwrap(this.sdpFmtpLine());
|
|
48
|
+
sdp.media = sdp.media.map((media) => {
|
|
49
|
+
media.payloads = '';
|
|
50
|
+
media.rtp = [];
|
|
51
|
+
media.fmtp = [];
|
|
52
|
+
media.rtcpFb = [];
|
|
53
|
+
media.payloads = String(payload);
|
|
54
|
+
media.rtp.push({ payload, codec: this.codec, rate: this.clockRate });
|
|
55
|
+
if (this.sdpFmtpLine()) {
|
|
56
|
+
media.fmtp.push({ payload, config });
|
|
57
|
+
}
|
|
58
|
+
media.rtcpFb.push({ payload, type: 'goog-remb' });
|
|
59
|
+
media.rtcpFb.push({ payload, type: 'transport-cc' });
|
|
60
|
+
media.rtcpFb.push({ payload, type: 'ccm', subtype: 'fir' });
|
|
61
|
+
media.rtcpFb.push({ payload, type: 'nack' });
|
|
62
|
+
media.rtcpFb.push({ payload, type: 'nack', subtype: 'pli' });
|
|
63
|
+
return media;
|
|
64
|
+
});
|
|
65
|
+
return write(sdp);
|
|
66
|
+
}
|
|
67
|
+
payloadType() {
|
|
68
|
+
switch (this.codec) {
|
|
69
|
+
case 'VP8':
|
|
70
|
+
return success(96);
|
|
71
|
+
case 'VP9':
|
|
72
|
+
return success(98);
|
|
73
|
+
case 'AV1':
|
|
74
|
+
return success(41);
|
|
75
|
+
case 'H264':
|
|
76
|
+
return success(102);
|
|
77
|
+
default:
|
|
78
|
+
return failure('invalid video codec');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
mimeType() {
|
|
82
|
+
switch (this.codec) {
|
|
83
|
+
case 'VP8':
|
|
84
|
+
return success('video/VP8');
|
|
85
|
+
case 'VP9':
|
|
86
|
+
return success('video/VP9');
|
|
87
|
+
case 'AV1':
|
|
88
|
+
return success('video/AV1');
|
|
89
|
+
case 'H264':
|
|
90
|
+
return success('video/H264');
|
|
91
|
+
default:
|
|
92
|
+
return failure('invalid video codec');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
sdpFmtpLine() {
|
|
96
|
+
switch (this.codec) {
|
|
97
|
+
case 'VP8':
|
|
98
|
+
return success('');
|
|
99
|
+
case 'VP9':
|
|
100
|
+
return success(
|
|
101
|
+
// using high-bit-depth variant profile
|
|
102
|
+
'profile-id=2');
|
|
103
|
+
case 'AV1':
|
|
104
|
+
return success(
|
|
105
|
+
// using baseline profile (https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters)
|
|
106
|
+
'level-idx=5;profile=0;tier=0');
|
|
107
|
+
case 'H264':
|
|
108
|
+
return success(
|
|
109
|
+
// using baseline profile
|
|
110
|
+
'level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f');
|
|
111
|
+
default:
|
|
112
|
+
return failure('invalid video codec');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
package/lib/esm/utility/log.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-redeclare */
|
|
2
1
|
export function assert(condition, message) {
|
|
3
2
|
if (!condition) {
|
|
4
3
|
fail(message);
|
|
@@ -19,3 +18,6 @@ export function unwrap(result) {
|
|
|
19
18
|
}
|
|
20
19
|
return result.value;
|
|
21
20
|
}
|
|
21
|
+
export function unwrapOr(result, fallback) {
|
|
22
|
+
return result.type === 'Success' ? result.value : fallback;
|
|
23
|
+
}
|
package/lib/esm/utility/sleep.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * as zod from 'zod';
|
|
1
2
|
export * from './schema/serialization';
|
|
2
3
|
export * from './schema/token';
|
|
3
4
|
export * from './schema/room';
|
|
@@ -9,6 +10,7 @@ export * from './rpc/commands';
|
|
|
9
10
|
export * from './rpc/notifications';
|
|
10
11
|
export * from './utility/base64';
|
|
11
12
|
export * from './utility/bytearray';
|
|
13
|
+
export * from './utility/codec';
|
|
12
14
|
export * from './utility/iterable';
|
|
13
15
|
export * from './utility/environment';
|
|
14
16
|
export * from './utility/json';
|
|
@@ -22,4 +24,3 @@ export * from './utility/uuid';
|
|
|
22
24
|
export * from './utility/validation';
|
|
23
25
|
export * from './utility/log';
|
|
24
26
|
export * from './plugin/api';
|
|
25
|
-
export * as zod from 'zod';
|
package/lib/rpc/commands.d.ts
CHANGED
|
@@ -19,15 +19,15 @@ export declare const MainCommandsRpc: {
|
|
|
19
19
|
request: z.ZodObject<{
|
|
20
20
|
token: z.ZodString;
|
|
21
21
|
room_id: z.ZodString;
|
|
22
|
-
user_data: z.ZodType<Uint8Array
|
|
22
|
+
user_data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
23
23
|
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
24
24
|
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
user_data: Uint8Array
|
|
25
|
+
user_data: Uint8Array<ArrayBufferLike>;
|
|
26
26
|
token: string;
|
|
27
27
|
room_id: string;
|
|
28
28
|
position: [number, number, number] | [number, number];
|
|
29
29
|
}, {
|
|
30
|
-
user_data: Uint8Array
|
|
30
|
+
user_data: Uint8Array<ArrayBufferLike>;
|
|
31
31
|
token: string;
|
|
32
32
|
room_id: string;
|
|
33
33
|
position: [number, number, number] | [number, number];
|
|
@@ -111,16 +111,16 @@ export declare const RoomCommandsRpc: {
|
|
|
111
111
|
stream: z.ZodLiteral<"room">;
|
|
112
112
|
token: z.ZodString;
|
|
113
113
|
room_id: z.ZodString;
|
|
114
|
-
user_data: z.ZodType<Uint8Array
|
|
114
|
+
user_data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
115
115
|
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
116
116
|
}, "strip", z.ZodTypeAny, {
|
|
117
|
-
user_data: Uint8Array
|
|
117
|
+
user_data: Uint8Array<ArrayBufferLike>;
|
|
118
118
|
stream: "room";
|
|
119
119
|
token: string;
|
|
120
120
|
room_id: string;
|
|
121
121
|
position: [number, number, number] | [number, number];
|
|
122
122
|
}, {
|
|
123
|
-
user_data: Uint8Array
|
|
123
|
+
user_data: Uint8Array<ArrayBufferLike>;
|
|
124
124
|
stream: "room";
|
|
125
125
|
token: string;
|
|
126
126
|
room_id: string;
|
|
@@ -130,11 +130,11 @@ export declare const RoomCommandsRpc: {
|
|
|
130
130
|
};
|
|
131
131
|
UpdatePeer: {
|
|
132
132
|
request: z.ZodObject<{
|
|
133
|
-
user_data: z.ZodType<Uint8Array
|
|
133
|
+
user_data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
134
134
|
}, "strip", z.ZodTypeAny, {
|
|
135
|
-
user_data: Uint8Array
|
|
135
|
+
user_data: Uint8Array<ArrayBufferLike>;
|
|
136
136
|
}, {
|
|
137
|
-
user_data: Uint8Array
|
|
137
|
+
user_data: Uint8Array<ArrayBufferLike>;
|
|
138
138
|
}>;
|
|
139
139
|
response: z.ZodNull;
|
|
140
140
|
};
|
|
@@ -239,12 +239,12 @@ export declare const RoomCommandsRpc: {
|
|
|
239
239
|
SendMessage: {
|
|
240
240
|
request: z.ZodObject<{
|
|
241
241
|
target_peer_ids: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
242
|
-
message: z.ZodType<Uint8Array
|
|
242
|
+
message: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
243
243
|
}, "strip", z.ZodTypeAny, {
|
|
244
|
-
message: Uint8Array
|
|
244
|
+
message: Uint8Array<ArrayBufferLike>;
|
|
245
245
|
target_peer_ids?: number[] | undefined;
|
|
246
246
|
}, {
|
|
247
|
-
message: Uint8Array
|
|
247
|
+
message: Uint8Array<ArrayBufferLike>;
|
|
248
248
|
target_peer_ids?: number[] | undefined;
|
|
249
249
|
}>;
|
|
250
250
|
response: z.ZodNull;
|