Skip to content
Permalink
Browse files

Add {MediaStream, MediaStreamTrack}.clone()

  • Loading branch information...
Manishearth committed May 7, 2019
1 parent 477ca17 commit 229ce3643156eff39b119429e6c579d32634eb5c
@@ -4,7 +4,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::reflector::{reflect_dom_object, DomObject};
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::DOMString;
use crate::dom::eventtarget::EventTarget;
@@ -98,4 +98,13 @@ impl MediaStreamMethods for MediaStream {
fn RemoveTrack(&self, track: &MediaStreamTrack) {
self.tracks.borrow_mut().retain(|x| *x != track);
}

/// https://w3c.github.io/mediacapture-main/#dom-mediastream-clone
fn Clone(&self) -> DomRoot<MediaStream> {
let new = MediaStream::new(&self.global());
for track in &*self.tracks.borrow() {
new.add_track(&track)
}
new
}
}
@@ -5,7 +5,7 @@
use crate::dom::bindings::codegen::Bindings::MediaStreamTrackBinding::{
self, MediaStreamTrackMethods,
};
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::eventtarget::EventTarget;
@@ -66,4 +66,9 @@ impl MediaStreamTrackMethods for MediaStreamTrack {
fn Id(&self) -> DOMString {
self.id.id().to_string().into()
}

/// https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-clone
fn Clone(&self) -> DomRoot<MediaStreamTrack> {
MediaStreamTrack::new(&self.global(), self.id, self.ty)
}
}
@@ -17,7 +17,7 @@ interface MediaStream : EventTarget {
MediaStreamTrack? getTrackById(DOMString trackId);
void addTrack(MediaStreamTrack track);
void removeTrack(MediaStreamTrack track);
// MediaStream clone();
MediaStream clone();
// readonly attribute boolean active;
// attribute EventHandler onaddtrack;
// attribute EventHandler onremovetrack;
@@ -15,7 +15,7 @@ interface MediaStreamTrack : EventTarget {
// attribute EventHandler onunmute;
// readonly attribute MediaStreamTrackState readyState;
// attribute EventHandler onended;
// MediaStreamTrack clone();
MediaStreamTrack clone();
// void stop();
// MediaTrackCapabilities getCapabilities();
// MediaTrackConstraints getConstraints();

0 comments on commit 229ce36

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