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  };
189 
190  static const std::map<usb_spec, std::string> usb_spec_names = {
191  { usb_undefined,"Undefined" },
192  { usb1_type, "1.0" },
193  { usb1_1_type, "1.1" },
194  { usb2_type, "2.0" },
195  { usb2_1_type, "2.1" },
196  { usb3_type, "3.0" },
197  { usb3_1_type, "3.1" }
198  };
199 
201  {
202  std::string id = ""; // to distinguish between different pins of the same device
203  uint16_t vid = 0;
204  uint16_t pid = 0;
205  uint16_t mi = 0;
206  std::string unique_id = "";
207  std::string device_path = "";
208  usb_spec conn_spec = usb_undefined;
209 
210  operator std::string()
211  {
212  std::stringstream s;
213  s << "id- " << id <<
214  "\nvid- " << std::hex << vid <<
215  "\npid- " << std::hex << pid <<
216  "\nmi- " << mi <<
217  "\nunique_id- " << unique_id <<
218  "\npath- " << device_path <<
219  "\nsusb specification- " << std::hex << (uint16_t)conn_spec << std::dec;
220 
221  return s.str();
222  }
223 
224  bool operator <(const uvc_device_info& obj) const
225  {
226  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));
227  }
228  };
229 
230  inline bool operator==(const uvc_device_info& a,
231  const uvc_device_info& b)
232  {
233  return (a.vid == b.vid) &&
234  (a.pid == b.pid) &&
235  (a.mi == b.mi) &&
236  (a.unique_id == b.unique_id) &&
237  (a.id == b.id) &&
238  (a.device_path == b.device_path) &&
239  (a.conn_spec == b.conn_spec);
240  }
241 
243  {
244  std::string id;
245 
246  uint16_t vid;
247  uint16_t pid;
248  uint16_t mi;
249  std::string unique_id;
251 
252  operator std::string()
253  {
254  std::stringstream s;
255 
256  s << "vid- " << std::hex << vid <<
257  "\npid- " << std::hex << pid <<
258  "\nmi- " << mi <<
259  "\nsusb specification- " << std::hex << (uint16_t)conn_spec << std::dec <<
260  "\nunique_id- " << unique_id;
261 
262  return s.str();
263  }
264  };
265 
266  inline bool operator==(const usb_device_info& a,
267  const usb_device_info& b)
268  {
269  return (a.id == b.id) &&
270  (a.vid == b.vid) &&
271  (a.pid == b.pid) &&
272  (a.mi == b.mi) &&
273  (a.unique_id == b.unique_id) &&
274  (a.conn_spec == b.conn_spec);
275  }
276 
278  {
279  std::string id;
280  std::string vid;
281  std::string pid;
282  std::string unique_id;
283  std::string device_path;
284 
285  operator std::string()
286  {
287  std::stringstream s;
288  s << "id- " << id <<
289  "\nvid- " << std::hex << vid <<
290  "\npid- " << std::hex << pid <<
291  "\nunique_id- " << unique_id <<
292  "\npath- " << device_path;
293 
294  return s.str();
295  }
296  };
297 
298  inline bool operator==(const hid_device_info& a,
299  const hid_device_info& b)
300  {
301  return (a.id == b.id) &&
302  (a.vid == b.vid) &&
303  (a.pid == b.pid) &&
304  (a.unique_id == b.unique_id) &&
305  (a.device_path == b.device_path);
306  }
307 
309  {
310  std::string file_path;
311 
312  operator std::string()
313  {
314  return file_path;
315  }
316  };
317 
318  inline bool operator==(const playback_device_info& a,
319  const playback_device_info& b)
320  {
321  return (a.file_path == b.file_path);
322  }
323 
325  {
326  void* device_ptr;
327 
328  operator std::string()
329  {
330  std::ostringstream oss;
331  oss << device_ptr;
332  return oss.str();
333  }
334  };
335 
336  inline bool operator==(const tm2_device_info& a,
337  const tm2_device_info& b)
338  {
339  return (a.device_ptr == b.device_ptr);
340  }
341 
342  struct hid_sensor
343  {
344  std::string name;
345  };
346 
348  {
349  uint32_t index;
350  std::string name;
351  };
352 
356  uint32_t value;
357  };
358 
359  struct sensor_data
360  {
363  };
364 
365  struct hid_profile
366  {
367  std::string sensor_name;
368  uint32_t frequency;
369  };
370 
379  };
380 
382  {
383  short x;
384  char reserved1[2];
385  short y;
386  char reserved2[2];
387  short z;
388  char reserved3[2];
389  uint32_t ts_low;
390  uint32_t ts_high;
391  };
392 
393  typedef std::function<void(const sensor_data&)> hid_callback;
394 
396  {
397  public:
398  virtual ~hid_device() = default;
399  virtual void open(const std::vector<hid_profile>& hid_profiles) = 0;
400  virtual void close() = 0;
401  virtual void stop_capture() = 0;
402  virtual void start_capture(hid_callback callback) = 0;
403  virtual std::vector<hid_sensor> get_sensors() = 0;
404  virtual std::vector<uint8_t> get_custom_report_data(const std::string& custom_sensor_name,
405  const std::string& report_name,
406  custom_sensor_report_field report_field) = 0;
407  };
408 
409  struct request_mapping;
410 
412  {
413  public:
414  virtual void probe_and_commit(stream_profile profile, frame_callback callback, int buffers = DEFAULT_V4L2_FRAME_BUFFERS) = 0;
415  virtual void stream_on(std::function<void(const notification& n)> error_handler = [](const notification& n){}) = 0;
416  virtual void start_callbacks() = 0;
417  virtual void stop_callbacks() = 0;
418  virtual void close(stream_profile profile) = 0;
419 
420  virtual void set_power_state(power_state state) = 0;
421  virtual power_state get_power_state() const = 0;
422 
423  virtual void init_xu(const extension_unit& xu) = 0;
424  virtual bool set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len) = 0;
425  virtual bool get_xu(const extension_unit& xu, uint8_t ctrl, uint8_t* data, int len) const = 0;
426  virtual control_range get_xu_range(const extension_unit& xu, uint8_t ctrl, int len) const = 0;
427 
428  virtual bool get_pu(rs2_option opt, int32_t& value) const = 0;
429  virtual bool set_pu(rs2_option opt, int32_t value) = 0;
430  virtual control_range get_pu_range(rs2_option opt) const = 0;
431 
432  virtual std::vector<stream_profile> get_profiles() const = 0;
433 
434  virtual void lock() const = 0;
435  virtual void unlock() const = 0;
436 
437  virtual std::string get_device_location() const = 0;
438  virtual usb_spec get_usb_specification() const = 0;
439 
440  virtual ~uvc_device() = default;
441 
442  protected:
443  std::function<void(const notification& n)> _error_handler;
444  };
445 
447  {
448  public:
449  explicit retry_controls_work_around(std::shared_ptr<uvc_device> dev)
450  : _dev(dev) {}
451 
452  void probe_and_commit(stream_profile profile, frame_callback callback, int buffers) override
453  {
454  _dev->probe_and_commit(profile, callback, buffers);
455  }
456 
457  void stream_on(std::function<void(const notification& n)> error_handler = [](const notification& n){}) override
458  {
459  _dev->stream_on(error_handler);
460  }
461 
462  void start_callbacks() override
463  {
464  _dev->start_callbacks();
465  }
466 
467  void stop_callbacks() override
468  {
469  _dev->stop_callbacks();
470  }
471 
472  void close(stream_profile profile) override
473  {
474  _dev->close(profile);
475  }
476 
477  void set_power_state(power_state state) override
478  {
479  _dev->set_power_state(state);
480  }
481 
482  power_state get_power_state() const override
483  {
484  return _dev->get_power_state();
485  }
486 
487  void init_xu(const extension_unit& xu) override
488  {
489  _dev->init_xu(xu);
490  }
491 
492  bool set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len) override
493  {
494  for (auto i = 0; i < MAX_RETRIES; ++i)
495  {
496  if (_dev->set_xu(xu, ctrl, data, len))
497  return true;
498 
499  std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_FOR_RETRIES));
500  }
501  return false;
502  }
503 
504  bool get_xu(const extension_unit& xu, uint8_t ctrl, uint8_t* data, int len) const override
505  {
506  for (auto i = 0; i < MAX_RETRIES; ++i)
507  {
508  if (_dev->get_xu(xu, ctrl, data, len))
509  return true;
510 
511  std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_FOR_RETRIES));
512  }
513  return false;
514  }
515 
516  control_range get_xu_range(const extension_unit& xu, uint8_t ctrl, int len) const override
517  {
518  return _dev->get_xu_range(xu, ctrl, len);
519  }
520 
521  bool get_pu(rs2_option opt, int32_t& value) const override
522  {
523  for (auto i = 0; i < MAX_RETRIES; ++i)
524  {
525  if (_dev->get_pu(opt, value))
526  return true;
527 
528  std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_FOR_RETRIES));
529  }
530  return false;
531  }
532 
533  bool set_pu(rs2_option opt, int32_t value) override
534  {
535  for (auto i = 0; i < MAX_RETRIES; ++i)
536  {
537  if (_dev->set_pu(opt, value))
538  return true;
539 
540  std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_FOR_RETRIES));
541  }
542  return false;
543  }
544 
546  {
547  return _dev->get_pu_range(opt);
548  }
549 
550  std::vector<stream_profile> get_profiles() const override
551  {
552  return _dev->get_profiles();
553  }
554 
555  std::string get_device_location() const override
556  {
557  return _dev->get_device_location();
558  }
559 
561  {
562  return _dev->get_usb_specification();
563  }
564 
565  void lock() const override { _dev->lock(); }
566  void unlock() const override { _dev->unlock(); }
567 
568  private:
569  std::shared_ptr<uvc_device> _dev;
570  };
571 
573  {
574  public:
575  // interupt endpoint and any additional USB specific stuff
576  };
577 
578 
579 
580  class device_watcher;
581 
583  {
585 
586  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)
587  :uvc_devices(uvc_devices), usb_devices(usb_devices), hid_devices(hid_devices) {}
588 
589  backend_device_group(const std::vector<usb_device_info>& usb_devices)
590  :usb_devices(usb_devices) {}
591 
592  backend_device_group(const std::vector<uvc_device_info>& uvc_devices, const std::vector<usb_device_info>& usb_devices)
593  :uvc_devices(uvc_devices), usb_devices(usb_devices) {}
594 
595  backend_device_group(const std::vector<playback_device_info>& playback_devices) : playback_devices(playback_devices) {}
596 
597  std::vector<uvc_device_info> uvc_devices;
598  std::vector<usb_device_info> usb_devices;
599  std::vector<hid_device_info> hid_devices;
600  std::vector<playback_device_info> playback_devices;
601  std::vector<tm2_device_info> tm2_devices;
602 
604  {
605  return !list_changed(uvc_devices, other.uvc_devices) &&
606  !list_changed(hid_devices, other.hid_devices) &&
607  !list_changed(playback_devices, other.playback_devices) &&
608  !list_changed(tm2_devices, other.tm2_devices);
609  }
610 
611  operator std::string()
612  {
613  std::string s;
614  s = uvc_devices.size()>0 ? "uvc devices:\n" : "";
615  for (auto uvc : uvc_devices)
616  {
617  s += uvc;
618  s += "\n\n";
619  }
620 
621  s += usb_devices.size()>0 ? "usb devices:\n" : "";
622  for (auto usb : usb_devices)
623  {
624  s += usb;
625  s += "\n\n";
626  }
627 
628  s += hid_devices.size()>0 ? "hid devices: \n" : "";
629  for (auto hid : hid_devices)
630  {
631  s += hid;
632  s += "\n\n";
633  }
634 
635  s += playback_devices.size()>0 ? "playback devices: \n" : "";
636  for (auto playback_device : playback_devices)
637  {
638  s += playback_device;
639  s += "\n\n";
640  }
641 
642  return s;
643  }
644  };
645 
646 
647 
648  typedef std::function<void(backend_device_group old, backend_device_group curr)> device_changed_callback;
649 
650  class backend
651  {
652  public:
653  virtual std::shared_ptr<uvc_device> create_uvc_device(uvc_device_info info) const = 0;
654  virtual std::vector<uvc_device_info> query_uvc_devices() const = 0;
655 
656  virtual std::shared_ptr<usb_device> create_usb_device(usb_device_info info) const = 0;
657  virtual std::vector<usb_device_info> query_usb_devices() const = 0;
658 
659  virtual std::shared_ptr<hid_device> create_hid_device(hid_device_info info) const = 0;
660  virtual std::vector<hid_device_info> query_hid_devices() const = 0;
661 
662  virtual std::shared_ptr<time_service> create_time_service() const = 0;
663 
664  virtual std::shared_ptr<device_watcher> create_device_watcher() const = 0;
665 
666  virtual ~backend() = default;
667  };
668 
670  {
671  public:
672  void open(const std::vector<hid_profile>& sensor_iio) override
673  {
674  for (auto&& dev : _dev) dev->open(sensor_iio);
675  }
676 
677  void close() override
678  {
679  for (auto&& dev : _dev) dev->close();
680  }
681 
682  void stop_capture() override
683  {
684  _dev.front()->stop_capture();
685  }
686 
687  void start_capture(hid_callback callback) override
688  {
689  _dev.front()->start_capture(callback);
690  }
691 
692  std::vector<hid_sensor> get_sensors() override
693  {
694  return _dev.front()->get_sensors();
695  }
696 
697  explicit multi_pins_hid_device(const std::vector<std::shared_ptr<hid_device>>& dev)
698  : _dev(dev)
699  {
700  }
701 
702  std::vector<uint8_t> get_custom_report_data(const std::string& custom_sensor_name,
703  const std::string& report_name,
704  custom_sensor_report_field report_field) override
705  {
706  return _dev.front()->get_custom_report_data(custom_sensor_name, report_name, report_field);
707  }
708 
709  private:
710  std::vector<std::shared_ptr<hid_device>> _dev;
711  };
712 
714  {
715  public:
716  explicit multi_pins_uvc_device(const std::vector<std::shared_ptr<uvc_device>>& dev)
717  : _dev(dev)
718  {}
719 
720  void probe_and_commit(stream_profile profile, frame_callback callback, int buffers) override
721  {
722  auto dev_index = get_dev_index_by_profiles(profile);
723  _configured_indexes.insert(dev_index);
724  _dev[dev_index]->probe_and_commit(profile, callback, buffers);
725  }
726 
727 
728  void stream_on(std::function<void(const notification& n)> error_handler = [](const notification& n){}) override
729  {
730  for (auto& elem : _configured_indexes)
731  {
732  _dev[elem]->stream_on(error_handler);
733  }
734  }
735  void start_callbacks() override
736  {
737  for (auto& elem : _configured_indexes)
738  {
739  _dev[elem]->start_callbacks();
740  }
741  }
742 
743  void stop_callbacks() override
744  {
745  for (auto& elem : _configured_indexes)
746  {
747  _dev[elem]->stop_callbacks();
748  }
749  }
750 
751  void close(stream_profile profile) override
752  {
753  auto dev_index = get_dev_index_by_profiles(profile);
754  _dev[dev_index]->close(profile);
755  _configured_indexes.erase(dev_index);
756  }
757 
758  void set_power_state(power_state state) override
759  {
760  for (auto& elem : _dev)
761  {
762  elem->set_power_state(state);
763  }
764  }
765 
766  power_state get_power_state() const override
767  {
768  return _dev.front()->get_power_state();
769  }
770 
771  void init_xu(const extension_unit& xu) override
772  {
773  _dev.front()->init_xu(xu);
774  }
775 
776  bool set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len) override
777  {
778  return _dev.front()->set_xu(xu, ctrl, data, len);
779  }
780 
781  bool get_xu(const extension_unit& xu, uint8_t ctrl, uint8_t* data, int len) const override
782  {
783  return _dev.front()->get_xu(xu, ctrl, data, len);
784  }
785 
786  control_range get_xu_range(const extension_unit& xu, uint8_t ctrl, int len) const override
787  {
788  return _dev.front()->get_xu_range(xu, ctrl, len);
789  }
790 
791  bool get_pu(rs2_option opt, int32_t& value) const override
792  {
793  return _dev.front()->get_pu(opt, value);
794  }
795 
796  bool set_pu(rs2_option opt, int32_t value) override
797  {
798  return _dev.front()->set_pu(opt, value);
799  }
800 
802  {
803  return _dev.front()->get_pu_range(opt);
804  }
805 
806  std::vector<stream_profile> get_profiles() const override
807  {
808  std::vector<stream_profile> all_stream_profiles;
809  for (auto& elem : _dev)
810  {
811  auto pin_stream_profiles = elem->get_profiles();
812  all_stream_profiles.insert(all_stream_profiles.end(),
813  pin_stream_profiles.begin(), pin_stream_profiles.end());
814  }
815  return all_stream_profiles;
816  }
817 
818  std::string get_device_location() const override
819  {
820  return _dev.front()->get_device_location();
821  }
822 
824  {
825  return _dev.front()->get_usb_specification();
826  }
827 
828  void lock() const override
829  {
830  std::vector<uvc_device*> locked_dev;
831  try {
832  for (auto& elem : _dev)
833  {
834  elem->lock();
835  locked_dev.push_back(elem.get());
836  }
837  }
838  catch(...)
839  {
840  for (auto& elem : locked_dev)
841  {
842  elem->unlock();
843  }
844  throw;
845  }
846  }
847 
848  void unlock() const override
849  {
850  for (auto& elem : _dev)
851  {
852  elem->unlock();
853  }
854  }
855 
856  private:
857  uint32_t get_dev_index_by_profiles(const stream_profile& profile) const
858  {
859  uint32_t dev_index = 0;
860  for (auto& elem : _dev)
861  {
862  auto pin_stream_profiles = elem->get_profiles();
863  auto it = find(pin_stream_profiles.begin(), pin_stream_profiles.end(), profile);
864  if (it != pin_stream_profiles.end())
865  {
866  return dev_index;
867  }
868  ++dev_index;
869  }
870  throw std::runtime_error("profile not found");
871  }
872 
873  std::vector<std::shared_ptr<uvc_device>> _dev;
874  std::set<uint32_t> _configured_indexes;
875  };
876 
877  std::shared_ptr<backend> create_backend();
878 
879 
880 
882  {
883  public:
884  virtual void start(device_changed_callback callback) = 0;
885  virtual void stop() = 0;
886  virtual ~device_watcher() {};
887  };
888  }
889 
890  double monotonic_to_realtime(double monotonic);
891 }
892 
893 #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:390
Definition: backend.h:372
Definition: backend.h:184
usb_spec conn_spec
Definition: backend.h:250
bool set_xu(const extension_unit &xu, uint8_t ctrl, const uint8_t *data, int len) override
Definition: backend.h:776
std::string get_device_location() const override
Definition: backend.h:818
Definition: backend.h:374
std::vector< uint8_t > max
Definition: backend.h:84
std::string sensor_name
Definition: backend.h:367
uint32_t timestamp
Definition: backend.h:160
usb_spec conn_spec
Definition: backend.h:208
Definition: backend.h:378
std::vector< hid_sensor > get_sensors() override
Definition: backend.h:692
Definition: backend.h:650
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:472
Definition: backend.h:395
std::vector< playback_device_info > playback_devices
Definition: backend.h:600
constexpr uint8_t uvc_header_size
Definition: backend.h:165
usb_spec get_usb_specification() const override
Definition: backend.h:823
Definition: backend.h:182
hid_sensor_input sensor_input
Definition: backend.h:355
Definition: backend.h:108
size_t frame_size
Definition: backend.h:169
void init_xu(const extension_unit &xu) override
Definition: backend.h:487
uint16_t vid
Definition: backend.h:203
uint32_t format
Definition: backend.h:136
std::string device_path
Definition: backend.h:283
const uint8_t MAX_META_DATA_SIZE
Definition: backend.h:30
short x
Definition: backend.h:383
std::string id
Definition: backend.h:244
backend_device_group(const std::vector< uvc_device_info > &uvc_devices, const std::vector< usb_device_info > &usb_devices)
Definition: backend.h:592
const void * metadata
Definition: backend.h:172
backend_device_group(const std::vector< playback_device_info > &playback_devices)
Definition: backend.h:595
std::string vid
Definition: backend.h:280
Definition: backend.h:353
retry_controls_work_around(std::shared_ptr< uvc_device > dev)
Definition: backend.h:449
void close() override
Definition: backend.h:677
hid_sensor sensor
Definition: backend.h:361
virtual ~device_watcher()
Definition: backend.h:886
control_range get_xu_range(const extension_unit &xu, uint8_t ctrl, int len) const override
Definition: backend.h:786
void set_power_state(power_state state) override
Definition: backend.h:477
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:702
bool get_xu(const extension_unit &xu, uint8_t ctrl, uint8_t *data, int len) const override
Definition: backend.h:504
std::vector< tm2_device_info > tm2_devices
Definition: backend.h:601
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:566
Definition: algo.h:16
std::string pid
Definition: backend.h:281
bool get_xu(const extension_unit &xu, uint8_t ctrl, uint8_t *data, int len) const override
Definition: backend.h:781
bool set_xu(const extension_unit &xu, uint8_t ctrl, const uint8_t *data, int len) override
Definition: backend.h:492
uint8_t length
Definition: backend.h:157
std::vector< hid_device_info > hid_devices
Definition: backend.h:599
multi_pins_uvc_device(const std::vector< std::shared_ptr< uvc_device >> &dev)
Definition: backend.h:716
void probe_and_commit(stream_profile profile, frame_callback callback, int buffers) override
Definition: backend.h:452
bool get_pu(rs2_option opt, int32_t &value) const override
Definition: backend.h:521
uint8_t info
Definition: backend.h:159
std::string id
Definition: backend.h:279
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:648
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:771
control_range get_xu_range(const extension_unit &xu, uint8_t ctrl, int len) const override
Definition: backend.h:516
power_state
Definition: backend.h:123
std::string unique_id
Definition: backend.h:249
void stream_on(std::function< void(const notification &n)> error_handler=[](const notification &n){}) override
Definition: backend.h:457
void probe_and_commit(stream_profile profile, frame_callback callback, int buffers) override
Definition: backend.h:720
void start_callbacks() override
Definition: backend.h:462
void lock() const override
Definition: backend.h:565
void unlock() const override
Definition: backend.h:848
std::string name
Definition: backend.h:344
void lock() const override
Definition: backend.h:828
void close(stream_profile profile) override
Definition: backend.h:751
std::string device_path
Definition: backend.h:207
std::tuple< uint32_t, uint32_t, uint32_t, uint32_t > stream_profile_tuple
Definition: backend.h:129
Definition: backend.h:373
std::string unique_id
Definition: backend.h:206
uint8_t metadata_size
Definition: backend.h:170
uint16_t pid
Definition: backend.h:247
void set_power_state(power_state state) override
Definition: backend.h:758
uint16_t mi
Definition: backend.h:205
std::string get_device_location() const override
Definition: backend.h:555
std::vector< stream_profile > get_profiles() const override
Definition: backend.h:550
uint16_t pid
Definition: backend.h:204
bool set_pu(rs2_option opt, int32_t value) override
Definition: backend.h:796
void stop_callbacks() override
Definition: backend.h:743
std::string unique_id
Definition: backend.h:282
int unit
Definition: backend.h:110
short z
Definition: backend.h:387
Definition: backend.h:126
void start_callbacks() override
Definition: backend.h:735
uint32_t frequency
Definition: backend.h:368
void start_capture(hid_callback callback) override
Definition: backend.h:687
std::function< void(const notification &n)> _error_handler
Definition: backend.h:443
bool get_pu(rs2_option opt, int32_t &value) const override
Definition: backend.h:791
custom_sensor_report_field
Definition: backend.h:371
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:377
uint32_t width
Definition: backend.h:133
void stop_capture() override
Definition: backend.h:682
std::string file_path
Definition: backend.h:310
uint32_t ts_low
Definition: backend.h:389
uint32_t height
Definition: backend.h:134
Definition: backend.h:359
Definition: backend.h:572
void stream_on(std::function< void(const notification &n)> error_handler=[](const notification &n){}) override
Definition: backend.h:728
rs2_time_t get_time() const override
Definition: backend.h:102
uint32_t value
Definition: backend.h:356
Definition: backend.h:375
std::vector< usb_device_info > usb_devices
Definition: backend.h:598
Definition: backend.h:125
multi_pins_hid_device(const std::vector< std::shared_ptr< hid_device >> &dev)
Definition: backend.h:697
Definition: backend.h:155
control_range()
Definition: backend.h:69
std::shared_ptr< backend > create_backend()
frame_object fo
Definition: backend.h:362
std::vector< uint8_t > def
Definition: backend.h:86
Definition: backend.h:411
backend_device_group()
Definition: backend.h:584
Definition: backend.h:365
Definition: types.h:896
std::vector< uint8_t > min
Definition: backend.h:83
hid_sensor sensor
Definition: backend.h:354
backend_device_group(const std::vector< usb_device_info > &usb_devices)
Definition: backend.h:589
short y
Definition: backend.h:385
Definition: backend.h:187
control_range get_pu_range(rs2_option opt) const override
Definition: backend.h:801
power_state get_power_state() const override
Definition: backend.h:482
Definition: backend.h:376
std::function< void(const sensor_data &)> hid_callback
Definition: backend.h:393
std::vector< uvc_device_info > uvc_devices
Definition: backend.h:597
power_state get_power_state() const override
Definition: backend.h:766
void stop_callbacks() override
Definition: backend.h:467
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:560
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:586
std::string name
Definition: backend.h:350
std::vector< stream_profile > get_profiles() const override
Definition: backend.h:806
double rs2_time_t
Definition: rs_types.h:179
Definition: backend.h:181
void open(const std::vector< hid_profile > &sensor_iio) override
Definition: backend.h:672
Definition: backend.h:342
bool set_pu(rs2_option opt, int32_t value) override
Definition: backend.h:533
control_range get_pu_range(rs2_option opt) const override
Definition: backend.h:545
Definition: types.h:606
Definition: backend.h:186
void * device_ptr
Definition: backend.h:326
double get_time()
Definition: rs_internal.hpp:61
std::string id
Definition: backend.h:202
const void * pixels
Definition: backend.h:171
uint16_t mi
Definition: backend.h:248
uint16_t vid
Definition: backend.h:246
uint32_t index
Definition: backend.h:349
Definition: playback_device.h:17