| 402 | } // namespace openhd::v4l2 |
| 403 | |
| 404 | std::vector<DCameras::DiscoveredUSBCamera> DCameras::detect_usb_cameras( |
| 405 | std::shared_ptr<spdlog::logger> &m_console, bool debug) { |
| 406 | const auto platform = OHDPlatform::instance(); |
| 407 | if (platform.is_rpi_or_x86()) { |
| 408 | DThermalCamerasHelper::enableFlirIfFound(); |
| 409 | DThermalCamerasHelper::enableSeekIfFound(); |
| 410 | } |
| 411 | std::vector<DCameras::DiscoveredUSBCamera> ret; |
| 412 | const auto devices = openhd::v4l2::findV4l2VideoDevices(); |
| 413 | if (debug) { |
| 414 | m_console->debug("Found {} v4l2 devices", devices.size()); |
| 415 | for (auto &device : devices) m_console->debug("Device:{}", device); |
| 416 | } |
| 417 | for (const auto &device : devices) { |
| 418 | const auto v4l2_device_name = get_v4l2_device_name_string(device); |
| 419 | const auto probed_opt = |
| 420 | openhd::v4l2::probe_v4l2_device(platform, m_console, v4l2_device_name); |
| 421 | if (!probed_opt.has_value()) { |
| 422 | continue; |
| 423 | } |
| 424 | const auto &probed = probed_opt.value(); |
| 425 | const std::string bus((char *)probed.caps.bus_info); |
| 426 | const std::string driver((char *)probed.caps.driver); |
| 427 | if (debug) { |
| 428 | m_console->debug("V4l2 info {} {} {}", device, bus, |
| 429 | probed.formats.formats_raw.size()); |
| 430 | } |
| 431 | if (!probed.formats.formats_raw.empty()) { |
| 432 | // (RAW) format usb camera candidate |
| 433 | bool found = false; |
| 434 | for (auto &tmp : ret) { |
| 435 | if (tmp.bus == bus) { |
| 436 | found = true; |
| 437 | } |
| 438 | } |
| 439 | if (!found) { |
| 440 | ret.push_back(DCameras::DiscoveredUSBCamera{ |
| 441 | .bus = bus, .v4l2_device_number = device}); |
| 442 | } else { |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | if (debug) { |
| 447 | for (const auto &usb_cam : ret) { |
| 448 | m_console->debug("Found USB cam [{}]-[{}]", usb_cam.bus, |
| 449 | usb_cam.v4l2_device_number); |
| 450 | } |
| 451 | } |
| 452 | return ret; |
| 453 | } |
| 454 | |
| 455 | #endif |
nothing calls this directly
no test coverage detected