BlueGit

ict rusty-teams

Files

rusty-teams / vendor / libwebrtc / src / native / media_stream.rs

media_stream.rs

media_stream.rs 1.5 KiB Download Raw
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 cxx::SharedPtr;
16use webrtc_sys::media_stream as sys_ms;
17
18use crate::{
19 audio_track,
20 imp::{audio_track::RtcAudioTrack, video_track::RtcVideoTrack},
21 video_track,
22};
23
24#[derive(Clone)]
25pub struct MediaStream {
26 pub(crate) sys_handle: SharedPtr<sys_ms::ffi::MediaStream>,
27}
28
29impl MediaStream {
30 pub fn id(&self) -> String {
31 self.sys_handle.id()
32 }
33
34 pub fn audio_tracks(&self) -> Vec<audio_track::RtcAudioTrack> {
35 self.sys_handle
36 .get_audio_tracks()
37 .into_iter()
38 .map(|t| audio_track::RtcAudioTrack { handle: RtcAudioTrack { sys_handle: t.ptr } })
39 .collect()
40 }
41
42 pub fn video_tracks(&self) -> Vec<video_track::RtcVideoTrack> {
43 self.sys_handle
44 .get_video_tracks()
45 .into_iter()
46 .map(|t| video_track::RtcVideoTrack { handle: RtcVideoTrack::new(t.ptr) })
47 .collect()
48 }
49}