Skip to main content

gosuto_libwebrtc/
lib.rs

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
15use thiserror::Error;
16
17#[cfg_attr(target_arch = "wasm32", path = "web/mod.rs")]
18#[cfg_attr(not(target_arch = "wasm32"), path = "native/mod.rs")]
19mod imp;
20
21#[derive(Debug, Copy, Clone, PartialEq, Eq)]
22pub enum MediaType {
23    Audio,
24    Video,
25    Data,
26    Unsupported,
27}
28
29#[derive(Debug, Copy, Clone, PartialEq, Eq)]
30pub enum RtcErrorType {
31    Internal,
32    InvalidSdp,
33    InvalidState,
34}
35
36#[derive(Error, Debug)]
37#[error("an RtcError occured: {error_type:?} - {message}")]
38pub struct RtcError {
39    pub error_type: RtcErrorType,
40    pub message: String,
41}
42
43pub mod audio_frame;
44pub mod audio_source;
45pub mod audio_stream;
46pub mod audio_track;
47pub mod data_channel;
48#[cfg(any(target_os = "macos", target_os = "windows", target_os = "linux"))]
49pub mod desktop_capturer;
50pub mod ice_candidate;
51pub mod media_stream;
52pub mod media_stream_track;
53pub mod peer_connection;
54pub mod peer_connection_factory;
55pub mod prelude;
56pub mod rtp_parameters;
57pub mod rtp_receiver;
58pub mod rtp_sender;
59pub mod rtp_transceiver;
60pub mod session_description;
61pub mod stats;
62pub mod video_frame;
63pub mod video_source;
64pub mod video_stream;
65pub mod video_track;
66
67#[cfg(not(target_arch = "wasm32"))]
68pub mod native {
69    pub use gosuto_webrtc_sys::webrtc::ffi::create_random_uuid;
70
71    pub use crate::imp::{apm, audio_mixer, audio_resampler, frame_cryptor, yuv_helper};
72}
73
74#[cfg(target_os = "android")]
75pub mod android {
76    pub use crate::imp::android::*;
77}