Skip to main content

Crate moq

Crate moq 

Source
Expand description

C bindings for moq_net.

Provides a C-compatible API for real-time pub/sub over QUIC.

§Concepts

  • Session: Network connection to a MoQ relay, or one accepted by a server
  • Origin: Collection of broadcasts
  • Broadcast: Container for tracks
  • Track: Named stream of groups
  • Group: Collection of frames
  • Frame: Sized payload with timestamp

§Error Handling

All functions return negative error codes on failure or non-negative values on success. Resources are managed through opaque integer handles that must be explicitly closed.

Structs§

Audio
DecoderOutput
What moq_decode_video delivers per frame: the requested CPU pixel format and target size, validated up front so the delivery loop never second-guesses.
Id
Opaque resource identifier returned to C code.
Video
Raw-video state: encoders being published, plus decoder tasks and their buffered decoded frames.
moq_announce_update
A route announcement or retraction from an origin.
moq_audio_config
Information about an audio rendition in the catalog.
moq_audio_decoder_output
PCM layout the caller wants out of moq_decode_audio.
moq_audio_encoder_input
PCM layout the caller hands to moq_encode_audio_frame.
moq_audio_encoder_output
Codec-side configuration. sample_rate / channels = 0 means “match the input (snapping the rate up to a libopus-supported value if necessary)”.
moq_audio_frame
One audio frame: payload bytes plus a presentation timestamp.
moq_audio_init
Configuration for moq_publish_audio.
moq_binary_config
Options for a binary data track, in either mode.
moq_client_config
Settings for moq_session_connect, or NULL to dial with the defaults.
moq_connection_snapshot
Statistics and protocol sampled from the same connection by moq_session_snapshot.
moq_connection_stats
A snapshot of connection statistics, filled in by moq_session_stats.
moq_container
The container of a video or audio rendition, plus whatever that container needs to describe itself.
moq_container_init
Configuration for moq_publish_container.
moq_datagram
A best-effort raw track datagram delivered via moq_consume_datagrams.
moq_frame
Information about a frame of media.
moq_json_snapshot_config
Options for a JSON snapshot track (lossy latest-value mode).
moq_json_stream_config
Options for a JSON stream track (lossless append-log mode).
moq_json_value
A JSON value delivered by a consumer callback.
moq_protocol_error
A protocol failure a peer sent: scope, verbatim wire code, and recognized kind.
moq_route
A route advertisement: hops and costs.
moq_section
One untyped application catalog section: a name and its JSON value.
moq_server_config
Settings for moq_server_listen.
moq_string
A borrowed UTF-8 string slice, NOT NULL terminated.
moq_subscription
Subscriber-side raw track delivery preferences.
moq_track_info
Publisher-side raw track properties.
moq_video_config
Information about a video rendition in the catalog.
moq_video_decoder_output
Decode-side configuration the caller passes to moq_decode_video.
moq_video_encoder_frame
One raw frame handed to moq_encode_video_frame.
moq_video_encoder_input
Raw frame layout the caller hands to moq_encode_video_frame, plus the resolution and rate the encoder is opened at. Every published frame must match width x height; scale before publishing if your source moves.
moq_video_encoder_output
Codec-side configuration for moq_encode_video. Every knob spells “unset” as 0.
moq_video_frame
One decoded video frame from moq_decode_video: pixels plus a presentation timestamp.
moq_video_hint
Optional catalog fields for moq_video_init::hint.
moq_video_init
Configuration for moq_publish_video.
moq_video_properties
Catalog properties shared by every video rendition.

Enums§

Error
Error types that can occur in the FFI layer.
moq_audio_format
A single audio codec moq_publish_audio can parse.
moq_audio_sample_format
Raw PCM sample layout, mirroring WebCodecs AudioData.format.
moq_container_format
A container moq_publish_container can demux, which may publish several tracks.
moq_container_kind
How a media track’s frames are wrapped, independent of the codec.
moq_demand
Whether a published track has subscribers, as reported by a demand watcher.
moq_error_scope
Whether a protocol code is from the session or stream registry.
moq_protocol_kind
A recognized protocol kind. Pair with moq_error_scope: CANCEL is 0 on a session and 1 on a stream. APP and UNKNOWN keep the numeric code in moq_protocol_error.
moq_video_codec
Output video codec for moq_encode_video.
moq_video_encoder_kind
Which encoder implementation moq_encode_video should use.
moq_video_format
A single video codec moq_publish_video can parse.
moq_video_pixel_format
Pixel layout of the raw frames handed to moq_encode_video_frame.

