Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receive streams in WebRTC (and MediaStreamTrack support) #23342

Merged
merged 12 commits into from May 9, 2019

Add MediaStream.getVideoTracks(), MediaStream.getAudioTracks()

  • Loading branch information
Manishearth committed May 8, 2019
commit 70e1c29ae98f0dd4090c0093850ee07faba0dcbe
@@ -10,6 +10,7 @@ use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::dom::mediastreamtrack::MediaStreamTrack;
use dom_struct::dom_struct;
use servo_media::streams::MediaStreamType;
use std::cell::Ref;

#[dom_struct]
@@ -52,4 +53,24 @@ impl MediaStreamMethods for MediaStream {
.map(|x| DomRoot::from_ref(&**x))
.collect()
}

/// https://w3c.github.io/mediacapture-main/#dom-mediastream-getaudiotracks
fn GetAudioTracks(&self) -> Vec<DomRoot<MediaStreamTrack>> {
self.tracks
.borrow()
.iter()
.filter(|x| x.ty() == MediaStreamType::Audio)
.map(|x| DomRoot::from_ref(&**x))
.collect()
}

/// https://w3c.github.io/mediacapture-main/#dom-mediastream-getvideotracks
fn GetVideoTracks(&self) -> Vec<DomRoot<MediaStreamTrack>> {
self.tracks
.borrow()
.iter()
.filter(|x| x.ty() == MediaStreamType::Video)
.map(|x| DomRoot::from_ref(&**x))
.collect()
}
}
@@ -11,8 +11,8 @@
[Exposed=Window, Pref="dom.webrtc.enabled"]
interface MediaStream : EventTarget {
// readonly attribute DOMString id;
// sequence<MediaStreamTrack> getAudioTracks();
// sequence<MediaStreamTrack> getVideoTracks();
sequence<MediaStreamTrack> getAudioTracks();
sequence<MediaStreamTrack> getVideoTracks();
sequence<MediaStreamTrack> getTracks();
// MediaStreamTrack? getTrackById(DOMString trackId);
// void addTrack(MediaStreamTrack track);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.