44#pragma once
55
66#include < openxr/openxr.h>
7- #include < schema/timestamp_generated.h>
87
9- #include < functional>
108#include < memory>
119#include < string>
1210#include < string_view>
@@ -19,62 +17,14 @@ namespace core
1917struct OpenXRSessionHandles ;
2018class ITrackerFactory ;
2119
22- // Base interface for tracker implementations
23- // These are the actual worker objects that get updated by the session
20+ // Base interface for tracker implementations.
21+ // The actual worker objects updated each frame by DeviceIOSession.
2422class ITrackerImpl
2523{
2624public:
2725 virtual ~ITrackerImpl () = default ;
2826
29- // Update the tracker with the current time
3027 virtual bool update (XrTime time) = 0;
31-
32- /* *
33- * @brief Callback type for serialize_all.
34- *
35- * Receives (log_time_ns, data_ptr, data_size) for each serialized record.
36- *
37- * @param log_time_ns Monotonic nanoseconds used as the MCAP logTime/publishTime
38- * for this record. This is the time at which the recording
39- * system processed the record (update-tick time), not the
40- * sample capture time. The full per-sample DeviceDataTimestamp
41- * (including sample_time and raw_device_time) is embedded
42- * inside the serialized FlatBuffer payload.
43- *
44- * @warning The data_ptr and data_size are only valid for the duration of the
45- * callback invocation. The buffer is owned by a FlatBufferBuilder
46- * local to the tracker's serialize_all implementation and will be
47- * destroyed on return. If you need the bytes after the callback
48- * returns, copy them into your own storage before returning.
49- */
50- using RecordCallback = std::function<void (int64_t log_time_ns, const uint8_t *, size_t )>;
51-
52- /* *
53- * @brief Serialize all records accumulated since the last update() call.
54- *
55- * Each call to update() clears the previous batch and accumulates a fresh
56- * set of records (one for OpenXR-direct trackers; potentially many for
57- * SchemaTracker-based tensor-device trackers). serialize_all emits every
58- * record in that batch via the callback.
59- *
60- * @note For multi-channel trackers the recorder calls serialize_all once per
61- * channel index (channel_index = 0, 1, … N-1) after each update().
62- * All serialize_all calls for a given update() are guaranteed to
63- * complete before the next update() is issued. Implementations may
64- * therefore maintain a single shared pending batch and clear it at the
65- * start of the next update(); there is no need to track per-channel
66- * drain state.
67- *
68- * For read access without MCAP recording, use the tracker's typed get_*()
69- * accessors, which always reflect the last record in the current batch.
70- *
71- * @note The buffer pointer passed to the callback is only valid for the
72- * duration of that callback call. Copy if you need it beyond return.
73- *
74- * @param channel_index Which record channel to serialize (0-based).
75- * @param callback Invoked once per record with (timestamp, data_ptr, data_size).
76- */
77- virtual void serialize_all (size_t channel_index, const RecordCallback& callback) const = 0;
7828};
7929
8030/* *
@@ -100,8 +50,8 @@ class ITrackerSession
10050 virtual const ITrackerImpl& get_tracker_impl (const class ITracker & tracker) const = 0;
10151};
10252
103- // Base interface for all trackers
104- // PUBLIC API: Only exposes methods that external users should call
53+ // Base interface for all trackers.
54+ // Public API: configuration, extension requirements, and typed data accessors.
10555class ITracker
10656{
10757public:
@@ -110,48 +60,14 @@ class ITracker
11060 virtual std::vector<std::string> get_required_extensions () const = 0;
11161 virtual std::string_view get_name () const = 0;
11262
113- /* *
114- * @brief Get the FlatBuffer schema name (root type) for MCAP recording.
115- *
116- * This should return the fully qualified FlatBuffer type name (e.g., "core.HandPose")
117- * which matches the root_type defined in the .fbs schema file.
118- */
119- virtual std::string_view get_schema_name () const = 0;
120-
121- /* *
122- * @brief Get the binary FlatBuffer schema text for MCAP recording.
123- */
124- virtual std::string_view get_schema_text () const = 0;
125-
126- /* *
127- * @brief Get the channel names for MCAP recording.
128- *
129- * Every tracker must return at least one non-empty channel name. The returned
130- * vector size determines how many times serialize_all() is called per update,
131- * with the vector index used as the channel_index argument.
132- *
133- * Single-channel trackers return one name (e.g. {"head"}).
134- * Multi-channel trackers return multiple (e.g. {"left_hand", "right_hand"}).
135- *
136- * The MCAP recorder combines each channel name with the base channel name
137- * provided at registration as "base_name/channel_name". For example, a
138- * single-channel head tracker registered with base name "tracking" produces
139- * the MCAP channel "tracking/head". A multi-channel hand tracker registered
140- * with base name "hands" produces "hands/left_hand" and "hands/right_hand".
141- *
142- * @return Non-empty vector of non-empty channel name strings.
143- */
144- virtual std::vector<std::string> get_record_channels () const = 0;
145-
14663 /* *
14764 * @brief Create the tracker's implementation via the provided factory.
14865 *
14966 * Uses double dispatch: the tracker calls the factory method specific to its
150- * type (e.g., factory.create_head_tracker_impl()), so the factory controls
151- * which concrete impl is constructed without the tracker needing to know the
152- * session type.
67+ * concrete type, passing `this` so the factory can query a recorder for a
68+ * channel writer and attach it to the impl at construction time.
15369 *
154- * @param factory Session-provided factory (e.g., LiveDeviceIOFactory).
70+ * @param factory Session-provided factory (e.g. LiveDeviceIOFactory).
15571 * @return Owning pointer to the newly created impl.
15672 */
15773 virtual std::unique_ptr<ITrackerImpl> create_tracker_impl (ITrackerFactory& factory) const = 0;
0 commit comments