mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Add MedaStreamAudioDestinationNode::stream
This commit is contained in:
parent
bf9614edf7
commit
2a838d935b
2 changed files with 20 additions and 6 deletions
|
@ -8,10 +8,12 @@ use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions;
|
||||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||||
ChannelCountMode, ChannelInterpretation,
|
ChannelCountMode, ChannelInterpretation,
|
||||||
};
|
};
|
||||||
|
use crate::dom::bindings::codegen::Bindings::MediaStreamAudioDestinationNodeBinding::MediaStreamAudioDestinationNodeMethods;
|
||||||
use crate::dom::bindings::error::Fallible;
|
use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
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::root::{Dom, DomRoot};
|
||||||
|
use crate::dom::mediastream::MediaStream;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use servo_media::audio::node::AudioNodeInit;
|
use servo_media::audio::node::AudioNodeInit;
|
||||||
|
@ -21,6 +23,7 @@ use servo_media::ServoMedia;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MediaStreamAudioDestinationNode {
|
pub struct MediaStreamAudioDestinationNode {
|
||||||
node: AudioNode,
|
node: AudioNode,
|
||||||
|
stream: Dom<MediaStream>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MediaStreamAudioDestinationNode {
|
impl MediaStreamAudioDestinationNode {
|
||||||
|
@ -30,7 +33,8 @@ impl MediaStreamAudioDestinationNode {
|
||||||
options: &AudioNodeOptions,
|
options: &AudioNodeOptions,
|
||||||
) -> Fallible<MediaStreamAudioDestinationNode> {
|
) -> Fallible<MediaStreamAudioDestinationNode> {
|
||||||
let media = ServoMedia::get().unwrap();
|
let media = ServoMedia::get().unwrap();
|
||||||
let (socket, _id) = media.create_stream_and_socket(MediaStreamType::Audio);
|
let (socket, id) = media.create_stream_and_socket(MediaStreamType::Audio);
|
||||||
|
let stream = MediaStream::new_single(&context.global(), id, MediaStreamType::Audio);
|
||||||
let node_options = options.unwrap_or(
|
let node_options = options.unwrap_or(
|
||||||
2,
|
2,
|
||||||
ChannelCountMode::Explicit,
|
ChannelCountMode::Explicit,
|
||||||
|
@ -43,7 +47,10 @@ impl MediaStreamAudioDestinationNode {
|
||||||
1, // inputs
|
1, // inputs
|
||||||
0, // outputs
|
0, // outputs
|
||||||
)?;
|
)?;
|
||||||
Ok(MediaStreamAudioDestinationNode { node })
|
Ok(MediaStreamAudioDestinationNode {
|
||||||
|
node,
|
||||||
|
stream: Dom::from_ref(&stream),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
|
@ -65,3 +72,10 @@ impl MediaStreamAudioDestinationNode {
|
||||||
MediaStreamAudioDestinationNode::new(window, context, options)
|
MediaStreamAudioDestinationNode::new(window, context, options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl MediaStreamAudioDestinationNodeMethods for MediaStreamAudioDestinationNode {
|
||||||
|
/// https://webaudio.github.io/web-audio-api/#dom-mediastreamaudiodestinationnode-stream
|
||||||
|
fn Stream(&self) -> DomRoot<MediaStream> {
|
||||||
|
DomRoot::from_ref(&self.stream)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
[Exposed=Window]
|
[Exposed=Window]
|
||||||
interface MediaStreamAudioDestinationNode : AudioNode {
|
interface MediaStreamAudioDestinationNode : AudioNode {
|
||||||
[Throws] constructor (AudioContext context, optional AudioNodeOptions options = {});
|
[Throws] constructor (AudioContext context, optional AudioNodeOptions options = {});
|
||||||
// readonly attribute MediaStream stream;
|
readonly attribute MediaStream stream;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue