Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
backend.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 #ifndef LIBREALSENSE_BACKEND_H
6 #define LIBREALSENSE_BACKEND_H
7 
8 #include "../include/librealsense2/h/rs_types.h" // Inherit all type definitions in the public API
9 #include "../include/librealsense2/h/rs_option.h"
10 
11 #include <memory> // For shared_ptr
12 #include <functional> // For function
13 #include <thread> // For this_thread::sleep_for
14 #include <vector>
15 #include <algorithm>
16 #include <set>
17 #include <iterator>
18 #include <tuple>
19 #include <map>
20 #include <cstring>
21 #include <string>
22 #include <sstream>
23 
24 
25 const uint16_t MAX_RETRIES = 100;
26 const uint16_t VID_INTEL_CAMERA = 0x8086;
27 const uint8_t DEFAULT_V4L2_FRAME_BUFFERS = 4;
28 const uint16_t DELAY_FOR_RETRIES = 50;
29 
30 const uint8_t MAX_META_DATA_SIZE = 0xff; // UVC Metadata total length
31  // is limited by (UVC Bulk) design to 255 bytes
32 
33 namespace librealsense
34 {
35  struct notification;
36 
37  template<class T>
38  bool list_changed(const std::vector<T>& list1,
39  const std::vector<T>& list2,
40  std::function<bool(T, T)> equal = [](T first, T second) { return first == second; })
41  {
42  if (list1.size() != list2.size())
43  return true;
44 
45  for (auto dev1 : list1)
46  {
47  bool found = false;
48  for (auto dev2 : list2)
49  {
50  if (equal(dev1,dev2))
51  {
52  found = true;
53  }
54  }
55 
56  if (!found)
57  {
58  return true;
59  }
60  }
61  return false;
62  }
63 
64 
65  namespace platform
66  {
68  {
70  {}
71 
72  control_range(int32_t in_min, int32_t in_max, int32_t in_step, int32_t in_def)
73  {
74  populate_raw_data(min, in_min);
75  populate_raw_data(max, in_max);
76  populate_raw_data(step, in_step);
77  populate_raw_data(def, in_def);
78  }
79  control_range(std::vector<uint8_t> in_min, std::vector<uint8_t> in_max, std::vector<uint8_t> in_step, std::vector<uint8_t> in_def)
80  {
81  min = in_min; max = in_max; step = in_step; def = in_def;
82  }
83  std::vector<uint8_t> min;
84  std::vector<uint8_t> max;
85  std::vector<uint8_t> step;
86  std::vector<uint8_t> def;
87 
88  private:
89  void populate_raw_data(std::vector<uint8_t>& vec, int32_t value);
90  };
91 
93  {
94  public:
95  virtual double get_time() const = 0;
96  ~time_service() = default;
97  };
98 
100  {
101  public:
102  rs2_time_t get_time() const override
103  {
104  return std::chrono::duration<double, std::milli>(std::chrono::system_clock::now().time_since_epoch()).count();
105  }
106  };
107 
108  struct guid { uint32_t data1; uint16_t data2, data3; uint8_t data4[8]; };
109  // subdevice and node fields are assigned by Host driver; unit and GUID are hard-coded in camera firmware
110  struct extension_unit { int subdevice, unit, node; guid id; };
111 
113  {
114  public:
115  virtual std::vector<uint8_t> send_receive(
116  const std::vector<uint8_t>& data,
117  int timeout_ms = 5000,
118  bool require_response = true) = 0;
119 
120  virtual ~command_transfer() = default;
121  };
122 
124  {
125  D0,
127  };
128 
129  typedef std::tuple< uint32_t, uint32_t, uint32_t, uint32_t> stream_profile_tuple;
130 
132  {
133  uint32_t width;
134  uint32_t height;
135  uint32_t fps;
136  uint32_t format;
137 
138  operator stream_profile_tuple() const
139  {
140  return std::make_tuple(width, height, fps, format);
141  }
142 
143  };
144 
145  inline bool operator==(const stream_profile& a,
146  const stream_profile& b)
147  {
148  return (a.width == b.width) &&
149  (a.height == b.height) &&
150  (a.fps == b.fps) &&
151  (a.format == b.format);
152  }
153 
154 #pragma pack(push, 1)
155  struct uvc_header
156  {
157  uint8_t length; // UVC Metadata total length is
158  // limited by design to 255 bytes
159  uint8_t info;
160  uint32_t timestamp;
161  uint8_t source_clock[6];
162  };
163 #pragma pack(pop)
164 
165  constexpr uint8_t uvc_header_size = sizeof(uvc_header);
166 
168  {
169  size_t frame_size;
170  uint8_t metadata_size;
171  const void * pixels;
172  const void * metadata;
174 
175  };
176 
177  typedef std::function<void(stream_profile, frame_object, std::function<void()>)> frame_callback;
178 
179  // Binary-coded decimal represent the USB specification to which the UVC device complies
180  enum usb_spec : uint16_t {
182  usb1_type = 0x0100,
183  usb1_1_type = 0x0110,
184  usb2_type = 0x0200,
185  usb2_1_type = 0x0210,
186  usb3_type = 0x0300,
187  usb3_1_type = 0x0310,
188  usb3_2_type = 0x0320,
189  };
190 
191  static const std::map<usb_spec, std::string> usb_spec_names = {
192  { usb_undefined,"Undefined" },
193  { usb1_type, "1.0" },
194  { usb1_1_type, "1.1" },
195  { usb2_type, "2.0" },
196  { usb2_1_type, "2.1" },
197  { usb3_type, "3.0" },
198  { usb3_1_type, "3.1" },
199  { usb3_2_type, "3.2" }
200  };
201 
203  {
204  std::string id = ""; // to distinguish between different pins of the same device
205  uint16_t vid = 0;
206  uint16_t pid = 0;
207  uint16_t mi = 0;
208  std::string unique_id = "";
209  std::string device_path = "";
210  usb_spec conn_spec = usb_undefined;
211 
212  operator std::string()
213  {
214  std::stringstream s;
215  s << "id- " << id <<
216  "\nvid- " << std::hex << vid <<
217  "\npid- " << std::hex << pid <<
218  "\nmi- " << mi <<
219  "\nunique_id- " << unique_id <<
220  "\npath- " << device_path <<
221  "\nsusb specification- " << std::hex << (uint16_t)conn_spec << std::dec;
222 
223  return s.str();
224  }
225 
226  bool operator <(const uvc_device_info& obj) const
227  {
228  return (std::make_tuple(id, vid, pid, mi, unique_id, device_path) < std::make_tuple(obj.id, obj.vid, obj.pid, obj.mi, obj.unique_id, obj.device_path));
229  }
230  };
231 
232  inline bool operator==(const uvc_device_info& a,
233  const uvc_device_info& b)
234  {
235  return (a.vid == b.vid) &&
236  (a.pid == b.pid) &&
237  (a.mi == b.mi) &&
238  (a.unique_id == b.unique_id) &&
239  (a.id == b.id) &&
240  (a.device_path == b.device_path) &&
241  (a.conn_spec == b.conn_spec);
242  }
243 
245  {
246  std::string id;
247 
248  uint16_t vid;
249  uint16_t pid;
250  uint16_t mi;
251  std::string unique_id;
253 
254  operator std::string()
255  {
256  std::stringstream s;
257 
258  s << "vid- " << std::hex << vid <<
259  "\npid- " << std::hex << pid <<
260  "\nmi- " << mi <<
261  "\nsusb specification- " << std::hex << (uint16_t)conn_spec << std::dec <<
262  "\nunique_id- " << unique_id;
263 
264  return s.str();
265  }
266  };
267 
268  inline bool operator==(const usb_device_info& a,
269  const usb_device_info& b)
270  {
271  return (a.id == b.id) &&
272  (a.vid == b.vid) &&
273  (a.pid == b.pid) &&
274  (a.mi == b.mi) &&
275  (a.unique_id == b.unique_id) &&
276  (a.conn_spec == b.conn_spec);
277  }
278 
280  {
281  std::string id;
282  std::string vid;
283  std::string pid;
284  std::string unique_id;
285  std::string device_path;
286 
287  operator std::string()
288  {
289  std::stringstream s;
290  s << "id- " << id <<
291  "\nvid- " << std::hex << vid <<
292  "\npid- " << std::hex << pid <<
293  "\nunique_id- " << unique_id <<
294  "\npath- " << device_path;
295 
296  return s.str();
297  }
298  };
299 
300  inline bool operator==(const hid_device_info& a,
301  const hid_device_info& b)
302  {
303  return (a.id == b.id) &&
304  (a.vid == b.vid) &&
305  (a.pid == b.pid) &&
306  (a.unique_id == b.unique_id) &&
307  (a.device_path == b.device_path);
308  }
309 
311  {
312  std::string file_path;
313 
314  operator std::string()
315  {
316  return file_path;
317  }
318  };
319 
320  inline bool operator==(const playback_device_info& a,
321  const playback_device_info& b)
322  {
323  return (a.file_path == b.file_path);
324  }
325 
327  {
328  void* device_ptr;
329 
330  operator std::string()
331  {
332  std::ostringstream oss;
333  oss << device_ptr;
334  return oss.str();
335  }
336  };
337 
338  inline bool operator==(const tm2_device_info& a,
339  const tm2_device_info& b)
340  {
341  return (a.device_ptr == b.device_ptr);
342  }
343 
344  struct hid_sensor
345  {
346  std::string name;
347  };
348 
350  {
351  uint32_t index;
352  std::string name;
353  };
354 
358  uint32_t value;
359  };
360 
361  struct sensor_data
362  {
365  };
366 
367  struct hid_profile
368  {
369  std::string sensor_name;
370  uint32_t frequency;
371  };
372 
381  };
382 
384  {
385  short x;
386  char reserved1[2];
387  short y;
388  char reserved2[2];
389  short z;
390  char reserved3[2];
391  uint32_t ts_low;
392  uint32_t ts_high;
393  };
394 
395  typedef std::function<void(const sensor_data&)> hid_callback;
396 
398  {
399  public:
400  virtual ~hid_device() = default;
401  virtual void open(const std::vector<hid_profile>& hid_profiles) = 0;
402  virtual void close() = 0;
403  virtual void stop_capture() = 0;
404  virtual void start_capture(hid_callback callback) = 0;
405  virtual std::vector<hid_sensor> get_sensors() = 0;
406  virtual std::vector<uint8_t> get_custom_report_data(const std::string& custom_sensor_name,
407  const std::string& report_name,
408  custom_sensor_report_field report_field) = 0;
409  };
410 
411  struct request_mapping;
412 
414  {
415  public:
416  virtual void probe_and_commit(stream_profile profile, frame_callback callback, int buffers = DEFAULT_V4L2_FRAME_BUFFERS) = 0;
417  virtual void stream_on(std::function<void(const notification& n)> error_handler = [](const notification& n){}) = 0;
418  virtual void start_callbacks() = 0;
419  virtual void stop_callbacks() = 0;
420  virtual void close(stream_profile profile) = 0;
421 
422  virtual void set_power_state(power_state state) = 0;
423  virtual power_state get_power_state() const = 0;
424 
425  virtual void init_xu(const extension_unit& xu) = 0;
426  virtual bool set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len) = 0;
427  virtual bool get_xu(const extension_unit& xu, uint8_t ctrl, uint8_t* data, int len) const = 0;
428  virtual control_range get_xu_range(const extension_unit& xu, uint8_t ctrl, int len) const = 0;
429 
430  virtual bool get_pu(rs2_option opt, int32_t& value) const = 0;
431  virtual bool set_pu(rs2_option opt, int32_t value) = 0;
432  virtual control_range get_pu_range(rs2_option opt) const = 0;
433 
434  virtual std::vector<stream_profile> get_profiles() const = 0;
435 
436  virtual void lock() const = 0;
437  virtual void unlock() const = 0;
438 
439  virtual std::string get_device_location() const = 0;
440  virtual usb_spec get_usb_specification() const = 0;
441 
442  virtual ~uvc_device() = default;
443 
444  protected:
445  std::function<void(const notification& n)> _error_handler;
446  };
447 
449  {
450  public:
451  explicit retry_controls_work_around(std::shared_ptr<uvc_device> dev)
452  : _dev(dev) {}
453 
454  void probe_and_commit(stream_profile profile, frame_callback callback, int buffers) override
455  {
456  _dev->probe_and_commit(profile, callback, buffers);
457  }
458 
459  void stream_on(std::function<void(const notification& n)> error_handler = [](const notification& n){}) override
460  {
461  _dev->stream_on(error_handler);
462  }
463 
464  void start_callbacks() override
465  {
466  _dev->start_callbacks();
467  }
468 
469  void stop_callbacks() override
470  {
471  _dev->stop_callbacks();
472  }
473 
474  void close(stream_profile profile) override
475  {
476  _dev->close(profile);
477  }
478 
479  void set_power_state(power_state state) override
480  {
481  _dev->set_power_state(state);
482  }
483 
484  power_state get_power_state() const override
485  {
486  return _dev->get_power_state();
487  }
488 
489  void init_xu(const extension_unit& xu) override
490  {
491  _dev->init_xu(xu);
492  }
493 
494  bool set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len) override
495  {
496  for (auto i = 0; i < MAX_RETRIES; ++i)
497  {
498  if (_dev->set_xu(xu, ctrl, data, len))
499  return true;
500 
501  std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_FOR_RETRIES));
502  }
503  return false;
504  }
505 
506  bool get_xu(const extension_unit& xu, uint8_t ctrl, uint8_t* data, int len) const override
507  {
508  for (auto i = 0; i < MAX_RETRIES; ++i)
509  {
510  if (_dev->get_xu(xu, ctrl, data, len))
511  return true;
512 
513  std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_FOR_RETRIES));
514  }
515  return false;
516  }
517 
518  control_range get_xu_range(const extension_unit& xu, uint8_t ctrl, int len) const override
519  {
520  return _dev->get_xu_range(xu, ctrl, len);
521  }
522 
523  bool get_pu(rs2_option opt, int32_t& value) const override
524  {
525  for (auto i = 0; i < MAX_RETRIES; ++i)
526  {
527  if (_dev->get_pu(opt, value))
528  return true;
529 
530  std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_FOR_RETRIES));
531  }
532  return false;
533  }
534 
535  bool set_pu(rs2_option opt, int32_t value) override
536  {
537  for (auto i = 0; i < MAX_RETRIES; ++i)
538  {
539  if (_dev->set_pu(opt, value))
540  return true;
541 
542  std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_FOR_RETRIES));
543  }
544  return false;
545  }
546 
548  {
549  return _dev->get_pu_range(opt);
550  }
551 
552  std::vector<stream_profile> get_profiles() const override
553  {
554  return _dev->get_profiles();
555  }
556 
557  std::string get_device_location() const override
558  {
559  return _dev->get_device_location();
560  }
561 
563  {
564  return _dev->get_usb_specification();
565  }
566 
567  void lock() const override { _dev->lock(); }
568  void unlock() const override { _dev->unlock(); }
569 
570  private:
571  std::shared_ptr<uvc_device> _dev;
572  };
573 
575  {
576  public:
577  // interupt endpoint and any additional USB specific stuff
578  };
579 
580 
581 
582  class device_watcher;
583 
585  {
587 
588  backend_device_group(const std::vector<uvc_device_info>& uvc_devices, const std::vector<usb_device_info>& usb_devices, const std::vector<hid_device_info>& hid_devices)
589  :uvc_devices(uvc_devices), usb_devices(usb_devices), hid_devices(hid_devices) {}
590 
591  backend_device_group(const std::vector<usb_device_info>& usb_devices)
592  :usb_devices(usb_devices) {}
593 
594  backend_device_group(const std::vector<uvc_device_info>& uvc_devices, const std::vector<usb_device_info>& usb_devices)
595  :uvc_devices(uvc_devices), usb_devices(usb_devices) {}
596 
597  backend_device_group(const std::vector<playback_device_info>& playback_devices) : playback_devices(playback_devices) {}
598 
599  std::vector<uvc_device_info> uvc_devices;
600  std::vector<usb_device_info> usb_devices;
601  std::vector<hid_device_info> hid_devices;
602  std::vector<playback_device_info> playback_devices;
603  std::vector<tm2_device_info> tm2_devices;
604 
606  {
607  return !list_changed(uvc_devices, other.uvc_devices) &&
608  !list_changed(hid_devices, other.hid_devices) &&
609  !list_changed(playback_devices, other.playback_devices) &&
610  !list_changed(tm2_devices, other.tm2_devices);
611  }
612 
613  operator std::string()
614  {
615  std::string s;
616  s = uvc_devices.size()>0 ? "uvc devices:\n" : "";
617  for (auto uvc : uvc_devices)
618  {
619  s += uvc;
620  s += "\n\n";
621  }
622 
623  s += usb_devices.size()>0 ? "usb devices:\n" : "";
624  for (auto usb : usb_devices)
625  {
626  s += usb;
627  s += "\n\n";
628  }
629 
630  s += hid_devices.size()>0 ? "hid devices: \n" : "";
631  for (auto hid : hid_devices)
632  {
633  s += hid;
634  s += "\n\n";
635  }
636 
637  s += playback_devices.size()>0 ? "playback devices: \n" : "";
638  for (auto playback_device : playback_devices)
639  {
640  s += playback_device;
641  s += "\n\n";
642  }
643 
644  return s;
645  }
646  };
647 
648 
649 
650  typedef std::function<void(backend_device_group old, backend_device_group curr)> device_changed_callback;
651 
652  class backend
653  {
654  public:
655  virtual std::shared_ptr<uvc_device> create_uvc_device(uvc_device_info info) const = 0;
656  virtual std::vector<uvc_device_info> query_uvc_devices() const = 0;
657 
658  virtual std::shared_ptr<usb_device> create_usb_device(usb_device_info info) const = 0;
659  virtual std::vector<usb_device_info> query_usb_devices() const = 0;
660 
661  virtual std::shared_ptr<hid_device> create_hid_device(hid_device_info info) const = 0;
662  virtual std::vector<hid_device_info> query_hid_devices() const = 0;
663 
664  virtual std::shared_ptr<time_service> create_time_service() const = 0;
665 
666  virtual std::shared_ptr<device_watcher> create_device_watcher() const = 0;
667 
668  virtual ~backend() = default;
669  };
670 
672  {
673  public:
674  void open(const std::vector<hid_profile>& sensor_iio) override
675  {
676  for (auto&& dev : _dev) dev->open(sensor_iio);
677  }
678 
679  void close() override
680  {
681  for (auto&& dev : _dev) dev->close();
682  }
683 
684  void stop_capture() override
685  {
686  _dev.front()->stop_capture();
687  }
688 
689  void start_capture(hid_callback callback) override
690  {
691  _dev.front()->start_capture(callback);
692  }
693 
694  std::vector<hid_sensor> get_sensors() override
695  {
696  return _dev.front()->get_sensors();
697  }
698 
699  explicit multi_pins_hid_device(const std::vector<std::shared_ptr<hid_device>>& dev)
700  : _dev(dev)
701  {
702  }
703 
704  std::vector<uint8_t> get_custom_report_data(const std::string& custom_sensor_name,
705  const std::string& report_name,
706  custom_sensor_report_field report_field) override
707  {
708  return _dev.front()->get_custom_report_data(custom_sensor_name, report_name, report_field);
709  }
710 
711  private:
712  std::vector<std::shared_ptr<hid_device>> _dev;
713  };
714 
716  {
717  public:
718  explicit multi_pins_uvc_device(const std::vector<std::shared_ptr<uvc_device>>& dev)
719  : _dev(dev)
720  {}
721 
722  void probe_and_commit(stream_profile profile, frame_callback callback, int buffers) override
723  {
724  auto dev_index = get_dev_index_by_profiles(profile);
725  _configured_indexes.insert(dev_index);
726  _dev[dev_index]->probe_and_commit(profile, callback, buffers);
727  }
728 
729 
730  void stream_on(std::function<void(const notification& n)> error_handler = [](const notification& n){}) override
731  {
732  for (auto& elem : _configured_indexes)
733  {
734  _dev[elem]->stream_on(error_handler);
735  }
736  }
737  void start_callbacks() override
738  {
739  for (auto& elem : _configured_indexes)
740  {
741  _dev[elem]->start_callbacks();
742  }
743  }
744 
745  void stop_callbacks() override
746  {
747  for (auto& elem : _configured_indexes)
748  {
749  _dev[elem]->stop_callbacks();
750  }
751  }
752 
753  void close(stream_profile profile) override
754  {
755  auto dev_index = get_dev_index_by_profiles(profile);
756  _dev[dev_index]->close(profile);
757  _configured_indexes.erase(dev_index);
758  }
759 
760  void set_power_state(power_state state) override
761  {
762  for (auto& elem : _dev)
763  {
764  elem->set_power_state(state);
765  }
766  }
767 
768  power_state get_power_state() const override
769  {
770  return _dev.front()->get_power_state();
771  }
772 
773  void init_xu(const extension_unit& xu) override
774  {
775  _dev.front()->init_xu(xu);
776  }
777 
778  bool set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len) override
779  {
780  return _dev.front()->set_xu(xu, ctrl, data, len);
781  }
782 
783  bool get_xu(const extension_unit& xu, uint8_t ctrl, uint8_t* data, int len) const override
784  {
785  return _dev.front()->get_xu(xu, ctrl, data, len);
786  }
787 
788  control_range get_xu_range(const extension_unit& xu, uint8_t ctrl, int len) const override
789  {
790  return _dev.front()->get_xu_range(xu, ctrl, len);
791  }
792 
793  bool get_pu(rs2_option opt, int32_t& value) const override
794  {
795  return _dev.front()->get_pu(opt, value);
796  }
797 
798  bool set_pu(rs2_option opt, int32_t value) override
799  {
800  return _dev.front()->set_pu(opt, value);
801  }
802 
804  {
805  return _dev.front()->get_pu_range(opt);
806  }
807 
808  std::vector<stream_profile> get_profiles() const override
809  {
810  std::vector<stream_profile> all_stream_profiles;
811  for (auto& elem : _dev)
812  {
813  auto pin_stream_profiles = elem->get_profiles();
814  all_stream_profiles.insert(all_stream_profiles.end(),
815  pin_stream_profiles.begin(), pin_stream_profiles.end());
816  }
817  return all_stream_profiles;
818  }
819 
820  std::string get_device_location() const override
821  {
822  return _dev.front()->get_device_location();
823  }
824 
826  {
827  return _dev.front()->get_usb_specification();
828  }
829 
830  void lock() const override
831  {
832  std::vector<uvc_device*> locked_dev;
833  try {
834  for (auto& elem : _dev)
835  {
836  elem->lock();
837  locked_dev.push_back(elem.get());
838  }
839  }
840  catch(...)
841  {
842  for (auto& elem : locked_dev)
843  {
844  elem->unlock();
845  }
846  throw;
847  }
848  }
849 
850  void unlock() const override
851  {
852  for (auto& elem : _dev)
853  {
854  elem->unlock();
855  }
856  }
857 
858  private:
859  uint32_t get_dev_index_by_profiles(const stream_profile& profile) const
860  {
861  uint32_t dev_index = 0;
862  for (auto& elem : _dev)
863  {
864  auto pin_stream_profiles = elem->get_profiles();
865  auto it = find(pin_stream_profiles.begin(), pin_stream_profiles.end(), profile);
866  if (it != pin_stream_profiles.end())
867  {
868  return dev_index;
869  }
870  ++dev_index;
871  }
872  throw std::runtime_error("profile not found");
873  }
874 
875  std::vector<std::shared_ptr<uvc_device>> _dev;
876  std::set<uint32_t> _configured_indexes;
877  };
878 
879  std::shared_ptr<backend> create_backend();
880 
881 
882 
884  {
885  public:
886  virtual void start(device_changed_callback callback) = 0;
887  virtual void stop() = 0;
888  virtual ~device_watcher() {};
889  };
890  }
891 
892  double monotonic_to_realtime(double monotonic);
893 }
894 
895 #endif
bool operator<(const request_mapping &first, const request_mapping &second)
Definition: types.h:624
uint32_t fps
Definition: backend.h:135
uint32_t ts_high
Definition: backend.h:392
Definition: backend.h:374
Definition: backend.h:184
usb_spec conn_spec
Definition: backend.h:252
bool set_xu(const extension_unit &xu, uint8_t ctrl, const uint8_t *data, int len) override
Definition: backend.h:778
std::string get_device_location() const override
Definition: backend.h:820
Definition: backend.h:376
std::vector< uint8_t > max
Definition: backend.h:84
std::string sensor_name
Definition: backend.h:369
uint32_t timestamp
Definition: backend.h:160
usb_spec conn_spec
Definition: backend.h:210
Definition: backend.h:380
std::vector< hid_sensor > get_sensors() override
Definition: backend.h:694
Definition: backend.h:652
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
void close(stream_profile profile) override
Definition: backend.h:474
Definition: backend.h:397
std::vector< playback_device_info > playback_devices
Definition: backend.h:602
constexpr uint8_t uvc_header_size
Definition: backend.h:165
usb_spec get_usb_specification() const override
Definition: backend.h:825
Definition: backend.h:182
hid_sensor_input sensor_input
Definition: backend.h:357
Definition: backend.h:108
size_t frame_size
Definition: backend.h:169
void init_xu(const extension_unit &xu) override
Definition: backend.h:489
uint16_t vid
Definition: backend.h:205
uint32_t format
Definition: backend.h:136
std::string device_path
Definition: backend.h:285
const uint8_t MAX_META_DATA_SIZE
Definition: backend.h:30
short x
Definition: backend.h:385
std::string id
Definition: backend.h:246
backend_device_group(const std::vector< uvc_device_info > &uvc_devices, const std::vector< usb_device_info > &usb_devices)
Definition: backend.h:594
const void * metadata
Definition: backend.h:172
backend_device_group(const std::vector< playback_device_info > &playback_devices)
Definition: backend.h:597
std::string vid
Definition: backend.h:282
Definition: backend.h:355
retry_controls_work_around(std::shared_ptr< uvc_device > dev)
Definition: backend.h:451
void close() override
Definition: backend.h:679
hid_sensor sensor
Definition: backend.h:363
virtual ~device_watcher()
Definition: backend.h:888
control_range get_xu_range(const extension_unit &xu, uint8_t ctrl, int len) const override
Definition: backend.h:788
void set_power_state(power_state state) override
Definition: backend.h:479
usb_spec
Definition: backend.h:180
std::vector< uint8_t > get_custom_report_data(const std::string &custom_sensor_name, const std::string &report_name, custom_sensor_report_field report_field) override
Definition: backend.h:704
bool get_xu(const extension_unit &xu, uint8_t ctrl, uint8_t *data, int len) const override
Definition: backend.h:506
std::vector< tm2_device_info > tm2_devices
Definition: backend.h:603
Definition: backend.h:185
bool list_changed(const std::vector< T > &list1, const std::vector< T > &list2, std::function< bool(T, T)> equal=[](T first, T second) { return first==second;})
Definition: backend.h:38
const uint16_t MAX_RETRIES
Definition: backend.h:25
void unlock() const override
Definition: backend.h:568
Definition: algo.h:16
std::string pid
Definition: backend.h:283
bool get_xu(const extension_unit &xu, uint8_t ctrl, uint8_t *data, int len) const override
Definition: backend.h:783
bool set_xu(const extension_unit &xu, uint8_t ctrl, const uint8_t *data, int len) override
Definition: backend.h:494
uint8_t length
Definition: backend.h:157
std::vector< hid_device_info > hid_devices
Definition: backend.h:601
multi_pins_uvc_device(const std::vector< std::shared_ptr< uvc_device >> &dev)
Definition: backend.h:718
void probe_and_commit(stream_profile profile, frame_callback callback, int buffers) override
Definition: backend.h:454
bool get_pu(rs2_option opt, int32_t &value) const override
Definition: backend.h:523
uint8_t info
Definition: backend.h:159
std::string id
Definition: backend.h:281
Definition: types.h:348
control_range(std::vector< uint8_t > in_min, std::vector< uint8_t > in_max, std::vector< uint8_t > in_step, std::vector< uint8_t > in_def)
Definition: backend.h:79
const uint16_t VID_INTEL_CAMERA
Definition: backend.h:26
const uint16_t DELAY_FOR_RETRIES
Definition: backend.h:28
std::function< void(backend_device_group old, backend_device_group curr)> device_changed_callback
Definition: backend.h:650
rs2_time_t backend_time
Definition: backend.h:173
Definition: backend.h:167
Definition: backend.h:92
void init_xu(const extension_unit &xu) override
Definition: backend.h:773
control_range get_xu_range(const extension_unit &xu, uint8_t ctrl, int len) const override
Definition: backend.h:518
power_state
Definition: backend.h:123
std::string unique_id
Definition: backend.h:251
void stream_on(std::function< void(const notification &n)> error_handler=[](const notification &n){}) override
Definition: backend.h:459
void probe_and_commit(stream_profile profile, frame_callback callback, int buffers) override
Definition: backend.h:722
void start_callbacks() override
Definition: backend.h:464
void lock() const override
Definition: backend.h:567
void unlock() const override
Definition: backend.h:850
std::string name
Definition: backend.h:346
void lock() const override
Definition: backend.h:830
void close(stream_profile profile) override
Definition: backend.h:753
std::string device_path
Definition: backend.h:209
std::tuple< uint32_t, uint32_t, uint32_t, uint32_t > stream_profile_tuple
Definition: backend.h:129
Definition: backend.h:375
std::string unique_id
Definition: backend.h:208
uint8_t metadata_size
Definition: backend.h:170
uint16_t pid
Definition: backend.h:249
void set_power_state(power_state state) override
Definition: backend.h:760
uint16_t mi
Definition: backend.h:207
std::string get_device_location() const override
Definition: backend.h:557
std::vector< stream_profile > get_profiles() const override
Definition: backend.h:552
uint16_t pid
Definition: backend.h:206
bool set_pu(rs2_option opt, int32_t value) override
Definition: backend.h:798
void stop_callbacks() override
Definition: backend.h:745
std::string unique_id
Definition: backend.h:284
int unit
Definition: backend.h:110
short z
Definition: backend.h:389
Definition: backend.h:126
void start_callbacks() override
Definition: backend.h:737
uint32_t frequency
Definition: backend.h:370
void start_capture(hid_callback callback) override
Definition: backend.h:689
std::function< void(const notification &n)> _error_handler
Definition: backend.h:445
bool get_pu(rs2_option opt, int32_t &value) const override
Definition: backend.h:793
custom_sensor_report_field
Definition: backend.h:373
control_range(int32_t in_min, int32_t in_max, int32_t in_step, int32_t in_def)
Definition: backend.h:72
std::function< void(stream_profile, frame_object, std::function< void()>)> frame_callback
Definition: backend.h:177
double monotonic_to_realtime(double monotonic)
Definition: backend.h:379
uint32_t width
Definition: backend.h:133
void stop_capture() override
Definition: backend.h:684
std::string file_path
Definition: backend.h:312
uint32_t ts_low
Definition: backend.h:391
uint32_t height
Definition: backend.h:134
Definition: backend.h:361
Definition: backend.h:574
void stream_on(std::function< void(const notification &n)> error_handler=[](const notification &n){}) override
Definition: backend.h:730
rs2_time_t get_time() const override
Definition: backend.h:102
uint32_t value
Definition: backend.h:358
Definition: backend.h:377
std::vector< usb_device_info > usb_devices
Definition: backend.h:600
Definition: backend.h:125
multi_pins_hid_device(const std::vector< std::shared_ptr< hid_device >> &dev)
Definition: backend.h:699
Definition: backend.h:155
control_range()
Definition: backend.h:69
std::shared_ptr< backend > create_backend()
frame_object fo
Definition: backend.h:364
std::vector< uint8_t > def
Definition: backend.h:86
Definition: backend.h:413
Definition: backend.h:188
backend_device_group()
Definition: backend.h:586
Definition: backend.h:367
Definition: types.h:920
std::vector< uint8_t > min
Definition: backend.h:83
hid_sensor sensor
Definition: backend.h:356
backend_device_group(const std::vector< usb_device_info > &usb_devices)
Definition: backend.h:591
short y
Definition: backend.h:387
Definition: backend.h:187
control_range get_pu_range(rs2_option opt) const override
Definition: backend.h:803
power_state get_power_state() const override
Definition: backend.h:484
Definition: backend.h:378
std::function< void(const sensor_data &)> hid_callback
Definition: backend.h:395
std::vector< uvc_device_info > uvc_devices
Definition: backend.h:599
power_state get_power_state() const override
Definition: backend.h:768
void stop_callbacks() override
Definition: backend.h:469
bool operator==(const stream_profile &a, const stream_profile &b)
Definition: backend.h:145
Definition: backend.h:183
const uint8_t DEFAULT_V4L2_FRAME_BUFFERS
Definition: backend.h:27
std::vector< uint8_t > step
Definition: backend.h:85
usb_spec get_usb_specification() const override
Definition: backend.h:562
backend_device_group(const std::vector< uvc_device_info > &uvc_devices, const std::vector< usb_device_info > &usb_devices, const std::vector< hid_device_info > &hid_devices)
Definition: backend.h:588
std::string name
Definition: backend.h:352
std::vector< stream_profile > get_profiles() const override
Definition: backend.h:808
double rs2_time_t
Definition: rs_types.h:180
Definition: backend.h:181
void open(const std::vector< hid_profile > &sensor_iio) override
Definition: backend.h:674
Definition: backend.h:344
bool set_pu(rs2_option opt, int32_t value) override
Definition: backend.h:535
control_range get_pu_range(rs2_option opt) const override
Definition: backend.h:547
Definition: types.h:606
Definition: backend.h:186
void * device_ptr
Definition: backend.h:328
double get_time()
Definition: rs_internal.hpp:61
std::string id
Definition: backend.h:204
const void * pixels
Definition: backend.h:171
uint16_t mi
Definition: backend.h:250
uint16_t vid
Definition: backend.h:248
uint32_t index
Definition: backend.h:351
Definition: playback_device.h:17