@observertc/observer-js 0.9.26-beta → 0.30.0-beta
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/ObservedCall.d.ts +54 -0
- package/lib/ObservedCall.d.ts.map +1 -0
- package/lib/ObservedCall.js +166 -0
- package/lib/ObservedClient.d.ts +73 -0
- package/lib/ObservedClient.d.ts.map +1 -0
- package/lib/ObservedClient.js +487 -0
- package/lib/ObservedInboundTrack.d.ts +65 -0
- package/lib/ObservedInboundTrack.d.ts.map +1 -0
- package/lib/ObservedInboundTrack.js +192 -0
- package/lib/ObservedOutboundTrack.d.ts +55 -0
- package/lib/ObservedOutboundTrack.d.ts.map +1 -0
- package/lib/ObservedOutboundTrack.js +166 -0
- package/lib/ObservedPeerConnection.d.ts +57 -0
- package/lib/ObservedPeerConnection.d.ts.map +1 -0
- package/lib/ObservedPeerConnection.js +217 -0
- package/lib/Observer.d.ts +26 -1465
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +53 -605
- package/lib/{sinks/ObserverSink.d.ts → ReportsCollector.d.ts} +7 -23
- package/lib/ReportsCollector.d.ts.map +1 -0
- package/lib/{sinks/ObserverSink.js → ReportsCollector.js} +27 -85
- package/lib/common/ReportsCollector.d.ts +21 -24
- package/lib/common/ReportsCollector.d.ts.map +1 -1
- package/lib/common/ReportsCollector.js +24 -0
- package/lib/common/SingleExecutor.d.ts +3 -0
- package/lib/common/SingleExecutor.d.ts.map +1 -0
- package/lib/common/SingleExecutor.js +31 -0
- package/lib/common/TypedEventEmitter.d.ts +22 -0
- package/lib/common/TypedEventEmitter.d.ts.map +1 -0
- package/lib/common/TypedEventEmitter.js +11 -0
- package/lib/common/callEventReports.d.ts.map +1 -0
- package/lib/common/logger.d.ts +3 -9
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +58 -141
- package/lib/common/types.d.ts +2 -14
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +6 -1
- package/lib/index.d.ts +8 -19
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -2
- package/package.json +1 -1
- package/src/ObservedCall.ts +201 -0
- package/src/ObservedClient.ts +681 -0
- package/src/ObservedInboundTrack.ts +238 -0
- package/src/ObservedOutboundTrack.ts +205 -0
- package/src/ObservedPeerConnection.ts +249 -0
- package/src/Observer.ts +86 -442
- package/src/{sinks/ObserverSink.ts → ReportsCollector.ts} +29 -94
- package/src/common/ReportsCollector.ts +48 -23
- package/src/common/SingleExecutor.ts +36 -0
- package/src/common/TypedEventEmitter.ts +32 -0
- package/src/common/logger.ts +58 -161
- package/src/common/types.ts +4 -24
- package/src/common/utils.ts +6 -0
- package/src/index.ts +12 -23
- package/lib/Evaluator.d.ts +0 -43
- package/lib/Evaluator.d.ts.map +0 -1
- package/lib/Evaluator.js +0 -171
- package/lib/common/Semaphore.d.ts +0 -31
- package/lib/common/Semaphore.d.ts.map +0 -1
- package/lib/common/Semaphore.js +0 -16
- package/lib/entries/CallEntry.d.ts +0 -619
- package/lib/entries/CallEntry.d.ts.map +0 -1
- package/lib/entries/CallEntry.js +0 -75
- package/lib/entries/ClientEntry.d.ts +0 -478
- package/lib/entries/ClientEntry.d.ts.map +0 -1
- package/lib/entries/ClientEntry.js +0 -114
- package/lib/entries/InboundTrackEntry.d.ts +0 -682
- package/lib/entries/InboundTrackEntry.d.ts.map +0 -1
- package/lib/entries/InboundTrackEntry.js +0 -76
- package/lib/entries/OutboundTrackEntry.d.ts +0 -682
- package/lib/entries/OutboundTrackEntry.d.ts.map +0 -1
- package/lib/entries/OutboundTrackEntry.js +0 -73
- package/lib/entries/PeerConnectionEntry.d.ts +0 -505
- package/lib/entries/PeerConnectionEntry.d.ts.map +0 -1
- package/lib/entries/PeerConnectionEntry.js +0 -144
- package/lib/entries/SfuEntry.d.ts +0 -150
- package/lib/entries/SfuEntry.d.ts.map +0 -1
- package/lib/entries/SfuEntry.js +0 -77
- package/lib/entries/SfuInboundRtpPadEntry.d.ts +0 -14
- package/lib/entries/SfuInboundRtpPadEntry.d.ts.map +0 -1
- package/lib/entries/SfuInboundRtpPadEntry.js +0 -49
- package/lib/entries/SfuOutboundRtpPadEntry.d.ts +0 -14
- package/lib/entries/SfuOutboundRtpPadEntry.d.ts.map +0 -1
- package/lib/entries/SfuOutboundRtpPadEntry.js +0 -47
- package/lib/entries/SfuSctpChannelEntry.d.ts +0 -12
- package/lib/entries/SfuSctpChannelEntry.d.ts.map +0 -1
- package/lib/entries/SfuSctpChannelEntry.js +0 -43
- package/lib/entries/SfuTransportEntry.d.ts +0 -82
- package/lib/entries/SfuTransportEntry.d.ts.map +0 -1
- package/lib/entries/SfuTransportEntry.js +0 -122
- package/lib/evaluators/SetClientsCoordinateEvaluator.d.ts +0 -9
- package/lib/evaluators/SetClientsCoordinateEvaluator.d.ts.map +0 -1
- package/lib/evaluators/SetClientsCoordinateEvaluator.js +0 -95
- package/lib/middlewares/CallOperationsContext.d.ts +0 -18
- package/lib/middlewares/CallOperationsContext.d.ts.map +0 -1
- package/lib/middlewares/CallOperationsContext.js +0 -27
- package/lib/middlewares/CallProcessor.d.ts +0 -6
- package/lib/middlewares/CallProcessor.d.ts.map +0 -1
- package/lib/middlewares/CallProcessor.js +0 -36
- package/lib/middlewares/CommitTransactionMiddleware.d.ts +0 -6
- package/lib/middlewares/CommitTransactionMiddleware.d.ts.map +0 -1
- package/lib/middlewares/CommitTransactionMiddleware.js +0 -179
- package/lib/middlewares/DeleteOutdatedCallEntries.d.ts +0 -6
- package/lib/middlewares/DeleteOutdatedCallEntries.d.ts.map +0 -1
- package/lib/middlewares/DeleteOutdatedCallEntries.js +0 -121
- package/lib/middlewares/DeleteOutdatedSfuEntries.d.ts +0 -6
- package/lib/middlewares/DeleteOutdatedSfuEntries.d.ts.map +0 -1
- package/lib/middlewares/DeleteOutdatedSfuEntries.js +0 -127
- package/lib/middlewares/Middleware.d.ts +0 -3
- package/lib/middlewares/Middleware.d.ts.map +0 -1
- package/lib/middlewares/Middleware.js +0 -21
- package/lib/middlewares/Processor.d.ts +0 -9
- package/lib/middlewares/Processor.d.ts.map +0 -1
- package/lib/middlewares/Processor.js +0 -54
- package/lib/middlewares/TransactionContext.d.ts +0 -35
- package/lib/middlewares/TransactionContext.d.ts.map +0 -1
- package/lib/middlewares/TransactionContext.js +0 -90
- package/lib/middlewares/TransactoinProcessor.d.ts +0 -6
- package/lib/middlewares/TransactoinProcessor.d.ts.map +0 -1
- package/lib/middlewares/TransactoinProcessor.js +0 -17
- package/lib/middlewares/VisitObservedCallsMiddleware.d.ts +0 -7
- package/lib/middlewares/VisitObservedCallsMiddleware.d.ts.map +0 -1
- package/lib/middlewares/VisitObservedCallsMiddleware.js +0 -96
- package/lib/middlewares/VisitObservedSfusMiddleware.d.ts +0 -6
- package/lib/middlewares/VisitObservedSfusMiddleware.d.ts.map +0 -1
- package/lib/middlewares/VisitObservedSfusMiddleware.js +0 -151
- package/lib/middlewares/visitors/visitClient.d.ts +0 -5
- package/lib/middlewares/visitors/visitClient.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitClient.js +0 -174
- package/lib/middlewares/visitors/visitInboundAudioTrack.d.ts +0 -5
- package/lib/middlewares/visitors/visitInboundAudioTrack.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitInboundAudioTrack.js +0 -93
- package/lib/middlewares/visitors/visitInboundVideoTrack.d.ts +0 -5
- package/lib/middlewares/visitors/visitInboundVideoTrack.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitInboundVideoTrack.js +0 -94
- package/lib/middlewares/visitors/visitOutboundAudioTrack.d.ts +0 -5
- package/lib/middlewares/visitors/visitOutboundAudioTrack.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitOutboundAudioTrack.js +0 -90
- package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts +0 -5
- package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitOutboundVideoTarck.js +0 -90
- package/lib/middlewares/visitors/visitPeerConnection.d.ts +0 -5
- package/lib/middlewares/visitors/visitPeerConnection.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitPeerConnection.js +0 -111
- package/lib/middlewares/visitors/visitSfu.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfu.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfu.js +0 -78
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.js +0 -56
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.js +0 -56
- package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfuSctpChannel.js +0 -55
- package/lib/middlewares/visitors/visitSfuTransport.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfuTransport.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfuTransport.js +0 -56
- package/lib/processes/closePeerConnectionProcess.d.ts +0 -10
- package/lib/processes/closePeerConnectionProcess.d.ts.map +0 -1
- package/lib/processes/closePeerConnectionProcess.js +0 -51
- package/lib/processes/detachClientProcess.d.ts +0 -14
- package/lib/processes/detachClientProcess.d.ts.map +0 -1
- package/lib/processes/detachClientProcess.js +0 -106
- package/lib/processes/findRemoteMatches.d.ts +0 -9
- package/lib/processes/findRemoteMatches.d.ts.map +0 -1
- package/lib/processes/findRemoteMatches.js +0 -96
- package/lib/processes/inboundTrackRemoved.d.ts +0 -9
- package/lib/processes/inboundTrackRemoved.d.ts.map +0 -1
- package/lib/processes/inboundTrackRemoved.js +0 -22
- package/lib/processes/joinClientProcess.d.ts +0 -11
- package/lib/processes/joinClientProcess.d.ts.map +0 -1
- package/lib/processes/joinClientProcess.js +0 -120
- package/lib/processes/outboundTrackRemoved.d.ts +0 -9
- package/lib/processes/outboundTrackRemoved.d.ts.map +0 -1
- package/lib/processes/outboundTrackRemoved.js +0 -22
- package/lib/samples/ObservedCall.d.ts +0 -17
- package/lib/samples/ObservedCall.d.ts.map +0 -1
- package/lib/samples/ObservedCall.js +0 -29
- package/lib/samples/ObservedCalls.d.ts +0 -19
- package/lib/samples/ObservedCalls.d.ts.map +0 -1
- package/lib/samples/ObservedCalls.js +0 -113
- package/lib/samples/ObservedClient.d.ts +0 -28
- package/lib/samples/ObservedClient.d.ts.map +0 -1
- package/lib/samples/ObservedClient.js +0 -110
- package/lib/samples/ObservedInboundAudioTrack.d.ts +0 -17
- package/lib/samples/ObservedInboundAudioTrack.d.ts.map +0 -1
- package/lib/samples/ObservedInboundAudioTrack.js +0 -17
- package/lib/samples/ObservedInboundVideoTrack.d.ts +0 -17
- package/lib/samples/ObservedInboundVideoTrack.d.ts.map +0 -1
- package/lib/samples/ObservedInboundVideoTrack.js +0 -17
- package/lib/samples/ObservedOutboundAudioTrack.d.ts +0 -16
- package/lib/samples/ObservedOutboundAudioTrack.d.ts.map +0 -1
- package/lib/samples/ObservedOutboundAudioTrack.js +0 -17
- package/lib/samples/ObservedOutboundVideoTrack.d.ts +0 -16
- package/lib/samples/ObservedOutboundVideoTrack.d.ts.map +0 -1
- package/lib/samples/ObservedOutboundVideoTrack.js +0 -17
- package/lib/samples/ObservedPeerConnection.d.ts +0 -47
- package/lib/samples/ObservedPeerConnection.d.ts.map +0 -1
- package/lib/samples/ObservedPeerConnection.js +0 -130
- package/lib/samples/ObservedSfu.d.ts +0 -27
- package/lib/samples/ObservedSfu.d.ts.map +0 -1
- package/lib/samples/ObservedSfu.js +0 -65
- package/lib/samples/ObservedSfuInboundRtpPad.d.ts +0 -15
- package/lib/samples/ObservedSfuInboundRtpPad.d.ts.map +0 -1
- package/lib/samples/ObservedSfuInboundRtpPad.js +0 -17
- package/lib/samples/ObservedSfuOutboundRtpPad.d.ts +0 -15
- package/lib/samples/ObservedSfuOutboundRtpPad.d.ts.map +0 -1
- package/lib/samples/ObservedSfuOutboundRtpPad.js +0 -17
- package/lib/samples/ObservedSfuSctpChannel.d.ts +0 -15
- package/lib/samples/ObservedSfuSctpChannel.d.ts.map +0 -1
- package/lib/samples/ObservedSfuSctpChannel.js +0 -17
- package/lib/samples/ObservedSfuTransport.d.ts +0 -30
- package/lib/samples/ObservedSfuTransport.d.ts.map +0 -1
- package/lib/samples/ObservedSfuTransport.js +0 -86
- package/lib/samples/ObservedSfus.d.ts +0 -16
- package/lib/samples/ObservedSfus.d.ts.map +0 -1
- package/lib/samples/ObservedSfus.js +0 -72
- package/lib/sinks/ObserverSink.d.ts.map +0 -1
- package/lib/sinks/callEventReports.d.ts.map +0 -1
- package/lib/sources/ObservedCallSource.d.ts +0 -18
- package/lib/sources/ObservedCallSource.d.ts.map +0 -1
- package/lib/sources/ObservedCallSource.js +0 -2
- package/lib/sources/ObservedClientSource.d.ts +0 -19
- package/lib/sources/ObservedClientSource.d.ts.map +0 -1
- package/lib/sources/ObservedClientSource.js +0 -2
- package/lib/sources/ObservedSfuSource.d.ts +0 -15
- package/lib/sources/ObservedSfuSource.d.ts.map +0 -1
- package/lib/sources/ObservedSfuSource.js +0 -2
- package/lib/sources/Sources.d.ts +0 -47
- package/lib/sources/Sources.d.ts.map +0 -1
- package/lib/sources/Sources.js +0 -211
- package/src/Evaluator.ts +0 -229
- package/src/common/Semaphore.ts +0 -45
- package/src/entries/CallEntry.ts +0 -62
- package/src/entries/ClientEntry.ts +0 -106
- package/src/entries/InboundTrackEntry.ts +0 -74
- package/src/entries/OutboundTrackEntry.ts +0 -72
- package/src/entries/PeerConnectionEntry.ts +0 -133
- package/src/entries/SfuEntry.ts +0 -62
- package/src/entries/SfuInboundRtpPadEntry.ts +0 -46
- package/src/entries/SfuOutboundRtpPadEntry.ts +0 -44
- package/src/entries/SfuSctpChannelEntry.ts +0 -39
- package/src/entries/SfuTransportEntry.ts +0 -109
- package/src/evaluators/SetClientsCoordinateEvaluator.ts +0 -78
- package/src/middlewares/CallOperationsContext.ts +0 -56
- package/src/middlewares/CallProcessor.ts +0 -38
- package/src/middlewares/CommitTransactionMiddleware.ts +0 -328
- package/src/middlewares/DeleteOutdatedCallEntries.ts +0 -159
- package/src/middlewares/DeleteOutdatedSfuEntries.ts +0 -168
- package/src/middlewares/Middleware.ts +0 -10
- package/src/middlewares/Processor.ts +0 -59
- package/src/middlewares/TransactionContext.ts +0 -176
- package/src/middlewares/TransactoinProcessor.ts +0 -28
- package/src/middlewares/VisitObservedCallsMiddleware.ts +0 -172
- package/src/middlewares/VisitObservedSfusMiddleware.ts +0 -203
- package/src/middlewares/visitors/visitClient.ts +0 -239
- package/src/middlewares/visitors/visitInboundAudioTrack.ts +0 -113
- package/src/middlewares/visitors/visitInboundVideoTrack.ts +0 -117
- package/src/middlewares/visitors/visitOutboundAudioTrack.ts +0 -100
- package/src/middlewares/visitors/visitOutboundVideoTarck.ts +0 -102
- package/src/middlewares/visitors/visitPeerConnection.ts +0 -151
- package/src/middlewares/visitors/visitSfu.ts +0 -70
- package/src/middlewares/visitors/visitSfuInboundRtpPad.ts +0 -52
- package/src/middlewares/visitors/visitSfuOutboundRtpPad.ts +0 -53
- package/src/middlewares/visitors/visitSfuSctpChannel.ts +0 -50
- package/src/middlewares/visitors/visitSfuTransport.ts +0 -50
- package/src/processes/closePeerConnectionProcess.ts +0 -54
- package/src/processes/detachClientProcess.ts +0 -136
- package/src/processes/findRemoteMatches.ts +0 -104
- package/src/processes/inboundTrackRemoved.ts +0 -22
- package/src/processes/joinClientProcess.ts +0 -138
- package/src/processes/outboundTrackRemoved.ts +0 -22
- package/src/samples/ObservedCall.ts +0 -49
- package/src/samples/ObservedCalls.ts +0 -143
- package/src/samples/ObservedClient.ts +0 -172
- package/src/samples/ObservedInboundAudioTrack.ts +0 -35
- package/src/samples/ObservedInboundVideoTrack.ts +0 -36
- package/src/samples/ObservedOutboundAudioTrack.ts +0 -35
- package/src/samples/ObservedOutboundVideoTrack.ts +0 -35
- package/src/samples/ObservedPeerConnection.ts +0 -227
- package/src/samples/ObservedSfu.ts +0 -115
- package/src/samples/ObservedSfuInboundRtpPad.ts +0 -35
- package/src/samples/ObservedSfuOutboundRtpPad.ts +0 -35
- package/src/samples/ObservedSfuSctpChannel.ts +0 -35
- package/src/samples/ObservedSfuTransport.ts +0 -142
- package/src/samples/ObservedSfus.ts +0 -95
- package/src/sources/ObservedCallSource.ts +0 -26
- package/src/sources/ObservedClientSource.ts +0 -28
- package/src/sources/ObservedSfuSource.ts +0 -19
- package/src/sources/Sources.ts +0 -294
- /package/lib/{sinks → common}/callEventReports.d.ts +0 -0
- /package/lib/{sinks → common}/callEventReports.js +0 -0
- /package/src/{sinks → common}/callEventReports.ts +0 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.ObservedPeerConnection = void 0;
|
|
36
|
+
const events_1 = require("events");
|
|
37
|
+
const Models = __importStar(require("./models/Models"));
|
|
38
|
+
const ObservedInboundTrack_1 = require("./ObservedInboundTrack");
|
|
39
|
+
const ObservedOutboundTrack_1 = require("./ObservedOutboundTrack");
|
|
40
|
+
const SingleExecutor_1 = require("./common/SingleExecutor");
|
|
41
|
+
class ObservedPeerConnection extends events_1.EventEmitter {
|
|
42
|
+
static create(config, client, storageProvider) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const model = new Models.PeerConnection({
|
|
45
|
+
roomId: client.roomId,
|
|
46
|
+
serviceId: client.serviceId,
|
|
47
|
+
callId: client.callId,
|
|
48
|
+
clientId: client.clientId,
|
|
49
|
+
peerConnectionId: config.peerConnectionId,
|
|
50
|
+
});
|
|
51
|
+
const alreadyInserted = yield storageProvider.peerConnectionStorage.insert(config.peerConnectionId, model);
|
|
52
|
+
if (alreadyInserted)
|
|
53
|
+
throw new Error(`PeerConnection with id ${config.peerConnectionId} already exists`);
|
|
54
|
+
return new ObservedPeerConnection(model, client, storageProvider);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
constructor(_model, client, _storageProvider) {
|
|
58
|
+
super();
|
|
59
|
+
this._model = _model;
|
|
60
|
+
this.client = client;
|
|
61
|
+
this._storageProvider = _storageProvider;
|
|
62
|
+
this._closed = false;
|
|
63
|
+
this._updated = Date.now();
|
|
64
|
+
this._inboundAudioTracks = new Map();
|
|
65
|
+
this._inboundVideoTracks = new Map();
|
|
66
|
+
this._outboundAudioTracks = new Map();
|
|
67
|
+
this._outboundVideoTracks = new Map();
|
|
68
|
+
this._execute = (0, SingleExecutor_1.createSingleExecutor)();
|
|
69
|
+
}
|
|
70
|
+
get peerConnectionId() {
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
return this._model.peerConnectionId;
|
|
73
|
+
}
|
|
74
|
+
get reports() {
|
|
75
|
+
return this.client.reports;
|
|
76
|
+
}
|
|
77
|
+
get stats() {
|
|
78
|
+
return this._sample;
|
|
79
|
+
}
|
|
80
|
+
get updated() {
|
|
81
|
+
return this._updated;
|
|
82
|
+
}
|
|
83
|
+
get inboundAudioTracks() {
|
|
84
|
+
return this._inboundAudioTracks;
|
|
85
|
+
}
|
|
86
|
+
get inboundVideoTracks() {
|
|
87
|
+
return this._inboundVideoTracks;
|
|
88
|
+
}
|
|
89
|
+
get outboundAudioTracks() {
|
|
90
|
+
return this._outboundAudioTracks;
|
|
91
|
+
}
|
|
92
|
+
get outboundVideoTracks() {
|
|
93
|
+
return this._outboundVideoTracks;
|
|
94
|
+
}
|
|
95
|
+
get closed() {
|
|
96
|
+
return this._closed;
|
|
97
|
+
}
|
|
98
|
+
close() {
|
|
99
|
+
if (this._closed)
|
|
100
|
+
return;
|
|
101
|
+
this._closed = true;
|
|
102
|
+
Array.from(this._inboundAudioTracks.values()).forEach((track) => track.close());
|
|
103
|
+
Array.from(this._inboundVideoTracks.values()).forEach((track) => track.close());
|
|
104
|
+
Array.from(this._outboundAudioTracks.values()).forEach((track) => track.close());
|
|
105
|
+
Array.from(this._outboundVideoTracks.values()).forEach((track) => track.close());
|
|
106
|
+
this._execute(() => this._storageProvider.peerConnectionStorage.remove(this.peerConnectionId))
|
|
107
|
+
.catch(() => void 0)
|
|
108
|
+
.finally(() => this.emit('close'));
|
|
109
|
+
}
|
|
110
|
+
update(sample, timestamp) {
|
|
111
|
+
if (this._closed)
|
|
112
|
+
return;
|
|
113
|
+
if (sample.peerConnectionId !== this._model.peerConnectionId)
|
|
114
|
+
throw new Error(`TransportId mismatch. PeerConnectionId: ${this._model.peerConnectionId} TransportId: ${sample.transportId}`);
|
|
115
|
+
this._sample = sample;
|
|
116
|
+
const report = Object.assign(Object.assign({ serviceId: this.client.call.serviceId, roomId: this.client.call.roomId, callId: this.client.call.callId, clientId: this.client.clientId, userId: this.client.userId, mediaUnitId: this.client.mediaUnitId }, sample), { timestamp, sampleSeq: -1 });
|
|
117
|
+
this.reports.addPeerConnectionTransportReports(report);
|
|
118
|
+
this._updated = timestamp;
|
|
119
|
+
this.emit('update');
|
|
120
|
+
}
|
|
121
|
+
createInboundAudioTrack(config) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
if (this._closed)
|
|
124
|
+
throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
|
|
125
|
+
const result = yield ObservedInboundTrack_1.ObservedInboundTrack.create({
|
|
126
|
+
kind: 'audio',
|
|
127
|
+
trackId: config.trackId,
|
|
128
|
+
}, this, this._storageProvider);
|
|
129
|
+
result.on('close', () => {
|
|
130
|
+
this._inboundAudioTracks.delete(result.trackId);
|
|
131
|
+
this._model.inboundTrackIds = this._model.inboundTrackIds.filter((id) => id !== result.trackId);
|
|
132
|
+
!this._closed && this._save().catch(() => void 0);
|
|
133
|
+
});
|
|
134
|
+
this._inboundAudioTracks.set(result.trackId, result);
|
|
135
|
+
this._model.inboundTrackIds = [...(new Set([...this._model.inboundTrackIds, result.trackId]))];
|
|
136
|
+
yield this._save();
|
|
137
|
+
this.emit('newinboudaudiotrack', result);
|
|
138
|
+
return result;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
createInboundVideoTrack(config) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
if (this._closed)
|
|
144
|
+
throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
|
|
145
|
+
const result = yield ObservedInboundTrack_1.ObservedInboundTrack.create({
|
|
146
|
+
kind: 'video',
|
|
147
|
+
trackId: config.trackId,
|
|
148
|
+
}, this, this._storageProvider);
|
|
149
|
+
result.on('close', () => {
|
|
150
|
+
this._inboundVideoTracks.delete(result.trackId);
|
|
151
|
+
this._model.inboundTrackIds = this._model.inboundTrackIds.filter((id) => id !== result.trackId);
|
|
152
|
+
!this._closed && this._save().catch(() => void 0);
|
|
153
|
+
});
|
|
154
|
+
this._inboundVideoTracks.set(result.trackId, result);
|
|
155
|
+
this._model.inboundTrackIds = [...(new Set([...this._model.inboundTrackIds, result.trackId]))];
|
|
156
|
+
yield this._save();
|
|
157
|
+
this.emit('newinboudvideotrack', result);
|
|
158
|
+
return result;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
createOutboundAudioTrack(config) {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
if (this._closed)
|
|
164
|
+
throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
|
|
165
|
+
const result = yield ObservedOutboundTrack_1.ObservedOutboundTrack.create({
|
|
166
|
+
kind: 'audio',
|
|
167
|
+
trackId: config.trackId,
|
|
168
|
+
}, this, this._storageProvider);
|
|
169
|
+
result.on('close', () => {
|
|
170
|
+
this._outboundAudioTracks.delete(result.trackId);
|
|
171
|
+
this._model.outboundTrackIds = this._model.outboundTrackIds.filter((id) => id !== result.trackId);
|
|
172
|
+
result.sfuStreamId && this.client.call.sfuStreamIdToOutboundAudioTrack.delete(result.sfuStreamId);
|
|
173
|
+
!this._closed && this._save().catch(() => void 0);
|
|
174
|
+
});
|
|
175
|
+
this._outboundAudioTracks.set(result.trackId, result);
|
|
176
|
+
this._model.outboundTrackIds = [...(new Set([...this._model.outboundTrackIds, result.trackId]))];
|
|
177
|
+
result.sfuStreamId && this.client.call.sfuStreamIdToOutboundAudioTrack.set(result.sfuStreamId, result);
|
|
178
|
+
yield this._save();
|
|
179
|
+
this.emit('newoutboundaudiotrack', result);
|
|
180
|
+
return result;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
createOutboundVideoTrack(config) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
if (this._closed)
|
|
186
|
+
throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
|
|
187
|
+
const result = yield ObservedOutboundTrack_1.ObservedOutboundTrack.create({
|
|
188
|
+
kind: 'video',
|
|
189
|
+
trackId: config.trackId,
|
|
190
|
+
}, this, this._storageProvider);
|
|
191
|
+
result.on('close', () => {
|
|
192
|
+
this._outboundVideoTracks.delete(result.trackId);
|
|
193
|
+
result.sfuStreamId && this.client.call.sfuStreamIdToOutboundVideoTrack.set(result.sfuStreamId, result);
|
|
194
|
+
this._model.outboundTrackIds = this._model.outboundTrackIds.filter((id) => id !== result.trackId);
|
|
195
|
+
!this._closed && this._save().catch(() => void 0);
|
|
196
|
+
});
|
|
197
|
+
this._outboundVideoTracks.set(result.trackId, result);
|
|
198
|
+
result.sfuStreamId && this.client.call.sfuStreamIdToOutboundVideoTrack.set(result.sfuStreamId, result);
|
|
199
|
+
this._model.outboundTrackIds = [...(new Set([...this._model.outboundTrackIds, result.trackId]))];
|
|
200
|
+
yield this._save();
|
|
201
|
+
this.emit('newoutboundvideotrack', result);
|
|
202
|
+
return result;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
_save() {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
if (this._closed)
|
|
208
|
+
throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
|
|
209
|
+
return this._execute(() => __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
if (this._closed)
|
|
211
|
+
throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
|
|
212
|
+
yield this._storageProvider.peerConnectionStorage.set(this.peerConnectionId, this._model);
|
|
213
|
+
}));
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.ObservedPeerConnection = ObservedPeerConnection;
|