4 #ifdef RS2_USE_ANDROID_BACKEND 9 #include "../usb/usb-device.h" 10 #include "../usb/usb-enumerator.h" 13 #include "../android/device_watcher.h" 20 static std::vector<std::shared_ptr<librealsense::platform::usb_device>> _devices;
28 std::vector<usb_device_info> rv;
29 for(
auto&&
dev : _devices)
31 auto d = std::static_pointer_cast<usb_device_usbhost>(
dev);
32 auto sdi =
d->get_subdevices_info();
33 rv.insert(rv.end(), sdi.begin(), sdi.end());
40 for(
auto&&
dev : _devices)
42 if(info.id ==
dev->get_info().id)
50 extern "C" JNIEXPORT
void JNICALL
51 Java_com_intel_realsense_librealsense_DeviceWatcher_nAddUsbDevice(JNIEnv *env, jclass
type,
52 jstring deviceName_, jint fileDescriptor) {
53 LOG_DEBUG(
"AddUsbDevice, previous device count: " << _devices.size());
54 const char *deviceName = env->GetStringUTFChars(deviceName_, 0);
55 LOG_DEBUG(
"AddUsbDevice, adding device: " << deviceName <<
", descriptor: " << fileDescriptor);
58 env->ReleaseStringUTFChars(deviceName_, deviceName);
62 auto d = std::make_shared<librealsense::platform::usb_device_usbhost>(
handle);
63 _devices.push_back(
d);
70 LOG_DEBUG(
"AddUsbDevice, current device count: " << _devices.size());
73 extern "C" JNIEXPORT
void JNICALL
74 Java_com_intel_realsense_librealsense_DeviceWatcher_nRemoveUsbDevice(JNIEnv *env, jclass type,
75 jint fileDescriptor) {
76 LOG_DEBUG(
"RemoveUsbDevice, previous device count: " << _devices.size());
78 _devices.erase(std::remove_if(_devices.begin(), _devices.end(),
79 [fileDescriptor](std::shared_ptr<librealsense::platform::usb_device>
dev)
82 if(fileDescriptor ==
d->get_file_descriptor()){
84 LOG_DEBUG(
"RemoveUsbDevice, removing device: " <<
d->get_info().unique_id <<
", descriptor: " << fileDescriptor);
92 LOG_DEBUG(
"RemoveUsbDevice, current device count: " << _devices.size());
GLuint64 GLenum void * handle
def info(name, value, persistent=False)
struct usb_device * usb_device_new(const char *dev_name, int fd)