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