Monado OpenXR Runtime
Loading...
Searching...
No Matches
xrt_frame_source.h
Go to the documentation of this file.
1// Copyright 2026, NVIDIA CORPORATION.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Frame source interface, frame sinks can be added and removed at runtime.
6 * @author Jakob Bornecrantz <tbornecrantz@nvidia.com>
7 * @ingroup xrt_iface
8 */
9
10#pragma once
11
12#include "xrt/xrt_frame.h"
13#include "xrt/xrt_results.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19
20/*!
21 * @interface xrt_frame_source
22 *
23 * Something that produces frames, and pushes them to all sinks added to it.
24 * The frame counterpart of @ref t_timing_event_source.
25 *
26 * Implementations **must** also implement @ref xrt_frame_node. Once
27 * @ref xrt_frame_source::remove_sink returns the sink will not be pushed to
28 * again, so it is safe to destroy it.
29 *
30 * The same frame is pushed to all sinks, so they must not modify it. Sinks
31 * must not add or remove sinks on the same source from within
32 * @ref xrt_frame_sink::push_frame.
33 *
34 * @ingroup xrt_iface
35 */
37{
38 /*!
39 * Add a sink that frames will be pushed to.
40 *
41 * @param xfsrc The frame source.
42 * @param xs The sink to add.
43 *
44 * @return XRT_SUCCESS, XRT_ERROR_ALLOCATION if the source is full, or
45 * another error if the source can't take sinks right now.
46 */
48
49 /*!
50 * Remove a sink, does nothing if it hasn't been added. Waits for any
51 * in-flight push to the sink to return.
52 *
53 * @param xfsrc The frame source.
54 * @param xs The sink to remove.
55 */
56 void (*remove_sink)(struct xrt_frame_source *xfsrc, struct xrt_frame_sink *xs);
57};
58
59/*!
60 * @copydoc xrt_frame_source::add_sink
61 *
62 * Helper for calling through the function pointer.
63 *
64 * @public @memberof xrt_frame_source
65 */
66XRT_NONNULL_ALL static inline xrt_result_t
68{
69 return xfsrc->add_sink(xfsrc, xs);
70}
71
72/*!
73 * @copydoc xrt_frame_source::remove_sink
74 *
75 * Helper for calling through the function pointer.
76 *
77 * @public @memberof xrt_frame_source
78 */
79XRT_NONNULL_ALL static inline void
81{
82 xfsrc->remove_sink(xfsrc, xs);
83}
84
85
86#ifdef __cplusplus
87}
88#endif
enum xrt_result xrt_result_t
Result type used across Monado.
A object that is sent frames.
Definition xrt_frame.h:58
Something that produces frames, and pushes them to all sinks added to it.
Definition xrt_frame_source.h:37
static XRT_NONNULL_ALL void xrt_frame_source_remove_sink(struct xrt_frame_source *xfsrc, struct xrt_frame_sink *xs)
Remove a sink, does nothing if it hasn't been added.
Definition xrt_frame_source.h:80
void(* remove_sink)(struct xrt_frame_source *xfsrc, struct xrt_frame_sink *xs)
Remove a sink, does nothing if it hasn't been added.
Definition xrt_frame_source.h:56
static XRT_NONNULL_ALL xrt_result_t xrt_frame_source_add_sink(struct xrt_frame_source *xfsrc, struct xrt_frame_sink *xs)
Add a sink that frames will be pushed to.
Definition xrt_frame_source.h:67
xrt_result_t(* add_sink)(struct xrt_frame_source *xfsrc, struct xrt_frame_sink *xs)
Add a sink that frames will be pushed to.
Definition xrt_frame_source.h:47
Data frame header.
Internal result type for XRT.