gosuto_livekit/room/track/
video_track.rs1use gosuto_libwebrtc::prelude::*;
16use livekit_protocol as proto;
17use livekit_protocol::enum_dispatch;
18
19use super::track_dispatch;
20use crate::prelude::*;
21
22#[derive(Clone, Debug)]
23pub enum VideoTrack {
24 Local(LocalVideoTrack),
25 Remote(RemoteVideoTrack),
26}
27
28impl VideoTrack {
29 track_dispatch!([Local, Remote]);
30
31 #[inline]
32 pub fn rtc_track(&self) -> RtcVideoTrack {
33 match self {
34 Self::Local(track) => track.rtc_track(),
35 Self::Remote(track) => track.rtc_track(),
36 }
37 }
38}
39
40impl From<VideoTrack> for Track {
41 fn from(track: VideoTrack) -> Self {
42 match track {
43 VideoTrack::Local(track) => Self::LocalVideo(track),
44 VideoTrack::Remote(track) => Self::RemoteVideo(track),
45 }
46 }
47}
48
49impl TryFrom<Track> for VideoTrack {
50 type Error = &'static str;
51
52 fn try_from(track: Track) -> Result<Self, Self::Error> {
53 match track {
54 Track::LocalVideo(track) => Ok(Self::Local(track)),
55 Track::RemoteVideo(track) => Ok(Self::Remote(track)),
56 _ => Err("not a video track"),
57 }
58 }
59}