12#ifndef MCAP_COMPRESSION_NO_ZSTD
25 bool noChunkCRC =
false;
29 bool noAttachmentCRC =
false;
33 bool enableDataCRC =
false;
37 bool noSummaryCRC =
false;
42 bool noChunking =
false;
48 bool noMessageIndex =
false;
56 bool noSummary =
false;
83 bool forceCompression =
false;
99 bool noRepeatedSchemas =
false;
100 bool noRepeatedChannels =
false;
101 bool noAttachmentIndex =
false;
102 bool noMetadataIndex =
false;
103 bool noChunkIndex =
false;
104 bool noStatistics =
false;
105 bool noSummaryOffsets =
false;
108 : profile(profile) {}
116 bool crcEnabled =
false;
128 void write(const
std::
byte* data, uint64_t size);
133 virtual
void end() = 0;
138 virtual uint64_t size() const = 0;
153 virtual
void flush() {}
172 void handleWrite(
const std::byte* data, uint64_t size)
override;
174 void flush()
override;
175 uint64_t size()
const override;
190 void handleWrite(
const std::byte* data, uint64_t size)
override;
192 void flush()
override;
193 uint64_t size()
const override;
214 virtual void end()
override = 0;
218 virtual uint64_t
size()
const override = 0;
255 void handleWrite(
const std::byte* data, uint64_t size)
override;
257 uint64_t size()
const override;
258 uint64_t compressedSize()
const override;
259 bool empty()
const override;
260 void handleClear()
override;
262 const std::byte* compressedData()
const override;
268#ifndef MCAP_COMPRESSION_NO_LZ4
277 void handleWrite(
const std::byte* data, uint64_t size)
override;
279 uint64_t size()
const override;
280 uint64_t compressedSize()
const override;
281 bool empty()
const override;
282 void handleClear()
override;
284 const std::byte* compressedData()
const override;
293#ifndef MCAP_COMPRESSION_NO_ZSTD
303 void handleWrite(
const std::byte* data, uint64_t size)
override;
305 uint64_t size()
const override;
306 uint64_t compressedSize()
const override;
307 bool empty()
const override;
308 void handleClear()
override;
310 const std::byte* compressedData()
const override;
315 ZSTD_CCtx_s* zstdContext_ =
nullptr;
384 void addSchema(
Schema& schema);
400 void addChannel(
Channel& channel);
443 void closeLastChunk();
449 static void writeMagic(
IWritable& output);
452 static uint64_t write(
IWritable& output,
const Footer& footer,
bool crcEnabled);
455 static uint64_t getRecordSize(
const Message& message);
472 static void write(
IWritable& output, uint16_t value);
473 static void write(
IWritable& output, uint32_t value);
474 static void write(
IWritable& output, uint64_t value);
485#ifndef MCAP_COMPRESSION_NO_LZ4
488#ifndef MCAP_COMPRESSION_NO_ZSTD
502 uint64_t uncompressedSize_ = 0;
503 bool opened_ =
false;
512#ifdef MCAP_IMPLEMENTATION
An in-memory IChunkWriter implementation backed by a growable buffer.
std::vector< std::byte > buffer_
Implements the IWritable interface used by McapWriter by wrapping a FILE* pointer created by fopen().
An abstract interface for writing Chunk data. Chunk data is buffered in memory and written to disk as...
virtual void handleClear()=0
virtual bool empty() const =0
Returns true if write() has never been called since initialization or the last call to clear().
virtual ~IChunkWriter() override=default
virtual uint64_t size() const override=0
Returns the size in bytes of the uncompressed data.
virtual uint64_t compressedSize() const =0
Returns the size in bytes of the compressed data. This will only be called after end().
virtual void end() override=0
Called when the writer wants to close the current output Chunk. After this call, data() and size() sh...
virtual const std::byte * compressedData() const =0
Returns a pointer to the compressed data. This will only be called after end().
virtual const std::byte * data() const =0
Returns a pointer to the uncompressed data.
An abstract interface for writing MCAP data.
virtual void handleWrite(const std::byte *data, uint64_t size)=0
An in-memory IChunkWriter implementation that holds data in a temporary buffer before flushing to an ...
CompressionLevel compressionLevel_
std::vector< std::byte > compressedBuffer_
std::vector< std::byte > uncompressedBuffer_
Provides a write interface to an MCAP file.
std::vector< MetadataIndex > metadataIndex_
std::unique_ptr< StreamWriter > streamOutput_
std::unique_ptr< ZStdWriter > zstdChunk_
std::vector< Schema > schemas_
std::vector< Channel > channels_
std::vector< AttachmentIndex > attachmentIndex_
std::unordered_map< ChannelId, MessageIndex > currentMessageIndex_
std::unique_ptr< FileWriter > fileOutput_
std::unordered_set< SchemaId > writtenSchemas_
std::unique_ptr< BufferWriter > uncompressedChunk_
std::unique_ptr< LZ4Writer > lz4Chunk_
std::vector< ChunkIndex > chunkIndex_
Implements the IWritable interface used by McapWriter by wrapping a std::ostream stream.
An in-memory IChunkWriter implementation that holds data in a temporary buffer before flushing to an ...
std::vector< std::byte > uncompressedBuffer_
std::vector< std::byte > compressedBuffer_
constexpr Timestamp MaxTime
constexpr uint64_t DefaultChunkSize
Compression
Supported MCAP compression algorithms.
CompressionLevel
Compression level to use when compression is enabled. Slower generally produces smaller files,...
Attachment Index records are found in the Summary section, providing summary information for a single...
An Attachment is an arbitrary file embedded in an MCAP file, including a name, media type,...
Describes a Channel that messages are written to. A Channel represents a single connection from a pub...
Chunk Index records are found in the Summary section, providing summary information for a single Chun...
An collection of Schemas, Channels, and Messages that supports compression and indexing.
The final record in the Data section, signaling the end of Data and beginning of Summary....
Configuration options for McapWriter.
McapWriterOptions(const std::string_view profile)
std::string profile
The recording profile. See https://mcap.dev/spec/registry#well-known-profiles for more information on...
A list of timestamps to byte offsets for a single Channel. This record appears after each Chunk,...
A single Message published to a Channel.
A generic Type-Length-Value record using a uint8 type and uint64 length. This is the generic form of ...
Describes a schema used for message encoding and decoding and/or describing the shape of messages....
The Statistics record is found in the Summary section, providing counts and timestamp ranges for the ...
Wraps a status code and string message carrying additional context.
Summary Offset records are found in the Summary Offset section. Records in the Summary section are gr...
#define MCAP_LIBRARY_VERSION