Configuration Constants

namespace config

Configuration constants for OSI trace file reading and writing.

This namespace centralizes all configurable parameters and default values used throughout the tracefile reader and writer implementations. Users can reference these constants to understand the default behavior and make informed decisions when overriding settings.

Variables

constexpr uint64_t kDefaultChunkSize = 16 * 1024 * 1024

Default MCAP chunk size in bytes (16 MiB).

Real-world testing with Lichtblick and similar MCAP viewers shows that 4-32 MiB chunks provide the best playback performance for OSI trace files. 16 MiB is a good middle ground: large enough for efficient compression and smooth buffering, small enough to avoid excessive memory usage.

constexpr uint64_t kMinChunkSize = 1024 * 1024

Minimum allowed chunk size (1 MiB).

Chunks smaller than this create excessive indexing overhead and slow down sequential reading.

constexpr uint64_t kMaxChunkSize = 32 * 1024 * 1024

Maximum allowed chunk size (32 MiB).

Very large chunks increase memory requirements for readers and may cause issues with memory-constrained systems and coarse buffering. This upper bound ensures reasonable memory usage and smoother playback.

constexpr uint64_t kNanosecondsPerSecond = 1'000'000'000

Number of nanoseconds in one second.

constexpr size_t kBinaryOsiMessageLengthPrefixSize = sizeof(uint32_t)

Size of the message length prefix in binary OSI files.

Binary .osi files use a simple format: each message is preceded by a 4-byte little-endian unsigned integer indicating the message size.

constexpr size_t kMaxExpectedMessageSize = 512 * 1024 * 1024

Maximum expected single message size (sanity check).

OSI messages can be large (especially SensorView with many objects), but anything larger than this is likely a corrupted file or format error.

constexpr size_t kTxthReadBufferReserveSize = 4096

Initial string reserve size when reading a TXTH text message.

constexpr auto kOsiTraceMetadataName = "net.asam.osi.trace"

Name of the OSI trace file-level metadata record.

constexpr std::array<const char*, 5> kOsiTraceRequiredMetadataKeys = {"version", "min_osi_version", "max_osi_version", "min_protobuf_version", "max_protobuf_version",}

Required file-level metadata keys for net.asam.osi.trace.

constexpr std::array<const char*, 5> kOsiTraceRecommendedMetadataKeys = {"zero_time", "creation_time", "description", "authors", "data_sources",}

Recommended file-level metadata keys for net.asam.osi.trace.

constexpr std::array<const char*, 2> kOsiChannelRequiredMetadataKeys = {"net.asam.osi.trace.channel.osi_version", "net.asam.osi.trace.channel.protobuf_version",}

Required channel metadata keys.

constexpr std::array<const char*, 1> kOsiChannelRecommendedMetadataKeys = {"net.asam.osi.trace.channel.description",}

Recommended channel metadata keys.