microsoft / MixedReality-WebRTC

MixedReality-WebRTC is a collection of components to help mixed reality app developers integrate audio and video real-time communication into their application and improve their collaborative experience
https://microsoft.github.io/MixedReality-WebRTC/
MIT License
911 stars 283 forks source link

Publishing video with same name cameras only initialize the first one. #129

Open eirikhollis opened 4 years ago

eirikhollis commented 4 years ago

So kinda clunky title, but I'll explain.

I'm trying the new "multiple videotracks per peerconnection" feature, and I have two webcameras that are of the same model, Logitech BRIO. When running PeerConnection.GetVideoCaptureDevicesAsync() both cameras appear and are recognized as seperate cameras. However, when setting PeerConnection.LocalVideoTrackSettings.VideoDevice to either one of them, only one of them is used. If I try to enable the first, then the second, in the same peerconnection, the app crashes, which I think is because it tries to access the first camera two times. I have a third webcamera which has a different name, Microsoft® LifeCam Studio(TM), and this is recognized and utilized correctly in conjunction with either of the two Brios. I'm assuming then that the WebRTC code checks the name of the camera instead of the ID? That would at least explain my findings.

djee-ms commented 4 years ago

Is this Desktop or UWP?

eirikhollis commented 4 years ago

In Unity, so desktop?

djee-ms commented 4 years ago

Yes, Desktop x64 then. I ask because the codepaths are quite different internally.

On Desktop, the video capture is handled by the Google implementation directly. And indeed there a bug in it, already identified by their devs it seems: https://github.com/webrtc-uwp/webrtc/blob/baa89682df1ab891ae274a1cb2d9be3b1ee7e20b/media/engine/webrtcvideocapturer.cc#L138-L150

This is annoying because there's no easy way currently for us to fix that. We will have to either backport a fix or upgrade to a later Google release.

djee-ms commented 4 years ago

Note this seems fixed on Google's HEAD, if I am not mistaken in thinking that VcmCapturer is the replacement for the current WebRtcVideoCapturer on M71. https://webrtc.googlesource.com/src/+/refs/heads/master/test/vcm_capturer.cc#42