73#include <unordered_map>
74#include <unordered_set>
205 using OutputCallback = std::function<void(int64_t microseconds_timestamp,
const std::string& url,
239 [[nodiscard]]
static std::shared_ptr<BagReader>
create(
const std::string& path,
bool read_only =
true,
240 bool try_to_fix =
false);
249 explicit BagReader(
const std::string& path,
bool read_only =
true,
bool try_to_fix =
false);
343 virtual void jump(int64_t begin_time,
double rate,
int times,
bool force_to_play =
false) = 0;
350 virtual std::future<bool>
check() = 0;
365 virtual std::future<bool>
fix(
bool rebuild =
false) = 0;
372 virtual void tag(
const std::string& tag_name) = 0;
415 [[nodiscard]]
virtual std::string
get_ser_type(
const std::string& url)
const = 0;
460 std::unordered_map<std::string, std::string>& ser_map,
461 std::unordered_map<std::string, SchemaType>& schema_type_map);
470 std::unique_ptr<struct BagReaderImpl> impl_;
Plugin interface for custom bag reader URL/type transformation and message processing.
Versatile byte buffer with small-buffer optimisation, ownership semantics and compression.
virtual std::future< bool > reindex()=0
Rebuilds the index tables asynchronously.
virtual void register_ready_callback(ReadyCallback &&ready_callback)
Registers a callback fired when the reader is ready to start playing.
virtual void bind_plugin_interface(const std::shared_ptr< BagReaderPluginInterface > &plugin_interface)
Attaches a BagReaderPluginInterface for custom URL/type conversion.
virtual bool is_jumping() const =0
Returns true if a jump-to-timestamp seek is currently in progress.
virtual int64_t get_real_timestamp() const =0
Returns the current playback position in real elapsed time.
virtual void pause_to_next()=0
Advances one message while paused, then pauses again.
virtual std::future< bool > fix(bool rebuild=false)=0
Repairs a corrupt bag file asynchronously.
void process_output(int64_t timestamp, const std::string &url, ActionType action_type, const Bytes &data)
virtual void play(const Config &config)=0
Starts playback with the given config.
virtual const Info & get_info() const =0
Returns the bag file metadata and per-URL statistics.
static std::shared_ptr< BagReader > create(const std::string &path, bool read_only=true, bool try_to_fix=false)
Creates a concrete BagReader for path, selecting the implementation by extension.
virtual std::vector< SchemaData > detect_schema()=0
Scans the bag and returns all embedded schemas.
virtual bool is_split_mode() const =0
Returns true if the bag spans multiple split files.
BagReader(const std::string &path, bool read_only=true, bool try_to_fix=false)
Constructs the reader for path.
Status
Playback state of the reader.
定义 bag_reader.h:109
@ kStoped
Stopped (not playing).
定义 bag_reader.h:110
@ kPaused
Paused mid-playback.
定义 bag_reader.h:111
@ kPlaying
Actively playing.
定义 bag_reader.h:112
virtual SchemaType get_schema_type(const std::string &url) const =0
Returns the coarse schema family for a given url.
virtual void jump(int64_t begin_time, double rate, int times, bool force_to_play=false)=0
Seeks to begin_time and resumes playback at rate with times loops.
virtual Status get_status() const =0
Returns the current playback status.
virtual void register_finish_callback(FinishCallback &&finish_callback)
Registers a callback fired when playback ends or is interrupted.
virtual void resume()=0
Resumes a paused playback from the current position.
std::function< void(bool is_interrupted)> FinishCallback
Callback fired when playback has finished (or was interrupted).
定义 bag_reader.h:225
virtual int64_t get_timestamp() const =0
Returns the current playback position as a recording timestamp.
virtual void tag(const std::string &tag_name)=0
Updates the tag name stored in the bag's metadata.
static ActionType convert_action(std::string_view str)
static void rebuild_url_meta_maps(const std::vector< Info::UrlMeta > &url_metas, std::unordered_map< std::string, std::string > &ser_map, std::unordered_map< std::string, SchemaType > &schema_type_map)
Rebuilds URL metadata lookup maps after plugin remapping.
virtual int get_split_index() const =0
Returns the zero-based index of the current split file being read.
std::function< void()> ReadyCallback
Callback fired when the reader has opened the file and is ready to start playing.
定义 bag_reader.h:218
std::function< void(Status status)> StatusCallback
Callback fired whenever the playback Status changes.
定义 bag_reader.h:213
virtual void stop()=0
Stops playback and resets the reader to the beginning.
void process_url_metas(std::vector< Info::UrlMeta > &url_metas)
virtual ~BagReader()
Destructor – stops playback and releases file resources.
virtual std::future< bool > check()=0
Verifies the integrity of the bag file asynchronously.
virtual void register_status_callback(StatusCallback &&status_callback)
Registers a callback fired whenever the playback status changes.
virtual void register_output_callback(OutputCallback &&output_callback)
Registers the callback that receives replayed messages.
static constexpr int kInfinite
Sentinel value for the Config::times field to indicate endless loop playback.
定义 bag_reader.h:98
std::function< void(int64_t microseconds_timestamp, const std::string &url, ActionType action_type, const Bytes &data)> OutputCallback
Callback type fired for each replayed message.
定义 bag_reader.h:205
virtual std::string get_ser_type(const std::string &url) const =0
Returns the serialisation type string for a given url.
virtual void pause()=0
Pauses playback at the current position.
Versatile 128-byte byte buffer with SBO, five ownership modes and compression helpers.
定义 bytes.h:113
MessageLoop()
Constructs a MessageLoop with kNormalType queue.
Platform-independent macro definitions for the VLink library.
#define VLINK_EXPORT
定义 macros.h:85
#define VLINK_DISALLOW_COPY_AND_ASSIGN(classname)
Deletes the copy constructor and copy-assignment operator of classname.
定义 macros.h:184
Single-threaded event loop with three queue types, timer management and task scheduling.
SchemaType
Coarse runtime schema family used by discovery, bag metadata, and proxy routing.
定义 types.h:184
@ kUnknown
Decode category is not known.
定义 types.h:185
ActionType
Identifies the type of message action for recording purposes.
定义 types.h:162
Playback configuration passed to play().
定义 bag_reader.h:181
int64_t force_delay
Override inter-message delay (ms). -1 = use timestamps.
定义 bag_reader.h:187
bool auto_quit
If true, quit the loop thread when playback ends.
定义 bag_reader.h:189
bool skip_blank
If true, skip silent gaps between messages.
定义 bag_reader.h:186
int64_t begin_time
Playback start timestamp (ms). 0 = from beginning.
定义 bag_reader.h:182
std::unordered_set< std::string > filter_urls
Whitelist of URLs to play. Empty = all URLs.
定义 bag_reader.h:190
int times
Number of loops. kInfinite (-1) = loop forever.
定义 bag_reader.h:184
double rate
Playback rate multiplier. 1.0 = real time.
定义 bag_reader.h:185
bool auto_pause
If true, pause automatically at each message.
定义 bag_reader.h:188
int64_t end_time
Playback end timestamp (ms). 0 = until end.
定义 bag_reader.h:183
Metadata extracted from the bag file header and index.
定义 bag_reader.h:122
std::string tag_name
Tag name stored in the bag header.
定义 bag_reader.h:153
int32_t timezone
Timezone offset in minutes from UTC.
定义 bag_reader.h:164
bool has_schema
true if any schemas are embedded.
定义 bag_reader.h:163
bool has_completed
true if the recording was cleanly finalized.
定义 bag_reader.h:160
int64_t total_raw_size
Total uncompressed payload size (bytes).
定义 bag_reader.h:169
std::vector< UrlMeta > url_metas
Per-URL statistics, one entry per recorded topic.
定义 bag_reader.h:174
bool has_idx_elapsed
true if an elapsed-time index is present.
定义 bag_reader.h:161
std::string file_name
Absolute path to the bag file.
定义 bag_reader.h:152
std::string process_name
Name of the recording process.
定义 bag_reader.h:158
std::string compression_type
Compression algorithm used (e.g., "lzav", "zstd").
定义 bag_reader.h:156
int64_t split_by_size
Split threshold by size (bytes).
定义 bag_reader.h:172
int64_t split_count
Number of file splits (0 if single file).
定义 bag_reader.h:171
int64_t file_size
File size in bytes.
定义 bag_reader.h:168
std::string storage_type
Storage backend (e.g., "sqlite", "mcap").
定义 bag_reader.h:155
int64_t start_timestamp
Recording start timestamp (milliseconds since epoch).
定义 bag_reader.h:165
int64_t blank_duration
Total blank (gap) duration (milliseconds).
定义 bag_reader.h:166
std::string time_accuracy
Timestamp resolution (e.g., "us", "ns").
定义 bag_reader.h:157
bool has_idx_url
true if a URL index is present.
定义 bag_reader.h:162
std::string version
Bag format version string.
定义 bag_reader.h:154
int64_t total_duration
Total recording duration (milliseconds).
定义 bag_reader.h:167
int64_t message_count
Total number of messages across all URLs.
定义 bag_reader.h:170
int64_t split_by_time
Split threshold by time (milliseconds).
定义 bag_reader.h:173
std::string date_time
Recording start date/time string.
定义 bag_reader.h:159
Core type definitions shared across all VLink node implementations.