servo_media_player/
context.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5//! `PlayerGLContext` is a trait to be used to pass the GL context for
6//! rendering purposes.
7//!
8//! The current consumer of this trait is the GL rendering mechanism
9//! for the GStreamer backend.
10//!
11//! The client application should implement this trait and pass the
12//! trait object to its `player` instance.
13
14#[derive(Clone, Debug, Deserialize, Serialize)]
15pub enum GlContext {
16    /// The EGL platform used primarily with the X11, Wayland and
17    /// Android window systems as well as on embedded Linux.
18    Egl(usize),
19    /// The GLX platform used primarily with the X11 window system.
20    Glx(usize),
21    Unknown,
22}
23
24#[derive(Clone, Debug, Deserialize, Serialize)]
25pub enum NativeDisplay {
26    /// The EGLDisplay memory address
27    Egl(usize),
28    /// XDisplay memory address
29    X11(usize),
30    /// wl_display memory address
31    Wayland(usize),
32    Headless,
33    Unknown,
34}
35
36#[derive(Clone, Debug, Deserialize, Serialize)]
37pub enum GlApi {
38    OpenGL,
39    OpenGL3,
40    Gles1,
41    Gles2,
42    None,
43}
44
45pub trait PlayerGLContext {
46    /// Returns the GL context living pointer wrapped by `GlContext`
47    fn get_gl_context(&self) -> GlContext;
48    /// Returns the living pointer to the native display structure
49    /// wrapped by `NativeDisplay`.
50    fn get_native_display(&self) -> NativeDisplay;
51    /// Returns the GL API of the context
52    fn get_gl_api(&self) -> GlApi;
53}