Constructor
new LOCParser(frameDuration)
Parameters:
| Name |
Type |
Description |
frameDuration |
number
|
|
- Source:
- See:
-
Members
frameDuration_ :number
Type:
- Source:
Methods
frameDurationFromTrack(track) → {number}
Computes the fixed frame duration (seconds) for a LOC track from MSF
catalog fields.
Rules:
- Video: `1 / track.framerate`
- Audio AAC (`mp4a.40.2`, AAC-LC): `1024 / track.samplerate`
(AAC-LC always uses 1024 samples per frame per ISO 14496-3)
- Audio Opus: `960 / track.samplerate`
(standard 20 ms Opus frame at any sample rate)
Parameters:
| Name |
Type |
Description |
track |
msfCatalog.Track
|
|
- Source:
Returns:
-
Type
-
number
parse(objnon-null) → {!{startTime: number, duration: number, payload: !Uint8Array}}
Parses a single LOC MoQ object.
Resolves `startTime` in priority order:
1. Timestamp property (ID 0x06) in public extensions (`obj.extensions`)
2. Timestamp property in private properties (LOC payload prefix)
3. Fallback: `groupId × frameDuration`
Parameters:
- Source:
Returns:
-
Type
-
!{startTime: number, duration: number, payload: !Uint8Array}
parseExtensions_(datanon-null) → {Map<bigint, (bigint|!Uint8Array)>}
Parses the raw MOQ Object Header Extensions buffer into a property map.
Wire format — flat sequence of type+value pairs until buffer end
(no leading count field; the total-length prefix was already consumed
by the transport layer before storing the bytes in `obj.extensions`):
type (vi64)
value: vi64 when type is even
length (vi64) + bytes when type is odd
This differs from `parsePrivateProperties_()`, whose buffer begins with
a count vi64. Both share the same per-pair encoding.
If parsing throws at any point the partial map built so far is returned,
so callers always receive a valid (possibly empty) map.
Parameters:
| Name |
Type |
Description |
data |
Uint8Array
|
Raw bytes from `obj.extensions`. |
- Source:
Returns:
-
Type
-
Map<bigint, (bigint|!Uint8Array)>
parsePrivateProperties_(datanon-null) → {{props: !Map<bigint, (bigint|!Uint8Array)>, payloadOffset: number}}
Parses the optional LOC Private Properties block at the start of the raw
MOQ Object Payload and returns the byte offset at which the actual media
bitstream begins together with the parsed properties map.
Wire format (mirrors msf_classes.js Reader.keyValuePairs()):
count (vi64)
For each of `count` pairs:
type (vi64)
value: vi64 when type is even
length (vi64) + bytes when type is odd
If parsing throws at any point `payloadOffset` is reset to 0 so the full
buffer is returned as-is.
Parameters:
| Name |
Type |
Description |
data |
Uint8Array
|
Raw MOQ Object Payload (obj.data). |
- Source:
Returns:
-
Type
-
{props: !Map<bigint, (bigint|!Uint8Array)>, payloadOffset: number}
readVi64At_(buffernon-null, offset) → {{value: bigint, bytesRead: number}}
Reads one QUIC variable-length integer (vi64, up to 62 bits) from
`buffer` at byte `offset`.
Top-two-bit size tag:
00 → 1 byte (6-bit value, mask 0x3f)
01 → 2 bytes (14-bit value, mask 0x3fff)
10 → 4 bytes (30-bit value, mask 0x3fffffff)
11 → 8 bytes (62-bit value, mask 0x3fffffffffffffff)
Synchronous equivalent of `Reader.u62WithSize()` in msf_classes.js.
Parameters:
| Name |
Type |
Description |
buffer |
Uint8Array
|
|
offset |
number
|
|
- Source:
Returns:
-
Type
-
{value: bigint, bytesRead: number}
timestampToSeconds_(timestamp, timescale) → {number}
Converts a raw LOC Timestamp value to presentation seconds.
Per LOC §2.3.1.1–§2.3.1.2:
- When `timescale` is present: `seconds = timestamp / timescale`
- When `timescale` is absent: the timestamp is wall-clock µs since the
Unix epoch, so the implicit timescale is 1 000 000.
Parameters:
| Name |
Type |
Description |
timestamp |
bigint
|
Raw vi64 timestamp value. |
timescale |
bigint
|
undefined
|
Raw vi64 timescale, or `undefined`
if the Timescale property was absent. |
- Source:
Returns:
-
Type
-
number