Constants§

MOQ_ERROR_ANNOUNCEMENT_NOT_FOUND
MOQ_ERROR_AUDIO
MOQ_ERROR_BROADCAST_NOT_FOUND
MOQ_ERROR_BUFFER_NOT_CONSUMED
MOQ_ERROR_CATALOG_NOT_FOUND
MOQ_ERROR_CONNECT
MOQ_ERROR_FORBIDDEN
MOQ_ERROR_FRAME_NOT_FOUND
MOQ_ERROR_GROUP_NOT_FOUND
MOQ_ERROR_HANG
MOQ_ERROR_INIT_FAILED
MOQ_ERROR_INVALID_CODE
MOQ_ERROR_INVALID_CONFIG
MOQ_ERROR_INVALID_ID
MOQ_ERROR_INVALID_POINTER
MOQ_ERROR_JSON
MOQ_ERROR_JSON_TRACK
MOQ_ERROR_LEVEL
MOQ_ERROR_MEDIA_NOT_FOUND
MOQ_ERROR_MOQ
MOQ_ERROR_MUX
MOQ_ERROR_NATIVE
MOQ_ERROR_NOT_FOUND
MOQ_ERROR_NO_INDEX
MOQ_ERROR_NUL
MOQ_ERROR_OFFLINE
MOQ_ERROR_ORIGIN_NOT_FOUND
MOQ_ERROR_PANIC
MOQ_ERROR_SESSION_NOT_FOUND
MOQ_ERROR_TIMESTAMP_OVERFLOW
MOQ_ERROR_TRACK_NOT_FOUND
MOQ_ERROR_UNAUTHORIZED
MOQ_ERROR_UNKNOWN_FORMAT
MOQ_ERROR_UNRESOLVABLE_BROADCAST
MOQ_ERROR_URL
MOQ_ERROR_UTF8
MOQ_ERROR_VIDEO

Functions§

