Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dc2bf2d
chore(quest): claim quest/m2/cut-gate/c/README.md
kixelated Nov 6, 2026
2bee67b
wip(moq-c): session auth, server config, catalog fields, closed, larg…
kixelated Nov 6, 2026
06facf5
wip(moq-c): decode video to a native surface
kixelated Nov 6, 2026
541ad8d
wip(moq-c): codec-only audio and video encoders
kixelated Nov 6, 2026
ccdbbe6
wip(moq-c): socket endpoints, group-ready wake on end, parity tests
kixelated Nov 6, 2026
c851f4b
wip(moq-c): rendition references on video and audio configs
kixelated Nov 6, 2026
4517233
wip(moq-c): docs for the new bindings, formatting
kixelated Nov 6, 2026
4a38bdc
wip(moq-c): lint fixes
kixelated Nov 6, 2026
d051c86
wip(moq-c): README cites current consume read calls
kixelated Nov 6, 2026
16eec92
Merge remote-tracking branch 'origin/main' into quest/m2/cut-gate/c/R…
kixelated Nov 6, 2026
d7fce30
chore(quest): finish quest/m2/cut-gate/c/README.md
kixelated Nov 6, 2026
4a486d0
fix(moq-c): a surface decode pins VideoToolbox and skips CPU validation
kixelated Nov 6, 2026
8564310
Merge remote-tracking branch 'origin/main' into quest/m2/cut-gate/c/R…
kixelated Nov 7, 2026
e2e4fa9
fix(moq-c): address review on the parity PR
kixelated Nov 8, 2026
d402e02
fix(moq-c): decoded consumers resolve rendition references
kixelated Nov 8, 2026
a2205c3
test(moq-c): poll group-ready waits by hand to prove they parked
kixelated Nov 8, 2026
f9578c4
fix(moq-c): a decoder cancel ends its sibling resolve wait
kixelated Nov 8, 2026
73709af
Merge remote-tracking branch 'origin/main' into t3/8060-close-wait
kixelated Nov 8, 2026
ec6cb0d
style(moq-c): format the resolve-cancel test
kixelated Nov 8, 2026
e364663
Merge remote-tracking branch 'origin/main' into t3/8060-close-wait
kixelated Nov 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/lib/c/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ inside. The header is the reference: each function carries a doc comment.

