| 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 | extern "C++" { |
| 20 | include!("livekit/helper.h"); |
| 21 | include!("livekit/media_stream_track.h"); |
| 22 | include!("livekit/audio_track.h"); |
| 23 | include!("livekit/video_track.h"); |
| 24 | |
| 25 | type MediaStreamTrack = crate::media_stream_track::ffi::MediaStreamTrack; |
| 26 | type AudioTrack = crate::audio_track::ffi::AudioTrack; |
| 27 | type VideoTrack = crate::video_track::ffi::VideoTrack; |
| 28 | type VideoTrackPtr = crate::helper::ffi::VideoTrackPtr; |
| 29 | type AudioTrackPtr = crate::helper::ffi::AudioTrackPtr; |
| 30 | } |
| 31 | |
| 32 | unsafe extern "C++" { |
| 33 | include!("livekit/media_stream.h"); |
| 34 | |
| 35 | type MediaStream; |
| 36 | |
| 37 | fn id(self: &MediaStream) -> String; |
| 38 | fn get_audio_tracks(self: &MediaStream) -> Vec<AudioTrackPtr>; |
| 39 | fn get_video_tracks(self: &MediaStream) -> Vec<VideoTrackPtr>; |
| 40 | fn find_audio_track(self: &MediaStream, track_id: String) -> SharedPtr<AudioTrack>; |
| 41 | fn find_video_track(self: &MediaStream, track_id: String) -> SharedPtr<VideoTrack>; |
| 42 | fn add_track(self: &MediaStream, audio_track: SharedPtr<MediaStreamTrack>) -> bool; |
| 43 | fn remove_track(self: &MediaStream, audio_track: SharedPtr<MediaStreamTrack>) -> bool; |
| 44 | |
| 45 | fn _shared_media_stream() -> SharedPtr<MediaStream>; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | impl_thread_safety!(ffi::MediaStream, Send + Sync); |