Skip to content

Commit

Permalink
Add MediaStream::new_single()
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Jul 2, 2020
1 parent 6a001e7 commit bf9614e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions components/script/dom/mediastream.rs
Expand Up @@ -13,6 +13,7 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::mediastreamtrack::MediaStreamTrack;
use crate::dom::window::Window;
use dom_struct::dom_struct;
use servo_media::streams::registry::MediaStreamId;
use servo_media::streams::MediaStreamType;

#[dom_struct]
Expand All @@ -34,6 +35,17 @@ impl MediaStream {
reflect_dom_object(Box::new(MediaStream::new_inherited()), global)
}

pub fn new_single(
global: &GlobalScope,
id: MediaStreamId,
ty: MediaStreamType,
) -> DomRoot<MediaStream> {
let this = Self::new(global);
let track = MediaStreamTrack::new(global, id, ty);
this.AddTrack(&track);
this
}

pub fn Constructor(global: &Window) -> Fallible<DomRoot<MediaStream>> {
Ok(MediaStream::new(&global.global()))
}
Expand Down

0 comments on commit bf9614e

Please sign in to comment.