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
14use malloc_size_of_derive::MallocSizeOf;
15use serde::{Deserialize, Serialize};
16
17#[derive(Clone, Debug, Deserialize, Serialize, MallocSizeOf)]
18pub enum GlContext {
19    /// The EGL platform used primarily with the X11, Wayland and
20    /// Android window systems as well as on embedded Linux.
21    Egl(usize),
22    /// The GLX platform used primarily with the X11 window system.
23    Glx(usize),
24    Unknown,
25}
26
27#[derive(Clone, Debug, Deserialize, Serialize, MallocSizeOf)]
28pub enum NativeDisplay {
29    /// The EGLDisplay memory address
30    Egl(usize),
31    /// XDisplay memory address
32    X11(usize),
33    /// wl_display memory address
34    Wayland(usize),
35    Headless,
36    Unknown,
37}
38
39#[derive(Clone, Debug, Deserialize, Serialize, MallocSizeOf)]
40pub enum GlApi {
41    OpenGL,
42    OpenGL3,
43    Gles1,
44    Gles2,
45    None,
46}
47
48pub trait PlayerGLContext {
49    /// Returns the GL context living pointer wrapped by `GlContext`
50    fn get_gl_context(&self) -> GlContext;
51    /// Returns the living pointer to the native display structure
52    /// wrapped by `NativeDisplay`.
53    fn get_native_display(&self) -> NativeDisplay;
54    /// Returns the GL API of the context
55    fn get_gl_api(&self) -> GlApi;
56}