devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

Cannot specify camera and capabilities in Ubuntu #30

Closed vria closed 1 year ago

vria commented 2 years ago

Hi Alex !

Thank you for 702e58c. The application does not crash anymore but I still experience the same bug. The camera refuses to launch if device and capability are not null.

There are not much detials about this exception because it remains unhandled:

catch (...) {
      // app falls here
      env->Throw(jni::JavaError(env, "Unhandled Exception"));
}

Context:

Thank you in advance.

P.S. This bug was introduced in 1029fe. Anterior versions work just exellent.

devopvoid commented 2 years ago

I'm not sure, maybe you are using the old devices API. Could you please try with:

List<VideoDevice> devices = MediaDevices.getVideoCaptureDevices();
List<VideoCaptureCapability> capabilities = MediaDevices.getVideoCaptureCapabilities(device);

VideoDevice cameraDevice = devices.get(0);  // Or any device retrieved with MediaDevices.getVideoCaptureDevices()
VideoCaptureCapability cameraCapability = capabilities.get(0);

VideoDeviceSource cameraSource = new VideoDeviceSource();
cameraSource.setVideoCaptureDevice(cameraDevice);
// Optionally
cameraSource.setVideoCaptureCapability(cameraCapability);

try {
    cameraSource.start();
}
catch (Throwable e) {
    e.printStackTrace();

    cameraSource.dispose();
}
vria commented 2 years ago

Thanks for your suggestion. This is precisely the problem. When cameraDevice is not null and when it is passed to setVideoCaptureDevice this error occurs :

backtrace: unhandled exception type: jni::Exception*
java.lang.Error: Unhandled Exception
    at webrtc.java/dev.onvoid.webrtc.media.video.VideoDeviceSource.start(Native Method)

What do you mean by "Old devices API" ? Is this related to Ubuntu libs like udev or v4l2 ?

P.S.

libv4l-dev is already the newest version (1.18.0-2build1).

devopvoid commented 2 years ago

Late, but should be fixed now.