| 1 | // Copyright 2025 LiveKit, Inc. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | use thiserror::Error; |
| 16 | |
| 17 | #[cfg_attr(target_arch = "wasm32", path = "web/mod.rs")] |
| 18 | #[cfg_attr(not(target_arch = "wasm32"), path = "native/mod.rs")] |
| 19 | mod imp; |
| 20 | |
| 21 | mod enum_dispatch; |
| 22 | |
| 23 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] |
| 24 | pub enum MediaType { |
| 25 | Audio, |
| 26 | Video, |
| 27 | Data, |
| 28 | Unsupported, |
| 29 | } |
| 30 | |
| 31 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] |
| 32 | pub enum RtcErrorType { |
| 33 | Internal, |
| 34 | InvalidSdp, |
| 35 | InvalidState, |
| 36 | } |
| 37 | |
| 38 | #[derive(Error, Debug)] |
| 39 | #[error("an RtcError occurred: {error_type:?} - {message}")] |
| 40 | pub struct RtcError { |
| 41 | pub error_type: RtcErrorType, |
| 42 | pub message: String, |
| 43 | } |
| 44 | |
| 45 | pub mod audio_frame; |
| 46 | pub mod audio_source; |
| 47 | pub mod audio_stream; |
| 48 | pub mod audio_track; |
| 49 | pub mod data_channel; |
| 50 | #[cfg(any(target_os = "macos", target_os = "windows", target_os = "linux"))] |
| 51 | pub mod desktop_capturer; |
| 52 | pub mod ice_candidate; |
| 53 | pub mod media_stream; |
| 54 | pub mod media_stream_track; |
| 55 | pub mod peer_connection; |
| 56 | pub mod peer_connection_factory; |
| 57 | pub mod prelude; |
| 58 | pub mod rtp_parameters; |
| 59 | pub mod rtp_receiver; |
| 60 | pub mod rtp_sender; |
| 61 | pub mod rtp_transceiver; |
| 62 | pub mod session_description; |
| 63 | pub mod stats; |
| 64 | pub mod video_frame; |
| 65 | pub mod video_source; |
| 66 | pub mod video_stream; |
| 67 | pub mod video_track; |
| 68 | |
| 69 | #[cfg(not(target_arch = "wasm32"))] |
| 70 | pub mod native { |
| 71 | pub use webrtc_sys::webrtc::ffi::create_random_uuid; |
| 72 | |
| 73 | pub use crate::imp::{ |
| 74 | apm, audio_mixer, audio_resampler, frame_cryptor, packet_trailer, yuv_helper, |
| 75 | }; |
| 76 | } |
| 77 | |
| 78 | #[cfg(target_os = "android")] |
| 79 | pub mod android { |
| 80 | pub use crate::imp::android::*; |
| 81 | } |