@norskvideo/moq-net 0.1.2 → 0.1.4
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 +1 -0
- package/announced.d.ts +111 -21
- package/announced.d.ts.map +1 -1
- package/announced.js +213 -40
- package/announced.js.map +1 -1
- package/broadcast.d.ts +80 -25
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +270 -49
- package/broadcast.js.map +1 -1
- package/connection/accept.d.ts +6 -0
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +42 -13
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts +5 -0
- package/connection/browser.d.ts.map +1 -0
- package/connection/browser.js +31 -0
- package/connection/browser.js.map +1 -0
- package/connection/connect.d.ts +43 -1
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +118 -123
- package/connection/connect.js.map +1 -1
- package/connection/established.d.ts +43 -16
- package/connection/established.d.ts.map +1 -1
- package/connection/established.js.map +1 -1
- package/connection/handshake.d.ts +12 -1
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +30 -14
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +8 -0
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +6 -0
- package/connection/index.js.map +1 -1
- package/connection/reload.d.ts +66 -9
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +192 -66
- package/connection/reload.js.map +1 -1
- package/connection/stats.d.ts +92 -0
- package/connection/stats.d.ts.map +1 -0
- package/connection/stats.js +35 -0
- package/connection/stats.js.map +1 -0
- package/connection/transport.d.ts +10 -0
- package/connection/transport.d.ts.map +1 -0
- package/connection/transport.js +12 -0
- package/connection/transport.js.map +1 -0
- package/consume.d.ts +44 -0
- package/consume.d.ts.map +1 -0
- package/consume.js +60 -0
- package/consume.js.map +1 -0
- package/datagram.d.ts +23 -0
- package/datagram.d.ts.map +1 -0
- package/datagram.js +3 -0
- package/datagram.js.map +1 -0
- package/error.d.ts +76 -0
- package/error.d.ts.map +1 -0
- package/error.js +107 -0
- package/error.js.map +1 -0
- package/group.d.ts +143 -38
- package/group.d.ts.map +1 -1
- package/group.js +270 -68
- package/group.js.map +1 -1
- package/ietf/adapter.d.ts +2 -2
- package/ietf/adapter.d.ts.map +1 -1
- package/ietf/adapter.js +20 -10
- package/ietf/adapter.js.map +1 -1
- package/ietf/aliases.d.ts +73 -5
- package/ietf/aliases.d.ts.map +1 -1
- package/ietf/aliases.js +121 -14
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +141 -0
- package/ietf/cluster.d.ts.map +1 -0
- package/ietf/cluster.js +204 -0
- package/ietf/cluster.js.map +1 -0
- package/ietf/connection.d.ts +39 -6
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +73 -12
- package/ietf/connection.js.map +1 -1
- package/ietf/fetch.d.ts +17 -0
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +21 -0
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +87 -0
- package/ietf/filter.d.ts.map +1 -0
- package/ietf/filter.js +292 -0
- package/ietf/filter.js.map +1 -0
- package/ietf/index.d.ts +2 -0
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +3 -0
- package/ietf/index.js.map +1 -1
- package/ietf/namespace.d.ts +6 -0
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +27 -2
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +54 -6
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +178 -25
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +35 -10
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +236 -45
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +5 -0
- package/ietf/priority.d.ts.map +1 -0
- package/ietf/priority.js +10 -0
- package/ietf/priority.js.map +1 -0
- package/ietf/properties.d.ts +13 -2
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +65 -8
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +13 -3
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +16 -2
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +25 -6
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.d.ts +40 -7
- package/ietf/publisher.d.ts.map +1 -1
- package/ietf/publisher.js +751 -134
- package/ietf/publisher.js.map +1 -1
- package/ietf/request.js +1 -1
- package/ietf/request.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/subscribe.d.ts +41 -2
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +103 -22
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +21 -7
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +31 -14
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.d.ts +20 -7
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +512 -142
- package/ietf/subscriber.js.map +1 -1
- package/ietf/version.d.ts +7 -1
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +7 -0
- package/ietf/version.js.map +1 -1
- package/index.d.ts +10 -5
- package/index.d.ts.map +1 -1
- package/index.js +10 -5
- package/index.js.map +1 -1
- package/internal.d.ts +29 -0
- package/internal.d.ts.map +1 -0
- package/internal.js +8 -0
- package/internal.js.map +1 -0
- package/lite/announce.d.ts +62 -15
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +230 -94
- package/lite/announce.js.map +1 -1
- package/lite/connection.d.ts +69 -20
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +128 -81
- package/lite/connection.js.map +1 -1
- package/lite/datagram.d.ts +23 -0
- package/lite/datagram.d.ts.map +1 -0
- package/lite/datagram.js +57 -0
- package/lite/datagram.js.map +1 -0
- package/lite/datagram_stream.d.ts +8 -0
- package/lite/datagram_stream.d.ts.map +1 -0
- package/lite/datagram_stream.js +44 -0
- package/lite/datagram_stream.js.map +1 -0
- package/lite/fetch.d.ts.map +1 -1
- package/lite/fetch.js +2 -2
- package/lite/fetch.js.map +1 -1
- package/lite/index.d.ts +3 -0
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +3 -0
- package/lite/index.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/probe.d.ts +18 -2
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +24 -22
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +14 -7
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +406 -84
- package/lite/publisher.js.map +1 -1
- package/lite/setup.d.ts +83 -6
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +203 -31
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +12 -3
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +7 -4
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +37 -23
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +70 -55
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +29 -23
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +689 -112
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +25 -13
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +60 -35
- package/lite/track.js.map +1 -1
- package/lite/version.d.ts +39 -4
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +139 -17
- package/lite/version.js.map +1 -1
- package/mock.d.ts +53 -3
- package/mock.d.ts.map +1 -1
- package/mock.js +110 -21
- package/mock.js.map +1 -1
- package/{lite/origin.d.ts → origin.d.ts} +25 -1
- package/origin.d.ts.map +1 -0
- package/{lite/origin.js → origin.js} +25 -1
- package/origin.js.map +1 -0
- package/package.json +6 -4
- package/path.d.ts +67 -0
- package/path.d.ts.map +1 -1
- package/path.js +128 -0
- package/path.js.map +1 -1
- package/stream.d.ts +94 -4
- package/stream.d.ts.map +1 -1
- package/stream.js +128 -17
- package/stream.js.map +1 -1
- package/time.d.ts +109 -86
- package/time.d.ts.map +1 -1
- package/time.js +80 -30
- package/time.js.map +1 -1
- package/track.d.ts +298 -47
- package/track.d.ts.map +1 -1
- package/track.js +721 -109
- package/track.js.map +1 -1
- package/util/timeout.d.ts +5 -0
- package/util/timeout.d.ts.map +1 -0
- package/util/timeout.js +18 -0
- package/util/timeout.js.map +1 -0
- package/util/utf8.d.ts +3 -0
- package/util/utf8.d.ts.map +1 -0
- package/util/utf8.js +7 -0
- package/util/utf8.js.map +1 -0
- package/varint.d.ts +14 -3
- package/varint.d.ts.map +1 -1
- package/varint.js +23 -12
- package/varint.js.map +1 -1
- package/zod.d.ts +5 -5
- package/zod.d.ts.map +1 -1
- package/zod.js.map +1 -1
- package/bandwidth.d.ts +0 -11
- package/bandwidth.d.ts.map +0 -1
- package/bandwidth.js +0 -7
- package/bandwidth.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/reload.test.d.ts +0 -2
- package/connection/reload.test.d.ts.map +0 -1
- package/connection/reload.test.js +0 -39
- package/connection/reload.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 -66
- 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 -873
- package/ietf/ietf.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 -90
- package/integration.test.js.map +0 -1
- package/lite/origin.d.ts.map +0 -1
- package/lite/origin.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 -30
- 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 -53
- 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 -169
- 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 -210
- package/stream.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 -56
- package/track.test.js.map +0 -1
- package/util/error.d.ts +0 -3
- package/util/error.d.ts.map +0 -1
- package/util/error.js +0 -9
- package/util/error.js.map +0 -1
- package/util/index.d.ts +0 -2
- package/util/index.d.ts.map +0 -1
- package/util/index.js +0 -3
- package/util/index.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/time.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/* @ts-self-types="./time.d.ts" */
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Branded time types (nanoseconds, microseconds, milliseconds, seconds) with conversions,
|
|
4
|
+
* plus {@link Timescale} and {@link Timestamp} for presentation timing.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
* assertion: no conversion happens, so reach for `fromMicro`/`fromMilli`/`fromSecond`
|
|
7
|
-
* when the source has a unit.
|
|
6
|
+
* @module
|
|
8
7
|
*/
|
|
9
|
-
|
|
8
|
+
/** Constructors, conversions, and arithmetic for {@link Nano} values. */
|
|
9
|
+
// Calling `Nano(x)` brands a raw number as nanoseconds. The unit is the caller's assertion: no
|
|
10
|
+
// conversion happens, so reach for `fromMicro`/`fromMilli`/`fromSecond` when the source has a unit.
|
|
11
|
+
export const Nano = Object.assign((value) => value, {
|
|
10
12
|
zero: 0,
|
|
11
13
|
fromMicro: (us) => (us * 1_000),
|
|
12
14
|
fromMilli: (ms) => (ms * 1_000_000),
|
|
@@ -21,15 +23,11 @@ export const Nano = {
|
|
|
21
23
|
div: (a, b) => (a / b),
|
|
22
24
|
max: (a, b) => Math.max(a, b),
|
|
23
25
|
min: (a, b) => Math.min(a, b),
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert
|
|
30
|
-
* from another unit.
|
|
31
|
-
*/
|
|
32
|
-
export const Micro = {
|
|
26
|
+
});
|
|
27
|
+
/** Constructors, conversions, and arithmetic for {@link Micro} values. */
|
|
28
|
+
// Calling `Micro(x)` brands a raw number as microseconds. See the `Nano` note: this asserts the unit
|
|
29
|
+
// rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert from another unit.
|
|
30
|
+
export const Micro = Object.assign((value) => value, {
|
|
33
31
|
zero: 0,
|
|
34
32
|
fromNano: (ns) => (ns / 1_000),
|
|
35
33
|
fromMilli: (ms) => (ms * 1_000),
|
|
@@ -44,15 +42,11 @@ export const Micro = {
|
|
|
44
42
|
div: (a, b) => (a / b),
|
|
45
43
|
max: (a, b) => Math.max(a, b),
|
|
46
44
|
min: (a, b) => Math.min(a, b),
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert
|
|
53
|
-
* from another unit.
|
|
54
|
-
*/
|
|
55
|
-
export const Milli = {
|
|
45
|
+
});
|
|
46
|
+
/** Constructors, conversions, and arithmetic for {@link Milli} values. */
|
|
47
|
+
// Calling `Milli(x)` brands a raw number as milliseconds. See the `Nano` note: this asserts the unit
|
|
48
|
+
// rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert from another unit.
|
|
49
|
+
export const Milli = Object.assign((value) => value, {
|
|
56
50
|
zero: 0,
|
|
57
51
|
fromNano: (ns) => (ns / 1_000_000),
|
|
58
52
|
fromMicro: (us) => (us / 1_000),
|
|
@@ -67,15 +61,71 @@ export const Milli = {
|
|
|
67
61
|
div: (a, b) => (a / b),
|
|
68
62
|
max: (a, b) => Math.max(a, b),
|
|
69
63
|
min: (a, b) => Math.min(a, b),
|
|
70
|
-
};
|
|
64
|
+
});
|
|
65
|
+
/** Named timescales and a checked constructor (rejects non-positive / non-integer values). */
|
|
66
|
+
export const Timescale = Object.assign((unitsPerSecond) => {
|
|
67
|
+
if (!Number.isInteger(unitsPerSecond) || unitsPerSecond <= 0) {
|
|
68
|
+
throw new Error(`invalid timescale: ${unitsPerSecond}`);
|
|
69
|
+
}
|
|
70
|
+
return unitsPerSecond;
|
|
71
|
+
}, {
|
|
72
|
+
/** One unit per second. */
|
|
73
|
+
SECOND: 1,
|
|
74
|
+
/** 1,000 units per second. */
|
|
75
|
+
MILLI: 1_000,
|
|
76
|
+
/** 1,000,000 units per second. */
|
|
77
|
+
MICRO: 1_000_000,
|
|
78
|
+
/** 1,000,000,000 units per second. */
|
|
79
|
+
NANO: 1_000_000_000,
|
|
80
|
+
});
|
|
71
81
|
/**
|
|
72
|
-
*
|
|
82
|
+
* A presentation timestamp: a raw value in a given {@link Timescale}.
|
|
73
83
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* from another unit.
|
|
84
|
+
* Mirrors the Rust `Timestamp`. Unlike the bare `Milli`/`Micro` aliases it carries its
|
|
85
|
+
* own scale, so a track can pick its units and conversions can't silently mix them up.
|
|
77
86
|
*/
|
|
78
|
-
export
|
|
87
|
+
export class Timestamp {
|
|
88
|
+
/** The raw value, in `scale` units. */
|
|
89
|
+
value;
|
|
90
|
+
/** Units per second the {@link value} is measured in. */
|
|
91
|
+
scale;
|
|
92
|
+
/** Build a timestamp of `value` units at `scale`. */
|
|
93
|
+
constructor(value, scale) {
|
|
94
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
95
|
+
throw new Error(`invalid timestamp: ${value}`);
|
|
96
|
+
}
|
|
97
|
+
this.value = value;
|
|
98
|
+
this.scale = scale;
|
|
99
|
+
}
|
|
100
|
+
/** Monotonic now (`performance.now()`, milliseconds since page load), not wall-clock time. */
|
|
101
|
+
static now() {
|
|
102
|
+
return new Timestamp(performance.now(), Timescale.MILLI);
|
|
103
|
+
}
|
|
104
|
+
/** A timestamp of `ms` milliseconds. */
|
|
105
|
+
static fromMillis(ms) {
|
|
106
|
+
return new Timestamp(ms, Timescale.MILLI);
|
|
107
|
+
}
|
|
108
|
+
/** A timestamp of `us` microseconds. */
|
|
109
|
+
static fromMicros(us) {
|
|
110
|
+
return new Timestamp(us, Timescale.MICRO);
|
|
111
|
+
}
|
|
112
|
+
/** This timestamp's value re-expressed at `scale` (a raw number, not a new Timestamp). */
|
|
113
|
+
as(scale) {
|
|
114
|
+
return scale === this.scale ? this.value : (this.value * scale) / this.scale;
|
|
115
|
+
}
|
|
116
|
+
/** The value in milliseconds. */
|
|
117
|
+
asMillis() {
|
|
118
|
+
return this.as(Timescale.MILLI);
|
|
119
|
+
}
|
|
120
|
+
/** The value in microseconds. */
|
|
121
|
+
asMicros() {
|
|
122
|
+
return this.as(Timescale.MICRO);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Constructors, conversions, and arithmetic for {@link Second} values. */
|
|
126
|
+
// Calling `Second(x)` brands a raw number as seconds. See the `Nano` note: this asserts the unit
|
|
127
|
+
// rather than converting, so use `fromNano`/`fromMicro`/`fromMilli` to convert from another unit.
|
|
128
|
+
export const Second = Object.assign((value) => value, {
|
|
79
129
|
zero: 0,
|
|
80
130
|
fromNano: (ns) => (ns / 1_000_000_000),
|
|
81
131
|
fromMicro: (us) => (us / 1_000_000),
|
|
@@ -90,5 +140,5 @@ export const Second = {
|
|
|
90
140
|
div: (a, b) => (a / b),
|
|
91
141
|
max: (a, b) => Math.max(a, b),
|
|
92
142
|
min: (a, b) => Math.min(a, b),
|
|
93
|
-
};
|
|
143
|
+
});
|
|
94
144
|
//# sourceMappingURL=time.js.map
|
package/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IACnB,IAAI,EAAE,CAAS;IACf,SAAS,EAAE,CAAC,EAAS,EAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAS;IACpD,SAAS,EAAE,CAAC,EAAS,EAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,CAAS;IACxD,UAAU,EAAE,CAAC,CAAS,EAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,aAAa,CAAS;IAC5D,OAAO,EAAE,CAAC,EAAQ,EAAS,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAU;IACnD,OAAO,EAAE,CAAC,EAAQ,EAAS,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,CAAU;IACvD,QAAQ,EAAE,CAAC,EAAQ,EAAU,EAAE,CAAC,CAAC,EAAE,GAAG,aAAa,CAAW;IAC9D,GAAG,EAAE,GAAS,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAS;IACxD,GAAG,EAAE,CAAC,CAAO,EAAE,CAAO,EAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAS;IAChD,GAAG,EAAE,CAAC,CAAO,EAAE,CAAO,EAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAS;IAChD,GAAG,EA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,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAW;IAC/D,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAW;CACtD,CAAC","sourcesContent":["/** A duration in nanoseconds, branded so it can't be mixed with other units. */\nexport type Nano = number & { readonly _brand: \"nano\" };\n\n/**\n * Constructors, conversions, and arithmetic for {@link Nano} values.\n *\n * Calling `Nano(x)` brands a raw number as nanoseconds. The unit is the caller's\n * assertion: no conversion happens, so reach for `fromMicro`/`fromMilli`/`fromSecond`\n * when the source has a unit.\n */\nexport const Nano = {\n\tzero: 0 as Nano,\n\tfromMicro: (us: Micro): Nano => (us * 1_000) as Nano,\n\tfromMilli: (ms: Milli): Nano => (ms * 1_000_000) as Nano,\n\tfromSecond: (s: Second): Nano => (s * 1_000_000_000) as Nano,\n\ttoMicro: (ns: Nano): Micro => (ns / 1_000) as Micro,\n\ttoMilli: (ns: Nano): Milli => (ns / 1_000_000) as Milli,\n\ttoSecond: (ns: Nano): Second => (ns / 1_000_000_000) as Second,\n\tnow: (): Nano => (performance.now() * 1_000_000) as Nano,\n\tadd: (a: Nano, b: Nano): Nano => (a + b) as Nano,\n\tsub: (a: Nano, b: Nano): Nano => (a - b) as Nano,\n\tmul: (a: Nano, b: number): Nano => (a * b) as Nano,\n\tdiv: (a: Nano, b: number): Nano => (a / b) as Nano,\n\tmax: (a: Nano, b: Nano): Nano => Math.max(a, b) as Nano,\n\tmin: (a: Nano, b: Nano): Nano => Math.min(a, b) as Nano,\n} as const;\n\n/** A duration in microseconds, branded so it can't be mixed with other units. */\nexport type Micro = number & { readonly _brand: \"micro\" };\n\n/**\n * Constructors, conversions, and arithmetic for {@link Micro} values.\n *\n * Calling `Micro(x)` brands a raw number as microseconds. This asserts the unit\n * rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert\n * from another unit.\n */\nexport const Micro = {\n\tzero: 0 as Micro,\n\tfromNano: (ns: Nano): Micro => (ns / 1_000) as Micro,\n\tfromMilli: (ms: Milli): Micro => (ms * 1_000) as Micro,\n\tfromSecond: (s: Second): Micro => (s * 1_000_000) as Micro,\n\ttoNano: (us: Micro): Nano => (us * 1_000) as Nano,\n\ttoMilli: (us: Micro): Milli => (us / 1_000) as Milli,\n\ttoSecond: (us: Micro): Second => (us / 1_000_000) as Second,\n\tnow: (): Micro => (performance.now() * 1_000) as Micro,\n\tadd: (a: Micro, b: Micro): Micro => (a + b) as Micro,\n\tsub: (a: Micro, b: Micro): Micro => (a - b) as Micro,\n\tmul: (a: Micro, b: number): Micro => (a * b) as Micro,\n\tdiv: (a: Micro, b: number): Micro => (a / b) as Micro,\n\tmax: (a: Micro, b: Micro): Micro => Math.max(a, b) as Micro,\n\tmin: (a: Micro, b: Micro): Micro => Math.min(a, b) as Micro,\n} as const;\n\n/** A duration in milliseconds, branded so it can't be mixed with other units. */\nexport type Milli = number & { readonly _brand: \"milli\" };\n\n/**\n * Constructors, conversions, and arithmetic for {@link Milli} values.\n *\n * Calling `Milli(x)` brands a raw number as milliseconds. This asserts the unit\n * rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert\n * from another unit.\n */\nexport const Milli = {\n\tzero: 0 as Milli,\n\tfromNano: (ns: Nano): Milli => (ns / 1_000_000) as Milli,\n\tfromMicro: (us: Micro): Milli => (us / 1_000) as Milli,\n\tfromSecond: (s: Second): Milli => (s * 1_000) as Milli,\n\ttoNano: (ms: Milli): Nano => (ms * 1_000_000) as Nano,\n\ttoMicro: (ms: Milli): Micro => (ms * 1_000) as Micro,\n\ttoSecond: (ms: Milli): Second => (ms / 1_000) as Second,\n\tnow: (): Milli => performance.now() as Milli,\n\tadd: (a: Milli, b: Milli): Milli => (a + b) as Milli,\n\tsub: (a: Milli, b: Milli): Milli => (a - b) as Milli,\n\tmul: (a: Milli, b: number): Milli => (a * b) as Milli,\n\tdiv: (a: Milli, b: number): Milli => (a / b) as Milli,\n\tmax: (a: Milli, b: Milli): Milli => Math.max(a, b) as Milli,\n\tmin: (a: Milli, b: Milli): Milli => Math.min(a, b) as Milli,\n} as const;\n\n/** A duration in seconds, branded so it can't be mixed with other units. */\nexport type Second = number & { readonly _brand: \"second\" };\n\n/**\n * Constructors, conversions, and arithmetic for {@link Second} values.\n *\n * Calling `Second(x)` brands a raw number as seconds. This asserts the unit\n * rather than converting, so use `fromNano`/`fromMicro`/`fromMilli` to convert\n * from another unit.\n */\nexport const Second = {\n\tzero: 0 as Second,\n\tfromNano: (ns: Nano): Second => (ns / 1_000_000_000) as Second,\n\tfromMicro: (us: Micro): Second => (us / 1_000_000) as Second,\n\tfromMilli: (ms: Milli): Second => (ms / 1_000) as Second,\n\ttoNano: (s: Second): Nano => (s * 1_000_000_000) as Nano,\n\ttoMicro: (s: Second): Micro => (s * 1_000_000) as Micro,\n\ttoMilli: (s: Second): Milli => (s * 1_000) as Milli,\n\tnow: (): Second => (performance.now() / 1_000) as Second,\n\tadd: (a: Second, b: Second): Second => (a + b) as Second,\n\tsub: (a: Second, b: Second): Second => (a - b) as Second,\n\tmul: (a: Second, b: number): Second => (a * b) as Second,\n\tdiv: (a: Second, b: number): Second => (a / b) as Second,\n\tmax: (a: Second, b: Second): Second => Math.max(a, b) as Second,\n\tmin: (a: Second, b: Second): Second => Math.min(a, b) as Second,\n} as const;\n"]}
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,yEAAyE;AACzE,+FAA+F;AAC/F,oGAAoG;AACpG,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM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O,EAAE,CAAC,CAAS,EAAS,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAU;IACvD,OAAO,EAAE,CAAC,CAAS,EAAS,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAU;IACnD,GAAG,EAAE,GAAW,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAW;IAC/D,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAW;CAC/D,CAAC,CAAC","sourcesContent":["/**\n * Branded time types (nanoseconds, microseconds, milliseconds, seconds) with conversions,\n * plus {@link Timescale} and {@link Timestamp} for presentation timing.\n *\n * @module\n */\n\n/** A duration in nanoseconds, branded so it can't be mixed with other units. */\nexport type Nano = number & { readonly _brand: \"nano\" };\n\n/** Constructors, conversions, and arithmetic for {@link Nano} values. */\n// Calling `Nano(x)` brands a raw number as nanoseconds. The unit is the caller's assertion: no\n// conversion happens, so reach for `fromMicro`/`fromMilli`/`fromSecond` when the source has a unit.\nexport const Nano = Object.assign((value: number): Nano => value as Nano, {\n\tzero: 0 as Nano,\n\tfromMicro: (us: Micro): Nano => (us * 1_000) as Nano,\n\tfromMilli: (ms: Milli): Nano => (ms * 1_000_000) as Nano,\n\tfromSecond: (s: Second): Nano => (s * 1_000_000_000) as Nano,\n\ttoMicro: (ns: Nano): Micro => (ns / 1_000) as Micro,\n\ttoMilli: (ns: Nano): Milli => (ns / 1_000_000) as Milli,\n\ttoSecond: (ns: Nano): Second => (ns / 1_000_000_000) as Second,\n\tnow: (): Nano => (performance.now() * 1_000_000) as Nano,\n\tadd: (a: Nano, b: Nano): Nano => (a + b) as Nano,\n\tsub: (a: Nano, b: Nano): Nano => (a - b) as Nano,\n\tmul: (a: Nano, b: number): Nano => (a * b) as Nano,\n\tdiv: (a: Nano, b: number): Nano => (a / b) as Nano,\n\tmax: (a: Nano, b: Nano): Nano => Math.max(a, b) as Nano,\n\tmin: (a: Nano, b: Nano): Nano => Math.min(a, b) as Nano,\n});\n\n/** A duration in microseconds, branded so it can't be mixed with other units. */\nexport type Micro = number & { readonly _brand: \"micro\" };\n\n/** Constructors, conversions, and arithmetic for {@link Micro} values. */\n// Calling `Micro(x)` brands a raw number as microseconds. See the `Nano` note: this asserts the unit\n// rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert from another unit.\nexport const Micro = Object.assign((value: number): Micro => value as Micro, {\n\tzero: 0 as Micro,\n\tfromNano: (ns: Nano): Micro => (ns / 1_000) as Micro,\n\tfromMilli: (ms: Milli): Micro => (ms * 1_000) as Micro,\n\tfromSecond: (s: Second): Micro => (s * 1_000_000) as Micro,\n\ttoNano: (us: Micro): Nano => (us * 1_000) as Nano,\n\ttoMilli: (us: Micro): Milli => (us / 1_000) as Milli,\n\ttoSecond: (us: Micro): Second => (us / 1_000_000) as Second,\n\tnow: (): Micro => (performance.now() * 1_000) as Micro,\n\tadd: (a: Micro, b: Micro): Micro => (a + b) as Micro,\n\tsub: (a: Micro, b: Micro): Micro => (a - b) as Micro,\n\tmul: (a: Micro, b: number): Micro => (a * b) as Micro,\n\tdiv: (a: Micro, b: number): Micro => (a / b) as Micro,\n\tmax: (a: Micro, b: Micro): Micro => Math.max(a, b) as Micro,\n\tmin: (a: Micro, b: Micro): Micro => Math.min(a, b) as Micro,\n});\n\n/** A duration in milliseconds, branded so it can't be mixed with other units. */\nexport type Milli = number & { readonly _brand: \"milli\" };\n\n/** Constructors, conversions, and arithmetic for {@link Milli} values. */\n// Calling `Milli(x)` brands a raw number as milliseconds. See the `Nano` note: this asserts the unit\n// rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert from another unit.\nexport const Milli = Object.assign((value: number): Milli => value as Milli, {\n\tzero: 0 as Milli,\n\tfromNano: (ns: Nano): Milli => (ns / 1_000_000) as Milli,\n\tfromMicro: (us: Micro): Milli => (us / 1_000) as Milli,\n\tfromSecond: (s: Second): Milli => (s * 1_000) as Milli,\n\ttoNano: (ms: Milli): Nano => (ms * 1_000_000) as Nano,\n\ttoMicro: (ms: Milli): Micro => (ms * 1_000) as Micro,\n\ttoSecond: (ms: Milli): Second => (ms / 1_000) as Second,\n\tnow: (): Milli => performance.now() as Milli,\n\tadd: (a: Milli, b: Milli): Milli => (a + b) as Milli,\n\tsub: (a: Milli, b: Milli): Milli => (a - b) as Milli,\n\tmul: (a: Milli, b: number): Milli => (a * b) as Milli,\n\tdiv: (a: Milli, b: number): Milli => (a / b) as Milli,\n\tmax: (a: Milli, b: Milli): Milli => Math.max(a, b) as Milli,\n\tmin: (a: Milli, b: Milli): Milli => Math.min(a, b) as Milli,\n});\n\n/** Units per second for a {@link Timestamp}'s value, e.g. `1000` for milliseconds. */\nexport type Timescale = number & { readonly _brand: \"timescale\" };\n\n/** Named timescales and a checked constructor (rejects non-positive / non-integer values). */\nexport const Timescale = Object.assign(\n\t(unitsPerSecond: number): Timescale => {\n\t\tif (!Number.isInteger(unitsPerSecond) || unitsPerSecond <= 0) {\n\t\t\tthrow new Error(`invalid timescale: ${unitsPerSecond}`);\n\t\t}\n\t\treturn unitsPerSecond as Timescale;\n\t},\n\t{\n\t\t/** One unit per second. */\n\t\tSECOND: 1 as Timescale,\n\t\t/** 1,000 units per second. */\n\t\tMILLI: 1_000 as Timescale,\n\t\t/** 1,000,000 units per second. */\n\t\tMICRO: 1_000_000 as Timescale,\n\t\t/** 1,000,000,000 units per second. */\n\t\tNANO: 1_000_000_000 as Timescale,\n\t},\n);\n\n/**\n * A presentation timestamp: a raw value in a given {@link Timescale}.\n *\n * Mirrors the Rust `Timestamp`. Unlike the bare `Milli`/`Micro` aliases it carries its\n * own scale, so a track can pick its units and conversions can't silently mix them up.\n */\nexport class Timestamp {\n\t/** The raw value, in `scale` units. */\n\treadonly value: number;\n\t/** Units per second the {@link value} is measured in. */\n\treadonly scale: Timescale;\n\n\t/** Build a timestamp of `value` units at `scale`. */\n\tconstructor(value: number, scale: Timescale) {\n\t\tif (!Number.isFinite(value) || value < 0) {\n\t\t\tthrow new Error(`invalid timestamp: ${value}`);\n\t\t}\n\t\tthis.value = value;\n\t\tthis.scale = scale;\n\t}\n\n\t/** Monotonic now (`performance.now()`, milliseconds since page load), not wall-clock time. */\n\tstatic now(): Timestamp {\n\t\treturn new Timestamp(performance.now(), Timescale.MILLI);\n\t}\n\n\t/** A timestamp of `ms` milliseconds. */\n\tstatic fromMillis(ms: number): Timestamp {\n\t\treturn new Timestamp(ms, Timescale.MILLI);\n\t}\n\n\t/** A timestamp of `us` microseconds. */\n\tstatic fromMicros(us: number): Timestamp {\n\t\treturn new Timestamp(us, Timescale.MICRO);\n\t}\n\n\t/** This timestamp's value re-expressed at `scale` (a raw number, not a new Timestamp). */\n\tas(scale: Timescale): number {\n\t\treturn scale === this.scale ? this.value : (this.value * scale) / this.scale;\n\t}\n\n\t/** The value in milliseconds. */\n\tasMillis(): number {\n\t\treturn this.as(Timescale.MILLI);\n\t}\n\n\t/** The value in microseconds. */\n\tasMicros(): number {\n\t\treturn this.as(Timescale.MICRO);\n\t}\n}\n\n/** A duration in seconds, branded so it can't be mixed with other units. */\nexport type Second = number & { readonly _brand: \"second\" };\n\n/** Constructors, conversions, and arithmetic for {@link Second} values. */\n// Calling `Second(x)` brands a raw number as seconds. See the `Nano` note: this asserts the unit\n// rather than converting, so use `fromNano`/`fromMicro`/`fromMilli` to convert from another unit.\nexport const Second = Object.assign((value: number): Second => value as Second, {\n\tzero: 0 as Second,\n\tfromNano: (ns: Nano): Second => (ns / 1_000_000_000) as Second,\n\tfromMicro: (us: Micro): Second => (us / 1_000_000) as Second,\n\tfromMilli: (ms: Milli): Second => (ms / 1_000) as Second,\n\ttoNano: (s: Second): Nano => (s * 1_000_000_000) as Nano,\n\ttoMicro: (s: Second): Micro => (s * 1_000_000) as Micro,\n\ttoMilli: (s: Second): Milli => (s * 1_000) as Milli,\n\tnow: (): Second => (performance.now() / 1_000) as Second,\n\tadd: (a: Second, b: Second): Second => (a + b) as Second,\n\tsub: (a: Second, b: Second): Second => (a - b) as Second,\n\tmul: (a: Second, b: number): Second => (a * b) as Second,\n\tdiv: (a: Second, b: number): Second => (a / b) as Second,\n\tmax: (a: Second, b: Second): Second => Math.max(a, b) as Second,\n\tmin: (a: Second, b: Second): Second => Math.min(a, b) as Second,\n});\n"]}
|
package/track.d.ts
CHANGED
|
@@ -1,71 +1,326 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Track role handles: a live stream of groups (and best-effort datagrams) within a broadcast.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type GetPromise, type Getter } from "@norskvideo/moq-signals";
|
|
7
|
+
import type { Datagram } from "./datagram";
|
|
8
|
+
import { type Frame, type Consumer as GroupConsumer, Producer as GroupProducer } from "./group";
|
|
9
|
+
import { Timescale, type Timestamp } from "./time";
|
|
10
|
+
export type { Datagram } from "./datagram";
|
|
11
|
+
/** Default {@link Info.latencyMax} window (milliseconds) when the publisher does not set one. */
|
|
12
|
+
export declare const DEFAULT_LATENCY_MAX_MS = 5000;
|
|
13
|
+
/** A position within a track: a group's sequence and a frame's index inside it. */
|
|
14
|
+
export interface Location {
|
|
15
|
+
/** The group's sequence number within the track. */
|
|
16
|
+
group: number;
|
|
17
|
+
/** The frame's index within that group. */
|
|
18
|
+
frame: number;
|
|
8
19
|
}
|
|
9
|
-
/**
|
|
10
|
-
|
|
20
|
+
/**
|
|
21
|
+
* A track's immutable publisher properties, fixed for the lifetime of the track.
|
|
22
|
+
*
|
|
23
|
+
* A producer declares these once (via {@link Request.accept} or
|
|
24
|
+
* {@link Producer.accept}); a consumer awaits them via {@link Subscriber.info}
|
|
25
|
+
* (resolved from the wire TRACK_INFO on lite-05+). They map 1:1 onto TRACK_INFO.
|
|
26
|
+
*/
|
|
27
|
+
export interface Info {
|
|
28
|
+
/**
|
|
29
|
+
* Units per second for this track's frame timestamps (reported in TRACK_INFO on
|
|
30
|
+
* Lite05+). Defaults to milliseconds; set it finer (e.g. {@link Timescale.MICRO})
|
|
31
|
+
* for media that needs sub-millisecond timing.
|
|
32
|
+
*/
|
|
33
|
+
timescale: Timescale;
|
|
34
|
+
/**
|
|
35
|
+
* Publisher Max Latency: the maximum age (milliseconds) of a non-latest group before
|
|
36
|
+
* the publisher evicts it. Reported in TRACK_INFO (Lite05+) so relays re-serve with the
|
|
37
|
+
* same bound. The publisher-side half of the budget a subscriber sets for itself.
|
|
38
|
+
*/
|
|
39
|
+
latencyMax: number;
|
|
40
|
+
/** Tie-break priority between subscriptions of equal subscriber priority. */
|
|
41
|
+
priority: number;
|
|
42
|
+
/**
|
|
43
|
+
* Whether groups are prioritized in sequence order. Groups may always arrive
|
|
44
|
+
* out-of-order (or not at all) over the network. Defaults to `false` (newest-first).
|
|
45
|
+
*/
|
|
46
|
+
ordered: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Fill in any unset {@link Info} fields with their defaults. */
|
|
49
|
+
export declare function infoDefaults(info?: Partial<Info>): Info;
|
|
50
|
+
/**
|
|
51
|
+
* Per-subscription options, requested when a subscription opens and adjustable later via
|
|
52
|
+
* {@link Subscriber.update}. Mirrors the Rust `Subscription`.
|
|
53
|
+
*/
|
|
54
|
+
export interface Subscription {
|
|
55
|
+
/** Delivery priority relative to this session's other subscriptions. Defaults to `0`. */
|
|
56
|
+
priority?: number;
|
|
57
|
+
/** Whether groups are prioritized in sequence order. Defaults to `false` (newest-first). */
|
|
58
|
+
ordered?: boolean;
|
|
59
|
+
/** Maximum age (milliseconds) of a non-latest group before it is skipped. Defaults to `0`. */
|
|
60
|
+
latencyMax?: number;
|
|
61
|
+
/** First group the publisher should deliver, or omit to start at the latest group. */
|
|
62
|
+
startGroup?: number;
|
|
63
|
+
/** Last group the publisher should deliver (inclusive), or omit for no end. */
|
|
64
|
+
endGroup?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A request for a track the peer wants, yielded by `Broadcast.Producer.requested`.
|
|
68
|
+
*
|
|
69
|
+
* Created internally by the broadcast when a subscription (or info lookup) needs a track
|
|
70
|
+
* served; answer it with {@link accept} or {@link reject}.
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export declare class Request {
|
|
11
75
|
#private;
|
|
12
|
-
/**
|
|
76
|
+
/** The requested track name. */
|
|
77
|
+
readonly name: string;
|
|
78
|
+
private constructor();
|
|
79
|
+
/** The aggregate subscription requested for this track. */
|
|
80
|
+
get subscription(): Readonly<Subscription>;
|
|
81
|
+
/** The subscriber's priority for this track. */
|
|
82
|
+
get priority(): number;
|
|
83
|
+
/** Accept the request, committing the track's immutable {@link Info}. */
|
|
84
|
+
accept(info?: Partial<Info>): Producer;
|
|
85
|
+
/** Reject the request, closing the track optionally with an error. */
|
|
86
|
+
reject(err?: Error): void;
|
|
87
|
+
}
|
|
88
|
+
/** Options for {@link Consumer.fetchGroup}. */
|
|
89
|
+
export interface FetchGroupOptions {
|
|
90
|
+
/** Delivery priority for the fetch stream. Defaults to `0`. */
|
|
91
|
+
priority?: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The per-track operations a lazy {@link Consumer} delegates to the broadcast it came from.
|
|
95
|
+
*
|
|
96
|
+
* Implemented by `broadcast.Producer` / `broadcast.Consumer` (and the wire-layer subclasses
|
|
97
|
+
* that resolve them over the network), so a track handle holds a reference to its broadcast
|
|
98
|
+
* and calls methods on it rather than capturing a bag of callbacks.
|
|
99
|
+
*/
|
|
100
|
+
export interface Broadcast {
|
|
101
|
+
/** Open a live subscription to the named track. */
|
|
102
|
+
subscribe(name: string, options?: Subscription): Subscriber;
|
|
103
|
+
/** Resolve the named track's immutable info. */
|
|
104
|
+
resolveTrackInfo(name: string): Promise<Info>;
|
|
105
|
+
/** Fetch a single group of the named track by sequence. */
|
|
106
|
+
fetchGroup(name: string, sequence: number, options?: FetchGroupOptions): Promise<GroupConsumer>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A lazy handle to a track on a consumed broadcast.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export declare class Consumer {
|
|
114
|
+
#private;
|
|
115
|
+
/** The track name. */
|
|
116
|
+
readonly name: string;
|
|
117
|
+
constructor(name: string, broadcast: Broadcast);
|
|
118
|
+
/** Open a live subscription to the track. */
|
|
119
|
+
subscribe(options?: Subscription): Subscriber;
|
|
120
|
+
/** Fetch the track's immutable publisher properties without subscribing. */
|
|
121
|
+
info(): Promise<Info>;
|
|
122
|
+
/** Fetch a single group by sequence without holding a live subscription. */
|
|
123
|
+
fetchGroup(sequence: number, options?: FetchGroupOptions): Promise<GroupConsumer>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The write side of a track, mirroring the Rust `Producer`.
|
|
127
|
+
*
|
|
128
|
+
* A producer is a fan-out source: every {@link subscribe} (including each wire
|
|
129
|
+
* subscription the publisher serves from it) gets an independent
|
|
130
|
+
* {@link Subscriber} that receives a full copy of the groups, each with its own
|
|
131
|
+
* read cursor. Groups are mirrored into every live subscriber and retained for the
|
|
132
|
+
* track's `latencyMax` window so a late subscriber replays the recent groups.
|
|
133
|
+
*
|
|
134
|
+
* Obtained from {@link Request.accept} (the wire asks the application for a track to
|
|
135
|
+
* serve) or constructed directly for an in-process track.
|
|
136
|
+
*/
|
|
137
|
+
export declare class Producer {
|
|
138
|
+
#private;
|
|
139
|
+
/** The track name. */
|
|
13
140
|
readonly name: string;
|
|
14
|
-
/** Reactive backing state. */
|
|
15
|
-
state: TrackState;
|
|
16
|
-
/** Resolves with the abort error (or undefined) once closed. */
|
|
17
|
-
readonly closed: Promise<Error | undefined>;
|
|
18
141
|
constructor(name: string);
|
|
19
142
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
143
|
+
* Resolve this track's immutable publisher properties, committed at accept time.
|
|
144
|
+
* Rejects if the track is closed before the properties are known.
|
|
145
|
+
*/
|
|
146
|
+
info(): Promise<Info>;
|
|
147
|
+
/**
|
|
148
|
+
* Settles once the track closes: `null` on a clean close, or the abort {@link Error}.
|
|
149
|
+
* Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.
|
|
150
|
+
*/
|
|
151
|
+
get closed(): GetPromise<Error | null>;
|
|
152
|
+
/**
|
|
153
|
+
* The aggregate subscription across live subscribers, or `undefined` when there are none.
|
|
154
|
+
* The wire layer watches this to emit SUBSCRIBE_UPDATE.
|
|
155
|
+
*/
|
|
156
|
+
get subscription(): Getter<Subscription | undefined>;
|
|
157
|
+
/** Commit the immutable publisher properties, resolving {@link info}. Returns `this`. */
|
|
158
|
+
accept(info?: Partial<Info>): this;
|
|
159
|
+
/** An independent {@link Subscriber} receiving a full copy of this track's groups. */
|
|
160
|
+
subscribe(options?: Subscription): Subscriber;
|
|
161
|
+
/**
|
|
162
|
+
* Whether the track currently has any subscribers.
|
|
163
|
+
*
|
|
164
|
+
* Watch it (`effect.get` / `.peek()`) to drive on-demand work: a publisher can start and stop
|
|
165
|
+
* capture with demand, and the consumer wire watches it to tear an idle upstream subscription
|
|
166
|
+
* down instead of downloading to nobody. Pairs with {@link unused}. Mirrors the Rust `Demand`.
|
|
22
167
|
*/
|
|
23
|
-
|
|
168
|
+
get used(): Getter<boolean>;
|
|
169
|
+
/** Resolves once the track has no subscribers (or has closed). Await it to react to demand ending. */
|
|
170
|
+
unused(): Promise<void>;
|
|
171
|
+
/** Append a new group with the next sequence number. */
|
|
172
|
+
appendGroup(): GroupProducer;
|
|
24
173
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
174
|
+
* Insert an existing group into the track.
|
|
175
|
+
*
|
|
176
|
+
* Throws on a sequence that is still cached: a live duplicate would fan out to every
|
|
177
|
+
* subscriber twice. An aborted incarnation is evicted so a fresh group can serve the
|
|
178
|
+
* sequence again. Best effort (mirrors Rust): nothing remembers a sequence whose cache
|
|
179
|
+
* entry is already gone, so a long-evicted sequence is accepted as new.
|
|
27
180
|
*/
|
|
28
|
-
writeGroup(group:
|
|
181
|
+
writeGroup(group: GroupProducer): void;
|
|
29
182
|
/**
|
|
30
|
-
*
|
|
183
|
+
* Append a datagram with the next sequence number, returning the assigned sequence.
|
|
31
184
|
*
|
|
32
|
-
*
|
|
185
|
+
* A datagram is delivered best-effort over a single QUIC datagram, parallel to the track's
|
|
186
|
+
* groups but drawing from the same sequence namespace (interleaving with {@link appendGroup}
|
|
187
|
+
* never reuses a number). The payload must fit the negotiated transport datagram size minus
|
|
188
|
+
* a small header; an oversize payload is dropped at each hop (there is no group fallback), so
|
|
189
|
+
* keep datagram payloads small (e.g. a single audio frame). Datagrams are never delivered
|
|
190
|
+
* over IETF moq-transport or stream-only transports (the WebSocket fallback). A payload over
|
|
191
|
+
* 65535 bytes (the QUIC datagram frame ceiling) throws. An origin publisher uses this; a
|
|
192
|
+
* relay preserving upstream numbering uses {@link writeDatagram}.
|
|
33
193
|
*/
|
|
34
|
-
|
|
194
|
+
appendDatagram(timestamp: Timestamp, payload: Uint8Array): number;
|
|
195
|
+
/**
|
|
196
|
+
* Write a datagram with an explicit sequence number.
|
|
197
|
+
*
|
|
198
|
+
* Preserves the supplied sequence (advancing the shared counter if needed) so a relay can
|
|
199
|
+
* forward a datagram without renumbering it. The size limits of {@link appendDatagram}
|
|
200
|
+
* apply. Most origin publishers want {@link appendDatagram} instead.
|
|
201
|
+
*/
|
|
202
|
+
writeDatagram(datagram: Datagram): void;
|
|
203
|
+
/** Close the track and every subscriber, mirroring the abort to their groups. Idempotent. */
|
|
204
|
+
close(abort?: Error): void;
|
|
205
|
+
/** Append a frame as its own single-frame group. */
|
|
206
|
+
writeFrame(frame: Frame): void;
|
|
35
207
|
/** Appends a string to the track as its own single-frame group. */
|
|
36
208
|
writeString(str: string): void;
|
|
37
209
|
/** Appends a JSON value to the track as its own single-frame group. */
|
|
38
210
|
writeJson(json: unknown): void;
|
|
39
211
|
/** Appends a boolean to the track as its own single-frame group. */
|
|
40
212
|
writeBool(bool: boolean): void;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The read side of a live track subscription, mirroring the Rust `Subscriber`.
|
|
216
|
+
*
|
|
217
|
+
* Obtained from `Broadcast.Consumer.subscribe` / `Track.Consumer.subscribe`, or from
|
|
218
|
+
* {@link Producer.subscribe} for an in-process track. Reads the groups a
|
|
219
|
+
* {@link Producer} on the same underlying state writes.
|
|
220
|
+
*/
|
|
221
|
+
export declare class Subscriber {
|
|
222
|
+
#private;
|
|
223
|
+
/** The track name. */
|
|
224
|
+
readonly name: string;
|
|
225
|
+
private constructor();
|
|
41
226
|
/**
|
|
42
|
-
*
|
|
227
|
+
* Resolve this track's immutable publisher properties.
|
|
43
228
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
229
|
+
* Resolves once the wire layer commits the TRACK_INFO it received (lite-05+) or
|
|
230
|
+
* defaults (older drafts), so awaiting it never yields a placeholder. Rejects if
|
|
231
|
+
* the track is closed before the properties are known (e.g. a rejected subscription).
|
|
47
232
|
*/
|
|
48
|
-
|
|
233
|
+
info(): Promise<Info>;
|
|
234
|
+
/** Settles once the track closes; see {@link Producer.closed}. */
|
|
235
|
+
get closed(): GetPromise<Error | null>;
|
|
236
|
+
/** This subscriber's current options, including defaults and the last {@link update}. */
|
|
237
|
+
get subscription(): Getter<Subscription | undefined>;
|
|
238
|
+
/** Return the latest group sequence observed on this track, if any. */
|
|
239
|
+
latest(): number | undefined;
|
|
49
240
|
/**
|
|
50
|
-
*
|
|
241
|
+
* The newest frame this track has produced, or `undefined` while it has none.
|
|
242
|
+
*
|
|
243
|
+
* Read from the groups buffered for this subscriber, so nothing is consumed. A newest
|
|
244
|
+
* group that has no frames yet falls back to the newest older group that does. It
|
|
245
|
+
* reads as `undefined` once the newest group has been evicted or received: what is
|
|
246
|
+
* left can no longer say where the edge is.
|
|
51
247
|
*/
|
|
52
|
-
|
|
248
|
+
largest(): Location | undefined;
|
|
53
249
|
/**
|
|
54
|
-
*
|
|
250
|
+
* An independent subscriber to the same track, with its own cursor and its own replay of
|
|
251
|
+
* the retained window.
|
|
252
|
+
*
|
|
253
|
+
* Reads here do not consume anything this one would deliver, which is what lets a
|
|
254
|
+
* publisher read the cache alongside the cursor it is serving from. Resolving the track
|
|
255
|
+
* again through the broadcast would not do: a dynamic serve is one request per peer
|
|
256
|
+
* subscription, so that mints a second producer the application has to answer separately.
|
|
257
|
+
*
|
|
258
|
+
* @internal Wire layers only.
|
|
259
|
+
*/
|
|
260
|
+
fork(options?: Subscription): Subscriber;
|
|
261
|
+
/** Start this subscriber's local read cursor at `sequence`, without changing its wire request. */
|
|
262
|
+
startAt(sequence: number): void;
|
|
263
|
+
/**
|
|
264
|
+
* Cap {@link nextGroup} and {@link recvGroup} at `sequence` inclusively, or omit it to
|
|
265
|
+
* remove the cap. Groups above the cap remain buffered and become readable if the cap
|
|
266
|
+
* is raised. This local cursor does not change the subscription's wire request.
|
|
267
|
+
*/
|
|
268
|
+
endAt(sequence?: number): void;
|
|
269
|
+
/** Close the track (optionally with an error), closing any pending groups. Idempotent. */
|
|
270
|
+
close(abort?: Error): void;
|
|
271
|
+
/**
|
|
272
|
+
* Receive every group on this track exactly once, as it becomes available.
|
|
273
|
+
*
|
|
274
|
+
* Groups may arrive out of order or with gaps due to network conditions; unlike
|
|
275
|
+
* {@link nextGroup}, one that arrives after a newer group was already returned is
|
|
276
|
+
* still delivered. When several groups are buffered, the lowest sequence is
|
|
277
|
+
* returned first.
|
|
278
|
+
*
|
|
279
|
+
* Honors the floor set by {@link startAt} and the cap set by {@link endAt}: a group
|
|
280
|
+
* beyond the cap stays buffered (not dropped) and is offered once the cap rises, even
|
|
281
|
+
* after a clean close, without blocking in-range groups that arrive behind it.
|
|
282
|
+
*/
|
|
283
|
+
recvGroup(): Promise<GroupConsumer | undefined>;
|
|
284
|
+
/**
|
|
285
|
+
* Take the next buffered group without blocking, honoring the same cursor bounds as
|
|
286
|
+
* {@link recvGroup}.
|
|
287
|
+
*
|
|
288
|
+
* Returns `undefined` when nothing is deliverable right now, which is not by itself the
|
|
289
|
+
* end of the track: a group may still arrive, or one may be parked beyond the
|
|
290
|
+
* {@link endAt} cap. Use it to drain what the retained window already holds, where
|
|
291
|
+
* waiting for a sequence nothing will republish would park forever.
|
|
292
|
+
*/
|
|
293
|
+
tryRecvGroup(): GroupConsumer | undefined;
|
|
294
|
+
/**
|
|
295
|
+
* Receive the next datagram in arrival order.
|
|
55
296
|
*
|
|
56
|
-
*
|
|
297
|
+
* Datagrams are a separate best-effort channel from groups (see
|
|
298
|
+
* {@link Producer.appendDatagram}); they share only the sequence namespace. A consumer
|
|
299
|
+
* that falls too far behind silently loses the oldest datagrams. Read this alongside
|
|
300
|
+
* {@link recvGroup} (e.g. in a separate loop) to receive both channels concurrently. Returning
|
|
301
|
+
* a datagram advances {@link nextGroup} past that sequence.
|
|
302
|
+
*/
|
|
303
|
+
recvDatagram(): Promise<Datagram | undefined>;
|
|
304
|
+
/**
|
|
305
|
+
* Return the next group with a strictly-greater sequence number than the last returned.
|
|
57
306
|
*
|
|
58
|
-
*
|
|
307
|
+
* Late arrivals (sequence at or below the last returned) are silently skipped.
|
|
308
|
+
* Use {@link recvGroup} to see every group in arrival order instead.
|
|
59
309
|
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
310
|
+
nextGroup(): Promise<GroupConsumer | undefined>;
|
|
311
|
+
/**
|
|
312
|
+
* Reads the next frame across all groups, discarding older groups.
|
|
313
|
+
* Treat the returned frame bytes as read-only; they are shared with other consumers.
|
|
314
|
+
*/
|
|
315
|
+
readFrame(): Promise<Frame | undefined>;
|
|
316
|
+
/**
|
|
317
|
+
* Reads the next frame along with its group and frame sequence numbers.
|
|
318
|
+
* Treat the returned frame bytes as read-only; they are shared with other consumers.
|
|
319
|
+
*/
|
|
320
|
+
readFrameSequence(): Promise<({
|
|
65
321
|
group: number;
|
|
66
322
|
frame: number;
|
|
67
|
-
|
|
68
|
-
} | undefined>;
|
|
323
|
+
} & Frame) | undefined>;
|
|
69
324
|
/** Reads the next frame and decodes it as a UTF-8 string. */
|
|
70
325
|
readString(): Promise<string | undefined>;
|
|
71
326
|
/** Reads the next frame and parses it as JSON. */
|
|
@@ -73,13 +328,9 @@ export declare class Track {
|
|
|
73
328
|
/** Reads the next frame and decodes it as a one-byte boolean, throwing on a malformed frame. */
|
|
74
329
|
readBool(): Promise<boolean | undefined>;
|
|
75
330
|
/**
|
|
76
|
-
* Update
|
|
77
|
-
*
|
|
331
|
+
* Update this subscription's options (e.g. priority), triggering a SUBSCRIBE_UPDATE to the
|
|
332
|
+
* publisher. Mirrors the Rust `Subscriber::update`.
|
|
78
333
|
*/
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Closes the publisher and all associated groups.
|
|
82
|
-
*/
|
|
83
|
-
close(abort?: Error): void;
|
|
334
|
+
update(options: Subscription): void;
|
|
84
335
|
}
|
|
85
336
|
//# sourceMappingURL=track.d.ts.map
|
package/track.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAgB,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,QAAQ,IAAI,aAAa,EAAE,QAAQ,IAAI,aAAa,EAAU,MAAM,YAAY,CAAC;AAE3G,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtD,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,iGAAiG;AACjG,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAqB3C,mFAAmF;AACnF,MAAM,WAAW,QAAQ;IACxB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,IAAI;IACpB;;;;OAIG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,IAAI,GAAE,OAAO,CAAC,IAAI,CAAM,GAAG,IAAI,CAO3D;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4FAA4F;IAC5F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sFAAsF;IACtF,UAAU,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