Skip to content
Permalink
Browse files

Add MediaStream.addTrack() and MediaStream.removeTrack()

  • Loading branch information...
Manishearth committed May 7, 2019
1 parent 571c3d6 commit 477ca175e38b232535bdad47eb71f1f2152b4da4
Showing with 17 additions and 2 deletions.
  1. +15 −0 components/script/dom/mediastream.rs
  2. +2 −2 components/script/dom/webidls/MediaStream.webidl
@@ -83,4 +83,19 @@ impl MediaStreamMethods for MediaStream {
.find(|x| x.id().id().to_string() == &*id)
.map(|x| DomRoot::from_ref(&**x))
}

/// https://w3c.github.io/mediacapture-main/#dom-mediastream-addtrack
fn AddTrack(&self, track: &MediaStreamTrack) {
let existing = self.tracks.borrow().iter().find(|x| *x == &track).is_some();

if existing {
return;
}
self.add_track(track)
}

/// https://w3c.github.io/mediacapture-main/#dom-mediastream-removetrack
fn RemoveTrack(&self, track: &MediaStreamTrack) {
self.tracks.borrow_mut().retain(|x| *x != track);
}
}
@@ -15,8 +15,8 @@ interface MediaStream : EventTarget {
sequence<MediaStreamTrack> getVideoTracks();
sequence<MediaStreamTrack> getTracks();
MediaStreamTrack? getTrackById(DOMString trackId);
// void addTrack(MediaStreamTrack track);
// void removeTrack(MediaStreamTrack track);
void addTrack(MediaStreamTrack track);
void removeTrack(MediaStreamTrack track);
// MediaStream clone();
// readonly attribute boolean active;
// attribute EventHandler onaddtrack;

0 comments on commit 477ca17

Please sign in to comment.
You can’t perform that action at this time.