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
913 stars 283 forks source link

Can't use WebcamSource on another PeerConnection in HoloLens #737

Open Kawottex opened 3 years ago

Kawottex commented 3 years ago

Hello, I am currently trying to build a WebRTC setup with the possibility to have multiple PeerConnection at the same time. In order to do that, I first initialize the MicrophoneSource and WebcamSource component (this is done only once during the workflow of the application):

audioSource = audioSourceObj.AddComponent<MicrophoneSource>();
videoSource = videoSourceObj.AddComponent<WebcamSource>();

Then, everytime I create a new PeerConnection, I configure its MediaLine so that it takes these components as source:

MediaLine audioMediaLine = unityPeerConnection.AddMediaLine(MediaKind.Audio);
audioMediaLine.Receiver = audioReceiver;
audioMediaLine.Source = LocalMediaDevices.Instance.audioSource;
MediaLine videoMediaLine = unityPeerConnection.AddMediaLine(MediaKind.Video);
videoMediaLine.Receiver = videoReceiver;
videoMediaLine.Source = LocalMediaDevices.Instance.videoSource;

This setup works well in the Unity Editor, I've got no issue to create multiple connections at the same time. But on HoloLens, when I try to create another PeerConnection, the video is not sent anymore on the first, nor the second.

Moreover, another strange behaviour, if I try to create a PeerConnection, use it, destroy it and create another one (only one connection at a time), it connects well to the other peer but the video is not sent. I think this issue is probably related to the first one. Looking at this issue #382 it seems that it shouldn't be a problem to have a setup like this one, that's why I don't understand what I am doing wrong.

Could you help me on this one ? Thank you for your help,

Kevin.