Skip to main content

servo_media_streams/
lib.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 https://mozilla.org/MPL/2.0/. */
4
5pub mod capture;
6pub mod device_monitor;
7pub mod registry;
8
9use std::any::Any;
10
11use malloc_size_of::MallocSizeOf;
12use malloc_size_of_derive::MallocSizeOf;
13pub use registry::*;
14
15pub trait MediaStream: Any + Send {
16    fn as_any(&self) -> &dyn Any;
17    fn as_mut_any(&mut self) -> &mut dyn Any;
18    fn set_id(&mut self, id: registry::MediaStreamId);
19    fn ty(&self) -> MediaStreamType;
20}
21
22/// A MediaSocket is a way for a backend to represent a
23/// yet-to-be-connected source side of a MediaStream
24pub trait MediaSocket: Any + Send + MallocSizeOf {
25    fn as_any(&self) -> &dyn Any;
26}
27
28/// This isn't part of the webrtc spec; it's a leaky abstaction while media streams
29/// are under development and example consumers need to be able to inspect them.
30pub trait MediaOutput: Send {
31    fn add_stream(&mut self, stream: &registry::MediaStreamId);
32}
33
34#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq)]
35pub enum MediaStreamType {
36    Video,
37    Audio,
38}