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"
102 class BagPluginInterface;
120 static constexpr
int kInfinite{-1};
184 bool has_completed{
false};
185 bool has_idx_elapsed{
false};
186 bool has_idx_url{
false};
187 bool has_schema{
false};
189 int64_t start_timestamp{0};
190 int64_t blank_duration{0};
191 int64_t total_duration{0};
192 int64_t file_size{0};
193 int64_t total_raw_size{0};
194 int64_t message_count{0};
195 int64_t split_count{0};
196 int64_t split_by_size{0};
197 int64_t split_by_time{0};
206 int64_t begin_time{0};
210 bool skip_blank{
false};
211 int64_t force_delay{-1};
212 bool auto_pause{
false};
213 bool auto_quit{
false};
263 [[nodiscard]]
static std::shared_ptr<BagReader>
create(
const std::string& path,
bool read_only =
true,
264 bool try_to_fix =
false);
273 explicit BagReader(
const std::string& path,
bool read_only =
true,
bool try_to_fix =
false);
395 [[nodiscard]]
bool eof() const noexcept;
400 [[nodiscard]]
bool fail() const noexcept;
409 explicit operator
bool() const noexcept;
420 virtual
void play(const
Config& config) = 0;
429 virtual
void stop() = 0;
434 virtual
void pause() = 0;
439 virtual
void resume() = 0;
444 virtual
void pause_to_next() = 0;
454 virtual
void jump(int64_t begin_time,
double rate,
int times,
bool force_to_play = false) = 0;
461 virtual std::future<
bool> check() = 0;
468 virtual std::future<
bool> reindex() = 0;
476 virtual std::future<
bool> fix(
bool rebuild = false) = 0;
483 virtual
void tag(const std::
string& tag_name) = 0;
490 [[nodiscard]] virtual int64_t get_timestamp() const = 0;
497 [[nodiscard]] virtual int64_t get_real_timestamp() const = 0;
504 [[nodiscard]] virtual
Status get_status() const = 0;
511 [[nodiscard]] virtual const
Info& get_info() const = 0;
518 [[nodiscard]] virtual std::vector<
SchemaData> detect_schema() = 0;
526 [[nodiscard]] virtual std::
string get_ser_type(const std::
string& url) const;
534 [[nodiscard]] virtual
SchemaType get_schema_type(const std::
string& url) const;
539 [[nodiscard]] virtual
bool is_split_mode() const = 0;
546 [[nodiscard]] virtual
int get_split_index() const = 0;
551 [[nodiscard]] virtual
bool is_jumping() const = 0;
554 virtual
bool do_open_cursor(const
Config& config);
556 virtual
bool do_read_next(
Frame& out,
bool& is_error);
558 static
void rebuild_url_meta_maps(const std::vector<
Info::UrlMeta>& url_metas,
559 std::unordered_map<std::
string, std::
string>& ser_map,
560 std::unordered_map<std::
string,
SchemaType>& schema_type_map);
564 void fill_frame_meta(
Frame& frame) const;
570 void process_url_metas(std::vector<
Info::UrlMeta>& url_metas);
572 void rebuild_url_meta_lookup(const std::vector<
Info::UrlMeta>& url_metas);
574 std::unordered_map<std::
string, std::
string>& url_ser_map();
576 std::unordered_map<std::
string,
SchemaType>& url_schema_type_map();
578 bool convert_playback_url(const std::
string& input_url, std::
string& output_url) const;
580 bool match_playback_url_filter(std::string_view input_url, const std::unordered_set<std::
string>& filter_urls) const;
582 bool has_playback_url_rules() const noexcept;
586 void detach_plugin();
590 std::unique_ptr<Impl> impl_;
Format-agnostic VLink bag player driven by an internal MessageLoop.
Definition: bag_reader.h:115
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:131
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 bind_bag_interface(const std::shared_ptr< BagPluginInterface > &bag_interface)
Attaches a custom URL/type/message rewrite plugin to this reader.
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 clear_bag_interface()
Detaches the currently bound plugin, if any.
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:135
#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:203
@ kUnknown
Decoding family unknown.
ActionType
Labels for messages captured by the recording infrastructure.
Definition: types.h:181
@ kUnknownAction
Action category is not classified.
MoveFunction< void(const Frame &)> FrameCallback
Frame sink reused by every bag frame interface.
Definition: types.h:243
Playback parameters consumed by play().
Definition: bag_reader.h:205
std::unordered_set< std::string > filter_urls
Whitelist of playback URLs; empty means all URLs pass.
Definition: bag_reader.h:214
Aggregated metadata extracted from the bag header, summary and URL index.
Definition: bag_reader.h:145
std::string tag_name
Free-form tag persisted in the header.
Definition: bag_reader.h:177
std::vector< UrlMeta > url_metas
One entry per recorded URL.
Definition: bag_reader.h:198
std::string file_name
Absolute path to the opened bag file.
Definition: bag_reader.h:176
std::string process_name
Name of the recording process.
Definition: bag_reader.h:182
std::string compression_type
Default compression codec applied to payloads.
Definition: bag_reader.h:180
std::string storage_type
Storage backend label (e.g. "sqlite", "mcap").
Definition: bag_reader.h:179
std::string time_accuracy
Timestamp resolution token (e.g. "us", "ns").
Definition: bag_reader.h:181
std::string version
Bag format version string.
Definition: bag_reader.h:178
std::string date_time
Human-readable recording start date and time.
Definition: bag_reader.h:183
One recorded or replayed message as it flows through the bag pipeline.
Definition: types.h:226
Wire-format-neutral wrapper around one serialised schema blob.
Definition: types.h:297