@observertc/observer-js 0.9.27-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 -49
- package/lib/sources/Sources.d.ts.map +0 -1
- package/lib/sources/Sources.js +0 -213
- 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 -301
- /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,192 @@
|
|
|
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.ObservedInboundTrack = void 0;
|
|
36
|
+
const events_1 = require("events");
|
|
37
|
+
const Models = __importStar(require("./models/Models"));
|
|
38
|
+
const SingleExecutor_1 = require("./common/SingleExecutor");
|
|
39
|
+
class ObservedInboundTrack extends events_1.EventEmitter {
|
|
40
|
+
static create(config, peerConnection, storageProvider) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const model = new Models.InboundTrack({
|
|
43
|
+
serviceId: peerConnection.client.serviceId,
|
|
44
|
+
roomId: peerConnection.client.roomId,
|
|
45
|
+
callId: peerConnection.client.callId,
|
|
46
|
+
clientId: peerConnection.client.clientId,
|
|
47
|
+
mediaUnitId: peerConnection.client.mediaUnitId,
|
|
48
|
+
peerConnectionId: peerConnection.peerConnectionId,
|
|
49
|
+
trackId: config.trackId,
|
|
50
|
+
kind: config.kind,
|
|
51
|
+
sfuStreamId: config.sfuStreamId,
|
|
52
|
+
sfuSinkId: config.sfuSinkId,
|
|
53
|
+
});
|
|
54
|
+
const alreadyInserted = yield storageProvider.inboundTrackStorage.insert(config.trackId, model);
|
|
55
|
+
if (alreadyInserted)
|
|
56
|
+
throw new Error(`InboundAudioTrack with id ${config.trackId} already exists`);
|
|
57
|
+
return new ObservedInboundTrack(model, peerConnection, storageProvider);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
constructor(_model, peerConnection, _storageProvider) {
|
|
61
|
+
super();
|
|
62
|
+
this._model = _model;
|
|
63
|
+
this.peerConnection = peerConnection;
|
|
64
|
+
this._storageProvider = _storageProvider;
|
|
65
|
+
this._stats = new Map();
|
|
66
|
+
this._execute = (0, SingleExecutor_1.createSingleExecutor)();
|
|
67
|
+
this._closed = false;
|
|
68
|
+
this._updated = Date.now();
|
|
69
|
+
this.bitrate = -1;
|
|
70
|
+
this.rttInMs = -1;
|
|
71
|
+
}
|
|
72
|
+
get serviceId() {
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
74
|
+
return this._model.serviceId;
|
|
75
|
+
}
|
|
76
|
+
get roomId() {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
78
|
+
return this._model.roomId;
|
|
79
|
+
}
|
|
80
|
+
get callId() {
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
82
|
+
return this._model.callId;
|
|
83
|
+
}
|
|
84
|
+
get clientId() {
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
86
|
+
return this._model.clientId;
|
|
87
|
+
}
|
|
88
|
+
get mediaUnitId() {
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
|
+
return this._model.mediaUnitId;
|
|
91
|
+
}
|
|
92
|
+
get peerConnectionId() {
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
94
|
+
return this._model.peerConnectionId;
|
|
95
|
+
}
|
|
96
|
+
get trackId() {
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
98
|
+
return this._model.trackId;
|
|
99
|
+
}
|
|
100
|
+
get kind() {
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
102
|
+
return this._model.kind;
|
|
103
|
+
}
|
|
104
|
+
get sfuStreamId() {
|
|
105
|
+
return this._model.sfuStreamId;
|
|
106
|
+
}
|
|
107
|
+
get sfuSinkId() {
|
|
108
|
+
return this._model.sfuSinkId;
|
|
109
|
+
}
|
|
110
|
+
get updated() {
|
|
111
|
+
return this._updated;
|
|
112
|
+
}
|
|
113
|
+
get stats() {
|
|
114
|
+
return this._stats;
|
|
115
|
+
}
|
|
116
|
+
get reports() {
|
|
117
|
+
return this.peerConnection.reports;
|
|
118
|
+
}
|
|
119
|
+
set remoteOutboundTrack(track) {
|
|
120
|
+
if (this._closed)
|
|
121
|
+
return;
|
|
122
|
+
if (this._remoteOutboundTrack)
|
|
123
|
+
return;
|
|
124
|
+
if (!track)
|
|
125
|
+
return;
|
|
126
|
+
track === null || track === void 0 ? void 0 : track.once('close', () => {
|
|
127
|
+
this._remoteOutboundTrack = undefined;
|
|
128
|
+
});
|
|
129
|
+
this._remoteOutboundTrack = track;
|
|
130
|
+
this.emit('remoteoutboundtrack', track);
|
|
131
|
+
}
|
|
132
|
+
get remoteOutboundTrack() {
|
|
133
|
+
return this._remoteOutboundTrack;
|
|
134
|
+
}
|
|
135
|
+
get closed() {
|
|
136
|
+
return this._closed;
|
|
137
|
+
}
|
|
138
|
+
close() {
|
|
139
|
+
if (this._closed)
|
|
140
|
+
return;
|
|
141
|
+
this._closed = true;
|
|
142
|
+
this._execute(() => this._storageProvider.inboundTrackStorage.remove(this.trackId))
|
|
143
|
+
.catch(() => void 0)
|
|
144
|
+
.finally(() => this.emit('close'));
|
|
145
|
+
}
|
|
146
|
+
update(sample, timestamp) {
|
|
147
|
+
var _a, _b, _c, _d, _e, _f;
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
if (this._closed)
|
|
150
|
+
return;
|
|
151
|
+
let executeSave = false;
|
|
152
|
+
const report = Object.assign(Object.assign({ serviceId: this.peerConnection.client.call.serviceId, roomId: this.peerConnection.client.call.roomId, callId: this.peerConnection.client.call.callId, clientId: this.peerConnection.client.clientId, userId: this.peerConnection.client.userId, mediaUnitId: this.peerConnection.client.mediaUnitId, peerConnectionId: this.peerConnection.peerConnectionId }, sample), { timestamp, sampleSeq: -1 });
|
|
153
|
+
if (this.kind === 'audio')
|
|
154
|
+
this.reports.addInboundAudioTrackReport(report);
|
|
155
|
+
else if (this.kind === 'video')
|
|
156
|
+
this.reports.addInboundVideoTrackReport(report);
|
|
157
|
+
if (!this._model.sfuStreamId && sample.sfuStreamId) {
|
|
158
|
+
this._model.sfuStreamId = sample.sfuStreamId;
|
|
159
|
+
executeSave = true;
|
|
160
|
+
}
|
|
161
|
+
if (!this._model.sfuSinkId && sample.sfuSinkId) {
|
|
162
|
+
this._model.sfuSinkId = sample.sfuSinkId;
|
|
163
|
+
executeSave = true;
|
|
164
|
+
}
|
|
165
|
+
const elapsedTimeInMs = Math.max(1, timestamp - this._updated);
|
|
166
|
+
const lastStat = this._stats.get(sample.ssrc);
|
|
167
|
+
const rttInMs = sample.roundTripTime ? sample.roundTripTime * 1000 : undefined;
|
|
168
|
+
const bitrate = (((_a = sample.bytesReceived) !== null && _a !== void 0 ? _a : 0) - ((_b = lastStat === null || lastStat === void 0 ? void 0 : lastStat.bytesReceived) !== null && _b !== void 0 ? _b : 0)) * 8 / (elapsedTimeInMs / 1000);
|
|
169
|
+
const lostPackets = ((_c = sample.packetsLost) !== null && _c !== void 0 ? _c : 0) - ((_d = lastStat === null || lastStat === void 0 ? void 0 : lastStat.packetsLost) !== null && _d !== void 0 ? _d : 0);
|
|
170
|
+
const receivedPackets = ((_e = sample.packetsReceived) !== null && _e !== void 0 ? _e : 0) - ((_f = lastStat === null || lastStat === void 0 ? void 0 : lastStat.packetsReceived) !== null && _f !== void 0 ? _f : 0);
|
|
171
|
+
const fractionLost = 0 < receivedPackets && 0 < lostPackets ? (lostPackets / (receivedPackets + lostPackets)) : 0;
|
|
172
|
+
const stats = Object.assign(Object.assign({}, sample), { fractionLost,
|
|
173
|
+
rttInMs,
|
|
174
|
+
bitrate, ssrc: sample.ssrc });
|
|
175
|
+
this._stats.set(sample.ssrc, stats);
|
|
176
|
+
this.bitrate = [...this._stats.values()].reduce((acc, stat) => acc + stat.bitrate, 0);
|
|
177
|
+
this.rttInMs = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.rttInMs) !== null && _a !== void 0 ? _a : 0); }, 0) / (this._stats.size || 1);
|
|
178
|
+
if (executeSave)
|
|
179
|
+
yield this._save();
|
|
180
|
+
this._updated = timestamp;
|
|
181
|
+
this.emit('update');
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
_save() {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
if (this._closed)
|
|
187
|
+
throw new Error(`OutboundTrack ${this.trackId} is closed`);
|
|
188
|
+
return this._storageProvider.inboundTrackStorage.set(this.trackId, this._model);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.ObservedInboundTrack = ObservedInboundTrack;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { StorageProvider } from './storages/StorageProvider';
|
|
4
|
+
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
5
|
+
import { OutboundAudioTrack, OutboundVideoTrack } from '@observertc/sample-schemas-js';
|
|
6
|
+
import { ObservedInboundTrack } from './ObservedInboundTrack';
|
|
7
|
+
import { MediaKind } from './common/types';
|
|
8
|
+
export type ObservedOutboundTrackConfig<K extends MediaKind> = {
|
|
9
|
+
trackId: string;
|
|
10
|
+
kind: K;
|
|
11
|
+
sfuStreamId?: string;
|
|
12
|
+
};
|
|
13
|
+
export type ObservedOutboundTrackEvents = {
|
|
14
|
+
update: [];
|
|
15
|
+
close: [];
|
|
16
|
+
};
|
|
17
|
+
export type ObservedOutboundTrackStatsUpdate<K extends MediaKind> = K extends 'audio' ? OutboundAudioTrack : OutboundVideoTrack;
|
|
18
|
+
export type ObservedOutboundTrackStats<K extends MediaKind> = ObservedOutboundTrackStatsUpdate<K> & {
|
|
19
|
+
ssrc: number;
|
|
20
|
+
bitrate: number;
|
|
21
|
+
rttInMs?: number;
|
|
22
|
+
};
|
|
23
|
+
export declare interface ObservedOutboundTrack<Kind extends MediaKind> {
|
|
24
|
+
on<U extends keyof ObservedOutboundTrackEvents>(event: U, listener: (...args: ObservedOutboundTrackEvents[U]) => void): this;
|
|
25
|
+
off<U extends keyof ObservedOutboundTrackEvents>(event: U, listener: (...args: ObservedOutboundTrackEvents[U]) => void): this;
|
|
26
|
+
once<U extends keyof ObservedOutboundTrackEvents>(event: U, listener: (...args: ObservedOutboundTrackEvents[U]) => void): this;
|
|
27
|
+
emit<U extends keyof ObservedOutboundTrackEvents>(event: U, ...args: ObservedOutboundTrackEvents[U]): boolean;
|
|
28
|
+
update(sample: ObservedOutboundTrackStatsUpdate<Kind>, timestamp: number): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class ObservedOutboundTrack<Kind extends MediaKind> extends EventEmitter {
|
|
31
|
+
private readonly _model;
|
|
32
|
+
readonly peerConnection: ObservedPeerConnection;
|
|
33
|
+
private readonly _storageProvider;
|
|
34
|
+
static create<K extends MediaKind>(config: ObservedOutboundTrackConfig<K>, peerConnection: ObservedPeerConnection, storageProvider: StorageProvider): Promise<ObservedOutboundTrack<K>>;
|
|
35
|
+
bitrate?: number;
|
|
36
|
+
rttInMs?: number;
|
|
37
|
+
private readonly _stats;
|
|
38
|
+
private readonly _execute;
|
|
39
|
+
private _closed;
|
|
40
|
+
private _updated;
|
|
41
|
+
private _remoteInboundTracks;
|
|
42
|
+
private constructor();
|
|
43
|
+
get kind(): Kind;
|
|
44
|
+
get trackId(): string;
|
|
45
|
+
get sfuStreamId(): string | undefined;
|
|
46
|
+
get closed(): boolean;
|
|
47
|
+
get remoteInboundTracks(): ReadonlyMap<string, ObservedInboundTrack<Kind>>;
|
|
48
|
+
get reports(): import("./ReportsCollector").ReportsCollector;
|
|
49
|
+
get updated(): number;
|
|
50
|
+
close(): void;
|
|
51
|
+
get stats(): ReadonlyMap<number, ObservedOutboundTrackStats<Kind>>;
|
|
52
|
+
connectInboundTrack(track: ObservedInboundTrack<Kind>): void;
|
|
53
|
+
private _save;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=ObservedOutboundTrack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservedOutboundTrack.d.ts","sourceRoot":"","sources":["../src/ObservedOutboundTrack.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,SAAS,IAAI;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACzC,MAAM,EAAE,EAAE,CAAC;IACX,KAAK,EAAE,EAAE,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,gCAAgC,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS,OAA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AC,CAAC,SAAS,SAAS,EAC7C,MAAM,EAAE,2BAA2B,CAAC,CAAC,CAAC,EACtC,cAAc,EAAE,sBAAsB,EACtC,eAAe,EAAE,eAAe;IAqB1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;IAC9E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAEnD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,oBAAoB,CAAiD;IAE7E,OAAO;IAQP,IAAW,IAAI,IAAI,IAAI,CAGtB;IAED,IAAW,OAAO,WAGjB;IAED,IAAW,WAAW,uBAErB;IAED,IAAW,MAAM,YAEhB;IAED,IAAW,mBAAmB,IAAI,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAEhF;IAED,IAAW,OAAO,kDAEjB;IAED,IAAW,OAAO,WAEjB;IAEM,KAAK;IAUZ,IAAW,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAExE;IA8DM,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,CAAC,IAAI,CAAC;YAW9C,KAAK;CAKnB"}
|
|
@@ -0,0 +1,166 @@
|
|
|
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.ObservedOutboundTrack = void 0;
|
|
36
|
+
const events_1 = require("events");
|
|
37
|
+
const Models = __importStar(require("./models/Models"));
|
|
38
|
+
const SingleExecutor_1 = require("./common/SingleExecutor");
|
|
39
|
+
class ObservedOutboundTrack extends events_1.EventEmitter {
|
|
40
|
+
static create(config, peerConnection, storageProvider) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const model = new Models.OutboundTrack({
|
|
43
|
+
serviceId: peerConnection.client.serviceId,
|
|
44
|
+
roomId: peerConnection.client.roomId,
|
|
45
|
+
callId: peerConnection.client.callId,
|
|
46
|
+
clientId: peerConnection.client.clientId,
|
|
47
|
+
mediaUnitId: peerConnection.client.mediaUnitId,
|
|
48
|
+
peerConnectionId: peerConnection.peerConnectionId,
|
|
49
|
+
trackId: config.trackId,
|
|
50
|
+
kind: config.kind,
|
|
51
|
+
sfuStreamId: config.sfuStreamId,
|
|
52
|
+
});
|
|
53
|
+
const alreadyInserted = yield storageProvider.outboundTrackStorage.insert(config.trackId, model);
|
|
54
|
+
if (alreadyInserted)
|
|
55
|
+
throw new Error(`OutboundAudioTrack with id ${config.trackId} already exists`);
|
|
56
|
+
return new ObservedOutboundTrack(model, peerConnection, storageProvider);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
constructor(_model, peerConnection, _storageProvider) {
|
|
60
|
+
super();
|
|
61
|
+
this._model = _model;
|
|
62
|
+
this.peerConnection = peerConnection;
|
|
63
|
+
this._storageProvider = _storageProvider;
|
|
64
|
+
this._stats = new Map();
|
|
65
|
+
this._execute = (0, SingleExecutor_1.createSingleExecutor)();
|
|
66
|
+
this._closed = false;
|
|
67
|
+
this._updated = Date.now();
|
|
68
|
+
this._remoteInboundTracks = new Map();
|
|
69
|
+
}
|
|
70
|
+
get kind() {
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
return this._model.kind;
|
|
73
|
+
}
|
|
74
|
+
get trackId() {
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
76
|
+
return this._model.trackId;
|
|
77
|
+
}
|
|
78
|
+
get sfuStreamId() {
|
|
79
|
+
return this._model.sfuStreamId;
|
|
80
|
+
}
|
|
81
|
+
get closed() {
|
|
82
|
+
return this._closed;
|
|
83
|
+
}
|
|
84
|
+
get remoteInboundTracks() {
|
|
85
|
+
return this._remoteInboundTracks;
|
|
86
|
+
}
|
|
87
|
+
get reports() {
|
|
88
|
+
return this.peerConnection.reports;
|
|
89
|
+
}
|
|
90
|
+
get updated() {
|
|
91
|
+
return this._updated;
|
|
92
|
+
}
|
|
93
|
+
close() {
|
|
94
|
+
if (this._closed)
|
|
95
|
+
return;
|
|
96
|
+
this._closed = true;
|
|
97
|
+
this._execute(() => this._storageProvider.inboundTrackStorage.remove(this.trackId))
|
|
98
|
+
.catch(() => void 0)
|
|
99
|
+
.finally(() => this.emit('close'));
|
|
100
|
+
}
|
|
101
|
+
get stats() {
|
|
102
|
+
return this._stats;
|
|
103
|
+
}
|
|
104
|
+
update(sample, timestamp) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
if (this._closed)
|
|
108
|
+
return;
|
|
109
|
+
let executeSave = false;
|
|
110
|
+
const report = Object.assign(Object.assign({ serviceId: this.peerConnection.client.serviceId, roomId: this.peerConnection.client.call.roomId, callId: this.peerConnection.client.call.callId, clientId: this.peerConnection.client.clientId, userId: this.peerConnection.client.userId, mediaUnitId: this.peerConnection.client.mediaUnitId, peerConnectionId: this.peerConnection.peerConnectionId }, sample), { timestamp, sampleSeq: -1 });
|
|
111
|
+
if (this.kind === 'audio')
|
|
112
|
+
this.reports.addOutboundAudioTrackReport(report);
|
|
113
|
+
else if (this.kind === 'video')
|
|
114
|
+
this.reports.addOutboundVideoTrackReport(report);
|
|
115
|
+
const elapsedTimeInMs = Math.max(1, timestamp - this._updated);
|
|
116
|
+
const lastStat = this._stats.get(sample.ssrc);
|
|
117
|
+
const rttInMs = sample.roundTripTime ? sample.roundTripTime * 1000 : undefined;
|
|
118
|
+
const bitrate = (((_a = sample.bytesSent) !== null && _a !== void 0 ? _a : 0) - ((_b = lastStat === null || lastStat === void 0 ? void 0 : lastStat.bytesSent) !== null && _b !== void 0 ? _b : 0)) * 8 / (elapsedTimeInMs / 1000);
|
|
119
|
+
// const lostPackets = (sample.packetsLost ?? 0) - (lastStat?.packetsLost ?? 0);
|
|
120
|
+
// const sentPackets = (sample.packetsSent ?? 0) - (lastStat?.packetsSent ?? 0);
|
|
121
|
+
const stats = Object.assign(Object.assign({}, sample), { rttInMs,
|
|
122
|
+
bitrate, ssrc: sample.ssrc });
|
|
123
|
+
this._stats.set(sample.ssrc, stats);
|
|
124
|
+
this.bitrate = [...this._stats.values()].reduce((acc, stat) => acc + stat.bitrate, 0);
|
|
125
|
+
this.rttInMs = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.rttInMs) !== null && _a !== void 0 ? _a : 0); }, 0) / (this._stats.size || 1);
|
|
126
|
+
// setting up sfu connection as it is not always available at the first sample
|
|
127
|
+
if (sample.sfuStreamId && !this._model.sfuStreamId) {
|
|
128
|
+
this._model.sfuStreamId = sample.sfuStreamId;
|
|
129
|
+
this.once('close', () => {
|
|
130
|
+
if (!this._model.sfuStreamId)
|
|
131
|
+
return;
|
|
132
|
+
if (this.kind === 'audio')
|
|
133
|
+
this.peerConnection.client.call.sfuStreamIdToOutboundAudioTrack.delete(this._model.sfuStreamId);
|
|
134
|
+
else if (this.kind === 'video')
|
|
135
|
+
this.peerConnection.client.call.sfuStreamIdToOutboundVideoTrack.delete(this._model.sfuStreamId);
|
|
136
|
+
});
|
|
137
|
+
if (this.kind === 'audio')
|
|
138
|
+
this.peerConnection.client.call.sfuStreamIdToOutboundAudioTrack.set(this._model.sfuStreamId, this);
|
|
139
|
+
else if (this.kind === 'video')
|
|
140
|
+
this.peerConnection.client.call.sfuStreamIdToOutboundVideoTrack.set(this._model.sfuStreamId, this);
|
|
141
|
+
executeSave = true;
|
|
142
|
+
}
|
|
143
|
+
if (executeSave)
|
|
144
|
+
yield this._save();
|
|
145
|
+
this._updated = timestamp;
|
|
146
|
+
this.emit('update');
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
connectInboundTrack(track) {
|
|
150
|
+
if (this._closed)
|
|
151
|
+
return;
|
|
152
|
+
track.remoteOutboundTrack = this;
|
|
153
|
+
track.once('close', () => {
|
|
154
|
+
this._remoteInboundTracks.delete(track.trackId);
|
|
155
|
+
});
|
|
156
|
+
this._remoteInboundTracks.set(track.trackId, track);
|
|
157
|
+
}
|
|
158
|
+
_save() {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
if (this._closed)
|
|
161
|
+
throw new Error(`OutboundTrack ${this.trackId} is closed`);
|
|
162
|
+
return this._storageProvider.outboundTrackStorage.set(this.trackId, this._model);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.ObservedOutboundTrack = ObservedOutboundTrack;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { StorageProvider } from './storages/StorageProvider';
|
|
4
|
+
import { PeerConnectionTransport } from '@observertc/sample-schemas-js';
|
|
5
|
+
import { ObservedClient } from './ObservedClient';
|
|
6
|
+
import { ObservedInboundTrack, ObservedInboundTrackConfig } from './ObservedInboundTrack';
|
|
7
|
+
import { ObservedOutboundTrack, ObservedOutboundTrackConfig } from './ObservedOutboundTrack';
|
|
8
|
+
export type ObservedPeerConnectionEvents = {
|
|
9
|
+
update: [];
|
|
10
|
+
close: [];
|
|
11
|
+
newinboudaudiotrack: [ObservedInboundTrack<'audio'>];
|
|
12
|
+
newinboudvideotrack: [ObservedInboundTrack<'video'>];
|
|
13
|
+
newoutboundaudiotrack: [ObservedOutboundTrack<'audio'>];
|
|
14
|
+
newoutboundvideotrack: [ObservedOutboundTrack<'video'>];
|
|
15
|
+
};
|
|
16
|
+
export type ObservedPeerConnectionConfig = {
|
|
17
|
+
peerConnectionId: string;
|
|
18
|
+
};
|
|
19
|
+
export type ObservedPeerConnectionStats = Omit<PeerConnectionTransport, 'transportId' | 'label'>;
|
|
20
|
+
export declare interface ObservedPeerConnection {
|
|
21
|
+
on<U extends keyof ObservedPeerConnectionEvents>(event: U, listener: (...args: ObservedPeerConnectionEvents[U]) => void): this;
|
|
22
|
+
off<U extends keyof ObservedPeerConnectionEvents>(event: U, listener: (...args: ObservedPeerConnectionEvents[U]) => void): this;
|
|
23
|
+
once<U extends keyof ObservedPeerConnectionEvents>(event: U, listener: (...args: ObservedPeerConnectionEvents[U]) => void): this;
|
|
24
|
+
emit<U extends keyof ObservedPeerConnectionEvents>(event: U, ...args: ObservedPeerConnectionEvents[U]): boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare class ObservedPeerConnection extends EventEmitter {
|
|
27
|
+
private readonly _model;
|
|
28
|
+
readonly client: ObservedClient;
|
|
29
|
+
private readonly _storageProvider;
|
|
30
|
+
static create(config: ObservedPeerConnectionConfig, client: ObservedClient, storageProvider: StorageProvider): Promise<ObservedPeerConnection>;
|
|
31
|
+
private _closed;
|
|
32
|
+
private _updated;
|
|
33
|
+
private _sample?;
|
|
34
|
+
private readonly _inboundAudioTracks;
|
|
35
|
+
private readonly _inboundVideoTracks;
|
|
36
|
+
private readonly _outboundAudioTracks;
|
|
37
|
+
private readonly _outboundVideoTracks;
|
|
38
|
+
private readonly _execute;
|
|
39
|
+
private constructor();
|
|
40
|
+
get peerConnectionId(): string;
|
|
41
|
+
get reports(): import("./ReportsCollector").ReportsCollector;
|
|
42
|
+
get stats(): ObservedPeerConnectionStats | undefined;
|
|
43
|
+
get updated(): number;
|
|
44
|
+
get inboundAudioTracks(): ReadonlyMap<string, ObservedInboundTrack<'audio'>>;
|
|
45
|
+
get inboundVideoTracks(): ReadonlyMap<string, ObservedInboundTrack<'video'>>;
|
|
46
|
+
get outboundAudioTracks(): ReadonlyMap<string, ObservedOutboundTrack<'audio'>>;
|
|
47
|
+
get outboundVideoTracks(): ReadonlyMap<string, ObservedOutboundTrack<'video'>>;
|
|
48
|
+
get closed(): boolean;
|
|
49
|
+
close(): void;
|
|
50
|
+
update(sample: PeerConnectionTransport, timestamp: number): void;
|
|
51
|
+
createInboundAudioTrack(config: Omit<ObservedInboundTrackConfig<'audio'>, 'kind'>): Promise<ObservedInboundTrack<'audio'>>;
|
|
52
|
+
createInboundVideoTrack(config: Omit<ObservedInboundTrackConfig<'video'>, 'kind'>): Promise<ObservedInboundTrack<'video'>>;
|
|
53
|
+
createOutboundAudioTrack(config: Omit<ObservedOutboundTrackConfig<'audio'>, 'kind'>): Promise<ObservedOutboundTrack<'audio'>>;
|
|
54
|
+
createOutboundVideoTrack(config: Omit<ObservedOutboundTrackConfig<'video'>, 'kind'>): Promise<ObservedOutboundTrack<'video'>>;
|
|
55
|
+
private _save;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=ObservedPeerConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservedPeerConnection.d.ts","sourceRoot":"","sources":["../src/ObservedPeerConnection.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAI7F,MAAM,MAAM,4BAA4B,GAAG;IAC1C,MAAM,EAAE,EAAE,CAAC;IACX,KAAK,EAAE,EAAE,CAAC;IACV,mBAAmB,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,mBAAmB,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,qBAAqB,EAAE,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,qBAAqB,EAAE,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IAC1C,gBAAgB,EAAE,MAAM,CAAC;CAC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