@moqtap/codec 0.2.3 → 0.4.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/LICENSE +21 -21
- package/README.md +100 -99
- package/dist/{chunk-RZHAPEXO.js → chunk-2A57DRXV.js} +36 -10
- package/dist/{chunk-73MWUKSJ.js → chunk-2UTVXWFF.js} +190 -102
- package/dist/{chunk-JTVCOMBI.cjs → chunk-3XKO6PCR.cjs} +290 -183
- package/dist/{chunk-ACQ4CUJP.cjs → chunk-4BDEU3D4.cjs} +237 -158
- package/dist/{chunk-4N4INRE7.cjs → chunk-4HBKHNU2.cjs} +144 -110
- package/dist/{chunk-2ZT6CVSE.js → chunk-4IVZZOY3.js} +269 -162
- package/dist/{chunk-GLBQDG4L.cjs → chunk-5O764MBD.cjs} +508 -117
- package/dist/chunk-7KBAWOBA.js +1212 -0
- package/dist/{chunk-JSQM2MG3.js → chunk-7QOPNSDF.js} +44 -12
- package/dist/{chunk-SYHW3FLI.cjs → chunk-7RE6KSIY.cjs} +28 -8
- package/dist/{chunk-YG5KJESI.js → chunk-AY6IAHUM.js} +28 -8
- package/dist/{chunk-EFM5T7OM.js → chunk-BLQDWOSG.js} +36 -10
- package/dist/{chunk-UYXTY6ZQ.cjs → chunk-E65QKRSN.cjs} +20 -12
- package/dist/{chunk-BISI45MN.cjs → chunk-EAHE3IOG.cjs} +44 -12
- package/dist/{chunk-PZBPH2D7.js → chunk-GCBFHZW6.js} +216 -137
- package/dist/{chunk-GXEW4COZ.cjs → chunk-H5NSL4MO.cjs} +36 -10
- package/dist/chunk-HZHSO7EW.cjs +1212 -0
- package/dist/{chunk-KZCYQ7ED.cjs → chunk-IILNSDEQ.cjs} +69 -41
- package/dist/{chunk-4XYGE53S.cjs → chunk-J3XCPBW3.cjs} +36 -10
- package/dist/{chunk-6AEHWULA.cjs → chunk-JKOEJZ5B.cjs} +28 -8
- package/dist/{chunk-RUPCJTC3.cjs → chunk-JL3NEW3O.cjs} +23 -1
- package/dist/{chunk-G7GI7LJA.js → chunk-LORZMJJB.js} +36 -10
- package/dist/{chunk-DUBCL3WF.cjs → chunk-LV5C6MEC.cjs} +36 -10
- package/dist/{chunk-ENURAVHI.cjs → chunk-MYXAD5JC.cjs} +44 -12
- package/dist/{chunk-FXZ2MYKJ.js → chunk-MZ7HUCGJ.js} +20 -12
- package/dist/{chunk-S74DWJE2.cjs → chunk-OKG2HT25.cjs} +277 -88
- package/dist/{chunk-BGWGVINJ.cjs → chunk-PKEOQSSZ.cjs} +144 -110
- package/dist/{chunk-2GODRVT5.js → chunk-Q46ZURKX.js} +325 -48
- package/dist/{chunk-UR6JKS56.js → chunk-Q7IGWV3P.js} +41 -9
- package/dist/{chunk-XSNX2IUJ.js → chunk-RW4UG7CN.js} +121 -87
- package/dist/{chunk-DWK5ZQZ4.js → chunk-RZTLQAKF.js} +28 -8
- package/dist/{chunk-UNS34PTA.cjs → chunk-S6IPIN66.cjs} +44 -12
- package/dist/{chunk-YIG2C3LF.cjs → chunk-SDWRXXOO.cjs} +214 -126
- package/dist/{chunk-CEH7ESNC.js → chunk-SHMA4PBY.js} +121 -87
- package/dist/{chunk-MC7W6PMI.js → chunk-U3ZVLT5L.js} +483 -135
- package/dist/{chunk-VJUUZ4W2.cjs → chunk-UJU63EFY.cjs} +374 -97
- package/dist/{chunk-7L43FE6P.js → chunk-VOU7PNHI.js} +23 -1
- package/dist/{chunk-E6E3NQYU.js → chunk-WRHGCVYN.js} +44 -12
- package/dist/{chunk-FPISPJ5N.cjs → chunk-XNWYLVGU.cjs} +529 -181
- package/dist/{chunk-U3IPZYPX.js → chunk-XS77RBY7.js} +228 -39
- package/dist/{chunk-JGG7CMSZ.cjs → chunk-XZE5R57R.cjs} +144 -110
- package/dist/{chunk-77MNXX3M.js → chunk-Y6KCSM3V.js} +121 -87
- package/dist/{chunk-TLYNOOQP.cjs → chunk-YTPZZI2M.cjs} +41 -9
- package/dist/{chunk-7DUBLRXC.js → chunk-YWRCSQBA.js} +44 -12
- package/dist/{chunk-MRJWLGYH.js → chunk-Z3VKP3PJ.js} +69 -41
- package/dist/{chunk-E6P74GDT.js → chunk-Z6U26IRI.js} +464 -73
- package/dist/{codec-FvGCxIhr.d.ts → codec-25u4_1HS.d.ts} +4 -4
- package/dist/{codec-DRcsBCsb.d.ts → codec-3Ppy_5Gd.d.ts} +4 -4
- package/dist/{codec-BdVMRMOI.d.ts → codec-BB0U8MF2.d.cts} +4 -4
- package/dist/{codec-B2cH-f5V.d.cts → codec-BHHfBTnV.d.ts} +4 -4
- package/dist/{codec-B5K73Bdj.d.ts → codec-BN6jk0Td.d.cts} +4 -4
- package/dist/{codec-R8GrCPt2.d.ts → codec-BU0gaSZm.d.ts} +4 -4
- package/dist/{codec-Bq-tLtfP.d.ts → codec-C-Yk2RNa.d.ts} +4 -4
- package/dist/codec-CFWQY9Lj.d.cts +18 -0
- package/dist/{codec-CPlK3Pi5.d.ts → codec-COy4uuPO.d.cts} +4 -4
- package/dist/codec-CewFCsEy.d.ts +18 -0
- package/dist/{codec-KXHvXZVb.d.cts → codec-Ck7ZwFF1.d.cts} +4 -4
- package/dist/{codec-DZhZSIii.d.cts → codec-D2QVSH9D.d.ts} +4 -4
- package/dist/{codec-BwFgpeQu.d.ts → codec-DDUBJGn0.d.cts} +4 -4
- package/dist/{codec-BFeliJFc.d.ts → codec-DNfml-se.d.ts} +4 -4
- package/dist/{codec-C4n1PS09.d.cts → codec-DoOGjjDq.d.cts} +4 -4
- package/dist/{codec-Bap882Fh.d.cts → codec-J7ekOSMc.d.ts} +4 -4
- package/dist/{codec-SKBeHQk7.d.ts → codec-R9TJCq-E.d.cts} +4 -4
- package/dist/{codec-DNUIgLqc.d.cts → codec-ZwV-Njt6.d.ts} +4 -4
- package/dist/{codec-HgBgHkFI.d.cts → codec-j819z_hL.d.cts} +4 -4
- package/dist/{codec-DY4QH364.d.cts → codec-w8z2j_uo.d.cts} +4 -4
- package/dist/{codec-CPvPq0sb.d.cts → codec-wtt6WF1K.d.ts} +4 -4
- package/dist/{codec-BUMjz0J4.d.cts → codec-z6_2PSzi.d.cts} +4 -4
- package/dist/{draft7-session.cjs → draft07-session.cjs} +2 -2
- package/dist/draft07-session.d.cts +8 -0
- package/dist/draft07-session.d.ts +8 -0
- package/dist/{draft7-session.js → draft07-session.js} +1 -1
- package/dist/draft07.cjs +129 -0
- package/dist/draft07.d.cts +67 -0
- package/dist/draft07.d.ts +67 -0
- package/dist/draft07.js +129 -0
- package/dist/draft08-session.cjs +6 -0
- package/dist/draft08-session.d.cts +8 -0
- package/dist/draft08-session.d.ts +8 -0
- package/dist/{draft8-session.js → draft08-session.js} +1 -1
- package/dist/draft08.cjs +119 -0
- package/dist/{draft8.d.cts → draft08.d.cts} +15 -13
- package/dist/{draft8.d.ts → draft08.d.ts} +15 -13
- package/dist/{draft8.js → draft08.js} +7 -4
- package/dist/draft09-session.cjs +6 -0
- package/dist/draft09-session.d.cts +8 -0
- package/dist/draft09-session.d.ts +8 -0
- package/dist/{draft9-session.js → draft09-session.js} +1 -1
- package/dist/draft09.cjs +119 -0
- package/dist/{draft9.d.cts → draft09.d.cts} +15 -13
- package/dist/{draft9.d.ts → draft09.d.ts} +15 -13
- package/dist/{draft9.js → draft09.js} +7 -4
- package/dist/draft10-session.cjs +2 -2
- package/dist/draft10-session.d.cts +6 -6
- package/dist/draft10-session.d.ts +6 -6
- package/dist/draft10-session.js +1 -1
- package/dist/draft10.cjs +8 -5
- package/dist/draft10.d.cts +14 -12
- package/dist/draft10.d.ts +14 -12
- package/dist/draft10.js +16 -13
- package/dist/draft11-session.cjs +2 -2
- package/dist/draft11-session.d.cts +6 -6
- package/dist/draft11-session.d.ts +6 -6
- package/dist/draft11-session.js +1 -1
- package/dist/draft11.cjs +8 -5
- package/dist/draft11.d.cts +14 -12
- package/dist/draft11.d.ts +14 -12
- package/dist/draft11.js +16 -13
- package/dist/draft12-session.cjs +2 -2
- package/dist/draft12-session.d.cts +6 -6
- package/dist/draft12-session.d.ts +6 -6
- package/dist/draft12-session.js +1 -1
- package/dist/draft12.cjs +8 -5
- package/dist/draft12.d.cts +16 -14
- package/dist/draft12.d.ts +16 -14
- package/dist/draft12.js +16 -13
- package/dist/draft13-session.cjs +2 -2
- package/dist/draft13-session.d.cts +6 -6
- package/dist/draft13-session.d.ts +6 -6
- package/dist/draft13-session.js +1 -1
- package/dist/draft13.cjs +8 -5
- package/dist/draft13.d.cts +16 -14
- package/dist/draft13.d.ts +16 -14
- package/dist/draft13.js +16 -13
- package/dist/draft14-session.cjs +2 -2
- package/dist/draft14-session.d.cts +6 -6
- package/dist/draft14-session.d.ts +6 -6
- package/dist/draft14-session.js +1 -1
- package/dist/draft14.cjs +14 -5
- package/dist/draft14.d.cts +14 -12
- package/dist/draft14.d.ts +14 -12
- package/dist/draft14.js +13 -4
- package/dist/draft15-session.cjs +2 -2
- package/dist/draft15-session.d.cts +6 -6
- package/dist/draft15-session.d.ts +6 -6
- package/dist/draft15-session.js +1 -1
- package/dist/draft15.cjs +8 -5
- package/dist/draft15.d.cts +14 -12
- package/dist/draft15.d.ts +14 -12
- package/dist/draft15.js +16 -13
- package/dist/draft16-session.cjs +2 -2
- package/dist/draft16-session.d.cts +6 -6
- package/dist/draft16-session.d.ts +6 -6
- package/dist/draft16-session.js +1 -1
- package/dist/draft16.cjs +8 -5
- package/dist/draft16.d.cts +14 -12
- package/dist/draft16.d.ts +14 -12
- package/dist/draft16.js +16 -13
- package/dist/draft17-session.cjs +2 -2
- package/dist/draft17-session.d.cts +7 -7
- package/dist/draft17-session.d.ts +7 -7
- package/dist/draft17-session.js +1 -1
- package/dist/draft17.cjs +8 -5
- package/dist/draft17.d.cts +11 -9
- package/dist/draft17.d.ts +11 -9
- package/dist/draft17.js +16 -13
- package/dist/index.cjs +52 -74
- package/dist/index.d.cts +41 -60
- package/dist/index.d.ts +41 -60
- package/dist/index.js +40 -62
- package/dist/{session-types-CJIFbTPd.d.ts → session-types-C7UONex5.d.cts} +28 -27
- package/dist/{session-types-Cbq8IGCP.d.cts → session-types-X-IYEGoG.d.ts} +28 -27
- package/dist/session.cjs +46 -13
- package/dist/session.d.cts +29 -11
- package/dist/session.d.ts +29 -11
- package/dist/session.js +46 -13
- package/dist/{types-DxSFvL2b.d.cts → types--Q7_DcvP.d.cts} +43 -39
- package/dist/{types-DxSFvL2b.d.ts → types--Q7_DcvP.d.ts} +43 -39
- package/dist/{types-B0FT5Qs2.d.cts → types-0IWbU9Z_.d.cts} +36 -36
- package/dist/{types-B0FT5Qs2.d.ts → types-0IWbU9Z_.d.ts} +36 -36
- package/dist/{types-gQsr0AAA.d.cts → types-B3g5G9KP.d.cts} +36 -36
- package/dist/{types-gQsr0AAA.d.ts → types-B3g5G9KP.d.ts} +36 -36
- package/dist/{types-Pme7sua0.d.cts → types-BFpFNM_m.d.cts} +57 -32
- package/dist/{types-Pme7sua0.d.ts → types-BFpFNM_m.d.ts} +57 -32
- package/dist/{types-8gUGeMgs.d.cts → types-Br7fm2mf.d.cts} +48 -26
- package/dist/{types-8gUGeMgs.d.ts → types-Br7fm2mf.d.ts} +48 -26
- package/dist/{types-BeAVNU-F.d.cts → types-C2qKTRR_.d.cts} +50 -45
- package/dist/{types-BeAVNU-F.d.ts → types-C2qKTRR_.d.ts} +50 -45
- package/dist/{types-DKpsfD3i.d.cts → types-DEaypVsD.d.cts} +115 -55
- package/dist/{types-DKpsfD3i.d.ts → types-DEaypVsD.d.ts} +115 -55
- package/dist/types-Dl4IaAHR.d.cts +282 -0
- package/dist/types-Dl4IaAHR.d.ts +282 -0
- package/dist/{types-CDa7F5ct.d.cts → types-DrQpTW1G.d.cts} +58 -50
- package/dist/{types-CDa7F5ct.d.ts → types-DrQpTW1G.d.ts} +58 -50
- package/dist/types-DuIO7cWK.d.cts +25 -0
- package/dist/types-DuIO7cWK.d.ts +25 -0
- package/dist/{types-B9A2g05r.d.cts → types-DuxfOYiO.d.cts} +47 -31
- package/dist/{types-B9A2g05r.d.ts → types-DuxfOYiO.d.ts} +47 -31
- package/dist/{types-D1dI_oTX.d.cts → types-jV1yDDBA.d.cts} +36 -36
- package/dist/{types-D1dI_oTX.d.ts → types-jV1yDDBA.d.ts} +36 -36
- package/package.json +192 -192
- package/src/core/buffer-reader.ts +130 -130
- package/src/core/buffer-writer.ts +100 -100
- package/src/core/errors.ts +1 -1
- package/src/core/hex.ts +21 -21
- package/src/core/session-types.ts +61 -59
- package/src/core/types.ts +18 -361
- package/src/drafts/draft07/codec.ts +1058 -938
- package/src/drafts/draft07/data-streams.ts +240 -240
- package/src/drafts/draft07/index.ts +124 -89
- package/src/drafts/draft07/messages.ts +76 -42
- package/src/drafts/draft07/rules.ts +107 -101
- package/src/drafts/draft07/session-fsm.ts +315 -287
- package/src/drafts/draft07/session.ts +8 -6
- package/src/drafts/draft07/types.ts +406 -72
- package/src/drafts/draft07/varint.ts +51 -51
- package/src/drafts/draft08/codec.ts +985 -953
- package/src/drafts/draft08/data-streams.ts +363 -359
- package/src/drafts/draft08/index.ts +10 -9
- package/src/drafts/draft08/messages.ts +59 -59
- package/src/drafts/draft08/rules.ts +73 -73
- package/src/drafts/draft08/session-fsm.ts +335 -303
- package/src/drafts/draft08/session.ts +6 -7
- package/src/drafts/draft08/types.ts +380 -384
- package/src/drafts/draft09/codec.ts +977 -945
- package/src/drafts/draft09/data-streams.ts +336 -332
- package/src/drafts/draft09/index.ts +10 -9
- package/src/drafts/draft09/messages.ts +59 -59
- package/src/drafts/draft09/rules.ts +73 -73
- package/src/drafts/draft09/session-fsm.ts +335 -303
- package/src/drafts/draft09/session.ts +6 -7
- package/src/drafts/draft09/types.ts +380 -384
- package/src/drafts/draft10/codec.ts +977 -945
- package/src/drafts/draft10/data-streams.ts +336 -332
- package/src/drafts/draft10/index.ts +10 -9
- package/src/drafts/draft10/messages.ts +59 -59
- package/src/drafts/draft10/rules.ts +73 -73
- package/src/drafts/draft10/session-fsm.ts +335 -303
- package/src/drafts/draft10/session.ts +6 -7
- package/src/drafts/draft10/types.ts +380 -384
- package/src/drafts/draft11/codec.ts +1054 -988
- package/src/drafts/draft11/data-streams.ts +316 -269
- package/src/drafts/draft11/index.ts +10 -9
- package/src/drafts/draft11/messages.ts +60 -59
- package/src/drafts/draft11/rules.ts +73 -73
- package/src/drafts/draft11/session-fsm.ts +359 -333
- package/src/drafts/draft11/session.ts +6 -7
- package/src/drafts/draft11/types.ts +385 -381
- package/src/drafts/draft12/codec.ts +1178 -1122
- package/src/drafts/draft12/data-streams.ts +324 -275
- package/src/drafts/draft12/index.ts +10 -9
- package/src/drafts/draft12/messages.ts +67 -66
- package/src/drafts/draft12/rules.ts +79 -79
- package/src/drafts/draft12/session-fsm.ts +384 -358
- package/src/drafts/draft12/session.ts +6 -7
- package/src/drafts/draft12/types.ts +424 -419
- package/src/drafts/draft13/codec.ts +1296 -1206
- package/src/drafts/draft13/data-streams.ts +326 -275
- package/src/drafts/draft13/index.ts +10 -9
- package/src/drafts/draft13/messages.ts +73 -68
- package/src/drafts/draft13/rules.ts +81 -81
- package/src/drafts/draft13/session-fsm.ts +392 -366
- package/src/drafts/draft13/session.ts +6 -7
- package/src/drafts/draft13/types.ts +447 -438
- package/src/drafts/draft14/codec.ts +1347 -1043
- package/src/drafts/draft14/data-streams.ts +831 -813
- package/src/drafts/draft14/index.ts +17 -9
- package/src/drafts/draft14/messages.ts +65 -65
- package/src/drafts/draft14/rules.ts +81 -81
- package/src/drafts/draft14/session-fsm.ts +415 -405
- package/src/drafts/draft14/session.ts +6 -7
- package/src/drafts/draft14/types.ts +451 -381
- package/src/drafts/draft15/codec.ts +1138 -978
- package/src/drafts/draft15/data-streams.ts +842 -794
- package/src/drafts/draft15/index.ts +10 -9
- package/src/drafts/draft15/messages.ts +54 -53
- package/src/drafts/draft15/rules.ts +67 -67
- package/src/drafts/draft15/session-fsm.ts +319 -299
- package/src/drafts/draft15/session.ts +6 -7
- package/src/drafts/draft15/types.ts +357 -339
- package/src/drafts/draft16/codec.ts +1242 -966
- package/src/drafts/draft16/data-streams.ts +835 -789
- package/src/drafts/draft16/index.ts +10 -9
- package/src/drafts/draft16/messages.ts +56 -55
- package/src/drafts/draft16/rules.ts +69 -69
- package/src/drafts/draft16/session-fsm.ts +319 -299
- package/src/drafts/draft16/session.ts +6 -7
- package/src/drafts/draft16/types.ts +386 -357
- package/src/drafts/draft17/codec.ts +1209 -971
- package/src/drafts/draft17/data-streams.ts +969 -758
- package/src/drafts/draft17/index.ts +9 -7
- package/src/drafts/draft17/messages.ts +43 -42
- package/src/drafts/draft17/rules.ts +58 -58
- package/src/drafts/draft17/session-fsm.ts +248 -216
- package/src/drafts/draft17/session.ts +5 -5
- package/src/drafts/draft17/types.ts +337 -313
- package/src/index.ts +85 -274
- package/src/session.ts +63 -25
- package/dist/chunk-FZDIEHQL.cjs +0 -1042
- package/dist/chunk-HDWJ2GDE.js +0 -24
- package/dist/chunk-KNDYS3DK.cjs +0 -24
- package/dist/chunk-N2KBF5Q2.js +0 -1042
- package/dist/draft7-session.d.cts +0 -7
- package/dist/draft7-session.d.ts +0 -7
- package/dist/draft7.cjs +0 -72
- package/dist/draft7.d.cts +0 -148
- package/dist/draft7.d.ts +0 -148
- package/dist/draft7.js +0 -72
- package/dist/draft8-session.cjs +0 -6
- package/dist/draft8-session.d.cts +0 -8
- package/dist/draft8-session.d.ts +0 -8
- package/dist/draft8.cjs +0 -116
- package/dist/draft9-session.cjs +0 -6
- package/dist/draft9-session.d.cts +0 -8
- package/dist/draft9-session.d.ts +0 -8
- package/dist/draft9.cjs +0 -116
- package/dist/types-QNXoxC9Y.d.cts +0 -236
- package/dist/types-QNXoxC9Y.d.ts +0 -236
- package/src/drafts/draft07/announce-fsm.ts +0 -2
- package/src/drafts/draft07/parameters.ts +0 -12
- package/src/drafts/draft07/subscription-fsm.ts +0 -3
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunkKNDYS3DKcjs = require('./chunk-KNDYS3DK.cjs');
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
var _chunkRUPCJTC3cjs = require('./chunk-RUPCJTC3.cjs');
|
|
7
|
+
var _chunkJL3NEW3Ocjs = require('./chunk-JL3NEW3O.cjs');
|
|
10
8
|
|
|
11
9
|
// src/drafts/draft16/messages.ts
|
|
12
10
|
var MSG_REQUEST_UPDATE = 0x02n;
|
|
@@ -35,6 +33,7 @@ var MSG_CLIENT_SETUP = 0x20n;
|
|
|
35
33
|
var MSG_SERVER_SETUP = 0x21n;
|
|
36
34
|
var SETUP_PARAM_PATH = 0x01n;
|
|
37
35
|
var SETUP_PARAM_MAX_REQUEST_ID = 0x02n;
|
|
36
|
+
var SETUP_PARAM_AUTHORIZATION_TOKEN = 0x03n;
|
|
38
37
|
var SETUP_PARAM_MAX_AUTH_TOKEN_CACHE_SIZE = 0x04n;
|
|
39
38
|
var SETUP_PARAM_AUTHORITY = 0x05n;
|
|
40
39
|
var SETUP_PARAM_MOQT_IMPLEMENTATION = 0x07n;
|
|
@@ -71,7 +70,7 @@ var MESSAGE_ID_MAP = new Map(
|
|
|
71
70
|
// src/drafts/draft16/data-streams.ts
|
|
72
71
|
var FETCH_STREAM_TYPE = 0x05n;
|
|
73
72
|
function encodeSubgroupStream(stream) {
|
|
74
|
-
const w = new (0,
|
|
73
|
+
const w = new (0, _chunkJL3NEW3Ocjs.BufferWriter)();
|
|
75
74
|
const streamType = stream.headerType;
|
|
76
75
|
w.writeVarInt(BigInt(streamType));
|
|
77
76
|
const extensionsPresent = (streamType & 1) !== 0;
|
|
@@ -104,17 +103,26 @@ function encodeSubgroupStream(stream) {
|
|
|
104
103
|
return w.finish();
|
|
105
104
|
}
|
|
106
105
|
function encodeDatagram(dg) {
|
|
107
|
-
const w = new (0,
|
|
106
|
+
const w = new (0, _chunkJL3NEW3Ocjs.BufferWriter)();
|
|
108
107
|
const dgType = dg.datagramType;
|
|
109
108
|
w.writeVarInt(BigInt(dgType));
|
|
110
109
|
w.writeVarInt(dg.trackAlias);
|
|
111
110
|
w.writeVarInt(dg.groupId);
|
|
111
|
+
const extensionsPresent = (dgType & 1) !== 0;
|
|
112
112
|
const objectIdAbsent = (dgType & 4) !== 0;
|
|
113
|
+
const defaultPriority = (dgType & 8) !== 0;
|
|
113
114
|
const isStatus = (dgType & 32) !== 0;
|
|
114
115
|
if (!objectIdAbsent) {
|
|
115
116
|
w.writeVarInt(dg.objectId);
|
|
116
117
|
}
|
|
117
|
-
|
|
118
|
+
if (!defaultPriority) {
|
|
119
|
+
w.writeUint8(dg.publisherPriority);
|
|
120
|
+
}
|
|
121
|
+
if (extensionsPresent) {
|
|
122
|
+
const extData = _nullishCoalesce(dg.extensionData, () => ( new Uint8Array(0)));
|
|
123
|
+
w.writeVarInt(BigInt(extData.length));
|
|
124
|
+
if (extData.length > 0) w.writeBytes(extData);
|
|
125
|
+
}
|
|
118
126
|
if (isStatus) {
|
|
119
127
|
w.writeVarInt(_nullishCoalesce(dg.objectStatus, () => ( 0n)));
|
|
120
128
|
} else {
|
|
@@ -123,7 +131,7 @@ function encodeDatagram(dg) {
|
|
|
123
131
|
return w.finish();
|
|
124
132
|
}
|
|
125
133
|
function encodeFetchStream(stream) {
|
|
126
|
-
const w = new (0,
|
|
134
|
+
const w = new (0, _chunkJL3NEW3Ocjs.BufferWriter)();
|
|
127
135
|
w.writeVarInt(FETCH_STREAM_TYPE);
|
|
128
136
|
w.writeVarInt(stream.requestId);
|
|
129
137
|
for (const obj of stream.objects) {
|
|
@@ -153,14 +161,14 @@ function encodeFetchStream(stream) {
|
|
|
153
161
|
}
|
|
154
162
|
function decodeSubgroupStream(bytes) {
|
|
155
163
|
try {
|
|
156
|
-
const r = new (0,
|
|
164
|
+
const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes);
|
|
157
165
|
const streamType = Number(r.readVarInt());
|
|
158
|
-
if (!(streamType >= 16 && streamType <=
|
|
166
|
+
if (!(streamType >= 16 && streamType <= 31 || streamType >= 48 && streamType <= 63) || (streamType & 6) === 6) {
|
|
159
167
|
return {
|
|
160
168
|
ok: false,
|
|
161
|
-
error: new (0,
|
|
169
|
+
error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
162
170
|
"CONSTRAINT_VIOLATION",
|
|
163
|
-
`Expected subgroup stream type 0x10-
|
|
171
|
+
`Expected subgroup stream type 0x10-0x1F/0x30-0x3F, got 0x${streamType.toString(16)}`,
|
|
164
172
|
0
|
|
165
173
|
)
|
|
166
174
|
};
|
|
@@ -168,6 +176,7 @@ function decodeSubgroupStream(bytes) {
|
|
|
168
176
|
const extensionsPresent = (streamType & 1) !== 0;
|
|
169
177
|
const hasSubgroupField = (streamType & 4) !== 0;
|
|
170
178
|
const subgroupIsFirstObjId = (streamType & 2) !== 0 && !hasSubgroupField;
|
|
179
|
+
const endOfGroup = (streamType & 8) !== 0;
|
|
171
180
|
const hasPriority = streamType < 48;
|
|
172
181
|
const trackAlias = r.readVarInt();
|
|
173
182
|
const groupId = r.readVarInt();
|
|
@@ -212,35 +221,47 @@ function decodeSubgroupStream(bytes) {
|
|
|
212
221
|
payloadByteOffset = r.offset;
|
|
213
222
|
payload = r.readBytesView(payloadLength);
|
|
214
223
|
}
|
|
215
|
-
const obj = {
|
|
224
|
+
const obj = {
|
|
225
|
+
type: "object",
|
|
226
|
+
byteOffset,
|
|
227
|
+
payloadByteOffset,
|
|
228
|
+
objectId,
|
|
229
|
+
payloadLength,
|
|
230
|
+
extensionData,
|
|
231
|
+
payload
|
|
232
|
+
};
|
|
216
233
|
if (status !== void 0) obj.status = status;
|
|
217
234
|
objects.push(obj);
|
|
218
235
|
prevObjectId = objectId;
|
|
219
236
|
}
|
|
237
|
+
const result = {
|
|
238
|
+
type: "subgroup",
|
|
239
|
+
headerType: streamType,
|
|
240
|
+
trackAlias,
|
|
241
|
+
groupId,
|
|
242
|
+
subgroupId,
|
|
243
|
+
publisherPriority,
|
|
244
|
+
objects
|
|
245
|
+
};
|
|
246
|
+
if (endOfGroup) result.endOfGroup = true;
|
|
220
247
|
return {
|
|
221
248
|
ok: true,
|
|
222
|
-
value:
|
|
223
|
-
type: "subgroup",
|
|
224
|
-
headerType: streamType,
|
|
225
|
-
trackAlias,
|
|
226
|
-
groupId,
|
|
227
|
-
subgroupId,
|
|
228
|
-
publisherPriority,
|
|
229
|
-
objects
|
|
230
|
-
},
|
|
249
|
+
value: result,
|
|
231
250
|
bytesRead: r.offset
|
|
232
251
|
};
|
|
233
252
|
} catch (e) {
|
|
234
|
-
if (e instanceof
|
|
253
|
+
if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) return { ok: false, error: e };
|
|
235
254
|
throw e;
|
|
236
255
|
}
|
|
237
256
|
}
|
|
238
257
|
function decodeDatagram(bytes) {
|
|
239
258
|
try {
|
|
240
|
-
const r = new (0,
|
|
259
|
+
const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes);
|
|
241
260
|
const dgType = Number(r.readVarInt());
|
|
261
|
+
const extensionsPresent = (dgType & 1) !== 0;
|
|
242
262
|
const objectIdAbsent = (dgType & 4) !== 0;
|
|
243
263
|
const endOfGroup = (dgType & 2) !== 0;
|
|
264
|
+
const defaultPriority = (dgType & 8) !== 0;
|
|
244
265
|
const isStatus = (dgType & 32) !== 0;
|
|
245
266
|
const trackAlias = r.readVarInt();
|
|
246
267
|
const groupId = r.readVarInt();
|
|
@@ -248,7 +269,15 @@ function decodeDatagram(bytes) {
|
|
|
248
269
|
if (!objectIdAbsent) {
|
|
249
270
|
objectId = r.readVarInt();
|
|
250
271
|
}
|
|
251
|
-
|
|
272
|
+
let publisherPriority = 128;
|
|
273
|
+
if (!defaultPriority) {
|
|
274
|
+
publisherPriority = r.readUint8();
|
|
275
|
+
}
|
|
276
|
+
let extensionData;
|
|
277
|
+
if (extensionsPresent) {
|
|
278
|
+
const extLen = Number(r.readVarInt());
|
|
279
|
+
extensionData = extLen > 0 ? r.readBytesView(extLen) : new Uint8Array(0);
|
|
280
|
+
}
|
|
252
281
|
let objectStatus;
|
|
253
282
|
let payload;
|
|
254
283
|
if (isStatus) {
|
|
@@ -271,20 +300,22 @@ function decodeDatagram(bytes) {
|
|
|
271
300
|
if (endOfGroup) result.endOfGroup = true;
|
|
272
301
|
if (objectStatus !== void 0)
|
|
273
302
|
result.objectStatus = objectStatus;
|
|
303
|
+
if (extensionData !== void 0)
|
|
304
|
+
result.extensionData = extensionData;
|
|
274
305
|
return { ok: true, value: result, bytesRead: r.offset };
|
|
275
306
|
} catch (e) {
|
|
276
|
-
if (e instanceof
|
|
307
|
+
if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) return { ok: false, error: e };
|
|
277
308
|
throw e;
|
|
278
309
|
}
|
|
279
310
|
}
|
|
280
311
|
function decodeFetchStream(bytes) {
|
|
281
312
|
try {
|
|
282
|
-
const r = new (0,
|
|
313
|
+
const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes);
|
|
283
314
|
const streamType = r.readVarInt();
|
|
284
315
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
285
316
|
return {
|
|
286
317
|
ok: false,
|
|
287
|
-
error: new (0,
|
|
318
|
+
error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
288
319
|
"CONSTRAINT_VIOLATION",
|
|
289
320
|
`Expected fetch stream type 0x05, got 0x${streamType.toString(16)}`,
|
|
290
321
|
0
|
|
@@ -310,7 +341,7 @@ function decodeFetchStream(bytes) {
|
|
|
310
341
|
if (flags !== 140 && flags !== 268) {
|
|
311
342
|
return {
|
|
312
343
|
ok: false,
|
|
313
|
-
error: new (0,
|
|
344
|
+
error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
314
345
|
"CONSTRAINT_VIOLATION",
|
|
315
346
|
`Unknown serialization flags value: 0x${flags.toString(16)}`,
|
|
316
347
|
r.offset
|
|
@@ -336,40 +367,32 @@ function decodeFetchStream(bytes) {
|
|
|
336
367
|
payload
|
|
337
368
|
});
|
|
338
369
|
} else {
|
|
339
|
-
const
|
|
370
|
+
const datagramForwarding = (flags & 64) !== 0;
|
|
371
|
+
const subgroupEncoding = datagramForwarding ? -1 : flags & 3;
|
|
340
372
|
const objectIdPresent = (flags & 4) !== 0;
|
|
341
373
|
const groupIdPresent = (flags & 8) !== 0;
|
|
342
374
|
const priorityPresent = (flags & 16) !== 0;
|
|
343
375
|
const extensionsPresent = (flags & 32) !== 0;
|
|
344
|
-
if (flags & 64) {
|
|
345
|
-
return {
|
|
346
|
-
ok: false,
|
|
347
|
-
error: new (0, _chunkRUPCJTC3cjs.DecodeError)(
|
|
348
|
-
"CONSTRAINT_VIOLATION",
|
|
349
|
-
"Reserved bits set in fetch object flags",
|
|
350
|
-
r.offset
|
|
351
|
-
)
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
376
|
if (groupIdPresent) {
|
|
355
377
|
groupId = r.readVarInt();
|
|
356
378
|
} else if (first) {
|
|
357
379
|
return {
|
|
358
380
|
ok: false,
|
|
359
|
-
error: new (0,
|
|
381
|
+
error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
360
382
|
"CONSTRAINT_VIOLATION",
|
|
361
383
|
"First fetch object must include groupId",
|
|
362
384
|
r.offset
|
|
363
385
|
)
|
|
364
386
|
};
|
|
365
387
|
}
|
|
366
|
-
if (
|
|
388
|
+
if (datagramForwarding) {
|
|
389
|
+
} else if (subgroupEncoding === 0) {
|
|
367
390
|
subgroupId = 0n;
|
|
368
391
|
} else if (subgroupEncoding === 1) {
|
|
369
392
|
if (first) {
|
|
370
393
|
return {
|
|
371
394
|
ok: false,
|
|
372
|
-
error: new (0,
|
|
395
|
+
error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
373
396
|
"CONSTRAINT_VIOLATION",
|
|
374
397
|
"First fetch object cannot reference prior subgroupId",
|
|
375
398
|
r.offset
|
|
@@ -380,7 +403,7 @@ function decodeFetchStream(bytes) {
|
|
|
380
403
|
if (first) {
|
|
381
404
|
return {
|
|
382
405
|
ok: false,
|
|
383
|
-
error: new (0,
|
|
406
|
+
error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
384
407
|
"CONSTRAINT_VIOLATION",
|
|
385
408
|
"First fetch object cannot reference prior subgroupId",
|
|
386
409
|
r.offset
|
|
@@ -396,7 +419,7 @@ function decodeFetchStream(bytes) {
|
|
|
396
419
|
} else if (first) {
|
|
397
420
|
return {
|
|
398
421
|
ok: false,
|
|
399
|
-
error: new (0,
|
|
422
|
+
error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
400
423
|
"CONSTRAINT_VIOLATION",
|
|
401
424
|
"First fetch object must include objectId",
|
|
402
425
|
r.offset
|
|
@@ -439,7 +462,7 @@ function decodeFetchStream(bytes) {
|
|
|
439
462
|
bytesRead: r.offset
|
|
440
463
|
};
|
|
441
464
|
} catch (e) {
|
|
442
|
-
if (e instanceof
|
|
465
|
+
if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) return { ok: false, error: e };
|
|
443
466
|
throw e;
|
|
444
467
|
}
|
|
445
468
|
}
|
|
@@ -477,11 +500,11 @@ function createSubgroupStreamDecoder() {
|
|
|
477
500
|
buffer = newBuffer;
|
|
478
501
|
if (!headerEmitted) {
|
|
479
502
|
try {
|
|
480
|
-
const r = new (0,
|
|
503
|
+
const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(buffer.subarray(offset));
|
|
481
504
|
const streamType = Number(r.readVarInt());
|
|
482
|
-
if (!(streamType >= 16 && streamType <=
|
|
505
|
+
if (!(streamType >= 16 && streamType <= 31 || streamType >= 48 && streamType <= 63)) {
|
|
483
506
|
controller.error(
|
|
484
|
-
new (0,
|
|
507
|
+
new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
485
508
|
"CONSTRAINT_VIOLATION",
|
|
486
509
|
`Expected subgroup stream type, got 0x${streamType.toString(16)}`,
|
|
487
510
|
0
|
|
@@ -513,7 +536,7 @@ function createSubgroupStreamDecoder() {
|
|
|
513
536
|
headerEmitted = true;
|
|
514
537
|
offset += r.offset;
|
|
515
538
|
} catch (e) {
|
|
516
|
-
if (e instanceof
|
|
539
|
+
if (e instanceof _chunkJL3NEW3Ocjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
517
540
|
return;
|
|
518
541
|
}
|
|
519
542
|
controller.error(e);
|
|
@@ -522,7 +545,7 @@ function createSubgroupStreamDecoder() {
|
|
|
522
545
|
}
|
|
523
546
|
while (offset < buffer.length) {
|
|
524
547
|
try {
|
|
525
|
-
const r = new (0,
|
|
548
|
+
const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(buffer.subarray(offset));
|
|
526
549
|
const delta = r.readVarInt();
|
|
527
550
|
let objectId;
|
|
528
551
|
if (firstObject) {
|
|
@@ -546,13 +569,21 @@ function createSubgroupStreamDecoder() {
|
|
|
546
569
|
payloadByteOffset = r.offset;
|
|
547
570
|
}
|
|
548
571
|
const payload = payloadLength > 0 ? r.readBytesView(payloadLength) : new Uint8Array(0);
|
|
549
|
-
const obj = {
|
|
572
|
+
const obj = {
|
|
573
|
+
type: "object",
|
|
574
|
+
byteOffset: 0,
|
|
575
|
+
payloadByteOffset,
|
|
576
|
+
objectId,
|
|
577
|
+
payloadLength,
|
|
578
|
+
payload,
|
|
579
|
+
extensionData
|
|
580
|
+
};
|
|
550
581
|
if (status !== void 0) obj.status = status;
|
|
551
582
|
controller.enqueue(obj);
|
|
552
583
|
offset += r.offset;
|
|
553
584
|
prevObjectId = objectId;
|
|
554
585
|
} catch (e) {
|
|
555
|
-
if (e instanceof
|
|
586
|
+
if (e instanceof _chunkJL3NEW3Ocjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
556
587
|
break;
|
|
557
588
|
}
|
|
558
589
|
controller.error(e);
|
|
@@ -562,7 +593,7 @@ function createSubgroupStreamDecoder() {
|
|
|
562
593
|
},
|
|
563
594
|
flush(controller) {
|
|
564
595
|
if (offset < buffer.length) {
|
|
565
|
-
controller.error(new (0,
|
|
596
|
+
controller.error(new (0, _chunkJL3NEW3Ocjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
566
597
|
}
|
|
567
598
|
}
|
|
568
599
|
});
|
|
@@ -583,11 +614,11 @@ function createFetchStreamDecoder() {
|
|
|
583
614
|
buffer = newBuffer;
|
|
584
615
|
if (!headerEmitted) {
|
|
585
616
|
try {
|
|
586
|
-
const r = new (0,
|
|
617
|
+
const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(buffer.subarray(offset));
|
|
587
618
|
const streamType = r.readVarInt();
|
|
588
619
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
589
620
|
controller.error(
|
|
590
|
-
new (0,
|
|
621
|
+
new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
591
622
|
"CONSTRAINT_VIOLATION",
|
|
592
623
|
`Expected fetch stream type 0x05, got 0x${streamType.toString(16)}`,
|
|
593
624
|
0
|
|
@@ -600,7 +631,7 @@ function createFetchStreamDecoder() {
|
|
|
600
631
|
headerEmitted = true;
|
|
601
632
|
offset += r.offset;
|
|
602
633
|
} catch (e) {
|
|
603
|
-
if (e instanceof
|
|
634
|
+
if (e instanceof _chunkJL3NEW3Ocjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
604
635
|
return;
|
|
605
636
|
}
|
|
606
637
|
controller.error(e);
|
|
@@ -609,7 +640,7 @@ function createFetchStreamDecoder() {
|
|
|
609
640
|
}
|
|
610
641
|
while (offset < buffer.length) {
|
|
611
642
|
try {
|
|
612
|
-
const r = new (0,
|
|
643
|
+
const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(buffer.subarray(offset));
|
|
613
644
|
const flags = Number(r.readVarInt());
|
|
614
645
|
const objectIdPresent = (flags & 4) !== 0;
|
|
615
646
|
const groupIdPresent = (flags & 8) !== 0;
|
|
@@ -629,10 +660,18 @@ function createFetchStreamDecoder() {
|
|
|
629
660
|
const payloadLength = Number(r.readVarInt());
|
|
630
661
|
const payloadByteOffset = r.offset;
|
|
631
662
|
const payload = payloadLength > 0 ? r.readBytesView(payloadLength) : new Uint8Array(0);
|
|
632
|
-
controller.enqueue({
|
|
663
|
+
controller.enqueue({
|
|
664
|
+
type: "object",
|
|
665
|
+
byteOffset: 0,
|
|
666
|
+
payloadByteOffset,
|
|
667
|
+
objectId,
|
|
668
|
+
payloadLength,
|
|
669
|
+
payload,
|
|
670
|
+
extensionData
|
|
671
|
+
});
|
|
633
672
|
offset += r.offset;
|
|
634
673
|
} catch (e) {
|
|
635
|
-
if (e instanceof
|
|
674
|
+
if (e instanceof _chunkJL3NEW3Ocjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
636
675
|
break;
|
|
637
676
|
}
|
|
638
677
|
controller.error(e);
|
|
@@ -642,7 +681,7 @@ function createFetchStreamDecoder() {
|
|
|
642
681
|
},
|
|
643
682
|
flush(controller) {
|
|
644
683
|
if (offset < buffer.length) {
|
|
645
|
-
controller.error(new (0,
|
|
684
|
+
controller.error(new (0, _chunkJL3NEW3Ocjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
646
685
|
}
|
|
647
686
|
}
|
|
648
687
|
});
|
|
@@ -664,7 +703,7 @@ function createDataStreamDecoder() {
|
|
|
664
703
|
if (inner === null) {
|
|
665
704
|
if (offset >= buffer.length) return;
|
|
666
705
|
const firstByte = buffer[offset];
|
|
667
|
-
if (firstByte >= 16 && firstByte <=
|
|
706
|
+
if (firstByte >= 16 && firstByte <= 31 || firstByte >= 48 && firstByte <= 63) {
|
|
668
707
|
const decoder = createSubgroupStreamDecoder();
|
|
669
708
|
inner = decoder;
|
|
670
709
|
} else if (firstByte === 5) {
|
|
@@ -672,7 +711,7 @@ function createDataStreamDecoder() {
|
|
|
672
711
|
inner = decoder;
|
|
673
712
|
} else {
|
|
674
713
|
controller.error(
|
|
675
|
-
new (0,
|
|
714
|
+
new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
676
715
|
"CONSTRAINT_VIOLATION",
|
|
677
716
|
`Unknown data stream type: 0x${firstByte.toString(16)}`,
|
|
678
717
|
0
|
|
@@ -687,13 +726,13 @@ function createDataStreamDecoder() {
|
|
|
687
726
|
const view = buffer.subarray(offset);
|
|
688
727
|
const firstByte = view[0];
|
|
689
728
|
let result;
|
|
690
|
-
if (firstByte >= 16 && firstByte <=
|
|
729
|
+
if (firstByte >= 16 && firstByte <= 31 || firstByte >= 48 && firstByte <= 63) {
|
|
691
730
|
result = decodeSubgroupStream(view);
|
|
692
731
|
} else if (firstByte === 5) {
|
|
693
732
|
result = decodeFetchStream(view);
|
|
694
733
|
} else {
|
|
695
734
|
controller.error(
|
|
696
|
-
new (0,
|
|
735
|
+
new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
697
736
|
"CONSTRAINT_VIOLATION",
|
|
698
737
|
`Unknown data stream type: 0x${firstByte.toString(16)}`,
|
|
699
738
|
0
|
|
@@ -737,6 +776,7 @@ function encodeSetupParams(params, writer) {
|
|
|
737
776
|
let count = 0;
|
|
738
777
|
if (params.path !== void 0) count++;
|
|
739
778
|
if (params.max_request_id !== void 0) count++;
|
|
779
|
+
if (params.authorization_token !== void 0) count++;
|
|
740
780
|
if (params.max_auth_token_cache_size !== void 0) count++;
|
|
741
781
|
if (params.authority !== void 0) count++;
|
|
742
782
|
if (params.moqt_implementation !== void 0) count++;
|
|
@@ -752,6 +792,14 @@ function encodeSetupParams(params, writer) {
|
|
|
752
792
|
writer.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID);
|
|
753
793
|
writer.writeVarInt(params.max_request_id);
|
|
754
794
|
}
|
|
795
|
+
if (params.authorization_token !== void 0) {
|
|
796
|
+
writer.writeVarInt(SETUP_PARAM_AUTHORIZATION_TOKEN);
|
|
797
|
+
const tmpW = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(64);
|
|
798
|
+
encodeAuthorizationToken(params.authorization_token, tmpW);
|
|
799
|
+
const raw = tmpW.finish();
|
|
800
|
+
writer.writeVarInt(raw.byteLength);
|
|
801
|
+
writer.writeBytes(raw);
|
|
802
|
+
}
|
|
755
803
|
if (params.max_auth_token_cache_size !== void 0) {
|
|
756
804
|
writer.writeVarInt(SETUP_PARAM_MAX_AUTH_TOKEN_CACHE_SIZE);
|
|
757
805
|
writer.writeVarInt(params.max_auth_token_cache_size);
|
|
@@ -773,12 +821,12 @@ function encodeSetupParams(params, writer) {
|
|
|
773
821
|
const id = BigInt(u.id);
|
|
774
822
|
writer.writeVarInt(id);
|
|
775
823
|
if (id % 2n === 0n) {
|
|
776
|
-
const raw =
|
|
777
|
-
const tmpReader = new (0,
|
|
824
|
+
const raw = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, u.raw_hex);
|
|
825
|
+
const tmpReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(raw);
|
|
778
826
|
const value = tmpReader.readVarInt();
|
|
779
827
|
writer.writeVarInt(value);
|
|
780
828
|
} else {
|
|
781
|
-
const raw =
|
|
829
|
+
const raw = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, u.raw_hex);
|
|
782
830
|
writer.writeVarInt(raw.byteLength);
|
|
783
831
|
writer.writeBytes(raw);
|
|
784
832
|
}
|
|
@@ -798,13 +846,13 @@ function decodeSetupParams(reader) {
|
|
|
798
846
|
} else if (paramType === SETUP_PARAM_MAX_AUTH_TOKEN_CACHE_SIZE) {
|
|
799
847
|
result.max_auth_token_cache_size = value;
|
|
800
848
|
} else {
|
|
801
|
-
const tmpWriter = new (0,
|
|
849
|
+
const tmpWriter = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(16);
|
|
802
850
|
tmpWriter.writeVarInt(value);
|
|
803
851
|
const raw = tmpWriter.finish();
|
|
804
852
|
unknown.push({
|
|
805
853
|
id: `0x${paramType.toString(16)}`,
|
|
806
854
|
length: raw.byteLength,
|
|
807
|
-
raw_hex:
|
|
855
|
+
raw_hex: _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, raw)
|
|
808
856
|
});
|
|
809
857
|
}
|
|
810
858
|
} else {
|
|
@@ -812,6 +860,8 @@ function decodeSetupParams(reader) {
|
|
|
812
860
|
const bytes = reader.readBytes(length);
|
|
813
861
|
if (paramType === SETUP_PARAM_PATH) {
|
|
814
862
|
result.path = textDecoder.decode(bytes);
|
|
863
|
+
} else if (paramType === SETUP_PARAM_AUTHORIZATION_TOKEN) {
|
|
864
|
+
result.authorization_token = decodeAuthorizationToken(new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes));
|
|
815
865
|
} else if (paramType === SETUP_PARAM_AUTHORITY) {
|
|
816
866
|
result.authority = textDecoder.decode(bytes);
|
|
817
867
|
} else if (paramType === SETUP_PARAM_MOQT_IMPLEMENTATION) {
|
|
@@ -820,7 +870,7 @@ function decodeSetupParams(reader) {
|
|
|
820
870
|
unknown.push({
|
|
821
871
|
id: `0x${paramType.toString(16)}`,
|
|
822
872
|
length,
|
|
823
|
-
raw_hex:
|
|
873
|
+
raw_hex: _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, bytes)
|
|
824
874
|
});
|
|
825
875
|
}
|
|
826
876
|
}
|
|
@@ -830,39 +880,172 @@ function decodeSetupParams(reader) {
|
|
|
830
880
|
}
|
|
831
881
|
return result;
|
|
832
882
|
}
|
|
883
|
+
function encodeAuthorizationToken(token, w) {
|
|
884
|
+
w.writeVarInt(token.alias_type);
|
|
885
|
+
const aliasType = Number(token.alias_type);
|
|
886
|
+
if (aliasType === 0 || aliasType === 1) {
|
|
887
|
+
w.writeVarInt(token.token_alias);
|
|
888
|
+
}
|
|
889
|
+
if (aliasType === 1 || aliasType === 3) {
|
|
890
|
+
w.writeVarInt(token.token_type);
|
|
891
|
+
const tokenBytes = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, token.token_value_hex);
|
|
892
|
+
w.writeBytes(tokenBytes);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
function decodeAuthorizationToken(r) {
|
|
896
|
+
const alias_type = r.readVarInt();
|
|
897
|
+
const aliasType = Number(alias_type);
|
|
898
|
+
const result = { alias_type };
|
|
899
|
+
if (aliasType === 0 || aliasType === 1) {
|
|
900
|
+
result.token_alias = r.readVarInt();
|
|
901
|
+
}
|
|
902
|
+
if (aliasType === 1 || aliasType === 3) {
|
|
903
|
+
result.token_type = r.readVarInt();
|
|
904
|
+
const tokenBytes = r.readBytesView(r.remaining);
|
|
905
|
+
result.token_value_hex = _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, tokenBytes);
|
|
906
|
+
}
|
|
907
|
+
return result;
|
|
908
|
+
}
|
|
909
|
+
var PARAM_DELIVERY_TIMEOUT = 0x02n;
|
|
910
|
+
var PARAM_AUTHORIZATION_TOKEN = 0x03n;
|
|
911
|
+
var PARAM_MAX_CACHE_DURATION = 0x04n;
|
|
833
912
|
var PARAM_EXPIRES = 0x08n;
|
|
834
913
|
var PARAM_LARGEST_OBJECT = 0x09n;
|
|
914
|
+
var PARAM_PUBLISHER_PRIORITY = 0x0en;
|
|
915
|
+
var PARAM_FORWARD = 0x10n;
|
|
835
916
|
var PARAM_SUBSCRIBER_PRIORITY = 0x20n;
|
|
836
917
|
var PARAM_SUBSCRIPTION_FILTER = 0x21n;
|
|
837
918
|
var PARAM_GROUP_ORDER = 0x22n;
|
|
919
|
+
var PARAM_DYNAMIC_GROUPS = 0x30n;
|
|
920
|
+
var PARAM_NEW_GROUP_REQUEST = 0x32n;
|
|
921
|
+
var TRACK_EXT_DELIVERY_TIMEOUT = 0x02n;
|
|
922
|
+
var TRACK_EXT_MAX_CACHE_DURATION = 0x04n;
|
|
923
|
+
var TRACK_EXT_DEFAULT_PUBLISHER_PRIORITY = 0x0en;
|
|
924
|
+
function encodeTrackExtensions(ext, writer) {
|
|
925
|
+
if (ext.delivery_timeout !== void 0) {
|
|
926
|
+
writer.writeVarInt(TRACK_EXT_DELIVERY_TIMEOUT);
|
|
927
|
+
writer.writeVarInt(ext.delivery_timeout);
|
|
928
|
+
}
|
|
929
|
+
if (ext.max_cache_duration !== void 0) {
|
|
930
|
+
writer.writeVarInt(TRACK_EXT_MAX_CACHE_DURATION);
|
|
931
|
+
writer.writeVarInt(ext.max_cache_duration);
|
|
932
|
+
}
|
|
933
|
+
if (ext.default_publisher_priority !== void 0) {
|
|
934
|
+
writer.writeVarInt(TRACK_EXT_DEFAULT_PUBLISHER_PRIORITY);
|
|
935
|
+
writer.writeVarInt(ext.default_publisher_priority);
|
|
936
|
+
}
|
|
937
|
+
if (ext.unknown) {
|
|
938
|
+
for (const u of ext.unknown) {
|
|
939
|
+
const id = BigInt(u.id);
|
|
940
|
+
writer.writeVarInt(id);
|
|
941
|
+
if (id % 2n === 0n) {
|
|
942
|
+
const raw = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, u.raw_hex);
|
|
943
|
+
const tmpReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(raw);
|
|
944
|
+
const value = tmpReader.readVarInt();
|
|
945
|
+
writer.writeVarInt(value);
|
|
946
|
+
} else {
|
|
947
|
+
const raw = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, u.raw_hex);
|
|
948
|
+
writer.writeVarInt(raw.byteLength);
|
|
949
|
+
writer.writeBytes(raw);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
function decodeTrackExtensions(reader) {
|
|
955
|
+
const result = {};
|
|
956
|
+
const unknown = [];
|
|
957
|
+
while (reader.remaining > 0) {
|
|
958
|
+
const extType = reader.readVarInt();
|
|
959
|
+
if (extType === TRACK_EXT_DELIVERY_TIMEOUT) {
|
|
960
|
+
result.delivery_timeout = reader.readVarInt();
|
|
961
|
+
} else if (extType === TRACK_EXT_MAX_CACHE_DURATION) {
|
|
962
|
+
result.max_cache_duration = reader.readVarInt();
|
|
963
|
+
} else if (extType === TRACK_EXT_DEFAULT_PUBLISHER_PRIORITY) {
|
|
964
|
+
result.default_publisher_priority = reader.readVarInt();
|
|
965
|
+
} else if (extType % 2n === 0n) {
|
|
966
|
+
const value = reader.readVarInt();
|
|
967
|
+
const tmpWriter = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(16);
|
|
968
|
+
tmpWriter.writeVarInt(value);
|
|
969
|
+
const raw = tmpWriter.finish();
|
|
970
|
+
unknown.push({
|
|
971
|
+
id: `0x${extType.toString(16)}`,
|
|
972
|
+
length: raw.byteLength,
|
|
973
|
+
raw_hex: _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, raw)
|
|
974
|
+
});
|
|
975
|
+
} else {
|
|
976
|
+
const length = Number(reader.readVarInt());
|
|
977
|
+
const bytes = reader.readBytes(length);
|
|
978
|
+
unknown.push({
|
|
979
|
+
id: `0x${extType.toString(16)}`,
|
|
980
|
+
length,
|
|
981
|
+
raw_hex: _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, bytes)
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (unknown.length > 0) {
|
|
986
|
+
result.unknown = unknown;
|
|
987
|
+
}
|
|
988
|
+
return result;
|
|
989
|
+
}
|
|
838
990
|
function encodeParams(params, writer) {
|
|
839
991
|
let count = params.unknown ? params.unknown.length : 0;
|
|
992
|
+
if (params.delivery_timeout !== void 0) count++;
|
|
993
|
+
if (params.authorization_token !== void 0) count++;
|
|
994
|
+
if (params.max_cache_duration !== void 0) count++;
|
|
840
995
|
if (params.expires !== void 0) count++;
|
|
841
996
|
if (params.largest_object !== void 0) count++;
|
|
997
|
+
if (params.publisher_priority !== void 0) count++;
|
|
998
|
+
if (params.forward !== void 0) count++;
|
|
842
999
|
if (params.subscriber_priority !== void 0) count++;
|
|
843
1000
|
if (params.subscription_filter !== void 0) count++;
|
|
844
1001
|
if (params.group_order !== void 0) count++;
|
|
1002
|
+
if (params.dynamic_groups !== void 0) count++;
|
|
1003
|
+
if (params.new_group_request !== void 0) count++;
|
|
845
1004
|
writer.writeVarInt(count);
|
|
1005
|
+
if (params.delivery_timeout !== void 0) {
|
|
1006
|
+
writer.writeVarInt(PARAM_DELIVERY_TIMEOUT);
|
|
1007
|
+
writer.writeVarInt(params.delivery_timeout);
|
|
1008
|
+
}
|
|
1009
|
+
if (params.authorization_token !== void 0) {
|
|
1010
|
+
writer.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
|
|
1011
|
+
const tmpW = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(64);
|
|
1012
|
+
encodeAuthorizationToken(params.authorization_token, tmpW);
|
|
1013
|
+
const raw = tmpW.finish();
|
|
1014
|
+
writer.writeVarInt(raw.byteLength);
|
|
1015
|
+
writer.writeBytes(raw);
|
|
1016
|
+
}
|
|
1017
|
+
if (params.max_cache_duration !== void 0) {
|
|
1018
|
+
writer.writeVarInt(PARAM_MAX_CACHE_DURATION);
|
|
1019
|
+
writer.writeVarInt(params.max_cache_duration);
|
|
1020
|
+
}
|
|
846
1021
|
if (params.expires !== void 0) {
|
|
847
1022
|
writer.writeVarInt(PARAM_EXPIRES);
|
|
848
1023
|
writer.writeVarInt(params.expires);
|
|
849
1024
|
}
|
|
850
1025
|
if (params.largest_object !== void 0) {
|
|
851
1026
|
writer.writeVarInt(PARAM_LARGEST_OBJECT);
|
|
852
|
-
const tmpW = new (0,
|
|
1027
|
+
const tmpW = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(16);
|
|
853
1028
|
tmpW.writeVarInt(params.largest_object.group);
|
|
854
1029
|
tmpW.writeVarInt(params.largest_object.object);
|
|
855
1030
|
const raw = tmpW.finish();
|
|
856
1031
|
writer.writeVarInt(raw.byteLength);
|
|
857
1032
|
writer.writeBytes(raw);
|
|
858
1033
|
}
|
|
1034
|
+
if (params.publisher_priority !== void 0) {
|
|
1035
|
+
writer.writeVarInt(PARAM_PUBLISHER_PRIORITY);
|
|
1036
|
+
writer.writeVarInt(params.publisher_priority);
|
|
1037
|
+
}
|
|
1038
|
+
if (params.forward !== void 0) {
|
|
1039
|
+
writer.writeVarInt(PARAM_FORWARD);
|
|
1040
|
+
writer.writeVarInt(params.forward);
|
|
1041
|
+
}
|
|
859
1042
|
if (params.subscriber_priority !== void 0) {
|
|
860
1043
|
writer.writeVarInt(PARAM_SUBSCRIBER_PRIORITY);
|
|
861
1044
|
writer.writeVarInt(params.subscriber_priority);
|
|
862
1045
|
}
|
|
863
1046
|
if (params.subscription_filter !== void 0) {
|
|
864
1047
|
writer.writeVarInt(PARAM_SUBSCRIPTION_FILTER);
|
|
865
|
-
const tmpW = new (0,
|
|
1048
|
+
const tmpW = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(32);
|
|
866
1049
|
const f = params.subscription_filter;
|
|
867
1050
|
tmpW.writeVarInt(f.filter_type);
|
|
868
1051
|
if (f.filter_type === 3n || f.filter_type === 4n) {
|
|
@@ -880,17 +1063,25 @@ function encodeParams(params, writer) {
|
|
|
880
1063
|
writer.writeVarInt(PARAM_GROUP_ORDER);
|
|
881
1064
|
writer.writeVarInt(params.group_order);
|
|
882
1065
|
}
|
|
1066
|
+
if (params.dynamic_groups !== void 0) {
|
|
1067
|
+
writer.writeVarInt(PARAM_DYNAMIC_GROUPS);
|
|
1068
|
+
writer.writeVarInt(params.dynamic_groups);
|
|
1069
|
+
}
|
|
1070
|
+
if (params.new_group_request !== void 0) {
|
|
1071
|
+
writer.writeVarInt(PARAM_NEW_GROUP_REQUEST);
|
|
1072
|
+
writer.writeVarInt(params.new_group_request);
|
|
1073
|
+
}
|
|
883
1074
|
if (params.unknown) {
|
|
884
1075
|
for (const u of params.unknown) {
|
|
885
1076
|
const id = BigInt(u.id);
|
|
886
1077
|
writer.writeVarInt(id);
|
|
887
1078
|
if (id % 2n === 0n) {
|
|
888
|
-
const raw =
|
|
889
|
-
const tmpReader = new (0,
|
|
1079
|
+
const raw = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, u.raw_hex);
|
|
1080
|
+
const tmpReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(raw);
|
|
890
1081
|
const value = tmpReader.readVarInt();
|
|
891
1082
|
writer.writeVarInt(value);
|
|
892
1083
|
} else {
|
|
893
|
-
const raw =
|
|
1084
|
+
const raw = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, u.raw_hex);
|
|
894
1085
|
writer.writeVarInt(raw.byteLength);
|
|
895
1086
|
writer.writeBytes(raw);
|
|
896
1087
|
}
|
|
@@ -903,12 +1094,28 @@ function decodeParams(reader) {
|
|
|
903
1094
|
const unknown = [];
|
|
904
1095
|
for (let i = 0; i < count; i++) {
|
|
905
1096
|
const paramType = reader.readVarInt();
|
|
906
|
-
if (paramType ===
|
|
1097
|
+
if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
1098
|
+
result.delivery_timeout = reader.readVarInt();
|
|
1099
|
+
} else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
1100
|
+
const length = Number(reader.readVarInt());
|
|
1101
|
+
const tokenBytes = reader.readBytes(length);
|
|
1102
|
+
result.authorization_token = decodeAuthorizationToken(new (0, _chunkJL3NEW3Ocjs.BufferReader)(tokenBytes));
|
|
1103
|
+
} else if (paramType === PARAM_MAX_CACHE_DURATION) {
|
|
1104
|
+
result.max_cache_duration = reader.readVarInt();
|
|
1105
|
+
} else if (paramType === PARAM_EXPIRES) {
|
|
907
1106
|
result.expires = reader.readVarInt();
|
|
1107
|
+
} else if (paramType === PARAM_PUBLISHER_PRIORITY) {
|
|
1108
|
+
result.publisher_priority = reader.readVarInt();
|
|
1109
|
+
} else if (paramType === PARAM_FORWARD) {
|
|
1110
|
+
result.forward = reader.readVarInt();
|
|
908
1111
|
} else if (paramType === PARAM_SUBSCRIBER_PRIORITY) {
|
|
909
1112
|
result.subscriber_priority = reader.readVarInt();
|
|
910
1113
|
} else if (paramType === PARAM_GROUP_ORDER) {
|
|
911
1114
|
result.group_order = reader.readVarInt();
|
|
1115
|
+
} else if (paramType === PARAM_DYNAMIC_GROUPS) {
|
|
1116
|
+
result.dynamic_groups = reader.readVarInt();
|
|
1117
|
+
} else if (paramType === PARAM_NEW_GROUP_REQUEST) {
|
|
1118
|
+
result.new_group_request = reader.readVarInt();
|
|
912
1119
|
} else if (paramType === PARAM_LARGEST_OBJECT) {
|
|
913
1120
|
const length = Number(reader.readVarInt());
|
|
914
1121
|
const startOff = reader.offset;
|
|
@@ -934,13 +1141,13 @@ function decodeParams(reader) {
|
|
|
934
1141
|
result.subscription_filter = filter;
|
|
935
1142
|
} else if (paramType % 2n === 0n) {
|
|
936
1143
|
const value = reader.readVarInt();
|
|
937
|
-
const tmpWriter = new (0,
|
|
1144
|
+
const tmpWriter = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(16);
|
|
938
1145
|
tmpWriter.writeVarInt(value);
|
|
939
1146
|
const raw = tmpWriter.finish();
|
|
940
1147
|
unknown.push({
|
|
941
1148
|
id: `0x${paramType.toString(16)}`,
|
|
942
1149
|
length: raw.byteLength,
|
|
943
|
-
raw_hex:
|
|
1150
|
+
raw_hex: _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, raw)
|
|
944
1151
|
});
|
|
945
1152
|
} else {
|
|
946
1153
|
const length = Number(reader.readVarInt());
|
|
@@ -948,7 +1155,7 @@ function decodeParams(reader) {
|
|
|
948
1155
|
unknown.push({
|
|
949
1156
|
id: `0x${paramType.toString(16)}`,
|
|
950
1157
|
length,
|
|
951
|
-
raw_hex:
|
|
1158
|
+
raw_hex: _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, bytes)
|
|
952
1159
|
});
|
|
953
1160
|
}
|
|
954
1161
|
}
|
|
@@ -973,6 +1180,7 @@ function encodeSubscribeOkPayload(msg, w) {
|
|
|
973
1180
|
w.writeVarInt(msg.request_id);
|
|
974
1181
|
w.writeVarInt(msg.track_alias);
|
|
975
1182
|
encodeParams(msg.parameters, w);
|
|
1183
|
+
if (msg.track_extensions) encodeTrackExtensions(msg.track_extensions, w);
|
|
976
1184
|
}
|
|
977
1185
|
function encodeRequestUpdatePayload(msg, w) {
|
|
978
1186
|
w.writeVarInt(msg.request_id);
|
|
@@ -988,6 +1196,7 @@ function encodePublishPayload(msg, w) {
|
|
|
988
1196
|
w.writeString(msg.track_name);
|
|
989
1197
|
w.writeVarInt(msg.track_alias);
|
|
990
1198
|
encodeParams(msg.parameters, w);
|
|
1199
|
+
if (msg.track_extensions) encodeTrackExtensions(msg.track_extensions, w);
|
|
991
1200
|
}
|
|
992
1201
|
function encodePublishOkPayload(msg, w) {
|
|
993
1202
|
w.writeVarInt(msg.request_id);
|
|
@@ -1047,6 +1256,7 @@ function encodeFetchOkPayload(msg, w) {
|
|
|
1047
1256
|
w.writeVarInt(msg.end_group);
|
|
1048
1257
|
w.writeVarInt(msg.end_object);
|
|
1049
1258
|
encodeParams(msg.parameters, w);
|
|
1259
|
+
if (msg.track_extensions) encodeTrackExtensions(msg.track_extensions, w);
|
|
1050
1260
|
}
|
|
1051
1261
|
function encodeFetchCancelPayload(msg, w) {
|
|
1052
1262
|
w.writeVarInt(msg.request_id);
|
|
@@ -1089,13 +1299,28 @@ function decodeSubscribePayload(r) {
|
|
|
1089
1299
|
const track_namespace = r.readTuple();
|
|
1090
1300
|
const track_name = r.readString();
|
|
1091
1301
|
const parameters = decodeParams(r);
|
|
1092
|
-
return {
|
|
1302
|
+
return {
|
|
1303
|
+
type: "subscribe",
|
|
1304
|
+
request_id,
|
|
1305
|
+
track_namespace,
|
|
1306
|
+
track_name,
|
|
1307
|
+
parameters
|
|
1308
|
+
};
|
|
1093
1309
|
}
|
|
1094
1310
|
function decodeSubscribeOkPayload(r) {
|
|
1095
1311
|
const request_id = r.readVarInt();
|
|
1096
1312
|
const track_alias = r.readVarInt();
|
|
1097
1313
|
const parameters = decodeParams(r);
|
|
1098
|
-
|
|
1314
|
+
const result = {
|
|
1315
|
+
type: "subscribe_ok",
|
|
1316
|
+
request_id,
|
|
1317
|
+
track_alias,
|
|
1318
|
+
parameters
|
|
1319
|
+
};
|
|
1320
|
+
if (r.remaining > 0) {
|
|
1321
|
+
result.track_extensions = decodeTrackExtensions(r);
|
|
1322
|
+
}
|
|
1323
|
+
return result;
|
|
1099
1324
|
}
|
|
1100
1325
|
function decodeRequestUpdatePayload(r) {
|
|
1101
1326
|
const request_id = r.readVarInt();
|
|
@@ -1113,7 +1338,18 @@ function decodePublishPayload(r) {
|
|
|
1113
1338
|
const track_name = r.readString();
|
|
1114
1339
|
const track_alias = r.readVarInt();
|
|
1115
1340
|
const parameters = decodeParams(r);
|
|
1116
|
-
|
|
1341
|
+
const result = {
|
|
1342
|
+
type: "publish",
|
|
1343
|
+
request_id,
|
|
1344
|
+
track_namespace,
|
|
1345
|
+
track_name,
|
|
1346
|
+
track_alias,
|
|
1347
|
+
parameters
|
|
1348
|
+
};
|
|
1349
|
+
if (r.remaining > 0) {
|
|
1350
|
+
result.track_extensions = decodeTrackExtensions(r);
|
|
1351
|
+
}
|
|
1352
|
+
return result;
|
|
1117
1353
|
}
|
|
1118
1354
|
function decodePublishOkPayload(r) {
|
|
1119
1355
|
const request_id = r.readVarInt();
|
|
@@ -1125,7 +1361,13 @@ function decodePublishDonePayload(r) {
|
|
|
1125
1361
|
const status_code = r.readVarInt();
|
|
1126
1362
|
const stream_count = r.readVarInt();
|
|
1127
1363
|
const reason_phrase = r.readString();
|
|
1128
|
-
return {
|
|
1364
|
+
return {
|
|
1365
|
+
type: "publish_done",
|
|
1366
|
+
request_id,
|
|
1367
|
+
status_code,
|
|
1368
|
+
stream_count,
|
|
1369
|
+
reason_phrase
|
|
1370
|
+
};
|
|
1129
1371
|
}
|
|
1130
1372
|
function decodePublishNamespacePayload(r) {
|
|
1131
1373
|
const request_id = r.readVarInt();
|
|
@@ -1141,7 +1383,12 @@ function decodePublishNamespaceCancelPayload(r) {
|
|
|
1141
1383
|
const request_id = r.readVarInt();
|
|
1142
1384
|
const error_code = r.readVarInt();
|
|
1143
1385
|
const reason_phrase = r.readString();
|
|
1144
|
-
return {
|
|
1386
|
+
return {
|
|
1387
|
+
type: "publish_namespace_cancel",
|
|
1388
|
+
request_id,
|
|
1389
|
+
error_code,
|
|
1390
|
+
reason_phrase
|
|
1391
|
+
};
|
|
1145
1392
|
}
|
|
1146
1393
|
function decodeSubscribeNamespacePayload(r) {
|
|
1147
1394
|
const request_id = r.readVarInt();
|
|
@@ -1169,7 +1416,7 @@ function decodeFetchPayload(r) {
|
|
|
1169
1416
|
const fetch_type = r.readVarInt();
|
|
1170
1417
|
const ft = Number(fetch_type);
|
|
1171
1418
|
if (ft < 1 || ft > 3) {
|
|
1172
|
-
throw new (0,
|
|
1419
|
+
throw new (0, _chunkJL3NEW3Ocjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${ft}`, r.offset);
|
|
1173
1420
|
}
|
|
1174
1421
|
let standalone;
|
|
1175
1422
|
let joining;
|
|
@@ -1180,7 +1427,14 @@ function decodeFetchPayload(r) {
|
|
|
1180
1427
|
const start_object = r.readVarInt();
|
|
1181
1428
|
const end_group = r.readVarInt();
|
|
1182
1429
|
const end_object = r.readVarInt();
|
|
1183
|
-
standalone = {
|
|
1430
|
+
standalone = {
|
|
1431
|
+
track_namespace,
|
|
1432
|
+
track_name,
|
|
1433
|
+
start_group,
|
|
1434
|
+
start_object,
|
|
1435
|
+
end_group,
|
|
1436
|
+
end_object
|
|
1437
|
+
};
|
|
1184
1438
|
} else {
|
|
1185
1439
|
const joining_request_id = r.readVarInt();
|
|
1186
1440
|
const joining_start = r.readVarInt();
|
|
@@ -1202,7 +1456,18 @@ function decodeFetchOkPayload(r) {
|
|
|
1202
1456
|
const end_group = r.readVarInt();
|
|
1203
1457
|
const end_object = r.readVarInt();
|
|
1204
1458
|
const parameters = decodeParams(r);
|
|
1205
|
-
|
|
1459
|
+
const result = {
|
|
1460
|
+
type: "fetch_ok",
|
|
1461
|
+
request_id,
|
|
1462
|
+
end_of_track,
|
|
1463
|
+
end_group,
|
|
1464
|
+
end_object,
|
|
1465
|
+
parameters
|
|
1466
|
+
};
|
|
1467
|
+
if (r.remaining > 0) {
|
|
1468
|
+
result.track_extensions = decodeTrackExtensions(r);
|
|
1469
|
+
}
|
|
1470
|
+
return result;
|
|
1206
1471
|
}
|
|
1207
1472
|
function decodeFetchCancelPayload(r) {
|
|
1208
1473
|
const request_id = r.readVarInt();
|
|
@@ -1213,7 +1478,13 @@ function decodeTrackStatusPayload(r) {
|
|
|
1213
1478
|
const track_namespace = r.readTuple();
|
|
1214
1479
|
const track_name = r.readString();
|
|
1215
1480
|
const parameters = decodeParams(r);
|
|
1216
|
-
return {
|
|
1481
|
+
return {
|
|
1482
|
+
type: "track_status",
|
|
1483
|
+
request_id,
|
|
1484
|
+
track_namespace,
|
|
1485
|
+
track_name,
|
|
1486
|
+
parameters
|
|
1487
|
+
};
|
|
1217
1488
|
}
|
|
1218
1489
|
function decodeRequestOkPayload(r) {
|
|
1219
1490
|
const request_id = r.readVarInt();
|
|
@@ -1225,7 +1496,13 @@ function decodeRequestErrorPayload(r) {
|
|
|
1225
1496
|
const error_code = r.readVarInt();
|
|
1226
1497
|
const retry_interval = r.readVarInt();
|
|
1227
1498
|
const reason_phrase = r.readString();
|
|
1228
|
-
return {
|
|
1499
|
+
return {
|
|
1500
|
+
type: "request_error",
|
|
1501
|
+
request_id,
|
|
1502
|
+
error_code,
|
|
1503
|
+
retry_interval,
|
|
1504
|
+
reason_phrase
|
|
1505
|
+
};
|
|
1229
1506
|
}
|
|
1230
1507
|
function decodeGoAwayPayload(r) {
|
|
1231
1508
|
const new_session_uri = r.readString();
|
|
@@ -1270,13 +1547,13 @@ function encodeMessage(message) {
|
|
|
1270
1547
|
if (typeId === void 0) {
|
|
1271
1548
|
throw new Error(`Unknown message type: ${message.type}`);
|
|
1272
1549
|
}
|
|
1273
|
-
const payloadWriter = new (0,
|
|
1550
|
+
const payloadWriter = new (0, _chunkJL3NEW3Ocjs.BufferWriter)();
|
|
1274
1551
|
encodePayload(message, payloadWriter);
|
|
1275
1552
|
const payload = payloadWriter.finishView();
|
|
1276
1553
|
if (payload.byteLength > 65535) {
|
|
1277
1554
|
throw new Error(`Payload too large for 16-bit length: ${payload.byteLength}`);
|
|
1278
1555
|
}
|
|
1279
|
-
const writer = new (0,
|
|
1556
|
+
const writer = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(payload.byteLength + 16);
|
|
1280
1557
|
writer.writeVarInt(typeId);
|
|
1281
1558
|
writer.writeUint8(payload.byteLength >> 8 & 255);
|
|
1282
1559
|
writer.writeUint8(payload.byteLength & 255);
|
|
@@ -1341,18 +1618,18 @@ function encodePayload(msg, w) {
|
|
|
1341
1618
|
}
|
|
1342
1619
|
function decodeMessage(bytes) {
|
|
1343
1620
|
try {
|
|
1344
|
-
const reader = new (0,
|
|
1621
|
+
const reader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes);
|
|
1345
1622
|
const typeId = reader.readVarInt();
|
|
1346
1623
|
const lenHi = reader.readUint8();
|
|
1347
1624
|
const lenLo = reader.readUint8();
|
|
1348
1625
|
const payloadLength = lenHi << 8 | lenLo;
|
|
1349
1626
|
const payloadBytes = reader.readBytes(payloadLength);
|
|
1350
|
-
const payloadReader = new (0,
|
|
1627
|
+
const payloadReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(payloadBytes);
|
|
1351
1628
|
const decoder = payloadDecoders.get(typeId);
|
|
1352
1629
|
if (!decoder) {
|
|
1353
1630
|
return {
|
|
1354
1631
|
ok: false,
|
|
1355
|
-
error: new (0,
|
|
1632
|
+
error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
|
|
1356
1633
|
"UNKNOWN_MESSAGE_TYPE",
|
|
1357
1634
|
`Unknown message type ID: 0x${typeId.toString(16)}`,
|
|
1358
1635
|
0
|
|
@@ -1362,7 +1639,7 @@ function decodeMessage(bytes) {
|
|
|
1362
1639
|
const message = decoder(payloadReader);
|
|
1363
1640
|
return { ok: true, value: message, bytesRead: reader.offset };
|
|
1364
1641
|
} catch (e) {
|
|
1365
|
-
if (e instanceof
|
|
1642
|
+
if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) {
|
|
1366
1643
|
return { ok: false, error: e };
|
|
1367
1644
|
}
|
|
1368
1645
|
throw e;
|
|
@@ -1397,7 +1674,7 @@ function createStreamDecoder() {
|
|
|
1397
1674
|
flush(controller) {
|
|
1398
1675
|
if (offset < buffer.length) {
|
|
1399
1676
|
controller.error(
|
|
1400
|
-
new (0,
|
|
1677
|
+
new (0, _chunkJL3NEW3Ocjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete message data", 0)
|
|
1401
1678
|
);
|
|
1402
1679
|
}
|
|
1403
1680
|
}
|
|
@@ -1405,7 +1682,7 @@ function createStreamDecoder() {
|
|
|
1405
1682
|
}
|
|
1406
1683
|
function createDraft16Codec() {
|
|
1407
1684
|
return {
|
|
1408
|
-
draft: "
|
|
1685
|
+
draft: "16",
|
|
1409
1686
|
encodeMessage,
|
|
1410
1687
|
decodeMessage,
|
|
1411
1688
|
encodeSubgroupStream,
|