VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
bag_reader.h File Reference

Abstract base class for VLink bag file playback with time-based seeking and rate control. More...

#include <cstdint>
#include <functional>
#include <future>
#include <memory>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "../base/bytes.h"
#include "../base/macros.h"
#include "../base/message_loop.h"
#include "../impl/types.h"
#include "./bag_reader_plugin_interface.h"
Include dependency graph for bag_reader.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

 Abstract VLink bag file player with time control, seeking, and integrity tools. More...
 Metadata extracted from the bag file header and index. More...
 Per-URL statistics extracted from the bag index. More...
 Playback configuration passed to play(). More...

Namespaces

Detailed Description

Abstract base class for VLink bag file playback with time-based seeking and rate control.

BagReader is an abstract MessageLoop-based player that reads VLink bag files and replays recorded messages through an OutputCallback. Concrete implementations are DatabaseReader (SQLite-backed) and McapReader (MCAP-format).

Playback features:

  • Configurable playback rate (e.g., rate=2.0 for 2x speed).
  • Loop playback via the times field (kInfinite = -1 for endless loop).
  • Time-range filtering via begin_time and end_time.
  • Jump-to-timestamp seeking with optional forced play.
  • Per-URL output filtering via Config::filter_urls whitelist.
  • Background integrity check, reindex, and fix operations via std::future.
  • Plugin interface for custom URL/type mapping.
Playback example
auto reader = vlink::BagReader::create("/data/log.vdb");
reader->register_output_callback([](int64_t ts, const std::string& url,
vlink::ActionType action, const vlink::Bytes& data) {
VLOG_I("ts=", ts, " url=", url, " size=", data.size());
});
reader->async_run();
cfg.rate = 1.0;
reader->play(cfg);
#define VLOG_I(...)
Definition logger.h:850
Note
  • Call async_run() before play().
  • check(), reindex(), and fix() run on a background thread and return a std::future<bool> for result polling.
  • The file format is auto-detected from the extension by create() (.vcap / .vcapx -> McapReader, otherwise -> DatabaseReader).