@observertc/observer-js 1.3.0-rc.4 → 1.3.0-rc.5
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/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -2196,7 +2196,6 @@ declare class ObservedOutboundTrack implements OutboundTrackSample {
|
|
|
2196
2196
|
readonly id: string;
|
|
2197
2197
|
readonly kind: MediaKind;
|
|
2198
2198
|
private readonly _peerConnection;
|
|
2199
|
-
private readonly _outboundRtps?;
|
|
2200
2199
|
private readonly _mediaSource?;
|
|
2201
2200
|
private _visited;
|
|
2202
2201
|
appData?: Record<string, unknown>;
|
|
@@ -2228,11 +2227,12 @@ declare class ObservedOutboundTrack implements OutboundTrackSample {
|
|
|
2228
2227
|
* latest tick. Needs a `RemoteTrackResolver`: without links there are no receivers to ask.
|
|
2229
2228
|
*/
|
|
2230
2229
|
receivedRmsAudioLevel?: number;
|
|
2231
|
-
constructor(timestamp: number, id: string, kind: MediaKind, _peerConnection: ObservedPeerConnection,
|
|
2230
|
+
constructor(timestamp: number, id: string, kind: MediaKind, _peerConnection: ObservedPeerConnection, _mediaSource?: ObservedMediaSource | undefined);
|
|
2232
2231
|
get score(): number | undefined;
|
|
2233
2232
|
get visited(): boolean;
|
|
2234
2233
|
get degraded(): boolean;
|
|
2235
2234
|
getPeerConnection(): ObservedPeerConnection;
|
|
2235
|
+
/** The outbound RTPs of this track's media source, looked up on every call. */
|
|
2236
2236
|
getOutboundRtps(): ObservedOutboundRtp[] | undefined;
|
|
2237
2237
|
getMediaSource(): ObservedMediaSource | undefined;
|
|
2238
2238
|
/** The capture device behind this track, when the client sent `AUDIO_INPUT_DEVICE` metadata for it. */
|
|
@@ -2695,6 +2695,7 @@ declare class ObservedPeerConnection extends EventEmitter {
|
|
|
2695
2695
|
private _updateMediaSourceStats;
|
|
2696
2696
|
private _updateOutboundRtpStats;
|
|
2697
2697
|
private _updateOutboundTrackSample;
|
|
2698
|
+
private _removeOutboundTrack;
|
|
2698
2699
|
private _updatePeerConnectionTransportStats;
|
|
2699
2700
|
private _updateRemoteInboundRtpStats;
|
|
2700
2701
|
private _updateRemoteOutboundRtpStats;
|
|
@@ -4096,6 +4097,7 @@ declare class RemoteTrackResolver {
|
|
|
4096
4097
|
readonly observedCall: ObservedCall;
|
|
4097
4098
|
private readonly resolvers;
|
|
4098
4099
|
private readonly _publisherIdToOutboundTrack;
|
|
4100
|
+
private readonly _outboundTrackPublisherIds;
|
|
4099
4101
|
private readonly _subscriberIdToInboundTrack;
|
|
4100
4102
|
/**
|
|
4101
4103
|
* Tracks whose publisher id the strategy could not resolve **yet**.
|
package/dist/index.d.ts
CHANGED
|
@@ -2196,7 +2196,6 @@ declare class ObservedOutboundTrack implements OutboundTrackSample {
|
|
|
2196
2196
|
readonly id: string;
|
|
2197
2197
|
readonly kind: MediaKind;
|
|
2198
2198
|
private readonly _peerConnection;
|
|
2199
|
-
private readonly _outboundRtps?;
|
|
2200
2199
|
private readonly _mediaSource?;
|
|
2201
2200
|
private _visited;
|
|
2202
2201
|
appData?: Record<string, unknown>;
|
|
@@ -2228,11 +2227,12 @@ declare class ObservedOutboundTrack implements OutboundTrackSample {
|
|
|
2228
2227
|
* latest tick. Needs a `RemoteTrackResolver`: without links there are no receivers to ask.
|
|
2229
2228
|
*/
|
|
2230
2229
|
receivedRmsAudioLevel?: number;
|
|
2231
|
-
constructor(timestamp: number, id: string, kind: MediaKind, _peerConnection: ObservedPeerConnection,
|
|
2230
|
+
constructor(timestamp: number, id: string, kind: MediaKind, _peerConnection: ObservedPeerConnection, _mediaSource?: ObservedMediaSource | undefined);
|
|
2232
2231
|
get score(): number | undefined;
|
|
2233
2232
|
get visited(): boolean;
|
|
2234
2233
|
get degraded(): boolean;
|
|
2235
2234
|
getPeerConnection(): ObservedPeerConnection;
|
|
2235
|
+
/** The outbound RTPs of this track's media source, looked up on every call. */
|
|
2236
2236
|
getOutboundRtps(): ObservedOutboundRtp[] | undefined;
|
|
2237
2237
|
getMediaSource(): ObservedMediaSource | undefined;
|
|
2238
2238
|
/** The capture device behind this track, when the client sent `AUDIO_INPUT_DEVICE` metadata for it. */
|
|
@@ -2695,6 +2695,7 @@ declare class ObservedPeerConnection extends EventEmitter {
|
|
|
2695
2695
|
private _updateMediaSourceStats;
|
|
2696
2696
|
private _updateOutboundRtpStats;
|
|
2697
2697
|
private _updateOutboundTrackSample;
|
|
2698
|
+
private _removeOutboundTrack;
|
|
2698
2699
|
private _updatePeerConnectionTransportStats;
|
|
2699
2700
|
private _updateRemoteInboundRtpStats;
|
|
2700
2701
|
private _updateRemoteOutboundRtpStats;
|
|
@@ -4096,6 +4097,7 @@ declare class RemoteTrackResolver {
|
|
|
4096
4097
|
readonly observedCall: ObservedCall;
|
|
4097
4098
|
private readonly resolvers;
|
|
4098
4099
|
private readonly _publisherIdToOutboundTrack;
|
|
4100
|
+
private readonly _outboundTrackPublisherIds;
|
|
4099
4101
|
private readonly _subscriberIdToInboundTrack;
|
|
4100
4102
|
/**
|
|
4101
4103
|
* Tracks whose publisher id the strategy could not resolve **yet**.
|
package/dist/index.js
CHANGED
|
@@ -1912,19 +1912,17 @@ function isPublicIpAddress(address) {
|
|
|
1912
1912
|
|
|
1913
1913
|
// src/ObservedOutboundTrack.ts
|
|
1914
1914
|
var ObservedOutboundTrack = class {
|
|
1915
|
-
constructor(timestamp, id, kind, _peerConnection,
|
|
1915
|
+
constructor(timestamp, id, kind, _peerConnection, _mediaSource) {
|
|
1916
1916
|
this.timestamp = timestamp;
|
|
1917
1917
|
this.id = id;
|
|
1918
1918
|
this.kind = kind;
|
|
1919
1919
|
this._peerConnection = _peerConnection;
|
|
1920
|
-
this._outboundRtps = _outboundRtps;
|
|
1921
1920
|
this._mediaSource = _mediaSource;
|
|
1922
1921
|
}
|
|
1923
1922
|
timestamp;
|
|
1924
1923
|
id;
|
|
1925
1924
|
kind;
|
|
1926
1925
|
_peerConnection;
|
|
1927
|
-
_outboundRtps;
|
|
1928
1926
|
_mediaSource;
|
|
1929
1927
|
_visited = false;
|
|
1930
1928
|
appData;
|
|
@@ -1975,8 +1973,11 @@ var ObservedOutboundTrack = class {
|
|
|
1975
1973
|
getPeerConnection() {
|
|
1976
1974
|
return this._peerConnection;
|
|
1977
1975
|
}
|
|
1976
|
+
/** The outbound RTPs of this track's media source, looked up on every call. */
|
|
1978
1977
|
getOutboundRtps() {
|
|
1979
|
-
|
|
1978
|
+
const mediaSource = this._mediaSource;
|
|
1979
|
+
if (!mediaSource) return void 0;
|
|
1980
|
+
return [...this._peerConnection.observedOutboundRtps.values()].filter((rtp) => rtp.mediaSourceId === mediaSource.id);
|
|
1980
1981
|
}
|
|
1981
1982
|
getMediaSource() {
|
|
1982
1983
|
return this._mediaSource;
|
|
@@ -1995,7 +1996,7 @@ var ObservedOutboundTrack = class {
|
|
|
1995
1996
|
this.remoteFractionLost = void 0;
|
|
1996
1997
|
this.remoteRttInMs = void 0;
|
|
1997
1998
|
this.qualityLimitationReason = void 0;
|
|
1998
|
-
for (const rtp of this.
|
|
1999
|
+
for (const rtp of this.getOutboundRtps() ?? []) {
|
|
1999
2000
|
this.bitrate = (this.bitrate ?? 0) + rtp.bitrate;
|
|
2000
2001
|
this.deltaPacketsSent = (this.deltaPacketsSent ?? 0) + rtp.deltaPacketsSent;
|
|
2001
2002
|
if (rtp.remoteFractionLost !== void 0) {
|
|
@@ -2660,9 +2661,7 @@ var ObservedPeerConnection = class extends import_node_events2.EventEmitter {
|
|
|
2660
2661
|
}
|
|
2661
2662
|
for (const observedOutboundTrack of [...this.observedOutboundTracks.values()]) {
|
|
2662
2663
|
if (observedOutboundTrack.visited) continue;
|
|
2663
|
-
this.
|
|
2664
|
-
this.emit("removed-outbound-track", observedOutboundTrack);
|
|
2665
|
-
this._notify("outbound-track-removed", { ...this.eventScope, observedOutboundTrack });
|
|
2664
|
+
this._removeOutboundTrack(observedOutboundTrack);
|
|
2666
2665
|
}
|
|
2667
2666
|
for (const observedPeerConnectionTransport of [...this.observedPeerConnectionTransports.values()]) {
|
|
2668
2667
|
if (observedPeerConnectionTransport.visited) continue;
|
|
@@ -2923,6 +2922,11 @@ var ObservedPeerConnection = class extends import_node_events2.EventEmitter {
|
|
|
2923
2922
|
}
|
|
2924
2923
|
_updateOutboundTrackSample(stats) {
|
|
2925
2924
|
let observedOutboundTrack = this.observedOutboundTracks.get(stats.id);
|
|
2925
|
+
const mediaSource = [...this.observedMediaSources.values()].filter((source) => source.trackIdentifier === stats.id).pop();
|
|
2926
|
+
if (observedOutboundTrack && observedOutboundTrack.getMediaSource() !== mediaSource) {
|
|
2927
|
+
this._removeOutboundTrack(observedOutboundTrack);
|
|
2928
|
+
observedOutboundTrack = void 0;
|
|
2929
|
+
}
|
|
2926
2930
|
if (!observedOutboundTrack) {
|
|
2927
2931
|
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
2928
2932
|
return logger3.warn(
|
|
@@ -2930,15 +2934,12 @@ var ObservedPeerConnection = class extends import_node_events2.EventEmitter {
|
|
|
2930
2934
|
stats
|
|
2931
2935
|
);
|
|
2932
2936
|
}
|
|
2933
|
-
const observedMediaSource = [...this.observedMediaSources.values()].find((mediaSource) => mediaSource.trackIdentifier === stats.id);
|
|
2934
|
-
const outboundRtps = observedMediaSource ? [...this.observedOutboundRtps.values()].filter((outboundRtp) => outboundRtp.mediaSourceId === observedMediaSource?.id) : void 0;
|
|
2935
2937
|
observedOutboundTrack = new ObservedOutboundTrack(
|
|
2936
2938
|
stats.timestamp,
|
|
2937
2939
|
stats.id,
|
|
2938
2940
|
stats.kind,
|
|
2939
2941
|
this,
|
|
2940
|
-
|
|
2941
|
-
observedMediaSource
|
|
2942
|
+
mediaSource
|
|
2942
2943
|
);
|
|
2943
2944
|
observedOutboundTrack.update(stats);
|
|
2944
2945
|
this.observedOutboundTracks.set(stats.id, observedOutboundTrack);
|
|
@@ -2949,6 +2950,11 @@ var ObservedPeerConnection = class extends import_node_events2.EventEmitter {
|
|
|
2949
2950
|
this._notify("outbound-track-updated", { ...this.eventScope, observedOutboundTrack });
|
|
2950
2951
|
return observedOutboundTrack;
|
|
2951
2952
|
}
|
|
2953
|
+
_removeOutboundTrack(observedOutboundTrack) {
|
|
2954
|
+
this.observedOutboundTracks.delete(observedOutboundTrack.id);
|
|
2955
|
+
this.emit("removed-outbound-track", observedOutboundTrack);
|
|
2956
|
+
this._notify("outbound-track-removed", { ...this.eventScope, observedOutboundTrack });
|
|
2957
|
+
}
|
|
2952
2958
|
_updatePeerConnectionTransportStats(stats) {
|
|
2953
2959
|
let observedPeerConnectionTransport = this.observedPeerConnectionTransports.get(stats.id);
|
|
2954
2960
|
if (!observedPeerConnectionTransport) {
|
|
@@ -8178,6 +8184,7 @@ var RemoteTrackResolver = class {
|
|
|
8178
8184
|
observer.off("outbound-track-updated", onOutboundUpdated);
|
|
8179
8185
|
this._pendingInboundTracks.clear();
|
|
8180
8186
|
this._pendingOutboundTracks.clear();
|
|
8187
|
+
this._outboundTrackPublisherIds.clear();
|
|
8181
8188
|
});
|
|
8182
8189
|
observer.on("inbound-track-added", onInboundAdded);
|
|
8183
8190
|
observer.on("inbound-track-removed", onInboundRemoved);
|
|
@@ -8189,6 +8196,8 @@ var RemoteTrackResolver = class {
|
|
|
8189
8196
|
observedCall;
|
|
8190
8197
|
resolvers;
|
|
8191
8198
|
_publisherIdToOutboundTrack = /* @__PURE__ */ new Map();
|
|
8199
|
+
// The publisher id each outbound track was indexed under, so removal does not depend on its current attachments.
|
|
8200
|
+
_outboundTrackPublisherIds = /* @__PURE__ */ new Map();
|
|
8192
8201
|
_subscriberIdToInboundTrack = /* @__PURE__ */ new Map();
|
|
8193
8202
|
/**
|
|
8194
8203
|
* Tracks whose publisher id the strategy could not resolve **yet**.
|
|
@@ -8264,6 +8273,7 @@ var RemoteTrackResolver = class {
|
|
|
8264
8273
|
}
|
|
8265
8274
|
this._pendingOutboundTracks.delete(outboundTrack);
|
|
8266
8275
|
this._publisherIdToOutboundTrack.set(publisherId, outboundTrack);
|
|
8276
|
+
this._outboundTrackPublisherIds.set(outboundTrack, publisherId);
|
|
8267
8277
|
this.observedCall.unconsumedOutboundTracks.add(outboundTrack);
|
|
8268
8278
|
for (const observedClient of this.observedCall.observedClients.values()) {
|
|
8269
8279
|
for (const observedPeerConnection of observedClient.observedPeerConnections.values()) {
|
|
@@ -8278,7 +8288,8 @@ var RemoteTrackResolver = class {
|
|
|
8278
8288
|
}
|
|
8279
8289
|
_removeOutboundTrack(outboundTrack) {
|
|
8280
8290
|
this._pendingOutboundTracks.delete(outboundTrack);
|
|
8281
|
-
const publisherId = this.
|
|
8291
|
+
const publisherId = this._outboundTrackPublisherIds.get(outboundTrack);
|
|
8292
|
+
this._outboundTrackPublisherIds.delete(outboundTrack);
|
|
8282
8293
|
if (publisherId && this._publisherIdToOutboundTrack.get(publisherId) === outboundTrack) {
|
|
8283
8294
|
this._publisherIdToOutboundTrack.delete(publisherId);
|
|
8284
8295
|
}
|