4 #if (_MSC_VER <= 1800) // constexpr is not supported in MSVC2013 5 #error( "Librealsense requires MSVC2015 or later to build. Compilation will be aborted" ) 29 template<
unsigned...
Is>
struct seq{};
30 template<
unsigned N,
unsigned...
Is>
32 template<
unsigned...
Is>
35 template<
unsigned N1,
unsigned... I1,
unsigned N2,
unsigned... I2>
37 return {{ a1[I1]..., a2[I2]... }};
40 template<
unsigned N1,
unsigned N2>
41 constexpr
std::array<
char const, N1+N2-1>
concat(
char const (&a1)[N1],
char const (&a2)[N2]){
50 const std::shared_ptr<librealsense::device_info>& second)
52 auto first_data = first->get_device_data();
53 auto second_data = second->get_device_data();
55 for (
auto&& uvc : first_data.uvc_devices)
57 if (
std::find(second_data.uvc_devices.begin(),
58 second_data.uvc_devices.end(), uvc) ==
59 second_data.uvc_devices.end())
62 for (
auto&& usb : first_data.usb_devices)
64 if (
std::find(second_data.usb_devices.begin(),
65 second_data.usb_devices.end(), usb) ==
66 second_data.usb_devices.end())
69 for (
auto&& hid : first_data.hid_devices)
71 if (
std::find(second_data.hid_devices.begin(),
72 second_data.hid_devices.end(), hid) ==
73 second_data.hid_devices.end())
76 for (
auto&& pd : first_data.playback_devices)
78 if (
std::find(second_data.playback_devices.begin(),
79 second_data.playback_devices.end(), pd) ==
80 second_data.playback_devices.end())
106 static bool version_logged=
false;
109 version_logged =
true;
122 _backend = std::make_shared<platform::playback_backend>(
filename, section, min_api_version);
136 std::shared_ptr<device_interface>
create(std::shared_ptr<context>,
bool)
const override 144 return pid == 0x0ADB || pid == 0x0AB3;
148 std::shared_ptr<context>
ctx,
149 const std::vector<platform::usb_device_info>& usb_devices)
151 std::vector<std::shared_ptr<device_info>> list;
152 for (
auto&& usb : usb_devices)
154 if (is_recovery_pid(usb.pid))
156 list.push_back(std::make_shared<recovery_info>(ctx, usb));
172 const char* RECOVERY_MESSAGE =
"Selected RealSense device is in recovery mode!\nEither perform a firmware update or reconnect the camera to fall-back to last working firmware if available!";
178 std::shared_ptr<device_interface> create(std::shared_ptr<context>,
bool)
const override;
181 const std::shared_ptr<context>&
ctx,
182 const std::vector<platform::uvc_device_info>& uvc_devices)
184 std::vector<std::shared_ptr<device_info>> list;
190 list.push_back(std::make_shared<platform_camera_info>(ctx,
g));
196 std::vector<platform::uvc_device_info> uvcs)
205 std::vector<platform::uvc_device_info>
_uvcs;
213 :
synthetic_sensor(
"RGB Camera", uvc_sensor, owner,platform_color_fourcc_to_rs2_format,platform_color_fourcc_to_rs2_stream),
224 for (
auto&&
p : results)
227 assign_stream(_default_stream,
p);
243 const std::vector<platform::uvc_device_info>& uvc_infos,
245 bool register_device_notifications)
246 :
device(ctx, group, register_device_notifications)
248 std::vector<std::shared_ptr<platform::uvc_device>> devs;
249 for (
auto&&
info : uvc_infos)
250 devs.push_back(ctx->get_backend().create_uvc_device(
info));
253 auto raw_color_ep = std::make_shared<uvc_sensor>(
"Raw RGB Camera",
254 std::make_shared<platform::multi_pins_uvc_device>(devs),
257 auto color_ep = std::make_shared<platform_camera_sensor>(
this, raw_color_ep);
258 add_sensor(color_ep);
261 std::string pid_str(
to_string() << std::setfill(
'0') << std::setw(4) << std::hex << uvc_infos.front().pid);
262 std::transform(pid_str.begin(), pid_str.end(), pid_str.begin(), ::toupper);
264 using namespace platform;
265 auto usb_mode = raw_color_ep->get_usb_specification();
303 std::vector<tagged_profile> markers;
310 bool register_device_notifications)
const 312 return std::make_shared<platform_camera>(
ctx, _uvcs, this->get_device_data(), register_device_notifications);
331 std::vector<std::shared_ptr<device_info>> list;
333 auto t =
const_cast<context*
>(
this);
335 auto ctx =
t->shared_from_this();
363 if (mask & RS2_PRODUCT_LINE_D400 || mask & RS2_PRODUCT_LINE_SR300 || mask & RS2_PRODUCT_LINE_L500)
366 std::copy(
begin(recovery_devices),
end(recovery_devices), std::back_inserter(list));
375 for (
auto&& item : playback_devices)
377 if (
auto dev = item.second.lock())
382 LOG_INFO(
"Found " << list.size() <<
" RealSense devices (mask 0x" << std::hex << mask <<
")" );
395 if (
librealsense::list_changed<std::shared_ptr<device_info>>(old_list, new_list, [](std::shared_ptr<device_info>
first, std::shared_ptr<device_info> second) {
return *first == *second; }))
397 std::vector<rs2_device_info> rs2_devices_info_added;
398 std::vector<rs2_device_info> rs2_devices_info_removed;
400 auto devices_info_removed =
subtract_sets(old_list, new_list);
402 for (
size_t i = 0;
i < devices_info_removed.size();
i++)
404 rs2_devices_info_removed.push_back({ shared_from_this(), devices_info_removed[
i] });
409 for (
size_t i = 0;
i < devices_info_added.size();
i++)
411 rs2_devices_info_added.push_back({ shared_from_this(), devices_info_added[
i] });
415 std::map<uint64_t, devices_changed_callback_ptr> devices_changed_callbacks;
421 for (
auto&
kvp : devices_changed_callbacks)
425 kvp.second->on_devices_changed(
new rs2_device_list({ shared_from_this(), rs2_devices_info_removed }),
430 LOG_ERROR(
"Exception thrown from user callback handler");
448 LOG_ERROR(
"Exception thrown from user callback handler");
478 std::vector<platform::uvc_device_info>
filter_by_product(
const std::vector<platform::uvc_device_info>&
devices,
const std::set<uint16_t>& pid_list)
480 std::vector<platform::uvc_device_info>
result;
481 for (
auto&&
info : devices)
483 if (pid_list.count(
info.pid))
484 result.push_back(
info);
490 std::vector<platform::usb_device_info>
filter_by_product(
const std::vector<platform::usb_device_info>&
devices,
const std::set<uint16_t>& pid_list)
492 std::vector<platform::usb_device_info>
result;
493 for (
auto&&
info : devices)
495 if (pid_list.count(
info.pid))
496 result.push_back(
info);
502 const std::vector<std::vector<platform::uvc_device_info>>&
devices,
503 const std::vector<platform::hid_device_info>& hids)
505 std::vector<std::pair<std::vector<platform::uvc_device_info>, std::vector<platform::hid_device_info>>> results;
511 std::vector<platform::hid_device_info> hid_group;
513 auto device_serial =
dev.front().serial;
515 for (
auto&& hid : hids)
517 if( ! hid.unique_id.empty() )
519 std::stringstream(hid.vid) >> std::hex >> vid;
520 std::stringstream(hid.pid) >> std::hex >> pid;
524 hid_group.push_back(hid);
528 results.push_back(std::make_pair(
dev, hid_group));
541 auto playback_dev = std::make_shared<playback_device>(shared_from_this(), std::make_shared<ros_reader>(file, shared_from_this()));
542 auto dinfo = std::make_shared<playback_device_info>(playback_dev);
551 auto file = dev->get_device_data().playback_devices.front().file_path;
578 void context::unload_tracking_module()
585 std::map<std::string, std::vector<platform::uvc_device_info>>
map;
586 for (
auto&&
info : devices)
588 map[
info.unique_id].push_back(
info);
590 std::vector<std::vector<platform::uvc_device_info>>
result;
591 for (
auto&&
kvp : map)
593 result.push_back(
kvp.second);
607 return find(chosen.begin(), chosen.end(),
info) != chosen.end();
609 devices.erase(std::remove_if(devices.begin(), devices.end(), was_chosen), devices.end());
619 return find(chosen.begin(), chosen.end(),
info) != chosen.end();
621 devices.erase(std::remove_if(devices.begin(), devices.end(), was_chosen), devices.end());
626 for (
auto&&
info : devices)
636 for (
auto&&
info : devices)
646 std::vector<platform::uvc_device_info> results;
647 for (
auto&&
info : devices)
650 results.push_back(
info);
void on_device_changed(platform::backend_device_group old, platform::backend_device_group curr, const std::map< std::string, std::weak_ptr< device_info >> &old_playback_devices, const std::map< std::string, std::weak_ptr< device_info >> &new_playback_devices)
static const textual_icon lock
static bool is_recovery_pid(uint16_t pid)
std::vector< platform::uvc_device_info > filter_by_product(const std::vector< platform::uvc_device_info > &devices, const std::set< uint16_t > &pid_list)
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;})
std::map< std::string, std::weak_ptr< device_info > > _playback_devices
void trim_device_list(std::vector< platform::usb_device_info > &devices, const std::vector< platform::usb_device_info > &chosen)
std::vector< std::shared_ptr< device_info > > query_devices(int mask) const
virtual stream_profiles init_stream_profiles() override
const uint16_t VID_INTEL_CAMERA
void register_same_extrinsics(const stream_interface &from, const stream_interface &to)
GLsizei const GLchar *const * string
bool Is(std::shared_ptr< P > ptr)
std::mutex _devices_changed_callbacks_mtx
void remove_device(const std::string &file)
def info(name, value, persistent=False)
#define RS2_PRODUCT_LINE_NON_INTEL
platform::usb_device_info _dfu
bool contains(const std::shared_ptr< librealsense::device_info > &first, const std::shared_ptr< librealsense::device_info > &second)
std::vector< std::pair< std::vector< platform::uvc_device_info >, std::vector< platform::hid_device_info > > > group_devices_and_hids_by_unique_id(const std::vector< std::vector< platform::uvc_device_info >> &devices, const std::vector< platform::hid_device_info > &hids)
std::vector< std::vector< platform::uvc_device_info > > group_devices_by_unique_id(const std::vector< platform::uvc_device_info > &devices)
std::vector< std::shared_ptr< T > > subtract_sets(const std::vector< std::shared_ptr< T >> &first, const std::vector< std::shared_ptr< T >> &second)
#define RS2_PRODUCT_LINE_D400
uint32_t rs_fourcc(const T a, const T b, const T c, const T d)
void set_time_service(std::shared_ptr< platform::time_service > ts)
platform::uvc_device_info get_mi(const std::vector< platform::uvc_device_info > &devices, uint32_t mi)
static processing_block_factory create_id_pbf(rs2_format format, rs2_stream stream, int idx=0)
recovery_info(std::shared_ptr< context > ctx, platform::usb_device_info dfu)
unsigned __int64 uint64_t
std::shared_ptr< md_attribute_parser_base > make_uvc_header_parser(Attribute St::*attribute, attrib_modifyer mod=nullptr)
A utility function to create UVC metadata header parser.
#define RS2_PRODUCT_LINE_L500
#define RS2_PRODUCT_LINE_T200
std::shared_ptr< platform::device_watcher > _device_watcher
std::vector< std::shared_ptr< stream_profile_interface >> stream_profiles
static environment & get_instance()
extrinsics_graph & get_extrinsics_graph()
#define RS2_PRODUCT_LINE_ANY
LOG_INFO("Log message using LOG_INFO()")
constexpr std::array< char const, N1+N2-1 > concat(char const (&a1)[N1], char const (&a2)[N2], seq< I1... >, seq< I2... >)
static std::vector< std::shared_ptr< device_info > > pick_recovery_devices(std::shared_ptr< context > ctx, const std::vector< platform::usb_device_info > &usb_devices, int mask)
platform::backend_device_group get_device_data() const override
void add_software_device(std::shared_ptr< device_info > software_device)
static std::vector< std::shared_ptr< device_info > > pick_ds5_devices(std::shared_ptr< context > ctx, platform::backend_device_group &gproup)
void raise_devices_changed(const std::vector< rs2_device_info > &removed, const std::vector< rs2_device_info > &added)
#define RS2_API_VERSION_STR
static std::vector< std::shared_ptr< device_info > > pick_l500_devices(std::shared_ptr< context > ctx, platform::backend_device_group &group)
std::map< uint64_t, devices_changed_callback_ptr > _devices_changed_callbacks
static std::vector< std::shared_ptr< device_info > > pick_tm2_devices(std::shared_ptr< context > ctx, std::vector< platform::usb_device_info > &usb)
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
uint64_t register_internal_device_callback(devices_changed_callback_ptr callback)
void set_devices_changed_callback(devices_changed_callback_ptr callback)
std::vector< std::shared_ptr< device_info > > create_devices(platform::backend_device_group devices, const std::map< std::string, std::weak_ptr< device_info >> &playback_devices, int mask) const
std::shared_ptr< platform::backend > _backend
std::shared_ptr< rs2_devices_changed_callback > devices_changed_callback_ptr
static uint64_t generate_id()
std::shared_ptr< device_interface > create(std::shared_ptr< context >, bool) const override
struct rs2_device_list rs2_device_list
constexpr auto rs2_api_version
static std::vector< std::shared_ptr< device_info > > pick_recovery_devices(std::shared_ptr< context > ctx, const std::vector< platform::usb_device_info > &usb_devices)
GLuint GLenum GLenum transform
std::vector< platform::uvc_device_info > filter_by_mi(const std::vector< platform::uvc_device_info > &devices, uint32_t mi)
static std::vector< std::shared_ptr< device_info > > pick_sr300_devices(std::shared_ptr< context > ctx, std::vector< platform::uvc_device_info > &platform, std::vector< platform::usb_device_info > &usb)
const std::map< uint32_t, rs2_stream > platform_color_fourcc_to_rs2_stream
#define RS2_PRODUCT_LINE_SR300
void unregister_internal_device_callback(uint64_t cb_id)
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
devices_changed_callback_ptr _devices_changed_callback
const std::map< uint32_t, rs2_format > platform_color_fourcc_to_rs2_format
void copy(void *dst, void const *src, size_t size)
bool mi_present(const std::vector< platform::uvc_device_info > &devices, uint32_t mi)
std::shared_ptr< playback_device_info > add_device(const std::string &file)
std::string to_string(T value)