@moqtap/codec 0.6.0 → 0.7.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 +4 -2
- package/dist/{chunk-CXFAQKL3.js → chunk-23KRITJ6.js} +1 -1
- package/dist/{chunk-JL3NEW3O.cjs → chunk-4XLYCT5Q.cjs} +90 -1
- package/dist/{chunk-DLSGOZ6P.js → chunk-5XZKO2U5.js} +34 -34
- package/dist/{chunk-62LYLROG.js → chunk-APTV6F72.js} +35 -35
- package/dist/{chunk-JB5VDJ2V.cjs → chunk-B56AG5HU.cjs} +37 -37
- package/dist/{chunk-4HBKHNU2.cjs → chunk-CZNW3R5E.cjs} +37 -37
- package/dist/{chunk-Q5D6OW6Q.js → chunk-DORX55MO.js} +1 -1
- package/dist/{chunk-OGZTQA24.cjs → chunk-EQAYMCXO.cjs} +64 -64
- package/dist/{chunk-HYI6LFMD.js → chunk-HEO2JG6C.js} +1 -1
- package/dist/{chunk-UP4XPH4J.js → chunk-I55J3KXD.js} +31 -31
- package/dist/{chunk-HZHSO7EW.cjs → chunk-IDV2JYJ6.cjs} +39 -39
- package/dist/{chunk-BAG6YWCP.cjs → chunk-IEJULBKB.cjs} +63 -63
- package/dist/{chunk-Y6KCSM3V.js → chunk-IJAF6PAY.js} +1 -1
- package/dist/{chunk-WMJVSBBE.cjs → chunk-J3ASFPCX.cjs} +57 -57
- package/dist/{chunk-COWGGUL4.js → chunk-JKMYAUGY.js} +1 -1
- package/dist/{chunk-SIYYMFCC.cjs → chunk-KCH4BQXK.cjs} +37 -37
- package/dist/{chunk-VOU7PNHI.js → chunk-KLPWJU6W.js} +89 -0
- package/dist/{chunk-NZ7GYEMT.js → chunk-KNLPX3YA.js} +1 -1
- package/dist/{chunk-A33U4WVS.cjs → chunk-KTVN4P6J.cjs} +67 -67
- package/dist/{chunk-7KBAWOBA.js → chunk-KYVTM5VI.js} +1 -1
- package/dist/{chunk-RZ3UML47.js → chunk-MD2OA7SE.js} +1 -1
- package/dist/{chunk-MSG2FXJ2.cjs → chunk-MH7537FB.cjs} +68 -68
- package/dist/{chunk-SHMA4PBY.js → chunk-N2V7Z37J.js} +1 -1
- package/dist/{chunk-HO44OANK.cjs → chunk-QGIHC6BA.cjs} +36 -36
- package/dist/{chunk-PKEOQSSZ.cjs → chunk-RIIA4ALQ.cjs} +37 -37
- package/dist/{chunk-XZE5R57R.cjs → chunk-VZHL2U2N.cjs} +37 -37
- package/dist/{chunk-RW4UG7CN.js → chunk-XHAP2YST.js} +1 -1
- package/dist/{chunk-JTRU76JN.cjs → chunk-Y4FRXYX6.cjs} +59 -59
- package/dist/draft07.cjs +4 -4
- package/dist/draft07.js +2 -2
- package/dist/draft08.cjs +3 -3
- package/dist/draft08.js +2 -2
- package/dist/draft09.cjs +3 -3
- package/dist/draft09.js +2 -2
- package/dist/draft10.cjs +3 -3
- package/dist/draft10.js +2 -2
- package/dist/draft11.cjs +3 -3
- package/dist/draft11.js +2 -2
- package/dist/draft12.cjs +3 -3
- package/dist/draft12.js +2 -2
- package/dist/draft13.cjs +3 -3
- package/dist/draft13.js +2 -2
- package/dist/draft14.cjs +3 -3
- package/dist/draft14.js +2 -2
- package/dist/draft15.cjs +3 -3
- package/dist/draft15.js +2 -2
- package/dist/draft16.cjs +3 -3
- package/dist/draft16.js +2 -2
- package/dist/draft17.cjs +3 -3
- package/dist/draft17.js +2 -2
- package/dist/draft18.cjs +3 -3
- package/dist/draft18.js +2 -2
- package/dist/draft19.cjs +3 -3
- package/dist/draft19.js +2 -2
- package/dist/index.cjs +28 -28
- package/dist/index.js +14 -14
- package/package.json +2 -2
- package/src/core/buffer-reader.ts +74 -2
- package/src/core/buffer-writer.ts +56 -4
- package/src/drafts/draft17/codec.ts +2 -2
- package/src/drafts/draft17/data-streams.ts +2 -2
- package/src/drafts/draft18/codec.ts +2 -2
- package/src/drafts/draft18/data-streams.ts +2 -2
- package/src/drafts/draft19/codec.ts +2 -2
- package/src/drafts/draft19/data-streams.ts +2 -2
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk4XLYCT5Qcjs = require('./chunk-4XLYCT5Q.cjs');
|
|
8
8
|
|
|
9
9
|
// src/drafts/draft19/messages.ts
|
|
10
10
|
var MSG_REQUEST_UPDATE = 0x02n;
|
|
@@ -110,7 +110,7 @@ function isValidSubgroupType(streamType) {
|
|
|
110
110
|
return (streamType & 6) !== 6;
|
|
111
111
|
}
|
|
112
112
|
function encodeSubgroupStream(stream) {
|
|
113
|
-
const w = new (0,
|
|
113
|
+
const w = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)();
|
|
114
114
|
const streamType = stream.headerType;
|
|
115
115
|
w.writeUint8(streamType);
|
|
116
116
|
const propertiesPresent = (streamType & 1) !== 0;
|
|
@@ -131,7 +131,7 @@ function encodeSubgroupStream(stream) {
|
|
|
131
131
|
w.writeVarInt(delta);
|
|
132
132
|
if (propertiesPresent) {
|
|
133
133
|
if (obj.objectProperties && Object.keys(obj.objectProperties).length > 0) {
|
|
134
|
-
const tmpW = new (0,
|
|
134
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(32);
|
|
135
135
|
encodeObjectProperties(obj.objectProperties, tmpW);
|
|
136
136
|
const raw = tmpW.finish();
|
|
137
137
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
@@ -151,7 +151,7 @@ function encodeSubgroupStream(stream) {
|
|
|
151
151
|
return w.finish();
|
|
152
152
|
}
|
|
153
153
|
function encodeDatagram(dg) {
|
|
154
|
-
const w = new (0,
|
|
154
|
+
const w = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)();
|
|
155
155
|
const dgType = dg.datagramType;
|
|
156
156
|
w.writeUint8(dgType);
|
|
157
157
|
w.writeVarInt(dg.trackAlias);
|
|
@@ -168,7 +168,7 @@ function encodeDatagram(dg) {
|
|
|
168
168
|
}
|
|
169
169
|
if (propertiesPresent) {
|
|
170
170
|
if (dg.objectProperties && Object.keys(dg.objectProperties).length > 0) {
|
|
171
|
-
const tmpW = new (0,
|
|
171
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(32);
|
|
172
172
|
encodeObjectProperties(dg.objectProperties, tmpW);
|
|
173
173
|
const raw = tmpW.finish();
|
|
174
174
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
@@ -185,7 +185,7 @@ function encodeDatagram(dg) {
|
|
|
185
185
|
return w.finish();
|
|
186
186
|
}
|
|
187
187
|
function encodeFetchStream(stream) {
|
|
188
|
-
const w = new (0,
|
|
188
|
+
const w = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)();
|
|
189
189
|
w.writeVarInt(FETCH_STREAM_TYPE);
|
|
190
190
|
w.writeVarInt(stream.requestId);
|
|
191
191
|
let prevGroupId = 0n;
|
|
@@ -207,7 +207,7 @@ function encodeFetchStream(stream) {
|
|
|
207
207
|
if (flags & 16) w.writeUint8(obj.publisherPriority);
|
|
208
208
|
if (flags & 32) {
|
|
209
209
|
if (obj.objectProperties && Object.keys(obj.objectProperties).length > 0) {
|
|
210
|
-
const tmpW = new (0,
|
|
210
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(32);
|
|
211
211
|
encodeObjectProperties(obj.objectProperties, tmpW);
|
|
212
212
|
const raw = tmpW.finish();
|
|
213
213
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
@@ -231,7 +231,7 @@ function encodeFetchStream(stream) {
|
|
|
231
231
|
if (flags & 16) w.writeUint8(obj.publisherPriority);
|
|
232
232
|
if (flags & 32) {
|
|
233
233
|
if (obj.objectProperties && Object.keys(obj.objectProperties).length > 0) {
|
|
234
|
-
const tmpW = new (0,
|
|
234
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(32);
|
|
235
235
|
encodeObjectProperties(obj.objectProperties, tmpW);
|
|
236
236
|
const raw = tmpW.finish();
|
|
237
237
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
@@ -254,12 +254,12 @@ function encodeFetchStream(stream) {
|
|
|
254
254
|
}
|
|
255
255
|
function decodeSubgroupStream(bytes) {
|
|
256
256
|
try {
|
|
257
|
-
const r = new (0,
|
|
257
|
+
const r = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes);
|
|
258
258
|
const streamType = r.readUint8();
|
|
259
259
|
if (!isValidSubgroupType(streamType)) {
|
|
260
260
|
return {
|
|
261
261
|
ok: false,
|
|
262
|
-
error: new (0,
|
|
262
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
263
263
|
"CONSTRAINT_VIOLATION",
|
|
264
264
|
`Invalid subgroup stream type 0x${streamType.toString(16)}`,
|
|
265
265
|
0
|
|
@@ -351,13 +351,13 @@ function decodeSubgroupStream(bytes) {
|
|
|
351
351
|
bytesRead: r.offset
|
|
352
352
|
};
|
|
353
353
|
} catch (e) {
|
|
354
|
-
if (e instanceof
|
|
354
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
355
355
|
throw e;
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
function decodeDatagram(bytes) {
|
|
359
359
|
try {
|
|
360
|
-
const r = new (0,
|
|
360
|
+
const r = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes);
|
|
361
361
|
const dgType = r.readUint8();
|
|
362
362
|
const objectIdAbsent = (dgType & 4) !== 0;
|
|
363
363
|
const endOfGroup = (dgType & 2) !== 0;
|
|
@@ -407,18 +407,18 @@ function decodeDatagram(bytes) {
|
|
|
407
407
|
result.objectProperties = objectProperties;
|
|
408
408
|
return { ok: true, value: result, bytesRead: r.offset };
|
|
409
409
|
} catch (e) {
|
|
410
|
-
if (e instanceof
|
|
410
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
411
411
|
throw e;
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
function decodeFetchStream(bytes) {
|
|
415
415
|
try {
|
|
416
|
-
const r = new (0,
|
|
416
|
+
const r = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes);
|
|
417
417
|
const streamType = r.readVarInt();
|
|
418
418
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
419
419
|
return {
|
|
420
420
|
ok: false,
|
|
421
|
-
error: new (0,
|
|
421
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
422
422
|
"CONSTRAINT_VIOLATION",
|
|
423
423
|
`Expected fetch stream type 0x05, got 0x${streamType.toString(16)}`,
|
|
424
424
|
0
|
|
@@ -446,7 +446,7 @@ function decodeFetchStream(bytes) {
|
|
|
446
446
|
if (flags !== 140 && flags !== 268) {
|
|
447
447
|
return {
|
|
448
448
|
ok: false,
|
|
449
|
-
error: new (0,
|
|
449
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
450
450
|
"CONSTRAINT_VIOLATION",
|
|
451
451
|
`Unknown serialization flags value: 0x${flags.toString(16)}`,
|
|
452
452
|
r.offset
|
|
@@ -515,7 +515,7 @@ function decodeFetchStream(bytes) {
|
|
|
515
515
|
} else if (first) {
|
|
516
516
|
return {
|
|
517
517
|
ok: false,
|
|
518
|
-
error: new (0,
|
|
518
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
519
519
|
"CONSTRAINT_VIOLATION",
|
|
520
520
|
"First fetch object must include groupId",
|
|
521
521
|
r.offset
|
|
@@ -528,7 +528,7 @@ function decodeFetchStream(bytes) {
|
|
|
528
528
|
if (first) {
|
|
529
529
|
return {
|
|
530
530
|
ok: false,
|
|
531
|
-
error: new (0,
|
|
531
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
532
532
|
"CONSTRAINT_VIOLATION",
|
|
533
533
|
"First fetch object cannot reference prior subgroupId",
|
|
534
534
|
r.offset
|
|
@@ -540,7 +540,7 @@ function decodeFetchStream(bytes) {
|
|
|
540
540
|
if (first) {
|
|
541
541
|
return {
|
|
542
542
|
ok: false,
|
|
543
|
-
error: new (0,
|
|
543
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
544
544
|
"CONSTRAINT_VIOLATION",
|
|
545
545
|
"First fetch object cannot reference prior subgroupId",
|
|
546
546
|
r.offset
|
|
@@ -556,7 +556,7 @@ function decodeFetchStream(bytes) {
|
|
|
556
556
|
} else if (first) {
|
|
557
557
|
return {
|
|
558
558
|
ok: false,
|
|
559
|
-
error: new (0,
|
|
559
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
560
560
|
"CONSTRAINT_VIOLATION",
|
|
561
561
|
"First fetch object must include objectId",
|
|
562
562
|
r.offset
|
|
@@ -624,7 +624,7 @@ function decodeFetchStream(bytes) {
|
|
|
624
624
|
bytesRead: r.offset
|
|
625
625
|
};
|
|
626
626
|
} catch (e) {
|
|
627
|
-
if (e instanceof
|
|
627
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
628
628
|
throw e;
|
|
629
629
|
}
|
|
630
630
|
}
|
|
@@ -661,11 +661,11 @@ function createSubgroupStreamDecoder() {
|
|
|
661
661
|
buffer = newBuffer;
|
|
662
662
|
if (!headerEmitted) {
|
|
663
663
|
try {
|
|
664
|
-
const r = new (0,
|
|
664
|
+
const r = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(buffer.subarray(offset));
|
|
665
665
|
const streamType = r.readUint8();
|
|
666
666
|
if (!isValidSubgroupType(streamType)) {
|
|
667
667
|
controller.error(
|
|
668
|
-
new (0,
|
|
668
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
669
669
|
"CONSTRAINT_VIOLATION",
|
|
670
670
|
`Invalid subgroup stream type 0x${streamType.toString(16)}`,
|
|
671
671
|
0
|
|
@@ -697,7 +697,7 @@ function createSubgroupStreamDecoder() {
|
|
|
697
697
|
headerEmitted = true;
|
|
698
698
|
offset += r.offset;
|
|
699
699
|
} catch (e) {
|
|
700
|
-
if (e instanceof
|
|
700
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
701
701
|
return;
|
|
702
702
|
}
|
|
703
703
|
controller.error(e);
|
|
@@ -706,7 +706,7 @@ function createSubgroupStreamDecoder() {
|
|
|
706
706
|
}
|
|
707
707
|
while (offset < buffer.length) {
|
|
708
708
|
try {
|
|
709
|
-
const r = new (0,
|
|
709
|
+
const r = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(buffer.subarray(offset));
|
|
710
710
|
const delta = r.readVarInt();
|
|
711
711
|
let objectId;
|
|
712
712
|
if (firstObject) {
|
|
@@ -735,7 +735,7 @@ function createSubgroupStreamDecoder() {
|
|
|
735
735
|
offset += r.offset;
|
|
736
736
|
prevObjectId = objectId;
|
|
737
737
|
} catch (e) {
|
|
738
|
-
if (e instanceof
|
|
738
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
739
739
|
break;
|
|
740
740
|
}
|
|
741
741
|
controller.error(e);
|
|
@@ -745,7 +745,7 @@ function createSubgroupStreamDecoder() {
|
|
|
745
745
|
},
|
|
746
746
|
flush(controller) {
|
|
747
747
|
if (offset < buffer.length) {
|
|
748
|
-
controller.error(new (0,
|
|
748
|
+
controller.error(new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
});
|
|
@@ -766,11 +766,11 @@ function createFetchStreamDecoder() {
|
|
|
766
766
|
buffer = newBuffer;
|
|
767
767
|
if (!headerEmitted) {
|
|
768
768
|
try {
|
|
769
|
-
const r = new (0,
|
|
769
|
+
const r = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(buffer.subarray(offset));
|
|
770
770
|
const streamType = r.readVarInt();
|
|
771
771
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
772
772
|
controller.error(
|
|
773
|
-
new (0,
|
|
773
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
774
774
|
"CONSTRAINT_VIOLATION",
|
|
775
775
|
`Expected fetch stream type 0x05, got 0x${streamType.toString(16)}`,
|
|
776
776
|
0
|
|
@@ -783,7 +783,7 @@ function createFetchStreamDecoder() {
|
|
|
783
783
|
headerEmitted = true;
|
|
784
784
|
offset += r.offset;
|
|
785
785
|
} catch (e) {
|
|
786
|
-
if (e instanceof
|
|
786
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
789
|
controller.error(e);
|
|
@@ -792,7 +792,7 @@ function createFetchStreamDecoder() {
|
|
|
792
792
|
}
|
|
793
793
|
while (offset < buffer.length) {
|
|
794
794
|
try {
|
|
795
|
-
const r = new (0,
|
|
795
|
+
const r = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(buffer.subarray(offset));
|
|
796
796
|
const flags = Number(r.readVarInt());
|
|
797
797
|
const objectIdPresent = (flags & 4) !== 0;
|
|
798
798
|
const groupIdPresent = (flags & 8) !== 0;
|
|
@@ -823,7 +823,7 @@ function createFetchStreamDecoder() {
|
|
|
823
823
|
});
|
|
824
824
|
offset += r.offset;
|
|
825
825
|
} catch (e) {
|
|
826
|
-
if (e instanceof
|
|
826
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
827
827
|
break;
|
|
828
828
|
}
|
|
829
829
|
controller.error(e);
|
|
@@ -833,7 +833,7 @@ function createFetchStreamDecoder() {
|
|
|
833
833
|
},
|
|
834
834
|
flush(controller) {
|
|
835
835
|
if (offset < buffer.length) {
|
|
836
|
-
controller.error(new (0,
|
|
836
|
+
controller.error(new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
839
|
});
|
|
@@ -863,7 +863,7 @@ function createDataStreamDecoder() {
|
|
|
863
863
|
inner = decoder;
|
|
864
864
|
} else {
|
|
865
865
|
controller.error(
|
|
866
|
-
new (0,
|
|
866
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
867
867
|
"CONSTRAINT_VIOLATION",
|
|
868
868
|
`Unknown data stream type: 0x${firstByte.toString(16)}`,
|
|
869
869
|
0
|
|
@@ -884,7 +884,7 @@ function createDataStreamDecoder() {
|
|
|
884
884
|
result = decodeFetchStream(view);
|
|
885
885
|
} else {
|
|
886
886
|
controller.error(
|
|
887
|
-
new (0,
|
|
887
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
888
888
|
"CONSTRAINT_VIOLATION",
|
|
889
889
|
`Unknown data stream type: 0x${firstByte.toString(16)}`,
|
|
890
890
|
0
|
|
@@ -941,7 +941,7 @@ function encodeSetupOptions(opts, writer) {
|
|
|
941
941
|
entries.push({
|
|
942
942
|
type: SETUP_OPT_AUTHORIZATION_TOKEN,
|
|
943
943
|
encode: (w) => {
|
|
944
|
-
const tmpW = new (0,
|
|
944
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(64);
|
|
945
945
|
encodeAuthorizationToken(opts.authorization_token, tmpW);
|
|
946
946
|
const raw = tmpW.finish();
|
|
947
947
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
@@ -994,11 +994,11 @@ function encodeSetupOptions(opts, writer) {
|
|
|
994
994
|
type: id,
|
|
995
995
|
encode: (w) => {
|
|
996
996
|
if (id % 2n === 0n) {
|
|
997
|
-
const raw =
|
|
998
|
-
const tmpReader = new (0,
|
|
997
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
998
|
+
const tmpReader = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(raw);
|
|
999
999
|
w.writeVarInt(tmpReader.readVarInt());
|
|
1000
1000
|
} else {
|
|
1001
|
-
const raw =
|
|
1001
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
1002
1002
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
1003
1003
|
w.writeBytes(raw);
|
|
1004
1004
|
}
|
|
@@ -1031,13 +1031,13 @@ function decodeSetupOptions(reader, payloadEnd) {
|
|
|
1031
1031
|
} else if (optType === SETUP_OPT_MAX_REQUEST_UPDATES) {
|
|
1032
1032
|
result.max_request_updates = value;
|
|
1033
1033
|
} else {
|
|
1034
|
-
const tmpWriter = new (0,
|
|
1034
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(16);
|
|
1035
1035
|
tmpWriter.writeVarInt(value);
|
|
1036
1036
|
const raw = tmpWriter.finish();
|
|
1037
1037
|
unknown.push({
|
|
1038
1038
|
id: `0x${optType.toString(16)}`,
|
|
1039
1039
|
length: raw.byteLength,
|
|
1040
|
-
raw_hex:
|
|
1040
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
|
|
1041
1041
|
});
|
|
1042
1042
|
}
|
|
1043
1043
|
} else {
|
|
@@ -1046,7 +1046,7 @@ function decodeSetupOptions(reader, payloadEnd) {
|
|
|
1046
1046
|
if (optType === SETUP_OPT_PATH) {
|
|
1047
1047
|
result.path = textDecoder.decode(bytes);
|
|
1048
1048
|
} else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
|
|
1049
|
-
result.authorization_token = decodeAuthorizationToken(new (0,
|
|
1049
|
+
result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
|
|
1050
1050
|
} else if (optType === SETUP_OPT_AUTHORITY) {
|
|
1051
1051
|
result.authority = textDecoder.decode(bytes);
|
|
1052
1052
|
} else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
|
|
@@ -1055,7 +1055,7 @@ function decodeSetupOptions(reader, payloadEnd) {
|
|
|
1055
1055
|
unknown.push({
|
|
1056
1056
|
id: `0x${optType.toString(16)}`,
|
|
1057
1057
|
length,
|
|
1058
|
-
raw_hex:
|
|
1058
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
|
|
1059
1059
|
});
|
|
1060
1060
|
}
|
|
1061
1061
|
}
|
|
@@ -1131,7 +1131,7 @@ function encodeRangeFilter(filter, hasProperty, w) {
|
|
|
1131
1131
|
w.writeVarInt(0n);
|
|
1132
1132
|
return;
|
|
1133
1133
|
}
|
|
1134
|
-
const tmpW = new (0,
|
|
1134
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(32);
|
|
1135
1135
|
tmpW.writeUint8(Number(_nullishCoalesce(filter.set_id, () => ( 0n))));
|
|
1136
1136
|
if (hasProperty) {
|
|
1137
1137
|
tmpW.writeVarInt(_nullishCoalesce(filter.property_type, () => ( 0n)));
|
|
@@ -1185,7 +1185,7 @@ function encodeParams(params, writer) {
|
|
|
1185
1185
|
entries.push({
|
|
1186
1186
|
type: PARAM_AUTHORIZATION_TOKEN,
|
|
1187
1187
|
encode: (w) => {
|
|
1188
|
-
const tmpW = new (0,
|
|
1188
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(64);
|
|
1189
1189
|
encodeAuthorizationToken(params.authorization_token, tmpW);
|
|
1190
1190
|
const raw = tmpW.finish();
|
|
1191
1191
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
@@ -1215,7 +1215,7 @@ function encodeParams(params, writer) {
|
|
|
1215
1215
|
entries.push({
|
|
1216
1216
|
type: PARAM_LARGEST_OBJECT,
|
|
1217
1217
|
encode: (w) => {
|
|
1218
|
-
const tmpW = new (0,
|
|
1218
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(16);
|
|
1219
1219
|
tmpW.writeVarInt(params.largest_object.group);
|
|
1220
1220
|
tmpW.writeVarInt(params.largest_object.object);
|
|
1221
1221
|
const raw = tmpW.finish();
|
|
@@ -1247,7 +1247,7 @@ function encodeParams(params, writer) {
|
|
|
1247
1247
|
type: PARAM_LOCATION_FILTER,
|
|
1248
1248
|
encode: (w) => {
|
|
1249
1249
|
const f = params.location_filter;
|
|
1250
|
-
const tmpW = new (0,
|
|
1250
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(32);
|
|
1251
1251
|
tmpW.writeVarInt(f.filter_type);
|
|
1252
1252
|
if (f.filter_type === 3n || f.filter_type === 4n) {
|
|
1253
1253
|
tmpW.writeVarInt(f.start_group);
|
|
@@ -1308,7 +1308,7 @@ function encodeParams(params, writer) {
|
|
|
1308
1308
|
entries.push({
|
|
1309
1309
|
type: PARAM_TRACK_NAMESPACE_PREFIX,
|
|
1310
1310
|
encode: (w) => {
|
|
1311
|
-
const tmpW = new (0,
|
|
1311
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(32);
|
|
1312
1312
|
encodeNamespaceTuple(params.track_namespace_prefix, tmpW);
|
|
1313
1313
|
const raw = tmpW.finish();
|
|
1314
1314
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
@@ -1322,7 +1322,7 @@ function encodeParams(params, writer) {
|
|
|
1322
1322
|
entries.push({
|
|
1323
1323
|
type: id,
|
|
1324
1324
|
encode: (w) => {
|
|
1325
|
-
const raw =
|
|
1325
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
1326
1326
|
w.writeBytes(raw);
|
|
1327
1327
|
}
|
|
1328
1328
|
});
|
|
@@ -1351,7 +1351,7 @@ function decodeParams(reader) {
|
|
|
1351
1351
|
} else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
1352
1352
|
const length = Number(reader.readVarInt());
|
|
1353
1353
|
const bytes = reader.readBytes(length);
|
|
1354
|
-
result.authorization_token = decodeAuthorizationToken(new (0,
|
|
1354
|
+
result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
|
|
1355
1355
|
} else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
|
|
1356
1356
|
result.rendezvous_timeout = reader.readVarInt();
|
|
1357
1357
|
} else if (paramType === PARAM_SUBGROUP_DELIVERY_TIMEOUT) {
|
|
@@ -1404,17 +1404,17 @@ function decodeParams(reader) {
|
|
|
1404
1404
|
} else if (paramType === PARAM_TRACK_NAMESPACE_PREFIX) {
|
|
1405
1405
|
const length = Number(reader.readVarInt());
|
|
1406
1406
|
const bytes = reader.readBytes(length);
|
|
1407
|
-
result.track_namespace_prefix = decodeNamespaceTuple(new (0,
|
|
1407
|
+
result.track_namespace_prefix = decodeNamespaceTuple(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
|
|
1408
1408
|
} else {
|
|
1409
1409
|
if (paramType % 2n === 0n) {
|
|
1410
1410
|
const value = reader.readVarInt();
|
|
1411
|
-
const tmpWriter = new (0,
|
|
1411
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(16);
|
|
1412
1412
|
tmpWriter.writeVarInt(value);
|
|
1413
1413
|
const raw = tmpWriter.finish();
|
|
1414
1414
|
unknown.push({
|
|
1415
1415
|
id: `0x${paramType.toString(16)}`,
|
|
1416
1416
|
length: raw.byteLength,
|
|
1417
|
-
raw_hex:
|
|
1417
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
|
|
1418
1418
|
});
|
|
1419
1419
|
} else {
|
|
1420
1420
|
const length = Number(reader.readVarInt());
|
|
@@ -1422,7 +1422,7 @@ function decodeParams(reader) {
|
|
|
1422
1422
|
unknown.push({
|
|
1423
1423
|
id: `0x${paramType.toString(16)}`,
|
|
1424
1424
|
length,
|
|
1425
|
-
raw_hex:
|
|
1425
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
|
|
1426
1426
|
});
|
|
1427
1427
|
}
|
|
1428
1428
|
}
|
|
@@ -1492,11 +1492,11 @@ function encodeTrackProperties(props, writer) {
|
|
|
1492
1492
|
type: id,
|
|
1493
1493
|
encode: (w) => {
|
|
1494
1494
|
if (id % 2n === 0n) {
|
|
1495
|
-
const raw =
|
|
1496
|
-
const tmpReader = new (0,
|
|
1495
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
1496
|
+
const tmpReader = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(raw);
|
|
1497
1497
|
w.writeVarInt(tmpReader.readVarInt());
|
|
1498
1498
|
} else {
|
|
1499
|
-
const raw =
|
|
1499
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
1500
1500
|
w.writeVarInt(BigInt(raw.byteLength));
|
|
1501
1501
|
w.writeBytes(raw);
|
|
1502
1502
|
}
|
|
@@ -1535,13 +1535,13 @@ function decodeTrackProperties(reader, payloadEnd) {
|
|
|
1535
1535
|
} else if (propType === TPROP_DYNAMIC_GROUPS) {
|
|
1536
1536
|
result.dynamic_groups = value;
|
|
1537
1537
|
} else {
|
|
1538
|
-
const tmpWriter = new (0,
|
|
1538
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(16);
|
|
1539
1539
|
tmpWriter.writeVarInt(value);
|
|
1540
1540
|
const raw = tmpWriter.finish();
|
|
1541
1541
|
unknown.push({
|
|
1542
1542
|
id: `0x${propType.toString(16)}`,
|
|
1543
1543
|
length: raw.byteLength,
|
|
1544
|
-
raw_hex:
|
|
1544
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
|
|
1545
1545
|
});
|
|
1546
1546
|
}
|
|
1547
1547
|
} else {
|
|
@@ -1553,7 +1553,7 @@ function decodeTrackProperties(reader, payloadEnd) {
|
|
|
1553
1553
|
unknown.push({
|
|
1554
1554
|
id: `0x${propType.toString(16)}`,
|
|
1555
1555
|
length,
|
|
1556
|
-
raw_hex:
|
|
1556
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
|
|
1557
1557
|
});
|
|
1558
1558
|
}
|
|
1559
1559
|
}
|
|
@@ -1784,7 +1784,7 @@ function decodeFetchPayload(r) {
|
|
|
1784
1784
|
const fetch_type = r.readVarInt();
|
|
1785
1785
|
const ft = Number(fetch_type);
|
|
1786
1786
|
if (ft < 1 || ft > 3) {
|
|
1787
|
-
throw new (0,
|
|
1787
|
+
throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${ft}`, r.offset);
|
|
1788
1788
|
}
|
|
1789
1789
|
let standalone;
|
|
1790
1790
|
let joining;
|
|
@@ -1874,13 +1874,13 @@ function encodeMessage(message) {
|
|
|
1874
1874
|
if (typeId === void 0) {
|
|
1875
1875
|
throw new Error(`Unknown message type: ${message.type}`);
|
|
1876
1876
|
}
|
|
1877
|
-
const payloadWriter = new (0,
|
|
1877
|
+
const payloadWriter = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)();
|
|
1878
1878
|
encodePayload(message, payloadWriter);
|
|
1879
1879
|
const payload = payloadWriter.finishView();
|
|
1880
1880
|
if (payload.byteLength > 65535) {
|
|
1881
1881
|
throw new Error(`Payload too large for 16-bit length: ${payload.byteLength}`);
|
|
1882
1882
|
}
|
|
1883
|
-
const writer = new (0,
|
|
1883
|
+
const writer = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(payload.byteLength + 16);
|
|
1884
1884
|
writer.writeVarInt(typeId);
|
|
1885
1885
|
writer.writeUint8(payload.byteLength >> 8 & 255);
|
|
1886
1886
|
writer.writeUint8(payload.byteLength & 255);
|
|
@@ -1933,13 +1933,13 @@ function encodePayload(msg, w) {
|
|
|
1933
1933
|
}
|
|
1934
1934
|
function decodeMessage(bytes) {
|
|
1935
1935
|
try {
|
|
1936
|
-
const reader = new (0,
|
|
1936
|
+
const reader = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes);
|
|
1937
1937
|
const typeId = reader.readVarInt();
|
|
1938
1938
|
const lenHi = reader.readUint8();
|
|
1939
1939
|
const lenLo = reader.readUint8();
|
|
1940
1940
|
const payloadLength = lenHi << 8 | lenLo;
|
|
1941
1941
|
const payloadBytes = reader.readBytes(payloadLength);
|
|
1942
|
-
const payloadReader = new (0,
|
|
1942
|
+
const payloadReader = new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(payloadBytes);
|
|
1943
1943
|
let message;
|
|
1944
1944
|
if (typeId === MSG_SETUP) {
|
|
1945
1945
|
message = decodeSetupPayload(payloadReader, payloadLength);
|
|
@@ -1980,7 +1980,7 @@ function decodeMessage(bytes) {
|
|
|
1980
1980
|
} else {
|
|
1981
1981
|
return {
|
|
1982
1982
|
ok: false,
|
|
1983
|
-
error: new (0,
|
|
1983
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
1984
1984
|
"UNKNOWN_MESSAGE_TYPE",
|
|
1985
1985
|
`Unknown message type ID: 0x${typeId.toString(16)}`,
|
|
1986
1986
|
0
|
|
@@ -1989,7 +1989,7 @@ function decodeMessage(bytes) {
|
|
|
1989
1989
|
}
|
|
1990
1990
|
return { ok: true, value: message, bytesRead: reader.offset };
|
|
1991
1991
|
} catch (e) {
|
|
1992
|
-
if (e instanceof
|
|
1992
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) {
|
|
1993
1993
|
return { ok: false, error: e };
|
|
1994
1994
|
}
|
|
1995
1995
|
throw e;
|
|
@@ -2024,7 +2024,7 @@ function createStreamDecoder() {
|
|
|
2024
2024
|
flush(controller) {
|
|
2025
2025
|
if (offset < buffer.length) {
|
|
2026
2026
|
controller.error(
|
|
2027
|
-
new (0,
|
|
2027
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete message data", 0)
|
|
2028
2028
|
);
|
|
2029
2029
|
}
|
|
2030
2030
|
}
|