Monado OpenXR Runtime
rs_driver.h
Go to the documentation of this file.
1// Copyright 2021, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Internal header for the RealSense driver.
6 * @author Mateo de Mayo <mateo.demayo@collabora.com>
7 * @ingroup drv_realsense
8 */
9#pragma once
10
11#include "xrt/xrt_prober.h"
12
13#include "rs_interface.h"
14
15#include <librealsense2/rs.h>
16#include <librealsense2/h/rs_pipeline.h>
17
18/*!
19 * @addtogroup drv_realsense
20 * @{
21 */
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27//! Container to store and manage useful objects from the RealSense API
29{
30 rs2_error *error_status;
31
32 // Used by prober and devices
33 rs2_context *context; //!< RealSense API context
34 rs2_device_list *device_list; //!< List of connected RealSense devices
35 int device_count; //!< Length of device_list
36
37 // Used by devices
38 int device_idx; //!< `device` index in `device_list`
39 rs2_device *device; //!< Main device
40 rs2_pipeline *pipeline; //!< RealSense running pipeline
41 rs2_config *config; //!< Pipeline streaming configuration
42 rs2_pipeline_profile *profile; //!< Pipeline profile
43};
44
45//! Cleans up an @ref rs_container and resets its fields to NULL;
46static void
48{
49 // A note about what is and what is not being deleted:
50 // In its documentation, the RealSense API specifies which calls require the
51 // caller to delete the returned object afterwards. By looking at the code of
52 // the API it seems that when that is not explicitly pointed out in the
53 // interface documentation, you should *not* delete the returned object.
54
55 // clang-format off
56 if (rsc->profile) rs2_delete_pipeline_profile(rsc->profile);
57 if (rsc->config) rs2_delete_config(rsc->config);
58 if (rsc->pipeline) rs2_delete_pipeline(rsc->pipeline);
59 if (rsc->device) rs2_delete_device(rsc->device);
60 if (rsc->device_list) rs2_delete_device_list(rsc->device_list);
61 if (rsc->context) rs2_delete_context(rsc->context);
62 if (rsc->error_status) rs2_free_error(rsc->error_status);
63 // clang-format on
64
65 rsc->profile = NULL;
66 rsc->config = NULL;
67 rsc->pipeline = NULL;
68 rsc->device = NULL;
69 rsc->device_idx = -1;
70 rsc->device_count = 0;
71 rsc->device_list = NULL;
72 rsc->context = NULL;
73 rsc->error_status = NULL;
74}
75
76//! Create a RealSense device tracked with device-SLAM (T26x).
77struct xrt_device *
78rs_ddev_create(int device_idx);
79
80//! Create RealSense device tracked with host-SLAM (one with camera and IMU streams)
81struct xrt_device *
82rs_hdev_create(struct xrt_prober *xp, int device_idx);
83
84/*!
85 * @}
86 */
87
88#ifdef __cplusplus
89}
90#endif
struct xrt_device * rs_ddev_create(int device_idx)
Create a RealSense device tracked with device-SLAM (T26x).
Definition: rs_ddev.c:442
struct xrt_device * rs_hdev_create(struct xrt_prober *xp, int device_idx)
Create RealSense device tracked with host-SLAM (one with camera and IMU streams)
Definition: rs_hdev.c:989
static void rs_container_cleanup(struct rs_container *rsc)
Cleans up an rs_container and resets its fields to NULL;.
Definition: rs_driver.h:47
Interface to RealSense devices.
Container to store and manage useful objects from the RealSense API.
Definition: rs_driver.h:29
rs2_device * device
Main device.
Definition: rs_driver.h:39
rs2_pipeline * pipeline
RealSense running pipeline.
Definition: rs_driver.h:40
int device_count
Length of device_list.
Definition: rs_driver.h:35
rs2_device_list * device_list
List of connected RealSense devices.
Definition: rs_driver.h:34
rs2_pipeline_profile * profile
Pipeline profile.
Definition: rs_driver.h:42
rs2_config * config
Pipeline streaming configuration.
Definition: rs_driver.h:41
int device_idx
device index in device_list
Definition: rs_driver.h:38
rs2_context * context
RealSense API context.
Definition: rs_driver.h:33
A single HMD or input device.
Definition: xrt_device.h:241
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition: xrt_prober.h:132
Common interface to probe for devices.