14 std::vector<std::shared_ptr<device_info>>
filter_by_vid(std::vector<std::shared_ptr<device_info>>
devices ,
int vid)
16 std::vector<std::shared_ptr<device_info>>
result;
19 bool filtered =
false;
20 auto data =
dev->get_device_data();
21 for (
const auto& usb :
data.usb_devices)
23 if (usb.vid == vid || vid == 0)
25 result.push_back(
dev);
30 for (
const auto& uvc :
data.uvc_devices)
32 if (uvc.vid == vid || vid == 0)
34 result.push_back(
dev);
44 bool register_device_notifications)
45 : _ctx(ctx), _vid(vid),
46 _device_changes_callback_id(0),
47 _register_device_notifications(register_device_notifications)
78 std::shared_ptr<device_interface>
res =
nullptr;
87 if(serial.size() > 0 )
91 if(serial == new_serial)
94 cycle_devices =
false;
102 catch (
const std::exception& ex)
104 LOG_WARNING(
"Could not open device " << ex.what());
109 if (res && cycle_devices)
124 std::shared_ptr<device_interface>
res =
nullptr;
136 if (!
_cv.wait_for(lock, timeout, [&]()
138 if (_device_list.size() > 0)
140 res = create_device(serial, loop_through_devices);
142 return res !=
nullptr;
145 throw std::runtime_error(
"No device connected");
static const textual_icon lock
device_hub(std::shared_ptr< librealsense::context > ctx, int mask=RS2_PRODUCT_LINE_ANY, int vid=0, bool register_device_notifications=true)
bool is_connected(const device_interface &dev)
GLsizei const GLchar *const * string
std::condition_variable _cv
virtual bool is_valid() const =0
std::shared_ptr< device_interface > create_device(const std::string &serial, bool cycle_devices=true)
std::shared_ptr< librealsense::context > _ctx
std::shared_ptr< device_interface > wait_for_device(const std::chrono::milliseconds &timeout=std::chrono::milliseconds(std::chrono::hours(1)), bool loop_through_devices=true, const std::string &serial="")
#define RS2_PRODUCT_LINE_ANY
uint64_t _device_changes_callback_id
GLbitfield GLuint64 timeout
std::vector< std::shared_ptr< device_info > > filter_by_vid(std::vector< std::shared_ptr< device_info >> devices, int vid)
std::vector< std::shared_ptr< device_info > > _device_list
rs2::devices_changed_callback< std::function< void(rs2::event_information &info)> > hub_devices_changed_callback
std::shared_ptr< librealsense::context > get_context()
bool _register_device_notifications