@observertc/observer-js 0.9.2-beta → 0.9.4-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@observertc/observer-js",
3
- "version": "0.9.2-beta",
3
+ "version": "0.9.4-beta",
4
4
  "description": "Server Side NodeJS Library for processing ObserveRTC Samples",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/Observer.ts CHANGED
@@ -176,18 +176,22 @@ export class Observer {
176
176
  return this._sink;
177
177
  }
178
178
 
179
- public addEvaluator(process: EvaluatorProcess) {
179
+ public addEvaluators(...processes: EvaluatorProcess[]) {
180
180
  if (this._closed) {
181
181
  throw new Error(`Attempted to add an evaluator to a closed observer`);
182
182
  }
183
- this._evaluator.addProcess(process);
183
+ for (const process of processes) {
184
+ this._evaluator.addProcess(process);
185
+ }
184
186
  }
185
187
 
186
- public removeEvaluator(process: EvaluatorProcess) {
188
+ public removeEvaluators(...processes: EvaluatorProcess[]) {
187
189
  if (this._closed) {
188
190
  throw new Error(`Attempted to remove an evaluator from a closed observer`);
189
191
  }
190
- this._evaluator.removeProcess(process);
192
+ for (const process of processes) {
193
+ this._evaluator.removeProcess(process);
194
+ }
191
195
  }
192
196
 
193
197
  public calls(): AsyncIterableIterator<[string, Models.Call]> {
@@ -3,6 +3,7 @@ import * as Models from '../../models/Models';
3
3
  import { ReportsCollector } from '../../common/ReportsCollector';
4
4
  import { logger } from '../VisitObservedCallsMiddleware';
5
5
  import { PeerConnectionTransportReport } from '@observertc/report-schemas-js';
6
+ import { Samples_ClientSample_IceCandidatePair, Samples_ClientSample_IceLocalCandidate, Samples_ClientSample_IceRemoteCandidate, Samples_ClientSample_PeerConnectionTransport } from '../../models/samples_pb';
6
7
 
7
8
  export function visitPeerConnection(
8
9
  observedPeerConnection: ObservedPeerConnection,
@@ -55,16 +56,62 @@ export function visitPeerConnection(
55
56
  }
56
57
 
57
58
  if (fetchSamples) {
59
+ storedPeerConnection.icelocalCandidates = [];
58
60
  for (const iceLocalCandidate of observedPeerConnection.iceLocalCandidates()) {
59
- // iceLocalCandidate.id
61
+ const {
62
+ priority,
63
+ ...sample
64
+ } = iceLocalCandidate;
65
+ storedPeerConnection.icelocalCandidates.push(new Samples_ClientSample_IceLocalCandidate({
66
+ ...sample,
67
+ priority: BigInt(priority ?? -1)
68
+ }));
60
69
  }
61
70
 
71
+ storedPeerConnection.iceRemoteCandidates = [];
62
72
  for (const iceRemoteCandidate of observedPeerConnection.iceRemoteCandidates()) {
63
- // iceRemoteCandidates
73
+ const {
74
+ priority,
75
+ ...sample
76
+ } = iceRemoteCandidate;
77
+ storedPeerConnection.iceRemoteCandidates.push(new Samples_ClientSample_IceRemoteCandidate({
78
+ ...sample,
79
+ priority: BigInt(priority ?? -1)
80
+ }));
64
81
  }
65
82
 
83
+ storedPeerConnection.iceCandidatePairs = [];
66
84
  for (const iceCandidatePair of observedPeerConnection.iceCandidatePairs()) {
67
- // iceCandidatePair
85
+ const {
86
+ bytesDiscardedOnSend,
87
+ bytesReceived,
88
+ bytesSent,
89
+ lastPacketReceivedTimestamp,
90
+ lastPacketSentTimestamp,
91
+ ...sample
92
+ } = iceCandidatePair;
93
+ storedPeerConnection.iceCandidatePairs.push(new Samples_ClientSample_IceCandidatePair({
94
+ ...sample,
95
+ bytesDiscardedOnSend: BigInt(bytesDiscardedOnSend ?? -1),
96
+ bytesReceived: BigInt(bytesReceived ?? -1),
97
+ bytesSent: BigInt(bytesSent ?? -1),
98
+ lastPacketReceivedTimestamp: BigInt(lastPacketReceivedTimestamp ?? -1),
99
+ lastPacketSentTimestamp: BigInt(lastPacketSentTimestamp ?? -1),
100
+ }));
101
+ }
102
+
103
+ storedPeerConnection.transports = [];
104
+ for (const pcTransport of observedPeerConnection.transportSamples()) {
105
+ const {
106
+ bytesReceived,
107
+ bytesSent,
108
+ ...sample
109
+ } = pcTransport;
110
+ storedPeerConnection.transports.push(new Samples_ClientSample_PeerConnectionTransport({
111
+ ...sample,
112
+ bytesReceived: BigInt(bytesReceived ?? -1),
113
+ bytesSent: BigInt(bytesSent ?? -1),
114
+ }));
68
115
  }
69
116
  }
70
117
  }