Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
device.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 
4 #pragma once
5 
6 #include <chrono>
7 #include <memory>
8 #include <vector>
9 
10 #include "backend.h"
11 #include "archive.h"
12 #include "hw-monitor.h"
13 #include "option.h"
14 #include "sensor.h"
15 #include "sync.h"
16 #include "core/streaming.h"
17 
18 #include "context.h"
19 
20 namespace librealsense
21 {
22  stream_interface* find_profile(rs2_stream stream, int index, std::vector<stream_interface*> profiles);
23 
25  {
26  public:
27  static std::shared_ptr<matcher> create(rs2_matchers matcher, std::vector<stream_interface*> profiles);
28 
29  private:
30  static std::shared_ptr<matcher> create_DLR_C_matcher(std::vector<stream_interface*> profiles);
31  static std::shared_ptr<matcher> create_DLR_matcher(std::vector<stream_interface*> profiles);
32  static std::shared_ptr<matcher> create_DI_C_matcher(std::vector<stream_interface*> profiles);
33  static std::shared_ptr<matcher> create_DI_matcher(std::vector<stream_interface*> profiles);
34 
35  static std::shared_ptr<matcher> create_identity_matcher(stream_interface* profiles);
36  static std::shared_ptr<matcher> create_frame_number_matcher(std::vector<stream_interface*> profiles);
37  static std::shared_ptr<matcher> create_timestamp_matcher(std::vector<stream_interface*> profiles);
38 
39  static std::shared_ptr<matcher> create_timestamp_composite_matcher(std::vector<std::shared_ptr<matcher>> matchers);
40  static std::shared_ptr<matcher> create_frame_number_composite_matcher(std::vector<std::shared_ptr<matcher>> matchers);
41  };
42 
43  class device : public virtual device_interface, public info_container
44  {
45  public:
46  virtual ~device();
47  size_t get_sensors_count() const override;
48 
49  sensor_interface& get_sensor(size_t subdevice) override;
50  const sensor_interface& get_sensor(size_t subdevice) const override;
51 
52  void hardware_reset() override;
53 
54  virtual std::shared_ptr<matcher> create_matcher(const frame_holder& frame) const override;
55 
56  size_t find_sensor_idx(const sensor_interface& s) const;
57 
58  std::shared_ptr<context> get_context() const override { return _context; }
59 
61  {
62  return _group;
63  }
64 
65  std::pair<uint32_t, rs2_extrinsics> get_extrinsics(const stream_interface& stream) const override;
66 
67  bool is_valid() const override
68  {
69  std::lock_guard<std::mutex> lock(_device_changed_mtx);
70  return _is_valid;
71  }
72 
73  protected:
74  int add_sensor(std::shared_ptr<sensor_interface> sensor_base);
75  int assign_sensor(std::shared_ptr<sensor_interface> sensor_base, uint8_t idx);
76  void register_stream_to_extrinsic_group(const stream_interface& stream, uint32_t groupd_index);
77  uvc_sensor& get_uvc_sensor(int subdevice);
78 
79  explicit device(std::shared_ptr<context> ctx,
81  bool device_changed_notifications = false);
82 
83  private:
84  std::map<int, std::pair<uint32_t, std::shared_ptr<const stream_interface>>> _extrinsics;
85  std::vector<std::shared_ptr<sensor_interface>> _sensors;
86  std::shared_ptr<context> _context;
87  const platform::backend_device_group _group;
88  bool _is_valid, _device_changed_notifications;
89  mutable std::mutex _device_changed_mtx;
90  uint64_t _callback_id;
91  };
92 }
Definition: sync.h:78
void hardware_reset() override
int add_sensor(std::shared_ptr< sensor_interface > sensor_base)
Definition: info.h:22
sensor_interface & get_sensor(size_t subdevice) override
size_t find_sensor_idx(const sensor_interface &s) const
stream_interface * find_profile(rs2_stream stream, int index, std::vector< stream_interface *> profiles)
device(std::shared_ptr< context > ctx, const platform::backend_device_group group, bool device_changed_notifications=false)
Definition: streaming.h:131
int assign_sensor(std::shared_ptr< sensor_interface > sensor_base, uint8_t idx)
static std::shared_ptr< matcher > create(rs2_matchers matcher, std::vector< stream_interface *> profiles)
Definition: archive.h:63
Definition: algo.h:16
Definition: streaming.h:31
virtual std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
bool is_valid() const override
Definition: device.h:67
rs2_matchers
Specifies types of different matchers.
Definition: rs_types.h:126
uvc_sensor & get_uvc_sensor(int subdevice)
size_t get_sensors_count() const override
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:36
std::pair< uint32_t, rs2_extrinsics > get_extrinsics(const stream_interface &stream) const override
std::shared_ptr< context > get_context() const override
Definition: device.h:58
Definition: stream.h:14
Definition: types.h:587
void register_stream_to_extrinsic_group(const stream_interface &stream, uint32_t groupd_index)
Definition: streaming.h:106
Definition: device.h:24
platform::backend_device_group get_device_data() const override
Definition: device.h:60
Definition: sensor.h:31
Definition: device.h:43
Definition: sensor.h:173