Publisher — any topic that matches the recorder’s filter is written automatically on every Publish() call. The replayer reads an MCAP file and re-publishes each message through a TransportManager at the correct wall time.
Recorder types live in
basis::recorder (aliased into basis::).
The replayer lives in basis::.
Headers: cpp/recorder/include/basis/recorder.h and cpp/replayer/include/basis/replayer.h.class OwningSpan
basis/recorder.h
A helper that bundles a std::span<const std::byte> with the shared_ptr that owns the underlying allocation, ensuring the data outlives the span.
Owning pointer to the object whose memory
span views. Kept alive for the lifetime of the OwningSpan.View into the payload bytes. Must point into memory owned by
ptr.Span
class RecorderInterface
basis/recorder.h — namespace basis::recorder
Abstract interface implemented by both Recorder and AsyncRecorder. Override this in tests to verify message recording without writing to disk.
Start
output_name is used as a filename stem (.mcap is appended).
Name for the recording, without extension.
true on success.
Stop
RegisterTopic
Topic name, e.g.
"/camera/rgb".Serializer and type metadata for the topic.
Full schema definition (e.g. protobuf descriptor) used for offline decoding.
true if this topic will be recorded; false if it is filtered out. Publisher uses the return value to decide whether to attach the recorder.
WriteMessage
PublisherBase::PublishRaw() for every published message on a registered topic.
The topic the message was published on.
Serialized message bytes, bundled with the owning allocation.
Monotonic timestamp at the time of publishing.
true on success.
class Recorder
basis/recorder.h — namespace basis::recorder
Synchronous (blocking) MCAP recorder. Writes messages inline on the calling thread. Appropriate for low-frequency topics or when latency is acceptable.
RECORD_ALL_TOPICS
topic_patterns value that matches every topic.
Constructor
Directory where MCAP files are written. Defaults to the current working directory.
Allowlist of
(label, regex) pairs. A topic is recorded if its name matches any regex in the list. Use RECORD_ALL_TOPICS to record everything.Start
<recording_dir>/<output_name>.mcap for writing using the "basis" MCAP profile.
Stop
Split
new_name. Useful for creating time-bounded recordings without stopping and restarting the recorder.
New output filename stem (
.mcap is appended automatically).class AsyncRecorder
basis/recorder.h — namespace basis::recorder
Asynchronous recorder that writes messages on a dedicated background thread. WriteMessage() returns immediately after enqueuing the event, minimizing latency on publisher threads.
Constructor
Directory for output files.
topic_patterns
const std::vector<std::pair<std::string, std::regex>>&
default:"Recorder::RECORD_ALL_TOPICS"
Topic allowlist, same semantics as
Recorder.When
true, Stop() blocks until the write queue is fully flushed before closing the file. Set to false to discard pending messages on shutdown.Start
Recorder and starts the background write thread.
Stop
drain_queue_on_stop is true, waits for all queued writes to complete before closing the file.
RegisterTopic
Recorder::RegisterTopic().
WriteMessage
RecordEvent onto the internal MPSC queue and returns immediately. The background thread drains the queue and writes to disk.
struct Config
basis/replayer/config.h — namespace basis::replayer
Configuration for Replayer.
When
true, the replayer restarts from the beginning of the recording after reaching the end.Path to the MCAP file to replay.
class Replayer
basis/replayer.h — namespace basis
Reads an MCAP recording and re-publishes each message through a TransportManager at the correct wall time.
Constructor
Replay configuration (input file path, loop flag).
Transport manager used to advertise topics and publish replayed messages.
Coordinator connection used to announce publishers to the rest of the system.
Run
config.loop == true).
Returns true on normal completion, false on error.