webrtc-java icon indicating copy to clipboard operation
webrtc-java copied to clipboard

Cannot specify camera and capabilities in Ubuntu

Open vria opened this issue 3 years ago • 3 comments

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:

  • Ubuntu 20
  • variables passed to VideoDeviceSource Screenshot from 2021-09-20 13-29-20

Thank you in advance.

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

vria avatar Sep 20 '21 12:09 vria

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();
}

devopvoid avatar Nov 10 '21 14:11 devopvoid

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).

vria avatar Nov 10 '21 15:11 vria

Late, but should be fixed now.

devopvoid avatar Jan 14 '22 22:01 devopvoid