1use client::{ParticipantIndex, User, proto};
2use collections::HashMap;
3use gpui::WeakEntity;
4use livekit_client::AudioStream;
5use project::Project;
6use std::sync::Arc;
7
8pub use livekit_client::TrackSid;
9pub use livekit_client::{RemoteAudioTrack, RemoteVideoTrack};
10
11#[derive(Clone, Default)]
12pub struct LocalParticipant {
13 pub projects: Vec<proto::ParticipantProject>,
14 pub active_project: Option<WeakEntity<Project>>,
15 pub role: proto::ChannelRole,
16}
17
18impl LocalParticipant {
19 pub fn can_write(&self) -> bool {
20 matches!(
21 self.role,
22 proto::ChannelRole::Admin | proto::ChannelRole::Member
23 )
24 }
25}
26
27pub struct RemoteParticipant {
28 pub user: Arc<User>,
29 pub peer_id: proto::PeerId,
30 pub role: proto::ChannelRole,
31 pub projects: Vec<proto::ParticipantProject>,
32 pub location: workspace::ParticipantLocation,
33 pub participant_index: ParticipantIndex,
34 pub muted: bool,
35 pub speaking: bool,
36 pub video_tracks: HashMap<TrackSid, RemoteVideoTrack>,
37 pub audio_tracks: HashMap<TrackSid, (RemoteAudioTrack, AudioStream)>,
38}
39
40impl RemoteParticipant {
41 pub fn has_video_tracks(&self) -> bool {
42 !self.video_tracks.is_empty()
43 }
44
45 pub fn can_write(&self) -> bool {
46 matches!(
47 self.role,
48 proto::ChannelRole::Admin | proto::ChannelRole::Member
49 )
50 }
51}