Skip to main content
Everything here lives in namespace reactor and arrives with #include <reactor/reactor.hpp>.

Status

Definition
Four states, in the order they happen. Read the current one with client.status(), or subscribe with on_status().
Signature
status_from_string reads an unrecognised spelling as Disconnected: a client that cannot understand what the library is telling it should behave as though it has no session, rather than assume the most capable state it knows.
Several calls require Ready and throw InvalidStateError otherwise — upload_file(), publish(), push_frame(), set_bitrate().

ReactorError

Thrown when an operation fails — from .get() on a future, or directly from a synchronous call — and the payload on_error delivers. The same class either way: what the event hands you is not a separate type that happens to agree with the exception, it is the exception.
Definition
Every code in the table below has its own subclass, so a specific failure is caught by class rather than by parsing code():
Example
ReactorError is the base of all of them, so catch (const ReactorError&) still catches every one.
recoverable is not computed in C++. The core decides it from the code and sends it, so two SDKs cannot disagree about whether a timeout is worth retrying.
There is no component field. Which tier of the platform failed is not something a caller can act on, and splitting codes by it once produced two names for one failure — a 401 during connect that the caller saw as UNAUTHORIZED and not recoverable while the event called it CONNECTION_FAILED and recoverable, so anything listening to the event reconnected in a loop against a token that would never work. Match on code() alone.

Error codes

The spellings are also available as constants under reactor::codes — reactor::codes::UNAUTHORIZED and so on.
Codes are open-ended. A command or control request the model itself rejects reports the platform’s own code, which this list cannot enumerate — that arrives as the base ReactorError with code() set to whatever came. Match on code() for anything not in the table, and never assume an unrecognised code means the payload was malformed.

Subscription

What every on_* registration hands back. An RAII token: it unregisters the handler when it goes out of scope.
Definition
Example
remove() and the destructor also wait for a delivery already in flight on another thread. When either returns, the handler is not in a call, so whatever it captured is safe to destroy.
Discarding the return value unregisters immediately — client.on_status(...); as a statement registers a handler and cancels it on the same line, which is usually a bug and always a quiet one. Hold the token, or call detach() for a handler meant to live as long as the client does:
This is the one place the C++ surface diverges from the Python one, which offers off(event, handler). Two std::functions cannot be compared, so a C++ binding has no way to find “the handler you passed earlier” — a token is the only honest answer, and it doubles as RAII. Move-only, like every other handle here.

FileRef

A file the platform is holding, ready to be passed into a command. Returned by upload_file() and upload_bytes().
Definition
A parameter that takes one file is handed to send_command() as a named upload rather than embedded in the arguments — the platform resolves the reference on its side, so the bytes cross the wire once. A parameter that takes several has no named slot. Put those references in the arguments: a FileRef converts to Json as that same reference, and Json::array({first, second}) is the list. See File Uploads.

Clip

A clip or a full-session recording, once the platform has accepted the request — which is not the same as it being ready. Returned by request_clip() and request_recording().
Definition

download()

Fetches and assembles the clip into one playable file at path, waiting for it to become ready.
Example
The file is created before anything is asked of the network, so an unwritable path fails immediately; a download that fails part-way leaves nothing behind, because a truncated clip opens, plays some of itself, and gives no reason to suspect the download.
Definition
Empty is the right default for a model generating slower than real time: a clip becomes ready because the model keeps generating, and once the session is gone a “not yet” is a “not yet” forever, which is what ends the wait. predicted_ready_at_ms is a wall clock plus media seconds, so it is only right for a model generating at real time — treat it as an anchor, never a deadline.
Reactor does not host clips: playlist_url() names a short-lived HLS playlist, and the fragments behind it have to be fetched and assembled. That assembly lives in the Rust core, so this SDK carries no HTTP client and no playlist parser of its own. See Recordings.

ConnectionStats

Returned by get_stats().
Definition
An unmeasured field is empty, never zero. A missing RTT does not mean a zero-latency link. candidate_type reads "relay" when the media goes through a TURN server. Check this field first when latency is bad. The SDK measures the two bitrates on the candidate pair that carries the media, over the window since the previous call. Both read empty on the first call after connecting, again after a reconnect, and until ICE selects a pair. A call made less than 200 ms after the last one also reads empty for them. Every other field is on every call. The SDK reads jitter_s, packet_loss_ratio, and frames_per_second from the received video stream. With no video stream, the first two fall back to whatever receive streams exist, and frames_per_second stays empty. reactor-webrtc 0.15 brought this shape to field-for-field parity with the browser SDK’s own getStats() — same candidate pair, same byte counters, same video stream. inbound, outbound, candidate_pairs, and relay_protocol have no match there. The browser SDK reports none of them.

InboundStream

One receive stream’s counters, as the WebRTC engine reports them. Read from ConnectionStats::inbound.
Definition

OutboundStream

One send stream’s counters. Read from ConnectionStats::outbound.
Definition
The last four fields come from the far end’s report about this client. They stay at zero until it sends one. A zero there means “not measured yet”, not a perfect connection.

CandidatePair

One ICE candidate pair. Read from ConnectionStats::candidate_pairs.
Definition
A connection gathers many pairs, and exactly one is nominated. Only that pair carries traffic. The rest report zeros. Read nominated instead of averaging across the list.

Bytes

A borrowed run of bytes — what std::span<const std::uint8_t> would be, which C++17 does not have.
Definition
Borrowed, always: it is valid for the call it is passed to, or for the handler it is delivered in, and no longer.
Example

Samples

The same, for interleaved 16-bit PCM.
Definition
A length, not just a pointer, so push_frame() can check it against the channel count instead of trusting it — the native layer reads what it is told to read.

Json

Definition
JSON is the native layer’s own currency: capabilities, errors, command arguments and replies all cross the boundary as JSON text. nlohmann/json is the de facto standard for reading it in C++, and it is exposed under this alias so there is one seam to change if that ever stops being true. The archive carries a copy, and a consumer who already pins their own gets theirs.