Class MCAPSink

Inheritance Relationships

Base Type

Class Documentation

class MCAPSink : public DataTamer::DataSinkBase

The MCAPSink is an implementation of DataSinkBase that will save the data as MCAP file (https://mcap.dev/)

Public Functions

explicit MCAPSink(std::string const &filepath, bool do_compression = false)

MCAPSink. IMPORTANT: if you want the recorder to be more robust to crash/segfault, set do_compression to false. Compression is dafe if your application is closing cleanly.

Parameters:
  • filepath – path of the file to be saved. Should have extension “.mcap”

  • do_compression – if true, compress the data on the fly.

~MCAPSink() override
virtual void addChannel(std::string const &channel_name, Schema const &schema) override

addChannel will register a schema into the sink. That schema will be recognized by its hash.

Parameters:
virtual bool storeSnapshot(const Snapshot &snapshot) override

storeSnapshot contains the code to execute when popping a snapshot from the queue.

Parameters:

snapshot – data to be pushed into the sink.

Returns:

true if processed successfully

void setMaxTimeBeforeReset(std::chrono::seconds reset_time)

After a certain amount of time, the MCAP file will be reset and overwritten. Default value is 600 seconds (10 minutes)

void stopRecording()

Stop recording and save the file.

void restartRecording(std::string const &filepath, bool do_compression = false)

restartRecording saves the current file (unless we did it already, calling stopRecording) and start recording into a new one. Note that all the registered channels and their schemas will be copied into the new file.

Parameters:
  • filepath – file path of the new file (should be “.mcap” extension)

  • do_compression – if true, compress the data on the fly.