@furious.luke/argus-js 0.5.4 → 0.5.6
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/README.md +75 -7
- package/dist/index.cjs +456 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +154 -5
- package/dist/index.d.ts +154 -5
- package/dist/index.js +456 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -102,6 +102,12 @@ type SignalMessage = {
|
|
|
102
102
|
turn_username?: string;
|
|
103
103
|
turn_credential?: string;
|
|
104
104
|
read_token?: string;
|
|
105
|
+
} | {
|
|
106
|
+
type: "placement_redirect";
|
|
107
|
+
gateway_url: string;
|
|
108
|
+
} | {
|
|
109
|
+
type: "unavailable";
|
|
110
|
+
retry_after_ms?: number;
|
|
105
111
|
};
|
|
106
112
|
/**
|
|
107
113
|
* Callbacks emitted by the Publisher during its lifecycle.
|
|
@@ -125,6 +131,19 @@ interface PublisherCallbacks {
|
|
|
125
131
|
onUserTextResult?: (event: UserTextResultEvent) => void;
|
|
126
132
|
/** Called once the explicitly requested outbound speech track arrives. */
|
|
127
133
|
onSpeechTrack?: (track: MediaStreamTrack, streams: readonly MediaStream[]) => void;
|
|
134
|
+
/**
|
|
135
|
+
* Called for every periodic connection-stats sample while connected — the raw
|
|
136
|
+
* feed behind {@link onConnectionQualityChange}. Fires at
|
|
137
|
+
* {@link PublisherOptions.connectionStatsIntervalMs}.
|
|
138
|
+
*/
|
|
139
|
+
onConnectionStats?: (sample: ConnectionStatsSample) => void;
|
|
140
|
+
/**
|
|
141
|
+
* Called when the derived connection-quality level changes (including the
|
|
142
|
+
* first assessment after connecting). Downgrades are debounced; upgrades fire
|
|
143
|
+
* immediately. Use this to react to a degrading network — e.g. warn the user
|
|
144
|
+
* or drop a secondary track.
|
|
145
|
+
*/
|
|
146
|
+
onConnectionQualityChange?: (quality: ConnectionQuality) => void;
|
|
128
147
|
}
|
|
129
148
|
interface AssistantTextEvent {
|
|
130
149
|
utteranceId: string;
|
|
@@ -138,6 +157,86 @@ interface UserTextResultEvent {
|
|
|
138
157
|
accepted: boolean;
|
|
139
158
|
reason?: string;
|
|
140
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* A coarse assessment of the uplink to the media server, derived from periodic
|
|
162
|
+
* WebRTC stats. Ordered worst-last by severity: `"good"` is a healthy
|
|
163
|
+
* connection, `"critical"` is barely usable.
|
|
164
|
+
*/
|
|
165
|
+
type ConnectionQualityLevel = "good" | "fair" | "poor" | "critical";
|
|
166
|
+
/**
|
|
167
|
+
* One periodic sample of the outbound connection's health, taken from
|
|
168
|
+
* `RTCPeerConnection.getStats()`. Packet loss and send bitrate are windowed over
|
|
169
|
+
* the interval since the previous sample (the first sample covers the session so
|
|
170
|
+
* far); the rest are point-in-time readings. A field is `null` when the browser
|
|
171
|
+
* did not report the underlying stat for this sample.
|
|
172
|
+
*/
|
|
173
|
+
interface ConnectionStatsSample {
|
|
174
|
+
/** Monotonic clock timestamp (ms) when the sample was taken. */
|
|
175
|
+
timestamp: number;
|
|
176
|
+
/**
|
|
177
|
+
* Fraction of outbound RTP packets lost, in `0..1` — the primary quality
|
|
178
|
+
* signal. A traffic-weighted mean of each stream's loss fraction: a stream uses
|
|
179
|
+
* its remote `fractionLost` (its loss ratio over the last RTCP report interval)
|
|
180
|
+
* when present, otherwise its windowed
|
|
181
|
+
* `Δpacketslost / Δ(packetsSent - retransmittedPacketsSent)`. Both kinds of
|
|
182
|
+
* stream are combined, so a lossy stream is never dropped for lacking
|
|
183
|
+
* `fractionLost`.
|
|
184
|
+
*/
|
|
185
|
+
lossRatio: number;
|
|
186
|
+
/** Round-trip time in milliseconds, or `null` if unknown. */
|
|
187
|
+
rttMs: number | null;
|
|
188
|
+
/** Inter-arrival jitter in milliseconds, or `null` if unknown. */
|
|
189
|
+
jitterMs: number | null;
|
|
190
|
+
/** ICE-estimated available outgoing bitrate in bits/sec, or `null` if unknown. */
|
|
191
|
+
availableOutgoingBitrate: number | null;
|
|
192
|
+
/** Actual send bitrate over the interval in bits/sec, or `null` if unknown. */
|
|
193
|
+
sendBitrate: number | null;
|
|
194
|
+
/**
|
|
195
|
+
* Why the encoder is limiting quality: `"none"`, `"cpu"`, `"bandwidth"`, or
|
|
196
|
+
* `"other"`. `null` when no video is being sent. `"bandwidth"` is treated as a
|
|
197
|
+
* degradation signal by the default classifier.
|
|
198
|
+
*/
|
|
199
|
+
qualityLimitationReason: string | null;
|
|
200
|
+
/** Cumulative NACKs received on outbound media, or `null` if unknown. */
|
|
201
|
+
nackCount: number | null;
|
|
202
|
+
/** Cumulative PLIs received on outbound media, or `null` if unknown. */
|
|
203
|
+
pliCount: number | null;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* A committed connection-quality assessment, delivered to
|
|
207
|
+
* {@link PublisherCallbacks.onConnectionQualityChange} whenever the level
|
|
208
|
+
* changes. `sample` is the reading that triggered the transition.
|
|
209
|
+
*/
|
|
210
|
+
interface ConnectionQuality {
|
|
211
|
+
level: ConnectionQualityLevel;
|
|
212
|
+
sample: ConnectionStatsSample;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Thresholds mapping a {@link ConnectionStatsSample} to a
|
|
216
|
+
* {@link ConnectionQualityLevel}. Packet loss is the primary axis; RTT and
|
|
217
|
+
* jitter can only push the assessment to a worse level, never a better one, and
|
|
218
|
+
* a `"bandwidth"` encoder limitation forces at least `"fair"`. Any subset may be
|
|
219
|
+
* overridden via {@link PublisherOptions.connectionQualityThresholds}; the rest
|
|
220
|
+
* keep their defaults.
|
|
221
|
+
*/
|
|
222
|
+
interface ConnectionQualityThresholds {
|
|
223
|
+
/** Loss ratio (`0..1`) at or above which quality is at least `"fair"`. Default `0.02`. */
|
|
224
|
+
fairLossRatio: number;
|
|
225
|
+
/** Loss ratio at or above which quality is at least `"poor"`. Default `0.05`. */
|
|
226
|
+
poorLossRatio: number;
|
|
227
|
+
/** Loss ratio at or above which quality is `"critical"`. Default `0.12`. */
|
|
228
|
+
criticalLossRatio: number;
|
|
229
|
+
/** RTT (ms) at or above which quality is at least `"fair"`. Default `300`. */
|
|
230
|
+
fairRttMs: number;
|
|
231
|
+
/** RTT (ms) at or above which quality is at least `"poor"`. Default `600`. */
|
|
232
|
+
poorRttMs: number;
|
|
233
|
+
/** RTT (ms) at or above which quality is `"critical"`. Default `1000`. */
|
|
234
|
+
criticalRttMs: number;
|
|
235
|
+
/** Jitter (ms) at or above which quality is at least `"fair"`. Default `50`. */
|
|
236
|
+
fairJitterMs: number;
|
|
237
|
+
/** Jitter (ms) at or above which quality is at least `"poor"`. Default `150`. */
|
|
238
|
+
poorJitterMs: number;
|
|
239
|
+
}
|
|
141
240
|
type PublisherRecoveryState = "recovering" | "recovered" | "failed";
|
|
142
241
|
type PublisherRecoveryAction = "sender_restart" | "ice_restart";
|
|
143
242
|
type PublisherRecoveryFailureReason = "capture_ended" | "automatic_recovery_failed";
|
|
@@ -165,7 +264,12 @@ interface GatewayReadyInfo {
|
|
|
165
264
|
* Options for publishing a media stream.
|
|
166
265
|
*/
|
|
167
266
|
interface PublisherOptions {
|
|
168
|
-
/**
|
|
267
|
+
/**
|
|
268
|
+
* Gateway WebSocket URLs returned by POST /api/streams `gateway_urls`. All are
|
|
269
|
+
* opened at once; the region whose `accepted` returns first is selected on
|
|
270
|
+
* network path, and only that region places the stream. The rest are held as
|
|
271
|
+
* standbys the publisher fails over to.
|
|
272
|
+
*/
|
|
169
273
|
gatewayURLs: string[];
|
|
170
274
|
/** The short-lived join token from POST /api/streams. */
|
|
171
275
|
token: string;
|
|
@@ -187,11 +291,26 @@ interface PublisherOptions {
|
|
|
187
291
|
*/
|
|
188
292
|
turnTransportPolicy?: TurnTransportPolicy;
|
|
189
293
|
/**
|
|
190
|
-
* Overall deadline for the initial accepted/proceed/ready gateway race
|
|
191
|
-
*
|
|
192
|
-
*
|
|
294
|
+
* Overall deadline for the initial accepted/proceed/ready gateway race,
|
|
295
|
+
* spanning selection, placement, and any failovers. Sockets that have not sent
|
|
296
|
+
* `accepted` are replaced after three seconds within this deadline. Defaults to
|
|
297
|
+
* 20 seconds.
|
|
193
298
|
*/
|
|
194
299
|
gatewayHandshakeTimeoutMs?: number;
|
|
300
|
+
/**
|
|
301
|
+
* How long the selected region has to return `ready` before the publisher
|
|
302
|
+
* abandons it and fails over to the next-fastest acknowledgement. This is a
|
|
303
|
+
* backstop for a region whose socket stays open but silent (a hung placement);
|
|
304
|
+
* a socket that closes or errors fails over immediately regardless. It is
|
|
305
|
+
* deliberately generous — placement includes the selected region's own
|
|
306
|
+
* control-plane round-trips, and a short deadline would abandon exactly the
|
|
307
|
+
* user-close-but-control-plane-distant regions this race is meant to prefer.
|
|
308
|
+
* Defaults to 8 seconds and is capped at 20 seconds: the gateway reaps a
|
|
309
|
+
* standby socket that has been accepted but not yet told to proceed, so the
|
|
310
|
+
* failover window must stay below that deadline or standbys would disappear
|
|
311
|
+
* before the browser fails over to them.
|
|
312
|
+
*/
|
|
313
|
+
gatewayFailoverTimeoutMs?: number;
|
|
195
314
|
/** Deadline after the initial offer for WebRTC to reach connected. Defaults to 30 seconds. */
|
|
196
315
|
peerConnectionTimeoutMs?: number;
|
|
197
316
|
/**
|
|
@@ -206,6 +325,24 @@ interface PublisherOptions {
|
|
|
206
325
|
preferredVideoCodecs?: string[];
|
|
207
326
|
/** How long to retry a dropped signaling connection to the selected gateway. Defaults to 20 seconds. */
|
|
208
327
|
signalingReconnectTimeoutMs?: number;
|
|
328
|
+
/**
|
|
329
|
+
* How often, in milliseconds, to poll `RTCPeerConnection.getStats()` for
|
|
330
|
+
* connection-quality assessment once connected. Defaults to 2000. Set to 0 to
|
|
331
|
+
* disable stats polling entirely — neither {@link PublisherCallbacks.onConnectionStats}
|
|
332
|
+
* nor {@link PublisherCallbacks.onConnectionQualityChange} will fire.
|
|
333
|
+
*/
|
|
334
|
+
connectionStatsIntervalMs?: number;
|
|
335
|
+
/**
|
|
336
|
+
* Overrides for the connection-quality classification thresholds. Any omitted
|
|
337
|
+
* field keeps its default. See {@link ConnectionQualityThresholds}.
|
|
338
|
+
*/
|
|
339
|
+
connectionQualityThresholds?: Partial<ConnectionQualityThresholds>;
|
|
340
|
+
/**
|
|
341
|
+
* Number of consecutive worse-than-current samples required before a quality
|
|
342
|
+
* downgrade is committed, damping transient blips. Improvements are reported
|
|
343
|
+
* on the first better sample. Defaults to 2; values below 1 are treated as 1.
|
|
344
|
+
*/
|
|
345
|
+
connectionQualityDebounceSamples?: number;
|
|
209
346
|
/** Callbacks for lifecycle events. */
|
|
210
347
|
callbacks?: PublisherCallbacks;
|
|
211
348
|
}
|
|
@@ -251,6 +388,11 @@ declare class Publisher {
|
|
|
251
388
|
private gatewayURL;
|
|
252
389
|
private lastReportedICEPath;
|
|
253
390
|
private watchedICETransports;
|
|
391
|
+
private connectionStatsTimer;
|
|
392
|
+
private statsSampleInFlight;
|
|
393
|
+
private lastStatsSample;
|
|
394
|
+
private currentQualityLevel;
|
|
395
|
+
private qualityDowngradeStreak;
|
|
254
396
|
private stopped;
|
|
255
397
|
private lifecycleGeneration;
|
|
256
398
|
private runAbort;
|
|
@@ -433,6 +575,13 @@ declare class Publisher {
|
|
|
433
575
|
private releaseLocalCandidateBatch;
|
|
434
576
|
private applyAnswered;
|
|
435
577
|
private watchSelectedICEPairChanges;
|
|
578
|
+
private startConnectionStatsLoop;
|
|
579
|
+
private stopConnectionStatsLoop;
|
|
580
|
+
private sampleConnectionQuality;
|
|
581
|
+
private buildStatsSample;
|
|
582
|
+
private resolveQualityThresholds;
|
|
583
|
+
private classifyQuality;
|
|
584
|
+
private updateConnectionQuality;
|
|
436
585
|
private reportSelectedICEPath;
|
|
437
586
|
private completeMediaRecovery;
|
|
438
587
|
private failMediaRecovery;
|
|
@@ -662,4 +811,4 @@ interface CaptureMicrophoneOptions {
|
|
|
662
811
|
*/
|
|
663
812
|
declare function captureMicrophone(opts?: CaptureMicrophoneOptions): Promise<MediaStream>;
|
|
664
813
|
|
|
665
|
-
export { type AssistantTextEvent, type CaptureCameraOptions, type CaptureMicrophoneOptions, type CaptureScreenOptions, type GatewayReadyInfo, Publisher, type PublisherCallbacks, type PublisherOptions, type PublisherRecoveryAction, type PublisherRecoveryEvent, type PublisherRecoveryFailureReason, type PublisherRecoveryState, type SignalMessage, type TrackLabel, type TrackType, type TurnTransportPolicy, type UserTextResultEvent, type VideoTrackType, captureCamera, captureMicrophone, captureScreen };
|
|
814
|
+
export { type AssistantTextEvent, type CaptureCameraOptions, type CaptureMicrophoneOptions, type CaptureScreenOptions, type ConnectionQuality, type ConnectionQualityLevel, type ConnectionQualityThresholds, type ConnectionStatsSample, type GatewayReadyInfo, Publisher, type PublisherCallbacks, type PublisherOptions, type PublisherRecoveryAction, type PublisherRecoveryEvent, type PublisherRecoveryFailureReason, type PublisherRecoveryState, type SignalMessage, type TrackLabel, type TrackType, type TurnTransportPolicy, type UserTextResultEvent, type VideoTrackType, captureCamera, captureMicrophone, captureScreen };
|
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,12 @@ type SignalMessage = {
|
|
|
102
102
|
turn_username?: string;
|
|
103
103
|
turn_credential?: string;
|
|
104
104
|
read_token?: string;
|
|
105
|
+
} | {
|
|
106
|
+
type: "placement_redirect";
|
|
107
|
+
gateway_url: string;
|
|
108
|
+
} | {
|
|
109
|
+
type: "unavailable";
|
|
110
|
+
retry_after_ms?: number;
|
|
105
111
|
};
|
|
106
112
|
/**
|
|
107
113
|
* Callbacks emitted by the Publisher during its lifecycle.
|
|
@@ -125,6 +131,19 @@ interface PublisherCallbacks {
|
|
|
125
131
|
onUserTextResult?: (event: UserTextResultEvent) => void;
|
|
126
132
|
/** Called once the explicitly requested outbound speech track arrives. */
|
|
127
133
|
onSpeechTrack?: (track: MediaStreamTrack, streams: readonly MediaStream[]) => void;
|
|
134
|
+
/**
|
|
135
|
+
* Called for every periodic connection-stats sample while connected — the raw
|
|
136
|
+
* feed behind {@link onConnectionQualityChange}. Fires at
|
|
137
|
+
* {@link PublisherOptions.connectionStatsIntervalMs}.
|
|
138
|
+
*/
|
|
139
|
+
onConnectionStats?: (sample: ConnectionStatsSample) => void;
|
|
140
|
+
/**
|
|
141
|
+
* Called when the derived connection-quality level changes (including the
|
|
142
|
+
* first assessment after connecting). Downgrades are debounced; upgrades fire
|
|
143
|
+
* immediately. Use this to react to a degrading network — e.g. warn the user
|
|
144
|
+
* or drop a secondary track.
|
|
145
|
+
*/
|
|
146
|
+
onConnectionQualityChange?: (quality: ConnectionQuality) => void;
|
|
128
147
|
}
|
|
129
148
|
interface AssistantTextEvent {
|
|
130
149
|
utteranceId: string;
|
|
@@ -138,6 +157,86 @@ interface UserTextResultEvent {
|
|
|
138
157
|
accepted: boolean;
|
|
139
158
|
reason?: string;
|
|
140
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* A coarse assessment of the uplink to the media server, derived from periodic
|
|
162
|
+
* WebRTC stats. Ordered worst-last by severity: `"good"` is a healthy
|
|
163
|
+
* connection, `"critical"` is barely usable.
|
|
164
|
+
*/
|
|
165
|
+
type ConnectionQualityLevel = "good" | "fair" | "poor" | "critical";
|
|
166
|
+
/**
|
|
167
|
+
* One periodic sample of the outbound connection's health, taken from
|
|
168
|
+
* `RTCPeerConnection.getStats()`. Packet loss and send bitrate are windowed over
|
|
169
|
+
* the interval since the previous sample (the first sample covers the session so
|
|
170
|
+
* far); the rest are point-in-time readings. A field is `null` when the browser
|
|
171
|
+
* did not report the underlying stat for this sample.
|
|
172
|
+
*/
|
|
173
|
+
interface ConnectionStatsSample {
|
|
174
|
+
/** Monotonic clock timestamp (ms) when the sample was taken. */
|
|
175
|
+
timestamp: number;
|
|
176
|
+
/**
|
|
177
|
+
* Fraction of outbound RTP packets lost, in `0..1` — the primary quality
|
|
178
|
+
* signal. A traffic-weighted mean of each stream's loss fraction: a stream uses
|
|
179
|
+
* its remote `fractionLost` (its loss ratio over the last RTCP report interval)
|
|
180
|
+
* when present, otherwise its windowed
|
|
181
|
+
* `Δpacketslost / Δ(packetsSent - retransmittedPacketsSent)`. Both kinds of
|
|
182
|
+
* stream are combined, so a lossy stream is never dropped for lacking
|
|
183
|
+
* `fractionLost`.
|
|
184
|
+
*/
|
|
185
|
+
lossRatio: number;
|
|
186
|
+
/** Round-trip time in milliseconds, or `null` if unknown. */
|
|
187
|
+
rttMs: number | null;
|
|
188
|
+
/** Inter-arrival jitter in milliseconds, or `null` if unknown. */
|
|
189
|
+
jitterMs: number | null;
|
|
190
|
+
/** ICE-estimated available outgoing bitrate in bits/sec, or `null` if unknown. */
|
|
191
|
+
availableOutgoingBitrate: number | null;
|
|
192
|
+
/** Actual send bitrate over the interval in bits/sec, or `null` if unknown. */
|
|
193
|
+
sendBitrate: number | null;
|
|
194
|
+
/**
|
|
195
|
+
* Why the encoder is limiting quality: `"none"`, `"cpu"`, `"bandwidth"`, or
|
|
196
|
+
* `"other"`. `null` when no video is being sent. `"bandwidth"` is treated as a
|
|
197
|
+
* degradation signal by the default classifier.
|
|
198
|
+
*/
|
|
199
|
+
qualityLimitationReason: string | null;
|
|
200
|
+
/** Cumulative NACKs received on outbound media, or `null` if unknown. */
|
|
201
|
+
nackCount: number | null;
|
|
202
|
+
/** Cumulative PLIs received on outbound media, or `null` if unknown. */
|
|
203
|
+
pliCount: number | null;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* A committed connection-quality assessment, delivered to
|
|
207
|
+
* {@link PublisherCallbacks.onConnectionQualityChange} whenever the level
|
|
208
|
+
* changes. `sample` is the reading that triggered the transition.
|
|
209
|
+
*/
|
|
210
|
+
interface ConnectionQuality {
|
|
211
|
+
level: ConnectionQualityLevel;
|
|
212
|
+
sample: ConnectionStatsSample;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Thresholds mapping a {@link ConnectionStatsSample} to a
|
|
216
|
+
* {@link ConnectionQualityLevel}. Packet loss is the primary axis; RTT and
|
|
217
|
+
* jitter can only push the assessment to a worse level, never a better one, and
|
|
218
|
+
* a `"bandwidth"` encoder limitation forces at least `"fair"`. Any subset may be
|
|
219
|
+
* overridden via {@link PublisherOptions.connectionQualityThresholds}; the rest
|
|
220
|
+
* keep their defaults.
|
|
221
|
+
*/
|
|
222
|
+
interface ConnectionQualityThresholds {
|
|
223
|
+
/** Loss ratio (`0..1`) at or above which quality is at least `"fair"`. Default `0.02`. */
|
|
224
|
+
fairLossRatio: number;
|
|
225
|
+
/** Loss ratio at or above which quality is at least `"poor"`. Default `0.05`. */
|
|
226
|
+
poorLossRatio: number;
|
|
227
|
+
/** Loss ratio at or above which quality is `"critical"`. Default `0.12`. */
|
|
228
|
+
criticalLossRatio: number;
|
|
229
|
+
/** RTT (ms) at or above which quality is at least `"fair"`. Default `300`. */
|
|
230
|
+
fairRttMs: number;
|
|
231
|
+
/** RTT (ms) at or above which quality is at least `"poor"`. Default `600`. */
|
|
232
|
+
poorRttMs: number;
|
|
233
|
+
/** RTT (ms) at or above which quality is `"critical"`. Default `1000`. */
|
|
234
|
+
criticalRttMs: number;
|
|
235
|
+
/** Jitter (ms) at or above which quality is at least `"fair"`. Default `50`. */
|
|
236
|
+
fairJitterMs: number;
|
|
237
|
+
/** Jitter (ms) at or above which quality is at least `"poor"`. Default `150`. */
|
|
238
|
+
poorJitterMs: number;
|
|
239
|
+
}
|
|
141
240
|
type PublisherRecoveryState = "recovering" | "recovered" | "failed";
|
|
142
241
|
type PublisherRecoveryAction = "sender_restart" | "ice_restart";
|
|
143
242
|
type PublisherRecoveryFailureReason = "capture_ended" | "automatic_recovery_failed";
|
|
@@ -165,7 +264,12 @@ interface GatewayReadyInfo {
|
|
|
165
264
|
* Options for publishing a media stream.
|
|
166
265
|
*/
|
|
167
266
|
interface PublisherOptions {
|
|
168
|
-
/**
|
|
267
|
+
/**
|
|
268
|
+
* Gateway WebSocket URLs returned by POST /api/streams `gateway_urls`. All are
|
|
269
|
+
* opened at once; the region whose `accepted` returns first is selected on
|
|
270
|
+
* network path, and only that region places the stream. The rest are held as
|
|
271
|
+
* standbys the publisher fails over to.
|
|
272
|
+
*/
|
|
169
273
|
gatewayURLs: string[];
|
|
170
274
|
/** The short-lived join token from POST /api/streams. */
|
|
171
275
|
token: string;
|
|
@@ -187,11 +291,26 @@ interface PublisherOptions {
|
|
|
187
291
|
*/
|
|
188
292
|
turnTransportPolicy?: TurnTransportPolicy;
|
|
189
293
|
/**
|
|
190
|
-
* Overall deadline for the initial accepted/proceed/ready gateway race
|
|
191
|
-
*
|
|
192
|
-
*
|
|
294
|
+
* Overall deadline for the initial accepted/proceed/ready gateway race,
|
|
295
|
+
* spanning selection, placement, and any failovers. Sockets that have not sent
|
|
296
|
+
* `accepted` are replaced after three seconds within this deadline. Defaults to
|
|
297
|
+
* 20 seconds.
|
|
193
298
|
*/
|
|
194
299
|
gatewayHandshakeTimeoutMs?: number;
|
|
300
|
+
/**
|
|
301
|
+
* How long the selected region has to return `ready` before the publisher
|
|
302
|
+
* abandons it and fails over to the next-fastest acknowledgement. This is a
|
|
303
|
+
* backstop for a region whose socket stays open but silent (a hung placement);
|
|
304
|
+
* a socket that closes or errors fails over immediately regardless. It is
|
|
305
|
+
* deliberately generous — placement includes the selected region's own
|
|
306
|
+
* control-plane round-trips, and a short deadline would abandon exactly the
|
|
307
|
+
* user-close-but-control-plane-distant regions this race is meant to prefer.
|
|
308
|
+
* Defaults to 8 seconds and is capped at 20 seconds: the gateway reaps a
|
|
309
|
+
* standby socket that has been accepted but not yet told to proceed, so the
|
|
310
|
+
* failover window must stay below that deadline or standbys would disappear
|
|
311
|
+
* before the browser fails over to them.
|
|
312
|
+
*/
|
|
313
|
+
gatewayFailoverTimeoutMs?: number;
|
|
195
314
|
/** Deadline after the initial offer for WebRTC to reach connected. Defaults to 30 seconds. */
|
|
196
315
|
peerConnectionTimeoutMs?: number;
|
|
197
316
|
/**
|
|
@@ -206,6 +325,24 @@ interface PublisherOptions {
|
|
|
206
325
|
preferredVideoCodecs?: string[];
|
|
207
326
|
/** How long to retry a dropped signaling connection to the selected gateway. Defaults to 20 seconds. */
|
|
208
327
|
signalingReconnectTimeoutMs?: number;
|
|
328
|
+
/**
|
|
329
|
+
* How often, in milliseconds, to poll `RTCPeerConnection.getStats()` for
|
|
330
|
+
* connection-quality assessment once connected. Defaults to 2000. Set to 0 to
|
|
331
|
+
* disable stats polling entirely — neither {@link PublisherCallbacks.onConnectionStats}
|
|
332
|
+
* nor {@link PublisherCallbacks.onConnectionQualityChange} will fire.
|
|
333
|
+
*/
|
|
334
|
+
connectionStatsIntervalMs?: number;
|
|
335
|
+
/**
|
|
336
|
+
* Overrides for the connection-quality classification thresholds. Any omitted
|
|
337
|
+
* field keeps its default. See {@link ConnectionQualityThresholds}.
|
|
338
|
+
*/
|
|
339
|
+
connectionQualityThresholds?: Partial<ConnectionQualityThresholds>;
|
|
340
|
+
/**
|
|
341
|
+
* Number of consecutive worse-than-current samples required before a quality
|
|
342
|
+
* downgrade is committed, damping transient blips. Improvements are reported
|
|
343
|
+
* on the first better sample. Defaults to 2; values below 1 are treated as 1.
|
|
344
|
+
*/
|
|
345
|
+
connectionQualityDebounceSamples?: number;
|
|
209
346
|
/** Callbacks for lifecycle events. */
|
|
210
347
|
callbacks?: PublisherCallbacks;
|
|
211
348
|
}
|
|
@@ -251,6 +388,11 @@ declare class Publisher {
|
|
|
251
388
|
private gatewayURL;
|
|
252
389
|
private lastReportedICEPath;
|
|
253
390
|
private watchedICETransports;
|
|
391
|
+
private connectionStatsTimer;
|
|
392
|
+
private statsSampleInFlight;
|
|
393
|
+
private lastStatsSample;
|
|
394
|
+
private currentQualityLevel;
|
|
395
|
+
private qualityDowngradeStreak;
|
|
254
396
|
private stopped;
|
|
255
397
|
private lifecycleGeneration;
|
|
256
398
|
private runAbort;
|
|
@@ -433,6 +575,13 @@ declare class Publisher {
|
|
|
433
575
|
private releaseLocalCandidateBatch;
|
|
434
576
|
private applyAnswered;
|
|
435
577
|
private watchSelectedICEPairChanges;
|
|
578
|
+
private startConnectionStatsLoop;
|
|
579
|
+
private stopConnectionStatsLoop;
|
|
580
|
+
private sampleConnectionQuality;
|
|
581
|
+
private buildStatsSample;
|
|
582
|
+
private resolveQualityThresholds;
|
|
583
|
+
private classifyQuality;
|
|
584
|
+
private updateConnectionQuality;
|
|
436
585
|
private reportSelectedICEPath;
|
|
437
586
|
private completeMediaRecovery;
|
|
438
587
|
private failMediaRecovery;
|
|
@@ -662,4 +811,4 @@ interface CaptureMicrophoneOptions {
|
|
|
662
811
|
*/
|
|
663
812
|
declare function captureMicrophone(opts?: CaptureMicrophoneOptions): Promise<MediaStream>;
|
|
664
813
|
|
|
665
|
-
export { type AssistantTextEvent, type CaptureCameraOptions, type CaptureMicrophoneOptions, type CaptureScreenOptions, type GatewayReadyInfo, Publisher, type PublisherCallbacks, type PublisherOptions, type PublisherRecoveryAction, type PublisherRecoveryEvent, type PublisherRecoveryFailureReason, type PublisherRecoveryState, type SignalMessage, type TrackLabel, type TrackType, type TurnTransportPolicy, type UserTextResultEvent, type VideoTrackType, captureCamera, captureMicrophone, captureScreen };
|
|
814
|
+
export { type AssistantTextEvent, type CaptureCameraOptions, type CaptureMicrophoneOptions, type CaptureScreenOptions, type ConnectionQuality, type ConnectionQualityLevel, type ConnectionQualityThresholds, type ConnectionStatsSample, type GatewayReadyInfo, Publisher, type PublisherCallbacks, type PublisherOptions, type PublisherRecoveryAction, type PublisherRecoveryEvent, type PublisherRecoveryFailureReason, type PublisherRecoveryState, type SignalMessage, type TrackLabel, type TrackType, type TurnTransportPolicy, type UserTextResultEvent, type VideoTrackType, captureCamera, captureMicrophone, captureScreen };
|