diff --git a/components/script/dom/mediastream.rs b/components/script/dom/mediastream.rs index 1c9c7646939..ff2c8f3a990 100644 --- a/components/script/dom/mediastream.rs +++ b/components/script/dom/mediastream.rs @@ -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] @@ -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 { + let this = Self::new(global); + let track = MediaStreamTrack::new(global, id, ty); + this.AddTrack(&track); + this + } + pub fn Constructor(global: &Window) -> Fallible> { Ok(MediaStream::new(&global.global())) }