NsdkSessionDataSource
Provides synchronous, pull-based access to the latest available sensor data required by [NSDKSession]. All methods must be non-blocking and thread-safe. Returned values represent the most recent samples already captured by the underlying services. Implement this interface and assign it to [NSDKSession.dataSource], then call [NSDKSession.update] once per camera frame to submit data to the native layer.
Declaration
interface NsdkSessionDataSourceFunctions
| Name | Type | Summary |
|---|---|---|
| latestCameraSample | CameraSample? | Returns the most recent camera sample, or null if unavailable. |
| latestCompassSample | Compass? | Returns the most recent compass/magnetometer reading, or null if unavailable. |
| latestDepthSample | DepthSample? | Returns the most recent platform depth sample (e.g. LiDAR), or null if unavailable. |
| latestGpsSample | Location? | Returns the most recent GPS location, or null if unavailable. |
| latestTrackingStateSample | TrackingState | Returns the current VIO tracking state. |
| prepareFrame | Boolean | Snapshots the current frame data so that [latestCameraSample] and the other accessors can be called from any thread. Returns true when a frame is ready to be consumed, false if no frame was available — in which case the caller should skip [NSDKSession.update]. The default implementation returns true and does nothing; data sources that hold no per-frame state do not need to override it. Threading contract: the caller must ensure that [prepareFrame], [NSDKSession.update], and any latest* accessor calls are serialized — i.e., a complete prepareFrame → update → (accessors finish) cycle must complete before the next [prepareFrame] call begins. This is typically achieved by driving the cycle from a single-threaded executor or a coroutine with an in-flight gate. |