src/stream.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 #pragma once
4 
5 #include "core/streaming.h"
6 #include "core/video.h"
7 #include "core/motion.h"
8 #include "context.h"
9 #include "image.h"
10 #include "environment.h"
11 
12 namespace librealsense
13 {
14  class stream : public stream_interface
15  {
16  public:
17  stream(rs2_stream stream_type, int index = 0);
18 
19  int get_stream_index() const override;
20  void set_stream_index(int index) override;
21 
22  rs2_stream get_stream_type() const override;
23  void set_stream_type(rs2_stream stream) override;
24 
25  int get_unique_id() const override { return _uid; }
26  void set_unique_id(int uid) override { _uid = uid; };
27 
28  private:
29  int _index = 0;
30  int _uid = 0;
32  };
33 
35  {
36  public:
38 
40 
41  virtual ~backend_stream_profile() = default;
42  private:
44  };
45 
47  {
48  public:
50 
51  int get_stream_index() const override;
52  void set_stream_index(int index) override;
53 
54  rs2_stream get_stream_type() const override;
55  void set_stream_type(rs2_stream stream) override;
56 
57  rs2_format get_format() const override;
58  void set_format(rs2_format format) override;
59 
60  uint32_t get_framerate() const override;
61  void set_framerate(uint32_t val) override;
62 
63  int get_tag() const override;
64  void tag_profile(int tag) override;
65 
66  int get_unique_id() const override { return _uid; }
67  void set_unique_id(int uid) override
68  {
69  _uid = uid;
70  };
71 
72  std::shared_ptr<stream_profile_interface> clone() const override;
73 
74  rs2_stream_profile* get_c_wrapper() const override;
75 
76  void set_c_wrapper(rs2_stream_profile* wrapper) override;
77 
78  void create_snapshot(std::shared_ptr<stream_profile_interface>& snapshot) const override;
79  void enable_recording(std::function<void(const stream_profile_interface&)> record_action) override;
80  private:
81  int _index = 1;
82  int _uid = 0;
85  uint32_t _framerate = 0;
88  rs2_stream_profile* _c_ptr = nullptr;
89  };
90 
92  {
93  public:
96  _calc_intrinsics([]() -> rs2_intrinsics { throw not_implemented_exception("No intrinsics are available for this stream profile!"); }),
97  _width(0), _height(0)
98  {
99  }
100 
101  rs2_intrinsics get_intrinsics() const override { return _calc_intrinsics(); }
102  void set_intrinsics(std::function<rs2_intrinsics()> calc) override { _calc_intrinsics = calc; }
103 
104  uint32_t get_width() const override { return _width; }
105  uint32_t get_height() const override { return _height; }
107  {
108  _width = width;
109  _height = height;
110  }
111 
112  std::shared_ptr<stream_profile_interface> clone() const override
113  {
114  auto res = std::make_shared<video_stream_profile>(platform::stream_profile{});
116  res->set_unique_id( id );
117  LOG_DEBUG( "video_stream_profile::clone, id= " << id );
118  res->set_dims(get_width(), get_height());
119  std::function<rs2_intrinsics()> int_func = _calc_intrinsics;
120  res->set_intrinsics([int_func]() { return int_func(); });
121  res->set_framerate(get_framerate());
123  return res;
124  }
125 
126  bool operator==(const video_stream_profile& other) const
127  {
128  return get_height() == other.get_height() &&
129  get_width() == other.get_width() &&
130  get_framerate() == other.get_framerate() &&
131  get_stream_index() == other.get_stream_index() &&
132  get_stream_type() == other.get_stream_type() &&
133  get_unique_id() == other.get_unique_id() &&
134  get_format() == other.get_format();
135  }
136 
137  void update(std::shared_ptr<extension_snapshot> ext) override
138  {
139  return; //TODO: apply changes here
140  }
141  private:
142  std::function<rs2_intrinsics()> _calc_intrinsics;
143  uint32_t _width, _height;
144  };
145 
146 
148  {
149  public:
151  : stream_profile_base(std::move(sp)),
152  _calc_intrinsics([]() -> rs2_motion_device_intrinsic { throw not_implemented_exception("No intrinsics are available for this stream profile!"); })
153  {}
154 
155  rs2_motion_device_intrinsic get_intrinsics() const override { return _calc_intrinsics(); }
156  void set_intrinsics(std::function<rs2_motion_device_intrinsic()> calc) override { _calc_intrinsics = calc; }
157 
158  void update(std::shared_ptr<extension_snapshot> ext) override
159  {
160  return; //TODO: apply changes here
161  }
162 
163  std::shared_ptr<stream_profile_interface> clone() const override
164  {
165  auto res = std::make_shared<motion_stream_profile>(platform::stream_profile{});
166  res->set_unique_id(environment::get_instance().generate_stream_id());
167  std::function<rs2_motion_device_intrinsic()> init_func = _calc_intrinsics;
168  res->set_intrinsics([init_func]() { return init_func(); });
169  res->set_framerate(get_framerate());
171  return res;
172  }
173 
174  private:
175  std::function<rs2_motion_device_intrinsic()> _calc_intrinsics;
176  };
177 
179  {
180  public:
182  void update(std::shared_ptr<extension_snapshot> ext) override { /*Nothing to do here*/ }
183  };
184 
186  {
187  auto fps = static_cast<uint32_t>(sp->get_framerate());
188  if (auto vid = dynamic_cast<const video_stream_profile*>(sp))
189  {
190  return { sp->get_format(), sp->get_stream_type(), sp->get_stream_index(), vid->get_width(), vid->get_height(), fps };
191  }
192 
193  return { sp->get_format(), sp->get_stream_type(), sp->get_stream_index(), 0, 0, fps };
194  }
195 
196  inline std::vector<stream_profile> to_profiles(const std::vector<std::shared_ptr<stream_profile_interface>>& vec)
197  {
198  std::vector<stream_profile> res;
199  for (auto&& p : vec) res.push_back(to_profile(p.get()));
200  return res;
201  }
202 }
203 
204 namespace std
205 {
206  template<>
207  struct hash<std::shared_ptr<librealsense::video_stream_profile>>
208  {
209  size_t operator()(const std::shared_ptr<librealsense::video_stream_profile>& k) const
210  {
211  using std::hash;
212 
213  return (hash<uint32_t>()(k->get_height()))
214  ^ (hash<uint32_t>()(k->get_width()))
215  ^ (hash<uint32_t>()(k->get_framerate()))
216  ^ (hash<uint32_t>()(k->get_stream_index()))
217  ^ (hash<uint32_t>()(k->get_stream_type()))
218  ^ (hash<uint32_t>()(k->get_unique_id()))
219  ^ (hash<uint32_t>()(k->get_format()));
220  }
221  };
222 
223  inline bool operator==(const std::shared_ptr<librealsense::video_stream_profile>& a, const std::shared_ptr<librealsense::video_stream_profile>& b)
224  {
225  if (!a.get() || !b.get()) return a.get() == b.get();
226  return *a == *b;
227  }
228 }
virtual rs2_format get_format() const =0
virtual rs2_stream get_stream_type() const =0
int get_stream_index() const override
Definition: src/stream.cpp:14
GLboolean GLboolean GLboolean b
platform::stream_profile _sp
Definition: src/stream.h:43
boost_foreach_argument_dependent_lookup_hack tag
Definition: foreach_fwd.hpp:31
rs2_stream get_stream_type() const override
Definition: src/stream.cpp:52
void set_intrinsics(std::function< rs2_intrinsics()> calc) override
Definition: src/stream.h:102
GLfloat GLfloat p
Definition: glext.h:12687
uint32_t get_height() const override
Definition: src/stream.h:105
size_t operator()(const std::shared_ptr< librealsense::video_stream_profile > &k) const
Definition: src/stream.h:209
rs2_stream _type
Definition: src/stream.h:31
motion_stream_profile(platform::stream_profile sp)
Definition: src/stream.h:150
std::vector< stream_profile > to_profiles(const std::vector< std::shared_ptr< stream_profile_interface >> &vec)
Definition: src/stream.h:196
void register_same_extrinsics(const stream_interface &from, const stream_interface &to)
Definition: environment.cpp:23
uint32_t get_framerate() const override
Definition: src/stream.cpp:72
void set_unique_id(int uid) override
Definition: src/stream.h:26
void update(std::shared_ptr< extension_snapshot > ext) override
Definition: src/stream.h:158
GLuint index
GLboolean GLboolean GLboolean GLboolean a
void update(std::shared_ptr< extension_snapshot > ext) override
Definition: src/stream.h:137
GLuint GLfloat * val
bool operator==(const video_stream_profile &other) const
Definition: src/stream.h:126
rs2_motion_device_intrinsic get_intrinsics() const override
Definition: src/stream.h:155
int get_unique_id() const override
Definition: src/stream.h:25
void set_stream_index(int index) override
Definition: src/stream.cpp:19
unsigned int uint32_t
Definition: stdint.h:80
std::shared_ptr< stream_profile_interface > clone() const override
Definition: src/stream.h:163
void set_stream_type(rs2_stream stream) override
Definition: src/stream.cpp:29
rs2_stream get_stream_type() const override
Definition: src/stream.cpp:24
struct rs2_motion_device_intrinsic rs2_motion_device_intrinsic
Motion device intrinsics: scale, bias, and variances.
GLint GLsizei GLsizei height
GLint GLint GLsizei GLint GLenum format
void update(std::shared_ptr< extension_snapshot > ext) override
Definition: src/stream.h:182
std::function< rs2_motion_device_intrinsic()> _calc_intrinsics
Definition: src/stream.h:175
void set_dims(uint32_t width, uint32_t height) override
Definition: src/stream.h:106
rs2_format
A stream&#39;s format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:59
std::shared_ptr< stream_profile_interface > clone() const override
Definition: src/stream.h:112
rs2_intrinsics get_intrinsics() const override
Definition: src/stream.h:101
int get_stream_index() const override
Definition: src/stream.cpp:42
stream(rs2_stream stream_type, int index=0)
Definition: src/stream.cpp:8
int get_unique_id() const override
Definition: src/stream.h:66
pose_stream_profile(platform::stream_profile sp)
Definition: src/stream.h:181
uint32_t get_width() const override
Definition: src/stream.h:104
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
bool operator==(const hdr_params &first, const hdr_params &second)
Definition: hdr-config.h:23
static environment & get_instance()
extrinsics_graph & get_extrinsics_graph()
platform::stream_profile get_backend_profile() const
Definition: src/stream.h:39
video_stream_profile(platform::stream_profile sp)
Definition: src/stream.h:94
struct rs2_intrinsics rs2_intrinsics
Video stream intrinsics.
stream_profile to_profile(const stream_profile_interface *sp)
Definition: src/stream.h:185
std::function< rs2_intrinsics()> _calc_intrinsics
Definition: src/stream.h:142
void set_intrinsics(std::function< rs2_motion_device_intrinsic()> calc) override
Definition: src/stream.h:156
backend_stream_profile(platform::stream_profile sp)
Definition: src/stream.h:37
virtual int get_stream_index() const =0
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
Video stream intrinsics.
Definition: rs_types.h:58
void set_unique_id(int uid) override
Definition: src/stream.h:67
Motion device intrinsics: scale, bias, and variances.
Definition: rs_types.h:103
virtual uint32_t get_framerate() const =0
rs2_format get_format() const override
Definition: src/stream.cpp:62
GLuint res
Definition: glext.h:8856
rs2_stream_profile _c_wrapper
Definition: src/stream.h:87
#define LOG_DEBUG(...)
Definition: src/types.h:239
GLint GLsizei width


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11