1use anyhow::{anyhow, Result};
2use client::ParticipantIndex;
3use client::{proto, User};
4use collections::HashMap;
5use gpui::WeakModel;
6pub use live_kit_client::Frame;
7pub use live_kit_client::{RemoteAudioTrack, RemoteVideoTrack};
8use project::Project;
9use std::sync::Arc;
10
11#[derive(Copy, Clone, Debug, Eq, PartialEq)]
12pub enum ParticipantLocation {
13 SharedProject { project_id: u64 },
14 UnsharedProject,
15 External,
16}
17
18impl ParticipantLocation {
19 pub fn from_proto(location: Option<proto::ParticipantLocation>) -> Result<Self> {
20 match location.and_then(|l| l.variant) {
21 Some(proto::participant_location::Variant::SharedProject(project)) => {
22 Ok(Self::SharedProject {
23 project_id: project.id,
24 })
25 }
26 Some(proto::participant_location::Variant::UnsharedProject(_)) => {
27 Ok(Self::UnsharedProject)
28 }
29 Some(proto::participant_location::Variant::External(_)) => Ok(Self::External),
30 None => Err(anyhow!("participant location was not provided")),
31 }
32 }
33}
34
35#[derive(Clone, Default)]
36pub struct LocalParticipant {
37 pub projects: Vec<proto::ParticipantProject>,
38 pub active_project: Option<WeakModel<Project>>,
39 pub role: proto::ChannelRole,
40}
41
42#[derive(Clone, Debug)]
43pub struct RemoteParticipant {
44 pub user: Arc<User>,
45 pub peer_id: proto::PeerId,
46 pub role: proto::ChannelRole,
47 pub projects: Vec<proto::ParticipantProject>,
48 pub location: ParticipantLocation,
49 pub participant_index: ParticipantIndex,
50 pub muted: bool,
51 pub speaking: bool,
52 pub video_tracks: HashMap<live_kit_client::Sid, Arc<RemoteVideoTrack>>,
53 pub audio_tracks: HashMap<live_kit_client::Sid, Arc<RemoteAudioTrack>>,
54}