| 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 std::fmt::Debug; |
| 16 | |
| 17 | use crate::{audio_track::RtcAudioTrack, imp::media_stream as imp_ms, video_track::RtcVideoTrack}; |
| 18 | |
| 19 | #[derive(Clone)] |
| 20 | pub struct MediaStream { |
| 21 | pub(crate) handle: imp_ms::MediaStream, |
| 22 | } |
| 23 | |
| 24 | impl MediaStream { |
| 25 | pub fn id(&self) -> String { |
| 26 | self.handle.id() |
| 27 | } |
| 28 | |
| 29 | pub fn audio_tracks(&self) -> Vec<RtcAudioTrack> { |
| 30 | self.handle.audio_tracks() |
| 31 | } |
| 32 | |
| 33 | pub fn video_tracks(&self) -> Vec<RtcVideoTrack> { |
| 34 | self.handle.video_tracks() |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | impl Debug for MediaStream { |
| 39 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 40 | f.debug_struct("MediaStream") |
| 41 | .field("id", &self.id()) |
| 42 | .field("audio_tracks", &self.audio_tracks()) |
| 43 | .field("video_tracks", &self.video_tracks()) |
| 44 | .finish() |
| 45 | } |
| 46 | } |