90 #include <string_view>
91 #include <unordered_map>
92 #include <unordered_set>
95 #include "../base/functional.h"
96 #include "../base/macros.h"
97 #include "../base/message_loop.h"
98 #include "../impl/types.h"
119 static constexpr
int kInfinite{-1};
183 bool has_completed{
false};
184 bool has_idx_elapsed{
false};
185 bool has_idx_url{
false};
186 bool has_schema{
false};
188 int64_t start_timestamp{0};
189 int64_t blank_duration{0};
190 int64_t total_duration{0};
191 int64_t file_size{0};
192 int64_t total_raw_size{0};
193 int64_t message_count{0};
194 int64_t split_count{0};
195 int64_t split_by_size{0};
196 int64_t split_by_time{0};
205 int64_t begin_time{0};
209 bool skip_blank{
false};
210 int64_t force_delay{-1};
211 bool auto_pause{
false};
212 bool auto_quit{
false};
262 [[nodiscard]]
static std::shared_ptr<BagReader>
create(
const std::string& path,
bool read_only =
true,
263 bool try_to_fix =
false);
272 explicit BagReader(
const std::string& path,
bool read_only =
true,
bool try_to_fix =
false);
393 [[nodiscard]]
bool eof() const noexcept;
398 [[nodiscard]]
bool fail() const noexcept;
407 explicit operator
bool() const noexcept;
418 virtual
void play(const
Config& config) = 0;
427 virtual
void stop() = 0;
432 virtual
void pause() = 0;
437 virtual
void resume() = 0;
442 virtual
void pause_to_next() = 0;
452 virtual
void jump(int64_t begin_time,
double rate,
int times,
bool force_to_play = false) = 0;
459 virtual std::future<
bool> check() = 0;
466 virtual std::future<
bool> reindex() = 0;
474 virtual std::future<
bool> fix(
bool rebuild = false) = 0;
481 virtual
void tag(const std::
string& tag_name) = 0;
488 [[nodiscard]] virtual int64_t get_timestamp() const = 0;
495 [[nodiscard]] virtual int64_t get_real_timestamp() const = 0;
502 [[nodiscard]] virtual
Status get_status() const = 0;
509 [[nodiscard]] virtual const
Info& get_info() const = 0;
516 [[nodiscard]] virtual std::vector<
SchemaData> detect_schema() = 0;
524 [[nodiscard]] virtual std::
string get_ser_type(const std::
string& url) const;
532 [[nodiscard]] virtual
SchemaType get_schema_type(const std::
string& url) const;
537 [[nodiscard]] virtual
bool is_split_mode() const = 0;
544 [[nodiscard]] virtual
int get_split_index() const = 0;
549 [[nodiscard]] virtual
bool is_jumping() const = 0;
552 virtual
bool do_open_cursor(const
Config& config);
554 virtual
bool do_read_next(
Frame& out,
bool& is_error);
556 static
void rebuild_url_meta_maps(const std::vector<
Info::UrlMeta>& url_metas,
557 std::unordered_map<std::
string, std::
string>& ser_map,
558 std::unordered_map<std::
string,
SchemaType>& schema_type_map);
562 void fill_frame_meta(
Frame& frame) const;
566 void process_url_metas(std::vector<
Info::UrlMeta>& url_metas);
568 void rebuild_url_meta_lookup(const std::vector<
Info::UrlMeta>& url_metas);
570 std::unordered_map<std::
string, std::
string>& url_ser_map();
572 std::unordered_map<std::
string,
SchemaType>& url_schema_type_map();
574 bool convert_playback_url(const std::
string& input_url, std::
string& output_url) const;
576 bool match_playback_url_filter(std::string_view input_url, const std::unordered_set<std::
string>& filter_urls) const;
580 void detach_plugin();
584 std::unique_ptr<Impl> impl_;
Unified plugin contract for rewriting bag traffic on both playback (read) and recording (write).
Format-agnostic VLink bag player driven by an internal MessageLoop.
Definition: bag_reader.h:114
virtual void register_ready_callback(ReadyCallback &&ready_callback)
Installs the "open complete" observer.
bool read_next(Frame &out)
Reads the next frame in recorded order into out.
BagReader & operator>>(Frame &out)
Stream-style alias for read_next(), enabling while (reader >> frame).
BagReader(const std::string &path, bool read_only=true, bool try_to_fix=false)
Constructs the base reader and stores construction-time options.
bool eof() const noexcept
Returns whether the cursor has reached the end of the bag.
static std::shared_ptr< BagReader > create(const std::string &path, bool read_only=true, bool try_to_fix=false)
Builds the concrete reader matching the extension of path.
Status
Coarse playback state observable through get_status().
Definition: bag_reader.h:130
bool open_cursor(const Config &config)
Opens (or rewinds) a synchronous sequential read cursor over the bag.
virtual void register_finish_callback(FinishCallback &&finish_callback)
Installs the "play session ended" observer.
virtual void clear_plugin_interface()
Detaches the currently bound plugin, if any.
bool open_cursor()
Opens (or rewinds) a full, unfiltered sequential read cursor over the bag.
virtual ~BagReader()
Stops the loop, closes the file and releases backend resources.
virtual void register_status_callback(StatusCallback &&status_callback)
Installs a state-change observer.
virtual void register_output_callback(OutputCallback &&output_callback)
Installs the per-frame data sink.
virtual void bind_plugin_interface(const std::shared_ptr< BagPluginInterface > &plugin_interface)
Attaches a custom URL/type/message rewrite plugin to this reader.
Serial task dispatcher with selectable queue backend and bounded timer registry.
Definition: message_loop.h:126
Move-only type-erased callable analogue of std::move_only_function with pool spill.
Definition: functional.h:134
#define VLINK_EXPORT
Definition: macros.h:81
#define VLINK_DISALLOW_COPY_AND_ASSIGN(classname)
Deletes the copy constructor and copy-assignment operator of classname.
Definition: macros.h:174
SchemaType
Coarse runtime schema family used by discovery, bag metadata and proxy routing.
Definition: types.h:207
@ kUnknown
Decoding family unknown.
ActionType
Labels for messages captured by the recording infrastructure.
Definition: types.h:185
@ kUnknownAction
Action category is not classified.
MoveFunction< void(const Frame &)> FrameCallback
Frame sink reused by every bag frame interface.
Definition: types.h:247
Playback parameters consumed by play().
Definition: bag_reader.h:204
std::unordered_set< std::string > filter_urls
Whitelist of playback URLs; empty means all URLs pass.
Definition: bag_reader.h:213
Aggregated metadata extracted from the bag header, summary and URL index.
Definition: bag_reader.h:144
std::string tag_name
Free-form tag persisted in the header.
Definition: bag_reader.h:176
std::vector< UrlMeta > url_metas
One entry per recorded URL.
Definition: bag_reader.h:197
std::string file_name
Absolute path to the opened bag file.
Definition: bag_reader.h:175
std::string process_name
Name of the recording process.
Definition: bag_reader.h:181
std::string compression_type
Default compression codec applied to payloads.
Definition: bag_reader.h:179
std::string storage_type
Storage backend label (e.g. "sqlite", "mcap").
Definition: bag_reader.h:178
std::string time_accuracy
Timestamp resolution token (e.g. "us", "ns").
Definition: bag_reader.h:180
std::string version
Bag format version string.
Definition: bag_reader.h:177
std::string date_time
Human-readable recording start date and time.
Definition: bag_reader.h:182
One recorded or replayed message as it flows through the bag pipeline.
Definition: types.h:230
Wire-format-neutral wrapper around one serialised schema blob.
Definition: types.h:301