@moqtap/codec 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -95
- package/dist/chunk-4RIXXEII.js +1275 -0
- package/dist/chunk-4XYGE53S.cjs +698 -0
- package/dist/chunk-4YJANAXU.cjs +1109 -0
- package/dist/chunk-6AEHWULA.cjs +641 -0
- package/dist/chunk-7DUBLRXC.js +680 -0
- package/dist/{chunk-YBZD3DU5.cjs → chunk-7IVGHMKJ.cjs} +44 -42
- package/dist/chunk-BISI45MN.cjs +680 -0
- package/dist/{chunk-NLYTRGXA.cjs → chunk-BPNL5YFQ.cjs} +5 -5
- package/dist/chunk-CXDHOMHG.js +1097 -0
- package/dist/chunk-DUBCL3WF.cjs +749 -0
- package/dist/chunk-DWK5ZQZ4.js +642 -0
- package/dist/chunk-E6E3NQYU.js +680 -0
- package/dist/chunk-EFM5T7OM.js +698 -0
- package/dist/chunk-ENURAVHI.cjs +680 -0
- package/dist/{chunk-Z66WDWHI.js → chunk-FXZ2MYKJ.js} +127 -1
- package/dist/chunk-G26SJ6XS.cjs +1341 -0
- package/dist/chunk-G7GI7LJA.js +737 -0
- package/dist/chunk-GXEW4COZ.cjs +737 -0
- package/dist/chunk-HSVYF6XX.cjs +1361 -0
- package/dist/chunk-IBVM4DMJ.cjs +1097 -0
- package/dist/chunk-IV2H5CFI.cjs +1275 -0
- package/dist/chunk-IV2HRJVT.js +1198 -0
- package/dist/chunk-JSQM2MG3.js +680 -0
- package/dist/chunk-K4OLITS2.cjs +1055 -0
- package/dist/{chunk-UOBWHJA5.js → chunk-KFTCU2P6.js} +2 -3
- package/dist/chunk-LH4NTURO.js +1361 -0
- package/dist/{chunk-YTXLWKOR.js → chunk-MFAP7R6L.js} +1 -1
- package/dist/chunk-NGVE2RZT.js +1097 -0
- package/dist/chunk-NUX5BHWO.js +1341 -0
- package/dist/chunk-PJRA2TQ5.js +1055 -0
- package/dist/chunk-RVJAGE4S.cjs +1198 -0
- package/dist/{chunk-QYG6KGOV.cjs → chunk-RWQ43Z4F.cjs} +2 -3
- package/dist/chunk-RZHAPEXO.js +749 -0
- package/dist/chunk-ST24APEO.js +1109 -0
- package/dist/chunk-SYHW3FLI.cjs +642 -0
- package/dist/chunk-TLYNOOQP.cjs +432 -0
- package/dist/{chunk-IXHOBNXA.js → chunk-TMNGRIPL.js} +43 -41
- package/dist/chunk-UNS34PTA.cjs +680 -0
- package/dist/chunk-UR6JKS56.js +432 -0
- package/dist/{chunk-NPWHHWXT.cjs → chunk-UYXTY6ZQ.cjs} +127 -1
- package/dist/chunk-XUUCOLWU.cjs +1097 -0
- package/dist/chunk-YG5KJESI.js +641 -0
- package/dist/chunk-ZBKE2QRQ.js +1401 -0
- package/dist/chunk-ZSPO2GF2.cjs +1401 -0
- package/dist/codec-95k8CAu5.d.cts +35 -0
- package/dist/codec-AFuOxfsO.d.ts +60 -0
- package/dist/codec-B-UJ5Iow.d.cts +75 -0
- package/dist/codec-BC5jfvMb.d.ts +35 -0
- package/dist/codec-BECYPfY8.d.ts +35 -0
- package/dist/codec-BsPU1vNC.d.ts +39 -0
- package/dist/codec-BvpuF-6u.d.cts +39 -0
- package/dist/codec-C8jZI5Cx.d.cts +39 -0
- package/dist/codec-CAevkgf5.d.cts +33 -0
- package/dist/codec-CSUqCrRs.d.ts +39 -0
- package/dist/codec-C_HMXNK_.d.ts +33 -0
- package/dist/{codec-Bvr7rFtj.d.cts → codec-CpuvYTSV.d.cts} +1 -1
- package/dist/codec-D0x8-SCw.d.cts +35 -0
- package/dist/codec-D7ARhpG1.d.ts +75 -0
- package/dist/codec-DNAUGshO.d.cts +60 -0
- package/dist/codec-DPx_QNn0.d.ts +31 -0
- package/dist/{codec-B2mc2g3i.d.ts → codec-DRhCx_hw.d.ts} +1 -1
- package/dist/codec-Db7YPe3l.d.ts +31 -0
- package/dist/codec-axkJpb7D.d.cts +31 -0
- package/dist/codec-ujAbFaep.d.cts +31 -0
- package/dist/draft10-session.cjs +6 -0
- package/dist/draft10-session.d.cts +8 -0
- package/dist/draft10-session.d.ts +8 -0
- package/dist/draft10-session.js +6 -0
- package/dist/draft10.cjs +115 -0
- package/dist/draft10.d.cts +95 -0
- package/dist/draft10.d.ts +95 -0
- package/dist/draft10.js +115 -0
- package/dist/draft11-session.cjs +6 -0
- package/dist/draft11-session.d.cts +8 -0
- package/dist/draft11-session.d.ts +8 -0
- package/dist/draft11-session.js +6 -0
- package/dist/draft11.cjs +109 -0
- package/dist/draft11.d.cts +99 -0
- package/dist/draft11.d.ts +99 -0
- package/dist/draft11.js +109 -0
- package/dist/draft12-session.cjs +6 -0
- package/dist/draft12-session.d.cts +8 -0
- package/dist/draft12-session.d.ts +8 -0
- package/dist/draft12-session.js +6 -0
- package/dist/draft12.cjs +117 -0
- package/dist/draft12.d.cts +106 -0
- package/dist/draft12.d.ts +106 -0
- package/dist/draft12.js +117 -0
- package/dist/draft13-session.cjs +6 -0
- package/dist/draft13-session.d.cts +8 -0
- package/dist/draft13-session.d.ts +8 -0
- package/dist/draft13-session.js +6 -0
- package/dist/draft13.cjs +119 -0
- package/dist/draft13.d.cts +108 -0
- package/dist/draft13.d.ts +108 -0
- package/dist/draft13.js +119 -0
- package/dist/draft14-session.cjs +2 -2
- package/dist/draft14-session.d.cts +3 -3
- package/dist/draft14-session.d.ts +3 -3
- package/dist/draft14-session.js +1 -1
- package/dist/draft14.cjs +3 -3
- package/dist/draft14.d.cts +16 -4
- package/dist/draft14.d.ts +16 -4
- package/dist/draft14.js +2 -2
- package/dist/draft15-session.cjs +6 -0
- package/dist/draft15-session.d.cts +8 -0
- package/dist/draft15-session.d.ts +8 -0
- package/dist/draft15-session.js +6 -0
- package/dist/draft15.cjs +111 -0
- package/dist/draft15.d.cts +93 -0
- package/dist/draft15.d.ts +93 -0
- package/dist/draft15.js +111 -0
- package/dist/draft16-session.cjs +6 -0
- package/dist/draft16-session.d.cts +8 -0
- package/dist/draft16-session.d.ts +8 -0
- package/dist/draft16-session.js +6 -0
- package/dist/draft16.cjs +113 -0
- package/dist/draft16.d.cts +94 -0
- package/dist/draft16.d.ts +94 -0
- package/dist/draft16.js +113 -0
- package/dist/draft17-session.cjs +8 -0
- package/dist/draft17-session.d.cts +51 -0
- package/dist/draft17-session.d.ts +51 -0
- package/dist/draft17-session.js +8 -0
- package/dist/draft17.cjs +99 -0
- package/dist/draft17.d.cts +40 -0
- package/dist/draft17.d.ts +40 -0
- package/dist/draft17.js +99 -0
- package/dist/draft7-session.cjs +3 -3
- package/dist/draft7-session.d.cts +3 -3
- package/dist/draft7-session.d.ts +3 -3
- package/dist/draft7-session.js +2 -2
- package/dist/draft7.cjs +4 -4
- package/dist/draft7.d.cts +2 -2
- package/dist/draft7.d.ts +2 -2
- package/dist/draft7.js +2 -2
- package/dist/draft8-session.cjs +6 -0
- package/dist/draft8-session.d.cts +8 -0
- package/dist/draft8-session.d.ts +8 -0
- package/dist/draft8-session.js +6 -0
- package/dist/draft8.cjs +115 -0
- package/dist/draft8.d.cts +95 -0
- package/dist/draft8.d.ts +95 -0
- package/dist/draft8.js +115 -0
- package/dist/draft9-session.cjs +6 -0
- package/dist/draft9-session.d.cts +8 -0
- package/dist/draft9-session.d.ts +8 -0
- package/dist/draft9-session.js +6 -0
- package/dist/draft9.cjs +115 -0
- package/dist/draft9.d.cts +95 -0
- package/dist/draft9.d.ts +95 -0
- package/dist/draft9.js +115 -0
- package/dist/index.cjs +76 -4
- package/dist/index.d.cts +68 -5
- package/dist/index.d.ts +68 -5
- package/dist/index.js +76 -4
- package/dist/{session-types-DFjMk4HH.d.ts → session-types-CJIFbTPd.d.ts} +1 -1
- package/dist/{session-types-DW1RSZX_.d.cts → session-types-Cbq8IGCP.d.cts} +1 -1
- package/dist/session.cjs +5 -5
- package/dist/session.d.cts +3 -3
- package/dist/session.d.ts +3 -3
- package/dist/session.js +5 -5
- package/dist/types-4VxSL2Ho.d.cts +261 -0
- package/dist/types-4VxSL2Ho.d.ts +261 -0
- package/dist/types-B2afJZM-.d.cts +236 -0
- package/dist/types-B2afJZM-.d.ts +236 -0
- package/dist/types-Bg6QYNVt.d.cts +290 -0
- package/dist/types-Bg6QYNVt.d.ts +290 -0
- package/dist/types-C_1HrqBl.d.cts +306 -0
- package/dist/types-C_1HrqBl.d.ts +306 -0
- package/dist/types-Cw4WE9dh.d.cts +261 -0
- package/dist/types-Cw4WE9dh.d.ts +261 -0
- package/dist/types-D5gNQiDj.d.cts +261 -0
- package/dist/types-D5gNQiDj.d.ts +261 -0
- package/dist/types-DqCDFqgB.d.cts +230 -0
- package/dist/types-DqCDFqgB.d.ts +230 -0
- package/dist/types-ERexTpT8.d.cts +217 -0
- package/dist/types-ERexTpT8.d.ts +217 -0
- package/dist/{types-DPYE49t0.d.cts → types-QNXoxC9Y.d.cts} +2 -7
- package/dist/{types-DPYE49t0.d.ts → types-QNXoxC9Y.d.ts} +2 -7
- package/dist/types-r-CasCf1.d.cts +262 -0
- package/dist/types-r-CasCf1.d.ts +262 -0
- package/package.json +110 -2
- package/src/core/types.ts +24 -7
- package/src/drafts/draft07/codec.ts +49 -41
- package/src/drafts/draft07/rules.ts +1 -3
- package/src/drafts/draft08/codec.ts +1254 -0
- package/src/drafts/draft08/index.ts +125 -0
- package/src/drafts/draft08/messages.ts +72 -0
- package/src/drafts/draft08/rules.ts +91 -0
- package/src/drafts/draft08/session-fsm.ts +718 -0
- package/src/drafts/draft08/session.ts +26 -0
- package/src/drafts/draft08/types.ts +377 -0
- package/src/drafts/draft09/codec.ts +1235 -0
- package/src/drafts/draft09/index.ts +125 -0
- package/src/drafts/draft09/messages.ts +72 -0
- package/src/drafts/draft09/rules.ts +91 -0
- package/src/drafts/draft09/session-fsm.ts +718 -0
- package/src/drafts/draft09/session.ts +26 -0
- package/src/drafts/draft09/types.ts +376 -0
- package/src/drafts/draft10/codec.ts +1235 -0
- package/src/drafts/draft10/index.ts +125 -0
- package/src/drafts/draft10/messages.ts +72 -0
- package/src/drafts/draft10/rules.ts +91 -0
- package/src/drafts/draft10/session-fsm.ts +718 -0
- package/src/drafts/draft10/session.ts +26 -0
- package/src/drafts/draft10/types.ts +376 -0
- package/src/drafts/draft11/codec.ts +1198 -0
- package/src/drafts/draft11/index.ts +123 -0
- package/src/drafts/draft11/messages.ts +71 -0
- package/src/drafts/draft11/rules.ts +100 -0
- package/src/drafts/draft11/session-fsm.ts +758 -0
- package/src/drafts/draft11/session.ts +26 -0
- package/src/drafts/draft11/types.ts +375 -0
- package/src/drafts/draft12/codec.ts +1354 -0
- package/src/drafts/draft12/index.ts +130 -0
- package/src/drafts/draft12/messages.ts +84 -0
- package/src/drafts/draft12/rules.ts +106 -0
- package/src/drafts/draft12/session-fsm.ts +805 -0
- package/src/drafts/draft12/session.ts +26 -0
- package/src/drafts/draft12/types.ts +414 -0
- package/src/drafts/draft13/codec.ts +1438 -0
- package/src/drafts/draft13/index.ts +132 -0
- package/src/drafts/draft13/messages.ts +86 -0
- package/src/drafts/draft13/rules.ts +108 -0
- package/src/drafts/draft13/session-fsm.ts +819 -0
- package/src/drafts/draft13/session.ts +26 -0
- package/src/drafts/draft13/types.ts +433 -0
- package/src/drafts/draft14/session-fsm.ts +182 -1
- package/src/drafts/draft15/codec.ts +1661 -0
- package/src/drafts/draft15/index.ts +121 -0
- package/src/drafts/draft15/messages.ts +64 -0
- package/src/drafts/draft15/rules.ts +95 -0
- package/src/drafts/draft15/session-fsm.ts +687 -0
- package/src/drafts/draft15/session.ts +26 -0
- package/src/drafts/draft15/types.ts +336 -0
- package/src/drafts/draft16/codec.ts +1623 -0
- package/src/drafts/draft16/index.ts +123 -0
- package/src/drafts/draft16/messages.ts +67 -0
- package/src/drafts/draft16/rules.ts +96 -0
- package/src/drafts/draft16/session-fsm.ts +682 -0
- package/src/drafts/draft16/session.ts +26 -0
- package/src/drafts/draft16/types.ts +354 -0
- package/src/drafts/draft17/codec.ts +1621 -0
- package/src/drafts/draft17/index.ts +105 -0
- package/src/drafts/draft17/messages.ts +53 -0
- package/src/drafts/draft17/rules.ts +85 -0
- package/src/drafts/draft17/session-fsm.ts +437 -0
- package/src/drafts/draft17/session.ts +15 -0
- package/src/drafts/draft17/types.ts +310 -0
- package/src/index.ts +217 -2
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
interface UnknownParam {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly length: number;
|
|
4
|
+
readonly raw_hex: string;
|
|
5
|
+
}
|
|
6
|
+
interface Draft08SetupParams {
|
|
7
|
+
path?: string;
|
|
8
|
+
max_subscribe_id?: bigint;
|
|
9
|
+
unknown?: UnknownParam[];
|
|
10
|
+
}
|
|
11
|
+
interface Draft08Params {
|
|
12
|
+
authorization_info?: string;
|
|
13
|
+
delivery_timeout?: bigint;
|
|
14
|
+
max_cache_duration?: bigint;
|
|
15
|
+
unknown?: UnknownParam[];
|
|
16
|
+
}
|
|
17
|
+
type Draft08MessageType = "client_setup" | "server_setup" | "subscribe" | "subscribe_ok" | "subscribe_error" | "subscribe_update" | "subscribe_done" | "unsubscribe" | "announce" | "announce_ok" | "announce_error" | "unannounce" | "announce_cancel" | "subscribe_announces" | "subscribe_announces_ok" | "subscribe_announces_error" | "unsubscribe_announces" | "fetch" | "fetch_ok" | "fetch_error" | "fetch_cancel" | "track_status_request" | "track_status" | "goaway" | "max_subscribe_id" | "subscribes_blocked";
|
|
18
|
+
interface Draft08BaseMessage {
|
|
19
|
+
readonly type: Draft08MessageType;
|
|
20
|
+
}
|
|
21
|
+
interface Draft08ClientSetup extends Draft08BaseMessage {
|
|
22
|
+
readonly type: "client_setup";
|
|
23
|
+
readonly supported_versions: bigint[];
|
|
24
|
+
readonly parameters: Draft08SetupParams;
|
|
25
|
+
}
|
|
26
|
+
interface Draft08ServerSetup extends Draft08BaseMessage {
|
|
27
|
+
readonly type: "server_setup";
|
|
28
|
+
readonly selected_version: bigint;
|
|
29
|
+
readonly parameters: Draft08SetupParams;
|
|
30
|
+
}
|
|
31
|
+
interface Draft08Subscribe extends Draft08BaseMessage {
|
|
32
|
+
readonly type: "subscribe";
|
|
33
|
+
readonly subscribe_id: bigint;
|
|
34
|
+
readonly track_alias: bigint;
|
|
35
|
+
readonly track_namespace: string[];
|
|
36
|
+
readonly track_name: string;
|
|
37
|
+
readonly subscriber_priority: number;
|
|
38
|
+
readonly group_order: number;
|
|
39
|
+
readonly filter_type: bigint;
|
|
40
|
+
readonly start_group?: bigint;
|
|
41
|
+
readonly start_object?: bigint;
|
|
42
|
+
readonly end_group?: bigint;
|
|
43
|
+
readonly parameters: Draft08Params;
|
|
44
|
+
}
|
|
45
|
+
interface Draft08SubscribeOk extends Draft08BaseMessage {
|
|
46
|
+
readonly type: "subscribe_ok";
|
|
47
|
+
readonly subscribe_id: bigint;
|
|
48
|
+
readonly expires: bigint;
|
|
49
|
+
readonly group_order: number;
|
|
50
|
+
readonly content_exists: number;
|
|
51
|
+
readonly largest_group_id?: bigint;
|
|
52
|
+
readonly largest_object_id?: bigint;
|
|
53
|
+
readonly parameters: Draft08Params;
|
|
54
|
+
}
|
|
55
|
+
interface Draft08SubscribeError extends Draft08BaseMessage {
|
|
56
|
+
readonly type: "subscribe_error";
|
|
57
|
+
readonly subscribe_id: bigint;
|
|
58
|
+
readonly error_code: bigint;
|
|
59
|
+
readonly reason_phrase: string;
|
|
60
|
+
readonly track_alias: bigint;
|
|
61
|
+
}
|
|
62
|
+
interface Draft08SubscribeDone extends Draft08BaseMessage {
|
|
63
|
+
readonly type: "subscribe_done";
|
|
64
|
+
readonly subscribe_id: bigint;
|
|
65
|
+
readonly status_code: bigint;
|
|
66
|
+
readonly stream_count: bigint;
|
|
67
|
+
readonly reason_phrase: string;
|
|
68
|
+
}
|
|
69
|
+
interface Draft08SubscribeUpdate extends Draft08BaseMessage {
|
|
70
|
+
readonly type: "subscribe_update";
|
|
71
|
+
readonly subscribe_id: bigint;
|
|
72
|
+
readonly start_group: bigint;
|
|
73
|
+
readonly start_object: bigint;
|
|
74
|
+
readonly end_group: bigint;
|
|
75
|
+
readonly subscriber_priority: number;
|
|
76
|
+
readonly parameters: Draft08Params;
|
|
77
|
+
}
|
|
78
|
+
interface Draft08Unsubscribe extends Draft08BaseMessage {
|
|
79
|
+
readonly type: "unsubscribe";
|
|
80
|
+
readonly subscribe_id: bigint;
|
|
81
|
+
}
|
|
82
|
+
interface Draft08Announce extends Draft08BaseMessage {
|
|
83
|
+
readonly type: "announce";
|
|
84
|
+
readonly track_namespace: string[];
|
|
85
|
+
readonly parameters: Draft08Params;
|
|
86
|
+
}
|
|
87
|
+
interface Draft08AnnounceOk extends Draft08BaseMessage {
|
|
88
|
+
readonly type: "announce_ok";
|
|
89
|
+
readonly track_namespace: string[];
|
|
90
|
+
}
|
|
91
|
+
interface Draft08AnnounceError extends Draft08BaseMessage {
|
|
92
|
+
readonly type: "announce_error";
|
|
93
|
+
readonly track_namespace: string[];
|
|
94
|
+
readonly error_code: bigint;
|
|
95
|
+
readonly reason_phrase: string;
|
|
96
|
+
}
|
|
97
|
+
interface Draft08Unannounce extends Draft08BaseMessage {
|
|
98
|
+
readonly type: "unannounce";
|
|
99
|
+
readonly track_namespace: string[];
|
|
100
|
+
}
|
|
101
|
+
interface Draft08AnnounceCancel extends Draft08BaseMessage {
|
|
102
|
+
readonly type: "announce_cancel";
|
|
103
|
+
readonly track_namespace: string[];
|
|
104
|
+
readonly error_code: bigint;
|
|
105
|
+
readonly reason_phrase: string;
|
|
106
|
+
}
|
|
107
|
+
interface Draft08SubscribeAnnounces extends Draft08BaseMessage {
|
|
108
|
+
readonly type: "subscribe_announces";
|
|
109
|
+
readonly track_namespace_prefix: string[];
|
|
110
|
+
readonly parameters: Draft08Params;
|
|
111
|
+
}
|
|
112
|
+
interface Draft08SubscribeAnnouncesOk extends Draft08BaseMessage {
|
|
113
|
+
readonly type: "subscribe_announces_ok";
|
|
114
|
+
readonly track_namespace_prefix: string[];
|
|
115
|
+
}
|
|
116
|
+
interface Draft08SubscribeAnnouncesError extends Draft08BaseMessage {
|
|
117
|
+
readonly type: "subscribe_announces_error";
|
|
118
|
+
readonly track_namespace_prefix: string[];
|
|
119
|
+
readonly error_code: bigint;
|
|
120
|
+
readonly reason_phrase: string;
|
|
121
|
+
}
|
|
122
|
+
interface Draft08UnsubscribeAnnounces extends Draft08BaseMessage {
|
|
123
|
+
readonly type: "unsubscribe_announces";
|
|
124
|
+
readonly track_namespace_prefix: string[];
|
|
125
|
+
}
|
|
126
|
+
interface StandaloneFetch {
|
|
127
|
+
readonly track_namespace: string[];
|
|
128
|
+
readonly track_name: string;
|
|
129
|
+
readonly start_group: bigint;
|
|
130
|
+
readonly start_object: bigint;
|
|
131
|
+
readonly end_group: bigint;
|
|
132
|
+
readonly end_object: bigint;
|
|
133
|
+
}
|
|
134
|
+
interface JoiningFetch {
|
|
135
|
+
readonly joining_subscribe_id: bigint;
|
|
136
|
+
readonly preceding_group_offset: bigint;
|
|
137
|
+
}
|
|
138
|
+
interface Draft08Fetch extends Draft08BaseMessage {
|
|
139
|
+
readonly type: "fetch";
|
|
140
|
+
readonly subscribe_id: bigint;
|
|
141
|
+
readonly subscriber_priority: number;
|
|
142
|
+
readonly group_order: number;
|
|
143
|
+
readonly fetch_type: bigint;
|
|
144
|
+
readonly standalone?: StandaloneFetch;
|
|
145
|
+
readonly joining?: JoiningFetch;
|
|
146
|
+
readonly parameters: Draft08Params;
|
|
147
|
+
}
|
|
148
|
+
interface Draft08FetchOk extends Draft08BaseMessage {
|
|
149
|
+
readonly type: "fetch_ok";
|
|
150
|
+
readonly subscribe_id: bigint;
|
|
151
|
+
readonly group_order: number;
|
|
152
|
+
readonly end_of_track: number;
|
|
153
|
+
readonly largest_group_id: bigint;
|
|
154
|
+
readonly largest_object_id: bigint;
|
|
155
|
+
readonly parameters: Draft08Params;
|
|
156
|
+
}
|
|
157
|
+
interface Draft08FetchError extends Draft08BaseMessage {
|
|
158
|
+
readonly type: "fetch_error";
|
|
159
|
+
readonly subscribe_id: bigint;
|
|
160
|
+
readonly error_code: bigint;
|
|
161
|
+
readonly reason_phrase: string;
|
|
162
|
+
}
|
|
163
|
+
interface Draft08FetchCancel extends Draft08BaseMessage {
|
|
164
|
+
readonly type: "fetch_cancel";
|
|
165
|
+
readonly subscribe_id: bigint;
|
|
166
|
+
}
|
|
167
|
+
interface Draft08TrackStatusRequest extends Draft08BaseMessage {
|
|
168
|
+
readonly type: "track_status_request";
|
|
169
|
+
readonly track_namespace: string[];
|
|
170
|
+
readonly track_name: string;
|
|
171
|
+
}
|
|
172
|
+
interface Draft08TrackStatus extends Draft08BaseMessage {
|
|
173
|
+
readonly type: "track_status";
|
|
174
|
+
readonly track_namespace: string[];
|
|
175
|
+
readonly track_name: string;
|
|
176
|
+
readonly status_code: bigint;
|
|
177
|
+
readonly last_group_id: bigint;
|
|
178
|
+
readonly last_object_id: bigint;
|
|
179
|
+
}
|
|
180
|
+
interface Draft08GoAway extends Draft08BaseMessage {
|
|
181
|
+
readonly type: "goaway";
|
|
182
|
+
readonly new_session_uri: string;
|
|
183
|
+
}
|
|
184
|
+
interface Draft08MaxSubscribeId extends Draft08BaseMessage {
|
|
185
|
+
readonly type: "max_subscribe_id";
|
|
186
|
+
readonly subscribe_id: bigint;
|
|
187
|
+
}
|
|
188
|
+
interface Draft08SubscribesBlocked extends Draft08BaseMessage {
|
|
189
|
+
readonly type: "subscribes_blocked";
|
|
190
|
+
readonly maximum_subscribe_id: bigint;
|
|
191
|
+
}
|
|
192
|
+
type Draft08Message = Draft08ClientSetup | Draft08ServerSetup | Draft08Subscribe | Draft08SubscribeOk | Draft08SubscribeError | Draft08SubscribeUpdate | Draft08SubscribeDone | Draft08Unsubscribe | Draft08Announce | Draft08AnnounceOk | Draft08AnnounceError | Draft08Unannounce | Draft08AnnounceCancel | Draft08SubscribeAnnounces | Draft08SubscribeAnnouncesOk | Draft08SubscribeAnnouncesError | Draft08UnsubscribeAnnounces | Draft08Fetch | Draft08FetchOk | Draft08FetchError | Draft08FetchCancel | Draft08TrackStatusRequest | Draft08TrackStatus | Draft08GoAway | Draft08MaxSubscribeId | Draft08SubscribesBlocked;
|
|
193
|
+
interface ObjectPayload {
|
|
194
|
+
readonly type: "object";
|
|
195
|
+
readonly objectId: bigint;
|
|
196
|
+
readonly extensionCount: bigint;
|
|
197
|
+
readonly payloadLength: number;
|
|
198
|
+
readonly status?: bigint;
|
|
199
|
+
readonly payload: Uint8Array;
|
|
200
|
+
}
|
|
201
|
+
interface SubgroupStream {
|
|
202
|
+
readonly type: "subgroup";
|
|
203
|
+
readonly streamTypeId: 0x04;
|
|
204
|
+
readonly trackAlias: bigint;
|
|
205
|
+
readonly groupId: bigint;
|
|
206
|
+
readonly subgroupId: bigint;
|
|
207
|
+
readonly publisherPriority: number;
|
|
208
|
+
readonly objects: ObjectPayload[];
|
|
209
|
+
}
|
|
210
|
+
interface DatagramObject {
|
|
211
|
+
readonly type: "datagram";
|
|
212
|
+
readonly streamTypeId: 0x01;
|
|
213
|
+
readonly trackAlias: bigint;
|
|
214
|
+
readonly groupId: bigint;
|
|
215
|
+
readonly objectId: bigint;
|
|
216
|
+
readonly publisherPriority: number;
|
|
217
|
+
readonly extensionCount: bigint;
|
|
218
|
+
readonly objectStatus: bigint;
|
|
219
|
+
readonly payloadLength: number;
|
|
220
|
+
readonly payload: Uint8Array;
|
|
221
|
+
}
|
|
222
|
+
interface DatagramStatusObject {
|
|
223
|
+
readonly type: "datagram_status";
|
|
224
|
+
readonly streamTypeId: 0x02;
|
|
225
|
+
readonly trackAlias: bigint;
|
|
226
|
+
readonly groupId: bigint;
|
|
227
|
+
readonly objectId: bigint;
|
|
228
|
+
readonly publisherPriority: number;
|
|
229
|
+
readonly objectStatus: bigint;
|
|
230
|
+
}
|
|
231
|
+
interface FetchObjectPayload {
|
|
232
|
+
readonly type: "object";
|
|
233
|
+
readonly groupId: bigint;
|
|
234
|
+
readonly subgroupId: bigint;
|
|
235
|
+
readonly objectId: bigint;
|
|
236
|
+
readonly publisherPriority: number;
|
|
237
|
+
readonly extensionCount: bigint;
|
|
238
|
+
readonly payloadLength: number;
|
|
239
|
+
readonly status?: bigint;
|
|
240
|
+
readonly payload: Uint8Array;
|
|
241
|
+
}
|
|
242
|
+
interface FetchStream {
|
|
243
|
+
readonly type: "fetch";
|
|
244
|
+
readonly subscribeId: bigint;
|
|
245
|
+
readonly objects: FetchObjectPayload[];
|
|
246
|
+
}
|
|
247
|
+
type Draft08DataStream = SubgroupStream | DatagramObject | DatagramStatusObject | FetchStream;
|
|
248
|
+
interface SubgroupStreamHeader {
|
|
249
|
+
readonly type: "subgroup_header";
|
|
250
|
+
readonly trackAlias: bigint;
|
|
251
|
+
readonly groupId: bigint;
|
|
252
|
+
readonly subgroupId: bigint;
|
|
253
|
+
readonly publisherPriority: number;
|
|
254
|
+
}
|
|
255
|
+
interface FetchStreamHeader {
|
|
256
|
+
readonly type: "fetch_header";
|
|
257
|
+
readonly subscribeId: bigint;
|
|
258
|
+
}
|
|
259
|
+
type DataStreamHeader = SubgroupStreamHeader | FetchStreamHeader;
|
|
260
|
+
type DataStreamEvent = DataStreamHeader | ObjectPayload;
|
|
261
|
+
|
|
262
|
+
export type { Draft08SubscribeError as A, Draft08SubscribeOk as B, Draft08SubscribeUpdate as C, Draft08DataStream as D, Draft08SubscribesBlocked as E, Draft08TrackStatus as F, Draft08TrackStatusRequest as G, Draft08Unannounce as H, Draft08Unsubscribe as I, Draft08UnsubscribeAnnounces as J, FetchObjectPayload as K, FetchStream as L, FetchStreamHeader as M, JoiningFetch as N, ObjectPayload as O, SubgroupStream as P, SubgroupStreamHeader as Q, StandaloneFetch as S, UnknownParam as U, Draft08Message as a, Draft08Params as b, Draft08SetupParams as c, Draft08MessageType as d, DataStreamEvent as e, DataStreamHeader as f, DatagramObject as g, DatagramStatusObject as h, Draft08Announce as i, Draft08AnnounceCancel as j, Draft08AnnounceError as k, Draft08AnnounceOk as l, Draft08BaseMessage as m, Draft08ClientSetup as n, Draft08Fetch as o, Draft08FetchCancel as p, Draft08FetchError as q, Draft08FetchOk as r, Draft08GoAway as s, Draft08MaxSubscribeId as t, Draft08ServerSetup as u, Draft08Subscribe as v, Draft08SubscribeAnnounces as w, Draft08SubscribeAnnouncesError as x, Draft08SubscribeAnnouncesOk as y, Draft08SubscribeDone as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moqtap/codec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MoQT wire-format codec and session state machine — multi-draft, zero dependencies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,6 +41,78 @@
|
|
|
41
41
|
"import": "./dist/draft7.js",
|
|
42
42
|
"require": "./dist/draft7.cjs"
|
|
43
43
|
},
|
|
44
|
+
"./draft8": {
|
|
45
|
+
"bun": "./src/drafts/draft08/index.ts",
|
|
46
|
+
"types": "./dist/draft8.d.ts",
|
|
47
|
+
"import": "./dist/draft8.js",
|
|
48
|
+
"require": "./dist/draft8.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./draft8/session": {
|
|
51
|
+
"bun": "./src/drafts/draft08/session.ts",
|
|
52
|
+
"types": "./dist/draft8-session.d.ts",
|
|
53
|
+
"import": "./dist/draft8-session.js",
|
|
54
|
+
"require": "./dist/draft8-session.cjs"
|
|
55
|
+
},
|
|
56
|
+
"./draft9": {
|
|
57
|
+
"bun": "./src/drafts/draft09/index.ts",
|
|
58
|
+
"types": "./dist/draft9.d.ts",
|
|
59
|
+
"import": "./dist/draft9.js",
|
|
60
|
+
"require": "./dist/draft9.cjs"
|
|
61
|
+
},
|
|
62
|
+
"./draft9/session": {
|
|
63
|
+
"bun": "./src/drafts/draft09/session.ts",
|
|
64
|
+
"types": "./dist/draft9-session.d.ts",
|
|
65
|
+
"import": "./dist/draft9-session.js",
|
|
66
|
+
"require": "./dist/draft9-session.cjs"
|
|
67
|
+
},
|
|
68
|
+
"./draft10": {
|
|
69
|
+
"bun": "./src/drafts/draft10/index.ts",
|
|
70
|
+
"types": "./dist/draft10.d.ts",
|
|
71
|
+
"import": "./dist/draft10.js",
|
|
72
|
+
"require": "./dist/draft10.cjs"
|
|
73
|
+
},
|
|
74
|
+
"./draft10/session": {
|
|
75
|
+
"bun": "./src/drafts/draft10/session.ts",
|
|
76
|
+
"types": "./dist/draft10-session.d.ts",
|
|
77
|
+
"import": "./dist/draft10-session.js",
|
|
78
|
+
"require": "./dist/draft10-session.cjs"
|
|
79
|
+
},
|
|
80
|
+
"./draft11": {
|
|
81
|
+
"bun": "./src/drafts/draft11/index.ts",
|
|
82
|
+
"types": "./dist/draft11.d.ts",
|
|
83
|
+
"import": "./dist/draft11.js",
|
|
84
|
+
"require": "./dist/draft11.cjs"
|
|
85
|
+
},
|
|
86
|
+
"./draft11/session": {
|
|
87
|
+
"bun": "./src/drafts/draft11/session.ts",
|
|
88
|
+
"types": "./dist/draft11-session.d.ts",
|
|
89
|
+
"import": "./dist/draft11-session.js",
|
|
90
|
+
"require": "./dist/draft11-session.cjs"
|
|
91
|
+
},
|
|
92
|
+
"./draft12": {
|
|
93
|
+
"bun": "./src/drafts/draft12/index.ts",
|
|
94
|
+
"types": "./dist/draft12.d.ts",
|
|
95
|
+
"import": "./dist/draft12.js",
|
|
96
|
+
"require": "./dist/draft12.cjs"
|
|
97
|
+
},
|
|
98
|
+
"./draft12/session": {
|
|
99
|
+
"bun": "./src/drafts/draft12/session.ts",
|
|
100
|
+
"types": "./dist/draft12-session.d.ts",
|
|
101
|
+
"import": "./dist/draft12-session.js",
|
|
102
|
+
"require": "./dist/draft12-session.cjs"
|
|
103
|
+
},
|
|
104
|
+
"./draft13": {
|
|
105
|
+
"bun": "./src/drafts/draft13/index.ts",
|
|
106
|
+
"types": "./dist/draft13.d.ts",
|
|
107
|
+
"import": "./dist/draft13.js",
|
|
108
|
+
"require": "./dist/draft13.cjs"
|
|
109
|
+
},
|
|
110
|
+
"./draft13/session": {
|
|
111
|
+
"bun": "./src/drafts/draft13/session.ts",
|
|
112
|
+
"types": "./dist/draft13-session.d.ts",
|
|
113
|
+
"import": "./dist/draft13-session.js",
|
|
114
|
+
"require": "./dist/draft13-session.cjs"
|
|
115
|
+
},
|
|
44
116
|
"./draft14": {
|
|
45
117
|
"bun": "./src/drafts/draft14/index.ts",
|
|
46
118
|
"types": "./dist/draft14.d.ts",
|
|
@@ -64,6 +136,42 @@
|
|
|
64
136
|
"types": "./dist/draft14-session.d.ts",
|
|
65
137
|
"import": "./dist/draft14-session.js",
|
|
66
138
|
"require": "./dist/draft14-session.cjs"
|
|
139
|
+
},
|
|
140
|
+
"./draft15": {
|
|
141
|
+
"bun": "./src/drafts/draft15/index.ts",
|
|
142
|
+
"types": "./dist/draft15.d.ts",
|
|
143
|
+
"import": "./dist/draft15.js",
|
|
144
|
+
"require": "./dist/draft15.cjs"
|
|
145
|
+
},
|
|
146
|
+
"./draft15/session": {
|
|
147
|
+
"bun": "./src/drafts/draft15/session.ts",
|
|
148
|
+
"types": "./dist/draft15-session.d.ts",
|
|
149
|
+
"import": "./dist/draft15-session.js",
|
|
150
|
+
"require": "./dist/draft15-session.cjs"
|
|
151
|
+
},
|
|
152
|
+
"./draft16": {
|
|
153
|
+
"bun": "./src/drafts/draft16/index.ts",
|
|
154
|
+
"types": "./dist/draft16.d.ts",
|
|
155
|
+
"import": "./dist/draft16.js",
|
|
156
|
+
"require": "./dist/draft16.cjs"
|
|
157
|
+
},
|
|
158
|
+
"./draft16/session": {
|
|
159
|
+
"bun": "./src/drafts/draft16/session.ts",
|
|
160
|
+
"types": "./dist/draft16-session.d.ts",
|
|
161
|
+
"import": "./dist/draft16-session.js",
|
|
162
|
+
"require": "./dist/draft16-session.cjs"
|
|
163
|
+
},
|
|
164
|
+
"./draft17": {
|
|
165
|
+
"bun": "./src/drafts/draft17/index.ts",
|
|
166
|
+
"types": "./dist/draft17.d.ts",
|
|
167
|
+
"import": "./dist/draft17.js",
|
|
168
|
+
"require": "./dist/draft17.cjs"
|
|
169
|
+
},
|
|
170
|
+
"./draft17/session": {
|
|
171
|
+
"bun": "./src/drafts/draft17/session.ts",
|
|
172
|
+
"types": "./dist/draft17-session.d.ts",
|
|
173
|
+
"import": "./dist/draft17-session.js",
|
|
174
|
+
"require": "./dist/draft17-session.cjs"
|
|
67
175
|
}
|
|
68
176
|
},
|
|
69
177
|
"files": [
|
|
@@ -76,7 +184,7 @@
|
|
|
76
184
|
"test": "vitest run"
|
|
77
185
|
},
|
|
78
186
|
"devDependencies": {
|
|
79
|
-
"@moqtap/test-vectors": "^0.
|
|
187
|
+
"@moqtap/test-vectors": "^0.6.0",
|
|
80
188
|
"tsup": "^8.0.0",
|
|
81
189
|
"typescript": "^5.5.0",
|
|
82
190
|
"vitest": "^3.0.0"
|
package/src/core/types.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
// Draft identifiers
|
|
2
|
-
export type Draft =
|
|
3
|
-
|
|
2
|
+
export type Draft =
|
|
3
|
+
| "draft-ietf-moq-transport-07"
|
|
4
|
+
| "draft-ietf-moq-transport-08"
|
|
5
|
+
| "draft-ietf-moq-transport-09"
|
|
6
|
+
| "draft-ietf-moq-transport-10"
|
|
7
|
+
| "draft-ietf-moq-transport-11"
|
|
8
|
+
| "draft-ietf-moq-transport-12"
|
|
9
|
+
| "draft-ietf-moq-transport-13"
|
|
10
|
+
| "draft-ietf-moq-transport-14"
|
|
11
|
+
| "draft-ietf-moq-transport-15"
|
|
12
|
+
| "draft-ietf-moq-transport-16"
|
|
13
|
+
| "draft-ietf-moq-transport-17";
|
|
14
|
+
export type DraftShorthand =
|
|
15
|
+
| "07"
|
|
16
|
+
| "08"
|
|
17
|
+
| "09"
|
|
18
|
+
| "10"
|
|
19
|
+
| "11"
|
|
20
|
+
| "12"
|
|
21
|
+
| "13"
|
|
22
|
+
| "14"
|
|
23
|
+
| "15"
|
|
24
|
+
| "16"
|
|
25
|
+
| "17";
|
|
4
26
|
|
|
5
27
|
// All MoQT message type tags
|
|
6
28
|
export type MoqtMessageType =
|
|
@@ -169,7 +191,6 @@ export interface TrackStatus extends BaseMessage {
|
|
|
169
191
|
// Object/stream messages
|
|
170
192
|
export interface ObjectStream extends BaseMessage {
|
|
171
193
|
readonly type: "object_stream";
|
|
172
|
-
readonly subscribeId: bigint;
|
|
173
194
|
readonly trackAlias: bigint;
|
|
174
195
|
readonly groupId: bigint;
|
|
175
196
|
readonly objectId: bigint;
|
|
@@ -180,7 +201,6 @@ export interface ObjectStream extends BaseMessage {
|
|
|
180
201
|
|
|
181
202
|
export interface ObjectDatagram extends BaseMessage {
|
|
182
203
|
readonly type: "object_datagram";
|
|
183
|
-
readonly subscribeId: bigint;
|
|
184
204
|
readonly trackAlias: bigint;
|
|
185
205
|
readonly groupId: bigint;
|
|
186
206
|
readonly objectId: bigint;
|
|
@@ -191,14 +211,12 @@ export interface ObjectDatagram extends BaseMessage {
|
|
|
191
211
|
|
|
192
212
|
export interface StreamHeaderTrack extends BaseMessage {
|
|
193
213
|
readonly type: "stream_header_track";
|
|
194
|
-
readonly subscribeId: bigint;
|
|
195
214
|
readonly trackAlias: bigint;
|
|
196
215
|
readonly publisherPriority: number;
|
|
197
216
|
}
|
|
198
217
|
|
|
199
218
|
export interface StreamHeaderGroup extends BaseMessage {
|
|
200
219
|
readonly type: "stream_header_group";
|
|
201
|
-
readonly subscribeId: bigint;
|
|
202
220
|
readonly trackAlias: bigint;
|
|
203
221
|
readonly groupId: bigint;
|
|
204
222
|
readonly publisherPriority: number;
|
|
@@ -206,7 +224,6 @@ export interface StreamHeaderGroup extends BaseMessage {
|
|
|
206
224
|
|
|
207
225
|
export interface StreamHeaderSubgroup extends BaseMessage {
|
|
208
226
|
readonly type: "stream_header_subgroup";
|
|
209
|
-
readonly subscribeId: bigint;
|
|
210
227
|
readonly trackAlias: bigint;
|
|
211
228
|
readonly groupId: bigint;
|
|
212
229
|
readonly subgroupId: bigint;
|
|
@@ -288,46 +288,45 @@ function encodeFetchCancel(msg: FetchCancel, writer: BufferWriter): void {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
// Data stream encoders (no type+length framing)
|
|
291
|
+
function encodeObjectPayload(
|
|
292
|
+
msg: { objectStatus?: number; payload: Uint8Array },
|
|
293
|
+
writer: BufferWriter,
|
|
294
|
+
): void {
|
|
295
|
+
if (msg.payload.byteLength === 0) {
|
|
296
|
+
writer.writeVarInt(0); // payloadLength = 0 signals objectStatus follows
|
|
297
|
+
writer.writeVarInt(msg.objectStatus ?? 0);
|
|
298
|
+
} else {
|
|
299
|
+
writer.writeVarInt(msg.payload.byteLength);
|
|
300
|
+
writer.writeBytes(msg.payload);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
291
304
|
function encodeObjectStream(msg: ObjectStream, writer: BufferWriter): void {
|
|
292
305
|
writer.writeVarInt(MESSAGE_TYPE_IDS.object_stream);
|
|
293
|
-
writer.writeVarInt(msg.subscribeId);
|
|
294
306
|
writer.writeVarInt(msg.trackAlias);
|
|
295
307
|
writer.writeVarInt(msg.groupId);
|
|
296
308
|
writer.writeVarInt(msg.objectId);
|
|
297
309
|
writer.writeUint8(msg.publisherPriority);
|
|
298
|
-
|
|
299
|
-
writer.writeVarInt(msg.objectStatus);
|
|
300
|
-
} else {
|
|
301
|
-
writer.writeVarInt(0);
|
|
302
|
-
}
|
|
303
|
-
writer.writeBytes(msg.payload);
|
|
310
|
+
encodeObjectPayload(msg, writer);
|
|
304
311
|
}
|
|
305
312
|
|
|
306
313
|
function encodeObjectDatagram(msg: ObjectDatagram, writer: BufferWriter): void {
|
|
307
314
|
writer.writeVarInt(MESSAGE_TYPE_IDS.object_datagram);
|
|
308
|
-
writer.writeVarInt(msg.subscribeId);
|
|
309
315
|
writer.writeVarInt(msg.trackAlias);
|
|
310
316
|
writer.writeVarInt(msg.groupId);
|
|
311
317
|
writer.writeVarInt(msg.objectId);
|
|
312
318
|
writer.writeUint8(msg.publisherPriority);
|
|
313
|
-
|
|
314
|
-
writer.writeVarInt(msg.objectStatus);
|
|
315
|
-
} else {
|
|
316
|
-
writer.writeVarInt(0);
|
|
317
|
-
}
|
|
318
|
-
writer.writeBytes(msg.payload);
|
|
319
|
+
encodeObjectPayload(msg, writer);
|
|
319
320
|
}
|
|
320
321
|
|
|
321
322
|
function encodeStreamHeaderTrack(msg: StreamHeaderTrack, writer: BufferWriter): void {
|
|
322
323
|
writer.writeVarInt(MESSAGE_TYPE_IDS.stream_header_track);
|
|
323
|
-
writer.writeVarInt(msg.subscribeId);
|
|
324
324
|
writer.writeVarInt(msg.trackAlias);
|
|
325
325
|
writer.writeUint8(msg.publisherPriority);
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
function encodeStreamHeaderGroup(msg: StreamHeaderGroup, writer: BufferWriter): void {
|
|
329
329
|
writer.writeVarInt(MESSAGE_TYPE_IDS.stream_header_group);
|
|
330
|
-
writer.writeVarInt(msg.subscribeId);
|
|
331
330
|
writer.writeVarInt(msg.trackAlias);
|
|
332
331
|
writer.writeVarInt(msg.groupId);
|
|
333
332
|
writer.writeUint8(msg.publisherPriority);
|
|
@@ -335,7 +334,6 @@ function encodeStreamHeaderGroup(msg: StreamHeaderGroup, writer: BufferWriter):
|
|
|
335
334
|
|
|
336
335
|
function encodeStreamHeaderSubgroup(msg: StreamHeaderSubgroup, writer: BufferWriter): void {
|
|
337
336
|
writer.writeVarInt(MESSAGE_TYPE_IDS.stream_header_subgroup);
|
|
338
|
-
writer.writeVarInt(msg.subscribeId);
|
|
339
337
|
writer.writeVarInt(msg.trackAlias);
|
|
340
338
|
writer.writeVarInt(msg.groupId);
|
|
341
339
|
writer.writeVarInt(msg.subgroupId);
|
|
@@ -687,75 +685,85 @@ function decodeFetchCancel(reader: BufferReader): FetchCancel {
|
|
|
687
685
|
}
|
|
688
686
|
|
|
689
687
|
function decodeObjectStream(reader: BufferReader): ObjectStream {
|
|
690
|
-
const subscribeId = reader.readVarInt();
|
|
691
688
|
const trackAlias = reader.readVarInt();
|
|
692
689
|
const groupId = reader.readVarInt();
|
|
693
690
|
const objectId = reader.readVarInt();
|
|
694
691
|
const publisherPriority = reader.readUint8();
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
692
|
+
const payloadLength = Number(reader.readVarInt());
|
|
693
|
+
if (payloadLength === 0) {
|
|
694
|
+
// Object Status follows when payload length is 0
|
|
695
|
+
const objectStatus = reader.remaining > 0 ? Number(reader.readVarInt()) : 0;
|
|
696
|
+
return {
|
|
697
|
+
type: "object_stream" as const,
|
|
698
|
+
trackAlias,
|
|
699
|
+
groupId,
|
|
700
|
+
objectId,
|
|
701
|
+
publisherPriority,
|
|
702
|
+
objectStatus,
|
|
703
|
+
payload: new Uint8Array(0),
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
const payload = reader.readBytes(payloadLength);
|
|
707
|
+
return {
|
|
698
708
|
type: "object_stream" as const,
|
|
699
|
-
subscribeId,
|
|
700
709
|
trackAlias,
|
|
701
710
|
groupId,
|
|
702
711
|
objectId,
|
|
703
712
|
publisherPriority,
|
|
704
713
|
payload,
|
|
705
714
|
};
|
|
706
|
-
if (objectStatusRaw !== 0) {
|
|
707
|
-
return { ...base, objectStatus: objectStatusRaw };
|
|
708
|
-
}
|
|
709
|
-
return base;
|
|
710
715
|
}
|
|
711
716
|
|
|
712
717
|
function decodeObjectDatagram(reader: BufferReader): ObjectDatagram {
|
|
713
|
-
const subscribeId = reader.readVarInt();
|
|
714
718
|
const trackAlias = reader.readVarInt();
|
|
715
719
|
const groupId = reader.readVarInt();
|
|
716
720
|
const objectId = reader.readVarInt();
|
|
717
721
|
const publisherPriority = reader.readUint8();
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
722
|
+
const payloadLength = Number(reader.readVarInt());
|
|
723
|
+
if (payloadLength === 0) {
|
|
724
|
+
// Object Status follows when payload length is 0
|
|
725
|
+
const objectStatus = reader.remaining > 0 ? Number(reader.readVarInt()) : 0;
|
|
726
|
+
return {
|
|
727
|
+
type: "object_datagram" as const,
|
|
728
|
+
trackAlias,
|
|
729
|
+
groupId,
|
|
730
|
+
objectId,
|
|
731
|
+
publisherPriority,
|
|
732
|
+
objectStatus,
|
|
733
|
+
payload: new Uint8Array(0),
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
const payload = reader.readBytes(payloadLength);
|
|
737
|
+
return {
|
|
721
738
|
type: "object_datagram" as const,
|
|
722
|
-
subscribeId,
|
|
723
739
|
trackAlias,
|
|
724
740
|
groupId,
|
|
725
741
|
objectId,
|
|
726
742
|
publisherPriority,
|
|
727
743
|
payload,
|
|
728
744
|
};
|
|
729
|
-
if (objectStatusRaw !== 0) {
|
|
730
|
-
return { ...base, objectStatus: objectStatusRaw };
|
|
731
|
-
}
|
|
732
|
-
return base;
|
|
733
745
|
}
|
|
734
746
|
|
|
735
747
|
function decodeStreamHeaderTrack(reader: BufferReader): StreamHeaderTrack {
|
|
736
|
-
const subscribeId = reader.readVarInt();
|
|
737
748
|
const trackAlias = reader.readVarInt();
|
|
738
749
|
const publisherPriority = reader.readUint8();
|
|
739
|
-
return { type: "stream_header_track",
|
|
750
|
+
return { type: "stream_header_track", trackAlias, publisherPriority };
|
|
740
751
|
}
|
|
741
752
|
|
|
742
753
|
function decodeStreamHeaderGroup(reader: BufferReader): StreamHeaderGroup {
|
|
743
|
-
const subscribeId = reader.readVarInt();
|
|
744
754
|
const trackAlias = reader.readVarInt();
|
|
745
755
|
const groupId = reader.readVarInt();
|
|
746
756
|
const publisherPriority = reader.readUint8();
|
|
747
|
-
return { type: "stream_header_group",
|
|
757
|
+
return { type: "stream_header_group", trackAlias, groupId, publisherPriority };
|
|
748
758
|
}
|
|
749
759
|
|
|
750
760
|
function decodeStreamHeaderSubgroup(reader: BufferReader): StreamHeaderSubgroup {
|
|
751
|
-
const subscribeId = reader.readVarInt();
|
|
752
761
|
const trackAlias = reader.readVarInt();
|
|
753
762
|
const groupId = reader.readVarInt();
|
|
754
763
|
const subgroupId = reader.readVarInt();
|
|
755
764
|
const publisherPriority = reader.readUint8();
|
|
756
765
|
return {
|
|
757
766
|
type: "stream_header_subgroup",
|
|
758
|
-
subscribeId,
|
|
759
767
|
trackAlias,
|
|
760
768
|
groupId,
|
|
761
769
|
subgroupId,
|
|
@@ -46,7 +46,6 @@ export const CLIENT_ONLY_MESSAGES: ReadonlySet<MoqtMessageType> = new Set([
|
|
|
46
46
|
"unannounce",
|
|
47
47
|
"subscribe_announces",
|
|
48
48
|
"unsubscribe_announces",
|
|
49
|
-
"max_subscribe_id",
|
|
50
49
|
"fetch",
|
|
51
50
|
"fetch_cancel",
|
|
52
51
|
"track_status_request",
|
|
@@ -67,6 +66,7 @@ export const SERVER_ONLY_MESSAGES: ReadonlySet<MoqtMessageType> = new Set([
|
|
|
67
66
|
"fetch_ok",
|
|
68
67
|
"fetch_error",
|
|
69
68
|
"track_status",
|
|
69
|
+
"goaway",
|
|
70
70
|
]);
|
|
71
71
|
|
|
72
72
|
// Messages legal in each session phase -- for outbound validation
|
|
@@ -81,8 +81,6 @@ export function getLegalOutgoing(phase: string, role: "client" | "server"): Set<
|
|
|
81
81
|
if (role === "server") legal.add("server_setup");
|
|
82
82
|
break;
|
|
83
83
|
case "ready": {
|
|
84
|
-
// Both roles can send goaway
|
|
85
|
-
legal.add("goaway");
|
|
86
84
|
const roleMessages = role === "client" ? CLIENT_ONLY_MESSAGES : SERVER_ONLY_MESSAGES;
|
|
87
85
|
for (const msg of roleMessages) {
|
|
88
86
|
if (msg !== "client_setup" && msg !== "server_setup") {
|