wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
moqdata.h
Go to the documentation of this file.
1#ifndef MOQDATA_H
2#define MOQDATA_H
3
6
15
17#define MOQDATA_OK 1
19#define MOQDATA_INSUFFICIENT 0
21#define MOQDATA_VIOLATION (-1)
22
23/* Unidirectional stream types (3.4). */
25#define MOQDATA_STREAM_INSUFFICIENT 0
27#define MOQDATA_STREAM_CONTROL 1
29#define MOQDATA_STREAM_FETCH 2
31#define MOQDATA_STREAM_SUBGROUP 3
33#define MOQDATA_STREAM_PADDING 4
35#define MOQDATA_STREAM_UNKNOWN 5
36
38#define MOQDATA_TYPE_SETUP 0x2F00ULL
40#define MOQDATA_TYPE_FETCH_HEADER 0x05ULL
42#define MOQDATA_TYPE_PADDING 0x132B3E28ULL
45#define MOQDATA_MSG_TYPE 0x70ULL
46
53
70
91
104
107void moqdata_subhdr_resolve(moqdata_subhdr* h, u64 first_object_id);
108
111typedef struct {
119
122
134
136#define MOQDATA_STATUS_NORMAL 0x0ULL
138#define MOQDATA_STATUS_END_OF_GROUP 0x3ULL
140#define MOQDATA_STATUS_END_OF_TRACK 0x4ULL
141
148 wired_span buf, usz* off, moqdata_objseq* seq, moqdata_obj* out);
149
155 wired_mspan buf, usz* off, u64 id_delta, wired_span payload);
156
159int moqdata_obj_put_status(wired_mspan buf, usz* off, u64 id_delta, u64 status);
160
172
176#define MOQDATA_MSG_OVERHEAD 37
177
185
189#define MOQDATA_BLOB_CHUNK 16384
190
196#define MOQDATA_BLOB_WIRE_CAP(n) \
197 ((n) + MOQDATA_MSG_OVERHEAD + 8 * ((n) / MOQDATA_BLOB_CHUNK + 1))
198
211
212#endif
int moqdata_subhdr_put(wired_mspan buf, usz *off, const moqdata_subhdr *h)
Writes h as a SUBGROUP_HEADER; the fields h->type selects are emitted (Subgroup ID only in mode 0b10,...
moqdata_objseq moqdata_objseq_of(u64 type)
Initializes an Object sequence from a SUBGROUP_HEADER Type byte.
int moqdata_classify(wired_span in, usz *off)
Classify a unidirectional stream by its leading Stream Type varint (3.4).
int moqdata_msg_build(wired_mspan buf, usz *off, const moqdata_msg *m)
Writes m as one SUBGROUP_HEADER + one Object (Object ID 0).
int moqdata_type_props(u64 type)
1 iff type has PROPERTIES (bit 0x01): each Object carries a Properties field.
int moqdata_subhdr_take(wired_span buf, usz *off, moqdata_subhdr *h)
Returns MOQDATA_OK/INSUFFICIENT/VIOLATION.
int moqdata_type_valid(u64 type)
SUBGROUP_HEADER Type byte (11.4.2): 0b0XX1XXXX with bit4 required and mode 0b11 reserved.
int moqdata_type_default_priority(u64 type)
1 iff type has DEFAULT_PRIORITY (bit 0x20): no Publisher Priority field in the header.
int moqdata_obj_put_status(wired_mspan buf, usz *off, u64 id_delta, u64 status)
Encodes an Object ID Delta of id_delta, Payload Length 0, and the given explicit Status.
usz moqdata_blob_build(wired_mspan buf, u64 track_alias, wired_span blob)
Multi-Object builder: moqdata_msg_build's SUBGROUP_HEADER (Type 0x70, track_alias,...
int moqdata_obj_put(wired_mspan buf, usz *off, u64 id_delta, wired_span payload)
Encodes an Object ID Delta of id_delta followed by payload.
int moqdata_type_end_of_group(u64 type)
1 iff type has END_OF_GROUP (bit 0x08).
void moqdata_subhdr_resolve(moqdata_subhdr *h, u64 first_object_id)
Resolves a mode-0b01 deferred Subgroup ID from the first Object ID.
int moqdata_obj_take(wired_span buf, usz *off, moqdata_objseq *seq, moqdata_obj *out)
Decodes one Object and advances *seq (Object ID chaining, 11.4.2).
u64 moqdata_type_sgid_mode(u64 type)
Subgroup ID mode, bits 0x06: 0 = Subgroup ID 0, 1 = first Object ID, 2 = explicit field,...
int moqdata_type_first_object(u64 type)
1 iff type has FIRST_OBJECT (bit 0x40).
Value-type views that fold the SDK's recurring argument shapes into single parameters,...
One-message builder: a single SUBGROUP_HEADER (Type 0x70: PROPERTIES off, mode 0b00,...
Definition moqdata.h:164
wired_span payload
The one Object's payload (copied into buf).
Definition moqdata.h:170
u64 group_id
Group ID carried by the header.
Definition moqdata.h:168
u64 track_alias
Track Alias carried by the header.
Definition moqdata.h:166
Decoded Object (11.4.2 / 4237-4466).
Definition moqdata.h:126
wired_span payload
Object payload; view into the stream buffer.
Definition moqdata.h:132
u64 object_id
Absolute Object ID after delta chaining.
Definition moqdata.h:128
u64 status
Object Status, one of MOQDATA_STATUS_*.
Definition moqdata.h:130
Per-subgroup Object decode state, threaded across successive moqdata_obj_take calls on the same SUBGR...
Definition moqdata.h:111
int have_prev
1 once an Object was decoded; the next delta chains from prev_id.
Definition moqdata.h:115
int has_props
1 iff each Object carries a Properties field (from the Type).
Definition moqdata.h:113
u64 prev_id
Object ID of the previous Object; valid iff have_prev.
Definition moqdata.h:117
Decoded SUBGROUP_HEADER (11.4.2).
Definition moqdata.h:76
u64 type
SUBGROUP_HEADER Type (flag bits, see moqdata_type_*).
Definition moqdata.h:78
u64 subgroup_id
Subgroup ID (0 for mode 0b00, wire field for 0b10, first Object ID for 0b01 once resolved).
Definition moqdata.h:85
u64 group_id
Group ID.
Definition moqdata.h:82
u64 track_alias
Track Alias the subscription was given.
Definition moqdata.h:80
int subgroup_id_pending
1 while a mode-0b01 Subgroup ID awaits the first Object.
Definition moqdata.h:87
u64 priority
Publisher Priority (0..255); 0 under DEFAULT_PRIORITY.
Definition moqdata.h:89
Mutable view of a byte range.
Definition span.h:42
Read-only view of a byte range.
Definition span.h:30
Linux direct syscalls.
u64 usz
unsigned size (size_t equivalent)
Definition types.h:20
unsigned long u64
unsigned 64-bit integer
Definition types.h:13