Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T06:10:34.381Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

publication.rs

92 lines · 2.2 KB · rust
1use gpui::App;
2
3use crate::{RemoteTrack, TrackSid, test::WeakRoom};
4
5#[derive(Clone, Debug)]
6pub struct LocalTrackPublication {
7    pub(crate) sid: TrackSid,
8    pub(crate) room: WeakRoom,
9}
10
11#[derive(Clone, Debug)]
12pub struct RemoteTrackPublication {
13    pub(crate) sid: TrackSid,
14    pub(crate) room: WeakRoom,
15    pub(crate) track: RemoteTrack,
16}
17
18impl LocalTrackPublication {
19    pub fn sid(&self) -> TrackSid {
20        self.sid.clone()
21    }
22
23    pub fn mute(&self, _cx: &App) {
24        self.set_mute(true)
25    }
26
27    pub fn unmute(&self, _cx: &App) {
28        self.set_mute(false)
29    }
30
31    fn set_mute(&self, mute: bool) {
32        if let Some(room) = self.room.upgrade() {
33            room.test_server()
34                .set_track_muted(&room.token(), &self.sid, mute)
35                .ok();
36        }
37    }
38
39    pub fn is_muted(&self) -> bool {
40        if let Some(room) = self.room.upgrade() {
41            room.test_server()
42                .is_track_muted(&room.token(), &self.sid)
43                .unwrap_or(false)
44        } else {
45            false
46        }
47    }
48}
49
50impl RemoteTrackPublication {
51    pub fn sid(&self) -> TrackSid {
52        self.sid.clone()
53    }
54
55    pub fn track(&self) -> Option<RemoteTrack> {
56        Some(self.track.clone())
57    }
58
59    pub fn is_audio(&self) -> bool {
60        matches!(self.track, RemoteTrack::Audio(_))
61    }
62
63    pub fn is_muted(&self) -> bool {
64        if let Some(room) = self.room.upgrade() {
65            room.test_server()
66                .is_track_muted(&room.token(), &self.sid)
67                .unwrap_or(false)
68        } else {
69            false
70        }
71    }
72
73    pub fn is_enabled(&self) -> bool {
74        if let Some(room) = self.room.upgrade() {
75            !room.0.lock().paused_audio_tracks.contains(&self.sid)
76        } else {
77            false
78        }
79    }
80
81    pub fn set_enabled(&self, enabled: bool, _cx: &App) {
82        if let Some(room) = self.room.upgrade() {
83            let paused_audio_tracks = &mut room.0.lock().paused_audio_tracks;
84            if enabled {
85                paused_audio_tracks.remove(&self.sid);
86            } else {
87                paused_audio_tracks.insert(self.sid.clone());
88            }
89        }
90    }
91}
92
Served at tenant.openagents/omega Member data and write actions are omitted.