@observertc/observer-js 1.0.1-f31d7a4.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +2184 -1
  2. package/dist/index.d.mts +6842 -0
  3. package/dist/index.d.ts +6842 -0
  4. package/dist/index.js +7736 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +7608 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +44 -18
  9. package/.eslintrc.json +0 -143
  10. package/.prettierignore +0 -5
  11. package/.prettierrc +0 -7
  12. package/jest.config.js +0 -9
  13. package/lib/ObservedCall.d.ts +0 -62
  14. package/lib/ObservedCall.d.ts.map +0 -1
  15. package/lib/ObservedCall.js +0 -127
  16. package/lib/ObservedCertificate.d.ts +0 -19
  17. package/lib/ObservedCertificate.d.ts.map +0 -1
  18. package/lib/ObservedCertificate.js +0 -38
  19. package/lib/ObservedClient.d.ts +0 -104
  20. package/lib/ObservedClient.d.ts.map +0 -1
  21. package/lib/ObservedClient.js +0 -250
  22. package/lib/ObservedCodec.d.ts +0 -22
  23. package/lib/ObservedCodec.d.ts.map +0 -1
  24. package/lib/ObservedCodec.js +0 -45
  25. package/lib/ObservedDataChannel.d.ts +0 -28
  26. package/lib/ObservedDataChannel.d.ts.map +0 -1
  27. package/lib/ObservedDataChannel.js +0 -73
  28. package/lib/ObservedIceCandidate.d.ts +0 -29
  29. package/lib/ObservedIceCandidate.d.ts.map +0 -1
  30. package/lib/ObservedIceCandidate.js +0 -59
  31. package/lib/ObservedIceCandidatePair.d.ts +0 -44
  32. package/lib/ObservedIceCandidatePair.d.ts.map +0 -1
  33. package/lib/ObservedIceCandidatePair.js +0 -111
  34. package/lib/ObservedIceTransport.d.ts +0 -32
  35. package/lib/ObservedIceTransport.d.ts.map +0 -1
  36. package/lib/ObservedIceTransport.js +0 -65
  37. package/lib/ObservedInboundRtp.d.ts +0 -92
  38. package/lib/ObservedInboundRtp.d.ts.map +0 -1
  39. package/lib/ObservedInboundRtp.js +0 -193
  40. package/lib/ObservedInboundTrack.d.ts +0 -29
  41. package/lib/ObservedInboundTrack.d.ts.map +0 -1
  42. package/lib/ObservedInboundTrack.js +0 -57
  43. package/lib/ObservedMediaPlayout.d.ts +0 -22
  44. package/lib/ObservedMediaPlayout.d.ts.map +0 -1
  45. package/lib/ObservedMediaPlayout.js +0 -42
  46. package/lib/ObservedMediaSource.d.ts +0 -28
  47. package/lib/ObservedMediaSource.d.ts.map +0 -1
  48. package/lib/ObservedMediaSource.js +0 -55
  49. package/lib/ObservedOutboundRtp.d.ts +0 -62
  50. package/lib/ObservedOutboundRtp.d.ts.map +0 -1
  51. package/lib/ObservedOutboundRtp.js +0 -144
  52. package/lib/ObservedOutboundTrack.d.ts +0 -29
  53. package/lib/ObservedOutboundTrack.d.ts.map +0 -1
  54. package/lib/ObservedOutboundTrack.js +0 -57
  55. package/lib/ObservedPeerConnection.d.ts +0 -183
  56. package/lib/ObservedPeerConnection.d.ts.map +0 -1
  57. package/lib/ObservedPeerConnection.js +0 -688
  58. package/lib/ObservedPeerConnectionTransport.d.ts +0 -17
  59. package/lib/ObservedPeerConnectionTransport.d.ts.map +0 -1
  60. package/lib/ObservedPeerConnectionTransport.js +0 -34
  61. package/lib/ObservedRemoteInboundRtp.d.ts +0 -30
  62. package/lib/ObservedRemoteInboundRtp.d.ts.map +0 -1
  63. package/lib/ObservedRemoteInboundRtp.js +0 -60
  64. package/lib/ObservedRemoteOutboundRtp.d.ts +0 -30
  65. package/lib/ObservedRemoteOutboundRtp.d.ts.map +0 -1
  66. package/lib/ObservedRemoteOutboundRtp.js +0 -60
  67. package/lib/ObservedTURN.d.ts +0 -30
  68. package/lib/ObservedTURN.d.ts.map +0 -1
  69. package/lib/ObservedTURN.js +0 -54
  70. package/lib/ObservedTurnServer.d.ts +0 -25
  71. package/lib/ObservedTurnServer.d.ts.map +0 -1
  72. package/lib/ObservedTurnServer.js +0 -59
  73. package/lib/Observer.d.ts +0 -50
  74. package/lib/Observer.d.ts.map +0 -1
  75. package/lib/Observer.js +0 -101
  76. package/lib/common/Middleware.d.ts +0 -17
  77. package/lib/common/Middleware.d.ts.map +0 -1
  78. package/lib/common/Middleware.js +0 -60
  79. package/lib/common/SingleExecutor.d.ts +0 -3
  80. package/lib/common/SingleExecutor.d.ts.map +0 -1
  81. package/lib/common/SingleExecutor.js +0 -31
  82. package/lib/common/logger.d.ts +0 -17
  83. package/lib/common/logger.d.ts.map +0 -1
  84. package/lib/common/logger.js +0 -50
  85. package/lib/common/types.d.ts +0 -3
  86. package/lib/common/types.d.ts.map +0 -1
  87. package/lib/common/types.js +0 -3
  88. package/lib/common/utils.d.ts +0 -10
  89. package/lib/common/utils.d.ts.map +0 -1
  90. package/lib/common/utils.js +0 -55
  91. package/lib/detectors/Detector.d.ts +0 -5
  92. package/lib/detectors/Detector.d.ts.map +0 -1
  93. package/lib/detectors/Detector.js +0 -3
  94. package/lib/detectors/Detectors.d.ts +0 -11
  95. package/lib/detectors/Detectors.d.ts.map +0 -1
  96. package/lib/detectors/Detectors.js +0 -34
  97. package/lib/index.d.ts +0 -26
  98. package/lib/index.d.ts.map +0 -1
  99. package/lib/index.js +0 -41
  100. package/lib/monitors/TurnUsageMonitor.d.ts +0 -1
  101. package/lib/monitors/TurnUsageMonitor.d.ts.map +0 -1
  102. package/lib/monitors/TurnUsageMonitor.js +0 -146
  103. package/lib/schema/ClientEventTypes.d.ts +0 -33
  104. package/lib/schema/ClientEventTypes.d.ts.map +0 -1
  105. package/lib/schema/ClientEventTypes.js +0 -38
  106. package/lib/schema/ClientMetaTypes.d.ts +0 -34
  107. package/lib/schema/ClientMetaTypes.d.ts.map +0 -1
  108. package/lib/schema/ClientMetaTypes.js +0 -16
  109. package/lib/schema/ClientSample.d.ts +0 -1333
  110. package/lib/schema/ClientSample.d.ts.map +0 -1
  111. package/lib/schema/ClientSample.js +0 -4
  112. package/lib/scores/CalculatedScore.d.ts +0 -6
  113. package/lib/scores/CalculatedScore.d.ts.map +0 -1
  114. package/lib/scores/CalculatedScore.js +0 -2
  115. package/lib/scores/DefaultCallScoreCalculator.d.ts +0 -7
  116. package/lib/scores/DefaultCallScoreCalculator.d.ts.map +0 -1
  117. package/lib/scores/DefaultCallScoreCalculator.js +0 -21
  118. package/lib/scores/ScoreCalculator.d.ts +0 -4
  119. package/lib/scores/ScoreCalculator.d.ts.map +0 -1
  120. package/lib/scores/ScoreCalculator.js +0 -2
  121. package/lib/utils/CallUpdater.d.ts +0 -5
  122. package/lib/utils/CallUpdater.d.ts.map +0 -1
  123. package/lib/utils/CallUpdater.js +0 -2
  124. package/lib/utils/OnAllClientCallUpdater.d.ts +0 -16
  125. package/lib/utils/OnAllClientCallUpdater.d.ts.map +0 -1
  126. package/lib/utils/OnAllClientCallUpdater.js +0 -58
  127. package/lib/utils/RemoteTrackResolver.d.ts +0 -7
  128. package/lib/utils/RemoteTrackResolver.d.ts.map +0 -1
  129. package/lib/utils/RemoteTrackResolver.js +0 -2
  130. package/lib/utils/onAnyClientCallUpdater.d.ts +0 -14
  131. package/lib/utils/onAnyClientCallUpdater.d.ts.map +0 -1
  132. package/lib/utils/onAnyClientCallUpdater.js +0 -51
  133. package/src/ObservedCall.ts +0 -176
  134. package/src/ObservedCertificate.ts +0 -43
  135. package/src/ObservedClient.ts +0 -324
  136. package/src/ObservedCodec.ts +0 -49
  137. package/src/ObservedDataChannel.ts +0 -82
  138. package/src/ObservedIceCandidate.ts +0 -64
  139. package/src/ObservedIceCandidatePair.ts +0 -118
  140. package/src/ObservedIceTransport.ts +0 -70
  141. package/src/ObservedInboundRtp.ts +0 -205
  142. package/src/ObservedInboundTrack.ts +0 -70
  143. package/src/ObservedMediaPlayout.ts +0 -49
  144. package/src/ObservedMediaSource.ts +0 -60
  145. package/src/ObservedOutboundRtp.ts +0 -156
  146. package/src/ObservedOutboundTrack.ts +0 -69
  147. package/src/ObservedPeerConnection.ts +0 -995
  148. package/src/ObservedPeerConnectionTransport.ts +0 -38
  149. package/src/ObservedRemoteInboundRtp.ts +0 -64
  150. package/src/ObservedRemoteOutboundRtp.ts +0 -65
  151. package/src/ObservedTURN.ts +0 -80
  152. package/src/ObservedTurnServer.ts +0 -72
  153. package/src/Observer.ts +0 -152
  154. package/src/common/Middleware.ts +0 -84
  155. package/src/common/SingleExecutor.ts +0 -36
  156. package/src/common/logger.ts +0 -82
  157. package/src/common/types.ts +0 -4
  158. package/src/common/utils.ts +0 -59
  159. package/src/detectors/Detector.ts +0 -6
  160. package/src/detectors/Detectors.ts +0 -38
  161. package/src/index.ts +0 -27
  162. package/src/monitors/TurnUsageMonitor.ts +0 -187
  163. package/src/schema/ClientEventTypes.ts +0 -36
  164. package/src/schema/ClientMetaTypes.ts +0 -41
  165. package/src/schema/ClientSample.ts +0 -1682
  166. package/src/scores/CalculatedScore.ts +0 -6
  167. package/src/scores/DefaultCallScoreCalculator.ts +0 -23
  168. package/src/scores/ScoreCalculator.ts +0 -3
  169. package/src/utils/CallUpdater.ts +0 -5
  170. package/src/utils/OnAllClientCallUpdater.ts +0 -68
  171. package/src/utils/RemoteTrackResolver.ts +0 -12
  172. package/src/utils/onAnyClientCallUpdater.ts +0 -59
  173. package/tsconfig.json +0 -19
  174. package/tslint.json +0 -6
