werift 0.18.3 → 0.18.5
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/lib/dtls/src/flight/server/flight2.js +1 -1
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/rtp/src/container/ebml/ebml.d.ts +5 -6
- package/lib/rtp/src/container/ebml/ebml.js +14 -13
- package/lib/rtp/src/container/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/container/ebml/typedArrayUtils.d.ts +3 -4
- package/lib/rtp/src/container/ebml/typedArrayUtils.js +9 -10
- package/lib/rtp/src/container/ebml/typedArrayUtils.js.map +1 -1
- package/lib/rtp/src/container/index.d.ts +2 -0
- package/lib/rtp/src/{processor/source → container}/index.js +2 -3
- package/lib/rtp/src/container/index.js.map +1 -0
- package/lib/rtp/src/helper.d.ts +4 -0
- package/lib/rtp/src/helper.js +14 -1
- package/lib/rtp/src/helper.js.map +1 -1
- package/lib/rtp/src/index.d.ts +2 -0
- package/lib/rtp/src/index.js +2 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/processor/depacketizer.d.ts +1 -1
- package/lib/rtp/src/processor/depacketizer.js +16 -9
- package/lib/rtp/src/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/processor/depacketizerCallback.d.ts +14 -6
- package/lib/rtp/src/processor/depacketizerCallback.js +2 -35
- package/lib/rtp/src/processor/depacketizerCallback.js.map +1 -1
- package/lib/rtp/src/processor/dtx.d.ts +1 -0
- package/lib/rtp/src/processor/dtx.js +10 -1
- package/lib/rtp/src/processor/dtx.js.map +1 -1
- package/lib/rtp/src/processor/dtxCallback.d.ts +14 -5
- package/lib/rtp/src/processor/dtxCallback.js +2 -35
- package/lib/rtp/src/processor/dtxCallback.js.map +1 -1
- package/lib/rtp/src/processor/index.d.ts +3 -1
- package/lib/rtp/src/processor/index.js +3 -1
- package/lib/rtp/src/processor/index.js.map +1 -1
- package/lib/rtp/src/processor/interface.d.ts +17 -0
- package/lib/rtp/src/processor/interface.js +57 -0
- package/lib/rtp/src/processor/interface.js.map +1 -1
- package/lib/rtp/src/processor/jitterBuffer.d.ts +1 -2
- package/lib/rtp/src/processor/jitterBuffer.js +3 -1
- package/lib/rtp/src/processor/jitterBuffer.js.map +1 -1
- package/lib/rtp/src/processor/jitterBufferCallback.d.ts +14 -5
- package/lib/rtp/src/processor/jitterBufferCallback.js +2 -35
- package/lib/rtp/src/processor/jitterBufferCallback.js.map +1 -1
- package/lib/rtp/src/processor/jitterBufferTransformer.d.ts +1 -1
- package/lib/rtp/src/processor/lipsync.d.ts +19 -8
- package/lib/rtp/src/processor/lipsync.js +131 -83
- package/lib/rtp/src/processor/lipsync.js.map +1 -1
- package/lib/rtp/src/processor/lipsyncCallback.d.ts +8 -5
- package/lib/rtp/src/processor/lipsyncCallback.js +39 -4
- package/lib/rtp/src/processor/lipsyncCallback.js.map +1 -1
- package/lib/rtp/src/processor/mute.d.ts +17 -4
- package/lib/rtp/src/processor/mute.js +121 -40
- package/lib/rtp/src/processor/mute.js.map +1 -1
- package/lib/rtp/src/processor/muteCallback.d.ts +5 -2
- package/lib/rtp/src/processor/muteCallback.js +23 -7
- package/lib/rtp/src/processor/muteCallback.js.map +1 -1
- package/lib/rtp/src/processor/nack.d.ts +6 -6
- package/lib/rtp/src/processor/nack.js +23 -17
- package/lib/rtp/src/processor/nack.js.map +1 -1
- package/lib/rtp/src/processor/nackHandlerCallback.d.ts +14 -7
- package/lib/rtp/src/processor/nackHandlerCallback.js +2 -29
- package/lib/rtp/src/processor/nackHandlerCallback.js.map +1 -1
- package/lib/rtp/src/processor/ntpTime.d.ts +7 -7
- package/lib/rtp/src/processor/ntpTime.js +27 -29
- package/lib/rtp/src/processor/ntpTime.js.map +1 -1
- package/lib/rtp/src/processor/ntpTimeCallback.d.ts +13 -4
- package/lib/rtp/src/processor/ntpTimeCallback.js +2 -29
- package/lib/rtp/src/processor/ntpTimeCallback.js.map +1 -1
- package/lib/rtp/src/processor/rtcpCallback.d.ts +18 -0
- package/lib/rtp/src/processor/{source/rtcpCallback.js → rtcpCallback.js} +25 -3
- package/lib/rtp/src/processor/rtcpCallback.js.map +1 -0
- package/lib/rtp/src/processor/rtpCallback.d.ts +28 -0
- package/lib/rtp/src/processor/rtpCallback.js +127 -0
- package/lib/rtp/src/processor/rtpCallback.js.map +1 -0
- package/lib/rtp/src/processor/{source/rtpStream.d.ts → rtpStream.d.ts} +1 -1
- package/lib/rtp/src/processor/{source/rtpStream.js → rtpStream.js} +4 -2
- package/lib/rtp/src/processor/rtpStream.js.map +1 -0
- package/lib/rtp/src/processor/rtpTimeCallback.d.ts +13 -5
- package/lib/rtp/src/processor/rtpTimeCallback.js +2 -29
- package/lib/rtp/src/processor/rtpTimeCallback.js.map +1 -1
- package/lib/rtp/src/processor/webm.d.ts +8 -4
- package/lib/rtp/src/processor/webm.js +41 -8
- package/lib/rtp/src/processor/webm.js.map +1 -1
- package/lib/rtp/src/processor/webmCallback.d.ts +6 -5
- package/lib/rtp/src/processor/webmCallback.js +21 -7
- package/lib/rtp/src/processor/webmCallback.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.js +1 -2
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.d.ts +32 -23
- package/lib/webrtc/src/nonstandard/userMedia.js +49 -131
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/package.json +1 -1
- package/src/media/rtpSender.ts +1 -1
- package/src/nonstandard/userMedia.ts +69 -75
- package/lib/rtp/src/processor/source/index.d.ts +0 -3
- package/lib/rtp/src/processor/source/index.js.map +0 -1
- package/lib/rtp/src/processor/source/rtcpCallback.d.ts +0 -13
- package/lib/rtp/src/processor/source/rtcpCallback.js.map +0 -1
- package/lib/rtp/src/processor/source/rtpCallback.d.ts +0 -19
- package/lib/rtp/src/processor/source/rtpCallback.js +0 -62
- package/lib/rtp/src/processor/source/rtpCallback.js.map +0 -1
- package/lib/rtp/src/processor/source/rtpStream.js.map +0 -1
|
@@ -34,9 +34,15 @@ class DtxBase {
|
|
|
34
34
|
writable: true,
|
|
35
35
|
value: 0
|
|
36
36
|
});
|
|
37
|
+
Object.defineProperty(this, "internalStats", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: {}
|
|
42
|
+
});
|
|
37
43
|
}
|
|
38
44
|
toJSON() {
|
|
39
|
-
return { id: this.id, fillCount: this.fillCount };
|
|
45
|
+
return { ...this.internalStats, id: this.id, fillCount: this.fillCount };
|
|
40
46
|
}
|
|
41
47
|
processInput({ frame, eol }) {
|
|
42
48
|
if (eol) {
|
|
@@ -46,6 +52,7 @@ class DtxBase {
|
|
|
46
52
|
if (frame) {
|
|
47
53
|
if (!this.previousTimestamp) {
|
|
48
54
|
this.previousTimestamp = frame.time;
|
|
55
|
+
this.internalStats["dtx"] = new Date().toISOString();
|
|
49
56
|
return [{ frame }];
|
|
50
57
|
}
|
|
51
58
|
if (frame.time != this.previousTimestamp + this.ptime) {
|
|
@@ -61,10 +68,12 @@ class DtxBase {
|
|
|
61
68
|
this.fillCount++;
|
|
62
69
|
}
|
|
63
70
|
this.previousTimestamp = frame.time;
|
|
71
|
+
this.internalStats["dtx"] = new Date().toISOString();
|
|
64
72
|
return [...dummyPackets, { frame }];
|
|
65
73
|
}
|
|
66
74
|
else {
|
|
67
75
|
this.previousTimestamp = frame.time;
|
|
76
|
+
this.internalStats["dtx"] = new Date().toISOString();
|
|
68
77
|
return [{ frame }];
|
|
69
78
|
}
|
|
70
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dtx.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/dtx.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AASpC,MAAa,OAAO;
|
|
1
|
+
{"version":3,"file":"dtx.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/dtx.ts"],"names":[],"mappings":";;;AAAA,mC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AC;oBACH,IAAI,CAAC,SAAS,EAAE,CAAC;iBAClB;gBAED,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC;gBACpC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;gBACrD,OAAO,CAAC,GAAG,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;aACrC;iBAAM;gBACL,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC;gBACpC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;gBACrD,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;aACpB;SACF;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,WAAW,GAAG,SAAgB,CAAC;IACtC,CAAC;CACF;AAzDD,0BAyDC","sourcesContent":["import { randomUUID } from \"crypto\";\n\nimport { CodecFrame, DepacketizerOutput } from \"./depacketizer\";\nimport { Processor } from \"./interface\";\n\nexport type DtxInput = DepacketizerOutput;\n\nexport type DtxOutput = DtxInput;\n\nexport class DtxBase implements Processor<DtxInput, DtxOutput> {\n readonly id = randomUUID();\n previousTimestamp?: number;\n private fillCount = 0;\n private internalStats = {};\n constructor(public ptime: number, private dummyPacket: Buffer) {}\n\n toJSON(): Record<string, any> {\n return { ...this.internalStats, id: this.id, fillCount: this.fillCount };\n }\n\n processInput({ frame, eol }: DtxInput): DtxOutput[] {\n if (eol) {\n this.stop();\n return [{ eol: true }];\n }\n\n if (frame) {\n if (!this.previousTimestamp) {\n this.previousTimestamp = frame.time;\n this.internalStats[\"dtx\"] = new Date().toISOString();\n return [{ frame }];\n }\n\n if (frame.time != this.previousTimestamp + this.ptime) {\n const dummyPackets: { frame: CodecFrame }[] = [];\n for (\n let time = this.previousTimestamp;\n time < frame.time;\n time += this.ptime\n ) {\n dummyPackets.push({\n frame: {\n time,\n isKeyframe: frame.isKeyframe,\n data: this.dummyPacket,\n },\n });\n this.fillCount++;\n }\n\n this.previousTimestamp = frame.time;\n this.internalStats[\"dtx\"] = new Date().toISOString();\n return [...dummyPackets, { frame }];\n } else {\n this.previousTimestamp = frame.time;\n this.internalStats[\"dtx\"] = new Date().toISOString();\n return [{ frame }];\n }\n }\n\n return [];\n }\n\n private stop() {\n this.dummyPacket = undefined as any;\n }\n}\n"]}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { DtxBase
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { DtxBase } from "./dtx";
|
|
2
|
+
declare const DtxCallback_base: {
|
|
3
|
+
new (...args: any[]): {
|
|
4
|
+
cb?: ((o: import("./depacketizer").DepacketizerOutput) => void) | undefined;
|
|
5
|
+
destructor?: (() => void) | undefined;
|
|
6
|
+
pipe: (cb: (o: import("./depacketizer").DepacketizerOutput) => void, destructor?: (() => void) | undefined) => any;
|
|
7
|
+
input: (input: import("./depacketizer").DepacketizerOutput) => void;
|
|
8
|
+
destroy: () => void;
|
|
9
|
+
processInput: (input: import("./depacketizer").DepacketizerOutput) => import("./depacketizer").DepacketizerOutput[];
|
|
10
|
+
toJSON(): Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
} & typeof DtxBase;
|
|
13
|
+
export declare class DtxCallback extends DtxCallback_base {
|
|
6
14
|
}
|
|
15
|
+
export {};
|
|
@@ -2,41 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DtxCallback = void 0;
|
|
4
4
|
const dtx_1 = require("./dtx");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
super(...arguments);
|
|
8
|
-
Object.defineProperty(this, "cb", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "pipe", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: (cb) => {
|
|
19
|
-
this.cb = cb;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(this, "input", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: (input) => {
|
|
28
|
-
if (!this.cb) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
for (const output of this.processInput(input)) {
|
|
32
|
-
this.cb(output);
|
|
33
|
-
}
|
|
34
|
-
if (input.eol) {
|
|
35
|
-
this.cb = undefined;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
5
|
+
const interface_1 = require("./interface");
|
|
6
|
+
class DtxCallback extends (0, interface_1.SimpleProcessorCallbackBase)(dtx_1.DtxBase) {
|
|
40
7
|
}
|
|
41
8
|
exports.DtxCallback = DtxCallback;
|
|
42
9
|
//# sourceMappingURL=dtxCallback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dtxCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/dtxCallback.ts"],"names":[],"mappings":";;;AAAA,+BAAqD;
|
|
1
|
+
{"version":3,"file":"dtxCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/dtxCallback.ts"],"names":[],"mappings":";;;AAAA,+BAAqD;AACrD,2CAA0D;AAE1D,MAAa,WAAY,SAAQ,IAAA,uCAA2B,EAI1D,aAAO,CAAC;CAAG;AAJb,kCAIa","sourcesContent":["import { DtxBase, DtxInput, DtxOutput } from \"./dtx\";\nimport { SimpleProcessorCallbackBase } from \"./interface\";\n\nexport class DtxCallback extends SimpleProcessorCallbackBase<\n DtxInput,\n DtxOutput,\n typeof DtxBase\n>(DtxBase) {}\n"]}
|
|
@@ -15,9 +15,11 @@ export * from "./nack";
|
|
|
15
15
|
export * from "./nackHandlerCallback";
|
|
16
16
|
export * from "./ntpTime";
|
|
17
17
|
export * from "./ntpTimeCallback";
|
|
18
|
+
export * from "./rtcpCallback";
|
|
19
|
+
export * from "./rtpCallback";
|
|
20
|
+
export * from "./rtpStream";
|
|
18
21
|
export * from "./rtpTime";
|
|
19
22
|
export * from "./rtpTimeCallback";
|
|
20
|
-
export * from "./source";
|
|
21
23
|
export * from "./webm";
|
|
22
24
|
export * from "./webmCallback";
|
|
23
25
|
export * from "./webmStream";
|
|
@@ -31,9 +31,11 @@ __exportStar(require("./nack"), exports);
|
|
|
31
31
|
__exportStar(require("./nackHandlerCallback"), exports);
|
|
32
32
|
__exportStar(require("./ntpTime"), exports);
|
|
33
33
|
__exportStar(require("./ntpTimeCallback"), exports);
|
|
34
|
+
__exportStar(require("./rtcpCallback"), exports);
|
|
35
|
+
__exportStar(require("./rtpCallback"), exports);
|
|
36
|
+
__exportStar(require("./rtpStream"), exports);
|
|
34
37
|
__exportStar(require("./rtpTime"), exports);
|
|
35
38
|
__exportStar(require("./rtpTimeCallback"), exports);
|
|
36
|
-
__exportStar(require("./source"), exports);
|
|
37
39
|
__exportStar(require("./webm"), exports);
|
|
38
40
|
__exportStar(require("./webmCallback"), exports);
|
|
39
41
|
__exportStar(require("./webmStream"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,yDAAuC;AACvC,4DAA0C;AAC1C,wCAAsB;AACtB,gDAA8B;AAC9B,8CAA4B;AAC5B,iDAA+B;AAC/B,yDAAuC;AACvC,4DAA0C;AAC1C,4CAA0B;AAC1B,oDAAkC;AAClC,yCAAuB;AACvB,iDAA+B;AAC/B,yCAAuB;AACvB,wDAAsC;AACtC,4CAA0B;AAC1B,oDAAkC;AAClC,4CAA0B;AAC1B,oDAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,yDAAuC;AACvC,4DAA0C;AAC1C,wCAAsB;AACtB,gDAA8B;AAC9B,8CAA4B;AAC5B,iDAA+B;AAC/B,yDAAuC;AACvC,4DAA0C;AAC1C,4CAA0B;AAC1B,oDAAkC;AAClC,yCAAuB;AACvB,iDAA+B;AAC/B,yCAAuB;AACvB,wDAAsC;AACtC,4CAA0B;AAC1B,oDAAkC;AAClC,iDAA+B;AAC/B,gDAA8B;AAC9B,8CAA4B;AAC5B,4CAA0B;AAC1B,oDAAkC;AAClC,yCAAuB;AACvB,iDAA+B;AAC/B,+CAA6B","sourcesContent":["export * from \"./depacketizer\";\nexport * from \"./depacketizerCallback\";\nexport * from \"./depacketizerTransformer\";\nexport * from \"./dtx\";\nexport * from \"./dtxCallback\";\nexport * from \"./interface\";\nexport * from \"./jitterBuffer\";\nexport * from \"./jitterBufferCallback\";\nexport * from \"./jitterBufferTransformer\";\nexport * from \"./lipsync\";\nexport * from \"./lipsyncCallback\";\nexport * from \"./mute\";\nexport * from \"./muteCallback\";\nexport * from \"./nack\";\nexport * from \"./nackHandlerCallback\";\nexport * from \"./ntpTime\";\nexport * from \"./ntpTimeCallback\";\nexport * from \"./rtcpCallback\";\nexport * from \"./rtpCallback\";\nexport * from \"./rtpStream\";\nexport * from \"./rtpTime\";\nexport * from \"./rtpTimeCallback\";\nexport * from \"./webm\";\nexport * from \"./webmCallback\";\nexport * from \"./webmStream\";\n"]}
|
|
@@ -7,3 +7,20 @@ export interface AVProcessor<Input> {
|
|
|
7
7
|
processVideoInput: (input: Input) => void;
|
|
8
8
|
toJSON(): Record<string, any>;
|
|
9
9
|
}
|
|
10
|
+
export interface SimpleProcessorCallback<Input = any, Output = any> {
|
|
11
|
+
pipe: (cb: (o: Output) => void, destructor?: () => void) => SimpleProcessorCallback<Input, Output>;
|
|
12
|
+
input: (input: Input) => void;
|
|
13
|
+
destroy: () => void;
|
|
14
|
+
toJSON(): Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
export declare const SimpleProcessorCallbackBase: <Input, Output, TBase extends new (...args: any[]) => Processor<Input, Output>>(Base: TBase) => {
|
|
17
|
+
new (...args: any[]): {
|
|
18
|
+
cb?: ((o: Output) => void) | undefined;
|
|
19
|
+
destructor?: (() => void) | undefined;
|
|
20
|
+
pipe: (cb: (o: Output) => void, destructor?: () => void) => any;
|
|
21
|
+
input: (input: Input) => void;
|
|
22
|
+
destroy: () => void;
|
|
23
|
+
processInput: (input: Input) => Output[];
|
|
24
|
+
toJSON(): Record<string, any>;
|
|
25
|
+
};
|
|
26
|
+
} & TBase;
|
|
@@ -1,3 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleProcessorCallbackBase = void 0;
|
|
4
|
+
const SimpleProcessorCallbackBase = (Base) => {
|
|
5
|
+
return class extends Base {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
Object.defineProperty(this, "cb", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "destructor", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: void 0
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "pipe", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: (cb, destructor) => {
|
|
25
|
+
this.cb = cb;
|
|
26
|
+
this.destructor = destructor;
|
|
27
|
+
cb = undefined;
|
|
28
|
+
destructor = undefined;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "input", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: (input) => {
|
|
37
|
+
for (const output of this.processInput(input)) {
|
|
38
|
+
if (this.cb) {
|
|
39
|
+
this.cb(output);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "destroy", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: () => {
|
|
49
|
+
if (this.destructor) {
|
|
50
|
+
this.destructor();
|
|
51
|
+
this.destructor = undefined;
|
|
52
|
+
}
|
|
53
|
+
this.cb = undefined;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.SimpleProcessorCallbackBase = SimpleProcessorCallbackBase;
|
|
3
60
|
//# sourceMappingURL=interface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/interface.ts"],"names":[],"mappings":"","sourcesContent":["export interface Processor<Input, Output> {\n processInput: (input: Input) => Output[];\n toJSON(): Record<string, any>;\n}\n\nexport interface AVProcessor<Input> {\n processAudioInput: (input: Input) => void;\n processVideoInput: (input: Input) => void;\n toJSON(): Record<string, any>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/interface.ts"],"names":[],"mappings":";;;AAqBO,MAAM,2BAA2B,GAAG,CAKzC,IAAW,EACX,EAAE;IACF,OAAO,KAAM,SAAQ,IAAI;QAAlB;;YACL;;;;;eAAyB;YACzB;;;;;eAAwB;YAExB;;;;uBAAO,CAAC,EAAuB,EAAE,UAAuB,EAAE,EAAE;oBAC1D,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;oBACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;oBAC7B,EAAE,GAAG,SAAgB,CAAC;oBACtB,UAAU,GAAG,SAAS,CAAC;oBACvB,OAAO,IAAI,CAAC;gBACd,CAAC;eAAC;YAEF;;;;uBAAQ,CAAC,KAAY,EAAE,EAAE;oBACvB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;wBAC7C,IAAI,IAAI,CAAC,EAAE,EAAE;4BACX,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;yBACjB;qBACF;gBACH,CAAC;eAAC;YAEF;;;;uBAAU,GAAG,EAAE;oBACb,IAAI,IAAI,CAAC,UAAU,EAAE;wBACnB,IAAI,CAAC,UAAU,EAAE,CAAC;wBAClB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;qBAC7B;oBACD,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;gBACtB,CAAC;eAAC;QACJ,CAAC;KAAA,CAAC;AACJ,CAAC,CAAC;AAnCW,QAAA,2BAA2B,+BAmCtC","sourcesContent":["export interface Processor<Input, Output> {\n processInput: (input: Input) => Output[];\n toJSON(): Record<string, any>;\n}\n\nexport interface AVProcessor<Input> {\n processAudioInput: (input: Input) => void;\n processVideoInput: (input: Input) => void;\n toJSON(): Record<string, any>;\n}\n\nexport interface SimpleProcessorCallback<Input = any, Output = any> {\n pipe: (\n cb: (o: Output) => void,\n destructor?: () => void\n ) => SimpleProcessorCallback<Input, Output>;\n input: (input: Input) => void;\n destroy: () => void;\n toJSON(): Record<string, any>;\n}\n\nexport const SimpleProcessorCallbackBase = <\n Input,\n Output,\n TBase extends new (...args: any[]) => Processor<Input, Output>\n>(\n Base: TBase\n) => {\n return class extends Base implements SimpleProcessorCallback<Input, Output> {\n cb?: (o: Output) => void;\n destructor?: () => void;\n\n pipe = (cb: (o: Output) => void, destructor?: () => void) => {\n this.cb = cb;\n this.destructor = destructor;\n cb = undefined as any;\n destructor = undefined;\n return this;\n };\n\n input = (input: Input) => {\n for (const output of this.processInput(input)) {\n if (this.cb) {\n this.cb(output);\n }\n }\n };\n\n destroy = () => {\n if (this.destructor) {\n this.destructor();\n this.destructor = undefined;\n }\n this.cb = undefined;\n };\n };\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Processor } from "./interface";
|
|
2
|
-
import { RtpOutput } from "./
|
|
2
|
+
import { RtpOutput } from "./rtpCallback";
|
|
3
3
|
export type JitterBufferInput = RtpOutput;
|
|
4
4
|
export interface JitterBufferOutput extends RtpOutput {
|
|
5
5
|
isPacketLost?: {
|
|
@@ -20,7 +20,6 @@ export declare class JitterBufferBase implements Processor<JitterBufferInput, Ji
|
|
|
20
20
|
rtpBufferLength: number;
|
|
21
21
|
presentSeqNum: number | undefined;
|
|
22
22
|
expectNextSeqNum: number;
|
|
23
|
-
stats: {};
|
|
24
23
|
};
|
|
25
24
|
private stop;
|
|
26
25
|
processInput(input: JitterBufferInput): JitterBufferOutput[];
|
|
@@ -45,10 +45,10 @@ class JitterBufferBase {
|
|
|
45
45
|
}
|
|
46
46
|
toJSON() {
|
|
47
47
|
return {
|
|
48
|
+
...this.internalStats,
|
|
48
49
|
rtpBufferLength: Object.values(this.rtpBuffer).length,
|
|
49
50
|
presentSeqNum: this.presentSeqNum,
|
|
50
51
|
expectNextSeqNum: this.expectNextSeqNum,
|
|
51
|
-
stats: this.internalStats,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
stop() {
|
|
@@ -80,6 +80,7 @@ class JitterBufferBase {
|
|
|
80
80
|
output.push({ rtp });
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
this.internalStats["jitterBuffer"] = new Date().toISOString();
|
|
83
84
|
return output;
|
|
84
85
|
}
|
|
85
86
|
else {
|
|
@@ -87,6 +88,7 @@ class JitterBufferBase {
|
|
|
87
88
|
for (const rtp of packets) {
|
|
88
89
|
output.push({ rtp });
|
|
89
90
|
}
|
|
91
|
+
this.internalStats["jitterBuffer"] = new Date().toISOString();
|
|
90
92
|
return output;
|
|
91
93
|
}
|
|
92
94
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jitterBuffer.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/jitterBuffer.ts"],"names":[],"mappings":";;;AAAA,0BAOY;AAUZ,MAAa,gBAAgB;IAO3B,IAAY,gBAAgB;QAC1B,OAAO,IAAA,aAAS,EAAC,IAAI,CAAC,aAAc,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAGD,YACS,SAAiB,EACxB,UAAwC,EAAE;;;;;mBADnC;;QAVT;;;;;WAAqC;QACrC,YAAY;QACZ;;;;;WAA+B;QAC/B;;;;mBAA6D,EAAE;WAAC;QAIhE;;;;mBAAwB,EAAE;WAAC;QAMzB,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,GAAG;YAC/B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,KAAK;SACxC,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO;YACL,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM;YACrD,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,KAAK,EAAE,IAAI,CAAC,aAAa;SAC1B,CAAC;IACJ,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,YAAY,CAAC,KAAwB;QACnC,MAAM,MAAM,GAAyB,EAAE,CAAC;QAExC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YACd,IAAI,KAAK,CAAC,GAAG,EAAE;gBACb,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACxD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;oBACzB,MAAM,CAAC,IAAI,CAAC,EAAE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AC;gBAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;gBACtC,OAAO,MAAM,CAAC;aACf;QACH,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,CAAC,EAAa,EAAE,CAAC,CAAc,CAAC;aACzC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAEpB,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CACpC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC;YACrC,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CACP,CAAC;QAEF,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,CAAC;IACzC,CAAC;CACF;AA9ND,4CA8NC","sourcesContent":["import {\n RequireAtLeastOne,\n RtpPacket,\n uint16Add,\n uint16Gte,\n uint32Add,\n uint32Gt,\n} from \"..\";\nimport { Processor } from \"./interface\";\nimport { RtpOutput } from \"./source\";\n\nexport type JitterBufferInput = RtpOutput;\n\nexport interface JitterBufferOutput extends RtpOutput {\n isPacketLost?: { from: number; to: number };\n}\n\nexport class JitterBufferBase\n implements Processor<JitterBufferInput, JitterBufferOutput>\n{\n private options: JitterBufferOptions;\n /**uint16 */\n private presentSeqNum?: number;\n private rtpBuffer: { [sequenceNumber: number]: RtpPacket } = {};\n private get expectNextSeqNum() {\n return uint16Add(this.presentSeqNum!, 1);\n }\n private internalStats = {};\n\n constructor(\n public clockRate: number,\n options: Partial<JitterBufferOptions> = {}\n ) {\n this.options = {\n latency: options.latency ?? 200,\n bufferSize: options.bufferSize ?? 10000,\n };\n }\n\n toJSON() {\n return {\n rtpBufferLength: Object.values(this.rtpBuffer).length,\n presentSeqNum: this.presentSeqNum,\n expectNextSeqNum: this.expectNextSeqNum,\n stats: this.internalStats,\n };\n }\n\n private stop() {\n this.rtpBuffer = {};\n }\n\n processInput(input: JitterBufferInput): JitterBufferOutput[] {\n const output: JitterBufferOutput[] = [];\n\n if (!input.rtp) {\n if (input.eol) {\n const packets = this.sortAndClearBuffer(this.rtpBuffer);\n for (const rtp of packets) {\n output.push({ rtp });\n }\n output.push({ eol: true });\n\n this.stop();\n }\n return output;\n }\n\n const { packets, timeoutSeqNum } = this.processRtp(input.rtp);\n\n if (timeoutSeqNum != undefined) {\n const isPacketLost = {\n from: this.expectNextSeqNum,\n to: timeoutSeqNum,\n };\n this.presentSeqNum = input.rtp.header.sequenceNumber;\n output.push({ isPacketLost });\n if (packets) {\n for (const rtp of [...packets, input.rtp]) {\n output.push({ rtp });\n }\n }\n return output;\n } else {\n if (packets) {\n for (const rtp of packets) {\n output.push({ rtp });\n }\n return output;\n }\n return [];\n }\n }\n\n private processRtp(rtp: RtpPacket): RequireAtLeastOne<{\n packets: RtpPacket[];\n timeoutSeqNum: number;\n nothing: undefined;\n }> {\n const { sequenceNumber, timestamp } = rtp.header;\n\n // init\n if (this.presentSeqNum == undefined) {\n this.presentSeqNum = sequenceNumber;\n return { packets: [rtp] };\n }\n\n // duplicate\n if (uint16Gte(this.presentSeqNum, sequenceNumber)) {\n this.internalStats[\"duplicate\"] = {\n count: (this.internalStats[\"duplicate\"]?.count ?? 0) + 1,\n sequenceNumber,\n timestamp: new Date().toISOString(),\n };\n return { nothing: undefined };\n }\n\n // expect\n if (sequenceNumber === this.expectNextSeqNum) {\n this.presentSeqNum = sequenceNumber;\n\n const rtpBuffer = this.resolveBuffer(uint16Add(sequenceNumber, 1));\n this.presentSeqNum =\n rtpBuffer.at(-1)?.header.sequenceNumber ?? this.presentSeqNum;\n\n this.disposeTimeoutPackets(timestamp);\n\n return { packets: [rtp, ...rtpBuffer] };\n }\n\n this.pushRtpBuffer(rtp);\n\n const { latestTimeoutSeqNum, sorted } =\n this.disposeTimeoutPackets(timestamp);\n\n if (latestTimeoutSeqNum) {\n return { timeoutSeqNum: latestTimeoutSeqNum, packets: sorted };\n } else {\n return { nothing: undefined };\n }\n }\n\n private pushRtpBuffer(rtp: RtpPacket) {\n if (Object.values(this.rtpBuffer).length > this.options.bufferSize) {\n this.internalStats[\"buffer_overflow\"] = {\n count: (this.internalStats[\"buffer_overflow\"]?.count ?? 0) + 1,\n timestamp: new Date().toISOString(),\n };\n return;\n }\n\n this.rtpBuffer[rtp.header.sequenceNumber] = rtp;\n }\n\n private resolveBuffer(seqNumFrom: number) {\n const resolve: RtpPacket[] = [];\n\n for (let index = seqNumFrom; ; index = uint16Add(index, 1)) {\n const rtp = this.rtpBuffer[index];\n if (rtp) {\n resolve.push(rtp);\n delete this.rtpBuffer[index];\n } else {\n break;\n }\n }\n\n return resolve;\n }\n\n private sortAndClearBuffer(rtpBuffer: {\n [sequenceNumber: number]: RtpPacket;\n }) {\n const buffer: RtpPacket[] = [];\n for (let index = this.presentSeqNum ?? 0; ; index = uint16Add(index, 1)) {\n const rtp = rtpBuffer[index];\n if (rtp) {\n buffer.push(rtp);\n delete rtpBuffer[index];\n }\n if (Object.values(rtpBuffer).length === 0) {\n break;\n }\n }\n return buffer;\n }\n\n private disposeTimeoutPackets(baseTimestamp: number) {\n let latestTimeoutSeqNum: number | undefined;\n\n const packets = Object.values(this.rtpBuffer)\n .map((rtp) => {\n const { timestamp, sequenceNumber } = rtp.header;\n\n if (uint32Gt(timestamp, baseTimestamp)) {\n return;\n }\n\n const elapsedSec =\n uint32Add(baseTimestamp, -timestamp) / this.clockRate;\n\n if (elapsedSec * 1000 > this.options.latency) {\n this.internalStats[\"timeout_packet\"] = {\n count: (this.internalStats[\"timeout_packet\"]?.count ?? 0) + 1,\n at: new Date().toISOString(),\n sequenceNumber,\n elapsedSec,\n baseTimestamp,\n timestamp,\n };\n\n if (latestTimeoutSeqNum == undefined) {\n latestTimeoutSeqNum = sequenceNumber;\n }\n // 現在のSeqNumとの差が最も大きいSeqNumを探す\n if (\n uint16Add(sequenceNumber, -this.presentSeqNum!) >\n uint16Add(latestTimeoutSeqNum, -this.presentSeqNum!)\n ) {\n latestTimeoutSeqNum = sequenceNumber;\n }\n\n const packet = this.rtpBuffer[sequenceNumber];\n delete this.rtpBuffer[sequenceNumber];\n return packet;\n }\n })\n .flatMap((p): RtpPacket => p as RtpPacket)\n .filter((p) => p);\n\n const sorted = this.sortAndClearBuffer(\n packets.reduce((acc, cur) => {\n acc[cur.header.sequenceNumber] = cur;\n return acc;\n }, {})\n );\n\n return { latestTimeoutSeqNum, sorted };\n }\n}\n\nexport interface JitterBufferOptions {\n /**milliseconds */\n latency: number;\n bufferSize: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jitterBuffer.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/jitterBuffer.ts"],"names":[],"mappings":";;;AAAA,0BAOY;AAUZ,MAAa,gBAAgB;IAO3B,IAAY,gBAAgB;QAC1B,OAAO,IAAA,aAAS,EAAC,IAAI,CAAC,aAAc,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAGD,YACS,SAAiB,EACxB,UAAwC,EAAE;;;;;mBADnC;;QAVT;;;;;WAAqC;QACrC,YAAY;QACZ;;;;;WAA+B;QAC/B;;;;mBAA6D,EAAE;WAAC;QAIhE;;;;mBAAwB,EAAE;WAAC;QAMzB,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,GAAG;YAC/B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,KAAK;SACxC,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO;YACL,GAAG,IAAI,CAAC,aAAa;YACrB,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM;YACrD,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;SACxC,CAAC;IACJ,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CA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,CAAC,GAAG,CAAC;oBAC7D,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;oBAC5B,cAAc;oBACd,UAAU;oBACV,aAAa;oBACb,SAAS;iBACV,CAAC;gBAEF,IAAI,mBAAmB,IAAI,SAAS,EAAE;oBACpC,mBAAmB,GAAG,cAAc,CAAC;iBACtC;gBACD,8BAA8B;gBAC9B,IACE,IAAA,aAAS,EAAC,cAAc,EAAE,CAAC,IAAI,CAAC,aAAc,CAAC;oBAC/C,IAAA,aAAS,EAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,aAAc,CAAC,EACpD;oBACA,mBAAmB,GAAG,cAAc,CAAC;iBACtC;gBAED,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;gBAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;gBACtC,OAAO,MAAM,CAAC;aACf;QACH,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,CAAC,EAAa,EAAE,CAAC,CAAc,CAAC;aACzC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAEpB,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CACpC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC;YACrC,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CACP,CAAC;QAEF,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,CAAC;IACzC,CAAC;CACF;AAhOD,4CAgOC","sourcesContent":["import {\n RequireAtLeastOne,\n RtpPacket,\n uint16Add,\n uint16Gte,\n uint32Add,\n uint32Gt,\n} from \"..\";\nimport { Processor } from \"./interface\";\nimport { RtpOutput } from \"./rtpCallback\";\n\nexport type JitterBufferInput = RtpOutput;\n\nexport interface JitterBufferOutput extends RtpOutput {\n isPacketLost?: { from: number; to: number };\n}\n\nexport class JitterBufferBase\n implements Processor<JitterBufferInput, JitterBufferOutput>\n{\n private options: JitterBufferOptions;\n /**uint16 */\n private presentSeqNum?: number;\n private rtpBuffer: { [sequenceNumber: number]: RtpPacket } = {};\n private get expectNextSeqNum() {\n return uint16Add(this.presentSeqNum!, 1);\n }\n private internalStats = {};\n\n constructor(\n public clockRate: number,\n options: Partial<JitterBufferOptions> = {}\n ) {\n this.options = {\n latency: options.latency ?? 200,\n bufferSize: options.bufferSize ?? 10000,\n };\n }\n\n toJSON() {\n return {\n ...this.internalStats,\n rtpBufferLength: Object.values(this.rtpBuffer).length,\n presentSeqNum: this.presentSeqNum,\n expectNextSeqNum: this.expectNextSeqNum,\n };\n }\n\n private stop() {\n this.rtpBuffer = {};\n }\n\n processInput(input: JitterBufferInput): JitterBufferOutput[] {\n const output: JitterBufferOutput[] = [];\n\n if (!input.rtp) {\n if (input.eol) {\n const packets = this.sortAndClearBuffer(this.rtpBuffer);\n for (const rtp of packets) {\n output.push({ rtp });\n }\n output.push({ eol: true });\n\n this.stop();\n }\n return output;\n }\n\n const { packets, timeoutSeqNum } = this.processRtp(input.rtp);\n\n if (timeoutSeqNum != undefined) {\n const isPacketLost = {\n from: this.expectNextSeqNum,\n to: timeoutSeqNum,\n };\n this.presentSeqNum = input.rtp.header.sequenceNumber;\n output.push({ isPacketLost });\n if (packets) {\n for (const rtp of [...packets, input.rtp]) {\n output.push({ rtp });\n }\n }\n this.internalStats[\"jitterBuffer\"] = new Date().toISOString();\n return output;\n } else {\n if (packets) {\n for (const rtp of packets) {\n output.push({ rtp });\n }\n this.internalStats[\"jitterBuffer\"] = new Date().toISOString();\n return output;\n }\n return [];\n }\n }\n\n private processRtp(rtp: RtpPacket): RequireAtLeastOne<{\n packets: RtpPacket[];\n timeoutSeqNum: number;\n nothing: undefined;\n }> {\n const { sequenceNumber, timestamp } = rtp.header;\n\n // init\n if (this.presentSeqNum == undefined) {\n this.presentSeqNum = sequenceNumber;\n return { packets: [rtp] };\n }\n\n // duplicate\n if (uint16Gte(this.presentSeqNum, sequenceNumber)) {\n this.internalStats[\"duplicate\"] = {\n count: (this.internalStats[\"duplicate\"]?.count ?? 0) + 1,\n sequenceNumber,\n timestamp: new Date().toISOString(),\n };\n return { nothing: undefined };\n }\n\n // expect\n if (sequenceNumber === this.expectNextSeqNum) {\n this.presentSeqNum = sequenceNumber;\n\n const rtpBuffer = this.resolveBuffer(uint16Add(sequenceNumber, 1));\n this.presentSeqNum =\n rtpBuffer.at(-1)?.header.sequenceNumber ?? this.presentSeqNum;\n\n this.disposeTimeoutPackets(timestamp);\n\n return { packets: [rtp, ...rtpBuffer] };\n }\n\n this.pushRtpBuffer(rtp);\n\n const { latestTimeoutSeqNum, sorted } =\n this.disposeTimeoutPackets(timestamp);\n\n if (latestTimeoutSeqNum) {\n return { timeoutSeqNum: latestTimeoutSeqNum, packets: sorted };\n } else {\n return { nothing: undefined };\n }\n }\n\n private pushRtpBuffer(rtp: RtpPacket) {\n if (Object.values(this.rtpBuffer).length > this.options.bufferSize) {\n this.internalStats[\"buffer_overflow\"] = {\n count: (this.internalStats[\"buffer_overflow\"]?.count ?? 0) + 1,\n timestamp: new Date().toISOString(),\n };\n return;\n }\n\n this.rtpBuffer[rtp.header.sequenceNumber] = rtp;\n }\n\n private resolveBuffer(seqNumFrom: number) {\n const resolve: RtpPacket[] = [];\n\n for (let index = seqNumFrom; ; index = uint16Add(index, 1)) {\n const rtp = this.rtpBuffer[index];\n if (rtp) {\n resolve.push(rtp);\n delete this.rtpBuffer[index];\n } else {\n break;\n }\n }\n\n return resolve;\n }\n\n private sortAndClearBuffer(rtpBuffer: {\n [sequenceNumber: number]: RtpPacket;\n }) {\n const buffer: RtpPacket[] = [];\n for (let index = this.presentSeqNum ?? 0; ; index = uint16Add(index, 1)) {\n const rtp = rtpBuffer[index];\n if (rtp) {\n buffer.push(rtp);\n delete rtpBuffer[index];\n }\n if (Object.values(rtpBuffer).length === 0) {\n break;\n }\n }\n return buffer;\n }\n\n private disposeTimeoutPackets(baseTimestamp: number) {\n let latestTimeoutSeqNum: number | undefined;\n\n const packets = Object.values(this.rtpBuffer)\n .map((rtp) => {\n const { timestamp, sequenceNumber } = rtp.header;\n\n if (uint32Gt(timestamp, baseTimestamp)) {\n return;\n }\n\n const elapsedSec =\n uint32Add(baseTimestamp, -timestamp) / this.clockRate;\n\n if (elapsedSec * 1000 > this.options.latency) {\n this.internalStats[\"timeout_packet\"] = {\n count: (this.internalStats[\"timeout_packet\"]?.count ?? 0) + 1,\n at: new Date().toISOString(),\n sequenceNumber,\n elapsedSec,\n baseTimestamp,\n timestamp,\n };\n\n if (latestTimeoutSeqNum == undefined) {\n latestTimeoutSeqNum = sequenceNumber;\n }\n // 現在のSeqNumとの差が最も大きいSeqNumを探す\n if (\n uint16Add(sequenceNumber, -this.presentSeqNum!) >\n uint16Add(latestTimeoutSeqNum, -this.presentSeqNum!)\n ) {\n latestTimeoutSeqNum = sequenceNumber;\n }\n\n const packet = this.rtpBuffer[sequenceNumber];\n delete this.rtpBuffer[sequenceNumber];\n return packet;\n }\n })\n .flatMap((p): RtpPacket => p as RtpPacket)\n .filter((p) => p);\n\n const sorted = this.sortAndClearBuffer(\n packets.reduce((acc, cur) => {\n acc[cur.header.sequenceNumber] = cur;\n return acc;\n }, {})\n );\n\n return { latestTimeoutSeqNum, sorted };\n }\n}\n\nexport interface JitterBufferOptions {\n /**milliseconds */\n latency: number;\n bufferSize: number;\n}\n"]}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { JitterBufferBase,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { JitterBufferBase, JitterBufferOutput } from "./jitterBuffer";
|
|
2
|
+
declare const JitterBufferCallback_base: {
|
|
3
|
+
new (...args: any[]): {
|
|
4
|
+
cb?: ((o: JitterBufferOutput) => void) | undefined;
|
|
5
|
+
destructor?: (() => void) | undefined;
|
|
6
|
+
pipe: (cb: (o: JitterBufferOutput) => void, destructor?: (() => void) | undefined) => any;
|
|
7
|
+
input: (input: import("./rtpCallback").RtpOutput) => void;
|
|
8
|
+
destroy: () => void;
|
|
9
|
+
processInput: (input: import("./rtpCallback").RtpOutput) => JitterBufferOutput[];
|
|
10
|
+
toJSON(): Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
} & typeof JitterBufferBase;
|
|
13
|
+
export declare class JitterBufferCallback extends JitterBufferCallback_base {
|
|
6
14
|
}
|
|
15
|
+
export {};
|
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JitterBufferCallback = void 0;
|
|
4
|
+
const interface_1 = require("./interface");
|
|
4
5
|
const jitterBuffer_1 = require("./jitterBuffer");
|
|
5
|
-
class JitterBufferCallback extends jitterBuffer_1.JitterBufferBase {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
Object.defineProperty(this, "cb", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "pipe", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: (cb) => {
|
|
19
|
-
this.cb = cb;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(this, "input", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: (input) => {
|
|
28
|
-
if (!this.cb) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
for (const output of this.processInput(input)) {
|
|
32
|
-
this.cb(output);
|
|
33
|
-
}
|
|
34
|
-
if (input.eol) {
|
|
35
|
-
this.cb = undefined;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
6
|
+
class JitterBufferCallback extends (0, interface_1.SimpleProcessorCallbackBase)(jitterBuffer_1.JitterBufferBase) {
|
|
40
7
|
}
|
|
41
8
|
exports.JitterBufferCallback = JitterBufferCallback;
|
|
42
9
|
//# sourceMappingURL=jitterBufferCallback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jitterBufferCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/jitterBufferCallback.ts"],"names":[],"mappings":";;;AAAA,iDAIwB;AAExB,MAAa,oBAAqB,SAAQ
|
|
1
|
+
{"version":3,"file":"jitterBufferCallback.js","sourceRoot":"","sources":["../../../../../rtp/src/processor/jitterBufferCallback.ts"],"names":[],"mappings":";;;AAAA,2CAA0D;AAC1D,iDAIwB;AAExB,MAAa,oBAAqB,SAAQ,IAAA,uCAA2B,EAInE,+BAAgB,CAAC;CAAG;AAJtB,oDAIsB","sourcesContent":["import { SimpleProcessorCallbackBase } from \"./interface\";\nimport {\n JitterBufferBase,\n JitterBufferInput,\n JitterBufferOutput,\n} from \"./jitterBuffer\";\n\nexport class JitterBufferCallback extends SimpleProcessorCallbackBase<\n JitterBufferInput,\n JitterBufferOutput,\n typeof JitterBufferBase\n>(JitterBufferBase) {}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { TransformStream } from "stream/web";
|
|
3
3
|
import { JitterBufferBase, JitterBufferInput, JitterBufferOptions, JitterBufferOutput } from "./jitterBuffer";
|
|
4
|
-
export declare const jitterBufferTransformer: (clockRate: number, options?: Partial<JitterBufferOptions> | undefined) => TransformStream<import("./
|
|
4
|
+
export declare const jitterBufferTransformer: (clockRate: number, options?: Partial<JitterBufferOptions> | undefined) => TransformStream<import("./rtpCallback").RtpOutput, JitterBufferOutput>;
|
|
5
5
|
export declare class JitterBufferTransformer extends JitterBufferBase {
|
|
6
6
|
clockRate: number;
|
|
7
7
|
transform: TransformStream<JitterBufferInput, JitterBufferOutput>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { CodecFrame } from "./depacketizer";
|
|
3
3
|
import { AVProcessor } from "./interface";
|
|
4
|
+
import { MediaKind } from "./webm";
|
|
4
5
|
export type LipsyncInput = {
|
|
5
6
|
frame?: CodecFrame;
|
|
6
7
|
eol?: boolean;
|
|
@@ -13,39 +14,49 @@ export declare class LipsyncBase implements AVProcessor<LipsyncInput> {
|
|
|
13
14
|
private audioOutput;
|
|
14
15
|
private videoOutput;
|
|
15
16
|
private options;
|
|
17
|
+
private id;
|
|
16
18
|
bufferLength: number;
|
|
17
19
|
/**ms */
|
|
18
20
|
baseTime?: number;
|
|
19
21
|
audioBuffer: {
|
|
20
22
|
frame: CodecFrame;
|
|
21
|
-
kind:
|
|
23
|
+
kind: MediaKind;
|
|
24
|
+
[key: string]: any;
|
|
22
25
|
}[][];
|
|
23
26
|
videoBuffer: {
|
|
24
27
|
frame: CodecFrame;
|
|
25
|
-
kind:
|
|
28
|
+
kind: MediaKind;
|
|
26
29
|
}[][];
|
|
27
30
|
stopped: boolean;
|
|
28
31
|
/**ms */
|
|
29
32
|
private interval;
|
|
30
|
-
private started;
|
|
31
33
|
/**ms */
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
+
private bufferDuration;
|
|
35
|
+
private ptime;
|
|
36
|
+
private index;
|
|
37
|
+
private currentTimestamp;
|
|
38
|
+
/**ms */
|
|
39
|
+
private lastCommittedTime;
|
|
40
|
+
private lastExecutionTime;
|
|
34
41
|
private internalStats;
|
|
42
|
+
/**ms */
|
|
43
|
+
private lastFrameReceivedAt;
|
|
35
44
|
constructor(audioOutput: (output: LipsyncOutput) => void, videoOutput: (output: LipsyncOutput) => void, options?: Partial<LipSyncOptions>);
|
|
36
45
|
toJSON(): Record<string, any>;
|
|
37
|
-
private
|
|
46
|
+
private executeTask;
|
|
38
47
|
private stop;
|
|
39
48
|
processAudioInput: ({ frame, eol }: LipsyncInput) => void;
|
|
40
49
|
processVideoInput: ({ frame, eol }: LipsyncInput) => void;
|
|
50
|
+
private processInput;
|
|
41
51
|
}
|
|
42
52
|
export interface LipSyncOptions {
|
|
43
53
|
/**ms */
|
|
44
54
|
syncInterval: number;
|
|
45
55
|
/**
|
|
46
56
|
* int
|
|
47
|
-
* @description syncInterval *
|
|
57
|
+
* @description syncInterval * bufferLength = max packet lifetime
|
|
48
58
|
* */
|
|
49
|
-
|
|
59
|
+
bufferLength: number;
|
|
50
60
|
fillDummyAudioPacket: Buffer;
|
|
61
|
+
ptime: number;
|
|
51
62
|
}
|