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