7 #include <unordered_set> 100 bool crcEnabled =
false;
117 virtual
void end() = 0;
122 virtual uint64_t size() const = 0;
133 virtual
void handleWrite(const
std::byte* data, uint64_t size) = 0;
149 void handleWrite(
const std::byte* data, uint64_t size)
override;
151 uint64_t
size()
const override;
156 std::FILE* file_ =
nullptr;
168 void handleWrite(
const std::byte*
data, uint64_t
size)
override;
170 uint64_t
size()
const override;
191 virtual void end() = 0;
195 virtual uint64_t
size()
const = 0;
205 virtual bool empty()
const = 0;
214 virtual const std::byte*
data()
const = 0;
219 virtual const std::byte* compressedData()
const = 0;
222 virtual void handleClear() = 0;
231 void handleWrite(
const std::byte*
data, uint64_t
size)
override;
233 uint64_t
size()
const override;
235 bool empty()
const override;
236 void handleClear()
override;
237 const std::byte*
data()
const override;
238 const std::byte* compressedData()
const override;
252 void handleWrite(
const std::byte*
data, uint64_t
size)
override;
254 uint64_t
size()
const override;
256 bool empty()
const override;
257 void handleClear()
override;
258 const std::byte*
data()
const override;
259 const std::byte* compressedData()
const override;
276 void handleWrite(
const std::byte*
data, uint64_t
size)
override;
278 uint64_t
size()
const override;
280 bool empty()
const override;
281 void handleClear()
override;
282 const std::byte*
data()
const override;
283 const std::byte* compressedData()
const override;
288 ZSTD_CCtx_s* zstdContext_ =
nullptr;
344 void addSchema(
Schema& schema);
354 void addChannel(
Channel& channel);
445 uint64_t uncompressedSize_ = 0;
446 bool opened_ =
false;
455 #ifdef MCAP_IMPLEMENTATION 456 #include "writer.inl" Implements the IWritable interface used by McapWriter by wrapping a FILE* pointer created by fopen() ...
Compression
Supported MCAP compression algorithms.
An abstract interface for writing MCAP data.
McapWriterOptions(const std::string_view profile)
An Attachment is an arbitrary file embedded in an MCAP file, including a name, content-type, timestamps, and optional CRC. Attachment records are written in the Data section, outside of Chunks.
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.
std::unordered_map< ChannelId, MessageIndex > currentMessageIndex_
Describes a Channel that messages are written to. A Channel represents a single connection from a pub...
std::unique_ptr< StreamWriter > streamOutput_
std::vector< std::byte > buffer_
CompressionLevel compressionLevel_
static int writer(lua_State *L, const void *b, size_t size, void *ud)
constexpr Timestamp MaxTime
An in-memory IChunkWriter implementation that holds data in a temporary buffer before flushing to an ...
CompressionLevel compressionLevel
Compression level to use when writing Chunks. Slower generally produces smaller files, at the expense of more CPU time. These levels map to different internal settings for each compression algorithm.
std::unique_ptr< LZ4Writer > lz4Chunk_
An collection of Schemas, Channels, and Messages that supports compression and indexing.
basic_string_view< char > string_view
Chunk Index records are found in the Summary section, providing summary information for a single Chun...
std::vector< std::byte > buffer_
Attachment Index records are found in the Summary section, providing summary information for a single...
uint64_t chunkSize
Target uncompressed Chunk payload size in bytes. Once a Chunk's uncompressed data meets or exceeds th...
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
#define MCAP_LIBRARY_VERSION
std::vector< std::byte > uncompressedBuffer_
bool noChunking
Do not write Chunks to the file, instead writing Schema, Channel, and Message records directly into t...
An in-memory IChunkWriter implementation backed by a growable buffer.
bool forceCompression
By default, Chunks that do not benefit from compression will be written uncompressed. This option can be used to force compression on all Chunks. This option is ignored if noChunking=true.
Summary Offset records are found in the Summary Offset section. Records in the Summary section are gr...
std::unique_ptr< FileWriter > fileOutput_
std::vector< std::byte > compressedBuffer_
The final record in the Data section, signaling the end of Data and beginning of Summary. Optionally contains a CRC of the entire Data section.
Provides a write interface to an MCAP file.
constexpr uint64_t DefaultChunkSize
Implements the IWritable interface used by McapWriter by wrapping a std::ostream stream.
std::unique_ptr< ZStdWriter > zstdChunk_
An abstract interface for writing Chunk data. Chunk data is buffered in memory and written to disk as...
std::unordered_set< SchemaId > writtenSchemas_
A single Message published to a Channel.
std::vector< Schema > schemas_
std::vector< std::byte > uncompressedBuffer_
An in-memory IChunkWriter implementation that holds data in a temporary buffer before flushing to an ...
std::vector< std::byte > compressedBuffer_
bool noSummary
Do not write Summary or Summary Offset sections to the file, placing the Footer record immediately af...
std::vector< MetadataIndex > metadataIndex_
std::vector< Channel > channels_
std::vector< ChunkIndex > chunkIndex_
Compression compression
Compression algorithm to use when writing Chunks. This option is ignored if noChunking=true.
bool noCRC
Disable CRC calculations for Chunks, Attachments, and the Data and Summary sections.
std::vector< AttachmentIndex > attachmentIndex_
span_constexpr std::size_t size(span< T, Extent > const &spn)
void clear(lua_State *L, int table_index)
CompressionLevel
Compression level to use when compression is enabled. Slower generally produces smaller files...
static const char * output
bool noMessageIndex
Do not write Message Index records to the file. If noSummary=true and noChunkIndex=false, Chunk Index records will still be written to the Summary section, providing a coarse message index.
std::unordered_map< std::string, std::string > KeyValueMap
Describes a schema used for message encoding and decoding and/or describing the shape of messages...
A list of timestamps to byte offsets for a single Channel. This record appears after each Chunk...
std::unique_ptr< BufferWriter > uncompressedChunk_
std::vector< std::byte > ByteArray
std::string library
A freeform string written by recording libraries. For this library, the default is "libmcap {Major}...
std::string profile
The recording profile. See https://github.com/foxglove/mcap/tree/main/docs/specification/profiles for...
A generic Type-Length-Value record using a uint8 type and uint64 length. This is the generic form of ...
Configuration options for McapWriter.