mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add RTCPeerConnection::AddStream
This commit is contained in:
parent
8b0719a6f2
commit
2d8ac7825c
3 changed files with 25 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::MediaStreamBinding;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
|
@ -9,19 +10,20 @@ use crate::dom::eventtarget::EventTarget;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_media::webrtc::MediaStream as BackendMediaStream;
|
||||
use std::mem;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct MediaStream {
|
||||
eventtarget: EventTarget,
|
||||
#[ignore_malloc_size_of = "defined in servo-media"]
|
||||
tracks: Vec<Box<BackendMediaStream>>,
|
||||
tracks: DomRefCell<Vec<Box<BackendMediaStream>>>,
|
||||
}
|
||||
|
||||
impl MediaStream {
|
||||
pub fn new_inherited(tracks: Vec<Box<BackendMediaStream>>) -> MediaStream {
|
||||
MediaStream {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
tracks,
|
||||
tracks: DomRefCell::new(tracks),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,4 +34,12 @@ impl MediaStream {
|
|||
MediaStreamBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_tracks(&self) -> Vec<Box<BackendMediaStream>> {
|
||||
// XXXManishearth we have hard ownership constraints here so we actually empty the vec,
|
||||
// ideally we should only have a media stream id here, or servo-media hands
|
||||
// out Arcs
|
||||
let mut tracks = self.tracks.borrow_mut();
|
||||
mem::replace(&mut *tracks, vec![])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue