feat(mcap): add paced replay tooling
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -25,6 +26,7 @@ enum class TesterExitCode : int {
|
||||
FormatMismatch = 7,
|
||||
EmptyPayload = 8,
|
||||
ThresholdError = 9,
|
||||
DumpError = 10,
|
||||
};
|
||||
|
||||
[[nodiscard]]
|
||||
@@ -36,6 +38,7 @@ struct Config {
|
||||
std::string input_path{};
|
||||
std::optional<std::string> expected_topic{};
|
||||
std::optional<std::string> expected_format{};
|
||||
std::optional<std::string> dump_annexb_output{};
|
||||
std::uint32_t min_messages{1};
|
||||
};
|
||||
|
||||
@@ -46,6 +49,7 @@ std::expected<Config, int> parse_args(int argc, char **argv) {
|
||||
app.add_option("input", config.input_path, "Input MCAP path")->required();
|
||||
app.add_option("--expect-topic", config.expected_topic, "Expected MCAP topic");
|
||||
app.add_option("--expect-format", config.expected_format, "Expected CompressedVideo format");
|
||||
app.add_option("--dump-annexb-output", config.dump_annexb_output, "Write concatenated CompressedVideo.data payloads to a file");
|
||||
app.add_option("--min-messages", config.min_messages, "Minimum expected message count")->check(CLI::PositiveNumber);
|
||||
|
||||
try {
|
||||
@@ -74,6 +78,15 @@ int main(int argc, char **argv) {
|
||||
std::uint64_t message_count{0};
|
||||
std::uint64_t previous_log_time{0};
|
||||
bool saw_log_time{false};
|
||||
std::optional<std::ofstream> dump_stream{};
|
||||
if (config->dump_annexb_output) {
|
||||
dump_stream.emplace(*config->dump_annexb_output, std::ios::binary | std::ios::trunc);
|
||||
if (!dump_stream->is_open()) {
|
||||
spdlog::error("failed to open dump output '{}'", *config->dump_annexb_output);
|
||||
reader.close();
|
||||
return exit_code(TesterExitCode::DumpError);
|
||||
}
|
||||
}
|
||||
|
||||
auto message_view = reader.readMessages();
|
||||
for (auto it = message_view.begin(); it != message_view.end(); ++it) {
|
||||
@@ -117,6 +130,14 @@ int main(int argc, char **argv) {
|
||||
reader.close();
|
||||
return exit_code(TesterExitCode::EmptyPayload);
|
||||
}
|
||||
if (dump_stream) {
|
||||
dump_stream->write(message.data().data(), static_cast<std::streamsize>(message.data().size()));
|
||||
if (!dump_stream->good()) {
|
||||
spdlog::error("failed to write Annex B dump to '{}'", *config->dump_annexb_output);
|
||||
reader.close();
|
||||
return exit_code(TesterExitCode::DumpError);
|
||||
}
|
||||
}
|
||||
|
||||
previous_log_time = it->message.logTime;
|
||||
saw_log_time = true;
|
||||
|
||||
Reference in New Issue
Block a user