Skip to content
Permalink
Browse files

Register pipeline instead of browsing contexts for media instances

  • Loading branch information...
ferjm committed Sep 17, 2019
1 parent 7b653ca commit 51ed44c77d999daee20550d6177aa4d8f96734b3
@@ -23,7 +23,7 @@ use crate::dom::promise::Promise;
use crate::dom::window::Window;
use crate::task_source::TaskSource;
use dom_struct::dom_struct;
use msg::constellation_msg::BrowsingContextId;
use msg::constellation_msg::PipelineId;
use servo_media::audio::context::{LatencyCategory, ProcessingState, RealTimeAudioContextOptions};
use std::rc::Rc;

@@ -40,14 +40,11 @@ pub struct AudioContext {
impl AudioContext {
#[allow(unrooted_must_root)]
// https://webaudio.github.io/web-audio-api/#AudioContext-constructors
fn new_inherited(
options: &AudioContextOptions,
browsing_context_id: BrowsingContextId,
) -> AudioContext {
fn new_inherited(options: &AudioContextOptions, pipeline_id: PipelineId) -> AudioContext {
// Steps 1-3.
let context = BaseAudioContext::new_inherited(
BaseAudioContextOptions::AudioContext(options.into()),
browsing_context_id,
pipeline_id,
);

// Step 4.1.
@@ -70,8 +67,10 @@ impl AudioContext {

#[allow(unrooted_must_root)]
pub fn new(window: &Window, options: &AudioContextOptions) -> DomRoot<AudioContext> {
let browsing_context_id = window.window_proxy().top_level_browsing_context_id().0;
let context = AudioContext::new_inherited(options, browsing_context_id);
let pipeline_id = window
.pipeline_id()
.expect("Cannot create AudioContext outside of a pipeline");
let context = AudioContext::new_inherited(options, pipeline_id);
let context = reflect_dom_object(Box::new(context), window, AudioContextBinding::Wrap);
context.resume();
context
@@ -51,7 +51,7 @@ use crate::task_source::TaskSource;
use dom_struct::dom_struct;
use js::rust::CustomAutoRooterGuard;
use js::typedarray::ArrayBuffer;
use msg::constellation_msg::BrowsingContextId;
use msg::constellation_msg::PipelineId;
use servo_media::audio::context::{AudioContext, AudioContextOptions, ProcessingState};
use servo_media::audio::context::{OfflineAudioContextOptions, RealTimeAudioContextOptions};
use servo_media::audio::decoder::AudioDecoderCallbacks;
@@ -109,7 +109,7 @@ impl BaseAudioContext {
#[allow(unrooted_must_root)]
pub fn new_inherited(
options: BaseAudioContextOptions,
browsing_context_id: BrowsingContextId,
pipeline_id: PipelineId,
) -> BaseAudioContext {
let (sample_rate, channel_count) = match options {
BaseAudioContextOptions::AudioContext(ref opt) => (opt.sample_rate, 2),
@@ -118,10 +118,8 @@ impl BaseAudioContext {
},
};

let client_context_id = ClientContextId::build(
browsing_context_id.namespace_id.0,
browsing_context_id.index.0.get(),
);
let client_context_id =
ClientContextId::build(pipeline_id.namespace_id.0, pipeline_id.index.0.get());
let context = BaseAudioContext {
eventtarget: EventTarget::new_inherited(),
audio_context_impl: ServoMedia::get()
@@ -1329,11 +1329,11 @@ impl HTMLMediaElement {
HTMLMediaElementTypeId::HTMLVideoElement => Some(self.frame_renderer.clone()),
};

let browsing_context_id = window.window_proxy().top_level_browsing_context_id().0;
let client_context_id = ClientContextId::build(
browsing_context_id.namespace_id.0,
browsing_context_id.index.0.get(),
);
let pipeline_id = window
.pipeline_id()
.expect("Cannot create player outside of a pipeline");
let client_context_id =
ClientContextId::build(pipeline_id.namespace_id.0, pipeline_id.index.0.get());
let player = ServoMedia::get().unwrap().create_player(
&client_context_id,
stream_type,
@@ -23,7 +23,7 @@ use crate::dom::promise::Promise;
use crate::dom::window::Window;
use crate::task_source::TaskSource;
use dom_struct::dom_struct;
use msg::constellation_msg::BrowsingContextId;
use msg::constellation_msg::PipelineId;
use servo_media::audio::context::OfflineAudioContextOptions as ServoMediaOfflineAudioContextOptions;
use std::cell::Cell;
use std::rc::Rc;
@@ -47,7 +47,7 @@ impl OfflineAudioContext {
channel_count: u32,
length: u32,
sample_rate: f32,
browsing_context_id: BrowsingContextId,
pipeline_id: PipelineId,
) -> OfflineAudioContext {
let options = ServoMediaOfflineAudioContextOptions {
channels: channel_count as u8,
@@ -56,7 +56,7 @@ impl OfflineAudioContext {
};
let context = BaseAudioContext::new_inherited(
BaseAudioContextOptions::OfflineAudioContext(options),
browsing_context_id,
pipeline_id,
);
OfflineAudioContext {
context,
@@ -82,13 +82,11 @@ impl OfflineAudioContext {
{
return Err(Error::NotSupported);
}
let browsing_context_id = window.window_proxy().top_level_browsing_context_id().0;
let context = OfflineAudioContext::new_inherited(
channel_count,
length,
sample_rate,
browsing_context_id,
);
let pipeline_id = window
.pipeline_id()
.expect("Cannot create audio context outside of a pipeline");
let context =
OfflineAudioContext::new_inherited(channel_count, length, sample_rate, pipeline_id);
Ok(reflect_dom_object(
Box::new(context),
window,

0 comments on commit 51ed44c

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