Monado OpenXR Runtime
xrt_frameserver.h
Go to the documentation of this file.
1// Copyright 2019, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Frameserver interface for video drivers.
6 * @author Pete Black <pblack@collabora.com>
7 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
8 * @author Jakob Bornecrantz <jakob@collabora.com>
9 * @ingroup xrt_iface
10 */
11
12#pragma once
13
14#include "xrt/xrt_frame.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20struct xrt_slam_sinks;
21
22/*!
23 * Controlling the camera capture parameters
24 *
25 * Used to configure cameras. since there is no guarantee every
26 * frameserver will support any/all of these params, a 'best effort'
27 * should be made to apply them. all numeric values are normalised
28 * floats for broad applicability.
29 *
30 * @ingroup xrt_iface
31 * @see xrt_fs
32 */
34{
35 float gain;
36 float exposure;
37};
38
39/*!
40 * @see xrt_fs
41 * @ingroup xrt_iface
42 */
44{
45 uint32_t width;
46 uint32_t height;
47 enum xrt_format format;
48 enum xrt_stereo_format stereo_format;
49};
50
51/*!
52 * Enum describing which type of capture we are doing.
53 * @see xrt_fs
54 * @ingroup xrt_iface
55 */
57{
58 XRT_FS_CAPTURE_TYPE_TRACKING = 0,
59 XRT_FS_CAPTURE_TYPE_CALIBRATION = 1,
60};
61
62/*!
63 * @interface xrt_fs
64 * Frameserver that generates frames. Multiple subframes (like stereo and
65 * mipmaps) can be generate in one frame.
66 *
67 * @ingroup xrt_iface
68 */
69struct xrt_fs
70{
71 //! Name of the frame server source, from the subsystem.
72 char name[512];
73 //! Frame server product identifier, matches the prober device.
74 char product[32];
75 //! Frame server manufacturer, matches the prober device.
76 char manufacturer[32];
77 //! Frame server serial number, matches the prober device.
78 char serial[32];
79
80 /*!
81 * All frames produced by this frameserver are tagged with this id.
82 */
83 uint64_t source_id;
84
85 /*!
86 * Enumerate all available modes that this frameserver supports.
87 */
88 bool (*enumerate_modes)(struct xrt_fs *xfs, struct xrt_fs_mode **out_modes, uint32_t *out_count);
89
90 /*!
91 * Set the capture parameters, may not be supported on all capture
92 * devices.
93 */
95
96 /*!
97 * Start the capture stream.
98 */
99 bool (*stream_start)(struct xrt_fs *xfs,
100 struct xrt_frame_sink *xs,
101 enum xrt_fs_capture_type capture_type,
102 uint32_t descriptor_index);
103
104 /*!
105 * Setup SLAM sinks for all the sensors a SLAM implementation may supports and
106 * start the frame server stream. Use @ref xrt_fs::stream_start instead if
107 * you only need the image stream.
108 *
109 * @note Having this method extends the scope of the frameserver to something
110 * more akin to a generic data source instead of just serving frames.
111 *
112 * @todo Fix this incongruence. Maybe rename the interface to xrt_data_source.
113 */
114 bool (*slam_stream_start)(struct xrt_fs *xfs, struct xrt_slam_sinks *sinks);
115
116 /*!
117 * Stop the capture stream.
118 */
119 bool (*stream_stop)(struct xrt_fs *xfs);
120
121 /*!
122 * Is the capture stream running.
123 */
124 bool (*is_running)(struct xrt_fs *xfs);
125};
126
127
128/*
129 *
130 * Inline functions.
131 *
132 */
133
134/*!
135 * @copydoc xrt_fs::enumerate_modes
136 *
137 * Helper for calling through the function pointer.
138 *
139 * @public @memberof xrt_fs
140 */
141static inline bool
142xrt_fs_enumerate_modes(struct xrt_fs *xfs, struct xrt_fs_mode **out_modes, uint32_t *out_count)
143{
144 return xfs->enumerate_modes(xfs, out_modes, out_count);
145}
146
147/*!
148 * @copydoc xrt_fs::configure_capture
149 *
150 * Helper for calling through the function pointer.
151 *
152 * @public @memberof xrt_fs
153 */
154static inline bool
156{
157 return xfs->configure_capture(xfs, cp);
158}
159
160/*!
161 * @copydoc xrt_fs::stream_start
162 *
163 * Helper for calling through the function pointer.
164 *
165 * @public @memberof xrt_fs
166 */
167static inline bool
169 struct xrt_frame_sink *xs,
170 enum xrt_fs_capture_type capture_type,
171 uint32_t descriptor_index)
172{
173 return xfs->stream_start(xfs, xs, capture_type, descriptor_index);
174}
175
176/*!
177 * @copydoc xrt_fs::slam_stream_start
178 *
179 * Helper for calling through the function pointer.
180 *
181 * @public @memberof xrt_fs
182 */
183static inline bool
185{
186 return xfs->slam_stream_start(xfs, sinks);
187}
188
189/*!
190 * @copydoc xrt_fs::stream_stop
191 *
192 * Helper for calling through the function pointer.
193 *
194 * @public @memberof xrt_fs
195 */
196static inline bool
198{
199 return xfs->stream_stop(xfs);
200}
201
202/*!
203 * @copydoc xrt_fs::is_running
204 *
205 * Helper for calling through the function pointer.
206 *
207 * @public @memberof xrt_fs
208 */
209static inline bool
211{
212 return xfs->is_running(xfs);
213}
214
215
216#ifdef __cplusplus
217}
218#endif
xrt_stereo_format
What type of stereo format a frame has.
Definition: xrt_defines.h:203
xrt_fs_capture_type
Enum describing which type of capture we are doing.
Definition: xrt_frameserver.h:57
A object that is sent frames.
Definition: xrt_frame.h:58
Controlling the camera capture parameters.
Definition: xrt_frameserver.h:34
Definition: xrt_frameserver.h:44
Frameserver that generates frames.
Definition: xrt_frameserver.h:70
bool(* stream_start)(struct xrt_fs *xfs, struct xrt_frame_sink *xs, enum xrt_fs_capture_type capture_type, uint32_t descriptor_index)
Start the capture stream.
Definition: xrt_frameserver.h:99
bool(* stream_stop)(struct xrt_fs *xfs)
Stop the capture stream.
Definition: xrt_frameserver.h:119
bool(* is_running)(struct xrt_fs *xfs)
Is the capture stream running.
Definition: xrt_frameserver.h:124
static bool xrt_fs_is_running(struct xrt_fs *xfs)
Is the capture stream running.
Definition: xrt_frameserver.h:210
char product[32]
Frame server product identifier, matches the prober device.
Definition: xrt_frameserver.h:74
bool(* slam_stream_start)(struct xrt_fs *xfs, struct xrt_slam_sinks *sinks)
Setup SLAM sinks for all the sensors a SLAM implementation may supports and start the frame server st...
Definition: xrt_frameserver.h:114
char serial[32]
Frame server serial number, matches the prober device.
Definition: xrt_frameserver.h:78
static bool xrt_fs_slam_stream_start(struct xrt_fs *xfs, struct xrt_slam_sinks *sinks)
Setup SLAM sinks for all the sensors a SLAM implementation may supports and start the frame server st...
Definition: xrt_frameserver.h:184
static bool xrt_fs_enumerate_modes(struct xrt_fs *xfs, struct xrt_fs_mode **out_modes, uint32_t *out_count)
Enumerate all available modes that this frameserver supports.
Definition: xrt_frameserver.h:142
char manufacturer[32]
Frame server manufacturer, matches the prober device.
Definition: xrt_frameserver.h:76
bool(* enumerate_modes)(struct xrt_fs *xfs, struct xrt_fs_mode **out_modes, uint32_t *out_count)
Enumerate all available modes that this frameserver supports.
Definition: xrt_frameserver.h:88
static bool xrt_fs_configure_capture(struct xrt_fs *xfs, struct xrt_fs_capture_parameters *cp)
Set the capture parameters, may not be supported on all capture devices.
Definition: xrt_frameserver.h:155
bool(* configure_capture)(struct xrt_fs *xfs, struct xrt_fs_capture_parameters *cp)
Set the capture parameters, may not be supported on all capture devices.
Definition: xrt_frameserver.h:94
static bool xrt_fs_stream_stop(struct xrt_fs *xfs)
Stop the capture stream.
Definition: xrt_frameserver.h:197
static bool xrt_fs_stream_start(struct xrt_fs *xfs, struct xrt_frame_sink *xs, enum xrt_fs_capture_type capture_type, uint32_t descriptor_index)
Start the capture stream.
Definition: xrt_frameserver.h:168
char name[512]
Name of the frame server source, from the subsystem.
Definition: xrt_frameserver.h:72
uint64_t source_id
All frames produced by this frameserver are tagged with this id.
Definition: xrt_frameserver.h:83
Container of pointers to sinks that could be used for a SLAM system.
Definition: xrt_tracking.h:202
xrt_format
Common formats, use u_format_* functions to reason about them.
Definition: xrt_defines.h:176
Data frame header.