I am working on an Electron app with React.js that sets up some peer connections through webRTC. Everything looks good with the connections and the peers receive the stream, but the video on the peers end does no play the audio. Perhaps I'm just not understanding how getUserMedia works, but I thought setting constraints true for audio and video was enough.
Relavent HTML (Peer)
<video ref="video" autoplay></video>
A few snippets of the code getting the stream
// constraints
this.constraints = {
video: true,
audio: true,
};
this.sdpConstraints = {
'mandatory': {
'OfferToReceiveAudio': this.constraints.audio,
'OfferToReceiveVideo': this.constraints.video
}
};
...
// getting/setting local video
setupLocalMedia(){
navigator.mediaDevices.getUserMedia(self.constraints)
.then(function(stream){
self.localVideo.src = window.URL.createObjectURL(stream);
self.stream = stream;
window.stream = stream;
}).catch(self.errorHandler);
}
// adding the stream to the peer
peerConnection.onaddstream = function(event){
peerVideo.src = window.URL.createObjectURL(event.stream);
};
Again, all the connections are working just fine, and the video is streaming as expected, but no audio. Consoling the stream shows that the audio channel is enabled. Any ideas?