node-webrtc / node-webrtc-examples

MediaStream and RTCDataChannel examples using node-webrtc
508 stars 161 forks source link

Unable to relay Audio back to browser #38

Open scootercop opened 3 years ago

scootercop commented 3 years ago

So i've done this on the server

const audioTransceiver = pc.addTransceiver("audio");
  audioTransceiver.sender.replaceTrack(audioTransceiver.receiver.track);

while creating the pc(peerconnection) object

and on the client

const remoteStream = new MediaStream(
      pc.getReceivers().map((receiver) => receiver.track)
    );
    remoteAudio.srcObject = remoteStream;

right before

`pc.setRemoteDescription(new RTCSessionDescription(message));`

But my remote audio stream isn't really working. Like it's just stuck at 0:00 not playing. I checked and the pc.getReceivers() does return mediaStream with 1 track (audio, which is all that im using).

Probably some mistake in my code but if anyone could help out that's be great. Thanks.