moq_bandwidth_close
Release a bandwidth handle. Reservations taken against it stay until they themselves are closed (or the session’s allocator is gone).
moq_bandwidth_reserve
Reserve up to max_bps for track, returning a reservation handle.
moq_broadcast_request_accept
Accept a broadcast request with an unannounced broadcast producer.
moq_broadcast_request_free
Free a broadcast request without accepting or rejecting it.
moq_broadcast_request_path⚠
The path of a broadcast request delivered to a moq_origin_dynamic callback.
moq_broadcast_request_reject
Reject a broadcast request with an application error code.
moq_client_defaults
The settings moq_session_connect dials with when given NULL.
moq_consume_audio⚠
Consume an audio track from a broadcast, emitting the frames in order.
moq_consume_audio_cancel
Stop an audio track consumer’s background task.
moq_consume_audio_config⚠
Query information about an audio track in a catalog.
moq_consume_catalog⚠
Create a catalog consumer for a broadcast.
moq_consume_catalog_cancel
Stop a catalog consumer’s background subscription.
moq_consume_catalog_free
Free a catalog snapshot received via the moq_consume_catalog callback.
moq_consume_catalog_section⚠
Look up an application catalog section by name.
moq_consume_catalog_section_at⚠
Query an application catalog section by index, keyed by name.
moq_consume_catalog_section_count
Number of untyped application catalog sections in a catalog snapshot.
moq_consume_close
Close a broadcast consumer and clean up its resources.
moq_consume_datagram⚠
Read a datagram delivered via the moq_consume_datagrams callback.
moq_consume_datagram_free
Free a datagram delivered via the moq_consume_datagrams callback, releasing its payload.
moq_consume_datagrams⚠
Subscribe to a raw track’s best-effort datagrams by name.
moq_consume_datagrams_cancel
Stop a datagram subscription’s background task.
moq_consume_frame⚠
Get a chunk of a frame’s payload.
moq_consume_frame_free
Free a decoded frame delivered via a moq_consume_video or moq_consume_audio callback.
moq_consume_json_cancel
Stop a JSON consumer’s background task (snapshot or stream).
moq_consume_json_snapshot⚠
Subscribe to a JSON snapshot track (lossy latest-value) by name.
moq_consume_json_stream⚠
Subscribe to a JSON stream track (lossless append-log) by name.
moq_consume_json_value⚠
Read a JSON value delivered via a moq_consume_json_snapshot or moq_consume_json_stream callback.
moq_consume_json_value_free
Release a JSON value delivered via a consumer callback.
moq_consume_track⚠
Subscribe to a raw track by name, delivering each frame’s payload as-is.
moq_consume_track_cancel
Stop a raw track consumer’s background task.
moq_consume_track_frame⚠
Read a raw frame’s payload delivered via the moq_consume_track callback.
moq_consume_track_frame_free
Free a raw frame delivered via the moq_consume_track callback, releasing its payload.
moq_consume_track_update⚠
Update a raw track subscription’s delivery preferences.
moq_consume_video⚠
Consume a video track from a broadcast, delivering frames in order.
moq_consume_video_cancel
Stop a video track consumer’s background task.
moq_consume_video_config⚠
Query information about a video track in a catalog.
moq_consume_video_properties⚠
Query the catalog properties shared by every video rendition.
moq_consume_video_stalled⚠
Query whether the publisher recommends temporarily avoiding a video rendition.
moq_decode_audio⚠
Subscribe to an audio track and decode it into PCM.
moq_decode_audio_cancel
Stop an audio (raw PCM) consumer’s background task.
moq_decode_audio_frame⚠
Copy a delivered frame’s metadata into dst.
moq_decode_audio_frame_free
Free a frame previously delivered through the consume callback. Required for every delivered frame ID; closing the parent consumer is not enough.
moq_decode_video⚠
Subscribe to a video track and decode it into raw frames in the requested CPU pixel format and size (see moq_video_decoder_output).
moq_decode_video_cancel
Stop a video (raw) consumer’s background task.
moq_decode_video_frame⚠
Copy a delivered frame’s metadata into dst.
moq_decode_video_frame_free
Free a frame previously delivered through the consume callback. Required for every delivered frame id; closing the parent consumer is not enough.
moq_encode_audio⚠
Open an audio track on a broadcast.
moq_encode_audio_demand⚠
Watch whether the encoded audio track has subscribers, so the microphone and encoder run only while someone listens. See crate::moq_publish_media_demand for the callback contract.
moq_encode_audio_finish
Flush any pending samples and finalize an audio producer.
moq_encode_audio_frame⚠
Push one audio frame.
moq_encode_audio_reservation
This encoder’s bandwidth reservation, or 0 if it was published without one.
moq_encode_video⚠
Open a video track on a broadcast, encoding the raw frames you publish to it.
moq_encode_video_bitrate
Retune a live encoder to bitrate bits per second, taking effect from roughly the next frame. No keyframe is forced, so this is cheap enough to drive from a congestion controller.
moq_encode_video_cut
Cut a new group at the next published frame.
moq_encode_video_demand⚠
Watch whether the encoded video track has subscribers, so the camera and encoder run only while someone watches. See crate::moq_publish_media_demand for the callback contract.
moq_encode_video_finish
Flush any frames the codec is still holding and finalize the video track.
moq_encode_video_frame⚠
Encode and publish one raw frame.
moq_encode_video_reservation
This encoder’s bandwidth reservation, or 0 if it was published without one.
moq_error
Human-readable reason for the most recent failed call on the calling thread.
moq_error_protocol⚠
Structured protocol details for the most recent failed call on the calling thread.
moq_group_request_abort
Reject a group request with an application error code, failing the waiting fetches.
moq_group_request_accept
Accept a group request, resolving the waiting fetches with the group you then fill.
moq_group_request_frame_start⚠
The first frame of the group the fetch wants; 0 is the whole group.
moq_group_request_free
Free a group request without accepting it, which rejects it.
moq_group_request_priority⚠
The delivery priority the fetching consumer asked for.
moq_group_request_sequence⚠
The group sequence a group request asks for.
moq_log_level⚠
Initialize the library with a log level.
moq_origin_announced⚠
Learn about broadcasts matching a pattern scope under an origin.
moq_origin_announced_broadcast⚠
Consume a broadcast from an origin by path, waiting until something can serve it.
moq_origin_announced_broadcast_cancel
Abort a wait started by moq_origin_announced_broadcast.
moq_origin_announced_cancel
Stop receiving announcements for broadcasts published to an origin.
moq_origin_announced_free
Free a single announcement delivered to a moq_origin_announced on_announce callback.
moq_origin_announced_info⚠
Query information about a broadcast discovered by moq_origin_announced.
moq_origin_close
Close an origin and clean up its resources.
moq_origin_create
Create an origin for publishing broadcasts.
moq_origin_create_broadcast⚠
Create a broadcast at path on an origin, for publishing media tracks.
moq_origin_dynamic⚠
Advertise prefix and serve the requests beneath it.
moq_origin_dynamic_cancel
Stop serving and retract the route.
moq_origin_dynamic_update⚠
Re-price a served route in place. The prefix cannot change.
moq_origin_request⚠
Request a broadcast from an origin by path, resolving as soon as it can be served.
moq_origin_request_cancel
Abort a request started by moq_origin_request.
moq_publish_announce⚠
Advertise a broadcast’s exact path as a route.
moq_publish_audio⚠
Publish one audio codec as a new media track.
moq_publish_audio_config⚠
Add or replace an audio rendition in a broadcast’s catalog.
moq_publish_audio_remove⚠
Remove an audio rendition from a broadcast’s catalog by name.
moq_publish_binary_snapshot⚠
Create a binary snapshot track (lossy latest-value) on a broadcast: each payload supersedes the last, and a late joiner only sees the newest, e.g. the latest thumbnail of a camera.
moq_publish_binary_snapshot_finish
Finish a binary snapshot track and retire its catalog entry. No more payloads can be published.
moq_publish_binary_snapshot_update⚠
Publish a new payload to a binary snapshot track, superseding the last.
moq_publish_binary_stream⚠
Create a binary stream track (lossless append-log) on a broadcast: every payload is preserved and delivered in order.
moq_publish_binary_stream_append⚠
Append one payload to a binary stream track.
moq_publish_binary_stream_finish
Finish a binary stream track and retire its catalog entry. No more payloads can be appended.
moq_publish_catalog_section⚠
Set (or replace) a top-level application catalog section by name.
moq_publish_catalog_section_remove⚠
Remove a top-level application catalog section by name.
moq_publish_container⚠
Publish a container, which demuxes and publishes its own tracks.
moq_publish_container_cut
Declare that the next chunk starts a new segment, rolling a group on every track the container publishes.
moq_publish_container_finish
Finish every track the container publishes and release the handle.
moq_publish_container_seek
Start a new segment and number its groups sequence.
moq_publish_container_write⚠
Write a whole chunk of container bytes.
moq_publish_demand_cancel
Stop a demand watcher from moq_publish_track_demand, moq_publish_media_demand, crate::moq_encode_video_demand, or crate::moq_encode_audio_demand.
moq_publish_dynamic⚠
Serve subscriber requests for tracks the broadcast has not declared.
moq_publish_dynamic_cancel
Stop a request handler from moq_publish_dynamic, moq_publish_track_dynamic, or moq_track_request_dynamic. Requests not yet delivered are rejected.
moq_publish_finish
Finish a broadcast and release it, ending its catalog cleanly.
moq_publish_group_abort
Abort a raw group with an application error code.
moq_publish_group_finish
Finish a raw group. No more frames can be written.
moq_publish_group_frame⚠
Write a frame into a raw group created by moq_publish_track_group.
moq_publish_json_snapshot⚠
Create a JSON snapshot track (lossy latest-value) on a broadcast.
moq_publish_json_snapshot_finish
Finish a JSON snapshot track. No more values can be published.
moq_publish_json_snapshot_update⚠
Publish a new value to a JSON snapshot track. value is a UTF-8 JSON document. A no-op if unchanged from the previous update.
moq_publish_json_stream⚠
Create a JSON stream track (lossless append-log) on a broadcast.
moq_publish_json_stream_append⚠
Append one record to a JSON stream track. value is a UTF-8 JSON document.
moq_publish_json_stream_finish
Finish a JSON stream track. No more records can be appended.
moq_publish_media_cut
Draw a group boundary on a media importer.
moq_publish_media_demand⚠
Watch whether a media track has subscribers, so an encoder runs only while someone watches.
moq_publish_media_finish
Finish a media track, flushing any buffered frames. No more frames can be written.
moq_publish_media_flush
Record the transport handoff of one locally encoded frame for catalog jitter.
moq_publish_media_frame⚠
Write data to a track.
moq_publish_media_seek
Draw a group boundary and number the next group sequence.
moq_publish_track⚠
Create a raw track on a broadcast for arbitrary byte payloads.
moq_publish_track_abort
Abort a raw track with an application error code.
moq_publish_track_datagram⚠
Send a best-effort datagram on a raw track created by moq_publish_track.
moq_publish_track_demand⚠
Watch whether a raw track has subscribers. See moq_publish_media_demand for the callback contract.
moq_publish_track_dynamic⚠
Serve fetches of groups a raw track no longer has cached.
moq_publish_track_finish
Finish a raw track. No more groups or frames can be written.
moq_publish_track_finish_at
Declare a raw track’s exclusive final group sequence.
moq_publish_track_frame⚠
Write a single-frame group to a raw track with a timestamp.
moq_publish_track_group
Append a new group to a raw track, returning a group producer.
moq_publish_track_group_at
Create a raw group with an explicit sequence number.
moq_publish_unannounce
Retract a broadcast’s exact-path advertisement, if any.
moq_publish_video⚠
Publish one video codec as a new media track.
moq_publish_video_config⚠
Add or replace a video rendition in a broadcast’s catalog.
moq_publish_video_properties⚠
Replace the catalog properties shared by every video rendition.
moq_publish_video_remove⚠
Remove a video rendition from a broadcast’s catalog by name.
moq_qlog_supported
Whether this build can capture qlog traces.
moq_reservation_close
Release a reservation, handing its share back to siblings.
moq_reservation_grant⚠
This reservation’s slice right now, in bits per second.
moq_reservation_update
Change the ceiling, keeping the same claim.
moq_server_addr⚠
The address a server bound, e.g. 127.0.0.1:4443.
moq_server_close
Stop listening.
moq_server_fingerprints⚠
The SHA-256 fingerprints of the server’s certificates, hex encoded.
moq_server_listen⚠
Listen for incoming sessions.
moq_session_bandwidth
The session’s bandwidth allocator. Clones share one reservation registry.
moq_session_close
Request that a session shut down.
moq_session_connect⚠
Start establishing a connection to a MoQ server.
moq_session_request_accept⚠
Accept a session request, completing the MoQ handshake.
moq_session_request_free
Free a session request without accepting or rejecting it.
moq_session_request_path⚠
The path of a session request, without the query, or empty for the root.
moq_session_request_query⚠
The query of a session request without the leading ?, or a NULL data if it has none.
moq_session_request_reject
Reject a session request with an HTTP-style status code.
moq_session_snapshot⚠
Snapshot statistics and the negotiated protocol from the same live connection.
moq_session_stats⚠
Snapshot the current connection statistics for a session.
moq_track_request_abort
Reject a track request with an application error code, failing the waiting subscribers.
moq_track_request_accept⚠
Accept a track request as a raw track, resolving the waiting subscribers.
moq_track_request_audio⚠
Accept a track request as an audio track, the importer picking the timescale.
moq_track_request_dynamic⚠
Serve fetches of uncached groups on a requested track, before accepting it.
moq_track_request_free
Free a track request without accepting it, which rejects it.
moq_track_request_name⚠
The name of a track request delivered to a moq_publish_dynamic callback.
moq_track_request_video⚠
Accept a track request as a video track, the importer picking the timescale.
moq_versions⚠
List the protocol versions offered during the handshake by default.

Type Aliases§

Status
Status code returned by FFI functions.
moq_status_callback
A callback receiving a positive handle/value, zero on clean completion, or a negative error.