1use collections::HashMap;
2
3mod remote_video_track_view;
4pub use remote_video_track_view::{RemoteVideoTrackView, RemoteVideoTrackViewEvent};
5
6#[cfg(not(any(
7 test,
8 feature = "test-support",
9 all(target_os = "windows", target_env = "gnu")
10)))]
11mod livekit_client;
12#[cfg(not(any(
13 test,
14 feature = "test-support",
15 all(target_os = "windows", target_env = "gnu")
16)))]
17pub use livekit_client::*;
18
19#[cfg(any(
20 test,
21 feature = "test-support",
22 all(target_os = "windows", target_env = "gnu")
23))]
24mod mock_client;
25#[cfg(any(
26 test,
27 feature = "test-support",
28 all(target_os = "windows", target_env = "gnu")
29))]
30pub mod test;
31#[cfg(any(
32 test,
33 feature = "test-support",
34 all(target_os = "windows", target_env = "gnu")
35))]
36pub use mock_client::*;
37
38#[derive(Debug, Clone)]
39pub enum Participant {
40 Local(LocalParticipant),
41 Remote(RemoteParticipant),
42}
43
44#[derive(Debug, Clone)]
45pub enum TrackPublication {
46 Local(LocalTrackPublication),
47 Remote(RemoteTrackPublication),
48}
49
50impl TrackPublication {
51 pub fn sid(&self) -> TrackSid {
52 match self {
53 TrackPublication::Local(local) => local.sid(),
54 TrackPublication::Remote(remote) => remote.sid(),
55 }
56 }
57
58 pub fn is_muted(&self) -> bool {
59 match self {
60 TrackPublication::Local(local) => local.is_muted(),
61 TrackPublication::Remote(remote) => remote.is_muted(),
62 }
63 }
64}
65
66#[derive(Clone, Debug)]
67pub enum RemoteTrack {
68 Audio(RemoteAudioTrack),
69 Video(RemoteVideoTrack),
70}
71
72impl RemoteTrack {
73 pub fn sid(&self) -> TrackSid {
74 match self {
75 RemoteTrack::Audio(remote_audio_track) => remote_audio_track.sid(),
76 RemoteTrack::Video(remote_video_track) => remote_video_track.sid(),
77 }
78 }
79}
80
81#[derive(Clone, Debug)]
82pub enum LocalTrack {
83 Audio(LocalAudioTrack),
84 Video(LocalVideoTrack),
85}
86
87#[derive(Clone, Debug)]
88#[non_exhaustive]
89pub enum RoomEvent {
90 ParticipantConnected(RemoteParticipant),
91 ParticipantDisconnected(RemoteParticipant),
92 LocalTrackPublished {
93 publication: LocalTrackPublication,
94 track: LocalTrack,
95 participant: LocalParticipant,
96 },
97 LocalTrackUnpublished {
98 publication: LocalTrackPublication,
99 participant: LocalParticipant,
100 },
101 LocalTrackSubscribed {
102 track: LocalTrack,
103 },
104 TrackSubscribed {
105 track: RemoteTrack,
106 publication: RemoteTrackPublication,
107 participant: RemoteParticipant,
108 },
109 TrackUnsubscribed {
110 track: RemoteTrack,
111 publication: RemoteTrackPublication,
112 participant: RemoteParticipant,
113 },
114 TrackSubscriptionFailed {
115 participant: RemoteParticipant,
116 // error: livekit::track::TrackError,
117 track_sid: TrackSid,
118 },
119 TrackPublished {
120 publication: RemoteTrackPublication,
121 participant: RemoteParticipant,
122 },
123 TrackUnpublished {
124 publication: RemoteTrackPublication,
125 participant: RemoteParticipant,
126 },
127 TrackMuted {
128 participant: Participant,
129 publication: TrackPublication,
130 },
131 TrackUnmuted {
132 participant: Participant,
133 publication: TrackPublication,
134 },
135 RoomMetadataChanged {
136 old_metadata: String,
137 metadata: String,
138 },
139 ParticipantMetadataChanged {
140 participant: Participant,
141 old_metadata: String,
142 metadata: String,
143 },
144 ParticipantNameChanged {
145 participant: Participant,
146 old_name: String,
147 name: String,
148 },
149 ParticipantAttributesChanged {
150 participant: Participant,
151 changed_attributes: HashMap<String, String>,
152 },
153 ActiveSpeakersChanged {
154 speakers: Vec<Participant>,
155 },
156 ConnectionStateChanged(ConnectionState),
157 Connected {
158 participants_with_tracks: Vec<(RemoteParticipant, Vec<RemoteTrackPublication>)>,
159 },
160 Disconnected {
161 reason: &'static str,
162 },
163 Reconnecting,
164 Reconnected,
165}