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 Ryan Pavlik <ryan.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
17 extern "C" {
18 #endif
19 
20 
21 /*!
22  * Controlling the camera capture parameters
23  *
24  * Used to configure cameras. since there is no guarantee every
25  * frameserver will support any/all of these params, a 'best effort'
26  * should be made to apply them. all numeric values are normalised
27  * floats for broad applicability.
28  *
29  * @ingroup xrt_iface
30  */
32 {
33  float gain;
34  float exposure;
35 };
36 
38 {
39  uint32_t width;
40  uint32_t height;
41  enum xrt_format format;
42  enum xrt_stereo_format stereo_format;
43 };
44 
45 /*!
46  * Frameserver that generates frame, multiple subframes (like stereo and
47  * mipmaps) can be generate in one frame.
48  *
49  * @ingroup xrt_iface
50  */
51 struct xrt_fs
52 {
53  /*!
54  * Name of the frame server source.
55  */
56  char name[512];
57 
58  /*!
59  * All frames produced by this frameserver is tagged with this id.
60  */
61  uint64_t source_id;
62 
63  /*!
64  * Enumerate all available modes that this frameserver supports.
65  */
66  bool (*enumerate_modes)(struct xrt_fs *xfs,
67  struct xrt_fs_mode **out_modes,
68  uint32_t *out_count);
69 
70  /*!
71  * Set the capture parameters, may not be supported on all capture
72  * devices.
73  */
74  bool (*configure_capture)(struct xrt_fs *xfs,
75  struct xrt_fs_capture_parameters *cp);
76 
77  /*!
78  * Start the capture stream.
79  */
80  bool (*stream_start)(struct xrt_fs *xfs,
81  struct xrt_frame_sink *xs,
82  uint32_t descriptor_index);
83 
84  /*!
85  * Stop the capture stream.
86  */
87  bool (*stream_stop)(struct xrt_fs *xfs);
88 
89  /*!
90  * Is the capture stream running.
91  */
92  bool (*is_running)(struct xrt_fs *xfs);
93 };
94 
95 
96 /*
97  *
98  * Inline functions.
99  *
100  */
101 
102 /*!
103  * Helper for xrt_fs::enumerate_modes.
104  *
105  * @ingroup xrt_iface
106  */
107 static inline bool
108 xrt_fs_enumerate_modes(struct xrt_fs *xfs,
109  struct xrt_fs_mode **out_modes,
110  uint32_t *out_count)
111 {
112  return xfs->enumerate_modes(xfs, out_modes, out_count);
113 }
114 
115 /*!
116  * Helper for xrt_fs::configure_capture.
117  *
118  * @ingroup xrt_iface
119  */
120 static inline bool
121 xrt_fs_configure_capture(struct xrt_fs *xfs,
122  struct xrt_fs_capture_parameters *cp)
123 {
124  return xfs->configure_capture(xfs, cp);
125 }
126 
127 /*!
128  * Helper for xrt_fs::stream_start.
129  *
130  * @ingroup xrt_iface
131  */
132 static inline bool
133 xrt_fs_stream_start(struct xrt_fs *xfs,
134  struct xrt_frame_sink *xs,
135  uint32_t descriptor_index)
136 {
137  return xfs->stream_start(xfs, xs, descriptor_index);
138 }
139 
140 /*!
141  * Helper for xrt_fs::stream_stop.
142  *
143  * @ingroup xrt_iface
144  */
145 static inline bool
146 xrt_fs_stream_stop(struct xrt_fs *xfs)
147 {
148  return xfs->stream_stop(xfs);
149 }
150 
151 /*!
152  * Helper for xrt_fs::is_running.
153  *
154  * @ingroup xrt_iface
155  */
156 static inline bool
157 xrt_fs_is_running(struct xrt_fs *xfs)
158 {
159  return xfs->is_running(xfs);
160 }
161 
162 
163 #ifdef __cplusplus
164 }
165 #endif
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:74
bool(* stream_stop)(struct xrt_fs *xfs)
Stop the capture stream.
Definition: xrt_frameserver.h:87
xrt_stereo_format
What type of stereo format a frame has.
Definition: xrt_defines.h:84
Definition: xrt_frameserver.h:37
A object that is sent frames.
Definition: xrt_frame.h:51
Controlling the camera capture parameters.
Definition: xrt_frameserver.h:31
bool(* is_running)(struct xrt_fs *xfs)
Is the capture stream running.
Definition: xrt_frameserver.h:92
Data frame header.
xrt_format
Common formats, use u_format_* functions to reason about them.
Definition: xrt_defines.h:60
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:66
uint64_t source_id
All frames produced by this frameserver is tagged with this id.
Definition: xrt_frameserver.h:61
Frameserver that generates frame, multiple subframes (like stereo and mipmaps) can be generate in one...
Definition: xrt_frameserver.h:51
bool(* stream_start)(struct xrt_fs *xfs, struct xrt_frame_sink *xs, uint32_t descriptor_index)
Start the capture stream.
Definition: xrt_frameserver.h:80