a07b3451a3
* Create README.md * add example * crates & examples * fix syntax * add LICENSE * thirdparty LICENSE * rearrange repo * fix build * egui versions * prepare publish * fix demo compilation * add test ci * Update rust.yml * forgot runs-on * install protoc before building * avoid rate limit * include submodules * updates to readme * cache rust builds Co-authored-by: David Zhao <dz@livekit.io> Co-authored-by: David Zhao <david@davidzhao.com>
32 lines
1011 B
Rust
32 lines
1011 B
Rust
use crate::room::track::local_video_track::LocalVideoTrack;
|
|
use crate::room::track::remote_video_track::RemoteVideoTrack;
|
|
use crate::room::track::TrackHandle;
|
|
use std::sync::Arc;
|
|
|
|
#[derive(Clone)]
|
|
pub enum VideoTrackHandle {
|
|
Local(Arc<LocalVideoTrack>),
|
|
Remote(Arc<RemoteVideoTrack>),
|
|
}
|
|
|
|
impl From<VideoTrackHandle> for TrackHandle {
|
|
fn from(video_track: VideoTrackHandle) -> Self {
|
|
match video_track {
|
|
VideoTrackHandle::Local(local_video) => Self::LocalVideo(local_video),
|
|
VideoTrackHandle::Remote(remote_video) => Self::RemoteVideo(remote_video),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl TryFrom<TrackHandle> for VideoTrackHandle {
|
|
type Error = &'static str;
|
|
|
|
fn try_from(track: TrackHandle) -> Result<Self, Self::Error> {
|
|
match track {
|
|
TrackHandle::LocalVideo(local_video) => Ok(Self::Local(local_video)),
|
|
TrackHandle::RemoteVideo(remote_video) => Ok(Self::Remote(remote_video)),
|
|
_ => Err("not a video track"),
|
|
}
|
|
}
|
|
}
|