mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Add media (WindowGLContext) module in canvas_trait
This module adds a structure (WindowGLContext) which holds the OpenGL parameters that are going to be used by servo-media player to render video frames using OpenGL. In order to fill this structure, three new methods were added to WindowMethods trait. In this patch only the Glutin-based implementation provides a simple boilerplate. The WindowGLContext is created in the entry point of libservo, when the application window is created, and later passed to the constellation, the pipeline and to the window element in dom, thus htmlmediaelement has a mean to obtain these parameters via its window.
This commit is contained in:
parent
e9f46f9d72
commit
9f4f9dc750
16 changed files with 133 additions and 26 deletions
|
@ -71,7 +71,6 @@ use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseLis
|
|||
use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType};
|
||||
use script_layout_interface::HTMLMediaData;
|
||||
use servo_config::pref;
|
||||
use servo_media::player::context::{GlContext, NativeDisplay, PlayerGLContext};
|
||||
use servo_media::player::frame::{Frame, FrameRenderer};
|
||||
use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, StreamType};
|
||||
use servo_media::{ServoMedia, SupportsMediaType};
|
||||
|
@ -162,16 +161,6 @@ impl FrameRenderer for MediaFrameRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
struct PlayerContextDummy();
|
||||
impl PlayerGLContext for PlayerContextDummy {
|
||||
fn get_gl_context(&self) -> GlContext {
|
||||
return GlContext::Unknown;
|
||||
}
|
||||
fn get_native_display(&self) -> NativeDisplay {
|
||||
return NativeDisplay::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
#[must_root]
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
enum SrcObject {
|
||||
|
@ -1222,22 +1211,23 @@ impl HTMLMediaElement {
|
|||
_ => StreamType::Seekable,
|
||||
};
|
||||
|
||||
let window = window_from_node(self);
|
||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||
let renderer: Option<Arc<Mutex<dyn FrameRenderer>>> = match self.media_type_id() {
|
||||
HTMLMediaElementTypeId::HTMLAudioElement => None,
|
||||
HTMLMediaElementTypeId::HTMLVideoElement => Some(self.frame_renderer.clone()),
|
||||
};
|
||||
|
||||
let player = ServoMedia::get().unwrap().create_player(
|
||||
stream_type,
|
||||
action_sender,
|
||||
renderer,
|
||||
Box::new(PlayerContextDummy()),
|
||||
Box::new(window.get_player_context()),
|
||||
);
|
||||
|
||||
*self.player.borrow_mut() = Some(player);
|
||||
|
||||
let trusted_node = Trusted::new(self);
|
||||
let window = window_from_node(self);
|
||||
let (task_source, canceller) = window
|
||||
.task_manager()
|
||||
.media_element_task_source_with_canceller();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue