Skip to content

Commit

Permalink
Do not overwrite channel metadata if already present (#14)
Browse files Browse the repository at this point in the history
Signed-off-by: Timm Ruppert <[email protected]>
  • Loading branch information
TimmRuppert authored Dec 20, 2024
1 parent 33685c8 commit fb363a4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/tracefile/writer/MCAPTraceFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,17 @@ uint16_t MCAPTraceFileWriter::AddChannel(const std::string& topic, const google:
path_schema = *it_schema;
}

// add osi version to channel metadata as required by spec.
const auto osi_version = osi3::InterfaceVersion::descriptor()->file()->options().GetExtension(osi3::current_interface_version);
channel_metadata["net.asam.osi.trace.channel.osi_version"] =
std::to_string(osi_version.version_major()) + "." + std::to_string(osi_version.version_minor()) + "." + std::to_string(osi_version.version_patch());
channel_metadata["net.asam.osi.trace.channel.protobuf_version"] = google::protobuf::internal::VersionString(GOOGLE_PROTOBUF_VERSION);
// add osi version (if not present) to channel metadata as required by spec.
if (channel_metadata.find("net.asam.osi.trace.channel.osi_version") == channel_metadata.end()) {
const auto osi_version = osi3::InterfaceVersion::descriptor()->file()->options().GetExtension(osi3::current_interface_version);
channel_metadata["net.asam.osi.trace.channel.osi_version"] =
std::to_string(osi_version.version_major()) + "." + std::to_string(osi_version.version_minor()) + "." + std::to_string(osi_version.version_patch());
}

// add protobuf version (if not present) to channel metadata as required by spec.
if (channel_metadata.find("net.asam.osi.trace.channel.protobuf_version") == channel_metadata.end()) {
channel_metadata["net.asam.osi.trace.channel.protobuf_version"] = google::protobuf::internal::VersionString(GOOGLE_PROTOBUF_VERSION);
}

// add the channel to the writer/mcap file
mcap::Channel channel(topic, "protobuf", path_schema.id, channel_metadata);
Expand Down

0 comments on commit fb363a4

Please sign in to comment.