Skip to main content

webrtc_sys/
webrtc.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 crate::impl_thread_safety;
16
17#[cxx::bridge(namespace = "livekit_ffi")]
18pub 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    unsafe extern "C++" {
58        include!("livekit/webrtc.h");
59
60        type LogSink;
61
62        fn create_random_uuid() -> String;
63        fn new_log_sink(fnc: fn(String, LoggingSeverity)) -> UniquePtr<LogSink>;
64    }
65}
66
67impl_thread_safety!(ffi::LogSink, Send + Sync);