feross / feross/simple-peer

peer.addTrack(), peer.addStream() throwing error when adding the user's displayMedia to an existing peer stream(camera and mic stream).

Open
#805 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.8k
Forks
983
PR merge metrics
No merged PRs in 30d

Description

**What version of this package are you using?**
9.11.0

**What operating system, Node.js, and npm version?**
Windows 10
Node version - 14.16.0
npm version - 6.14.11

**What happened?**
I created a mesh network of peers and passed the users' video and audio streams as the stream when establishing the connection. When I tried to add the user's navigator.mediaDevices.getDisplayMedia() stream to the existing peer, the peer connection gets destroyed and the following error stack is observed:
![image_2021-04-30_113232](https://user-images.githubusercontent.com/54759804/116654922-c08c8800-a9a7-11eb-96c7-96fb6d291b86.png)

the same peer signaling method was working fine when I used it for establishing the peer connection. However, this error is observed when I try to add the new Stream or add a new Track to the existing stream which was passed when creating the peer.

```
// initiator peer
const peer1 = new Peer({
initiator:true,
trickle: false,
stream1 /* stream is a state variable containing a MediaStream object with the user's video and audio stream */
});

const peer2 = new Peer({
initiator:false,
trickle: false,
stream2 /* stream is a state variable containing a MediaStream object with the user's video and audio stream */
});

//both peers got their respective streams. the signals were exchanged via socket.io
//adding screen stream/ track

navigator.mediaDevices.getDisplayMedia({cursor:true}).then(str =>{
let track = str.getTracks()[0] // only has one track
peer1.addTrack(track , stream1);
/* tried adding a stream as well and observed the same error
peer1.addStream(str);
});
```

**What did you expect to happen?**
The expectation was to still have the peer connection established with the new streams/tracks being provided to the users.

**Are you willing to submit a pull request to fix this bug?**
No.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.