@observertc/observer-js 0.42.9 → 1.0.1-57a1811.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 (247) hide show
  1. package/.prettierrc +6 -6
  2. package/README.md +0 -104
  3. package/lib/ObservedCall.d.ts +38 -41
  4. package/lib/ObservedCall.d.ts.map +1 -1
  5. package/lib/ObservedCall.js +97 -109
  6. package/lib/ObservedCertificate.d.ts +19 -0
  7. package/lib/ObservedCertificate.d.ts.map +1 -0
  8. package/lib/ObservedCertificate.js +38 -0
  9. package/lib/ObservedClient.d.ts +49 -127
  10. package/lib/ObservedClient.d.ts.map +1 -1
  11. package/lib/ObservedClient.js +201 -750
  12. package/lib/ObservedCodec.d.ts +22 -0
  13. package/lib/ObservedCodec.d.ts.map +1 -0
  14. package/lib/ObservedCodec.js +45 -0
  15. package/lib/ObservedDataChannel.d.ts +23 -69
  16. package/lib/ObservedDataChannel.d.ts.map +1 -1
  17. package/lib/ObservedDataChannel.js +67 -109
  18. package/lib/ObservedIceCandidate.d.ts +29 -0
  19. package/lib/ObservedIceCandidate.d.ts.map +1 -0
  20. package/lib/ObservedIceCandidate.js +59 -0
  21. package/lib/ObservedIceCandidatePair.d.ts +44 -0
  22. package/lib/ObservedIceCandidatePair.d.ts.map +1 -0
  23. package/lib/ObservedIceCandidatePair.js +111 -0
  24. package/lib/ObservedIceTransport.d.ts +32 -0
  25. package/lib/ObservedIceTransport.d.ts.map +1 -0
  26. package/lib/ObservedIceTransport.js +65 -0
  27. package/lib/ObservedInboundRtp.d.ts +92 -0
  28. package/lib/ObservedInboundRtp.d.ts.map +1 -0
  29. package/lib/ObservedInboundRtp.js +193 -0
  30. package/lib/ObservedInboundTrack.d.ts +29 -0
  31. package/lib/ObservedInboundTrack.d.ts.map +1 -0
  32. package/lib/ObservedInboundTrack.js +57 -0
  33. package/lib/ObservedMediaPlayout.d.ts +22 -0
  34. package/lib/ObservedMediaPlayout.d.ts.map +1 -0
  35. package/lib/ObservedMediaPlayout.js +42 -0
  36. package/lib/ObservedMediaSource.d.ts +28 -0
  37. package/lib/ObservedMediaSource.d.ts.map +1 -0
  38. package/lib/ObservedMediaSource.js +55 -0
  39. package/lib/ObservedOutboundRtp.d.ts +62 -0
  40. package/lib/ObservedOutboundRtp.d.ts.map +1 -0
  41. package/lib/ObservedOutboundRtp.js +144 -0
  42. package/lib/ObservedOutboundTrack.d.ts +29 -0
  43. package/lib/ObservedOutboundTrack.d.ts.map +1 -0
  44. package/lib/ObservedOutboundTrack.js +57 -0
  45. package/lib/ObservedPeerConnection.d.ts +128 -78
  46. package/lib/ObservedPeerConnection.d.ts.map +1 -1
  47. package/lib/ObservedPeerConnection.js +624 -357
  48. package/lib/ObservedPeerConnectionTransport.d.ts +17 -0
  49. package/lib/ObservedPeerConnectionTransport.d.ts.map +1 -0
  50. package/lib/ObservedPeerConnectionTransport.js +34 -0
  51. package/lib/ObservedRemoteInboundRtp.d.ts +30 -0
  52. package/lib/ObservedRemoteInboundRtp.d.ts.map +1 -0
  53. package/lib/ObservedRemoteInboundRtp.js +60 -0
  54. package/lib/ObservedRemoteOutboundRtp.d.ts +30 -0
  55. package/lib/ObservedRemoteOutboundRtp.d.ts.map +1 -0
  56. package/lib/ObservedRemoteOutboundRtp.js +60 -0
  57. package/lib/ObservedTURN.d.ts +31 -0
  58. package/lib/ObservedTURN.d.ts.map +1 -0
  59. package/lib/ObservedTURN.js +58 -0
  60. package/lib/ObservedTurnServer.d.ts +25 -0
  61. package/lib/ObservedTurnServer.d.ts.map +1 -0
  62. package/lib/ObservedTurnServer.js +59 -0
  63. package/lib/Observer.d.ts +31 -51
  64. package/lib/Observer.d.ts.map +1 -1
  65. package/lib/Observer.js +75 -229
  66. package/lib/common/Middleware.d.ts +10 -1
  67. package/lib/common/Middleware.d.ts.map +1 -1
  68. package/lib/common/Middleware.js +55 -36
  69. package/lib/common/logger.d.ts +8 -4
  70. package/lib/common/logger.d.ts.map +1 -1
  71. package/lib/common/logger.js +44 -68
  72. package/lib/common/types.d.ts +0 -21
  73. package/lib/common/types.d.ts.map +1 -1
  74. package/lib/common/types.js +1 -0
  75. package/lib/common/utils.d.ts +1 -0
  76. package/lib/common/utils.d.ts.map +1 -1
  77. package/lib/common/utils.js +13 -1
  78. package/lib/detectors/Detector.d.ts +5 -0
  79. package/lib/detectors/Detector.d.ts.map +1 -0
  80. package/lib/detectors/Detector.js +3 -0
  81. package/lib/detectors/Detectors.d.ts +11 -0
  82. package/lib/detectors/Detectors.d.ts.map +1 -0
  83. package/lib/detectors/Detectors.js +34 -0
  84. package/lib/index.d.ts +24 -25
  85. package/lib/index.d.ts.map +1 -1
  86. package/lib/index.js +41 -41
  87. package/lib/monitors/TurnUsageMonitor.d.ts +0 -52
  88. package/lib/monitors/TurnUsageMonitor.d.ts.map +1 -1
  89. package/lib/monitors/TurnUsageMonitor.js +145 -120
  90. package/lib/schema/ClientEventTypes.d.ts +33 -0
  91. package/lib/schema/ClientEventTypes.d.ts.map +1 -0
  92. package/lib/schema/ClientEventTypes.js +38 -0
  93. package/lib/schema/ClientMetaTypes.d.ts +34 -0
  94. package/lib/schema/ClientMetaTypes.d.ts.map +1 -0
  95. package/lib/schema/ClientMetaTypes.js +16 -0
  96. package/lib/schema/ClientSample.d.ts +1333 -0
  97. package/lib/schema/ClientSample.d.ts.map +1 -0
  98. package/lib/schema/ClientSample.js +4 -0
  99. package/lib/scores/CalculatedScore.d.ts +6 -0
  100. package/lib/scores/CalculatedScore.d.ts.map +1 -0
  101. package/lib/scores/DefaultCallScoreCalculator.d.ts +7 -0
  102. package/lib/scores/DefaultCallScoreCalculator.d.ts.map +1 -0
  103. package/lib/scores/DefaultCallScoreCalculator.js +21 -0
  104. package/lib/scores/ScoreCalculator.d.ts +4 -0
  105. package/lib/scores/ScoreCalculator.d.ts.map +1 -0
  106. package/lib/scores/ScoreCalculator.js +2 -0
  107. package/lib/utils/CallUpdater.d.ts +5 -0
  108. package/lib/utils/CallUpdater.d.ts.map +1 -0
  109. package/lib/utils/CallUpdater.js +2 -0
  110. package/lib/utils/OnAllClientCallUpdater.d.ts +16 -0
  111. package/lib/utils/OnAllClientCallUpdater.d.ts.map +1 -0
  112. package/lib/utils/OnAllClientCallUpdater.js +58 -0
  113. package/lib/utils/RemoteTrackResolver.d.ts +7 -0
  114. package/lib/utils/RemoteTrackResolver.d.ts.map +1 -0
  115. package/lib/utils/RemoteTrackResolver.js +2 -0
  116. package/lib/utils/onAnyClientCallUpdater.d.ts +14 -0
  117. package/lib/utils/onAnyClientCallUpdater.d.ts.map +1 -0
  118. package/lib/utils/onAnyClientCallUpdater.js +51 -0
  119. package/package.json +4 -4
  120. package/src/ObservedCall.ts +116 -166
  121. package/src/ObservedCertificate.ts +43 -0
  122. package/src/ObservedClient.ts +213 -1060
  123. package/src/ObservedCodec.ts +49 -0
  124. package/src/ObservedDataChannel.ts +68 -181
  125. package/src/ObservedIceCandidate.ts +64 -0
  126. package/src/ObservedIceCandidatePair.ts +118 -0
  127. package/src/ObservedIceTransport.ts +70 -0
  128. package/src/ObservedInboundRtp.ts +205 -0
  129. package/src/ObservedInboundTrack.ts +70 -0
  130. package/src/ObservedMediaPlayout.ts +49 -0
  131. package/src/ObservedMediaSource.ts +60 -0
  132. package/src/ObservedOutboundRtp.ts +156 -0
  133. package/src/ObservedOutboundTrack.ts +69 -0
  134. package/src/ObservedPeerConnection.ts +827 -405
  135. package/src/ObservedPeerConnectionTransport.ts +38 -0
  136. package/src/ObservedRemoteInboundRtp.ts +64 -0
  137. package/src/ObservedRemoteOutboundRtp.ts +65 -0
  138. package/src/ObservedTURN.ts +86 -0
  139. package/src/ObservedTurnServer.ts +72 -0
  140. package/src/Observer.ts +91 -302
  141. package/src/common/Middleware.ts +70 -42
  142. package/src/common/logger.ts +60 -69
  143. package/src/common/types.ts +0 -42
  144. package/src/common/utils.ts +12 -0
  145. package/src/detectors/Detector.ts +6 -0
  146. package/src/detectors/Detectors.ts +38 -0
  147. package/src/index.ts +24 -90
  148. package/src/monitors/TurnUsageMonitor.ts +164 -164
  149. package/src/schema/ClientEventTypes.ts +36 -0
  150. package/src/schema/ClientMetaTypes.ts +41 -0
  151. package/src/schema/ClientSample.ts +1682 -0
  152. package/src/scores/CalculatedScore.ts +6 -0
  153. package/src/scores/DefaultCallScoreCalculator.ts +23 -0
  154. package/src/scores/ScoreCalculator.ts +3 -0
  155. package/src/utils/CallUpdater.ts +5 -0
  156. package/src/utils/OnAllClientCallUpdater.ts +68 -0
  157. package/src/utils/RemoteTrackResolver.ts +12 -0
  158. package/src/utils/onAnyClientCallUpdater.ts +59 -0
  159. package/tsconfig.json +3 -3
  160. package/lib/ObservedICE.d.ts +0 -64
  161. package/lib/ObservedICE.d.ts.map +0 -1
  162. package/lib/ObservedICE.js +0 -141
  163. package/lib/ObservedInboundAudioTrack.d.ts +0 -96
  164. package/lib/ObservedInboundAudioTrack.d.ts.map +0 -1
  165. package/lib/ObservedInboundAudioTrack.js +0 -217
  166. package/lib/ObservedInboundVideoTrack.d.ts +0 -101
  167. package/lib/ObservedInboundVideoTrack.d.ts.map +0 -1
  168. package/lib/ObservedInboundVideoTrack.js +0 -232
  169. package/lib/ObservedOutboundAudioTrack.d.ts +0 -87
  170. package/lib/ObservedOutboundAudioTrack.d.ts.map +0 -1
  171. package/lib/ObservedOutboundAudioTrack.js +0 -186
  172. package/lib/ObservedOutboundVideoTrack.d.ts +0 -91
  173. package/lib/ObservedOutboundVideoTrack.d.ts.map +0 -1
  174. package/lib/ObservedOutboundVideoTrack.js +0 -193
  175. package/lib/ObservedSfu.d.ts +0 -59
  176. package/lib/ObservedSfu.d.ts.map +0 -1
  177. package/lib/ObservedSfu.js +0 -157
  178. package/lib/ObservedSfuInboundRtpPad.d.ts +0 -42
  179. package/lib/ObservedSfuInboundRtpPad.d.ts.map +0 -1
  180. package/lib/ObservedSfuInboundRtpPad.js +0 -71
  181. package/lib/ObservedSfuOutboundRtpPad.d.ts +0 -42
  182. package/lib/ObservedSfuOutboundRtpPad.d.ts.map +0 -1
  183. package/lib/ObservedSfuOutboundRtpPad.js +0 -72
  184. package/lib/ObservedSfuSctpChannel.d.ts +0 -42
  185. package/lib/ObservedSfuSctpChannel.d.ts.map +0 -1
  186. package/lib/ObservedSfuSctpChannel.js +0 -57
  187. package/lib/ObservedSfuTransport.d.ts +0 -58
  188. package/lib/ObservedSfuTransport.d.ts.map +0 -1
  189. package/lib/ObservedSfuTransport.js +0 -120
  190. package/lib/RemoteTrackAssigner.d.ts +0 -14
  191. package/lib/RemoteTrackAssigner.d.ts.map +0 -1
  192. package/lib/RemoteTrackAssigner.js +0 -52
  193. package/lib/ReportsCollector.d.ts +0 -109
  194. package/lib/ReportsCollector.d.ts.map +0 -1
  195. package/lib/ReportsCollector.js +0 -207
  196. package/lib/common/CalculatedScore.d.ts +0 -80
  197. package/lib/common/CalculatedScore.d.ts.map +0 -1
  198. package/lib/common/CalculatedScore.js +0 -162
  199. package/lib/common/CallEventType.d.ts +0 -63
  200. package/lib/common/CallEventType.d.ts.map +0 -1
  201. package/lib/common/CallEventType.js +0 -39
  202. package/lib/common/CallMetaReports.d.ts +0 -42
  203. package/lib/common/CallMetaReports.d.ts.map +0 -1
  204. package/lib/common/CallMetaReports.js +0 -36
  205. package/lib/common/QualityScoreUtils.d.ts +0 -1
  206. package/lib/common/QualityScoreUtils.d.ts.map +0 -1
  207. package/lib/common/QualityScoreUtils.js +0 -1
  208. package/lib/common/TypedEventEmitter.d.ts +0 -22
  209. package/lib/common/TypedEventEmitter.d.ts.map +0 -1
  210. package/lib/common/TypedEventEmitter.js +0 -11
  211. package/lib/common/callEventReports.d.ts +0 -10
  212. package/lib/common/callEventReports.d.ts.map +0 -1
  213. package/lib/common/callEventReports.js +0 -112
  214. package/lib/monitors/CallSummary.d.ts +0 -37
  215. package/lib/monitors/CallSummary.d.ts.map +0 -1
  216. package/lib/monitors/CallSummaryMonitor.d.ts +0 -32
  217. package/lib/monitors/CallSummaryMonitor.d.ts.map +0 -1
  218. package/lib/monitors/CallSummaryMonitor.js +0 -152
  219. package/lib/monitors/ClientIssueMonitor.d.ts +0 -32
  220. package/lib/monitors/ClientIssueMonitor.d.ts.map +0 -1
  221. package/lib/monitors/ClientIssueMonitor.js +0 -49
  222. package/lib/monitors/SfuServerMonitor.d.ts +0 -79
  223. package/lib/monitors/SfuServerMonitor.d.ts.map +0 -1
  224. package/lib/monitors/SfuServerMonitor.js +0 -198
  225. package/src/ObservedICE.ts +0 -237
  226. package/src/ObservedInboundAudioTrack.ts +0 -344
  227. package/src/ObservedInboundVideoTrack.ts +0 -361
  228. package/src/ObservedOutboundAudioTrack.ts +0 -307
  229. package/src/ObservedOutboundVideoTrack.ts +0 -319
  230. package/src/ObservedSfu.ts +0 -231
  231. package/src/ObservedSfuInboundRtpPad.ts +0 -106
  232. package/src/ObservedSfuOutboundRtpPad.ts +0 -107
  233. package/src/ObservedSfuSctpChannel.ts +0 -103
  234. package/src/ObservedSfuTransport.ts +0 -185
  235. package/src/RemoteTrackAssigner.ts +0 -68
  236. package/src/ReportsCollector.ts +0 -336
  237. package/src/common/CalculatedScore.ts +0 -188
  238. package/src/common/CallEventType.ts +0 -69
  239. package/src/common/CallMetaReports.ts +0 -82
  240. package/src/common/QualityScoreUtils.ts +0 -0
  241. package/src/common/TypedEventEmitter.ts +0 -32
  242. package/src/common/callEventReports.ts +0 -178
  243. package/src/monitors/CallSummary.ts +0 -38
  244. package/src/monitors/CallSummaryMonitor.ts +0 -192
  245. package/src/monitors/ClientIssueMonitor.ts +0 -88
  246. package/src/monitors/SfuServerMonitor.ts +0 -285
  247. /package/lib/{monitors/CallSummary.js → scores/CalculatedScore.js} +0 -0
