Skip to content
Permalink
Browse files

Add MediaStream.getTrackById()

  • Loading branch information...
Manishearth committed May 7, 2019
1 parent 70e1c29 commit 571c3d6d0e9785a611f39357ca9736259aa23004
Showing with 11 additions and 1 deletion.
  1. +10 −0 components/script/dom/mediastream.rs
  2. +1 −1 components/script/dom/webidls/MediaStream.webidl
@@ -6,6 +6,7 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::MediaStreamBinding::{self, MediaStreamMethods};
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::DOMString;
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::dom::mediastreamtrack::MediaStreamTrack;
@@ -73,4 +74,13 @@ impl MediaStreamMethods for MediaStream {
.map(|x| DomRoot::from_ref(&**x))
.collect()
}

/// https://w3c.github.io/mediacapture-main/#dom-mediastream-gettrackbyid
fn GetTrackById(&self, id: DOMString) -> Option<DomRoot<MediaStreamTrack>> {
self.tracks
.borrow()
.iter()
.find(|x| x.id().id().to_string() == &*id)
.map(|x| DomRoot::from_ref(&**x))
}
}
@@ -14,7 +14,7 @@ interface MediaStream : EventTarget {
sequence<MediaStreamTrack> getAudioTracks();
sequence<MediaStreamTrack> getVideoTracks();
sequence<MediaStreamTrack> getTracks();
// MediaStreamTrack? getTrackById(DOMString trackId);
MediaStreamTrack? getTrackById(DOMString trackId);
// void addTrack(MediaStreamTrack track);
// void removeTrack(MediaStreamTrack track);
// MediaStream clone();

0 comments on commit 571c3d6

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