@@ -1,6 +0,0 @@
1
-
2
- export type CalculatedScore = {
3
- weight: number;
4
- value?: number;
5
- appData?: Record<string, unknown>;
6
- };
@@ -1,23 +0,0 @@
1
- import { ObservedCall } from '../ObservedCall';
2
-
3
- export class DefaultCallScoreCalculator {
4
-
5
- public constructor(
6
- public readonly observedCall: ObservedCall,
7
- ) {
8
- }
9
-
10
- public update() {
11
- let totalScore = 0;
12
- let totalWeight = 0;
13
-
14
- for (const client of this.observedCall.observedClients.values()) {
15
- if (client.score === undefined) continue;
16
-
17
- totalScore += client.score * client.calculatedScore.weight;
18
- totalWeight += client.calculatedScore.weight;
19
- }
20
-
21
- this.observedCall.calculatedScore.value = totalWeight ? totalScore / totalWeight : undefined;
22
- }
23
- }
@@ -1,3 +0,0 @@
1
- export interface ScoreCalculator {
2
- update(): void;
3
- }
@@ -1,5 +0,0 @@
1
- import { ObservedClient } from '../ObservedClient';
2
-
3
- export interface CallUpdater {
4
- onClientUpdate(observedClient: ObservedClient): void;
5
- }
@@ -1,68 +0,0 @@
1
- import { ObservedCall } from '../ObservedCall';
2
- import { ObservedClient } from '../ObservedClient';
3
- import { CallUpdater } from './CallUpdater';
4
-
5
- export class OnAllClientCallUpdater implements CallUpdater {
6
-
7
- private readonly _updatedClients = new Set<string>();
8
- private _minClientJoinedTimestamp?: number;
9
- private _maxClientLeftTimestamp?: number;
10
-
11
- public constructor(
12
- private _observedCall: ObservedCall
13
- ) {
14
- this._onNewObservedClient = this._onNewObservedClient.bind(this);
15
- this._onCallEmpty = this._onCallEmpty.bind(this);
16
-
17
- this._observedCall.once('close', () => {
18
- this._observedCall.off('empty', this._onCallEmpty);
19
- this._observedCall.off('newclient', this._onNewObservedClient);
20
- });
21
- this._observedCall.on('newclient', this._onNewObservedClient);
22
- this._observedCall.on('empty', this._onCallEmpty);
23
- }
24
-
25
- public onClientUpdate(observedClient: ObservedClient) {
26
- this._updatedClients.add(observedClient.clientId);
27
-
28
- if (this._updatedClients.size < this._observedCall.observedClients.size) {
29
- return;
30
- }
31
- this._updatedClients.clear();
32
- this._observedCall.update();
33
- }
34
-
35
- private _onNewObservedClient(observedClient: ObservedClient) {
36
- const onJoined = () => this._onClientJoined(observedClient);
37
- const onLeft = () => this._onClientLeft(observedClient);
38
-
39
- observedClient.once('close', () => {
40
- observedClient.off('joined', onJoined);
41
- observedClient.off('left', onLeft);
42
- this._updatedClients.delete(observedClient.clientId);
43
- });
44
- observedClient.on('joined', onJoined);
45
- observedClient.on('left', onLeft);
46
- }
47
-
48
- private _onClientJoined(observedClient: ObservedClient) {
49
- if (!observedClient.joinedAt) return;
50
-
51
- if (!this._minClientJoinedTimestamp || observedClient.joinedAt < this._minClientJoinedTimestamp) {
52
- this._minClientJoinedTimestamp = observedClient.joinedAt;
53
- }
54
- }
55
-
56
- private _onClientLeft(observedClient: ObservedClient) {
57
- if (!observedClient.leftAt) return;
58
-
59
- if (!this._maxClientLeftTimestamp || observedClient.leftAt > this._maxClientLeftTimestamp) {
60
- this._maxClientLeftTimestamp = observedClient.leftAt;
61
- }
62
- }
63
-
64
- private _onCallEmpty() {
65
- this._observedCall.started = this._minClientJoinedTimestamp;
66
- this._observedCall.ended = this._maxClientLeftTimestamp;
67
- }
68
- }
@@ -1,12 +0,0 @@
1
- import { ObservedInboundTrack } from '../ObservedInboundTrack';
2
- import { ObservedOutboundTrack } from '../ObservedOutboundTrack';
3
-
4
- export interface RemoteTrackResolver {
5
- resolveRemoteOutboundTrack(
6
- inboundTrack: ObservedInboundTrack,
7
- ): ObservedOutboundTrack | undefined;
8
-
9
- resolveRemoteInboundTracks(
10
- outboundTrack: ObservedOutboundTrack,
11
- ): ObservedInboundTrack[] | undefined;
12
- }
@@ -1,59 +0,0 @@
1
- import { ObservedCall } from '../ObservedCall';
2
- import { ObservedClient } from '../ObservedClient';
3
- import { CallUpdater } from './CallUpdater';
4
-
5
- export class OnAnyClientCallUpdater implements CallUpdater {
6
- private _minClientJoinedTimestamp?: number;
7
- private _maxClientLeftTimestamp?: number;
8
-
9
- public constructor(
10
- private _observedCall: ObservedCall
11
- ) {
12
- this._onNewObservedClient = this._onNewObservedClient.bind(this);
13
- this._onCallEmpty = this._onCallEmpty.bind(this);
14
-
15
- this._observedCall.once('close', () => {
16
- this._observedCall.off('empty', this._onCallEmpty);
17
- this._observedCall.off('newclient', this._onNewObservedClient);
18
- });
19
- this._observedCall.on('newclient', this._onNewObservedClient);
20
- this._observedCall.on('empty', this._onCallEmpty);
21
- }
22
-
23
- public onClientUpdate() {
24
- this._observedCall.update();
25
- }
26
-
27
- private _onNewObservedClient(observedClient: ObservedClient) {
28
- const onJoined = () => this._onClientJoined(observedClient);
29
- const onLeft = () => this._onClientLeft(observedClient);
30
-
31
- observedClient.once('close', () => {
32
- observedClient.off('joined', onJoined);
33
- observedClient.off('left', onLeft);
34
- });
35
- observedClient.on('joined', onJoined);
36
- observedClient.on('left', onLeft);
37
- }
38
-
39
- private _onClientJoined(observedClient: ObservedClient) {
40
- if (!observedClient.joinedAt) return;
41
-
42
- if (!this._minClientJoinedTimestamp || observedClient.joinedAt < this._minClientJoinedTimestamp) {
43
- this._minClientJoinedTimestamp = observedClient.joinedAt;
44
- }
45
- }
46
-
47
- private _onClientLeft(observedClient: ObservedClient) {
48
- if (!observedClient.leftAt) return;
49
-
50
- if (!this._maxClientLeftTimestamp || observedClient.leftAt > this._maxClientLeftTimestamp) {
51
- this._maxClientLeftTimestamp = observedClient.leftAt;
52
- }
53
- }
54
-
55
- private _onCallEmpty() {
56
- this._observedCall.started = this._minClientJoinedTimestamp;
57
- this._observedCall.ended = this._maxClientLeftTimestamp;
58
- }
59
- }
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compileOnSave": true,
3
- "compilerOptions":
4
- {
5
- "lib": [ "ES2020" ],
6
- "target": "ESNext",
7
- "module": "CommonJS",
8
- "moduleResolution": "node",
9
- "esModuleInterop": true,
10
- "strict": true,
11
- "outDir": "lib",
12
- "declaration": true,
13
- "declarationMap": true,
14
- "experimentalDecorators": true,
15
- "emitDecoratorMetadata": true
16
- },
17
- "include": [ "src" ]
18
- }
19
-
package/tslint.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "rules": {
3
- "prefer-for-of": false
4
- },
5
- "extends": ["tslint:recommended", "tslint-config-prettier"]
6
- }