@@ -0,0 +1,205 @@
1
+ import { MediaKind } from './common/types';
2
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
3
+ import { InboundRtpStats } from './schema/ClientSample';
4
+
5
+ export class ObservedInboundRtp implements InboundRtpStats {
6
+ public appData?: Record<string, unknown>;
7
+
8
+ private _visited = false;
9
+
10
+ transportId?: string | undefined;
11
+ codecId?: string | undefined;
12
+ packetsReceived?: number | undefined;
13
+ packetsLost?: number | undefined;
14
+ mid?: string | undefined;
15
+ remoteId?: string | undefined;
16
+ framesDecoded?: number | undefined;
17
+ keyFramesDecoded?: number | undefined;
18
+ framesRendered?: number | undefined;
19
+ framesDropped?: number | undefined;
20
+ frameWidth?: number | undefined;
21
+ frameHeight?: number | undefined;
22
+ framesPerSecond?: number | undefined;
23
+ qpSum?: number | undefined;
24
+ totalDecodeTime?: number | undefined;
25
+ totalInterFrameDelay?: number | undefined;
26
+ totalSquaredInterFrameDelay?: number | undefined;
27
+ pauseCount?: number | undefined;
28
+ totalPausesDuration?: number | undefined;
29
+ freezeCount?: number | undefined;
30
+ totalFreezesDuration?: number | undefined;
31
+ lastPacketReceivedTimestamp?: number | undefined;
32
+ headerBytesReceived?: number | undefined;
33
+ packetsDiscarded?: number | undefined;
34
+ fecBytesReceived?: number | undefined;
35
+ fecPacketsReceived?: number | undefined;
36
+ fecPacketsDiscarded?: number | undefined;
37
+ bytesReceived?: number | undefined;
38
+ nackCount?: number | undefined;
39
+ firCount?: number | undefined;
40
+ pliCount?: number | undefined;
41
+ totalProcessingDelay?: number | undefined;
42
+ estimatedPlayoutTimestamp?: number | undefined;
43
+ jitterBufferDelay?: number | undefined;
44
+ jitterBufferTargetDelay?: number | undefined;
45
+ jitterBufferEmittedCount?: number | undefined;
46
+ jitterBufferMinimumDelay?: number | undefined;
47
+ totalSamplesReceived?: number | undefined;
48
+ concealedSamples?: number | undefined;
49
+ silentConcealedSamples?: number | undefined;
50
+ concealmentEvents?: number | undefined;
51
+ insertedSamplesForDeceleration?: number | undefined;
52
+ removedSamplesForAcceleration?: number | undefined;
53
+ audioLevel?: number | undefined;
54
+ totalAudioEnergy?: number | undefined;
55
+ totalSamplesDuration?: number | undefined;
56
+ framesReceived?: number | undefined;
57
+ decoderImplementation?: string | undefined;
58
+ playoutId?: string | undefined;
59
+ powerEfficientDecoder?: boolean | undefined;
60
+ framesAssembledFromMultiplePackets?: number | undefined;
61
+ totalAssemblyTime?: number | undefined;
62
+ retransmittedPacketsReceived?: number | undefined;
63
+ retransmittedBytesReceived?: number | undefined;
64
+ rtxSsrc?: number | undefined;
65
+ fecSsrc?: number | undefined;
66
+ totalCorruptionProbability?: number | undefined;
67
+ totalSquaredCorruptionProbability?: number | undefined;
68
+ corruptionMeasurements?: number | undefined;
69
+ attachments?: Record<string, unknown> | undefined;
70
+ jitter?: number | undefined;
71
+
72
+ public bitrate = 0;
73
+ public fractionLost?: number;
74
+ public bitPerPixel = 0;
75
+
76
+ public deltaLostPackets = 0;
77
+ public deltaReceivedPackets = 0;
78
+ public deltaBytesReceived = 0;
79
+ public deltaReceivedSamples = 0;
80
+ public deltaSilentConcealedSamples = 0;
81
+
82
+ public constructor(
83
+ public timestamp: number,
84
+ public id: string,
85
+ public ssrc: number,
86
+ public kind: MediaKind,
87
+ public trackIdentifier: string,
88
+ private readonly _peerConnection: ObservedPeerConnection
89
+ ) {}
90
+
91
+ public get visited() {
92
+ const visited = this._visited;
93
+
94
+ this._visited = false;
95
+
96
+ return visited;
97
+ }
98
+
99
+ public getPeerConnection() {
100
+ return this._peerConnection;
101
+ }
102
+
103
+ public getRemoteOutboundRtp() {
104
+ return this._peerConnection.observedRemoteOutboundRtps.get(this.ssrc);
105
+ }
106
+
107
+ public getIceTransport() {
108
+ return this._peerConnection.observedIceTransports.get(this.transportId ?? '');
109
+ }
110
+
111
+ public getCodec() {
112
+ return this._peerConnection.observedCodecs.get(this.codecId ?? '');
113
+ }
114
+
115
+ public getMediaPlayout() {
116
+ return this._peerConnection.observedMediaPlayouts.get(this.playoutId ?? '');
117
+ }
118
+
119
+ public getTrack() {
120
+ return this._peerConnection.observedInboundTracks.get(this.trackIdentifier);
121
+ }
122
+
123
+ public update(stats: InboundRtpStats) {
124
+ this._visited = true;
125
+ this.deltaBytesReceived = 0;
126
+ this.deltaLostPackets = 0;
127
+ this.deltaReceivedPackets = 0;
128
+ this.deltaReceivedSamples = 0;
129
+ this.deltaSilentConcealedSamples = 0;
130
+ this.bitrate = 0;
131
+ this.jitter = undefined;
132
+ this.fractionLost = undefined;
133
+ this.bitPerPixel = 0;
134
+
135
+ const elapsedTimeInMs = stats.timestamp - this.timestamp;
136
+
137
+ if (elapsedTimeInMs) {
138
+ // update metrics here
139
+ if (this.bytesReceived && stats.bytesReceived && this.bytesReceived < stats.bytesReceived) {
140
+ this.bitrate = ((stats.bytesReceived - (this.bytesReceived ?? 0)) * 8) / elapsedTimeInMs;
141
+ }
142
+ if (this.packetsLost && stats.packetsLost && this.packetsLost < stats.packetsLost) {
143
+ this.deltaLostPackets = stats.packetsLost - this.packetsLost;
144
+ }
145
+ if (this.packetsReceived && stats.packetsReceived && this.packetsReceived < stats.packetsReceived) {
146
+ this.deltaReceivedPackets = stats.packetsReceived - this.packetsReceived;
147
+ }
148
+ if (this.totalSamplesReceived && stats.totalSamplesReceived && this.totalSamplesReceived < stats.totalSamplesReceived) {
149
+ this.deltaReceivedSamples = stats.totalSamplesReceived - this.totalSamplesReceived;
150
+ }
151
+ if (this.silentConcealedSamples && stats.silentConcealedSamples && this.silentConcealedSamples < stats.silentConcealedSamples) {
152
+ this.deltaSilentConcealedSamples = stats.silentConcealedSamples - this.silentConcealedSamples;
153
+ }
154
+ if (stats.bytesReceived && this.framesReceived && stats.framesReceived && this.framesReceived < stats.framesReceived) {
155
+ this.bitPerPixel = (stats.bytesReceived - (this.bytesReceived ?? 0)) / (stats.framesReceived - this.framesReceived);
156
+ }
157
+ if (this.deltaLostPackets && this.deltaReceivedPackets) {
158
+ this.fractionLost = this.deltaLostPackets / (this.deltaLostPackets + this.deltaReceivedPackets);
159
+ }
160
+ }
161
+
162
+ this.timestamp = stats.timestamp;
163
+ this.transportId = stats.transportId;
164
+ this.codecId = stats.codecId;
165
+ this.packetsReceived = stats.packetsReceived;
166
+ this.packetsLost = stats.packetsLost;
167
+ this.mid = stats.mid;
168
+ this.remoteId = stats.remoteId;
169
+ this.framesDecoded = stats.framesDecoded;
170
+ this.keyFramesDecoded = stats.keyFramesDecoded;
171
+ this.framesRendered = stats.framesRendered;
172
+ this.framesDropped = stats.framesDropped;
173
+ this.frameWidth = stats.frameWidth;
174
+ this.frameHeight = stats.frameHeight;
175
+ this.framesPerSecond = stats.framesPerSecond;
176
+ this.qpSum = stats.qpSum;
177
+ this.totalDecodeTime = stats.totalDecodeTime;
178
+ this.totalInterFrameDelay = stats.totalInterFrameDelay;
179
+ this.totalSquaredInterFrameDelay = stats.totalSquaredInterFrameDelay;
180
+ this.pauseCount = stats.pauseCount;
181
+ this.totalPausesDuration = stats.totalPausesDuration;
182
+ this.freezeCount = stats.freezeCount;
183
+ this.totalFreezesDuration = stats.totalFreezesDuration;
184
+ this.lastPacketReceivedTimestamp = stats.lastPacketReceivedTimestamp;
185
+ this.headerBytesReceived = stats.headerBytesReceived;
186
+ this.packetsDiscarded = stats.packetsDiscarded;
187
+ this.fecBytesReceived = stats.fecBytesReceived;
188
+ this.fecPacketsReceived = stats.fecPacketsReceived;
189
+ this.fecPacketsDiscarded = stats.fecPacketsDiscarded;
190
+ this.bytesReceived = stats.bytesReceived;
191
+ this.nackCount = stats.nackCount;
192
+ this.firCount = stats.firCount;
193
+ this.pliCount = stats.pliCount;
194
+ this.totalProcessingDelay = stats.totalProcessingDelay;
195
+ this.estimatedPlayoutTimestamp = stats.estimatedPlayoutTimestamp;
196
+ this.jitterBufferDelay = stats.jitterBufferDelay;
197
+ this.jitterBufferTargetDelay = stats.jitterBufferTargetDelay;
198
+ this.jitterBufferEmittedCount = stats.jitterBufferEmittedCount;
199
+ this.jitterBufferMinimumDelay = stats.jitterBufferMinimumDelay;
200
+ this.totalSamplesReceived = stats.totalSamplesReceived;
201
+ this.concealedSamples = stats.concealedSamples;
202
+ this.silentConcealedSamples = stats.silentConcealedSamples;
203
+ this.concealmentEvents = stats.concealmentEvents;
204
+ }
205
+ }
@@ -0,0 +1,70 @@
1
+ import { CalculatedScore } from './scores/CalculatedScore';
2
+ import { MediaKind } from './common/types';
3
+ import { InboundTrackSample } from './schema/ClientSample';
4
+ import { Detectors } from './detectors/Detectors';
5
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
6
+ import { ObservedInboundRtp } from './ObservedInboundRtp';
7
+ import { ObservedMediaPlayout } from './ObservedMediaPlayout';
8
+
9
+ export class ObservedInboundTrack implements InboundTrackSample {
10
+ public readonly detectors: Detectors;
11
+ public readonly calculatedScore: CalculatedScore = {
12
+ weight: 1,
13
+ value: undefined,
14
+ };
15
+ public appData?: Record<string, unknown>;
16
+
17
+ private _visited = false;
18
+
19
+ attachments?: Record<string, unknown> | undefined;
20
+
21
+ constructor(
22
+ public timestamp: number,
23
+ public readonly id: string,
24
+ public readonly kind: MediaKind,
25
+ private readonly _peerConnection: ObservedPeerConnection,
26
+ private readonly _inboundRtp?: ObservedInboundRtp,
27
+ private readonly _mediaPlayout?: ObservedMediaPlayout,
28
+ ) {
29
+ this.detectors = new Detectors();
30
+ }
31
+
32
+ public get score() {
33
+ return this.calculatedScore.value;
34
+ }
35
+
36
+ public get visited() {
37
+ const visited = this._visited;
38
+
39
+ this._visited = false;
40
+
41
+ return visited;
42
+ }
43
+
44
+ public getPeerConnection() {
45
+ return this._peerConnection;
46
+ }
47
+
48
+ public getInboundRtp() {
49
+ return this._inboundRtp;
50
+ }
51
+
52
+ public getMediaPlayout() {
53
+ return this._mediaPlayout;
54
+ }
55
+
56
+ public getRemoteOutboundTrack() {
57
+ return this._peerConnection.client.call.remoteTrackResolver?.resolveRemoteOutboundTrack(this);
58
+ }
59
+
60
+ public update(stats: InboundTrackSample): void {
61
+ this._visited = true;
62
+
63
+ this.timestamp = stats.timestamp;
64
+ this.calculatedScore.value = stats.score;
65
+ this.attachments = stats.attachments;
66
+
67
+ this.detectors.update();
68
+ }
69
+
70
+ }
@@ -0,0 +1,49 @@
1
+ import { MediaKind } from './common/types';
2
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
3
+ import { MediaPlayoutStats } from './schema/ClientSample';
4
+
5
+ export class ObservedMediaPlayout implements MediaPlayoutStats {
6
+ private _visited = false;
7
+ public appData?: Record<string, unknown>;
8
+
9
+ synthesizedSamplesDuration?: number | undefined;
10
+ synthesizedSamplesEvents?: number | undefined;
11
+ totalSamplesDuration?: number | undefined;
12
+ totalPlayoutDelay?: number | undefined;
13
+ totalSamplesCount?: number | undefined;
14
+ attachments?: Record<string, unknown> | undefined;
15
+
16
+ public constructor(
17
+ public timestamp: number,
18
+ public id: string,
19
+ public kind: MediaKind,
20
+ private readonly _peerConnection: ObservedPeerConnection
21
+ ) {}
22
+
23
+ public get visited() {
24
+ const visited = this._visited;
25
+
26
+ this._visited = false;
27
+
28
+ return visited;
29
+ }
30
+
31
+ public getPeerConnection() {
32
+ return this._peerConnection;
33
+ }
34
+
35
+
36
+
37
+ public update(stats: MediaPlayoutStats) {
38
+ this._visited = true;
39
+
40
+ this.timestamp = stats.timestamp;
41
+ this.synthesizedSamplesDuration = stats.synthesizedSamplesDuration;
42
+ this.synthesizedSamplesEvents = stats.synthesizedSamplesEvents;
43
+ this.totalSamplesDuration = stats.totalSamplesDuration;
44
+ this.totalPlayoutDelay = stats.totalPlayoutDelay;
45
+ this.totalSamplesCount = stats.totalSamplesCount;
46
+ this.attachments = stats.attachments;
47
+
48
+ }
49
+ }
@@ -0,0 +1,60 @@
1
+ import { MediaKind } from './common/types';
2
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
3
+ import { MediaSourceStats } from './schema/ClientSample';
4
+
5
+ export class ObservedMediaSource implements MediaSourceStats {
6
+ private _visited = false;
7
+ public appData?: Record<string, unknown>;
8
+
9
+ trackIdentifier?: string | undefined;
10
+ audioLevel?: number | undefined;
11
+ totalAudioEnergy?: number | undefined;
12
+ totalSamplesDuration?: number | undefined;
13
+ echoReturnLoss?: number | undefined;
14
+ echoReturnLossEnhancement?: number | undefined;
15
+ width?: number | undefined;
16
+ height?: number | undefined;
17
+ frames?: number | undefined;
18
+ framesPerSecond?: number | undefined;
19
+ attachments?: Record<string, unknown> | undefined;
20
+
21
+ public constructor(
22
+ public timestamp: number,
23
+ public id: string,
24
+ public kind: MediaKind,
25
+ private readonly _peerConnection: ObservedPeerConnection
26
+ ) {}
27
+
28
+ public get visited() {
29
+ const visited = this._visited;
30
+
31
+ this._visited = false;
32
+
33
+ return visited;
34
+ }
35
+
36
+ public getPeerConnection() {
37
+ return this._peerConnection;
38
+ }
39
+
40
+ public getTrack() {
41
+ return this._peerConnection.observedOutboundTracks.get(this.trackIdentifier ?? '');
42
+ }
43
+
44
+ public update(stats: MediaSourceStats) {
45
+ this._visited = true;
46
+
47
+ this.timestamp = stats.timestamp;
48
+ this.trackIdentifier = stats.trackIdentifier;
49
+ this.audioLevel = stats.audioLevel;
50
+ this.totalAudioEnergy = stats.totalAudioEnergy;
51
+ this.totalSamplesDuration = stats.totalSamplesDuration;
52
+ this.echoReturnLoss = stats.echoReturnLoss;
53
+ this.echoReturnLossEnhancement = stats.echoReturnLossEnhancement;
54
+ this.width = stats.width;
55
+ this.height = stats.height;
56
+ this.frames = stats.frames;
57
+ this.framesPerSecond = stats.framesPerSecond;
58
+ this.attachments = stats.attachments;
59
+ }
60
+ }
@@ -0,0 +1,156 @@
1
+ import { MediaKind } from './common/types';
2
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
3
+ import { OutboundRtpStats, QualityLimitationDurations } from './schema/ClientSample';
4
+
5
+ export class ObservedOutboundRtp implements OutboundRtpStats {
6
+ private _visited = false;
7
+ public appData?: Record<string, unknown>;
8
+
9
+ transportId?: string | undefined;
10
+ codecId?: string | undefined;
11
+ packetsSent?: number | undefined;
12
+ bytesSent?: number | undefined;
13
+ mid?: string | undefined;
14
+ mediaSourceId?: string | undefined;
15
+ remoteId?: string | undefined;
16
+ rid?: string | undefined;
17
+ headerBytesSent?: number | undefined;
18
+ retransmittedPacketsSent?: number | undefined;
19
+ retransmittedBytesSent?: number | undefined;
20
+ rtxSsrc?: number | undefined;
21
+ targetBitrate?: number | undefined;
22
+ totalEncodedBytesTarget?: number | undefined;
23
+ frameWidth?: number | undefined;
24
+ frameHeight?: number | undefined;
25
+ framesPerSecond?: number | undefined;
26
+ framesSent?: number | undefined;
27
+ hugeFramesSent?: number | undefined;
28
+ framesEncoded?: number | undefined;
29
+ keyFramesEncoded?: number | undefined;
30
+ qpSum?: number | undefined;
31
+ totalEncodeTime?: number | undefined;
32
+ totalPacketSendDelay?: number | undefined;
33
+ qualityLimitationReason?: string | undefined;
34
+ qualityLimitationResolutionChanges?: number | undefined;
35
+ nackCount?: number | undefined;
36
+ firCount?: number | undefined;
37
+ pliCount?: number | undefined;
38
+ encoderImplementation?: string | undefined;
39
+ powerEfficientEncoder?: boolean | undefined;
40
+ active?: boolean | undefined;
41
+ scalabilityMode?: string | undefined;
42
+ qualityLimitationDurations?: QualityLimitationDurations | undefined;
43
+ attachments?: Record<string, unknown> | undefined;
44
+
45
+ // derived fields
46
+ public bitrate = 0;
47
+ public payloadBitrate = 0;
48
+ public packetRate = 0;
49
+ public bitPerPixel = 0;
50
+
51
+ public deltaPacketsSent = 0;
52
+ public deltaBytesSent = 0;
53
+
54
+ public constructor(
55
+ public timestamp: number,
56
+ public id: string,
57
+ public ssrc: number,
58
+ public kind: MediaKind,
59
+ private readonly _peerConnection: ObservedPeerConnection,
60
+ ) {
61
+ }
62
+
63
+ public get visited() {
64
+ const visited = this._visited;
65
+
66
+ this._visited = false;
67
+
68
+ return visited;
69
+ }
70
+
71
+ public getPeerConnection() {
72
+ return this._peerConnection;
73
+ }
74
+
75
+ public getRemoteInboundRtp() {
76
+ return this._peerConnection.observedRemoteInboundRtps.get(this.ssrc);
77
+ }
78
+
79
+ public getCodec() {
80
+ return this._peerConnection.observedCodecs.get(this.codecId ?? '');
81
+ }
82
+
83
+ public getMediaSource() {
84
+ return this._peerConnection.observedMediaSources.get(this.mediaSourceId ?? '');
85
+ }
86
+
87
+ public getTrack() {
88
+ return this.getMediaSource()?.getTrack();
89
+ }
90
+
91
+ public update(stats: OutboundRtpStats) {
92
+ this._visited = true;
93
+ this.bitPerPixel = 0;
94
+ this.bitrate = 0;
95
+ this.payloadBitrate = 0;
96
+ this.packetRate = 0;
97
+ this.deltaPacketsSent = 0;
98
+ this.deltaBytesSent = 0;
99
+
100
+ const elapsedTimeInMs = stats.timestamp - this.timestamp;
101
+
102
+ if (elapsedTimeInMs) {
103
+ if (stats.packetsSent !== undefined && this.packetsSent !== undefined) {
104
+ this.deltaPacketsSent = stats.packetsSent - this.packetsSent;
105
+ this.packetRate = this.deltaPacketsSent / (elapsedTimeInMs / 1000);
106
+ }
107
+ if (stats.bytesSent !== undefined && this.bytesSent !== undefined) {
108
+ this.deltaBytesSent = stats.bytesSent - this.bytesSent;
109
+ this.bitrate = (this.deltaBytesSent * 8) / (elapsedTimeInMs / 1000);
110
+ }
111
+ if (stats.headerBytesSent !== undefined && this.headerBytesSent !== undefined) {
112
+ this.payloadBitrate = ((this.deltaBytesSent ?? 0 - (stats.headerBytesSent - this.headerBytesSent)) * 8) / (elapsedTimeInMs / 1000);
113
+ }
114
+ if (this.framesSent !== undefined && stats.framesSent !== undefined) {
115
+ this.bitPerPixel = this.deltaBytesSent ? (this.deltaBytesSent * 8) / (this.framesSent - stats.framesSent) : 0;
116
+ }
117
+ }
118
+
119
+ this.timestamp = stats.timestamp;
120
+ this.transportId = stats.transportId;
121
+ this.codecId = stats.codecId;
122
+ this.packetsSent = stats.packetsSent;
123
+ this.bytesSent = stats.bytesSent;
124
+ this.mid = stats.mid;
125
+ this.mediaSourceId = stats.mediaSourceId;
126
+ this.remoteId = stats.remoteId;
127
+ this.rid = stats.rid;
128
+ this.headerBytesSent = stats.headerBytesSent;
129
+ this.retransmittedPacketsSent = stats.retransmittedPacketsSent;
130
+ this.retransmittedBytesSent = stats.retransmittedBytesSent;
131
+ this.rtxSsrc = stats.rtxSsrc;
132
+ this.targetBitrate = stats.targetBitrate;
133
+ this.totalEncodedBytesTarget = stats.totalEncodedBytesTarget;
134
+ this.frameWidth = stats.frameWidth;
135
+ this.frameHeight = stats.frameHeight;
136
+ this.framesPerSecond = stats.framesPerSecond;
137
+ this.framesSent = stats.framesSent;
138
+ this.hugeFramesSent = stats.hugeFramesSent;
139
+ this.framesEncoded = stats.framesEncoded;
140
+ this.keyFramesEncoded = stats.keyFramesEncoded;
141
+ this.qpSum = stats.qpSum;
142
+ this.totalEncodeTime = stats.totalEncodeTime;
143
+ this.totalPacketSendDelay = stats.totalPacketSendDelay;
144
+ this.qualityLimitationReason = stats.qualityLimitationReason;
145
+ this.qualityLimitationResolutionChanges = stats.qualityLimitationResolutionChanges;
146
+ this.nackCount = stats.nackCount;
147
+ this.firCount = stats.firCount;
148
+ this.pliCount = stats.pliCount;
149
+ this.encoderImplementation = stats.encoderImplementation;
150
+ this.powerEfficientEncoder = stats.powerEfficientEncoder;
151
+ this.active = stats.active;
152
+ this.scalabilityMode = stats.scalabilityMode;
153
+ this.qualityLimitationDurations = stats.qualityLimitationDurations;
154
+ this.attachments = stats.attachments;
155
+ }
156
+ }
@@ -0,0 +1,69 @@
1
+ import { CalculatedScore } from './scores/CalculatedScore';
2
+ import { MediaKind } from './common/types';
3
+ import { OutboundTrackSample } from './schema/ClientSample';
4
+ import { Detectors } from './detectors/Detectors';
5
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
6
+ import { ObservedOutboundRtp } from './ObservedOutboundRtp';
7
+ import { ObservedMediaSource } from './ObservedMediaSource';
8
+
9
+ export class ObservedOutboundTrack implements OutboundTrackSample {
10
+ public readonly detectors: Detectors;
11
+ private _visited = false;
12
+ public appData?: Record<string, unknown>;
13
+ public readonly calculatedScore: CalculatedScore = {
14
+ weight: 1,
15
+ value: undefined,
16
+ };
17
+
18
+ attachments?: Record<string, unknown> | undefined;
19
+
20
+ constructor(
21
+ public timestamp: number,
22
+ public readonly id: string,
23
+ public readonly kind: MediaKind,
24
+ private readonly _peerConnection: ObservedPeerConnection,
25
+ private readonly _outboundRtps?: ObservedOutboundRtp[],
26
+ private readonly _mediaSource?: ObservedMediaSource,
27
+ ) {
28
+ this.detectors = new Detectors();
29
+ }
30
+
31
+ public get score() {
32
+ return this.calculatedScore.value;
33
+ }
34
+
35
+ public get visited() {
36
+ const visited = this._visited;
37
+
38
+ this._visited = false;
39
+
40
+ return visited;
41
+ }
42
+
43
+ public getPeerConnection() {
44
+ return this._peerConnection;
45
+ }
46
+
47
+ public getOutboundRtps() {
48
+ return this._outboundRtps;
49
+ }
50
+
51
+ public getMediaSource() {
52
+ return this._mediaSource;
53
+ }
54
+
55
+ public getRemoteInboundTracks() {
56
+ return this._peerConnection.client.call.remoteTrackResolver?.resolveRemoteInboundTracks(this);
57
+ }
58
+
59
+ public update(stats: OutboundTrackSample): void {
60
+ this._visited = true;
61
+
62
+ this.timestamp = stats.timestamp;
63
+ this.calculatedScore.value = stats.score;
64
+ this.attachments = stats.attachments;
65
+
66
+ this.detectors.update();
67
+ }
68
+
69
+ }