| 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 crate::impl_thread_safety; |
| 16 | |
| 17 | #[cxx::bridge(namespace = "livekit_ffi")] |
| 18 | pub mod ffi { |
| 19 | #[derive(Debug)] |
| 20 | #[repr(i32)] |
| 21 | pub enum MediaType { |
| 22 | Audio, |
| 23 | Video, |
| 24 | Data, |
| 25 | Unsupported, |
| 26 | } |
| 27 | |
| 28 | #[derive(Debug)] |
| 29 | #[repr(i32)] |
| 30 | pub enum Priority { |
| 31 | VeryLow, |
| 32 | Low, |
| 33 | Medium, |
| 34 | High, |
| 35 | } |
| 36 | |
| 37 | #[derive(Debug)] |
| 38 | #[repr(i32)] |
| 39 | pub enum RtpTransceiverDirection { |
| 40 | SendRecv, |
| 41 | SendOnly, |
| 42 | RecvOnly, |
| 43 | Inactive, |
| 44 | Stopped, |
| 45 | } |
| 46 | |
| 47 | #[derive(Debug)] |
| 48 | #[repr(i32)] |
| 49 | pub enum LoggingSeverity { |
| 50 | Verbose, |
| 51 | Info, |
| 52 | Warning, |
| 53 | Error, |
| 54 | None, |
| 55 | } |
| 56 | |
| 57 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 58 | #[repr(i32)] |
| 59 | pub enum VideoEncoderBackend { |
| 60 | Auto, |
| 61 | Software, |
| 62 | Hardware, |
| 63 | Nvenc, |
| 64 | Vaapi, |
| 65 | VideoToolbox, |
| 66 | PreEncoded, |
| 67 | } |
| 68 | |
| 69 | unsafe extern "C++" { |
| 70 | include!("livekit/webrtc.h"); |
| 71 | |
| 72 | type LogSink; |
| 73 | |
| 74 | fn create_random_uuid() -> String; |
| 75 | fn video_encoder_backend_list() -> Vec<VideoEncoderBackend>; |
| 76 | fn new_log_sink(fnc: fn(String, LoggingSeverity)) -> UniquePtr<LogSink>; |
| 77 | fn tune_windows_camera(target: &str); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | impl_thread_safety!(ffi::LogSink, Send + Sync); |