moqtail 0.13.0 → 0.14.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.
- package/README.md +43 -0
- package/dist/{client-BzncAN14.mjs → client-BW1agDFV.mjs} +1268 -686
- package/dist/{client-DahXR3l4.cjs → client-Z7egUKTO.cjs} +1240 -628
- package/dist/client.cjs +6 -1
- package/dist/client.d.cts +583 -331
- package/dist/client.d.mts +583 -331
- package/dist/client.mjs +2 -2
- package/dist/{index-C8pNnaj0.d.cts → index-DBbxKcc1.d.cts} +594 -357
- package/dist/{index-C8pNnaj0.d.mts → index-DBbxKcc1.d.mts} +594 -357
- package/dist/index.cjs +30 -16
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/model.cjs +1139 -489
- package/dist/model.d.cts +2 -2
- package/dist/model.d.mts +2 -2
- package/dist/model.mjs +1116 -475
- package/package.json +1 -1
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as RequestError, B as GoAway, En as FetchObject, F as RequestUpdate, H as FetchOk, Hn as ObjectStatus, I as SubscribeOk, In as FetchHeader, Jn as Location, Kn as Tuple, L as Publish, Ln as Datagram, Lt as LocationFilter, M as SubscribeTracks, N as SubscribeNamespace, O as StreamResetCode, On as ControlMessageType, P as TrackStatus, Pn as SwitchMode, R as PublishDone, Sn as FullTrackName, X as TrackProperty, _n as Header, at as Setup, bn as MoqtObject, ct as PublishNamespace, it as Fetch, j as RequestOk, jn as PublishDoneStatusCode, k as ControlMessage, kn as GroupOrder, lt as MessageParameter, pn as PublishSkipped, r as SetupOptions, vn as RequestIdMap, xn as SubgroupObject, yn as SubgroupHeader, z as Subscribe } from "./index-DBbxKcc1.mjs";
|
|
2
2
|
import { t as LogLevel } from "./logger-dEoueCj7.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/client/control_stream.d.ts
|
|
@@ -36,6 +36,74 @@ declare class ControlStream {
|
|
|
36
36
|
close(): Promise<void>;
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
|
+
//#region src/client/data_event.d.ts
|
|
40
|
+
/** `in` for a stream the peer opened, `out` for one this client opened. */
|
|
41
|
+
type DataDirection = 'in' | 'out';
|
|
42
|
+
/** What every data event carries. */
|
|
43
|
+
type DataEventBase = {
|
|
44
|
+
direction: DataDirection; /** Local to this client, unique per data stream; every later event on the stream carries it. */
|
|
45
|
+
streamId: number;
|
|
46
|
+
/**
|
|
47
|
+
* When the client wrote or read it, as `performance.now()` in ms: high resolution and
|
|
48
|
+
* monotonic, so differences between events are exact. Add `performance.timeOrigin` for
|
|
49
|
+
* wall-clock time.
|
|
50
|
+
*/
|
|
51
|
+
at: number;
|
|
52
|
+
};
|
|
53
|
+
/** A data stream opened: what its header says. */
|
|
54
|
+
type DataHeaderEvent = DataEventBase & {
|
|
55
|
+
kind: 'header';
|
|
56
|
+
stream: 'subgroup' | 'fetch'; /** Subgroup streams only. */
|
|
57
|
+
trackAlias?: bigint; /** Subgroup streams only. */
|
|
58
|
+
groupId?: bigint; /** Subgroup streams only; unknown here when the header defers it to the first Object ID. */
|
|
59
|
+
subgroupId?: bigint; /** Fetch streams only. */
|
|
60
|
+
requestId?: bigint; /** The track the stream belongs to, when the client knows it at header time. */
|
|
61
|
+
fullTrackName?: FullTrackName;
|
|
62
|
+
};
|
|
63
|
+
/** One object written or read. Only its identity and size are reported, never its payload. */
|
|
64
|
+
type DataObjectEvent = DataEventBase & {
|
|
65
|
+
kind: 'object';
|
|
66
|
+
groupId: bigint;
|
|
67
|
+
subgroupId?: bigint;
|
|
68
|
+
objectId: bigint;
|
|
69
|
+
payloadLength: number; /** Set for an object that carries a status instead of a payload. */
|
|
70
|
+
objectStatus?: ObjectStatus;
|
|
71
|
+
/**
|
|
72
|
+
* The object's LOC Timestamp property, when it carries one: the sender's media time,
|
|
73
|
+
* in whatever unit and clock the sender chose.
|
|
74
|
+
*/
|
|
75
|
+
locTimestamp?: bigint;
|
|
76
|
+
};
|
|
77
|
+
/** A data stream ended: `fin` when it closed cleanly, `reset` when either side reset it. */
|
|
78
|
+
type DataStreamEndEvent = DataEventBase & {
|
|
79
|
+
kind: 'end';
|
|
80
|
+
reason: 'fin' | 'reset' | 'error';
|
|
81
|
+
resetCode?: StreamResetCode;
|
|
82
|
+
};
|
|
83
|
+
type DataEvent = DataHeaderEvent | DataObjectEvent | DataStreamEndEvent;
|
|
84
|
+
type DataEventObserver = (event: DataEvent) => void;
|
|
85
|
+
/** What a data stream is handed so it can report itself. */
|
|
86
|
+
type DataStreamObserver = {
|
|
87
|
+
onDataEvent: DataEventObserver; /** Names the track a header belongs to, if known. */
|
|
88
|
+
fullTrackNameOf?: (header: Header) => FullTrackName | undefined;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Turns one data stream's activity into {@link DataEvent}s. A throwing observer is
|
|
92
|
+
* logged and otherwise ignored, so it can never break the stream it watches.
|
|
93
|
+
*/
|
|
94
|
+
declare class DataStreamReporter {
|
|
95
|
+
#private;
|
|
96
|
+
private readonly direction;
|
|
97
|
+
private readonly observer?;
|
|
98
|
+
readonly streamId: number;
|
|
99
|
+
constructor(direction: DataDirection, observer?: DataStreamObserver | undefined);
|
|
100
|
+
header(header: Header): void;
|
|
101
|
+
/** `header` is the stream's own: a subgroup object takes its group and subgroup from it. */
|
|
102
|
+
object(header: Header, object: SubgroupObject | FetchObject): void;
|
|
103
|
+
/** Reports how the stream ended. Only the first call counts. */
|
|
104
|
+
end(reason: DataStreamEndEvent['reason'], resetCode?: StreamResetCode): void;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
39
107
|
//#region src/client/track/object_cache.d.ts
|
|
40
108
|
/**
|
|
41
109
|
* In‑memory index of {@link MoqtObject} instances keyed by their {@link Location} (group/subgroup/object),
|
|
@@ -225,175 +293,6 @@ type Track = {
|
|
|
225
293
|
trackProperties?: TrackProperty[];
|
|
226
294
|
};
|
|
227
295
|
//#endregion
|
|
228
|
-
//#region src/client/request_stream.d.ts
|
|
229
|
-
/**
|
|
230
|
-
* Wraps a WebTransport bidirectional stream carrying one MOQT request.
|
|
231
|
-
* Because a response is correlated by the stream it arrives on, nothing here needs a
|
|
232
|
-
* request id.
|
|
233
|
-
*/
|
|
234
|
-
declare class RequestStream {
|
|
235
|
-
#private;
|
|
236
|
-
readonly stream: ReadableStream<ControlMessage>;
|
|
237
|
-
/**
|
|
238
|
-
* The message this side opened the stream with, kept so the request can be re-issued
|
|
239
|
-
* on a fresh stream when the peer migrates it with a GOAWAY (§10.4). Undefined on a
|
|
240
|
-
* peer-opened stream, which is the peer's request to re-issue, not ours.
|
|
241
|
-
*/
|
|
242
|
-
first?: ControlMessage;
|
|
243
|
-
/**
|
|
244
|
-
* The type of the message that opened this stream, whichever side opened it. It is
|
|
245
|
-
* what the request on this stream *is*, which decides what may follow — a
|
|
246
|
-
* REQUEST_UPDATE is only valid for the types §10.9 lists.
|
|
247
|
-
*/
|
|
248
|
-
openingType?: ControlMessageType;
|
|
249
|
-
/** Set when the request this stream carried has been re-issued on a new stream. */
|
|
250
|
-
migrated: boolean;
|
|
251
|
-
constructor(biStream: WebTransportBidirectionalStream);
|
|
252
|
-
/**
|
|
253
|
-
* Opens a new bidi stream and writes `first` on it.
|
|
254
|
-
*
|
|
255
|
-
* @throws :{@link ProtocolViolationError} If `first` is not one of the seven types
|
|
256
|
-
* Table 5 marks `First`; those are the only ones allowed to open a request stream.
|
|
257
|
-
*/
|
|
258
|
-
static open(webTransport: WebTransport, first: ControlMessage): Promise<RequestStream>;
|
|
259
|
-
/**
|
|
260
|
-
* Reads the next control message off this stream, or `undefined` once the peer has
|
|
261
|
-
* closed or reset it.
|
|
262
|
-
*
|
|
263
|
-
* Takes ownership of {@link RequestStream.stream}'s reader on first use, so callers
|
|
264
|
-
* must not mix `next()` with `stream.getReader()`.
|
|
265
|
-
*/
|
|
266
|
-
next(): Promise<ControlMessage | undefined>;
|
|
267
|
-
send(message: ControlMessage): Promise<void>;
|
|
268
|
-
close(): Promise<void>;
|
|
269
|
-
/**
|
|
270
|
-
* Cancels the request by resetting its stream with `code` (§3.3.2), which is how
|
|
271
|
-
* draft-18 cancels a request now that the dedicated cancel messages are gone.
|
|
272
|
-
*/
|
|
273
|
-
reset(code: StreamResetCode): Promise<void>;
|
|
274
|
-
}
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region src/client/publication/subscribe.d.ts
|
|
277
|
-
/**
|
|
278
|
-
* @public
|
|
279
|
-
* Manages the publication of MOQT objects to a subscriber for a specific track.
|
|
280
|
-
* Handles live object streaming, subscription lifecycle, and stream management.
|
|
281
|
-
*/
|
|
282
|
-
declare class SubscribePublication {
|
|
283
|
-
#private;
|
|
284
|
-
private readonly client;
|
|
285
|
-
readonly track: Track;
|
|
286
|
-
private readonly subscribeMsg;
|
|
287
|
-
private readonly requestStream;
|
|
288
|
-
/**
|
|
289
|
-
* The latest location that was published to the subscriber.
|
|
290
|
-
*/
|
|
291
|
-
latestLocation: Location | undefined;
|
|
292
|
-
/**
|
|
293
|
-
* Creates a new SubscribePublication instance.
|
|
294
|
-
* @param client - The MOQT client managing the subscription.
|
|
295
|
-
* @param track - The track being published.
|
|
296
|
-
* @param subscribeMsg - The subscribe message containing subscription details.
|
|
297
|
-
* @param requestStream - The bidi request stream the SUBSCRIBE arrived on. Every
|
|
298
|
-
* message this publication sends back to the subscriber goes on it.
|
|
299
|
-
* @param largestLocation - The largest location seen so far, used for determining start location.
|
|
300
|
-
*/
|
|
301
|
-
constructor(client: MOQtailClient, track: Track, subscribeMsg: Subscribe, requestStream: RequestStream, largestLocation?: Location);
|
|
302
|
-
/**
|
|
303
|
-
* Cancels the publication and cleans up resources.
|
|
304
|
-
* Removes the publication from the client's publication map.
|
|
305
|
-
*/
|
|
306
|
-
cancel(): void;
|
|
307
|
-
/**
|
|
308
|
-
* Marks the publication as done and sends a PublishDone message to the client.
|
|
309
|
-
* @param statusCode - The status code indicating why the publication ended.
|
|
310
|
-
* @throws :{@link InternalError} If sending the message fails.
|
|
311
|
-
*/
|
|
312
|
-
done(statusCode: PublishDoneStatusCode): Promise<void>;
|
|
313
|
-
/**
|
|
314
|
-
* Updates the subscription parameters and locations based on a RequestUpdate message.
|
|
315
|
-
* @param msg - The update message containing new request details.
|
|
316
|
-
*/
|
|
317
|
-
update(msg: RequestUpdate): void;
|
|
318
|
-
/**
|
|
319
|
-
* Publishes MOQT objects to the subscriber as they become available.
|
|
320
|
-
* Handles stream creation, object writing, and stream closure based on subscription parameters.
|
|
321
|
-
* @throws :{@link InternalError} If the track does not support live content.
|
|
322
|
-
*/
|
|
323
|
-
publish(): Promise<void>;
|
|
324
|
-
}
|
|
325
|
-
//#endregion
|
|
326
|
-
//#region src/client/publication/fetch.d.ts
|
|
327
|
-
declare class FetchPublication {
|
|
328
|
-
#private;
|
|
329
|
-
constructor(client: MOQtailClient, track: Track, fetchRequest: Fetch);
|
|
330
|
-
cancel(): void;
|
|
331
|
-
/**
|
|
332
|
-
* Resets the data stream this fetch is being delivered on, which §10.9.1 requires when
|
|
333
|
-
* a REQUEST_UPDATE for a FETCH fails.
|
|
334
|
-
*/
|
|
335
|
-
resetDataStream(code: StreamResetCode): Promise<void>;
|
|
336
|
-
publish(): Promise<void>;
|
|
337
|
-
}
|
|
338
|
-
//#endregion
|
|
339
|
-
//#region src/client/publication/publish.d.ts
|
|
340
|
-
/**
|
|
341
|
-
* @public
|
|
342
|
-
* Manages the proactive publication of MOQT objects from a publisher to the relay.
|
|
343
|
-
* Handles live object streaming and stream management.
|
|
344
|
-
*/
|
|
345
|
-
declare class PublishPublication {
|
|
346
|
-
#private;
|
|
347
|
-
private readonly client;
|
|
348
|
-
readonly track: Track;
|
|
349
|
-
private readonly publishMsg;
|
|
350
|
-
/**
|
|
351
|
-
* The latest location that was published to the relay.
|
|
352
|
-
*/
|
|
353
|
-
latestLocation: Location | undefined;
|
|
354
|
-
/**
|
|
355
|
-
* Creates a new PublishPublication instance.
|
|
356
|
-
* @param client - The MOQT client managing the connection.
|
|
357
|
-
* @param track - The track being proactively published.
|
|
358
|
-
* @param publishMsg - The publish message that initiated this session.
|
|
359
|
-
*/
|
|
360
|
-
constructor(client: MOQtailClient, track: Track, publishMsg: Publish);
|
|
361
|
-
/**
|
|
362
|
-
* How many data streams this publication has opened, which is what a PUBLISH_DONE
|
|
363
|
-
* reports to the subscriber.
|
|
364
|
-
*/
|
|
365
|
-
get streamsOpened(): bigint;
|
|
366
|
-
/**
|
|
367
|
-
* Whether Objects are being sent right now. False while the peer holds this
|
|
368
|
-
* publication at FORWARD=0.
|
|
369
|
-
*/
|
|
370
|
-
get forwarding(): boolean;
|
|
371
|
-
/**
|
|
372
|
-
* Moves the Forward State: false parks the publication, true resumes it. The
|
|
373
|
-
* application hears about the move through {@link MOQtailClient.onForwardStateChange},
|
|
374
|
-
* which is where a publisher starts or stops the work behind the track -- a camera
|
|
375
|
-
* and an encoder cost the same whether or not anything is listening.
|
|
376
|
-
*/
|
|
377
|
-
setForwardState(forward: boolean): void;
|
|
378
|
-
/**
|
|
379
|
-
* Applies a REQUEST_UPDATE the peer sent on this publication's request stream. The
|
|
380
|
-
* Forward State is the one thing it can move; what a publisher sends, and when,
|
|
381
|
-
* is otherwise its own to decide.
|
|
382
|
-
*/
|
|
383
|
-
update(msg: RequestUpdate): void;
|
|
384
|
-
/**
|
|
385
|
-
* Cancels the publication and cleans up resources.
|
|
386
|
-
* Removes the publication from the client's publication map.
|
|
387
|
-
*/
|
|
388
|
-
cancel(): void;
|
|
389
|
-
/**
|
|
390
|
-
* Publishes MOQT objects to the relay as they become available.
|
|
391
|
-
* Handles stream creation, object writing, and stream closure.
|
|
392
|
-
* @throws :{@link InternalError} If the track does not support live content.
|
|
393
|
-
*/
|
|
394
|
-
publishToRelay(): Promise<void>;
|
|
395
|
-
}
|
|
396
|
-
//#endregion
|
|
397
296
|
//#region src/client/request/publish_namespace.d.ts
|
|
398
297
|
declare class PublishNamespaceRequest implements PromiseLike<RequestOk | RequestError> {
|
|
399
298
|
readonly requestId: bigint;
|
|
@@ -428,34 +327,6 @@ declare class FetchRequest implements PromiseLike<FetchOk | RequestError> {
|
|
|
428
327
|
finally(onfinally?: (() => void) | undefined | null): Promise<FetchOk | RequestError>;
|
|
429
328
|
}
|
|
430
329
|
//#endregion
|
|
431
|
-
//#region src/client/request/subscribe.d.ts
|
|
432
|
-
declare class SubscribeRequest implements PromiseLike<SubscribeOk | RequestError> {
|
|
433
|
-
#private;
|
|
434
|
-
requestId: bigint;
|
|
435
|
-
fullTrackName: FullTrackName;
|
|
436
|
-
isCanceled: boolean;
|
|
437
|
-
startLocation: Location | undefined;
|
|
438
|
-
endGroup: bigint | undefined;
|
|
439
|
-
priority: number;
|
|
440
|
-
forward: boolean;
|
|
441
|
-
subscribeParameters: MessageParameter[];
|
|
442
|
-
earlyDiscardPolicy: EarlyDiscardPolicyConfig | undefined;
|
|
443
|
-
largestLocation: Location | undefined;
|
|
444
|
-
streamsAccepted: bigint;
|
|
445
|
-
expectedStreams: bigint | undefined;
|
|
446
|
-
readonly controller: ReadableStreamDefaultController<MoqtObject>;
|
|
447
|
-
readonly stream: ReadableStream<MoqtObject>;
|
|
448
|
-
constructor(msg: Subscribe);
|
|
449
|
-
update(msg: RequestUpdate): void;
|
|
450
|
-
switch(newTrackName: FullTrackName, newParameters: MessageParameter[]): void;
|
|
451
|
-
unsubscribe(): void;
|
|
452
|
-
resolve(value: SubscribeOk | RequestError | PromiseLike<SubscribeOk | RequestError>): void;
|
|
453
|
-
reject(reason?: any): void;
|
|
454
|
-
then<TResult1 = SubscribeOk | RequestError, TResult2 = never>(onfulfilled?: ((value: SubscribeOk | RequestError) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
|
|
455
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<SubscribeOk | RequestError | TResult>;
|
|
456
|
-
finally(onfinally?: (() => void) | undefined | null): Promise<SubscribeOk | RequestError>;
|
|
457
|
-
}
|
|
458
|
-
//#endregion
|
|
459
330
|
//#region src/client/request/subscribe_namespace.d.ts
|
|
460
331
|
declare class SubscribeNamespaceRequest implements PromiseLike<RequestOk | RequestError> {
|
|
461
332
|
readonly requestId: bigint;
|
|
@@ -533,6 +404,39 @@ declare class TrackStatusRequest implements PromiseLike<RequestOk | RequestError
|
|
|
533
404
|
* ```
|
|
534
405
|
*/
|
|
535
406
|
type MOQtailRequest = PublishRequest | PublishNamespaceRequest | SubscribeNamespaceRequest | FetchRequest | SubscribeRequest | TrackStatusRequest;
|
|
407
|
+
/**
|
|
408
|
+
* Whatever holds a track alias in the client's routing table: a {@link SubscribeRequest},
|
|
409
|
+
* or the receiver {@link MOQtailClient.acceptPushedTrack} stands up for a track the peer
|
|
410
|
+
* pushes. Incoming objects are named after the holder of the alias their stream carries.
|
|
411
|
+
*/
|
|
412
|
+
type TrackAliasHolder = {
|
|
413
|
+
requestId: bigint;
|
|
414
|
+
fullTrackName: FullTrackName;
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* Default for {@link MOQtailClientOptions.trackAliasResolutionTimeoutMs}: how long a
|
|
418
|
+
* data stream waits for the control message that establishes its track alias.
|
|
419
|
+
*
|
|
420
|
+
* A subscription's data streams and the SUBSCRIBE_OK naming their alias travel on
|
|
421
|
+
* separate streams, so nothing orders them; the data can arrive first. Waiting costs
|
|
422
|
+
* a stalled reader, giving up costs the whole subgroup, so the wait is generous.
|
|
423
|
+
*/
|
|
424
|
+
declare const DEFAULT_TRACK_ALIAS_RESOLUTION_TIMEOUT_MS = 2000;
|
|
425
|
+
/**
|
|
426
|
+
* Default for {@link MOQtailClientOptions.switchDrainTimeoutMs}: how long a track a
|
|
427
|
+
* soft switch handed over from may stay quiet before it is retired anyway.
|
|
428
|
+
*
|
|
429
|
+
* A soft switch leaves that track delivering up to the group the new one starts at,
|
|
430
|
+
* so the two meet without a hole, and a PUBLISH_DONE normally ends it. This is the
|
|
431
|
+
* backstop for a publisher that never sends one.
|
|
432
|
+
*/
|
|
433
|
+
declare const DEFAULT_SWITCH_DRAIN_TIMEOUT_MS = 2000;
|
|
434
|
+
/**
|
|
435
|
+
* @public
|
|
436
|
+
* The MAX_FILTER_RANGES a client advertises when its setup options set none: how
|
|
437
|
+
* many Range Filter ranges it applies, in total, for one subscription or fetch.
|
|
438
|
+
*/
|
|
439
|
+
declare const DEFAULT_MAX_FILTER_RANGES = 32n;
|
|
536
440
|
/**
|
|
537
441
|
* Options for {@link MOQtailClient.new} controlling connection target, protocol negotiation, timeouts,
|
|
538
442
|
* and lifecycle callbacks.
|
|
@@ -567,73 +471,92 @@ type MOQtailClientOptions = {
|
|
|
567
471
|
protocols?: string[];
|
|
568
472
|
}; /** Per *data* uni-stream idle timeout in milliseconds. */
|
|
569
473
|
dataStreamTimeoutMs?: number; /** Control stream read timeout in milliseconds. */
|
|
570
|
-
controlStreamTimeoutMs?: number;
|
|
474
|
+
controlStreamTimeoutMs?: number;
|
|
475
|
+
/**
|
|
476
|
+
* How long a data stream waits for the control message that establishes its track
|
|
477
|
+
* alias before the stream is abandoned, in milliseconds. Defaults to
|
|
478
|
+
* {@link DEFAULT_TRACK_ALIAS_RESOLUTION_TIMEOUT_MS}.
|
|
479
|
+
*/
|
|
480
|
+
trackAliasResolutionTimeoutMs?: number;
|
|
481
|
+
/**
|
|
482
|
+
* How long a track a soft switch handed over from may stay quiet before it is
|
|
483
|
+
* retired anyway, in milliseconds. Defaults to
|
|
484
|
+
* {@link DEFAULT_SWITCH_DRAIN_TIMEOUT_MS}.
|
|
485
|
+
*/
|
|
486
|
+
switchDrainTimeoutMs?: number; /** If true, enables datagram support for the session. */
|
|
571
487
|
enableDatagrams?: boolean; /** callbacks for observability and logging purposes: */
|
|
572
488
|
callbacks?: {
|
|
573
489
|
/** Called after a control message is successfully written to the {@link ControlStream}. */onMessageSent?: (msg: ControlMessage) => void; /** Called for each incoming control message before protocol handling. */
|
|
574
490
|
onMessageReceived?: (msg: ControlMessage) => void; /** Fired once when the session ends (normal or error). Receives the reason passed to {@link MOQtailClient.disconnect | disconnect}. */
|
|
575
491
|
onSessionTerminated?: (reason?: unknown) => void; /** Invoked for each decoded datagram object/status arriving. */
|
|
576
492
|
onDatagramReceived?: (data: Datagram) => void; /** Invoked after enqueuing each outbound datagram object/status. */
|
|
577
|
-
onDatagramSent?: (data: Datagram) => void;
|
|
493
|
+
onDatagramSent?: (data: Datagram) => void; /** Invoked for each data stream's header, each of its objects, and its end. See {@link MOQtailClient.onDataEvent}. */
|
|
494
|
+
onDataEvent?: DataEventObserver;
|
|
578
495
|
};
|
|
579
496
|
};
|
|
580
497
|
/**
|
|
581
498
|
* Parameters for {@link MOQtailClient.subscribe | subscribing} to a track's live objects.
|
|
582
499
|
*
|
|
583
|
-
* @example
|
|
500
|
+
* @example From the next object
|
|
584
501
|
* ```ts
|
|
585
502
|
* await client.subscribe({
|
|
586
503
|
* fullTrackName,
|
|
587
504
|
* priority: 0,
|
|
588
505
|
* groupOrder: GroupOrder.Original,
|
|
589
506
|
* forward: true,
|
|
590
|
-
*
|
|
507
|
+
* locationFilter: new LocationFilter(LocationFilterType.NextObject)
|
|
591
508
|
* })
|
|
592
509
|
* ```
|
|
593
|
-
* @example
|
|
510
|
+
* @example Groups 100 through 120
|
|
594
511
|
* ```ts
|
|
595
512
|
* await client.subscribe({
|
|
596
513
|
* fullTrackName,
|
|
597
514
|
* priority: 32,
|
|
598
515
|
* groupOrder: GroupOrder.Original,
|
|
599
516
|
* forward: true,
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
517
|
+
* locationFilter: new LocationFilter(LocationFilterType.AbsoluteStartGroupEnd, 100n, 0n, 120n)
|
|
518
|
+
* })
|
|
519
|
+
* ```
|
|
520
|
+
* @example From the next object, filling the current group from its start
|
|
521
|
+
* ```ts
|
|
522
|
+
* await client.subscribe({
|
|
523
|
+
* fullTrackName,
|
|
524
|
+
* priority: 0,
|
|
525
|
+
* groupOrder: GroupOrder.Original,
|
|
526
|
+
* locationFilter: new LocationFilter(LocationFilterType.NextObject),
|
|
527
|
+
* parameters: [new FillParameters([new LocationFilter(LocationFilterType.RelativeStart, 1n)])]
|
|
603
528
|
* })
|
|
604
529
|
* ```
|
|
605
530
|
*/
|
|
606
531
|
type SubscribeOptions = {
|
|
607
532
|
/** Fully qualified track identifier ({@link FullTrackName}). */fullTrackName: FullTrackName; /** Subscriber priority (0 = highest, 255 = lowest). Values outside range are clamped. Fractional values are rounded. */
|
|
608
533
|
priority: number; /** Desired {@link (GroupOrder:enum)} (e.g. {@link (GroupOrder:enum).Original}) specifying delivery ordering semantics. */
|
|
609
|
-
groupOrder: GroupOrder; /** If
|
|
610
|
-
forward
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
534
|
+
groupOrder: GroupOrder; /** If present, forward parameter (0x10) is sent with the provided value */
|
|
535
|
+
forward?: boolean; /** The {@link LocationFilter} selecting which Objects to deliver. Omitted, the subscription is unfiltered. */
|
|
536
|
+
locationFilter?: LocationFilter;
|
|
537
|
+
/**
|
|
538
|
+
* Optional extension parameters appended to the SUBSCRIBE control message. A
|
|
539
|
+
* FILL_PARAMETERS here also retrieves already-published Objects on a fill fetch stream.
|
|
540
|
+
*/
|
|
541
|
+
parameters?: MessageParameter[]; /** Per-subscription early discard policy. Overrides the client-level default set via {@link MOQtailClient.setEarlyDiscardPolicy}. */
|
|
615
542
|
earlyDiscardPolicy?: EarlyDiscardPolicyConfig;
|
|
616
543
|
};
|
|
617
544
|
/**
|
|
618
|
-
*
|
|
545
|
+
* Changes applied to an existing SUBSCRIBE via {@link MOQtailClient.subscribeUpdate}.
|
|
619
546
|
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
* @example Narrowing a live window
|
|
547
|
+
* @example Narrowing a live window to groups 200 through 210
|
|
623
548
|
* ```ts
|
|
624
549
|
* await client.subscribeUpdate({
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
* endGroup: 210n,
|
|
550
|
+
* subscriptionRequestId,
|
|
551
|
+
* locationFilter: new LocationFilter(LocationFilterType.AbsoluteStartGroupEnd, 200n, 0n, 210n),
|
|
628
552
|
* priority: 16,
|
|
629
553
|
* forward: true
|
|
630
554
|
* })
|
|
631
555
|
* ```
|
|
632
556
|
*/
|
|
633
557
|
type SubscribeUpdateOptions = {
|
|
634
|
-
/** The original SUBSCRIBE request id (bigint) being updated. */subscriptionRequestId: bigint; /**
|
|
635
|
-
|
|
636
|
-
endGroup: bigint; /** Updated subscriber priority (same constraints as initial subscribe). 0 is highest, 255 is lowest. */
|
|
558
|
+
/** The original SUBSCRIBE request id (bigint) being updated. */subscriptionRequestId: bigint; /** The new {@link LocationFilter}. Omitted, the subscription keeps its own. */
|
|
559
|
+
locationFilter?: LocationFilter; /** Updated subscriber priority (same constraints as initial subscribe). 0 is highest, 255 is lowest. */
|
|
637
560
|
priority: number; /** Updated direction flag. */
|
|
638
561
|
forward: boolean; /** Optional additional parameters; existing parameters persist if omitted. */
|
|
639
562
|
parameters?: MessageParameter[];
|
|
@@ -641,89 +564,351 @@ type SubscribeUpdateOptions = {
|
|
|
641
564
|
/**
|
|
642
565
|
* Parameters for {@link MOQtailClient.switch | switching} an existing SUBSCRIBE to a new track.
|
|
643
566
|
*
|
|
644
|
-
* @example Switching subscription to a new track
|
|
567
|
+
* @example Switching a subscription to a new track
|
|
645
568
|
* ```ts
|
|
646
569
|
* await client.switch({
|
|
647
|
-
*
|
|
648
|
-
*
|
|
570
|
+
* switchFromRequestId,
|
|
571
|
+
* switchMode: SwitchMode.Soft,
|
|
572
|
+
* newSubscribeOptions: {
|
|
573
|
+
* fullTrackName: newFullTrackName,
|
|
574
|
+
* priority: 0,
|
|
575
|
+
* groupOrder: GroupOrder.Original,
|
|
576
|
+
* forward: true,
|
|
577
|
+
* locationFilter: new LocationFilter(LocationFilterType.NextObject)
|
|
578
|
+
* }
|
|
649
579
|
* })
|
|
650
580
|
* ```
|
|
651
581
|
*/
|
|
652
582
|
type SwitchOptions = {
|
|
653
|
-
/**
|
|
654
|
-
|
|
655
|
-
|
|
583
|
+
/** The original SUBSCRIBE request id (bigint) being switched from. */switchFromRequestId: bigint; /** {@link SwitchMode} controlling how the switch is applied. */
|
|
584
|
+
switchMode: SwitchMode; /** New subscription options to switch to. */
|
|
585
|
+
newSubscribeOptions: SubscribeOptions; /** Callback to determine whether to continue draining the superseded subscription. Returning true will reset the relevant stream. */
|
|
586
|
+
onDrainDecision?: (request: SubscribeRequest) => boolean;
|
|
587
|
+
};
|
|
588
|
+
/**
|
|
589
|
+
* Configuration for the early discard policy applied to incoming subgroup streams.
|
|
590
|
+
*/
|
|
591
|
+
type EarlyDiscardPolicyConfig = {
|
|
592
|
+
/** Cancel a subgroup QUIC stream if it has not fully completed within this many milliseconds. */subgroupReceiveTimeout: number;
|
|
656
593
|
};
|
|
657
594
|
/**
|
|
658
|
-
* Options for {@link MOQtailClient.fetch | performing a FETCH}
|
|
595
|
+
* Options for {@link MOQtailClient.fetch | performing a FETCH} of Objects already published.
|
|
659
596
|
*
|
|
660
|
-
* @example
|
|
597
|
+
* @example Groups 10 through 12, inclusive
|
|
661
598
|
* ```ts
|
|
662
599
|
* const { requestId, stream } = await client.fetch({
|
|
600
|
+
* fullTrackName,
|
|
663
601
|
* priority: 64,
|
|
664
602
|
* groupOrder: GroupOrder.Original,
|
|
665
|
-
*
|
|
666
|
-
* type: FetchType.Standalone,
|
|
667
|
-
* props: { fullTrackName, startLocation, endLocation }
|
|
668
|
-
* }
|
|
603
|
+
* locationFilter: new LocationFilter(LocationFilterType.AbsoluteStartGroupEnd, 10n, 0n, 12n)
|
|
669
604
|
* })
|
|
670
605
|
* ```
|
|
671
|
-
* @example
|
|
606
|
+
* @example The current group and the one before it
|
|
672
607
|
* ```ts
|
|
673
|
-
*
|
|
608
|
+
* await client.fetch({
|
|
674
609
|
* fullTrackName,
|
|
675
|
-
* priority: 0,
|
|
676
|
-
* groupOrder: GroupOrder.Original,
|
|
677
|
-
* forward: true,
|
|
678
|
-
* filterType: FilterType.LatestObject
|
|
679
|
-
* })
|
|
680
|
-
* const fetchRes = await client.fetch({
|
|
681
610
|
* priority: 32,
|
|
682
611
|
* groupOrder: GroupOrder.Original,
|
|
683
|
-
*
|
|
684
|
-
* type: FetchType.Relative,
|
|
685
|
-
* props: { joiningRequestId: subId, joiningStart: 0n }
|
|
686
|
-
* }
|
|
612
|
+
* locationFilter: new LocationFilter(LocationFilterType.RelativeStart, 2n)
|
|
687
613
|
* })
|
|
688
614
|
* ```
|
|
689
615
|
*/
|
|
690
|
-
/**
|
|
691
|
-
* Configuration for the early discard policy applied to incoming subgroup streams.
|
|
692
|
-
*/
|
|
693
|
-
type EarlyDiscardPolicyConfig = {
|
|
694
|
-
/** Cancel a subgroup QUIC stream if it has not fully completed within this many milliseconds. */subgroupReceiveTimeout: number;
|
|
695
|
-
};
|
|
696
616
|
type FetchOptions = {
|
|
697
617
|
/** Request priority (0 = highest, 255 = lowest). Rounded & clamped. */priority: number; /** {@link (GroupOrder:enum)} governing sequencing. */
|
|
698
|
-
groupOrder: GroupOrder;
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
props: {
|
|
707
|
-
fullTrackName: FullTrackName;
|
|
708
|
-
startLocation: Location;
|
|
709
|
-
endLocation: Location;
|
|
710
|
-
};
|
|
711
|
-
} | {
|
|
712
|
-
/** Fetch a range relative to an existing {@link SubscribeRequest} identified by `joiningRequestId`. */type: FetchType.Relative; /** Properties for relative fetch: subscription id and starting position. */
|
|
713
|
-
props: {
|
|
714
|
-
joiningRequestId: bigint;
|
|
715
|
-
joiningStart: bigint;
|
|
716
|
-
};
|
|
717
|
-
} | {
|
|
718
|
-
/** Fetch an absolute group/object range relative to a {@link SubscribeRequest}. */type: FetchType.Absolute; /** Properties for absolute fetch: subscription id and starting position. */
|
|
719
|
-
props: {
|
|
720
|
-
joiningRequestId: bigint;
|
|
721
|
-
joiningStart: bigint;
|
|
722
|
-
};
|
|
723
|
-
}; /** Optional parameters block. */
|
|
618
|
+
groupOrder: GroupOrder; /** Fully qualified track identifier ({@link FullTrackName}). */
|
|
619
|
+
fullTrackName: FullTrackName;
|
|
620
|
+
/**
|
|
621
|
+
* Which Objects to fetch; the end, when the filter has one, is the last Object
|
|
622
|
+
* sent. Without a filter the whole track up to the Largest Object is fetched, and
|
|
623
|
+
* a filter without an end also stops at the Largest Object.
|
|
624
|
+
*/
|
|
625
|
+
locationFilter?: LocationFilter; /** Optional parameters block. */
|
|
724
626
|
parameters?: MessageParameter[];
|
|
725
627
|
};
|
|
726
628
|
//#endregion
|
|
629
|
+
//#region src/client/request/subscribe.d.ts
|
|
630
|
+
/**
|
|
631
|
+
* Represents an active subscription request in MOQT, implementing `PromiseLike`
|
|
632
|
+
* for convenient async resolution when subscription setup succeeds or fails.
|
|
633
|
+
*/
|
|
634
|
+
declare class SubscribeRequest implements PromiseLike<SubscribeOk | RequestError> {
|
|
635
|
+
#private;
|
|
636
|
+
requestId: bigint;
|
|
637
|
+
fullTrackName: FullTrackName;
|
|
638
|
+
isCanceled: boolean;
|
|
639
|
+
startLocation: Location | undefined;
|
|
640
|
+
endGroup: bigint | undefined;
|
|
641
|
+
priority: number;
|
|
642
|
+
forward: boolean;
|
|
643
|
+
subscribeParameters: MessageParameter[];
|
|
644
|
+
earlyDiscardPolicy: EarlyDiscardPolicyConfig | undefined;
|
|
645
|
+
largestLocation: Location | undefined;
|
|
646
|
+
/**
|
|
647
|
+
* The publisher's Largest Object as of the last SUBSCRIBE_OK or REQUEST_UPDATE_OK,
|
|
648
|
+
* which is where a fill fetch stream stops.
|
|
649
|
+
*/
|
|
650
|
+
fillBoundary: Location | undefined;
|
|
651
|
+
/** EXPIRES from the last SUBSCRIBE_OK or REQUEST_UPDATE_OK, in milliseconds. */
|
|
652
|
+
expires: bigint | undefined;
|
|
653
|
+
streamsAccepted: bigint;
|
|
654
|
+
expectedStreams: bigint | undefined;
|
|
655
|
+
/** The Subscription managing this request's output stream once switching is involved. */
|
|
656
|
+
manager?: Subscription;
|
|
657
|
+
readonly controller: ReadableStreamDefaultController<MoqtObject>;
|
|
658
|
+
readonly stream: ReadableStream<MoqtObject>;
|
|
659
|
+
constructor(msg: Subscribe);
|
|
660
|
+
/**
|
|
661
|
+
* Updates subscription parameters in-place when a `RequestUpdate` message is received.
|
|
662
|
+
*/
|
|
663
|
+
update(msg: RequestUpdate): void;
|
|
664
|
+
/**
|
|
665
|
+
* Marks this subscription request as canceled.
|
|
666
|
+
*/
|
|
667
|
+
unsubscribe(): void;
|
|
668
|
+
/**
|
|
669
|
+
* Resolves the internal promise with a `SubscribeOk` or `RequestError`.
|
|
670
|
+
*/
|
|
671
|
+
resolve(value: SubscribeOk | RequestError | PromiseLike<SubscribeOk | RequestError>): void;
|
|
672
|
+
/**
|
|
673
|
+
* Rejects the internal promise with an error/reason.
|
|
674
|
+
*/
|
|
675
|
+
reject(reason?: any): void;
|
|
676
|
+
then<TResult1 = SubscribeOk | RequestError, TResult2 = never>(onfulfilled?: ((value: SubscribeOk | RequestError) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
|
|
677
|
+
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<SubscribeOk | RequestError | TResult>;
|
|
678
|
+
finally(onfinally?: (() => void) | undefined | null): Promise<SubscribeOk | RequestError>;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Owns the single consumer-facing stream for a SUBSCRIBE that may be switched to a
|
|
682
|
+
* new track one or more times. A soft switch can keep producing from the old track
|
|
683
|
+
* for an unknown time after SUBSCRIBE_OK, and a second switch may be issued before the
|
|
684
|
+
* first target ever delivers anything, so only the first object actually delivered by
|
|
685
|
+
* the newest tracked request is the guarantee that nothing older will send again.
|
|
686
|
+
*
|
|
687
|
+
* That first delivery is the handover, not the end of the old track: a soft switch
|
|
688
|
+
* leaves it delivering up to the group the new one starts at, so the two meet without
|
|
689
|
+
* a hole. Those objects keep coming through here until the publisher says the
|
|
690
|
+
* subscription is done, or until it has been quiet long enough to say so itself.
|
|
691
|
+
*/
|
|
692
|
+
declare class Subscription {
|
|
693
|
+
#private;
|
|
694
|
+
readonly controller: ReadableStreamDefaultController<MoqtObject>;
|
|
695
|
+
readonly stream: ReadableStream<MoqtObject>;
|
|
696
|
+
/** Set once by `MOQtailClient.switch`; invoked with everything older on cutover. */
|
|
697
|
+
onSuperseded?: (superseded: SubscribeRequest[]) => void;
|
|
698
|
+
/** Set by the client to decide whether draining a request should continue. */
|
|
699
|
+
onDrainDecision: (request: SubscribeRequest) => boolean;
|
|
700
|
+
/**
|
|
701
|
+
* How long a drained request may stay quiet before it is retired anyway, in
|
|
702
|
+
* milliseconds. The publisher normally ends the drain with a PUBLISH_DONE; this is
|
|
703
|
+
* what keeps a request that never gets one from being tracked forever.
|
|
704
|
+
*/
|
|
705
|
+
drainTimeoutMs: number;
|
|
706
|
+
constructor(initial: SubscribeRequest);
|
|
707
|
+
/** Requests still tracked, oldest first, draining ones last. */
|
|
708
|
+
get requests(): readonly SubscribeRequest[];
|
|
709
|
+
/** The request most recently switched to; must deliver data to win the handover. */
|
|
710
|
+
get newest(): SubscribeRequest;
|
|
711
|
+
/**
|
|
712
|
+
* Track a newly issued switch target alongside whatever is still delivering.
|
|
713
|
+
*
|
|
714
|
+
* `drainSuperseded` says what its handover does to the requests it takes over from:
|
|
715
|
+
* a soft switch leaves them delivering to the end of what the publisher was told to
|
|
716
|
+
* finish, a hard one retires them on the spot.
|
|
717
|
+
*/
|
|
718
|
+
addSwitchTarget(request: SubscribeRequest, drainSuperseded?: boolean): void;
|
|
719
|
+
/** Stop tracking `request` (e.g. it naturally completed without ever losing/winning a handover). */
|
|
720
|
+
drop(request: SubscribeRequest): void;
|
|
721
|
+
/** Stop tracking everything (used when the whole switch chain is torn down at once). */
|
|
722
|
+
clear(): void;
|
|
723
|
+
/**
|
|
724
|
+
* Delivers an object received for `request`. The first object delivered by the
|
|
725
|
+
* newest tracked request retires everything older — only then is it guaranteed no
|
|
726
|
+
* more data is coming from them.
|
|
727
|
+
*
|
|
728
|
+
* Returns `true` if the object was delivered to the caller,
|
|
729
|
+
* `false` if it was not consumed, and client should cancel the stream.
|
|
730
|
+
*/
|
|
731
|
+
deliver(request: SubscribeRequest, obj: MoqtObject): boolean;
|
|
732
|
+
}
|
|
733
|
+
//#endregion
|
|
734
|
+
//#region src/client/request_stream.d.ts
|
|
735
|
+
/** Observers for the messages a request stream carries, for logging or debugging. */
|
|
736
|
+
type RequestStreamHooks = {
|
|
737
|
+
onMessageSent?: (msg: ControlMessage) => void;
|
|
738
|
+
onMessageReceived?: (msg: ControlMessage) => void;
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* Wraps a WebTransport bidirectional stream carrying one MOQT request.
|
|
742
|
+
* Because a response is correlated by the stream it arrives on, nothing here needs a
|
|
743
|
+
* request id.
|
|
744
|
+
*/
|
|
745
|
+
declare class RequestStream {
|
|
746
|
+
#private;
|
|
747
|
+
readonly stream: ReadableStream<ControlMessage>;
|
|
748
|
+
/**
|
|
749
|
+
* The message this side opened the stream with, kept so the request can be re-issued
|
|
750
|
+
* on a fresh stream when the peer migrates it with a GOAWAY (§10.4). Undefined on a
|
|
751
|
+
* peer-opened stream, which is the peer's request to re-issue, not ours.
|
|
752
|
+
*/
|
|
753
|
+
first?: ControlMessage;
|
|
754
|
+
/**
|
|
755
|
+
* The type of the message that opened this stream, whichever side opened it. It is
|
|
756
|
+
* what the request on this stream *is*, which decides what may follow — a
|
|
757
|
+
* REQUEST_UPDATE is only valid for the types §10.9 lists.
|
|
758
|
+
*/
|
|
759
|
+
openingType?: ControlMessageType;
|
|
760
|
+
/** Set when the request this stream carried has been re-issued on a new stream. */
|
|
761
|
+
migrated: boolean;
|
|
762
|
+
constructor(biStream: WebTransportBidirectionalStream, hooks?: RequestStreamHooks);
|
|
763
|
+
/**
|
|
764
|
+
* Opens a new bidi stream and writes `first` on it.
|
|
765
|
+
*
|
|
766
|
+
* @throws :{@link ProtocolViolationError} If `first` is not one of the seven types
|
|
767
|
+
* Table 5 marks `First`; those are the only ones allowed to open a request stream.
|
|
768
|
+
*/
|
|
769
|
+
static open(webTransport: WebTransport, first: ControlMessage, hooks?: RequestStreamHooks): Promise<RequestStream>;
|
|
770
|
+
/**
|
|
771
|
+
* Reads the next control message off this stream, or `undefined` once the peer has
|
|
772
|
+
* closed or reset it.
|
|
773
|
+
*
|
|
774
|
+
* Takes ownership of {@link RequestStream.stream}'s reader on first use, so callers
|
|
775
|
+
* must not mix `next()` with `stream.getReader()`.
|
|
776
|
+
*/
|
|
777
|
+
next(): Promise<ControlMessage | undefined>;
|
|
778
|
+
send(message: ControlMessage): Promise<void>;
|
|
779
|
+
close(): Promise<void>;
|
|
780
|
+
/**
|
|
781
|
+
* Cancels the request by resetting its stream with `code`.
|
|
782
|
+
*/
|
|
783
|
+
reset(code: StreamResetCode): Promise<void>;
|
|
784
|
+
}
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/client/publication/subscribe.d.ts
|
|
787
|
+
/**
|
|
788
|
+
* @public
|
|
789
|
+
* Manages the publication of MOQT objects to a subscriber for a specific track.
|
|
790
|
+
* Handles live object streaming, subscription lifecycle, and stream management.
|
|
791
|
+
*/
|
|
792
|
+
declare class SubscribePublication {
|
|
793
|
+
#private;
|
|
794
|
+
private readonly client;
|
|
795
|
+
readonly track: Track;
|
|
796
|
+
private readonly subscribeMsg;
|
|
797
|
+
private readonly requestStream;
|
|
798
|
+
/**
|
|
799
|
+
* The latest location that was published to the subscriber.
|
|
800
|
+
*/
|
|
801
|
+
latestLocation: Location | undefined;
|
|
802
|
+
/**
|
|
803
|
+
* Creates a new SubscribePublication instance.
|
|
804
|
+
* @param client - The MOQT client managing the subscription.
|
|
805
|
+
* @param track - The track being published.
|
|
806
|
+
* @param subscribeMsg - The subscribe message containing subscription details.
|
|
807
|
+
* @param requestStream - The bidi request stream the SUBSCRIBE arrived on. Every
|
|
808
|
+
* message this publication sends back to the subscriber goes on it.
|
|
809
|
+
* @param largestLocation - The largest location seen so far, used for determining start location.
|
|
810
|
+
*/
|
|
811
|
+
constructor(client: MOQtailClient, track: Track, subscribeMsg: Subscribe, requestStream: RequestStream, largestLocation?: Location);
|
|
812
|
+
/**
|
|
813
|
+
* Cancels the publication and cleans up resources.
|
|
814
|
+
* Removes the publication from the client's publication map.
|
|
815
|
+
*/
|
|
816
|
+
cancel(): void;
|
|
817
|
+
/**
|
|
818
|
+
* Marks the publication as done and sends a PublishDone message to the client.
|
|
819
|
+
* @param statusCode - The status code indicating why the publication ended.
|
|
820
|
+
* @throws :{@link InternalError} If sending the message fails.
|
|
821
|
+
*/
|
|
822
|
+
done(statusCode: PublishDoneStatusCode): Promise<void>;
|
|
823
|
+
/**
|
|
824
|
+
* Updates the subscription parameters and locations based on a RequestUpdate message.
|
|
825
|
+
* @param msg - The update message containing new request details.
|
|
826
|
+
* @throws :{@link InvalidFilterError} If the Range Filters the subscription would be
|
|
827
|
+
* left with cannot be applied; nothing is updated.
|
|
828
|
+
*/
|
|
829
|
+
update(msg: RequestUpdate): void;
|
|
830
|
+
/**
|
|
831
|
+
* Publishes MOQT objects to the subscriber as they become available.
|
|
832
|
+
* Handles stream creation, object writing, and stream closure based on subscription parameters.
|
|
833
|
+
* @throws :{@link InternalError} If the track does not support live content.
|
|
834
|
+
*/
|
|
835
|
+
publish(): Promise<void>;
|
|
836
|
+
}
|
|
837
|
+
//#endregion
|
|
838
|
+
//#region src/client/publication/fetch.d.ts
|
|
839
|
+
declare class FetchPublication {
|
|
840
|
+
#private;
|
|
841
|
+
/** `start` and `end` are the FETCH's range resolved against the Largest Object, inclusive. */
|
|
842
|
+
constructor(client: MOQtailClient, track: Track, fetchRequest: Fetch, start: Location, end: Location);
|
|
843
|
+
cancel(): void;
|
|
844
|
+
/**
|
|
845
|
+
* Resets the data stream this fetch is being delivered on, which §10.9.1 requires when
|
|
846
|
+
* a REQUEST_UPDATE for a FETCH fails.
|
|
847
|
+
*/
|
|
848
|
+
resetDataStream(code: StreamResetCode): Promise<void>;
|
|
849
|
+
publish(): Promise<void>;
|
|
850
|
+
}
|
|
851
|
+
//#endregion
|
|
852
|
+
//#region src/client/publication/publish.d.ts
|
|
853
|
+
/**
|
|
854
|
+
* @public
|
|
855
|
+
* Manages the proactive publication of MOQT objects from a publisher to the relay.
|
|
856
|
+
* Handles live object streaming and stream management.
|
|
857
|
+
*/
|
|
858
|
+
declare class PublishPublication {
|
|
859
|
+
#private;
|
|
860
|
+
private readonly client;
|
|
861
|
+
readonly track: Track;
|
|
862
|
+
private readonly publishMsg;
|
|
863
|
+
/**
|
|
864
|
+
* The latest location that was published to the relay.
|
|
865
|
+
*/
|
|
866
|
+
latestLocation: Location | undefined;
|
|
867
|
+
/**
|
|
868
|
+
* Creates a new PublishPublication instance.
|
|
869
|
+
* @param client - The MOQT client managing the connection.
|
|
870
|
+
* @param track - The track being proactively published.
|
|
871
|
+
* @param publishMsg - The publish message that initiated this session.
|
|
872
|
+
*/
|
|
873
|
+
constructor(client: MOQtailClient, track: Track, publishMsg: Publish);
|
|
874
|
+
/**
|
|
875
|
+
* How many data streams this publication has opened, which is what a PUBLISH_DONE
|
|
876
|
+
* reports to the subscriber.
|
|
877
|
+
*/
|
|
878
|
+
get streamsOpened(): bigint;
|
|
879
|
+
/**
|
|
880
|
+
* Whether Objects are being sent right now. False while the peer holds this
|
|
881
|
+
* publication at FORWARD=0.
|
|
882
|
+
*/
|
|
883
|
+
get forwarding(): boolean;
|
|
884
|
+
/**
|
|
885
|
+
* Moves the Forward State: false parks the publication, true resumes it. The
|
|
886
|
+
* application hears about the move through {@link MOQtailClient.onForwardStateChange},
|
|
887
|
+
* which is where a publisher starts or stops the work behind the track -- a camera
|
|
888
|
+
* and an encoder cost the same whether or not anything is listening.
|
|
889
|
+
*/
|
|
890
|
+
setForwardState(forward: boolean): void;
|
|
891
|
+
/**
|
|
892
|
+
* Applies a REQUEST_UPDATE the peer sent on this publication's request stream. It
|
|
893
|
+
* can move the Forward State and the Range Filters; what a publisher sends, and
|
|
894
|
+
* when, is otherwise its own to decide.
|
|
895
|
+
* @throws :{@link InvalidFilterError} If the Range Filters the publication would be
|
|
896
|
+
* left with cannot be applied; nothing is updated.
|
|
897
|
+
*/
|
|
898
|
+
update(msg: RequestUpdate): void;
|
|
899
|
+
/**
|
|
900
|
+
* Cancels the publication and cleans up resources.
|
|
901
|
+
* Removes the publication from the client's publication map.
|
|
902
|
+
*/
|
|
903
|
+
cancel(): void;
|
|
904
|
+
/**
|
|
905
|
+
* Publishes MOQT objects to the relay as they become available.
|
|
906
|
+
* Handles stream creation, object writing, and stream closure.
|
|
907
|
+
* @throws :{@link InternalError} If the track does not support live content.
|
|
908
|
+
*/
|
|
909
|
+
publishToRelay(): Promise<void>;
|
|
910
|
+
}
|
|
911
|
+
//#endregion
|
|
727
912
|
//#region src/client/datagram_stream.d.ts
|
|
728
913
|
/**
|
|
729
914
|
* Sends MoqtObjects as WebTransport datagrams.
|
|
@@ -836,7 +1021,7 @@ declare class RecvDatagramStream {
|
|
|
836
1021
|
* const client = await MOQtailClient.new({ url });
|
|
837
1022
|
* const result = await client.subscribe({
|
|
838
1023
|
* fullTrackName,
|
|
839
|
-
*
|
|
1024
|
+
* locationFilter: new LocationFilter(LocationFilterType.NextObject),
|
|
840
1025
|
* forward: true,
|
|
841
1026
|
* groupOrder: GroupOrder.Original,
|
|
842
1027
|
* priority: 0
|
|
@@ -912,11 +1097,6 @@ declare class MOQtailClient {
|
|
|
912
1097
|
* Maps track aliases to full track names for quick resolution during data handling.
|
|
913
1098
|
*/
|
|
914
1099
|
readonly aliasFullTrackNameMap: Map<bigint, FullTrackName>;
|
|
915
|
-
/**
|
|
916
|
-
* Pending state updates keyed by requestId and applied once a new track alias is seen.
|
|
917
|
-
* Used to avoid premature state updates.
|
|
918
|
-
*/
|
|
919
|
-
readonly pendingStateUpdates: Map<bigint, (newTrackAlias: bigint) => boolean>;
|
|
920
1100
|
/** Underlying WebTransport session (set after successful construction in MOQtailClient.new). */
|
|
921
1101
|
webTransport: WebTransport;
|
|
922
1102
|
/** Outgoing / incoming control message stream pair. */
|
|
@@ -925,6 +1105,16 @@ declare class MOQtailClient {
|
|
|
925
1105
|
dataStreamTimeoutMs?: number;
|
|
926
1106
|
/** Timeout (ms) for control stream read operations; undefined =\> no explicit timeout. */
|
|
927
1107
|
controlStreamTimeoutMs?: number;
|
|
1108
|
+
/**
|
|
1109
|
+
* How long (ms) an incoming data stream waits for the control message that establishes
|
|
1110
|
+
* its track alias before the stream is abandoned.
|
|
1111
|
+
*/
|
|
1112
|
+
trackAliasResolutionTimeoutMs: number;
|
|
1113
|
+
/**
|
|
1114
|
+
* How long (ms) a track a soft switch handed over from may stay quiet before it is
|
|
1115
|
+
* retired anyway, if no PUBLISH_DONE ends its drain first.
|
|
1116
|
+
*/
|
|
1117
|
+
switchDrainTimeoutMs: number;
|
|
928
1118
|
/**
|
|
929
1119
|
* TODO: onNamespaceAnnounced may be a better name
|
|
930
1120
|
* Fired when an PUBLISH_NAMESPACE control message is processed for a track namespace.
|
|
@@ -940,7 +1130,7 @@ declare class MOQtailClient {
|
|
|
940
1130
|
onGoaway?: (msg: GoAway) => void;
|
|
941
1131
|
/**
|
|
942
1132
|
* Whether the peer has sent a GOAWAY on the control stream. Once it has, this side
|
|
943
|
-
* should not start new requests
|
|
1133
|
+
* should not start new requests; a second one closes the session with
|
|
944
1134
|
* PROTOCOL_VIOLATION.
|
|
945
1135
|
*/
|
|
946
1136
|
goawayReceived: boolean;
|
|
@@ -980,6 +1170,13 @@ declare class MOQtailClient {
|
|
|
980
1170
|
* Informational event.
|
|
981
1171
|
*/
|
|
982
1172
|
onDataSent?: (data: SubgroupObject | SubgroupHeader | FetchObject | FetchHeader) => void;
|
|
1173
|
+
/**
|
|
1174
|
+
* Invoked for every data stream this client opens or accepts: once for its header, once
|
|
1175
|
+
* per object (identity and payload length only), and once when the stream ends.
|
|
1176
|
+
* Use for counters and diagnostics.
|
|
1177
|
+
* Informational event.
|
|
1178
|
+
*/
|
|
1179
|
+
onDataEvent?: DataEventObserver;
|
|
983
1180
|
/**
|
|
984
1181
|
* General-purpose error callback for surfaced exceptions not thrown to caller synchronously.
|
|
985
1182
|
* Use to log or display errors.
|
|
@@ -1011,15 +1208,28 @@ declare class MOQtailClient {
|
|
|
1011
1208
|
onForwardStateChange?: (requestId: bigint, forward: boolean) => void;
|
|
1012
1209
|
/** Fired when an inbound SUBSCRIBE_NAMESPACE control message is received. */
|
|
1013
1210
|
onPeerSubscribeNamespace?: (msg: SubscribeNamespace) => void;
|
|
1014
|
-
/**
|
|
1211
|
+
/**
|
|
1212
|
+
* Fired when an inbound SUBSCRIBE_TRACKS control message is received. The PUBLISH
|
|
1213
|
+
* sent for each matching track:
|
|
1214
|
+
* - states the request's settings as its parameters, from
|
|
1215
|
+
* `MessageParameter.publishParametersFor(msg.parameters)`: FORWARD, GROUP_ORDER and
|
|
1216
|
+
* the LOCATION_FILTER the subscription starts from, but never the request's
|
|
1217
|
+
* AUTHORIZATION_TOKEN;
|
|
1218
|
+
* - goes without Track Properties when
|
|
1219
|
+
* `MessageParameter.includesProperties(msg.parameters)` is false.
|
|
1220
|
+
*
|
|
1221
|
+
* A request carrying FILL_PARAMETERS also asks for a fill of what each track has
|
|
1222
|
+
* already published. This client cannot open a fill for a pushed track, so such a
|
|
1223
|
+
* subscriber gets only the live Objects.
|
|
1224
|
+
*/
|
|
1015
1225
|
onPeerSubscribeTracks?: (msg: SubscribeTracks) => void;
|
|
1016
1226
|
/**
|
|
1017
|
-
* Fired when a
|
|
1227
|
+
* Fired when a PUBLISH_SKIPPED arrives on a {@link MOQtailClient.subscribeTracks}
|
|
1018
1228
|
* stream: the peer has a matching track but no bidi stream to send its PUBLISH on
|
|
1019
1229
|
* until its stream limit lifts (§10.20). `prefix` is the prefix this side subscribed
|
|
1020
1230
|
* with, which is what the message's suffix hangs off.
|
|
1021
1231
|
*/
|
|
1022
|
-
|
|
1232
|
+
onPeerPublishSkipped?: (prefix: Tuple, msg: PublishSkipped) => void;
|
|
1023
1233
|
/** Fired when a NAMESPACE message arrives on a SUBSCRIBE_NAMESPACE bi-stream (prefix + suffix). */
|
|
1024
1234
|
onPeerNamespace?: (prefix: Tuple, suffix: Tuple) => void;
|
|
1025
1235
|
/** Fired when a NAMESPACE_DONE message arrives on a SUBSCRIBE_NAMESPACE bi-stream (prefix + suffix). */
|
|
@@ -1042,6 +1252,21 @@ declare class MOQtailClient {
|
|
|
1042
1252
|
* @returns The {@link Setup} instance the server sent back during handshake.
|
|
1043
1253
|
*/
|
|
1044
1254
|
get serverSetup(): Setup;
|
|
1255
|
+
/**
|
|
1256
|
+
* How many filter ranges the server allows in one request: its MAX_FILTER_RANGES,
|
|
1257
|
+
* or 0 when it sent none, which allows no Range Filter at all.
|
|
1258
|
+
*/
|
|
1259
|
+
/**
|
|
1260
|
+
* How many filter ranges this client allows the server in one request: the
|
|
1261
|
+
* MAX_FILTER_RANGES it advertised, {@link DEFAULT_MAX_FILTER_RANGES} unless the
|
|
1262
|
+
* caller's setup options set one.
|
|
1263
|
+
*/
|
|
1264
|
+
get maxFilterRanges(): bigint;
|
|
1265
|
+
/**
|
|
1266
|
+
* How many filter ranges the server allows in one request: its MAX_FILTER_RANGES,
|
|
1267
|
+
* or 0 when it sent none, which allows no Range Filter at all.
|
|
1268
|
+
*/
|
|
1269
|
+
get peerMaxFilterRanges(): bigint;
|
|
1045
1270
|
/**
|
|
1046
1271
|
* Returns true if datagram support is currently active
|
|
1047
1272
|
*/
|
|
@@ -1081,6 +1306,7 @@ declare class MOQtailClient {
|
|
|
1081
1306
|
* transportOptions: { congestionControl: 'default' },
|
|
1082
1307
|
* dataStreamTimeoutMs: 5000,
|
|
1083
1308
|
* controlStreamTimeoutMs: 2000,
|
|
1309
|
+
* trackAliasResolutionTimeoutMs: 2000,
|
|
1084
1310
|
* enableDatagrams: true,
|
|
1085
1311
|
* callbacks: {
|
|
1086
1312
|
* onMessageSent: msg => console.log('Sent:', msg),
|
|
@@ -1277,25 +1503,25 @@ declare class MOQtailClient {
|
|
|
1277
1503
|
*
|
|
1278
1504
|
* - `forward: true` tells the relay to forward objects to this subscriber as they arrive.
|
|
1279
1505
|
* - `forward: false` means the relay subscribes upstream but buffers objects locally, not forwarding them to you.
|
|
1280
|
-
* - `
|
|
1281
|
-
*
|
|
1282
|
-
* -
|
|
1283
|
-
* observed at the publisher then it behaves as `filterType: LatestObject`.
|
|
1506
|
+
* - `locationFilter` selects which Objects are delivered; omitted, the subscription is unfiltered. An absolute start in the
|
|
1507
|
+
* future waits for that object.
|
|
1508
|
+
* - A {@link FillParameters} in `parameters` also retrieves Objects already published, on a fill fetch stream.
|
|
1284
1509
|
*
|
|
1285
|
-
* The method returns either a {@link RequestError} (on refusal) or an object with the subscription `requestId` and a `ReadableStream` of {@link MoqtObject}s.
|
|
1510
|
+
* The method returns either a {@link RequestError} (on refusal) or an object with the subscription `requestId`, the `trackAlias` and a `ReadableStream` of {@link MoqtObject}s.
|
|
1286
1511
|
* Use the `requestId` for {@link MOQtailClient.unsubscribe} or {@link MOQtailClient.subscribeUpdate}. Use the `stream` to decode and display objects.
|
|
1287
1512
|
*
|
|
1288
1513
|
* @param args - {@link SubscribeOptions} describing the subscription window and relay forwarding behavior.
|
|
1289
|
-
* @returns Either a {@link RequestError} or `{ requestId, stream }` for consuming objects.
|
|
1514
|
+
* @returns Either a {@link RequestError} or `{ requestId, trackAlias, stream }` for consuming objects.
|
|
1290
1515
|
* @throws : {@link MOQtailError} If the client is destroyed.
|
|
1291
1516
|
* @throws : {@link ProtocolViolationError} If required fields are missing or inconsistent.
|
|
1517
|
+
* @throws : {@link InvalidFilterError} If the Range Filters exceed the server's MAX_FILTER_RANGES; nothing is sent.
|
|
1292
1518
|
* @throws : {@link InternalError} On transport/protocol failure (disconnect is triggered before rethrow).
|
|
1293
1519
|
*
|
|
1294
1520
|
* @example Subscribe to the latest object and receive future objects as they arrive
|
|
1295
1521
|
* ```ts
|
|
1296
1522
|
* const result = await client.subscribe({
|
|
1297
1523
|
* fullTrackName,
|
|
1298
|
-
*
|
|
1524
|
+
* locationFilter: new LocationFilter(LocationFilterType.NextObject),
|
|
1299
1525
|
* forward: true,
|
|
1300
1526
|
* groupOrder: GroupOrder.Original,
|
|
1301
1527
|
* priority: 32
|
|
@@ -1307,13 +1533,11 @@ declare class MOQtailClient {
|
|
|
1307
1533
|
* }
|
|
1308
1534
|
* ```
|
|
1309
1535
|
*
|
|
1310
|
-
* @example Subscribe to a future range (waits for those objects to arrive)
|
|
1536
|
+
* @example Subscribe to a future range of groups (waits for those objects to arrive)
|
|
1311
1537
|
* ```ts
|
|
1312
1538
|
* const result = await client.subscribe({
|
|
1313
1539
|
* fullTrackName,
|
|
1314
|
-
*
|
|
1315
|
-
* startLocation: futureStart,
|
|
1316
|
-
* endGroup: futureEnd,
|
|
1540
|
+
* locationFilter: new LocationFilter(LocationFilterType.AbsoluteStartGroupEnd, startGroup, 0n, endGroup),
|
|
1317
1541
|
* forward: true,
|
|
1318
1542
|
* groupOrder: GroupOrder.Original,
|
|
1319
1543
|
* priority: 128
|
|
@@ -1322,6 +1546,7 @@ declare class MOQtailClient {
|
|
|
1322
1546
|
*/
|
|
1323
1547
|
subscribe(args: SubscribeOptions): Promise<RequestError | {
|
|
1324
1548
|
requestId: bigint;
|
|
1549
|
+
trackAlias: bigint;
|
|
1325
1550
|
stream: ReadableStream<MoqtObject>;
|
|
1326
1551
|
}>;
|
|
1327
1552
|
/**
|
|
@@ -1344,7 +1569,7 @@ declare class MOQtailClient {
|
|
|
1344
1569
|
*
|
|
1345
1570
|
* @example Subscribe and later unsubscribe
|
|
1346
1571
|
* ```ts
|
|
1347
|
-
* const sub = await client.subscribe({ fullTrackName,
|
|
1572
|
+
* const sub = await client.subscribe({ fullTrackName, locationFilter: new LocationFilter(LocationFilterType.NextObject), forward: true, groupOrder: GroupOrder.Original, priority: 0 });
|
|
1348
1573
|
* if (!(sub instanceof RequestError)) {
|
|
1349
1574
|
* // ...consume objects...
|
|
1350
1575
|
* await client.unsubscribe(sub.requestId);
|
|
@@ -1384,43 +1609,60 @@ declare class MOQtailClient {
|
|
|
1384
1609
|
*
|
|
1385
1610
|
* @example Trim start forward
|
|
1386
1611
|
* ```ts
|
|
1387
|
-
* await client.subscribeUpdate({
|
|
1612
|
+
* await client.subscribeUpdate({ subscriptionRequestId, locationFilter: new LocationFilter(LocationFilterType.AbsoluteStart, laterGroup, 0n), forward: true, priority });
|
|
1388
1613
|
* ```
|
|
1389
1614
|
*
|
|
1390
1615
|
* @example Convert tailing subscription into bounded slice
|
|
1391
1616
|
* ```ts
|
|
1392
|
-
* await client.subscribeUpdate({
|
|
1617
|
+
* await client.subscribeUpdate({ subscriptionRequestId, locationFilter: new LocationFilter(LocationFilterType.AbsoluteStartGroupEnd, startGroup, 0n, cutoffGroup), forward: false, priority });
|
|
1393
1618
|
* ```
|
|
1394
1619
|
*
|
|
1395
1620
|
* @example Lower priority only
|
|
1396
1621
|
* ```ts
|
|
1397
|
-
* await client.subscribeUpdate({
|
|
1622
|
+
* await client.subscribeUpdate({ subscriptionRequestId, forward: true, priority: 200 });
|
|
1398
1623
|
* ```
|
|
1399
1624
|
*/
|
|
1400
1625
|
subscribeUpdate(args: SubscribeUpdateOptions): Promise<void>;
|
|
1401
1626
|
/**
|
|
1402
|
-
* Switches an active subscription to a different track while retaining the same subscription
|
|
1627
|
+
* Switches an active subscription to a different track while retaining the same subscription's
|
|
1628
|
+
* output stream.
|
|
1403
1629
|
*
|
|
1404
|
-
*
|
|
1630
|
+
* Sends a fresh SUBSCRIBE carrying a SwitchFrom parameter referencing `switchFromRequestId`. A soft
|
|
1631
|
+
* switch may keep delivering objects from the old track for a while after SUBSCRIBE_OK, and this can
|
|
1632
|
+
* be called again before the previous target has produced anything; only the first object actually
|
|
1633
|
+
* delivered by the newest switch target retires everything older.
|
|
1405
1634
|
*
|
|
1406
|
-
* @param args - {@link SwitchOptions} referencing the
|
|
1407
|
-
* @returns
|
|
1635
|
+
* @param args - {@link SwitchOptions} referencing the subscription to switch from and the new subscription options.
|
|
1636
|
+
* @returns Either a {@link RequestError} (refusal) or `{ requestId, stream }`, where `stream` is the
|
|
1637
|
+
* same {@link https://developer.mozilla.org/docs/Web/API/ReadableStream | ReadableStream} object returned by the original `subscribe()` call.
|
|
1408
1638
|
* @throws :{@link MOQtailError} If the client is destroyed.
|
|
1639
|
+
* @throws :{@link ProtocolViolationError} If `switchFromRequestId` does not name an active subscription.
|
|
1409
1640
|
* @throws :{@link InternalError} On transport/control failure (disconnect is triggered before rethrow).
|
|
1410
1641
|
*
|
|
1411
|
-
* @remarks
|
|
1412
|
-
* - Only applies to active SUBSCRIBE requests; ignored if the request is not a subscription.
|
|
1413
|
-
* - All other subscription parameters (window, forwarding, priority) remain unchanged.
|
|
1414
|
-
*
|
|
1415
1642
|
* @example Switch to a different track
|
|
1416
1643
|
* ```ts
|
|
1417
|
-
* await client.switch({
|
|
1644
|
+
* await client.switch({
|
|
1645
|
+
* switchFromRequestId,
|
|
1646
|
+
* switchMode: SwitchMode.Soft,
|
|
1647
|
+
* newSubscribeOptions: { fullTrackName: newTrackName, priority: 0, groupOrder: GroupOrder.Original, forward: true, locationFilter: new LocationFilter(LocationFilterType.NextObject) },
|
|
1648
|
+
* onDrainDecision: (request) => true
|
|
1649
|
+
* });
|
|
1418
1650
|
* ```
|
|
1419
1651
|
*/
|
|
1420
1652
|
switch(args: SwitchOptions): Promise<RequestError | {
|
|
1421
1653
|
requestId: bigint;
|
|
1422
1654
|
stream: ReadableStream<MoqtObject>;
|
|
1423
1655
|
}>;
|
|
1656
|
+
/**
|
|
1657
|
+
* Ends a subscription whose publisher has said how many streams it opened and has
|
|
1658
|
+
* now delivered all of them, and reports whether that happened.
|
|
1659
|
+
*
|
|
1660
|
+
* Both halves of that arrive on their own: a PUBLISH_DONE carries the count, and
|
|
1661
|
+
* the streams finish whenever they finish. Either can be last, so this is checked
|
|
1662
|
+
* from both -- a drained switch target has usually finished its streams well
|
|
1663
|
+
* before the PUBLISH_DONE that ends it.
|
|
1664
|
+
*/
|
|
1665
|
+
completeSubscription(request: SubscribeRequest, force?: boolean): boolean;
|
|
1424
1666
|
/**
|
|
1425
1667
|
* One-shot retrieval of a bounded object span, optionally anchored to an existing subscription, returning a stream of {@link MoqtObject}s.
|
|
1426
1668
|
*
|
|
@@ -1452,15 +1694,13 @@ declare class MOQtailClient {
|
|
|
1452
1694
|
* - Result stream is finite; reader close occurs automatically when last object delivered.
|
|
1453
1695
|
* - Use {@link MOQtailClient.fetchCancel} only for early termination (not yet fully implemented: see TODO in code).
|
|
1454
1696
|
*
|
|
1455
|
-
* @example
|
|
1697
|
+
* @example Groups 10 through 12, inclusive
|
|
1456
1698
|
* ```ts
|
|
1457
1699
|
* const r = await client.fetch({
|
|
1700
|
+
* fullTrackName,
|
|
1458
1701
|
* priority: 64,
|
|
1459
1702
|
* groupOrder: GroupOrder.Original,
|
|
1460
|
-
*
|
|
1461
|
-
* type: FetchType.Standalone,
|
|
1462
|
-
* props: { fullTrackName, startLocation, endLocation }
|
|
1463
|
-
* }
|
|
1703
|
+
* locationFilter: new LocationFilter(LocationFilterType.AbsoluteStartGroupEnd, 10n, 0n, 12n)
|
|
1464
1704
|
* })
|
|
1465
1705
|
* if (!(r instanceof RequestError)) {
|
|
1466
1706
|
* for await (const obj of r.stream as any) {
|
|
@@ -1469,16 +1709,14 @@ declare class MOQtailClient {
|
|
|
1469
1709
|
* }
|
|
1470
1710
|
* ```
|
|
1471
1711
|
*
|
|
1472
|
-
* @example
|
|
1712
|
+
* @example The last 5 groups, counting the current one
|
|
1473
1713
|
* ```ts
|
|
1474
|
-
* const
|
|
1475
|
-
*
|
|
1476
|
-
*
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1480
|
-
* })
|
|
1481
|
-
* }
|
|
1714
|
+
* const slice = await client.fetch({
|
|
1715
|
+
* fullTrackName,
|
|
1716
|
+
* priority: 32,
|
|
1717
|
+
* groupOrder: GroupOrder.Original,
|
|
1718
|
+
* locationFilter: new LocationFilter(LocationFilterType.RelativeStart, 5n)
|
|
1719
|
+
* })
|
|
1482
1720
|
* ```
|
|
1483
1721
|
*/
|
|
1484
1722
|
fetch(args: FetchOptions): Promise<RequestError | {
|
|
@@ -1507,7 +1745,7 @@ declare class MOQtailClient {
|
|
|
1507
1745
|
*
|
|
1508
1746
|
* @example Cancel shortly after starting
|
|
1509
1747
|
* ```ts
|
|
1510
|
-
* const r = await client.fetch({ priority: 32, groupOrder: GroupOrder.Original,
|
|
1748
|
+
* const r = await client.fetch({ fullTrackName, priority: 32, groupOrder: GroupOrder.Original, locationFilter })
|
|
1511
1749
|
* if (!(r instanceof RequestError)) {
|
|
1512
1750
|
* // user navigated away
|
|
1513
1751
|
* await client.fetchCancel(r.requestId)
|
|
@@ -1582,7 +1820,7 @@ declare class MOQtailClient {
|
|
|
1582
1820
|
* const resp = await client.publishNamespace(["room","1234"], params)
|
|
1583
1821
|
* ```
|
|
1584
1822
|
*/
|
|
1585
|
-
publishNamespace(trackNamespace: Tuple, parameters?: MessageParameter[]): Promise<
|
|
1823
|
+
publishNamespace(trackNamespace: Tuple, parameters?: MessageParameter[]): Promise<RequestError | RequestOk>;
|
|
1586
1824
|
/**
|
|
1587
1825
|
* Withdraw a previously announced namespace so new subscribers no longer discover its tracks.
|
|
1588
1826
|
*
|
|
@@ -1658,6 +1896,18 @@ declare class MOQtailClient {
|
|
|
1658
1896
|
* ```
|
|
1659
1897
|
*/
|
|
1660
1898
|
trackStatus(fullTrackName: FullTrackName, trackAlias: bigint, parameters?: MessageParameter[]): Promise<RequestOk | RequestError>;
|
|
1899
|
+
/**
|
|
1900
|
+
* Opens a bidi request stream for `first` and starts reading responses off it.
|
|
1901
|
+
*
|
|
1902
|
+
* @param requestId - The requestId carried by `first`; the key the stream is filed under.
|
|
1903
|
+
*/
|
|
1904
|
+
/**
|
|
1905
|
+
* Hands a data stream {@link MOQtailClient.onDataEvent}, read at call time so an observer assigned
|
|
1906
|
+
* after connecting still sees streams that are already open.
|
|
1907
|
+
*
|
|
1908
|
+
* @internal
|
|
1909
|
+
*/
|
|
1910
|
+
dataStreamObserver(fullTrackNameOf?: DataStreamObserver['fullTrackNameOf']): DataStreamObserver;
|
|
1661
1911
|
/**
|
|
1662
1912
|
* Re-issues one request on a fresh stream after the peer sent a GOAWAY on its request
|
|
1663
1913
|
* stream (§10.4). Only that request moves: the session, and every other request on it,
|
|
@@ -1682,7 +1932,8 @@ declare class SendStream {
|
|
|
1682
1932
|
readonly header: Header;
|
|
1683
1933
|
readonly onDataSent?: (data: SubgroupObject | SubgroupHeader | FetchObject | FetchHeader) => void;
|
|
1684
1934
|
private constructor();
|
|
1685
|
-
|
|
1935
|
+
/** @param observer - Receives a {@link DataEvent} for the header, each object, and the stream's end. */
|
|
1936
|
+
static new(writeStream: WritableStream<Uint8Array>, header: Header, onDataSent?: (data: SubgroupObject | SubgroupHeader | FetchObject | FetchHeader) => void, groupOrder?: GroupOrder, observer?: DataStreamObserver): Promise<SendStream>;
|
|
1686
1937
|
write(object: FetchObject | SubgroupObject): Promise<void>;
|
|
1687
1938
|
close(): Promise<void>;
|
|
1688
1939
|
/** Abruptly tears the stream down, so the peer reads back `code` (§3.3.3). */
|
|
@@ -1697,10 +1948,11 @@ declare class RecvStream {
|
|
|
1697
1948
|
/**
|
|
1698
1949
|
* @param resolveGroupOrder - Consulted once the FETCH header names its request, since
|
|
1699
1950
|
* Group ID deltas on the stream are signed by the Group Order the request negotiated.
|
|
1951
|
+
* @param observer - Receives a {@link DataEvent} for the header, each object, and the stream's end.
|
|
1700
1952
|
*/
|
|
1701
|
-
static new(readStream: ReadableStream<Uint8Array>, partialDataTimeout?: number, onDataReceived?: (data: SubgroupObject | SubgroupHeader | FetchObject | FetchHeader) => void, resolveGroupOrder?: (header: Header) => GroupOrder): Promise<RecvStream>;
|
|
1953
|
+
static new(readStream: ReadableStream<Uint8Array>, partialDataTimeout?: number, onDataReceived?: (data: SubgroupObject | SubgroupHeader | FetchObject | FetchHeader) => void, resolveGroupOrder?: (header: Header) => GroupOrder, observer?: DataStreamObserver): Promise<RecvStream>;
|
|
1702
1954
|
/** Asks the peer to stop sending on this stream, reporting `code` (§3.3.3). */
|
|
1703
1955
|
stopSending(code: StreamResetCode): Promise<void>;
|
|
1704
1956
|
}
|
|
1705
1957
|
//#endregion
|
|
1706
|
-
export { ControlRecvStream, ControlSendStream, ControlStream, EarlyDiscardPolicyConfig, FetchOptions, FetchPublication, FetchRequest, HybridTrackSource, LiveObjectSource, LiveTrackSource, MOQtailClient, MOQtailClientOptions, MOQtailRequest, MemoryObjectCache, ObjectCache, PastObjectSource, PublishNamespaceRequest, PublishPublication, PublishRequest, RecvDatagramStream, RecvStream, RequestStream, RingBufferObjectCache, SendDatagramStream, SendStream, StaticTrackSource, SubscribeNamespaceRequest, SubscribeOptions, SubscribePublication, SubscribeRequest, SubscribeUpdateOptions, SwitchOptions, Track, TrackSource, TrackStatusRequest };
|
|
1958
|
+
export { ControlRecvStream, ControlSendStream, ControlStream, DEFAULT_MAX_FILTER_RANGES, DEFAULT_SWITCH_DRAIN_TIMEOUT_MS, DEFAULT_TRACK_ALIAS_RESOLUTION_TIMEOUT_MS, DataDirection, DataEvent, DataEventBase, DataEventObserver, DataHeaderEvent, DataObjectEvent, DataStreamEndEvent, DataStreamObserver, DataStreamReporter, EarlyDiscardPolicyConfig, FetchOptions, FetchPublication, FetchRequest, HybridTrackSource, LiveObjectSource, LiveTrackSource, MOQtailClient, MOQtailClientOptions, MOQtailRequest, MemoryObjectCache, ObjectCache, PastObjectSource, PublishNamespaceRequest, PublishPublication, PublishRequest, RecvDatagramStream, RecvStream, RequestStream, RequestStreamHooks, RingBufferObjectCache, SendDatagramStream, SendStream, StaticTrackSource, SubscribeNamespaceRequest, SubscribeOptions, SubscribePublication, SubscribeRequest, SubscribeUpdateOptions, Subscription, SwitchOptions, Track, TrackAliasHolder, TrackSource, TrackStatusRequest };
|