Skip to main content

gosuto_libwebrtc/native/
mod.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
15#[cfg(target_os = "android")]
16pub mod android;
17pub mod apm;
18pub mod audio_mixer;
19pub mod audio_resampler;
20pub mod audio_source;
21pub mod audio_stream;
22pub mod audio_track;
23pub mod data_channel;
24#[cfg(any(target_os = "macos", target_os = "windows", target_os = "linux"))]
25pub mod desktop_capturer;
26pub mod frame_cryptor;
27pub mod ice_candidate;
28pub mod media_stream;
29pub mod media_stream_track;
30pub mod peer_connection;
31pub mod peer_connection_factory;
32pub mod rtp_parameters;
33pub mod rtp_receiver;
34pub mod rtp_sender;
35pub mod rtp_transceiver;
36pub mod session_description;
37pub mod video_frame;
38pub mod video_source;
39pub mod video_stream;
40pub mod video_track;
41pub mod yuv_helper;
42
43use gosuto_webrtc_sys::{rtc_error as sys_err, webrtc as sys_rtc};
44
45use crate::{MediaType, RtcError, RtcErrorType};
46
47impl From<sys_err::ffi::RtcErrorType> for RtcErrorType {
48    fn from(value: sys_err::ffi::RtcErrorType) -> Self {
49        match value {
50            sys_err::ffi::RtcErrorType::InvalidState => Self::InvalidState,
51            _ => Self::Internal,
52        }
53    }
54}
55
56impl From<sys_err::ffi::RtcError> for RtcError {
57    fn from(value: sys_err::ffi::RtcError) -> Self {
58        Self { error_type: value.error_type.into(), message: value.message }
59    }
60}
61
62impl From<MediaType> for sys_rtc::ffi::MediaType {
63    fn from(value: MediaType) -> Self {
64        match value {
65            MediaType::Audio => Self::Audio,
66            MediaType::Video => Self::Video,
67            MediaType::Data => Self::Data,
68            MediaType::Unsupported => Self::Unsupported,
69        }
70    }
71}