- **Handles and callbacks.** Every object is an integer handle, and every async result arrives on a `moq_status_callback` with your `void *user_data`. A status `> 0` is a live result, `0` a clean close, and `< 0` an error. The last two are terminal: moq-c never touches `user_data` again, so free it there. `*_close` and `*_cancel` only request shutdown; the terminal callback still fires. A session reports on a `moq_state_callback` instead: each `moq_connection_state` carries its `phase`, `connects`, the negative `failure` of the latest attempt, and the live `protocol`, and the `MOQ_CONNECTION_PHASE_CLOSED` snapshot is terminal, delivered after the handle is released. `moq_session_close()` drains finished tracks for dialed and accepted sessions; wait for that terminal snapshot to learn the result.
- **Errors.** Negative return codes are named by `MOQ_ERROR_*`, and `moq_error()` gives the reason on the calling thread. Auth rejections have their own codes so you don't retry them. For the peer's protocol code use `moq_error_protocol()`; do not parse `moq_error()`. A panic in a binding background task reports `MOQ_ERROR_PANIC` through its terminal callback; unrelated objects keep running. A session closed because its credential expired has kind `MOQ_PROTOCOL_KIND_EXPIRED`, and a request refused for an expired token returns `MOQ_ERROR_EXPIRED`; refresh the token before retrying. Malformed credentials report `MOQ_PROTOCOL_KIND_MALFORMED_AUTH_TOKEN`; correct the token before reconnecting with it. A catalog that needs a newer moq-hang draft than this build reads returns `MOQ_ERROR_UNSUPPORTED_CATALOG`; upgrade the library to read it. A request-cap closure has kind `MOQ_PROTOCOL_KIND_TOO_MANY_REQUESTS`; reduce the workload or adjust the relay's [session limits](/bin/relay/config#session-and-peer) before reconnecting.
- **Tokens.** Set `moq_client_config.tokens` instead of putting the credential in the URL. The first is the connection credential, sent in SETUP and, while an offered version can't carry it there (lite before 07), as the URL's `?jwt=`; each other token widens the grant over AUTH. A `?jwt=` already in the URL stays the connection credential, which is how to reach a relay older than this release. To replace expiring tokens, close the session and connect again.
- **Tokens.** Set `moq_client_config.tokens` instead of putting the credential in the URL. The first is the connection credential, sent in SETUP and, while an offered version can't carry it there (lite before 07), as the URL's `?jwt=`; each other token widens the grant over AUTH. A `?jwt=` already in the URL stays the connection credential, which is how to reach a relay older than this release. `moq_session_tokens_set()` replaces them before they expire: the next dial presents them, and a live AUTH session at once. A live session without AUTH (lite before 07, or moq-transport without the extension) keeps the old credential until it redials, and `moq_session_tokens_answered()` reports `MOQ_ERROR_UNSUPPORTED` for it. Otherwise that call reports the peer's verdict. Follow what the peer granted with `moq_session_grants()`.
- **Threading.** Call any function from any thread. Callbacks run on moq-c's runtime thread; the callback and its `user_data` must be safe to use there. Synchronize access to data shared with other threads, and dispatch UI work to your UI thread. Raw publish calls block until the codec takes the frame, which paces a publisher.
- **Zeroed config is the default.** A zeroed `moq_client_config` means the default for every field, so new fields don't break callers. A field whose default isn't zero has a `has_*` flag: `backoff_timeout_us = 0` means "retry forever" only with `has_backoff_timeout = true`.
- **Subscription defaults.** A zeroed `moq_subscription`, a NULL pointer, and `moq_subscription_defaults()` all mean moq-net's defaults, whose zero `delay` starts at the newest group and skips a superseded one at once. Set `delay.max_unlimited` for no subscriber limit, and `delay.min_unstated` to leave the target latency unstated.
Expand Down
2 changes: 1 addition & 1 deletion doc/lib/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ how it looks in that language:
- **Connection stats** and **errors** that tell an auth rejection (don't retry) from a shutdown or a transport failure.
- **Authorization in band**: read the grant the relay sent back (the patterns this side may publish and subscribe to, and when it lapses), and present a fresh token before the current one expires, without reconnecting. It needs `moq-lite-07-wip`, which is opt-in, or moq-transport draft-18+ with the [MoQ Auth extension](/draft/moq-auth).

C's audio decoder takes a playout delay only as the floor `moq_delay.min_us` under its estimate, and reports none; C has no in-band authorization.
C cannot fetch a single group by sequence.

## Upgrading

Expand Down
4 changes: 0 additions & 4 deletions quest/m2/cut-gate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,3 @@ run re-created in m3. Only `/quest-delete` ends the recurrence.

The completed [release performance comparison](/.github/release-perf.md)
records the accepted costs and final relay pairing for this cut.

## Required

- [moq-c at parity](/quest/m2/cut-gate/c/README.md) - the hand-written `moq-c` ships at the cut with every binding feature moq-ffi gains
32 changes: 0 additions & 32 deletions quest/m2/cut-gate/c/README.md

This file was deleted.

5 changes: 4 additions & 1 deletion quest/m3/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ scope; they already sit on moq-ffi through the generated C++.

Decided 2026-10-25 (maintainer): this line ships after the cut, once moq builds
its bindings from rust2's UniFFI fork. The hand-written crate ships at the cut
with [parity](/quest/m2/cut-gate/c/README.md) instead. The generator fix for the C name
instead, with the binding features moq-ffi gained in m1 and m2
([moq-dev/moq#8060](https://github.com/moq-dev/moq/pull/8060)). Features moq-c
never had, such as single-group fetch and group-level consumption, wait for this
line. The generator fix for the C name
clash landed in rust2's fork
([moq-dev/rust2#66](https://github.com/moq-dev/rust2/pull/66)), not in a
`kixelated/uniffi-bindgen-cpp` release, and reaches moq with the switch.
Expand Down
2 changes: 1 addition & 1 deletion quest/m3/c/consumers.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ the smoke client (`test/smoke/clients/c`), which
callbacks on the host's own loop through `moq_set_dispatcher`.

Waits for the cut and the generator switch (found when first started,
2026-10-28; decided 2026-10-31). Until the cut, [moq-c parity](/quest/m2/cut-gate/c/README.md) ships the
2026-10-28; decided 2026-10-31). Until the cut, moq-c parity ([moq-dev/moq#8060](https://github.com/moq-dev/moq/pull/8060)) ships the
hand-written crate at 0.22 and proves it with this interop client and the current
`doc/lib/c`, and `doc/` describes only what ships, so either half landing first
drops the shipping crate's proof and documents an unpublished API. The switch
Expand Down
4 changes: 0 additions & 4 deletions quest/m5/c-origin-relay.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,3 @@ watcher.

Public API: additive in moq-c, or in moq-ffi if the generated C line has
replaced it. Wire: none.

## Related

- [moq-c at parity](/quest/m2/cut-gate/c/README.md) - the hand-written crate's pre-cut parity work, which this does not block
53 changes: 51 additions & 2 deletions rs/moq-c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ int32_t moq_viewer_rate(uint32_t viewer, uint64_t *bps, bool *present);
int32_t moq_viewer_update(uint32_t viewer, uint64_t max_bps);
int32_t moq_viewer_close(uint32_t viewer);

// Session: Auth (a dialed session's tokens, and the grant the peer answers with)
int32_t moq_session_tokens_set(uint32_t session, const moq_string *tokens, uintptr_t tokens_len);
int32_t moq_session_tokens_answered(uint32_t session, moq_status_callback on_answer, void *user_data);
int32_t moq_session_grants(uint32_t session, moq_status_callback on_grant, void *user_data);
int32_t moq_session_grants_cancel(uint32_t watcher);
int32_t moq_grant_info(uint32_t grant, moq_grant *dst);
int32_t moq_grant_free(uint32_t grant);

// Server
int32_t moq_server_listen(const moq_server_config *config, moq_status_callback on_request, void *user_data);
int32_t moq_server_addr(uint32_t server, moq_string *dst);
Expand Down Expand Up @@ -101,7 +109,12 @@ int32_t moq_publish_track_group(uint32_t track);
int32_t moq_publish_track_frame(uint32_t track, const uint8_t *payload, uintptr_t payload_size, const moq_timestamp *timestamp);
int32_t moq_publish_group_frame(uint32_t group, const uint8_t *payload, uintptr_t payload_size, const moq_timestamp *timestamp);
int32_t moq_publish_group_finish(uint32_t group);
int32_t moq_publish_group_ready(uint32_t group, uint64_t size, moq_status_callback on_ready, void *user_data);
int32_t moq_publish_track_finish(uint32_t track);
int32_t moq_publish_track_largest(uint32_t track, uint64_t *group, uint64_t *frame, bool *present);
int32_t moq_publish_timebase(uint32_t broadcast);
int32_t moq_publish_timebase_free(uint32_t timebase);
// moq_container_init.timebase (0 for none) shares one source clock across containers.

// Publishing: Demand
int32_t moq_publish_track_demand(uint32_t track, moq_status_callback on_demand, void *user_data);
Expand Down Expand Up @@ -131,6 +144,8 @@ int32_t moq_group_request_free(uint32_t request);

// Consuming
int32_t moq_consume_close(uint32_t consume);
int32_t moq_consume_closed(uint32_t broadcast, moq_status_callback on_closed, void *user_data);
int32_t moq_consume_closed_cancel(uint32_t watcher);

// Consuming: Catalog
int32_t moq_consume_catalog(uint32_t broadcast, moq_status_callback on_catalog, void *user_data);
Expand All @@ -150,13 +165,47 @@ int32_t moq_consume_audio(uint32_t catalog, uint32_t index, const moq_delay *del
int32_t moq_consume_audio_cancel(uint32_t track);

// Consuming: Frames
int32_t moq_consume_frame(uint32_t frame, moq_frame *dst);
int32_t moq_consume_frame_free(uint32_t frame);
int32_t moq_consume_read(uint32_t read, moq_media_read *dst);
int32_t moq_consume_read_free(uint32_t read);
moq_subscription moq_subscription_defaults(void);
int32_t moq_consume_track(uint32_t broadcast, const char *name, uintptr_t name_len, const moq_subscription *subscription, moq_status_callback on_frame, void *user_data);
int32_t moq_consume_track_frame(uint32_t frame, moq_frame *dst);
int32_t moq_consume_track_frame_free(uint32_t frame);
int32_t moq_consume_track_cancel(uint32_t track);

// Sockets: two-way sessions between endpoints sharing an origin
int32_t moq_socket_create(uint32_t origin, const char *prefix, uintptr_t prefix_len, const char *id, uintptr_t id_len);
int32_t moq_socket_close(uint32_t endpoint);
int32_t moq_socket_dial_tcp(uint32_t endpoint, const char *peer, uintptr_t peer_len, moq_status_callback on_stream, void *user_data);
int32_t moq_socket_dial_track(uint32_t endpoint, const char *peer, uintptr_t peer_len, const moq_track_info *info, moq_status_callback on_stream, void *user_data);
int32_t moq_socket_accept_tcp(uint32_t endpoint, moq_status_callback on_incoming, void *user_data);
int32_t moq_socket_accept_track(uint32_t endpoint, moq_status_callback on_incoming, void *user_data);
int32_t moq_socket_cancel(uint32_t task);
int32_t moq_socket_incoming_info(uint32_t incoming, moq_string *peer, moq_string *session);
int32_t moq_socket_incoming_accept(uint32_t incoming, const moq_track_info *info, moq_status_callback on_stream, void *user_data);
int32_t moq_socket_incoming_reject(uint32_t incoming);
int32_t moq_socket_stream_info(uint32_t stream, moq_string *peer, moq_string *session);
int32_t moq_socket_stream_writer(uint32_t stream); // a group (tcp) or raw track (track) handle
int32_t moq_socket_stream_reader(uint32_t stream, moq_status_callback on_frame, void *user_data); // read like moq_consume_track
int32_t moq_socket_stream_free(uint32_t stream);

// Codecs without a broadcast: encode, then publish or store the packets yourself
int32_t moq_audio_encoder_create(const moq_audio_encoder_output *output);
int32_t moq_audio_encoder_frame_size(uint32_t encoder);
int32_t moq_audio_encoder_init(uint32_t encoder, moq_audio_init *dst);
int32_t moq_audio_encoder_bitrate(uint32_t encoder, uint64_t bitrate);
int32_t moq_audio_encoder_encode(uint32_t encoder, const float *pcm, uintptr_t pcm_len);
int32_t moq_audio_encoder_finish(uint32_t encoder, const float *pcm, uintptr_t pcm_len, uint64_t *discard_padding);
int32_t moq_audio_encoder_packet(uint32_t encoder, uint32_t index, moq_frame *dst);
int32_t moq_audio_encoder_free(uint32_t encoder);
int32_t moq_video_encoder_create(const moq_video_encoder_input *input, const moq_video_encoder_output *output);
int32_t moq_video_encoder_encode(uint32_t encoder, const moq_video_encoder_frame *frame);
int32_t moq_video_encoder_cut(uint32_t encoder);
int32_t moq_video_encoder_bitrate(uint32_t encoder, uint64_t bitrate);
int32_t moq_video_encoder_flush(uint32_t encoder);
int32_t moq_video_encoder_finish(uint32_t encoder);
int32_t moq_video_encoder_packet(uint32_t encoder, uint32_t index, moq_frame *dst);
int32_t moq_video_encoder_free(uint32_t encoder);
```

Raw track frames use the same `moq_frame` record as media frames. Timestamps
Expand Down
3 changes: 2 additions & 1 deletion rs/moq-c/c-tests/decode-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ _Static_assert(offsetof(moq_video_decoder_output, format) == 24, "format moved")
_Static_assert(offsetof(moq_video_decoder_output, width) == 28, "width moved");
_Static_assert(offsetof(moq_video_decoder_output, height) == 32, "height moved");
_Static_assert(offsetof(moq_video_decoder_output, start) == 36, "start moved");
_Static_assert(sizeof(moq_video_decoder_output) == 40, "decoder output size changed");
_Static_assert(offsetof(moq_video_decoder_output, surface) == 40, "surface moved");
_Static_assert(sizeof(moq_video_decoder_output) == 48, "decoder output size changed");
_Static_assert(MOQ_DECODE_READ_FRAME == 0, "frame read discriminant moved");
_Static_assert(MOQ_DECODE_READ_GAP == 1, "gap read discriminant moved");
_Static_assert(MOQ_DECODE_READ_END == 2, "end read discriminant moved");
Expand Down
Loading
Loading