VLink  2.0.0
A high-performance communication middleware
bag_reader.h 文件参考

Abstract player for VLink bag recordings with seek, loop and rate control. 更多...

#include <cstdint>
#include <future>
#include <memory>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "../base/functional.h"
#include "../base/macros.h"
#include "../base/message_loop.h"
#include "../impl/types.h"
#include "./bag_plugin_interface.h"
bag_reader.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

class  vlink::BagReader
 Format-agnostic VLink bag player driven by an internal MessageLoop. 更多...
 
struct  vlink::BagReader::Info
 Aggregated metadata extracted from the bag header, summary and URL index. 更多...
 
struct  vlink::BagReader::Info::UrlMeta
 Per-URL accounting entry recorded inside Info::url_metas. 更多...
 
struct  vlink::BagReader::Config
 Playback parameters consumed by play(). 更多...
 

命名空间

 

详细描述

Abstract player for VLink bag recordings with seek, loop and rate control.

BagReader is the polymorphic base for VLink offline log playback. It owns a private MessageLoop thread, opens a bag file produced by BagWriter, and replays the stored messages back to user-supplied callbacks honouring their original timing. Concrete subclasses provide format-specific I/O: VDBReader for the SQLite-backed .vdb container and VCAPReader for the MCAP-based .vcap container. create() chooses the right one from the file suffix.

Supported formats and behaviour summary:

Suffix Concrete reader Storage Index source
.vdb / .vdbx VDBReader SQLite SQLite tables (elapsed/URL)
.vcap / .vcapx VCAPReader MCAP MCAP summary + chunk index

Internal playback state machine:

*                     play(cfg)              pause()
*      +------------+ -------> +-----------+ -------> +----------+
*      |  kStopped  |          |  kPlaying |          |  kPaused |
*      +------------+ <------- +-----------+ <------- +----------+
*                    stop() /         resume() / pause_to_next()
*                  end-of-bag
* 

Playback features:

  • Rate multiplier, loop count and time-window filtering through Config.
  • jump() seeks to an arbitrary recording timestamp and may force-resume playback.
  • URL whitelist via Config::filter_urls applies after plugin URL remapping.
  • check() / reindex() / fix() run asynchronously and report their outcome through std::future<bool>.
  • A bound BagPluginInterface may rename URLs, override serialisation types and intercept individual replayed messages.
Example
auto reader = vlink::BagReader::create("/data/drive_log.vdb");
reader->register_ready_callback([] { VLOG_I("bag ready"); });
reader->register_output_callback([](const vlink::Frame& frame) {
// replay each frame in real-time order
VLOG_I("us=", frame.timestamp, " url=", frame.url, " bytes=", frame.data.size());
});
reader->async_run();
cfg.rate = 2.0; // play at 2x speed
cfg.times = vlink::BagReader::kInfinite; // loop forever
reader->play(cfg);
#define VLOG_I(...)
Definition: logger.h:785
注解
Always call async_run() before play(); the loop thread must be alive to dispatch frames. Output callback timestamps are in microseconds, while Config::begin_time and Config::end_time are expressed in milliseconds.