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