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