Skip to content

Commit

Permalink
Producer: don't try to clone track if track.clone() is not supported …
Browse files Browse the repository at this point in the history
…(React-Native)
  • Loading branch information
ibc committed Jan 6, 2018
1 parent f0e4928 commit 37a99da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@
* Should not ignore pseudo media codecs:
* telephone-event
* CN


### React-Native (react-native-webrtc)

* It does not support `track.close()` so we must not do it and must document it.
- Done. Doc missing.

* In iOS, we must use a new stream `id` (in the `a=msid` line) for each new received `track`.
14 changes: 11 additions & 3 deletions lib/Producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ export default class Producer extends EnhancedEventEmitter
// @type {MediaStreamTrack}
this._originalTrack = track;

// Track cloned from the original one.
// Track cloned from the original one (if supported).
// @type {MediaStreamTrack}
this._track = track.clone();
if (typeof track.clone === 'function')
this._track = track.clone();
else
this._track = track;

// App custom data.
// @type {Any}
Expand Down Expand Up @@ -455,7 +458,12 @@ export default class Producer extends EnhancedEventEmitter
else if (track.readyState === 'ended')
return Promise.reject(new Error('track.readyState is "ended"'));

const clonedTrack = track.clone();
let clonedTrack = track.clone();

if (typeof track.clone === 'function')
clonedTrack = track.clone();
else
clonedTrack = track;

return Promise.resolve()
.then(() =>
Expand Down

0 comments on commit 37a99da

Please sign in to comment.