Monado OpenXR Runtime
Loading...
Searching...
No Matches
b_sink_bridge.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 Moves frames and timing events between two frame contexts.
6 * @author Jakob Bornecrantz <tbornecrantz@nvidia.com>
7 * @ingroup base
8 */
9
10#pragma once
11
12#include "xrt/xrt_frame.h"
14#include "xrt/xrt_results.h"
15#include "xrt/xrt_tracking.h"
16
18
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24//! Number of frame sources.
25#define B_SINK_BRIDGE_MAX_FRAME_SOURCES XRT_TRACKING_MAX_FRAME_SOURCES
26
27/*!
28 * Number of timing event sources. Synced cameras usually share one, but each
29 * frame source could have its own.
30 */
31#define B_SINK_BRIDGE_MAX_TIMING_SOURCES XRT_TRACKING_MAX_FRAME_SOURCES
32
33//! How many sinks can be added to each receiving source.
34#define B_SINK_BRIDGE_MAX_SINKS 4
35
36/*!
37 * Lets a long lived producer, like a camera, keep running while the frame
38 * context that consumes its data is torn down and created again.
39 *
40 * The bridge has one node in the sending context and one in the receiving
41 * context, it is freed once the nodes in all contexts it has been in are
42 * destroyed, in any order. The producer pushes into the plain sinks from
43 * @ref b_sink_bridge_get_frame_sink and @ref b_sink_bridge_get_timing_sink, so
44 * it doesn't need to know about the bridge. Frame and timing event sources are
45 * indexed separately, which index the producer uses for what is up to it and
46 * the consumers.
47 *
48 * The receiving context can keep references to frames, in queues for example,
49 * for longer than the sending context lives. If the frames' memory belongs to
50 * the producer, like a driver's frame pool, the receiving context must be
51 * destroyed first.
52 *
53 * The receiving side is one context at a time. After
54 * @ref b_sink_bridge_attach consumers add their sinks to the sources from
55 * @ref b_sink_bridge_get_frame_source and @ref b_sink_bridge_get_timing_source.
56 * When the receiving context is broken apart all of its sinks are dropped, so
57 * consumers living in it don't need to remove them, and must add them again
58 * after the next attach. Sinks destroyed before the receiving context, like a
59 * controller that is unplugged, must be removed.
60 *
61 * @ingroup base
62 */
63struct b_sink_bridge;
64
65/*!
66 * Create a bridge, it is added to @p send_xfctx.
67 *
68 * @ingroup base
69 */
71b_sink_bridge_create(struct xrt_frame_context *send_xfctx, struct b_sink_bridge **out_bsb);
72
73/*!
74 * Attach the receiving side to @p recv_xfctx. Fails if it is already attached
75 * to a context that hasn't been destroyed yet.
76 *
77 * @public @memberof b_sink_bridge
78 */
80b_sink_bridge_attach(struct b_sink_bridge *bsb, struct xrt_frame_context *recv_xfctx);
81
82/*!
83 * Sink for the producer to push frames for frame source @p index into.
84 *
85 * @public @memberof b_sink_bridge
86 */
87struct xrt_frame_sink *
88b_sink_bridge_get_frame_sink(struct b_sink_bridge *bsb, uint32_t index);
89
90/*!
91 * Sink for the producer to push timing events for timing event source
92 * @p index into.
93 *
94 * @public @memberof b_sink_bridge
95 */
97b_sink_bridge_get_timing_sink(struct b_sink_bridge *bsb, uint32_t index);
98
99/*!
100 * Receiving side frame source @p index, adding sinks to it fails when the
101 * bridge isn't attached.
102 *
103 * @public @memberof b_sink_bridge
104 */
105struct xrt_frame_source *
106b_sink_bridge_get_frame_source(struct b_sink_bridge *bsb, uint32_t index);
107
108/*!
109 * Receiving side timing event source @p index, adding sinks to it fails when
110 * the bridge isn't attached.
111 *
112 * @public @memberof b_sink_bridge
113 */
115b_sink_bridge_get_timing_source(struct b_sink_bridge *bsb, uint32_t index);
116
117#ifdef __cplusplus
118}
119#endif
xrt_result_t b_sink_bridge_create(struct xrt_frame_context *send_xfctx, struct b_sink_bridge **out_bsb)
Create a bridge, it is added to send_xfctx.
Definition b_sink_bridge.c:317
enum xrt_result xrt_result_t
Result type used across Monado.
Definition b_sink_bridge.c:42
xrt_result_t b_sink_bridge_attach(struct b_sink_bridge *bsb, struct xrt_frame_context *recv_xfctx)
Attach the receiving side to recv_xfctx.
Definition b_sink_bridge.c:349
A time sync sink is a component that receives timing events from a stable timing source,...
Definition t_time_sync.h:69
A time sync source is a component that generates timing events for an t_timing_event_sink to consume.
Definition t_time_sync.h:102
Object used to track all sinks and frame producers in a graph.
Definition xrt_frame.h:108
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
Header defining interfaces for time synchronization in Monado.
Data frame header.
Frame source interface, frame sinks can be added and removed at runtime.
Internal result type for XRT.
Header defining the tracking system integration in Monado.