Fallback to addStream when addTrack is not supported
See original GitHub issueHi,
Using Simple Peer together with older webrtc API such as https://github.com/oney/react-native-webrtc where addTrack is not supported. Results in stream not being created in the Peer constructor, it also results in a chrash if addStream is used directly.
On line 139 in index.js:
if ('addTrack' in self._pc) {
if (self.streams) {
self.streams.forEach(function (stream) {
self.addStream(stream)
})
}
self._pc.ontrack = function (event) {
self._onTrack(event)
}
}
This makes it so that the stream is not added and no feedback is given to the user of Simple Peer.
Using the peer.addStream method doesn’t have the same check.
On line 275 in index.js:
var sender = self._pc.addTrack(track, stream)
Here addTrack is used without checking if addTrack exists.
I have made a workaround that enables me to send stream from android app to a chrome browser. I will make a PR shortly.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
How to update from addStream to addTrack correctly?
Try: this.peer.addStream(this.myStream). Note: peer object has a method ...
Read more >npm:simple-peer-chicho - Skypack.dev
Simple one-to-one WebRTC video/voice and data channels.
Read more >RTCPeerConnection.addStream() - Web APIs - MDN Web Docs
The obsolete RTCPeerConnection method addStream() adds a MediaStream as a local source of audio or video. Instead of using this obsolete method ...
Read more >pc/peer_connection.cc - external/webrtc - Git at Google
RTC_CHECK(!IsUnifiedPlan()) << "AddStream is not available with Unified Plan ". "SdpSemantics. Please use AddTrack instead.";.
Read more >Using DTMF with WebRTC - Web APIs
In order to more fully support audio/video conferencing, WebRTC supports sending ... supports addTrack() ; if it doesn't, we'll fall back to addStream()...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi guys, If you want to use simple-peer in React Native need some changes:
now the other side for using this stream use like this:
tested on version 9.7.2 and work fine on react native, Regrads
hello @owodunni, how did you end up solving your issue? I am stuck with this same issue, and can’t figure out what to do. please help.