@moq/net 0.2.6 → 0.2.8
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/connection/accept.js +8 -3
- package/connection/accept.js.map +1 -1
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +5 -2
- package/connection/connect.js.map +1 -1
- package/connection/handshake.d.ts +9 -1
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +18 -14
- package/connection/handshake.js.map +1 -1
- package/ietf/adapter.js +2 -2
- package/ietf/adapter.js.map +1 -1
- package/ietf/connection.d.ts +7 -1
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +23 -3
- package/ietf/connection.js.map +1 -1
- package/ietf/index.d.ts +1 -0
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +1 -0
- package/ietf/index.js.map +1 -1
- package/ietf/parameters.d.ts +1 -0
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +2 -0
- package/ietf/parameters.js.map +1 -1
- package/ietf/publisher.d.ts +22 -8
- package/ietf/publisher.d.ts.map +1 -1
- package/ietf/publisher.js +294 -77
- package/ietf/publisher.js.map +1 -1
- package/ietf/solicit.d.ts +41 -0
- package/ietf/solicit.d.ts.map +1 -0
- package/ietf/solicit.js +47 -0
- package/ietf/solicit.js.map +1 -0
- package/ietf/subscriber.d.ts +4 -0
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +122 -50
- package/ietf/subscriber.js.map +1 -1
- package/lite/priority.d.ts +67 -0
- package/lite/priority.d.ts.map +1 -0
- package/lite/priority.js +114 -0
- package/lite/priority.js.map +1 -0
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +73 -18
- package/lite/publisher.js.map +1 -1
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +5 -4
- package/lite/subscriber.js.map +1 -1
- package/mock.d.ts +13 -2
- package/mock.d.ts.map +1 -1
- package/mock.js +22 -4
- package/mock.js.map +1 -1
- package/package.json +2 -2
- package/stream.d.ts +94 -4
- package/stream.d.ts.map +1 -1
- package/stream.js +100 -8
- package/stream.js.map +1 -1
- package/track.d.ts +20 -7
- package/track.d.ts.map +1 -1
- package/track.js +63 -27
- package/track.js.map +1 -1
- package/announced.test.d.ts +0 -2
- package/announced.test.d.ts.map +0 -1
- package/announced.test.js +0 -37
- package/announced.test.js.map +0 -1
- package/broadcast.test.d.ts +0 -2
- package/broadcast.test.d.ts.map +0 -1
- package/broadcast.test.js +0 -243
- package/broadcast.test.js.map +0 -1
- package/connection/browser.test.d.ts +0 -2
- package/connection/browser.test.d.ts.map +0 -1
- package/connection/browser.test.js +0 -29
- package/connection/browser.test.js.map +0 -1
- package/connection/cert.test.d.ts +0 -2
- package/connection/cert.test.d.ts.map +0 -1
- package/connection/cert.test.js +0 -26
- package/connection/cert.test.js.map +0 -1
- package/connection/connect.test.d.ts +0 -2
- package/connection/connect.test.d.ts.map +0 -1
- package/connection/connect.test.js +0 -118
- package/connection/connect.test.js.map +0 -1
- package/connection/reload.test.d.ts +0 -2
- package/connection/reload.test.d.ts.map +0 -1
- package/connection/reload.test.js +0 -160
- package/connection/reload.test.js.map +0 -1
- package/connection/stats.test.d.ts +0 -2
- package/connection/stats.test.d.ts.map +0 -1
- package/connection/stats.test.js +0 -120
- package/connection/stats.test.js.map +0 -1
- package/error.test.d.ts +0 -2
- package/error.test.d.ts.map +0 -1
- package/error.test.js +0 -89
- package/error.test.js.map +0 -1
- package/group.test.d.ts +0 -2
- package/group.test.d.ts.map +0 -1
- package/group.test.js +0 -152
- package/group.test.js.map +0 -1
- package/ietf/aliases.test.d.ts +0 -2
- package/ietf/aliases.test.d.ts.map +0 -1
- package/ietf/aliases.test.js +0 -30
- package/ietf/aliases.test.js.map +0 -1
- package/ietf/ietf.test.d.ts +0 -2
- package/ietf/ietf.test.d.ts.map +0 -1
- package/ietf/ietf.test.js +0 -983
- package/ietf/ietf.test.js.map +0 -1
- package/ietf/priority.test.d.ts +0 -2
- package/ietf/priority.test.d.ts.map +0 -1
- package/ietf/priority.test.js +0 -18
- package/ietf/priority.test.js.map +0 -1
- package/integration.test.d.ts +0 -2
- package/integration.test.d.ts.map +0 -1
- package/integration.test.js +0 -1006
- package/integration.test.js.map +0 -1
- package/lite/announce.test.d.ts +0 -2
- package/lite/announce.test.d.ts.map +0 -1
- package/lite/announce.test.js +0 -91
- package/lite/announce.test.js.map +0 -1
- package/lite/datagram.test.d.ts +0 -2
- package/lite/datagram.test.d.ts.map +0 -1
- package/lite/datagram.test.js +0 -26
- package/lite/datagram.test.js.map +0 -1
- package/lite/datagram_stream.test.d.ts +0 -2
- package/lite/datagram_stream.test.d.ts.map +0 -1
- package/lite/datagram_stream.test.js +0 -15
- package/lite/datagram_stream.test.js.map +0 -1
- package/lite/fetch.test.d.ts +0 -2
- package/lite/fetch.test.d.ts.map +0 -1
- package/lite/fetch.test.js +0 -41
- package/lite/fetch.test.js.map +0 -1
- package/lite/publisher.test.d.ts +0 -2
- package/lite/publisher.test.d.ts.map +0 -1
- package/lite/publisher.test.js +0 -65
- package/lite/publisher.test.js.map +0 -1
- package/lite/setup.test.d.ts +0 -2
- package/lite/setup.test.d.ts.map +0 -1
- package/lite/setup.test.js +0 -134
- package/lite/setup.test.js.map +0 -1
- package/lite/subscribe.test.d.ts +0 -2
- package/lite/subscribe.test.d.ts.map +0 -1
- package/lite/subscribe.test.js +0 -110
- package/lite/subscribe.test.js.map +0 -1
- package/lite/subscriber.test.d.ts +0 -2
- package/lite/subscriber.test.d.ts.map +0 -1
- package/lite/subscriber.test.js +0 -108
- package/lite/subscriber.test.js.map +0 -1
- package/lite/track.test.d.ts +0 -2
- package/lite/track.test.d.ts.map +0 -1
- package/lite/track.test.js +0 -55
- package/lite/track.test.js.map +0 -1
- package/path.test.d.ts +0 -2
- package/path.test.d.ts.map +0 -1
- package/path.test.js +0 -210
- package/path.test.js.map +0 -1
- package/stream.test.d.ts +0 -2
- package/stream.test.d.ts.map +0 -1
- package/stream.test.js +0 -252
- package/stream.test.js.map +0 -1
- package/time.test.d.ts +0 -2
- package/time.test.d.ts.map +0 -1
- package/time.test.js +0 -12
- package/time.test.js.map +0 -1
- package/track.test.d.ts +0 -2
- package/track.test.d.ts.map +0 -1
- package/track.test.js +0 -212
- package/track.test.js.map +0 -1
- package/util/timeout.test.d.ts +0 -2
- package/util/timeout.test.d.ts.map +0 -1
- package/util/timeout.test.js +0 -18
- package/util/timeout.test.js.map +0 -1
- package/varint.test.d.ts +0 -2
- package/varint.test.d.ts.map +0 -1
- package/varint.test.js +0 -106
- package/varint.test.js.map +0 -1
package/ietf/subscriber.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriber.js","sourceRoot":"","sources":["../../src/ietf/subscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,KAAK,EAA8B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAgB,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAyB,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1G,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACv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YACvB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACrB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACF,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,gBAAiB,SAAQ,SAAS,CAAC,QAAQ;IAChD,qGAAqG;IACrG,YAAY,KAAa;QACxB,KAAK,CAAC,KAAK,CAAC,CAAC;IACd,CAAC;IAED,qFAAqF;IAC5E,KAAK;QACb,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAChD,CAAC;IAEQ,UAAU;QAClB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC,CAAC;IACpF,CAAC;CACD","sourcesContent":["import * as announce from \"../announced.ts\";\nimport * as broadcast from \"../broadcast.ts\";\nimport { BroadcastCache } from \"../consume.ts\";\nimport { error, reason } from \"../error.ts\";\nimport * as netGroup from \"../group.ts\";\nimport * as Path from \"../path.ts\";\nimport type { Reader, Stream } from \"../stream.ts\";\nimport { type Timescale, Timestamp } from \"../time.ts\";\nimport type * as track from \"../track.ts\";\nimport { withTimeout } from \"../util/timeout.ts\";\nimport type { Session } from \"./adapter.ts\";\nimport { TrackAliases } from \"./aliases.ts\";\nimport { Frame, type Group as GroupMessage } from \"./object.ts\";\nimport { toWire } from \"./priority.ts\";\nimport { type Publish, PublishError } from \"./publish.ts\";\nimport { type PublishNamespace, PublishNamespaceError, PublishNamespaceOk } from \"./publish_namespace.ts\";\nimport { RequestError, RequestOk } from \"./request.ts\";\nimport { Subscribe, SubscribeError, SubscribeOk, Unsubscribe } from \"./subscribe.ts\";\nimport {\n\tPublishBlocked,\n\tSubscribeNamespace,\n\tSubscribeNamespaceEntry,\n\tSubscribeNamespaceEntryDone,\n\tSubscribeNamespaceLegacy,\n\tSubscribeNamespaceOk,\n\tUnsubscribeNamespace,\n} from \"./subscribe_namespace.ts\";\nimport { Version } from \"./version.ts\";\n\n// Bound on how long stream-open plus SUBSCRIBE_OK may take. Browsers cap\n// concurrent QUIC streams (Chrome ~100); past the cap openBi() silently\n// blocks. The timeout turns that into a clear error.\nconst SUBSCRIBE_OK_TIMEOUT_MS = 10_000;\n\n// Out-parameter for #openSubscribe: lets the caller observe partial progress\n// (stream opened, trackAlias registered) so it can clean up on timeout even\n// before the setup promise settles.\ntype SubscribeSetupState = {\n\tstream?: Stream;\n\tregisteredAlias?: bigint;\n};\n\n/**\n * Handles subscribing to broadcasts using moq-transport protocol.\n * Uses the stream-per-request pattern (real bidi streams for v17, virtual for v14-v16).\n *\n * @internal\n */\nexport class Subscriber {\n\t#session: Session;\n\n\t// Publisher-chosen aliases used by incoming group streams.\n\t#aliases = new TrackAliases<track.Producer>();\n\n\t// Units for each track's object Timestamps, from the TIMESCALE Track Property in\n\t// SUBSCRIBE_OK. A track missing from this map declared no timeline, so the publisher\n\t// opted out of timestamps and its frames are stamped on arrival instead.\n\t#timescales = new Map<bigint, Timescale>();\n\n\t// Dedup consumed broadcasts per path: repeat consume() calls share one subscription.\n\t#consumes = new BroadcastCache();\n\n\t// Any currently active announcements.\n\t#announced = new Set<Path.Valid>();\n\n\t// Any consumers that want each new announcement.\n\t#announcedConsumers = new Set<announce.Producer>();\n\n\t/**\n\t * Creates a new Subscriber instance.\n\t * @param session - The session abstraction for bidi streams and request IDs\n\t *\n\t * @internal\n\t */\n\tconstructor(session: Session) {\n\t\tthis.#session = session;\n\t}\n\n\t/**\n\t * Gets an announced reader for the specified prefix.\n\t */\n\tannounced(prefix = Path.empty()): announce.Consumer {\n\t\tconst announced = new announce.Producer(prefix);\n\t\tfor (const active of this.#announced) {\n\t\t\tconst suffix = Path.stripPrefix(prefix, active);\n\t\t\tif (suffix === null) continue;\n\t\t\tannounced.append({ path: suffix, active: true });\n\t\t}\n\t\tthis.#announcedConsumers.add(announced);\n\n\t\tvoid this.#runAnnounced(announced, prefix).finally(() => {\n\t\t\tthis.#announcedConsumers.delete(announced);\n\t\t\tannounced.close();\n\t\t});\n\n\t\treturn announced.consume();\n\t}\n\n\tasync #runAnnounced(announced: announce.Producer, prefix: Path.Valid) {\n\t\tconst version = this.#session.version;\n\n\t\t// v14/v15: SubscribeNamespace on control stream (via adapter virtual stream)\n\t\t// v16+: SubscribeNamespace on its own real bidi stream\n\n\t\tconst requestId = await this.#session.nextRequestId();\n\t\tif (requestId === undefined) return;\n\n\t\ttry {\n\t\t\t// v16: use a real bidi stream (not virtual control stream)\n\t\t\tconst stream =\n\t\t\t\tversion === Version.DRAFT_16 && this.#session.openNativeBi\n\t\t\t\t\t? await this.#session.openNativeBi()\n\t\t\t\t\t: await this.#session.openBi();\n\n\t\t\ttry {\n\t\t\t\t// Draft-18+ uses SUBSCRIBE_NAMESPACE (0x50); earlier drafts use the\n\t\t\t\t// legacy 0x11 message with a Subscribe Options field.\n\t\t\t\tif (\n\t\t\t\t\tversion === Version.DRAFT_14 ||\n\t\t\t\t\tversion === Version.DRAFT_15 ||\n\t\t\t\t\tversion === Version.DRAFT_16 ||\n\t\t\t\t\tversion === Version.DRAFT_17\n\t\t\t\t) {\n\t\t\t\t\tawait stream.writer.u53(SubscribeNamespaceLegacy.id);\n\t\t\t\t\tawait new SubscribeNamespaceLegacy({ namespace: prefix, requestId }).encode(stream.writer, version);\n\t\t\t\t} else {\n\t\t\t\t\tawait stream.writer.u53(SubscribeNamespace.id);\n\t\t\t\t\tawait new SubscribeNamespace({ namespace: prefix, requestId }).encode(stream.writer, version);\n\t\t\t\t}\n\t\t\t\tconsole.debug(`subscribe_namespace written: requestId=${requestId}`);\n\n\t\t\t\t// Read response\n\t\t\t\tconst respTypeId = await stream.reader.u53();\n\t\t\t\tif (respTypeId === RequestOk.id) {\n\t\t\t\t\tawait RequestOk.decode(stream.reader, version);\n\t\t\t\t} else if (respTypeId === SubscribeNamespaceOk.id) {\n\t\t\t\t\t// v14: SubscribeNamespaceOk\n\t\t\t\t\tconst size = await stream.reader.u16();\n\t\t\t\t\tawait stream.reader.read(size);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`SubscribeNamespace rejected: typeId=0x${respTypeId.toString(16)}`);\n\t\t\t\t}\n\n\t\t\t\t// Loop reading Namespace/NamespaceDone entries\n\t\t\t\tconst readLoop = (async () => {\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\tconst done = await stream.reader.done();\n\t\t\t\t\t\tif (done) break;\n\n\t\t\t\t\t\tconst msgType = await stream.reader.u53();\n\t\t\t\t\t\tif (msgType === SubscribeNamespaceEntry.id) {\n\t\t\t\t\t\t\tconst entry = await SubscribeNamespaceEntry.decode(stream.reader, version);\n\t\t\t\t\t\t\tconst path = Path.join(prefix, entry.suffix);\n\t\t\t\t\t\t\tconsole.debug(`announced: broadcast=${path} active=true`);\n\n\t\t\t\t\t\t\tthis.#announced.add(path);\n\t\t\t\t\t\t\tfor (const consumer of this.#announcedConsumers) {\n\t\t\t\t\t\t\t\tconst suffix = Path.stripPrefix(consumer.prefix, path);\n\t\t\t\t\t\t\t\tif (suffix === null) continue;\n\t\t\t\t\t\t\t\tconsumer.append({ path: suffix, active: true });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (msgType === SubscribeNamespaceEntryDone.id) {\n\t\t\t\t\t\t\tconst entry = await SubscribeNamespaceEntryDone.decode(stream.reader, version);\n\t\t\t\t\t\t\tconst path = Path.join(prefix, entry.suffix);\n\t\t\t\t\t\t\tconsole.debug(`announced: broadcast=${path} active=false`);\n\n\t\t\t\t\t\t\tthis.#announced.delete(path);\n\t\t\t\t\t\t\tthis.#consumes.evict(path);\n\t\t\t\t\t\t\tfor (const consumer of this.#announcedConsumers) {\n\t\t\t\t\t\t\t\tconst suffix = Path.stripPrefix(consumer.prefix, path);\n\t\t\t\t\t\t\t\tif (suffix === null) continue;\n\t\t\t\t\t\t\t\tconsumer.append({ path: suffix, active: false });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (msgType === PublishBlocked.id && version === Version.DRAFT_17) {\n\t\t\t\t\t\t\tconst blocked = await PublishBlocked.decode(stream.reader, version);\n\t\t\t\t\t\t\tconsole.debug(`publish_blocked: suffix=${blocked.suffix} track=${blocked.trackName}`);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`unexpected message on subscribe_namespace stream: 0x${msgType.toString(16)}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})();\n\n\t\t\t\t// Wait for either the read loop or the announced to close\n\t\t\t\tawait Promise.race([readLoop, announced.closed]);\n\n\t\t\t\t// For v14/v15: send UnsubscribeNamespace before closing\n\t\t\t\tif (version === Version.DRAFT_14 || version === Version.DRAFT_15) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait stream.writer.u53(UnsubscribeNamespace.id);\n\t\t\t\t\t\tconst unsub = new UnsubscribeNamespace({ requestId });\n\t\t\t\t\t\tawait unsub.encode(stream.writer, version);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Stream might already be closed\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tstream.close();\n\t\t\t} catch (err) {\n\t\t\t\tstream.abort(error(err));\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tconst e = error(err);\n\t\t\tconsole.warn(`subscribe_namespace error: ${reason(e)}`);\n\n\t\t\t// Abort the stream rather than letting the caller's `finally` close it cleanly.\n\t\t\t// A rejected namespace subscription is a failure, and a consumer that can't tell\n\t\t\t// it from \"nothing is published under this prefix\" waits forever on a broadcast\n\t\t\t// that will never be announced. Matches the lite subscriber.\n\t\t\tannounced.close(e);\n\t\t}\n\t}\n\n\t/**\n\t * Consumes a broadcast from the connection.\n\t *\n\t * Deduplicated per path: repeat calls for the same still-live path share one reference-counted\n\t * broadcast (and one upstream subscription). The shared broadcast closes once every caller has\n\t * closed its handle, so callers close normally.\n\t */\n\tconsume(path: Path.Valid): broadcast.Consumer {\n\t\treturn this.#consumes.get(path) ?? this.#consumes.insert(path, this.#createConsume(path));\n\t}\n\n\t#createConsume(path: Path.Valid): broadcast.Consumer {\n\t\t// moq-transport has no one-shot group fetch; ConsumeBroadcast rejects it. Track info\n\t\t// is resolved by the subscribe path (the inherited resolveTrackInfo).\n\t\tconst consumer = new ConsumeBroadcast();\n\n\t\tvoid (async () => {\n\t\t\tfor (;;) {\n\t\t\t\tconst request = await consumer.requested();\n\t\t\t\tif (!request) break;\n\t\t\t\tvoid this.#runSubscribe(path, request);\n\t\t\t}\n\t\t})();\n\n\t\treturn consumer;\n\t}\n\n\tasync #runSubscribe(broadcast: Path.Valid, request: track.Request) {\n\t\tconst version = this.#session.version;\n\t\tconst requestId = await this.#session.nextRequestId();\n\t\tif (requestId === undefined) {\n\t\t\trequest.reject(new Error(\"session closed\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.debug(`subscribe start: id=${requestId} broadcast=${broadcast} track=${request.name}`);\n\n\t\t// IETF negotiates group order in SUBSCRIBE_OK; this implementation only\n\t\t// supports descending (newest-first), so commit ordered: false. (There's no\n\t\t// per-frame timescale, so the rest stay at their defaults.) This\n\t\t// resolves the consumer's track.info() and gives us the write side that\n\t\t// incoming object streams are routed into.\n\t\tconst producer = request.accept({ ordered: false });\n\n\t\t// Open the stream and wait for SUBSCRIBE_OK under a timeout. State\n\t\t// flows back via `state` so the timeout path can clean up the stream\n\t\t// and any registration if setup eventually finishes.\n\t\tconst state: SubscribeSetupState = {};\n\t\tconst setup = this.#openSubscribe(state, broadcast, request, producer, requestId);\n\n\t\tlet stream: Stream;\n\t\tlet trackAlias: bigint;\n\t\ttry {\n\t\t\tconst result = await withTimeout(\n\t\t\t\tsetup,\n\t\t\t\tSUBSCRIBE_OK_TIMEOUT_MS,\n\t\t\t\t`subscribe timed out after ${SUBSCRIBE_OK_TIMEOUT_MS}ms waiting for SUBSCRIBE_OK (browser stream limit reached?)`,\n\t\t\t);\n\t\t\tstream = result.stream;\n\t\t\ttrackAlias = result.alias;\n\t\t\tconsole.debug(`subscribe ok: id=${requestId} broadcast=${broadcast} track=${request.name}`);\n\t\t} catch (err) {\n\t\t\tconst e = error(err);\n\t\t\tproducer.close(e);\n\t\t\tconsole.warn(\n\t\t\t\t`subscribe error: id=${requestId} broadcast=${broadcast} track=${request.name} error=${reason(e)}`,\n\t\t\t);\n\t\t\t// If setup eventually settles after the timeout, abort the stream\n\t\t\t// and drop any registration so we don't leak. Cover both branches:\n\t\t\t// setup may resolve late, or reject (e.g. SUBSCRIBE error) after the\n\t\t\t// stream is already open.\n\t\t\tconst cleanup = () => {\n\t\t\t\tif (state.registeredAlias !== undefined) this.#aliases.delete(state.registeredAlias, producer);\n\t\t\t\tstate.stream?.abort(e);\n\t\t\t};\n\t\t\tsetup.then(cleanup, cleanup);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Terminal conditions settle at most once (stream close = PublishDone, track close =\n\t\t\t// local unsubscribe); race them once so the demand loop doesn't re-subscribe each pass.\n\t\t\tconst done = Promise.race([stream.reader.closed, producer.closed]);\n\n\t\t\t// Serve until a terminal condition fires or the last local subscriber leaves. The unused\n\t\t\t// wake is level-triggered: re-check demand so a subscriber that returns before we tear\n\t\t\t// down resumes on the same stream.\n\t\t\tconst idle = Symbol(\"idle\");\n\t\t\tfor (;;) {\n\t\t\t\tconst reason = await Promise.race([done, producer.unused().then(() => idle)]);\n\t\t\t\tif (reason === idle && producer.closed.peek() === undefined && producer.used.peek()) continue;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// For v14-v16: send Unsubscribe before closing (removed in v17+)\n\t\t\tif (version === Version.DRAFT_14 || version === Version.DRAFT_15 || version === Version.DRAFT_16) {\n\t\t\t\ttry {\n\t\t\t\t\tawait stream.writer.u53(Unsubscribe.id);\n\t\t\t\t\tconst unsub = new Unsubscribe({ requestId });\n\t\t\t\t\tawait unsub.encode(stream.writer, version);\n\t\t\t\t} catch {\n\t\t\t\t\t// Stream might already be closed\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tproducer.close();\n\t\t\tstream.close();\n\t\t\tconsole.debug(`subscribe close: id=${requestId} broadcast=${broadcast} track=${request.name}`);\n\t\t} catch (err) {\n\t\t\tconst e = error(err);\n\t\t\tproducer.close(e);\n\t\t\tstream.abort(e);\n\t\t\tconsole.warn(\n\t\t\t\t`subscribe error: id=${requestId} broadcast=${broadcast} track=${request.name} error=${reason(e)}`,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.#aliases.delete(trackAlias, producer);\n\t\t\tthis.#timescales.delete(trackAlias);\n\t\t}\n\t}\n\n\t// Opens the subscribe stream, sends SUBSCRIBE, and reads the response.\n\t// `state` is populated as soon as the stream opens and again when the\n\t// trackAlias is registered, so the caller can clean both up on timeout\n\t// even before this promise settles.\n\tasync #openSubscribe(\n\t\tstate: SubscribeSetupState,\n\t\tbroadcast: Path.Valid,\n\t\trequest: track.Request,\n\t\tproducer: track.Producer,\n\t\trequestId: bigint,\n\t): Promise<{ stream: Stream; alias: bigint }> {\n\t\tconst version = this.#session.version;\n\n\t\tstate.stream = await this.#session.openBi();\n\n\t\tawait state.stream.writer.u53(Subscribe.id);\n\t\tconst msg = new Subscribe({\n\t\t\trequestId,\n\t\t\ttrackNamespace: broadcast,\n\t\t\ttrackName: request.name,\n\t\t\tsubscriberPriority: toWire(request.priority),\n\t\t});\n\t\tawait msg.encode(state.stream.writer, version);\n\t\tconsole.debug(`subscribe written: id=${requestId} broadcast=${broadcast} track=${request.name}`);\n\n\t\tconst respTypeId = await state.stream.reader.u53();\n\t\tif (respTypeId !== SubscribeOk.id) {\n\t\t\tlet reasonPhrase = \"unknown error\";\n\t\t\ttry {\n\t\t\t\tif (respTypeId === RequestError.id) {\n\t\t\t\t\tconst err =\n\t\t\t\t\t\tversion === Version.DRAFT_14\n\t\t\t\t\t\t\t? await SubscribeError.decode(state.stream.reader, version)\n\t\t\t\t\t\t\t: await RequestError.decode(state.stream.reader, version);\n\t\t\t\t\treasonPhrase = `code=${err.errorCode} reason=${err.reasonPhrase}`;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Decoding error response failed, use default message\n\t\t\t}\n\t\t\tthrow new Error(`SUBSCRIBE error: ${reasonPhrase}`);\n\t\t}\n\n\t\tconst ok = await SubscribeOk.decode(state.stream.reader, version);\n\t\ttry {\n\t\t\tthis.#aliases.set(ok.trackAlias, producer);\n\t\t\tif (ok.timescale !== undefined) {\n\t\t\t\tthis.#timescales.set(ok.trackAlias, ok.timescale);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tthis.#session.close();\n\t\t\tthrow err;\n\t\t}\n\t\tstate.registeredAlias = ok.trackAlias;\n\t\treturn { stream: state.stream, alias: ok.trackAlias };\n\t}\n\n\t/**\n\t * Handles an incoming PUBLISH_NAMESPACE on a bidi stream.\n\t * Tracks announced broadcasts and notifies consumers.\n\t *\n\t * @internal\n\t */\n\tasync runPublishNamespace(msg: PublishNamespace, stream: Stream) {\n\t\tconst version = this.#session.version;\n\t\tconst path = msg.trackNamespace;\n\n\t\tif (this.#announced.has(path)) {\n\t\t\tconsole.warn(\"duplicate PublishNamespace\");\n\t\t\tif (version === Version.DRAFT_14) {\n\t\t\t\tawait stream.writer.u53(PublishNamespaceError.id);\n\t\t\t\tconst err = new PublishNamespaceError({\n\t\t\t\t\trequestId: msg.requestId,\n\t\t\t\t\terrorCode: 409,\n\t\t\t\t\treasonPhrase: \"duplicate namespace\",\n\t\t\t\t});\n\t\t\t\tawait err.encode(stream.writer, version);\n\t\t\t} else {\n\t\t\t\tawait stream.writer.u53(RequestError.id);\n\t\t\t\tconst err = new RequestError({\n\t\t\t\t\trequestId: version === Version.DRAFT_15 || version === Version.DRAFT_16 ? msg.requestId : undefined,\n\t\t\t\t\terrorCode: 409,\n\t\t\t\t\treasonPhrase: \"duplicate namespace\",\n\t\t\t\t});\n\t\t\t\tawait err.encode(stream.writer, version);\n\t\t\t}\n\t\t\tstream.close();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#announced.add(path);\n\n\t\ttry {\n\t\t\t// Send OK first. This must complete before notifying consumers,\n\t\t\t// because consumers may trigger Subscribe writes that would\n\t\t\t// interleave with our OK on the control stream.\n\t\t\tif (version === Version.DRAFT_14) {\n\t\t\t\tawait stream.writer.u53(PublishNamespaceOk.id);\n\t\t\t\tconst ok = new PublishNamespaceOk({ requestId: msg.requestId });\n\t\t\t\tawait ok.encode(stream.writer, version);\n\t\t\t} else {\n\t\t\t\tawait stream.writer.u53(RequestOk.id);\n\t\t\t\tconst ok = new RequestOk({\n\t\t\t\t\trequestId: version === Version.DRAFT_15 || version === Version.DRAFT_16 ? msg.requestId : undefined,\n\t\t\t\t});\n\t\t\t\tawait ok.encode(stream.writer, version);\n\t\t\t}\n\n\t\t\tconsole.debug(`announced: broadcast=${path} active=true`);\n\n\t\t\t// Notify consumers after OK is written\n\t\t\tfor (const consumer of this.#announcedConsumers) {\n\t\t\t\tconst suffix = Path.stripPrefix(consumer.prefix, path);\n\t\t\t\tif (suffix === null) continue;\n\t\t\t\tconsumer.append({ path: suffix, active: true });\n\t\t\t}\n\n\t\t\t// Wait for stream close (= PublishNamespaceDone)\n\t\t\tconsole.debug(`runPublishNamespace: awaiting stream.reader.closed for ${path}`);\n\t\t\tawait stream.reader.closed;\n\t\t\tconsole.debug(`runPublishNamespace: stream.reader.closed resolved for ${path}`);\n\t\t} finally {\n\t\t\tthis.#announced.delete(path);\n\t\t\t// The path is gone, so stop sharing its broadcast: a holder outliving the publisher\n\t\t\t// would otherwise hand the dead generation to whoever consumes the path next.\n\t\t\tthis.#consumes.evict(path);\n\t\t\tconsole.debug(`announced: broadcast=${path} active=false`);\n\n\t\t\tfor (const consumer of this.#announcedConsumers) {\n\t\t\t\tconst suffix = Path.stripPrefix(consumer.prefix, path);\n\t\t\t\tif (suffix === null) continue;\n\t\t\t\ttry {\n\t\t\t\t\tconsumer.append({ path: suffix, active: false });\n\t\t\t\t} catch {\n\t\t\t\t\t// Consumer already closed, will be cleaned up\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles an incoming PUBLISH on a bidi stream.\n\t * We don't support reverse publish, so send error.\n\t *\n\t * @internal\n\t */\n\tasync runPublish(msg: Publish, stream: Stream) {\n\t\tconst version = this.#session.version;\n\n\t\tif (version === Version.DRAFT_14) {\n\t\t\tawait stream.writer.u53(PublishError.id);\n\t\t\tconst err = new PublishError({\n\t\t\t\trequestId: msg.requestId,\n\t\t\t\terrorCode: 500,\n\t\t\t\treasonPhrase: \"publish not supported\",\n\t\t\t});\n\t\t\tawait err.encode(stream.writer, version);\n\t\t} else {\n\t\t\tawait stream.writer.u53(RequestError.id);\n\t\t\tconst err = new RequestError({\n\t\t\t\trequestId: version === Version.DRAFT_15 || version === Version.DRAFT_16 ? msg.requestId : undefined,\n\t\t\t\terrorCode: 500,\n\t\t\t\treasonPhrase: \"publish not supported\",\n\t\t\t});\n\t\t\tawait err.encode(stream.writer, version);\n\t\t}\n\t\tstream.close();\n\t}\n\n\t/**\n\t * Handles an ObjectStream message (group + frames on uni stream).\n\t *\n\t * @internal\n\t */\n\tasync handleGroup(group: GroupMessage, stream: Reader) {\n\t\tconst producer = new netGroup.Producer(group.groupId);\n\n\t\tif (group.subGroupId !== 0) {\n\t\t\tthrow new Error(\"subgroups are not supported\");\n\t\t}\n\n\t\ttry {\n\t\t\t// The control message establishing this alias can arrive after the data stream.\n\t\t\tconst track = await this.#aliases.get(group.trackAlias);\n\n\t\t\ttrack.writeGroup(producer);\n\n\t\t\tfor (;;) {\n\t\t\t\tconst done = await Promise.race([stream.done(), producer.closed, track.closed]);\n\t\t\t\tif (done !== false) break;\n\n\t\t\t\tconst frame = await Frame.decode(\n\t\t\t\t\tstream,\n\t\t\t\t\tgroup.flags,\n\t\t\t\t\tthis.#timescales.get(group.trackAlias),\n\t\t\t\t\tthis.#session.version,\n\t\t\t\t);\n\t\t\t\tif (frame.payload === undefined) break;\n\n\t\t\t\tproducer.writeFrame({ payload: frame.payload, timestamp: frame.timestamp ?? Timestamp.now() });\n\t\t\t}\n\n\t\t\tproducer.close();\n\t\t} catch (err: unknown) {\n\t\t\tconst e = error(err);\n\t\t\tproducer.close(e);\n\t\t\tstream.stop(e);\n\t\t}\n\t}\n}\n\n/**\n * A broadcast consumed from a moq-transport session. Track info is resolved by the\n * subscribe path (the inherited `resolveTrackInfo`), but the protocol has no one-shot\n * group fetch, so `track.Consumer.fetchGroup()` is rejected.\n */\nclass ConsumeBroadcast extends broadcast.Consumer {\n\t// biome-ignore lint/complexity/noUselessConstructor: widens the protected base constructor to public\n\tconstructor(state?: never) {\n\t\tsuper(state);\n\t}\n\n\t// Preserve the subclass when the consume cache shares this broadcast across callers.\n\toverride clone(): ConsumeBroadcast {\n\t\treturn new ConsumeBroadcast(this.shareState());\n\t}\n\n\toverride fetchGroup(): Promise<netGroup.Consumer> {\n\t\treturn Promise.reject(new Error(\"fetch group is not supported for moq-transport\"));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"subscriber.js","sourceRoot":"","sources":["../../src/ietf/subscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,KAAK,EAA8B,MAAM,aAAa,CAAC;A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AK,CAAC,SAAS,IAAI,SAAS,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAChG,CAAC;YAED,QAAQ,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACrB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACF,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,gBAAiB,SAAQ,SAAS,CAAC,QAAQ;IAChD,qGAAqG;IACrG,YAAY,KAAa;QACxB,KAAK,CAAC,KAAK,CAAC,CAAC;IACd,CAAC;IAED,qFAAqF;IAC5E,KAAK;QACb,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAChD,CAAC;IAEQ,UAAU;QAClB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC,CAAC;IACpF,CAAC;CACD","sourcesContent":["import * as announce from \"../announced.ts\";\nimport * as broadcast from \"../broadcast.ts\";\nimport { BroadcastCache } from \"../consume.ts\";\nimport { error, reason } from \"../error.ts\";\nimport * as netGroup from \"../group.ts\";\nimport * as Path from \"../path.ts\";\nimport type { Reader, Stream } from \"../stream.ts\";\nimport { type Timescale, Timestamp } from \"../time.ts\";\nimport type * as track from \"../track.ts\";\nimport { withTimeout } from \"../util/timeout.ts\";\nimport type { Session } from \"./adapter.ts\";\nimport { TrackAliases } from \"./aliases.ts\";\nimport { Frame, type Group as GroupMessage } from \"./object.ts\";\nimport { toWire } from \"./priority.ts\";\nimport { type Publish, PublishError } from \"./publish.ts\";\nimport { type PublishNamespace, PublishNamespaceError, PublishNamespaceOk } from \"./publish_namespace.ts\";\nimport { RequestError, RequestOk } from \"./request.ts\";\nimport { Subscribe, SubscribeError, SubscribeOk, Unsubscribe } from \"./subscribe.ts\";\nimport {\n\tPublishBlocked,\n\tSubscribeNamespace,\n\tSubscribeNamespaceEntry,\n\tSubscribeNamespaceEntryDone,\n\tSubscribeNamespaceLegacy,\n\tSubscribeNamespaceOk,\n\tUnsubscribeNamespace,\n} from \"./subscribe_namespace.ts\";\nimport { Version } from \"./version.ts\";\n\n// Bound on how long stream-open plus SUBSCRIBE_OK may take. Browsers cap\n// concurrent QUIC streams (Chrome ~100); past the cap openBi() silently\n// blocks. The timeout turns that into a clear error.\nconst SUBSCRIBE_OK_TIMEOUT_MS = 10_000;\n\n// Out-parameter for #openSubscribe: lets the caller observe partial progress\n// (stream opened, trackAlias registered) so it can clean up on timeout even\n// before the setup promise settles.\ntype SubscribeSetupState = {\n\tstream?: Stream;\n\tregisteredAlias?: bigint;\n};\n\n/**\n * Handles subscribing to broadcasts using moq-transport protocol.\n * Uses the stream-per-request pattern (real bidi streams for v17, virtual for v14-v16).\n *\n * @internal\n */\nexport class Subscriber {\n\t#session: Session;\n\n\t// Publisher-chosen aliases used by incoming group streams.\n\t#aliases = new TrackAliases<track.Producer>();\n\n\t// Units for each track's object Timestamps, from the TIMESCALE Track Property in\n\t// SUBSCRIBE_OK. A track missing from this map declared no timeline, so the publisher\n\t// opted out of timestamps and its frames are stamped on arrival instead.\n\t#timescales = new Map<bigint, Timescale>();\n\n\t// Dedup consumed broadcasts per path: repeat consume() calls share one subscription.\n\t#consumes = new BroadcastCache();\n\n\t// Paths with a legacy PUBLISH_NAMESPACE request in flight, reserved synchronously.\n\t// The count below is only taken once the OK is written, and two requests that both\n\t// got past the duplicate check before either attached would both take one.\n\t#legacyRequests = new Set<Path.Valid>();\n\n\t// Every announced path, counted by how many live advertisements reference it.\n\t//\n\t// A peer may advertise one namespace twice on a session: an unsolicited\n\t// PUBLISH_NAMESPACE and an inline NAMESPACE answering our own SUBSCRIBE_NAMESPACE are\n\t// two messages about one source, which the MoQ Solicit draft requires us to tolerate.\n\t// Counting them is what keeps the second from duplicating the announce and the first\n\t// to end from retracting what the other still holds.\n\t#announced = new Map<Path.Valid, number>();\n\n\t// Any consumers that want each new announcement.\n\t#announcedConsumers = new Set<announce.Producer>();\n\n\t/**\n\t * Creates a new Subscriber instance.\n\t * @param session - The session abstraction for bidi streams and request IDs\n\t *\n\t * @internal\n\t */\n\tconstructor(session: Session) {\n\t\tthis.#session = session;\n\t}\n\n\t/**\n\t * Gets an announced reader for the specified prefix.\n\t *\n\t * The peer is asked with SUBSCRIBE_NAMESPACE regardless of what it declared, and an\n\t * unsolicited PUBLISH_NAMESPACE lands here too, so a peer that only tells and one\n\t * that only answers are both discovered.\n\t */\n\tannounced(prefix = Path.empty()): announce.Consumer {\n\t\tconst announced = new announce.Producer(prefix);\n\t\tfor (const active of this.#announced.keys()) {\n\t\t\tconst suffix = Path.stripPrefix(prefix, active);\n\t\t\tif (suffix === null) continue;\n\t\t\tannounced.append({ path: suffix, active: true });\n\t\t}\n\t\tthis.#announcedConsumers.add(announced);\n\n\t\tvoid this.#runAnnounced(announced, prefix).finally(() => {\n\t\t\tthis.#announcedConsumers.delete(announced);\n\t\t\tannounced.close();\n\t\t});\n\n\t\treturn announced.consume();\n\t}\n\n\t/**\n\t * Record one more advertisement for a path, telling consumers only when it is the\n\t * first. A second one is the same namespace said twice, not news.\n\t */\n\t#attachAnnounce(path: Path.Valid) {\n\t\tconst count = this.#announced.get(path) ?? 0;\n\t\tthis.#announced.set(path, count + 1);\n\t\tif (count > 0) return;\n\n\t\tconsole.debug(`announced: broadcast=${path} active=true`);\n\t\tfor (const consumer of this.#announcedConsumers) {\n\t\t\tconst suffix = Path.stripPrefix(consumer.prefix, path);\n\t\t\tif (suffix === null) continue;\n\t\t\tconsumer.append({ path: suffix, active: true });\n\t\t}\n\t}\n\n\t/**\n\t * Drop one advertisement for a path, retracting it only once the last one goes.\n\t */\n\t#detachAnnounce(path: Path.Valid) {\n\t\tconst count = this.#announced.get(path);\n\t\tif (count === undefined) return;\n\t\tif (count > 1) {\n\t\t\tthis.#announced.set(path, count - 1);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#announced.delete(path);\n\n\t\t// The path is gone, so stop sharing its broadcast: a holder outliving the publisher\n\t\t// would otherwise hand the dead generation to whoever consumes the path next.\n\t\tthis.#consumes.evict(path);\n\t\tconsole.debug(`announced: broadcast=${path} active=false`);\n\n\t\tfor (const consumer of this.#announcedConsumers) {\n\t\t\tconst suffix = Path.stripPrefix(consumer.prefix, path);\n\t\t\tif (suffix === null) continue;\n\t\t\ttry {\n\t\t\t\tconsumer.append({ path: suffix, active: false });\n\t\t\t} catch {\n\t\t\t\t// Consumer already closed, will be cleaned up\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #runAnnounced(announced: announce.Producer, prefix: Path.Valid) {\n\t\tconst version = this.#session.version;\n\n\t\t// Suffixes live on this stream, so a repeat is recognized as an update to the\n\t\t// advertisement rather than a second one, which would leak the count.\n\t\tconst live = new Set<Path.Valid>();\n\n\t\t// Set once the teardown below has given back everything this stream held. The read\n\t\t// loop is not awaited when the local consumer closes first, and closing the stream\n\t\t// cancels the transport without discarding what the reader already buffered, so a\n\t\t// fully buffered entry can still decode afterwards. Attaching one then would take a\n\t\t// reference nobody is left to release, pinning the path for the session.\n\t\tlet released = false;\n\n\t\t// v14/v15: SubscribeNamespace on control stream (via adapter virtual stream)\n\t\t// v16+: SubscribeNamespace on its own real bidi stream\n\n\t\tconst requestId = await this.#session.nextRequestId();\n\t\tif (requestId === undefined) return;\n\n\t\ttry {\n\t\t\t// v16: use a real bidi stream (not virtual control stream)\n\t\t\tconst stream =\n\t\t\t\tversion === Version.DRAFT_16 && this.#session.openNativeBi\n\t\t\t\t\t? await this.#session.openNativeBi()\n\t\t\t\t\t: await this.#session.openBi();\n\n\t\t\ttry {\n\t\t\t\t// Draft-18+ uses SUBSCRIBE_NAMESPACE (0x50); earlier drafts use the\n\t\t\t\t// legacy 0x11 message with a Subscribe Options field.\n\t\t\t\tif (\n\t\t\t\t\tversion === Version.DRAFT_14 ||\n\t\t\t\t\tversion === Version.DRAFT_15 ||\n\t\t\t\t\tversion === Version.DRAFT_16 ||\n\t\t\t\t\tversion === Version.DRAFT_17\n\t\t\t\t) {\n\t\t\t\t\tawait stream.writer.u53(SubscribeNamespaceLegacy.id);\n\t\t\t\t\tawait new SubscribeNamespaceLegacy({ namespace: prefix, requestId }).encode(stream.writer, version);\n\t\t\t\t} else {\n\t\t\t\t\tawait stream.writer.u53(SubscribeNamespace.id);\n\t\t\t\t\tawait new SubscribeNamespace({ namespace: prefix, requestId }).encode(stream.writer, version);\n\t\t\t\t}\n\t\t\t\tconsole.debug(`subscribe_namespace written: requestId=${requestId}`);\n\n\t\t\t\t// Read response\n\t\t\t\tconst respTypeId = await stream.reader.u53();\n\t\t\t\tif (respTypeId === RequestOk.id) {\n\t\t\t\t\tawait RequestOk.decode(stream.reader, version);\n\t\t\t\t} else if (respTypeId === SubscribeNamespaceOk.id) {\n\t\t\t\t\t// v14: SubscribeNamespaceOk\n\t\t\t\t\tconst size = await stream.reader.u16();\n\t\t\t\t\tawait stream.reader.read(size);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`SubscribeNamespace rejected: typeId=0x${respTypeId.toString(16)}`);\n\t\t\t\t}\n\n\t\t\t\t// Loop reading Namespace/NamespaceDone entries\n\t\t\t\tconst readLoop = (async () => {\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\tconst done = await stream.reader.done();\n\t\t\t\t\t\tif (done) break;\n\n\t\t\t\t\t\tconst msgType = await stream.reader.u53();\n\t\t\t\t\t\tif (msgType === SubscribeNamespaceEntry.id) {\n\t\t\t\t\t\t\tconst entry = await SubscribeNamespaceEntry.decode(stream.reader, version);\n\t\t\t\t\t\t\tif (released) break;\n\t\t\t\t\t\t\tconst path = Path.join(prefix, entry.suffix);\n\n\t\t\t\t\t\t\t// A repeat updates the advertisement; only the first is news.\n\t\t\t\t\t\t\tif (!live.has(path)) {\n\t\t\t\t\t\t\t\tlive.add(path);\n\t\t\t\t\t\t\t\tthis.#attachAnnounce(path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (msgType === SubscribeNamespaceEntryDone.id) {\n\t\t\t\t\t\t\tconst entry = await SubscribeNamespaceEntryDone.decode(stream.reader, version);\n\t\t\t\t\t\t\tif (released) break;\n\t\t\t\t\t\t\tconst path = Path.join(prefix, entry.suffix);\n\n\t\t\t\t\t\t\tif (live.delete(path)) {\n\t\t\t\t\t\t\t\tthis.#detachAnnounce(path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (msgType === PublishBlocked.id && version === Version.DRAFT_17) {\n\t\t\t\t\t\t\tconst blocked = await PublishBlocked.decode(stream.reader, version);\n\t\t\t\t\t\t\tconsole.debug(`publish_blocked: suffix=${blocked.suffix} track=${blocked.trackName}`);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`unexpected message on subscribe_namespace stream: 0x${msgType.toString(16)}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})();\n\n\t\t\t\t// Wait for either the read loop or the announced to close\n\t\t\t\tawait Promise.race([readLoop, announced.closed]);\n\n\t\t\t\t// For v14/v15: send UnsubscribeNamespace before closing\n\t\t\t\tif (version === Version.DRAFT_14 || version === Version.DRAFT_15) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait stream.writer.u53(UnsubscribeNamespace.id);\n\t\t\t\t\t\tconst unsub = new UnsubscribeNamespace({ requestId });\n\t\t\t\t\t\tawait unsub.encode(stream.writer, version);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Stream might already be closed\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tstream.close();\n\t\t\t} catch (err) {\n\t\t\t\tstream.abort(error(err));\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tconst e = error(err);\n\t\t\tconsole.warn(`subscribe_namespace error: ${reason(e)}`);\n\n\t\t\t// Abort the stream rather than letting the caller's `finally` close it cleanly.\n\t\t\t// A rejected namespace subscription is a failure, and a consumer that can't tell\n\t\t\t// it from \"nothing is published under this prefix\" waits forever on a broadcast\n\t\t\t// that will never be announced. Matches the lite subscriber.\n\t\t\tannounced.close(e);\n\t\t} finally {\n\t\t\t// The stream owns every advertisement it carried, so release them however it\n\t\t\t// ends: a clean close, a decode error, or the peer resetting it. Without this\n\t\t\t// each namespace keeps its count and the source never detaches, which would\n\t\t\t// pin the path for the session even after the other source withdrew.\n\t\t\treleased = true;\n\t\t\tfor (const path of live) {\n\t\t\t\tthis.#detachAnnounce(path);\n\t\t\t}\n\t\t\tlive.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Consumes a broadcast from the connection.\n\t *\n\t * Deduplicated per path: repeat calls for the same still-live path share one reference-counted\n\t * broadcast (and one upstream subscription). The shared broadcast closes once every caller has\n\t * closed its handle, so callers close normally.\n\t */\n\tconsume(path: Path.Valid): broadcast.Consumer {\n\t\treturn this.#consumes.get(path) ?? this.#consumes.insert(path, this.#createConsume(path));\n\t}\n\n\t#createConsume(path: Path.Valid): broadcast.Consumer {\n\t\t// moq-transport has no one-shot group fetch; ConsumeBroadcast rejects it. Track info\n\t\t// is resolved by the subscribe path (the inherited resolveTrackInfo).\n\t\tconst consumer = new ConsumeBroadcast();\n\n\t\tvoid (async () => {\n\t\t\tfor (;;) {\n\t\t\t\tconst request = await consumer.requested();\n\t\t\t\tif (!request) break;\n\t\t\t\tvoid this.#runSubscribe(path, request);\n\t\t\t}\n\t\t})();\n\n\t\treturn consumer;\n\t}\n\n\tasync #runSubscribe(broadcast: Path.Valid, request: track.Request) {\n\t\tconst version = this.#session.version;\n\t\tconst requestId = await this.#session.nextRequestId();\n\t\tif (requestId === undefined) {\n\t\t\trequest.reject(new Error(\"session closed\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.debug(`subscribe start: id=${requestId} broadcast=${broadcast} track=${request.name}`);\n\n\t\t// IETF negotiates group order in SUBSCRIBE_OK; this implementation only\n\t\t// supports descending (newest-first), so commit ordered: false. (There's no\n\t\t// per-frame timescale, so the rest stay at their defaults.) This\n\t\t// resolves the consumer's track.info() and gives us the write side that\n\t\t// incoming object streams are routed into.\n\t\tconst producer = request.accept({ ordered: false });\n\n\t\t// Open the stream and wait for SUBSCRIBE_OK under a timeout. State\n\t\t// flows back via `state` so the timeout path can clean up the stream\n\t\t// and any registration if setup eventually finishes.\n\t\tconst state: SubscribeSetupState = {};\n\t\tconst setup = this.#openSubscribe(state, broadcast, request, producer, requestId);\n\n\t\tlet stream: Stream;\n\t\tlet trackAlias: bigint;\n\t\ttry {\n\t\t\tconst result = await withTimeout(\n\t\t\t\tsetup,\n\t\t\t\tSUBSCRIBE_OK_TIMEOUT_MS,\n\t\t\t\t`subscribe timed out after ${SUBSCRIBE_OK_TIMEOUT_MS}ms waiting for SUBSCRIBE_OK (browser stream limit reached?)`,\n\t\t\t);\n\t\t\tstream = result.stream;\n\t\t\ttrackAlias = result.alias;\n\t\t\tconsole.debug(`subscribe ok: id=${requestId} broadcast=${broadcast} track=${request.name}`);\n\t\t} catch (err) {\n\t\t\tconst e = error(err);\n\t\t\tproducer.close(e);\n\t\t\tconsole.warn(\n\t\t\t\t`subscribe error: id=${requestId} broadcast=${broadcast} track=${request.name} error=${reason(e)}`,\n\t\t\t);\n\t\t\t// If setup eventually settles after the timeout, abort the stream\n\t\t\t// and drop any registration so we don't leak. Cover both branches:\n\t\t\t// setup may resolve late, or reject (e.g. SUBSCRIBE error) after the\n\t\t\t// stream is already open.\n\t\t\tconst cleanup = () => {\n\t\t\t\tif (state.registeredAlias !== undefined) this.#aliases.delete(state.registeredAlias, producer);\n\t\t\t\tstate.stream?.abort(e);\n\t\t\t};\n\t\t\tsetup.then(cleanup, cleanup);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Terminal conditions settle at most once (stream close = PublishDone, track close =\n\t\t\t// local unsubscribe); race them once so the demand loop doesn't re-subscribe each pass.\n\t\t\tconst done = Promise.race([stream.reader.closed, producer.closed]);\n\n\t\t\t// Serve until a terminal condition fires or the last local subscriber leaves. The unused\n\t\t\t// wake is level-triggered: re-check demand so a subscriber that returns before we tear\n\t\t\t// down resumes on the same stream.\n\t\t\tconst idle = Symbol(\"idle\");\n\t\t\tfor (;;) {\n\t\t\t\tconst reason = await Promise.race([done, producer.unused().then(() => idle)]);\n\t\t\t\tif (reason === idle && producer.closed.peek() === undefined && producer.used.peek()) continue;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// For v14-v16: send Unsubscribe before closing (removed in v17+)\n\t\t\tif (version === Version.DRAFT_14 || version === Version.DRAFT_15 || version === Version.DRAFT_16) {\n\t\t\t\ttry {\n\t\t\t\t\tawait stream.writer.u53(Unsubscribe.id);\n\t\t\t\t\tconst unsub = new Unsubscribe({ requestId });\n\t\t\t\t\tawait unsub.encode(stream.writer, version);\n\t\t\t\t} catch {\n\t\t\t\t\t// Stream might already be closed\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tproducer.close();\n\t\t\tstream.close();\n\t\t\tconsole.debug(`subscribe close: id=${requestId} broadcast=${broadcast} track=${request.name}`);\n\t\t} catch (err) {\n\t\t\tconst e = error(err);\n\t\t\tproducer.close(e);\n\t\t\tstream.abort(e);\n\t\t\tconsole.warn(\n\t\t\t\t`subscribe error: id=${requestId} broadcast=${broadcast} track=${request.name} error=${reason(e)}`,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.#aliases.delete(trackAlias, producer);\n\t\t\tthis.#timescales.delete(trackAlias);\n\t\t}\n\t}\n\n\t// Opens the subscribe stream, sends SUBSCRIBE, and reads the response.\n\t// `state` is populated as soon as the stream opens and again when the\n\t// trackAlias is registered, so the caller can clean both up on timeout\n\t// even before this promise settles.\n\tasync #openSubscribe(\n\t\tstate: SubscribeSetupState,\n\t\tbroadcast: Path.Valid,\n\t\trequest: track.Request,\n\t\tproducer: track.Producer,\n\t\trequestId: bigint,\n\t): Promise<{ stream: Stream; alias: bigint }> {\n\t\tconst version = this.#session.version;\n\n\t\tstate.stream = await this.#session.openBi();\n\n\t\tawait state.stream.writer.u53(Subscribe.id);\n\t\tconst msg = new Subscribe({\n\t\t\trequestId,\n\t\t\ttrackNamespace: broadcast,\n\t\t\ttrackName: request.name,\n\t\t\tsubscriberPriority: toWire(request.priority),\n\t\t});\n\t\tawait msg.encode(state.stream.writer, version);\n\t\tconsole.debug(`subscribe written: id=${requestId} broadcast=${broadcast} track=${request.name}`);\n\n\t\tconst respTypeId = await state.stream.reader.u53();\n\t\tif (respTypeId !== SubscribeOk.id) {\n\t\t\tlet reasonPhrase = \"unknown error\";\n\t\t\ttry {\n\t\t\t\tif (respTypeId === RequestError.id) {\n\t\t\t\t\tconst err =\n\t\t\t\t\t\tversion === Version.DRAFT_14\n\t\t\t\t\t\t\t? await SubscribeError.decode(state.stream.reader, version)\n\t\t\t\t\t\t\t: await RequestError.decode(state.stream.reader, version);\n\t\t\t\t\treasonPhrase = `code=${err.errorCode} reason=${err.reasonPhrase}`;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Decoding error response failed, use default message\n\t\t\t}\n\t\t\tthrow new Error(`SUBSCRIBE error: ${reasonPhrase}`);\n\t\t}\n\n\t\tconst ok = await SubscribeOk.decode(state.stream.reader, version);\n\t\ttry {\n\t\t\tthis.#aliases.set(ok.trackAlias, producer);\n\t\t\tif (ok.timescale !== undefined) {\n\t\t\t\tthis.#timescales.set(ok.trackAlias, ok.timescale);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tthis.#session.close();\n\t\t\tthrow err;\n\t\t}\n\t\tstate.registeredAlias = ok.trackAlias;\n\t\treturn { stream: state.stream, alias: ok.trackAlias };\n\t}\n\n\t/**\n\t * Handles an incoming PUBLISH_NAMESPACE on a bidi stream.\n\t * Tracks announced broadcasts and notifies consumers.\n\t *\n\t * @internal\n\t */\n\tasync runPublishNamespace(msg: PublishNamespace, stream: Stream) {\n\t\tconst version = this.#session.version;\n\t\tconst path = msg.trackNamespace;\n\n\t\t// Draft-14/15 key their namespace-scoped messages by name, not request ID, so the\n\t\t// adapter can hold only one request per namespace: a second would overwrite the\n\t\t// first, and the withdrawals would then close the wrong stream and fail to find\n\t\t// the other. Nothing is lost by refusing it, because the case that makes a second\n\t\t// reference legitimate (an inline NAMESPACE for a path a PUBLISH_NAMESPACE already\n\t\t// carried) needs a message those drafts do not have.\n\t\tconst legacy = version === Version.DRAFT_14 || version === Version.DRAFT_15;\n\t\tif (legacy && (this.#announced.has(path) || this.#legacyRequests.has(path))) {\n\t\t\tconsole.warn(\"duplicate PublishNamespace\");\n\t\t\tif (version === Version.DRAFT_14) {\n\t\t\t\tawait stream.writer.u53(PublishNamespaceError.id);\n\t\t\t\tawait new PublishNamespaceError({\n\t\t\t\t\trequestId: msg.requestId,\n\t\t\t\t\terrorCode: 409,\n\t\t\t\t\treasonPhrase: \"duplicate namespace\",\n\t\t\t\t}).encode(stream.writer, version);\n\t\t\t} else {\n\t\t\t\tawait stream.writer.u53(RequestError.id);\n\t\t\t\tawait new RequestError({\n\t\t\t\t\trequestId: msg.requestId,\n\t\t\t\t\terrorCode: 409,\n\t\t\t\t\treasonPhrase: \"duplicate namespace\",\n\t\t\t\t}).encode(stream.writer, version);\n\t\t\t}\n\t\t\tstream.close();\n\t\t\treturn;\n\t\t}\n\n\t\t// Everywhere else a path this session already knows is not refused: the same\n\t\t// namespace can reach us twice, and the count is what tells the second apart from\n\t\t// news. This request owns exactly one of those references and gives it back when\n\t\t// the stream ends.\n\t\tif (legacy) this.#legacyRequests.add(path);\n\t\tlet attached = false;\n\n\t\ttry {\n\t\t\t// Send OK first. This must complete before notifying consumers,\n\t\t\t// because consumers may trigger Subscribe writes that would\n\t\t\t// interleave with our OK on the control stream.\n\t\t\tif (version === Version.DRAFT_14) {\n\t\t\t\tawait stream.writer.u53(PublishNamespaceOk.id);\n\t\t\t\tconst ok = new PublishNamespaceOk({ requestId: msg.requestId });\n\t\t\t\tawait ok.encode(stream.writer, version);\n\t\t\t} else {\n\t\t\t\tawait stream.writer.u53(RequestOk.id);\n\t\t\t\tconst ok = new RequestOk({\n\t\t\t\t\trequestId: version === Version.DRAFT_15 || version === Version.DRAFT_16 ? msg.requestId : undefined,\n\t\t\t\t});\n\t\t\t\tawait ok.encode(stream.writer, version);\n\t\t\t}\n\n\t\t\t// Only now is the advertisement ours to announce, for the reason above: a\n\t\t\t// consumer reacting with a SUBSCRIBE must not interleave with that OK.\n\t\t\tattached = true;\n\t\t\tthis.#attachAnnounce(path);\n\n\t\t\t// Wait for stream close (= PublishNamespaceDone)\n\t\t\tconsole.debug(`runPublishNamespace: awaiting stream.reader.closed for ${path}`);\n\t\t\tawait stream.reader.closed;\n\t\t\tconsole.debug(`runPublishNamespace: stream.reader.closed resolved for ${path}`);\n\t\t} finally {\n\t\t\tif (legacy) this.#legacyRequests.delete(path);\n\n\t\t\t// Give back exactly what was taken: a request that never got its OK out never\n\t\t\t// referenced the path, and retracting there would drop someone else's count.\n\t\t\tif (attached) {\n\t\t\t\tthis.#detachAnnounce(path);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles an incoming PUBLISH on a bidi stream.\n\t * We don't support reverse publish, so send error.\n\t *\n\t * @internal\n\t */\n\tasync runPublish(msg: Publish, stream: Stream) {\n\t\tconst version = this.#session.version;\n\n\t\tif (version === Version.DRAFT_14) {\n\t\t\tawait stream.writer.u53(PublishError.id);\n\t\t\tconst err = new PublishError({\n\t\t\t\trequestId: msg.requestId,\n\t\t\t\terrorCode: 500,\n\t\t\t\treasonPhrase: \"publish not supported\",\n\t\t\t});\n\t\t\tawait err.encode(stream.writer, version);\n\t\t} else {\n\t\t\tawait stream.writer.u53(RequestError.id);\n\t\t\tconst err = new RequestError({\n\t\t\t\trequestId: version === Version.DRAFT_15 || version === Version.DRAFT_16 ? msg.requestId : undefined,\n\t\t\t\terrorCode: 500,\n\t\t\t\treasonPhrase: \"publish not supported\",\n\t\t\t});\n\t\t\tawait err.encode(stream.writer, version);\n\t\t}\n\t\tstream.close();\n\t}\n\n\t/**\n\t * Handles an ObjectStream message (group + frames on uni stream).\n\t *\n\t * @internal\n\t */\n\tasync handleGroup(group: GroupMessage, stream: Reader) {\n\t\tconst producer = new netGroup.Producer(group.groupId);\n\n\t\tif (group.subGroupId !== 0) {\n\t\t\tthrow new Error(\"subgroups are not supported\");\n\t\t}\n\n\t\ttry {\n\t\t\t// The control message establishing this alias can arrive after the data stream.\n\t\t\tconst track = await this.#aliases.get(group.trackAlias);\n\n\t\t\ttrack.writeGroup(producer);\n\n\t\t\tfor (;;) {\n\t\t\t\tconst done = await Promise.race([stream.done(), producer.closed, track.closed]);\n\t\t\t\tif (done !== false) break;\n\n\t\t\t\tconst frame = await Frame.decode(\n\t\t\t\t\tstream,\n\t\t\t\t\tgroup.flags,\n\t\t\t\t\tthis.#timescales.get(group.trackAlias),\n\t\t\t\t\tthis.#session.version,\n\t\t\t\t);\n\t\t\t\tif (frame.payload === undefined) break;\n\n\t\t\t\tproducer.writeFrame({ payload: frame.payload, timestamp: frame.timestamp ?? Timestamp.now() });\n\t\t\t}\n\n\t\t\tproducer.close();\n\t\t} catch (err: unknown) {\n\t\t\tconst e = error(err);\n\t\t\tproducer.close(e);\n\t\t\tstream.stop(e);\n\t\t}\n\t}\n}\n\n/**\n * A broadcast consumed from a moq-transport session. Track info is resolved by the\n * subscribe path (the inherited `resolveTrackInfo`), but the protocol has no one-shot\n * group fetch, so `track.Consumer.fetchGroup()` is rejected.\n */\nclass ConsumeBroadcast extends broadcast.Consumer {\n\t// biome-ignore lint/complexity/noUselessConstructor: widens the protected base constructor to public\n\tconstructor(state?: never) {\n\t\tsuper(state);\n\t}\n\n\t// Preserve the subclass when the consume cache shares this broadcast across callers.\n\toverride clone(): ConsumeBroadcast {\n\t\treturn new ConsumeBroadcast(this.shareState());\n\t}\n\n\toverride fetchGroup(): Promise<netGroup.Consumer> {\n\t\treturn Promise.reject(new Error(\"fetch group is not supported for moq-transport\"));\n\t}\n}\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream prioritization for moq-lite, mirroring the Rust `lite::priority` queue.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { Writer } from "../stream";
|
|
7
|
+
import type * as track from "../track";
|
|
8
|
+
/**
|
|
9
|
+
* What to rank a group stream by.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface Rank {
|
|
14
|
+
/** The subscriber's track priority, which outweighs everything below it. */
|
|
15
|
+
priority: number;
|
|
16
|
+
/**
|
|
17
|
+
* Where the group sits in the queue its own subscription wants sent, 0 being the one to
|
|
18
|
+
* send next. Defaults to 0, which is right for a stream that is the only one of its kind.
|
|
19
|
+
*/
|
|
20
|
+
position?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The transport send order for a group, where HIGHER values are transmitted first.
|
|
24
|
+
*
|
|
25
|
+
* A higher `priority` always wins. Below it, a group is ranked by its `position` in its own
|
|
26
|
+
* subscription rather than by its sequence, so two tracks at the same priority interleave:
|
|
27
|
+
* each one's next group ties with the other's, whatever their group numbering. Comparing
|
|
28
|
+
* sequences instead would let a track that had been running longer, or that numbered its
|
|
29
|
+
* groups from a clock, starve one that started later.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare function sendOrder({ priority, position }: Rank): number;
|
|
34
|
+
/**
|
|
35
|
+
* Ranks one subscription's group streams against each other, and re-ranks them whenever the
|
|
36
|
+
* set changes or the subscription is updated.
|
|
37
|
+
*
|
|
38
|
+
* A group's rank is its position among the groups in flight, so which group goes first is
|
|
39
|
+
* decided here rather than by arithmetic on sequence numbers. Newest-first by default, since
|
|
40
|
+
* that is what live playback wants; an `ordered` subscription is playing through in sequence,
|
|
41
|
+
* so it gets the oldest group first instead.
|
|
42
|
+
*
|
|
43
|
+
* One listener covers the whole subscription. A listener per group would instead pile up on
|
|
44
|
+
* it, and a track that stalls with many groups open would trip the signals leak guard.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare class Priority {
|
|
49
|
+
#private;
|
|
50
|
+
/** Follow `track`'s subscription until {@link close}. */
|
|
51
|
+
constructor(track: track.Subscriber);
|
|
52
|
+
/** The send order for a group at `sequence`, whether or not it has a stream yet. */
|
|
53
|
+
rank(sequence: number): number;
|
|
54
|
+
/** Rank a group's stream now, and again whenever the ranking changes, until {@link remove}. */
|
|
55
|
+
add(stream: Writer, sequence: number): void;
|
|
56
|
+
/** Stop ranking a finished group's stream, promoting whatever was queued behind it. */
|
|
57
|
+
remove(stream: Writer): void;
|
|
58
|
+
/**
|
|
59
|
+
* Stop taking new groups, and release the subscription listener once the last one leaves.
|
|
60
|
+
*
|
|
61
|
+
* The track can finish while several groups are still draining, and those are the ones the
|
|
62
|
+
* subscriber is still waiting on. They keep being promoted as the groups ahead of them
|
|
63
|
+
* finish, rather than being stranded at whatever position they held when the track ended.
|
|
64
|
+
*/
|
|
65
|
+
close(): void;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=priority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority.d.ts","sourceRoot":"","sources":["../../src/lite/priority.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAY1C;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACpB,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,EAAE,IAAI,GAAG,MAAM,CAElE;AAQD;;;;;;;;;;;;;GAaG;AACH,qBAAa,QAAQ;;IAMpB,yDAAyD;IACzD,YAAY,KAAK,EAAE,KAAK,CAAC,UAAU,EAGlC;IAED,oFAAoF;IACpF,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK7B;IAED,+FAA+F;IAC/F,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAMnC;IAED,uFAAuF;IACvF,MAAM,CAAC,MAAM,EAAE,MAAM,QAQpB;IAED;;;;;;OAMG;IACH,KAAK,SAGJ;CAqBD"}
|
package/lite/priority.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* @ts-self-types="./priority.d.ts" */
|
|
2
|
+
/**
|
|
3
|
+
* Stream prioritization for moq-lite, mirroring the Rust `lite::priority` queue.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
// The transport compares send orders as a single number, so the two ranks are packed into
|
|
8
|
+
// disjoint ranges: the track priority takes the high bits so it always dominates, and the
|
|
9
|
+
// position below it. Group data stays negative so protocol streams at the transport's default
|
|
10
|
+
// order of 0 always make progress. A u8 priority and 44-bit position fill the negative half of
|
|
11
|
+
// the safe integer range exactly.
|
|
12
|
+
const GROUP_SPAN = 2 ** 44;
|
|
13
|
+
/** The highest track priority the wire carries (a u8). */
|
|
14
|
+
const MAX_PRIORITY = 0xff;
|
|
15
|
+
/**
|
|
16
|
+
* The transport send order for a group, where HIGHER values are transmitted first.
|
|
17
|
+
*
|
|
18
|
+
* A higher `priority` always wins. Below it, a group is ranked by its `position` in its own
|
|
19
|
+
* subscription rather than by its sequence, so two tracks at the same priority interleave:
|
|
20
|
+
* each one's next group ties with the other's, whatever their group numbering. Comparing
|
|
21
|
+
* sequences instead would let a track that had been running longer, or that numbered its
|
|
22
|
+
* groups from a clock, starve one that started later.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export function sendOrder({ priority, position = 0 }) {
|
|
27
|
+
return -((MAX_PRIORITY - clamp(priority, MAX_PRIORITY)) * GROUP_SPAN + clamp(position, GROUP_SPAN - 1) + 1);
|
|
28
|
+
}
|
|
29
|
+
// Both ranks are bounded: the priority by its wire type, the position by the space left below
|
|
30
|
+
// it. Anything outside is a caller bug rather than a value worth preserving.
|
|
31
|
+
function clamp(value, max) {
|
|
32
|
+
return Math.min(Math.max(Math.trunc(value), 0), max);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Ranks one subscription's group streams against each other, and re-ranks them whenever the
|
|
36
|
+
* set changes or the subscription is updated.
|
|
37
|
+
*
|
|
38
|
+
* A group's rank is its position among the groups in flight, so which group goes first is
|
|
39
|
+
* decided here rather than by arithmetic on sequence numbers. Newest-first by default, since
|
|
40
|
+
* that is what live playback wants; an `ordered` subscription is playing through in sequence,
|
|
41
|
+
* so it gets the oldest group first instead.
|
|
42
|
+
*
|
|
43
|
+
* One listener covers the whole subscription. A listener per group would instead pile up on
|
|
44
|
+
* it, and a track that stalls with many groups open would trip the signals leak guard.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export class Priority {
|
|
49
|
+
#track;
|
|
50
|
+
#streams = new Map();
|
|
51
|
+
#dispose;
|
|
52
|
+
#closed = false;
|
|
53
|
+
/** Follow `track`'s subscription until {@link close}. */
|
|
54
|
+
constructor(track) {
|
|
55
|
+
this.#track = track;
|
|
56
|
+
this.#dispose = track.subscription.subscribe(() => this.#rerank());
|
|
57
|
+
}
|
|
58
|
+
/** The send order for a group at `sequence`, whether or not it has a stream yet. */
|
|
59
|
+
rank(sequence) {
|
|
60
|
+
return sendOrder({
|
|
61
|
+
priority: this.#track.subscription.peek()?.priority ?? 0,
|
|
62
|
+
position: this.#position(sequence),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** Rank a group's stream now, and again whenever the ranking changes, until {@link remove}. */
|
|
66
|
+
add(stream, sequence) {
|
|
67
|
+
this.#streams.set(stream, sequence);
|
|
68
|
+
// Also covers the stream itself: opening one can block on transport capacity, so an
|
|
69
|
+
// update that landed while it did predates this registration.
|
|
70
|
+
this.#rerank();
|
|
71
|
+
}
|
|
72
|
+
/** Stop ranking a finished group's stream, promoting whatever was queued behind it. */
|
|
73
|
+
remove(stream) {
|
|
74
|
+
if (!this.#streams.delete(stream))
|
|
75
|
+
return;
|
|
76
|
+
if (this.#closed && this.#streams.size === 0) {
|
|
77
|
+
this.#dispose();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.#rerank();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Stop taking new groups, and release the subscription listener once the last one leaves.
|
|
85
|
+
*
|
|
86
|
+
* The track can finish while several groups are still draining, and those are the ones the
|
|
87
|
+
* subscriber is still waiting on. They keep being promoted as the groups ahead of them
|
|
88
|
+
* finish, rather than being stranded at whatever position they held when the track ended.
|
|
89
|
+
*/
|
|
90
|
+
close() {
|
|
91
|
+
this.#closed = true;
|
|
92
|
+
if (this.#streams.size === 0)
|
|
93
|
+
this.#dispose();
|
|
94
|
+
}
|
|
95
|
+
// How many of this subscription's groups in flight should be sent before `sequence`.
|
|
96
|
+
// Sequences are unique within a subscription, so a group already registered never counts
|
|
97
|
+
// itself.
|
|
98
|
+
#position(sequence) {
|
|
99
|
+
const ordered = this.#track.subscription.peek()?.ordered ?? false;
|
|
100
|
+
let ahead = 0;
|
|
101
|
+
for (const other of this.#streams.values()) {
|
|
102
|
+
if (ordered ? other < sequence : other > sequence)
|
|
103
|
+
ahead++;
|
|
104
|
+
}
|
|
105
|
+
return ahead;
|
|
106
|
+
}
|
|
107
|
+
#rerank() {
|
|
108
|
+
const priority = this.#track.subscription.peek()?.priority ?? 0;
|
|
109
|
+
for (const [stream, sequence] of this.#streams) {
|
|
110
|
+
stream.setPriority(sendOrder({ priority, position: this.#position(sequence) }));
|
|
111
|
+
}
|
|
112
|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C;YAC5C,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,QAAQ;gBAAE,KAAK,EAAE,CAAC;QAC5D,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO;QACN,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,QAAQ,IAAI,CAAC,CAAC;QAChE,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChD,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACjF,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Stream prioritization for moq-lite, mirroring the Rust `lite::priority` queue.\n *\n * @module\n */\n\nimport type { Dispose } from \"@moq/signals\";\nimport type { Writer } from \"../stream.ts\";\nimport type * as track from \"../track.ts\";\n\n// The transport compares send orders as a single number, so the two ranks are packed into\n// disjoint ranges: the track priority takes the high bits so it always dominates, and the\n// position below it. Group data stays negative so protocol streams at the transport's default\n// order of 0 always make progress. A u8 priority and 44-bit position fill the negative half of\n// the safe integer range exactly.\nconst GROUP_SPAN = 2 ** 44;\n\n/** The highest track priority the wire carries (a u8). */\nconst MAX_PRIORITY = 0xff;\n\n/**\n * What to rank a group stream by.\n *\n * @internal\n */\nexport interface Rank {\n\t/** The subscriber's track priority, which outweighs everything below it. */\n\tpriority: number;\n\n\t/**\n\t * Where the group sits in the queue its own subscription wants sent, 0 being the one to\n\t * send next. Defaults to 0, which is right for a stream that is the only one of its kind.\n\t */\n\tposition?: number;\n}\n\n/**\n * The transport send order for a group, where HIGHER values are transmitted first.\n *\n * A higher `priority` always wins. Below it, a group is ranked by its `position` in its own\n * subscription rather than by its sequence, so two tracks at the same priority interleave:\n * each one's next group ties with the other's, whatever their group numbering. Comparing\n * sequences instead would let a track that had been running longer, or that numbered its\n * groups from a clock, starve one that started later.\n *\n * @internal\n */\nexport function sendOrder({ priority, position = 0 }: Rank): number {\n\treturn -((MAX_PRIORITY - clamp(priority, MAX_PRIORITY)) * GROUP_SPAN + clamp(position, GROUP_SPAN - 1) + 1);\n}\n\n// Both ranks are bounded: the priority by its wire type, the position by the space left below\n// it. Anything outside is a caller bug rather than a value worth preserving.\nfunction clamp(value: number, max: number): number {\n\treturn Math.min(Math.max(Math.trunc(value), 0), max);\n}\n\n/**\n * Ranks one subscription's group streams against each other, and re-ranks them whenever the\n * set changes or the subscription is updated.\n *\n * A group's rank is its position among the groups in flight, so which group goes first is\n * decided here rather than by arithmetic on sequence numbers. Newest-first by default, since\n * that is what live playback wants; an `ordered` subscription is playing through in sequence,\n * so it gets the oldest group first instead.\n *\n * One listener covers the whole subscription. A listener per group would instead pile up on\n * it, and a track that stalls with many groups open would trip the signals leak guard.\n *\n * @internal\n */\nexport class Priority {\n\t#track: track.Subscriber;\n\t#streams = new Map<Writer, number>();\n\t#dispose: Dispose;\n\t#closed = false;\n\n\t/** Follow `track`'s subscription until {@link close}. */\n\tconstructor(track: track.Subscriber) {\n\t\tthis.#track = track;\n\t\tthis.#dispose = track.subscription.subscribe(() => this.#rerank());\n\t}\n\n\t/** The send order for a group at `sequence`, whether or not it has a stream yet. */\n\trank(sequence: number): number {\n\t\treturn sendOrder({\n\t\t\tpriority: this.#track.subscription.peek()?.priority ?? 0,\n\t\t\tposition: this.#position(sequence),\n\t\t});\n\t}\n\n\t/** Rank a group's stream now, and again whenever the ranking changes, until {@link remove}. */\n\tadd(stream: Writer, sequence: number) {\n\t\tthis.#streams.set(stream, sequence);\n\n\t\t// Also covers the stream itself: opening one can block on transport capacity, so an\n\t\t// update that landed while it did predates this registration.\n\t\tthis.#rerank();\n\t}\n\n\t/** Stop ranking a finished group's stream, promoting whatever was queued behind it. */\n\tremove(stream: Writer) {\n\t\tif (!this.#streams.delete(stream)) return;\n\n\t\tif (this.#closed && this.#streams.size === 0) {\n\t\t\tthis.#dispose();\n\t\t} else {\n\t\t\tthis.#rerank();\n\t\t}\n\t}\n\n\t/**\n\t * Stop taking new groups, and release the subscription listener once the last one leaves.\n\t *\n\t * The track can finish while several groups are still draining, and those are the ones the\n\t * subscriber is still waiting on. They keep being promoted as the groups ahead of them\n\t * finish, rather than being stranded at whatever position they held when the track ended.\n\t */\n\tclose() {\n\t\tthis.#closed = true;\n\t\tif (this.#streams.size === 0) this.#dispose();\n\t}\n\n\t// How many of this subscription's groups in flight should be sent before `sequence`.\n\t// Sequences are unique within a subscription, so a group already registered never counts\n\t// itself.\n\t#position(sequence: number): number {\n\t\tconst ordered = this.#track.subscription.peek()?.ordered ?? false;\n\n\t\tlet ahead = 0;\n\t\tfor (const other of this.#streams.values()) {\n\t\t\tif (ordered ? other < sequence : other > sequence) ahead++;\n\t\t}\n\t\treturn ahead;\n\t}\n\n\t#rerank() {\n\t\tconst priority = this.#track.subscription.peek()?.priority ?? 0;\n\t\tfor (const [stream, sequence] of this.#streams) {\n\t\t\tstream.setPriority(sendOrder({ priority, position: this.#position(sequence) }));\n\t\t}\n\t}\n}\n"]}
|
package/lite/publisher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisher.d.ts","sourceRoot":"","sources":["../../src/lite/publisher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,cAAc,CAAC;AAGnD,OAAO,EAA4B,KAAK,eAAe,EAA2B,MAAM,eAAe,CAAC;AAGxG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"publisher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KG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,iBAmD5B;IAED,KAAK,SAWJ;CACD"}
|
package/lite/publisher.js
CHANGED
|
@@ -8,6 +8,7 @@ import { AnnounceInit, AnnounceOk, encodeAnnounceBroadcast } from "./announce.js
|
|
|
8
8
|
import { Datagram as DatagramMessage } from "./datagram.js";
|
|
9
9
|
import * as DatagramStream from "./datagram_stream.js";
|
|
10
10
|
import { Group as GroupMessage } from "./group.js";
|
|
11
|
+
import { Priority, sendOrder } from "./priority.js";
|
|
11
12
|
import { Probe } from "./probe.js";
|
|
12
13
|
import { encodeSubscribeResponse, SubscribeEnd, SubscribeOk, SubscribeStart, SubscribeUpdate, } from "./subscribe.js";
|
|
13
14
|
import { TrackInfo as TrackInfoMessage } from "./track.js";
|
|
@@ -226,7 +227,7 @@ export class Publisher {
|
|
|
226
227
|
// The best-effort datagram loop, started once serving begins. It parks when the
|
|
227
228
|
// track finishes (recvDatagram returns undefined), so #runTrack alone ends the
|
|
228
229
|
// subscription; awaited during teardown so it doesn't outlive the subscription.
|
|
229
|
-
let datagrams;
|
|
230
|
+
let datagrams = Promise.resolve();
|
|
230
231
|
try {
|
|
231
232
|
let timescale = Timescale.MILLI;
|
|
232
233
|
if (supportsTrackStream(this.version)) {
|
|
@@ -309,6 +310,9 @@ export class Publisher {
|
|
|
309
310
|
stream.writer.reset(new Error("not found"));
|
|
310
311
|
return;
|
|
311
312
|
}
|
|
313
|
+
// The subscriber opened this stream, so its send order only ranked the request. Rank the
|
|
314
|
+
// response here, on the same scale as the group streams it competes with.
|
|
315
|
+
stream.writer.setPriority(sendOrder({ priority: msg.priority }));
|
|
312
316
|
let group;
|
|
313
317
|
try {
|
|
314
318
|
// The timescale is immutable, so serve exactly what TRACK_INFO advertised.
|
|
@@ -344,9 +348,29 @@ export class Publisher {
|
|
|
344
348
|
// sequence-ordered, so this tracks the max and not the last group seen. 0 is already
|
|
345
349
|
// the encoding for a track that produced no groups.
|
|
346
350
|
let end = 0;
|
|
351
|
+
// One ranking for the whole subscription, shared by every group it serves.
|
|
352
|
+
const priority = new Priority(track);
|
|
353
|
+
// Cancels groups still queued for a stream slot. Only the subscriber leaving counts:
|
|
354
|
+
// a track that ran out of groups still has to flush the ones already queued, and we
|
|
355
|
+
// FIN the subscribe stream ourselves below to say so.
|
|
356
|
+
let finished = false;
|
|
357
|
+
let unsubscribe;
|
|
358
|
+
const unsubscribed = new Promise((resolve) => {
|
|
359
|
+
unsubscribe = resolve;
|
|
360
|
+
});
|
|
361
|
+
void stream.closed.then(() => {
|
|
362
|
+
if (!finished)
|
|
363
|
+
unsubscribe();
|
|
364
|
+
},
|
|
365
|
+
// A reset is always the peer.
|
|
366
|
+
() => unsubscribe());
|
|
347
367
|
try {
|
|
348
368
|
for (;;) {
|
|
349
|
-
|
|
369
|
+
// Exactly-once serving, not the sequence cursor: on a relay, a burst can be
|
|
370
|
+
// ingested micro-reordered by the upstream leg, and a sequence cursor would
|
|
371
|
+
// permanently skip the older group even though it is cached and in demand.
|
|
372
|
+
// Staleness is the latency window's job (cache expiry), not arrival order's.
|
|
373
|
+
const next = track.recvGroup();
|
|
350
374
|
const group = await Promise.race([next, stream.closed]);
|
|
351
375
|
if (!group) {
|
|
352
376
|
next.then((group) => group?.close()).catch(() => { });
|
|
@@ -354,24 +378,33 @@ export class Publisher {
|
|
|
354
378
|
}
|
|
355
379
|
if (emitRange && !startSent) {
|
|
356
380
|
startSent = true;
|
|
381
|
+
// SUBSCRIBE_START promises nothing below this sequence will be delivered.
|
|
382
|
+
// Arrival-order serving could later surface a straggler below the first
|
|
383
|
+
// group, so pin the floor to what was announced.
|
|
384
|
+
track.startAt(group.sequence);
|
|
357
385
|
await encodeSubscribeResponse(stream, { start: new SubscribeStart(group.sequence) }, this.version);
|
|
358
386
|
}
|
|
359
387
|
end = Math.max(end, group.sequence + 1);
|
|
360
|
-
void this.#runGroup(sub, group, timescale);
|
|
388
|
+
void this.#runGroup({ sub, group, timescale, priority, unsubscribed });
|
|
361
389
|
}
|
|
362
390
|
if (emitRange) {
|
|
363
391
|
await encodeSubscribeResponse(stream, { end: new SubscribeEnd(end) }, this.version);
|
|
364
392
|
}
|
|
365
393
|
console.debug(`publish close: broadcast=${broadcast} track=${track.name}`);
|
|
394
|
+
finished = true;
|
|
366
395
|
track.close();
|
|
367
396
|
stream.close();
|
|
368
397
|
}
|
|
369
398
|
catch (err) {
|
|
370
399
|
const e = error(err);
|
|
371
400
|
console.warn(`publish error: broadcast=${broadcast} track=${track.name} error=${reason(e)}`);
|
|
401
|
+
unsubscribe();
|
|
372
402
|
track.close(e);
|
|
373
403
|
stream.reset(e);
|
|
374
404
|
}
|
|
405
|
+
finally {
|
|
406
|
+
priority.close();
|
|
407
|
+
}
|
|
375
408
|
}
|
|
376
409
|
/**
|
|
377
410
|
* Answers a TRACK stream (0x6) with a single TRACK_INFO, then FINs.
|
|
@@ -456,13 +489,6 @@ export class Publisher {
|
|
|
456
489
|
console.debug(`datagram send stopped: sub=${sub} error=${reason(err)}`);
|
|
457
490
|
}
|
|
458
491
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Runs a group and sends its frames to the stream.
|
|
461
|
-
* @param sub - The subscription ID
|
|
462
|
-
* @param group - The group to run
|
|
463
|
-
*
|
|
464
|
-
* @internal
|
|
465
|
-
*/
|
|
466
492
|
// Serialize a fetched group's frames onto the FETCH stream as bare records: each a
|
|
467
493
|
// zigzag-delta timestamp (at the track's advertised timescale) followed by size + bytes.
|
|
468
494
|
async #runFetchGroup(group, stream, timescale) {
|
|
@@ -478,17 +504,43 @@ export class Publisher {
|
|
|
478
504
|
await stream.write(frame.payload);
|
|
479
505
|
}
|
|
480
506
|
}
|
|
481
|
-
|
|
507
|
+
/**
|
|
508
|
+
* Serves one group on its own unidirectional stream.
|
|
509
|
+
*
|
|
510
|
+
* @internal
|
|
511
|
+
*/
|
|
512
|
+
async #runGroup(options) {
|
|
513
|
+
const { sub, group, timescale, priority, unsubscribed } = options;
|
|
482
514
|
const msg = new GroupMessage(sub, group.sequence);
|
|
483
515
|
try {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
|
|
490
|
-
|
|
516
|
+
// The transport drains streams by send order, so this is what makes a high-priority
|
|
517
|
+
// track (and a newer group within it) win the link when there isn't room for both.
|
|
518
|
+
//
|
|
519
|
+
// One stream per group is faster than a peer at its limit can retire them, so this
|
|
520
|
+
// is the one path that doesn't wait for a slot: the transport would serve the opens
|
|
521
|
+
// in the order we asked, which is oldest-first, exactly backwards for live media.
|
|
522
|
+
// Failing here drops the group and lets the next one compete for the next slot.
|
|
523
|
+
const stream = await Writer.tryOpen(this.#quic, {
|
|
524
|
+
sendOrder: priority.rank(group.sequence),
|
|
525
|
+
cancel: unsubscribed,
|
|
526
|
+
waitUntilAvailable: false,
|
|
527
|
+
});
|
|
528
|
+
if (!stream) {
|
|
529
|
+
group.close(new Error("no stream slot"));
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
// Everything past this point runs inside the cleanup scope, so a failure never leaves
|
|
533
|
+
// a finished group's stream being ranked.
|
|
491
534
|
try {
|
|
535
|
+
// A SUBSCRIBE_UPDATE re-ranks the subscription, so a group already on the wire
|
|
536
|
+
// follows it too rather than keeping a stale rank until it finishes.
|
|
537
|
+
priority.add(stream, group.sequence);
|
|
538
|
+
await stream.u53(0); // stream type
|
|
539
|
+
await msg.encode(stream);
|
|
540
|
+
// Lite05+ prefixes every frame with a zigzag-delta timestamp at the track's
|
|
541
|
+
// advertised timescale; older drafts omit it.
|
|
542
|
+
const timestamps = supportsTrackStream(this.version);
|
|
543
|
+
let prevTs = 0n;
|
|
492
544
|
for (;;) {
|
|
493
545
|
const frame = await Promise.race([group.readFrame(), stream.closed]);
|
|
494
546
|
if (!frame)
|
|
@@ -510,6 +562,9 @@ export class Publisher {
|
|
|
510
562
|
stream.reset(e);
|
|
511
563
|
group.close(e);
|
|
512
564
|
}
|
|
565
|
+
finally {
|
|
566
|
+
priority.remove(stream);
|
|
567
|
+
}
|
|
513
568
|
}
|
|
514
569
|
catch (err) {
|
|
515
570
|
const e = error(err);
|