Intel® RealSense™ Cross Platform API  2.13.0
Intel Realsense Cross-platform API
rs_internal.hpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #ifndef LIBREALSENSE_RS2_INTERNAL_HPP
5 #define LIBREALSENSE_RS2_INTERNAL_HPP
6 
7 #include "rs_types.hpp"
8 #include "rs_device.hpp"
9 #include "rs_context.hpp"
10 #include "../h/rs_internal.h"
11 
12 namespace rs2
13 {
14  class recording_context : public context
15  {
16  public:
21  recording_context(const std::string& filename,
22  const std::string& section = "",
24  {
25  rs2_error* e = nullptr;
26  _context = std::shared_ptr<rs2_context>(
27  rs2_create_recording_context(RS2_API_VERSION, filename.c_str(), section.c_str(), mode, &e),
29  error::handle(e);
30  }
31 
32  recording_context() = delete;
33  };
34 
35  class mock_context : public context
36  {
37  public:
43  mock_context(const std::string& filename,
44  const std::string& section = "")
45  {
46  rs2_error* e = nullptr;
47  _context = std::shared_ptr<rs2_context>(
48  rs2_create_mock_context(RS2_API_VERSION, filename.c_str(), section.c_str(), &e),
50  error::handle(e);
51  }
52 
53  mock_context() = delete;
54  };
55 
56  namespace internal
57  {
61  inline double get_time()
62  {
63  rs2_error* e = nullptr;
64  auto time = rs2_get_time( &e);
65 
66  error::handle(e);
67 
68  return time;
69  }
70  }
71 
72  class software_sensor : public sensor
73  {
74  public:
81  {
82  rs2_error* e = nullptr;
83 
84  stream_profile stream(rs2_software_sensor_add_video_stream(_sensor.get(),video_stream, &e));
85  error::handle(e);
86 
87  return stream;
88  }
89 
96  {
97  rs2_error* e = nullptr;
99  error::handle(e);
100  }
101 
108  void add_read_only_option(rs2_option option, float val)
109  {
110  rs2_error* e = nullptr;
111  rs2_software_sensor_add_read_only_option(_sensor.get(), option, val, &e);
112  error::handle(e);
113  }
114 
121  void set_read_only_option(rs2_option option, float val)
122  {
123  rs2_error* e = nullptr;
125  error::handle(e);
126  }
127  private:
128  friend class software_device;
129 
130  software_sensor(std::shared_ptr<rs2_sensor> s)
131  : rs2::sensor(s)
132  {
133  rs2_error* e = nullptr;
135  {
136  _sensor = nullptr;
137  }
139  }
140  };
141 
142 
143  class software_device : public device
144  {
145  std::shared_ptr<rs2_device> create_device_ptr()
146  {
147  rs2_error* e = nullptr;
148  std::shared_ptr<rs2_device> dev(
151  error::handle(e);
152  return dev;
153  }
154 
155  public:
157  : device(create_device_ptr())
158  {}
159 
165  software_sensor add_sensor(std::string name)
166  {
167  rs2_error* e = nullptr;
168  std::shared_ptr<rs2_sensor> sensor(
169  rs2_software_device_add_sensor(_dev.get(), name.c_str(), &e),
171  error::handle(e);
172 
173  return software_sensor(sensor);
174  }
175 
181  {
182  rs2_error* e = nullptr;
183  rs2_software_device_create_matcher(_dev.get(), matcher, &e);
184  error::handle(e);
185  }
186  };
187 
188 }
189 #endif // LIBREALSENSE_RS2_INTERNAL_HPP
Definition: rs_frame.hpp:21
recording_context(const std::string &filename, const std::string &section="", rs2_recording_mode mode=RS2_RECORDING_MODE_BLANK_FRAMES)
Definition: rs_internal.hpp:21
Definition: rs_sensor.hpp:232
Definition: rs_frame.hpp:202
#define RS2_API_VERSION
Definition: rs.h:37
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
rs2_recording_mode
Definition: rs_internal.h:25
void rs2_delete_device(rs2_device *device)
void rs2_delete_context(rs2_context *context)
Frees the relevant context object.
void on_video_frame(rs2_software_video_frame frame)
Definition: rs_internal.hpp:95
All the parameters are requaired to defind video stream.
Definition: rs_internal.h:34
software_device()
Definition: rs_internal.hpp:156
Definition: rs_context.hpp:11
software_sensor add_sensor(std::string name)
Definition: rs_internal.hpp:165
Definition: rs_context.hpp:78
void set_read_only_option(rs2_option option, float val)
Definition: rs_internal.hpp:121
Definition: rs_internal.hpp:35
rs2_context * rs2_create_recording_context(int api_version, const char *filename, const char *section, rs2_recording_mode mode, rs2_error **error)
stream_profile add_video_stream(rs2_video_stream video_stream)
Definition: rs_internal.hpp:80
Definition: rs_types.h:120
rs2_time_t rs2_get_time(rs2_error **error)
std::shared_ptr< rs2_sensor > _sensor
Definition: rs_sensor.hpp:421
Definition: rs_internal.hpp:14
std::shared_ptr< rs2_context > _context
Definition: rs_context.hpp:176
Definition: rs_internal.hpp:72
void rs2_delete_sensor(rs2_sensor *sensor)
rs2_matchers
Specifies types of different matchers.
Definition: rs_types.h:127
std::shared_ptr< rs2_device > _dev
Definition: rs_device.hpp:143
rs2_device * rs2_create_software_device(rs2_error **error)
void rs2_software_sensor_add_read_only_option(rs2_sensor *sensor, rs2_option option, float val, rs2_error **error)
mock_context()=delete
void create_matcher(rs2_matchers matcher)
Definition: rs_internal.hpp:180
mock_context(const std::string &filename, const std::string &section="")
Definition: rs_internal.hpp:43
Definition: rs_internal.hpp:143
static void handle(rs2_error *e)
Definition: rs_types.hpp:121
rs2_context * rs2_create_mock_context(int api_version, const char *filename, const char *section, rs2_error **error)
rs2_sensor * rs2_software_device_add_sensor(rs2_device *dev, const char *sensor_name, rs2_error **error)
void rs2_software_sensor_update_read_only_option(rs2_sensor *sensor, rs2_option option, float val, rs2_error **error)
Definition: rs_internal.h:27
rs2_stream_profile * rs2_software_sensor_add_video_stream(rs2_sensor *sensor, rs2_video_stream video_stream, rs2_error **error)
void rs2_software_device_create_matcher(rs2_device *dev, rs2_matchers matcher, rs2_error **error)
int rs2_is_sensor_extendable_to(const rs2_sensor *sensor, rs2_extension extension, rs2_error **error)
void add_read_only_option(rs2_option option, float val)
Definition: rs_internal.hpp:108
void rs2_software_sensor_on_video_frame(rs2_sensor *sensor, rs2_software_video_frame frame, rs2_error **error)
All the parameters are requaired to define video frame.
Definition: rs_internal.h:48
struct rs2_error rs2_error
Definition: rs_types.h:149
Definition: rs_device.hpp:18
double get_time()
Definition: rs_internal.hpp:61