BlueGit

ict rusty-teams

Merge pull request #19: feat(calling): camera video quality Auto/720p/1080p

metis Daniel Däschle · pushed by metis

Authored 2026-11-13 · 2 weeks ago

Hash
68a5253d7dd4d6a9c750e87bff741fa4710585cf
10 files changed +329 −77
crates/app-call-model/src/demo.rs +6 −1
@@ -764,7 +764,7 @@ async fn speak_until_hangup(
764 764 people.iter().for_each(|(mri, _)| control.video.forget(&VideoKey::Person(mri.clone())));
765 765 control.send(CallUpdate::IncomingVideo(enabled));
766 766 }
767 Some(CallCommand::SetCameraEffects(_) | CallCommand::SetVideoWants(_) | CallCommand::SetShareMotion(_) | CallCommand::SetShareStandout(_)) => {}
767 Some(CallCommand::SetCameraEffects(_) | CallCommand::SetVideoQuality(_) | CallCommand::SetVideoWants(_) | CallCommand::SetShareMotion(_) | CallCommand::SetShareStandout(_)) => {}
768 768 Some(CallCommand::StartRecording { kind, .. }) => {
769 769 recording_on = kind != RecordingKind::TranscriptOnly;
770 770 transcribing_on = true;
@@ -789,6 +789,11 @@ async fn speak_until_hangup(
789 789 }
790 790 Some(CallCommand::OpenWhiteboard { .. }) => control.send(CallUpdate::WhiteboardUrl(DEMO_BOARD_URL.to_owned())),
791 791 Some(CallCommand::RefreshShareSources) => send_demo_share_sources(&control),
792 Some(
793 CallCommand::StartPortalShare(_)
794 | CallCommand::AbandonPortalShare
795 | CallCommand::FinishPortalShare { .. },
796 ) => {}
792 797 Some(CallCommand::Hangup | CallCommand::EndMeeting) | None => {
793 798 end(&control, EndReason::LocalHangup);
794 799 return;
@@ -764,7 +764,7 @@ async fn speak_until_hangup(
764 people.iter().for_each(|(mri, _)| control.video.forget(&VideoKey::Person(mri.clone())));
764 people.iter().for_each(|(mri, _)| control.video.forget(&VideoKey::Person(mri.clone())));
765 control.send(CallUpdate::IncomingVideo(enabled));
765 control.send(CallUpdate::IncomingVideo(enabled));
766 }
766 }
767 Some(CallCommand::SetCameraEffects(_) | CallCommand::SetVideoWants(_) | CallCommand::SetShareMotion(_) | CallCommand::SetShareStandout(_)) => {}
767 Some(CallCommand::SetCameraEffects(_) | CallCommand::SetVideoQuality(_) | CallCommand::SetVideoWants(_) | CallCommand::SetShareMotion(_) | CallCommand::SetShareStandout(_)) => {}
768 Some(CallCommand::StartRecording { kind, .. }) => {
768 Some(CallCommand::StartRecording { kind, .. }) => {
769 recording_on = kind != RecordingKind::TranscriptOnly;
769 recording_on = kind != RecordingKind::TranscriptOnly;
770 transcribing_on = true;
770 transcribing_on = true;
@@ -789,6 +789,11 @@ async fn speak_until_hangup(
789 }
789 }
790 Some(CallCommand::OpenWhiteboard { .. }) => control.send(CallUpdate::WhiteboardUrl(DEMO_BOARD_URL.to_owned())),
790 Some(CallCommand::OpenWhiteboard { .. }) => control.send(CallUpdate::WhiteboardUrl(DEMO_BOARD_URL.to_owned())),
791 Some(CallCommand::RefreshShareSources) => send_demo_share_sources(&control),
791 Some(CallCommand::RefreshShareSources) => send_demo_share_sources(&control),
792 Some(
793 CallCommand::StartPortalShare(_)
794 | CallCommand::AbandonPortalShare
795 | CallCommand::FinishPortalShare { .. },
796 ) => {}
792 Some(CallCommand::Hangup | CallCommand::EndMeeting) | None => {
797 Some(CallCommand::Hangup | CallCommand::EndMeeting) | None => {
793 end(&control, EndReason::LocalHangup);
798 end(&control, EndReason::LocalHangup);
794 return;
799 return;
crates/app-state/src/app_state.rs +14 −8
@@ -37,19 +37,19 @@ pub enum QuickView {
37 37 }
38 38
39 39 impl QuickView {
40 pub fn title(self) -> &'static str {
40 pub fn title(self) -> String {
41 41 match self {
42 QuickView::Mentions => "Mentions",
43 QuickView::Drafts => "Drafts",
44 QuickView::Saved => "Saved",
42 QuickView::Mentions => app_base::ui_locale::tr("sidebar.quick_view.mentions"),
43 QuickView::Drafts => app_base::ui_locale::tr("sidebar.quick_view.drafts"),
44 QuickView::Saved => app_base::ui_locale::tr("sidebar.quick_view.saved"),
45 45 }
46 46 }
47 47
48 pub fn empty_text(self) -> &'static str {
48 pub fn empty_text(self) -> String {
49 49 match self {
50 QuickView::Mentions => "No mentions yet. When someone @mentions you, it shows up here.",
51 QuickView::Drafts => "No drafts. Messages you start and do not send show up here.",
52 QuickView::Saved => "No saved messages. Use Save message in the ... menu of a message.",
50 QuickView::Mentions => app_base::ui_locale::tr("sidebar.quick_view.mentions_empty"),
51 QuickView::Drafts => app_base::ui_locale::tr("sidebar.quick_view.drafts_empty"),
52 QuickView::Saved => app_base::ui_locale::tr("sidebar.quick_view.saved_empty"),
53 53 }
54 54 }
55 55 }
@@ -191,12 +191,14 @@ pub struct AppState {
191 191 pub call_share_motion: bool,
192 192 pub call_share_standout: bool,
193 193 pub call_report_enabled: bool,
194 pub call_strip_width: f32,
194 195 pub call_view: crate::call::ViewSettings,
195 196 pub call_background: crate::call::BackgroundPick,
196 197 pub call_camera: calling::DeviceChoice,
197 198 pub call_input: calling::DeviceChoice,
198 199 pub call_output: calling::DeviceChoice,
199 200 pub call_mic: calling::MicSettings,
201 pub call_video_quality: calling::VideoQuality,
200 202 pub call_effects: calling::CameraEffects,
201 203 pub meet_now_pending: bool,
202 204 pub prejoin: Option<crate::call::PendingJoin>,
@@ -353,12 +355,14 @@ impl AppState {
353 355 call_share_motion: false,
354 356 call_share_standout: false,
355 357 call_report_enabled: true,
358 call_strip_width: crate::call::STRIP_DEFAULT_WIDTH,
356 359 call_view: crate::call::ViewSettings::default(),
357 360 call_background: crate::call::BackgroundPick::None,
358 361 call_camera: calling::DeviceChoice::SystemDefault,
359 362 call_input: calling::DeviceChoice::SystemDefault,
360 363 call_output: calling::DeviceChoice::SystemDefault,
361 364 call_mic: calling::MicSettings::default(),
365 call_video_quality: calling::VideoQuality::default(),
362 366 call_effects: calling::CameraEffects::default(),
363 367 meet_now_pending: false,
364 368 prejoin: None,
@@ -398,9 +402,11 @@ impl AppState {
398 402 state.call_output = crate::call::load_output(&state.store);
399 403 crate::call::apply_sound_output(&state.call_output);
400 404 state.call_mic = crate::call::load_mic(&state.store);
405 state.call_video_quality = crate::call::load_video_quality(&state.store);
401 406 state.call_effects = crate::call::load_camera_effects(&state.store);
402 407 state.join_options = crate::call::load_join_options(&state.store);
403 408 state.call_backgrounds.customs = crate::call::load_custom_backgrounds(&state.store);
409 state.call_strip_width = crate::call::load_strip_width(&state.store);
404 410 state.load_cached_translation_settings();
405 411 if !mode.demo {
406 412 state.directory.load_cached_presence(&state.store);
@@ -37,19 +37,19 @@ pub enum QuickView {
37}
37}
38
38
39impl QuickView {
39impl QuickView {
40 pub fn title(self) -> &'static str {
40 pub fn title(self) -> String {
41 match self {
41 match self {
42 QuickView::Mentions => "Mentions",
42 QuickView::Mentions => app_base::ui_locale::tr("sidebar.quick_view.mentions"),
43 QuickView::Drafts => "Drafts",
43 QuickView::Drafts => app_base::ui_locale::tr("sidebar.quick_view.drafts"),
44 QuickView::Saved => "Saved",
44 QuickView::Saved => app_base::ui_locale::tr("sidebar.quick_view.saved"),
45 }
45 }
46 }
46 }
47
47
48 pub fn empty_text(self) -> &'static str {
48 pub fn empty_text(self) -> String {
49 match self {
49 match self {
50 QuickView::Mentions => "No mentions yet. When someone @mentions you, it shows up here.",
50 QuickView::Mentions => app_base::ui_locale::tr("sidebar.quick_view.mentions_empty"),
51 QuickView::Drafts => "No drafts. Messages you start and do not send show up here.",
51 QuickView::Drafts => app_base::ui_locale::tr("sidebar.quick_view.drafts_empty"),
52 QuickView::Saved => "No saved messages. Use Save message in the ... menu of a message.",
52 QuickView::Saved => app_base::ui_locale::tr("sidebar.quick_view.saved_empty"),
53 }
53 }
54 }
54 }
55}
55}
@@ -191,12 +191,14 @@ pub struct AppState {
191 pub call_share_motion: bool,
191 pub call_share_motion: bool,
192 pub call_share_standout: bool,
192 pub call_share_standout: bool,
193 pub call_report_enabled: bool,
193 pub call_report_enabled: bool,
194 pub call_strip_width: f32,
194 pub call_view: crate::call::ViewSettings,
195 pub call_view: crate::call::ViewSettings,
195 pub call_background: crate::call::BackgroundPick,
196 pub call_background: crate::call::BackgroundPick,
196 pub call_camera: calling::DeviceChoice,
197 pub call_camera: calling::DeviceChoice,
197 pub call_input: calling::DeviceChoice,
198 pub call_input: calling::DeviceChoice,
198 pub call_output: calling::DeviceChoice,
199 pub call_output: calling::DeviceChoice,
199 pub call_mic: calling::MicSettings,
200 pub call_mic: calling::MicSettings,
201 pub call_video_quality: calling::VideoQuality,
200 pub call_effects: calling::CameraEffects,
202 pub call_effects: calling::CameraEffects,
201 pub meet_now_pending: bool,
203 pub meet_now_pending: bool,
202 pub prejoin: Option<crate::call::PendingJoin>,
204 pub prejoin: Option<crate::call::PendingJoin>,
@@ -353,12 +355,14 @@ impl AppState {
353 call_share_motion: false,
355 call_share_motion: false,
354 call_share_standout: false,
356 call_share_standout: false,
355 call_report_enabled: true,
357 call_report_enabled: true,
358 call_strip_width: crate::call::STRIP_DEFAULT_WIDTH,
356 call_view: crate::call::ViewSettings::default(),
359 call_view: crate::call::ViewSettings::default(),
357 call_background: crate::call::BackgroundPick::None,
360 call_background: crate::call::BackgroundPick::None,
358 call_camera: calling::DeviceChoice::SystemDefault,
361 call_camera: calling::DeviceChoice::SystemDefault,
359 call_input: calling::DeviceChoice::SystemDefault,
362 call_input: calling::DeviceChoice::SystemDefault,
360 call_output: calling::DeviceChoice::SystemDefault,
363 call_output: calling::DeviceChoice::SystemDefault,
361 call_mic: calling::MicSettings::default(),
364 call_mic: calling::MicSettings::default(),
365 call_video_quality: calling::VideoQuality::default(),
362 call_effects: calling::CameraEffects::default(),
366 call_effects: calling::CameraEffects::default(),
363 meet_now_pending: false,
367 meet_now_pending: false,
364 prejoin: None,
368 prejoin: None,
@@ -398,9 +402,11 @@ impl AppState {
398 state.call_output = crate::call::load_output(&state.store);
402 state.call_output = crate::call::load_output(&state.store);
399 crate::call::apply_sound_output(&state.call_output);
403 crate::call::apply_sound_output(&state.call_output);
400 state.call_mic = crate::call::load_mic(&state.store);
404 state.call_mic = crate::call::load_mic(&state.store);
405 state.call_video_quality = crate::call::load_video_quality(&state.store);
401 state.call_effects = crate::call::load_camera_effects(&state.store);
406 state.call_effects = crate::call::load_camera_effects(&state.store);
402 state.join_options = crate::call::load_join_options(&state.store);
407 state.join_options = crate::call::load_join_options(&state.store);
403 state.call_backgrounds.customs = crate::call::load_custom_backgrounds(&state.store);
408 state.call_backgrounds.customs = crate::call::load_custom_backgrounds(&state.store);
409 state.call_strip_width = crate::call::load_strip_width(&state.store);
404 state.load_cached_translation_settings();
410 state.load_cached_translation_settings();
405 if !mode.demo {
411 if !mode.demo {
406 state.directory.load_cached_presence(&state.store);
412 state.directory.load_cached_presence(&state.store);
crates/app-state/src/call/actions.rs +74 −4
@@ -1,10 +1,11 @@
1 1 use std::time::{Duration, Instant};
2 2
3 use app_base::ui_locale::localize_notice;
3 4 use calling::meeting::LiveMeeting;
4 5 use calling::{
5 6 AcceptMode, CallCommand, CallHandle, CallSpec, CallState, CallUpdate, Callee, CameraEffects,
6 7 DeviceChoice, EndReason, EngineEvent, MicSettings, MuteCommand, Reaction, RingSignal,
7 ShareSource, VideoKey,
8 ShareKind, ShareSource, VideoKey,
8 9 };
9 10 use gpui_kit::*;
10 11
@@ -48,6 +49,7 @@ const DEMO_LIVE_MINUTES: i64 = 60;
48 49 const ORGID_PREFIX: &str = "8:orgid:";
49 50 pub const SHARE_SOUND_META_KEY: &str = "call_share_sound";
50 51 const CAMERA_META_KEY: &str = "call_camera";
52 const VIDEO_QUALITY_META_KEY: &str = "call_video_quality";
51 53 const INPUT_META_KEY: &str = "call_input";
52 54 pub fn apply_sound_output(choice: &DeviceChoice) {
53 55 let device_key = match choice {
@@ -95,6 +97,22 @@ pub fn load_camera_effects(store: &store::Store) -> CameraEffects {
95 97 })
96 98 }
97 99
100 pub fn load_video_quality(store: &store::Store) -> calling::VideoQuality {
101 store
102 .meta(VIDEO_QUALITY_META_KEY)
103 .ok()
104 .flatten()
105 .as_deref()
106 .map_or_else(
107 calling::VideoQuality::default,
108 calling::VideoQuality::from_meta,
109 )
110 }
111
112 pub fn save_video_quality(store: &store::Store, quality: calling::VideoQuality) {
113 let _ = store.set_meta(VIDEO_QUALITY_META_KEY, quality.to_meta());
114 }
115
98 116 fn device_meta(choice: &DeviceChoice) -> &str {
99 117 match choice {
100 118 DeviceChoice::SystemDefault => DEFAULT_DEVICE_META,
@@ -286,6 +304,7 @@ impl AppState {
286 304 if self.call_mic != MicSettings::default() {
287 305 self.send_call_command(CallCommand::SetMicSettings(self.call_mic));
288 306 }
307 self.send_call_command(CallCommand::SetVideoQuality(self.call_video_quality));
289 308 if let Some(call) = self.call.as_mut() {
290 309 call.model.background = self.call_background.clone();
291 310 call.model.camera = self.call_camera.clone();
@@ -517,7 +536,7 @@ impl AppState {
517 536 return;
518 537 }
519 538 CallUpdate::Notice(text) => {
520 self.raise_notice(text, None, cx);
539 self.raise_notice(localize_notice(&text), None, cx);
521 540 return;
522 541 }
523 542 CallUpdate::WhiteboardUrl(url) => {
@@ -564,6 +583,7 @@ impl AppState {
564 583 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
565 584 }
566 585 let sharer_before = call.model.screen_sharer.clone();
586 let local_share_before = call.model.local_share.is_some();
567 587 let lobby_before = call.model.lobby_mris();
568 588 call.model.apply(update);
569 589 if call.model.someone_entered_the_lobby(&lobby_before)
@@ -576,6 +596,15 @@ impl AppState {
576 596 chatsvc::sounds::CallTone::MeetingReminder,
577 597 ));
578 598 }
599 if !local_share_before && call.model.local_share.is_some() && call.chat_thread().is_some() {
600 call.chat_open = true;
601 call.transcript_open = false;
602 call.people_open = false;
603 self.transcript_panel = None;
604 }
605 if call.model.local_share.is_none() {
606 call.pictures.forget(&VideoKey::LocalScreen, cx);
607 }
579 608 if call.model.screen_sharer != sharer_before {
580 609 call.pictures.forget(&VideoKey::Screen, cx);
581 610 }
@@ -676,6 +705,17 @@ impl AppState {
676 705 cx.notify();
677 706 }
678 707
708 pub fn set_call_video_quality(
709 &mut self,
710 quality: calling::VideoQuality,
711 cx: &mut Context<Self>,
712 ) {
713 self.call_video_quality = quality;
714 save_video_quality(&self.store, quality);
715 self.send_call_command(CallCommand::SetVideoQuality(quality));
716 cx.notify();
717 }
718
679 719 pub fn press_push_to_talk(&mut self, _cx: &mut Context<Self>) {
680 720 let Some(call) = self.call.as_mut() else {
681 721 return;
@@ -714,6 +754,10 @@ impl AppState {
714 754 self.send_call_command(CallCommand::StartShare(source));
715 755 }
716 756
757 pub fn start_portal_share(&mut self, kind: ShareKind, _cx: &mut Context<Self>) {
758 self.send_call_command(CallCommand::StartPortalShare(kind));
759 }
760
717 761 pub fn stop_call_share(&mut self, _cx: &mut Context<Self>) {
718 762 self.send_call_command(CallCommand::StopShare);
719 763 }
@@ -1442,12 +1486,15 @@ mod tests {
1442 1486 use calling::{
1443 1487 BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,
1444 1488 DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, RecordingKind,
1445 StopScope, call_channel,
1489 StopScope, VideoQuality, call_channel,
1446 1490 };
1447 1491 use gpui_kit::{AppContext as _, Entity, TestAppContext};
1448 1492 use store::{ChatRecord, MemberRecord, Store};
1449 1493
1450 use super::{ActiveCall, CallModel, load_camera, load_camera_effects, load_input, load_output};
1494 use super::{
1495 ActiveCall, CallModel, load_camera, load_camera_effects, load_input, load_output,
1496 load_video_quality,
1497 };
1451 1498 use crate::app_state::{AppEvent, AppState, Mode, Selection};
1452 1499 use crate::call::TransferCandidate;
1453 1500 use crate::call::background::BackgroundPick;
@@ -1670,6 +1717,7 @@ mod tests {
1670 1717 "headset".into()
1671 1718 )))
1672 1719 );
1720 assert!(commands.contains(&CallCommand::SetVideoQuality(VideoQuality::Auto)));
1673 1721 assert_eq!(
1674 1722 load_input(&store),
1675 1723 DeviceChoice::Device("unplugged-mic".into())
@@ -1722,6 +1770,28 @@ mod tests {
1722 1770 assert_eq!(cx.update(|cx| reopened.read(cx).call_effects), effects);
1723 1771 }
1724 1772
1773 #[gpui_kit::test]
1774 fn the_video_quality_is_remembered_and_sent_to_the_call(cx: &mut TestAppContext) {
1775 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1776 let store = cx.update(|cx| app.read(cx).store.clone());
1777 assert_eq!(load_video_quality(&store), VideoQuality::Auto);
1778 cx.update(|cx| {
1779 app.update(cx, |state, cx| {
1780 state.set_call_video_quality(VideoQuality::P1080, cx)
1781 })
1782 });
1783 assert_eq!(
1784 control.try_recv_command(),
1785 Some(CallCommand::SetVideoQuality(VideoQuality::P1080))
1786 );
1787 assert_eq!(load_video_quality(&store), VideoQuality::P1080);
1788 let reopened = cx.update(|cx| cx.new(|_| AppState::new(store.clone(), Mode::default())));
1789 assert_eq!(
1790 cx.update(|cx| reopened.read(cx).call_video_quality),
1791 VideoQuality::P1080
1792 );
1793 }
1794
1725 1795 #[gpui_kit::test]
1726 1796 fn hands_and_reactions_become_call_commands_and_lowering_needs_the_organizer(
1727 1797 cx: &mut TestAppContext,
@@ -1,10 +1,11 @@
1use std::time::{Duration, Instant};
1use std::time::{Duration, Instant};
2
2
3use app_base::ui_locale::localize_notice;
3use calling::meeting::LiveMeeting;
4use calling::meeting::LiveMeeting;
4use calling::{
5use calling::{
5 AcceptMode, CallCommand, CallHandle, CallSpec, CallState, CallUpdate, Callee, CameraEffects,
6 AcceptMode, CallCommand, CallHandle, CallSpec, CallState, CallUpdate, Callee, CameraEffects,
6 DeviceChoice, EndReason, EngineEvent, MicSettings, MuteCommand, Reaction, RingSignal,
7 DeviceChoice, EndReason, EngineEvent, MicSettings, MuteCommand, Reaction, RingSignal,
7 ShareSource, VideoKey,
8 ShareKind, ShareSource, VideoKey,
8};
9};
9use gpui_kit::*;
10use gpui_kit::*;
10
11
@@ -48,6 +49,7 @@ const DEMO_LIVE_MINUTES: i64 = 60;
48const ORGID_PREFIX: &str = "8:orgid:";
49const ORGID_PREFIX: &str = "8:orgid:";
49pub const SHARE_SOUND_META_KEY: &str = "call_share_sound";
50pub const SHARE_SOUND_META_KEY: &str = "call_share_sound";
50const CAMERA_META_KEY: &str = "call_camera";
51const CAMERA_META_KEY: &str = "call_camera";
52const VIDEO_QUALITY_META_KEY: &str = "call_video_quality";
51const INPUT_META_KEY: &str = "call_input";
53const INPUT_META_KEY: &str = "call_input";
52pub fn apply_sound_output(choice: &DeviceChoice) {
54pub fn apply_sound_output(choice: &DeviceChoice) {
53 let device_key = match choice {
55 let device_key = match choice {
@@ -95,6 +97,22 @@ pub fn load_camera_effects(store: &store::Store) -> CameraEffects {
95 })
97 })
96}
98}
97
99
100pub fn load_video_quality(store: &store::Store) -> calling::VideoQuality {
101 store
102 .meta(VIDEO_QUALITY_META_KEY)
103 .ok()
104 .flatten()
105 .as_deref()
106 .map_or_else(
107 calling::VideoQuality::default,
108 calling::VideoQuality::from_meta,
109 )
110}
111
112pub fn save_video_quality(store: &store::Store, quality: calling::VideoQuality) {
113 let _ = store.set_meta(VIDEO_QUALITY_META_KEY, quality.to_meta());
114}
115
98fn device_meta(choice: &DeviceChoice) -> &str {
116fn device_meta(choice: &DeviceChoice) -> &str {
99 match choice {
117 match choice {
100 DeviceChoice::SystemDefault => DEFAULT_DEVICE_META,
118 DeviceChoice::SystemDefault => DEFAULT_DEVICE_META,
@@ -286,6 +304,7 @@ impl AppState {
286 if self.call_mic != MicSettings::default() {
304 if self.call_mic != MicSettings::default() {
287 self.send_call_command(CallCommand::SetMicSettings(self.call_mic));
305 self.send_call_command(CallCommand::SetMicSettings(self.call_mic));
288 }
306 }
307 self.send_call_command(CallCommand::SetVideoQuality(self.call_video_quality));
289 if let Some(call) = self.call.as_mut() {
308 if let Some(call) = self.call.as_mut() {
290 call.model.background = self.call_background.clone();
309 call.model.background = self.call_background.clone();
291 call.model.camera = self.call_camera.clone();
310 call.model.camera = self.call_camera.clone();
@@ -517,7 +536,7 @@ impl AppState {
517 return;
536 return;
518 }
537 }
519 CallUpdate::Notice(text) => {
538 CallUpdate::Notice(text) => {
520 self.raise_notice(text, None, cx);
539 self.raise_notice(localize_notice(&text), None, cx);
521 return;
540 return;
522 }
541 }
523 CallUpdate::WhiteboardUrl(url) => {
542 CallUpdate::WhiteboardUrl(url) => {
@@ -564,6 +583,7 @@ impl AppState {
564 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
583 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
565 }
584 }
566 let sharer_before = call.model.screen_sharer.clone();
585 let sharer_before = call.model.screen_sharer.clone();
586 let local_share_before = call.model.local_share.is_some();
567 let lobby_before = call.model.lobby_mris();
587 let lobby_before = call.model.lobby_mris();
568 call.model.apply(update);
588 call.model.apply(update);
569 if call.model.someone_entered_the_lobby(&lobby_before)
589 if call.model.someone_entered_the_lobby(&lobby_before)
@@ -576,6 +596,15 @@ impl AppState {
576 chatsvc::sounds::CallTone::MeetingReminder,
596 chatsvc::sounds::CallTone::MeetingReminder,
577 ));
597 ));
578 }
598 }
599 if !local_share_before && call.model.local_share.is_some() && call.chat_thread().is_some() {
600 call.chat_open = true;
601 call.transcript_open = false;
602 call.people_open = false;
603 self.transcript_panel = None;
604 }
605 if call.model.local_share.is_none() {
606 call.pictures.forget(&VideoKey::LocalScreen, cx);
607 }
579 if call.model.screen_sharer != sharer_before {
608 if call.model.screen_sharer != sharer_before {
580 call.pictures.forget(&VideoKey::Screen, cx);
609 call.pictures.forget(&VideoKey::Screen, cx);
581 }
610 }
@@ -676,6 +705,17 @@ impl AppState {
676 cx.notify();
705 cx.notify();
677 }
706 }
678
707
708 pub fn set_call_video_quality(
709 &mut self,
710 quality: calling::VideoQuality,
711 cx: &mut Context<Self>,
712 ) {
713 self.call_video_quality = quality;
714 save_video_quality(&self.store, quality);
715 self.send_call_command(CallCommand::SetVideoQuality(quality));
716 cx.notify();
717 }
718
679 pub fn press_push_to_talk(&mut self, _cx: &mut Context<Self>) {
719 pub fn press_push_to_talk(&mut self, _cx: &mut Context<Self>) {
680 let Some(call) = self.call.as_mut() else {
720 let Some(call) = self.call.as_mut() else {
681 return;
721 return;
@@ -714,6 +754,10 @@ impl AppState {
714 self.send_call_command(CallCommand::StartShare(source));
754 self.send_call_command(CallCommand::StartShare(source));
715 }
755 }
716
756
757 pub fn start_portal_share(&mut self, kind: ShareKind, _cx: &mut Context<Self>) {
758 self.send_call_command(CallCommand::StartPortalShare(kind));
759 }
760
717 pub fn stop_call_share(&mut self, _cx: &mut Context<Self>) {
761 pub fn stop_call_share(&mut self, _cx: &mut Context<Self>) {
718 self.send_call_command(CallCommand::StopShare);
762 self.send_call_command(CallCommand::StopShare);
719 }
763 }
@@ -1442,12 +1486,15 @@ mod tests {
1442 use calling::{
1486 use calling::{
1443 BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,
1487 BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,
1444 DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, RecordingKind,
1488 DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, RecordingKind,
1445 StopScope, call_channel,
1489 StopScope, VideoQuality, call_channel,
1446 };
1490 };
1447 use gpui_kit::{AppContext as _, Entity, TestAppContext};
1491 use gpui_kit::{AppContext as _, Entity, TestAppContext};
1448 use store::{ChatRecord, MemberRecord, Store};
1492 use store::{ChatRecord, MemberRecord, Store};
1449
1493
1450 use super::{ActiveCall, CallModel, load_camera, load_camera_effects, load_input, load_output};
1494 use super::{
1495 ActiveCall, CallModel, load_camera, load_camera_effects, load_input, load_output,
1496 load_video_quality,
1497 };
1451 use crate::app_state::{AppEvent, AppState, Mode, Selection};
1498 use crate::app_state::{AppEvent, AppState, Mode, Selection};
1452 use crate::call::TransferCandidate;
1499 use crate::call::TransferCandidate;
1453 use crate::call::background::BackgroundPick;
1500 use crate::call::background::BackgroundPick;
@@ -1670,6 +1717,7 @@ mod tests {
1670 "headset".into()
1717 "headset".into()
1671 )))
1718 )))
1672 );
1719 );
1720 assert!(commands.contains(&CallCommand::SetVideoQuality(VideoQuality::Auto)));
1673 assert_eq!(
1721 assert_eq!(
1674 load_input(&store),
1722 load_input(&store),
1675 DeviceChoice::Device("unplugged-mic".into())
1723 DeviceChoice::Device("unplugged-mic".into())
@@ -1722,6 +1770,28 @@ mod tests {
1722 assert_eq!(cx.update(|cx| reopened.read(cx).call_effects), effects);
1770 assert_eq!(cx.update(|cx| reopened.read(cx).call_effects), effects);
1723 }
1771 }
1724
1772
1773 #[gpui_kit::test]
1774 fn the_video_quality_is_remembered_and_sent_to_the_call(cx: &mut TestAppContext) {
1775 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1776 let store = cx.update(|cx| app.read(cx).store.clone());
1777 assert_eq!(load_video_quality(&store), VideoQuality::Auto);
1778 cx.update(|cx| {
1779 app.update(cx, |state, cx| {
1780 state.set_call_video_quality(VideoQuality::P1080, cx)
1781 })
1782 });
1783 assert_eq!(
1784 control.try_recv_command(),
1785 Some(CallCommand::SetVideoQuality(VideoQuality::P1080))
1786 );
1787 assert_eq!(load_video_quality(&store), VideoQuality::P1080);
1788 let reopened = cx.update(|cx| cx.new(|_| AppState::new(store.clone(), Mode::default())));
1789 assert_eq!(
1790 cx.update(|cx| reopened.read(cx).call_video_quality),
1791 VideoQuality::P1080
1792 );
1793 }
1794
1725 #[gpui_kit::test]
1795 #[gpui_kit::test]
1726 fn hands_and_reactions_become_call_commands_and_lowering_needs_the_organizer(
1796 fn hands_and_reactions_become_call_commands_and_lowering_needs_the_organizer(
1727 cx: &mut TestAppContext,
1797 cx: &mut TestAppContext,
crates/app-state/src/call/mod.rs +9 −4
@@ -7,6 +7,7 @@ pub mod history;
7 7 pub mod join;
8 8 pub mod launcher;
9 9 pub mod list;
10 pub mod meeting_create;
10 11 pub mod outlook_reminders;
11 12 pub mod overlay_layout;
12 13 pub mod people_actions;
@@ -29,7 +30,8 @@ pub use app_call_model::{
29 30 };
30 31
31 32 pub use actions::{
32 apply_sound_output, load_camera, load_camera_effects, load_input, load_output, load_share_sound,
33 apply_sound_output, load_camera, load_camera_effects, load_input, load_output,
34 load_share_sound, load_video_quality,
33 35 };
34 36 pub use agenda::{AgendaRow, fetch_window, join_available, response_label};
35 37 pub use background::{
@@ -62,12 +64,15 @@ pub use report::load_enabled as load_report_enabled;
62 64 pub use ring::{MissedCall, RingEntry, Rings};
63 65 pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
64 66 pub use share_actions::ZoomStep;
65 pub use share_view::{SHARE_MOTION_META_KEY, SHARE_STANDOUT_META_KEY, ShareStage, load_flag};
67 pub use share_view::{
68 SHARE_MOTION_META_KEY, SHARE_STANDOUT_META_KEY, STRIP_DEFAULT_WIDTH, STRIP_WIDTH_META_KEY,
69 ShareStage, StripDrag, clamp_strip_width, load_flag, load_strip_width,
70 };
66 71 pub use speed_dial::SpeedDialEntry;
67 72 pub use stage_layout::{contain_size, focus_stage_size, gallery_grid};
68 73 pub use stage_split::{
69 GRID_PADDING, GalleryPage, STRIP_GAP, SpeakerSplit, StripSplit, TILE_GAP, gallery_page,
70 measured_stage, speaker_split, strip_split, video_wants,
74 GRID_PADDING, STRIP_GAP, SpeakerSplit, StripSplit, TILE_GAP, gallery_page, measured_stage,
75 speaker_split, strip_split, video_wants,
71 76 };
72 77 pub use target::{is_echo_chat, plan_for_chat};
73 78 pub use transcript::clock_label;
@@ -7,6 +7,7 @@ pub mod history;
7pub mod join;
7pub mod join;
8pub mod launcher;
8pub mod launcher;
9pub mod list;
9pub mod list;
10pub mod meeting_create;
10pub mod outlook_reminders;
11pub mod outlook_reminders;
11pub mod overlay_layout;
12pub mod overlay_layout;
12pub mod people_actions;
13pub mod people_actions;
@@ -29,7 +30,8 @@ pub use app_call_model::{
29};
30};
30
31
31pub use actions::{
32pub use actions::{
32 apply_sound_output, load_camera, load_camera_effects, load_input, load_output, load_share_sound,
33 apply_sound_output, load_camera, load_camera_effects, load_input, load_output,
34 load_share_sound, load_video_quality,
33};
35};
34pub use agenda::{AgendaRow, fetch_window, join_available, response_label};
36pub use agenda::{AgendaRow, fetch_window, join_available, response_label};
35pub use background::{
37pub use background::{
@@ -62,12 +64,15 @@ pub use report::load_enabled as load_report_enabled;
62pub use ring::{MissedCall, RingEntry, Rings};
64pub use ring::{MissedCall, RingEntry, Rings};
63pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
65pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
64pub use share_actions::ZoomStep;
66pub use share_actions::ZoomStep;
65pub use share_view::{SHARE_MOTION_META_KEY, SHARE_STANDOUT_META_KEY, ShareStage, load_flag};
67pub use share_view::{
68 SHARE_MOTION_META_KEY, SHARE_STANDOUT_META_KEY, STRIP_DEFAULT_WIDTH, STRIP_WIDTH_META_KEY,
69 ShareStage, StripDrag, clamp_strip_width, load_flag, load_strip_width,
70};
66pub use speed_dial::SpeedDialEntry;
71pub use speed_dial::SpeedDialEntry;
67pub use stage_layout::{contain_size, focus_stage_size, gallery_grid};
72pub use stage_layout::{contain_size, focus_stage_size, gallery_grid};
68pub use stage_split::{
73pub use stage_split::{
69 GRID_PADDING, GalleryPage, STRIP_GAP, SpeakerSplit, StripSplit, TILE_GAP, gallery_page,
74 GRID_PADDING, STRIP_GAP, SpeakerSplit, StripSplit, TILE_GAP, gallery_page, measured_stage,
70 measured_stage, speaker_split, strip_split, video_wants,
75 speaker_split, strip_split, video_wants,
71};
76};
72pub use target::{is_echo_chat, plan_for_chat};
77pub use target::{is_echo_chat, plan_for_chat};
73pub use transcript::clock_label;
78pub use transcript::clock_label;
crates/app/src/settings/devices.rs +6 −5
@@ -135,7 +135,7 @@ impl DevicesView {
135 135 };
136 136 view.load_devices(demo, cx);
137 137 view.apply_background(cx);
138 view.start_preview();
138 view.start_preview(cx);
139 139 view
140 140 }
141 141
@@ -165,9 +165,10 @@ impl DevicesView {
165 165 .detach();
166 166 }
167 167
168 fn start_preview(&mut self) {
168 fn start_preview(&mut self, cx: &Context<Self>) {
169 169 if !self.preview_blocked {
170 self.preview.start(&self.camera);
170 let quality = self.app.read(cx).call_video_quality;
171 self.preview.start(&self.camera, quality);
171 172 }
172 173 }
173 174
@@ -180,7 +181,7 @@ impl DevicesView {
180 181 if blocked {
181 182 self.preview.stop(cx);
182 183 } else {
183 self.start_preview();
184 self.start_preview(cx);
184 185 }
185 186 cx.notify();
186 187 }
@@ -189,7 +190,7 @@ impl DevicesView {
189 190 self.camera = camera.clone();
190 191 self.app
191 192 .update(cx, |state, cx| state.select_call_camera(camera, cx));
192 self.start_preview();
193 self.start_preview(cx);
193 194 cx.notify();
194 195 }
195 196
@@ -135,7 +135,7 @@ impl DevicesView {
135 };
135 };
136 view.load_devices(demo, cx);
136 view.load_devices(demo, cx);
137 view.apply_background(cx);
137 view.apply_background(cx);
138 view.start_preview();
138 view.start_preview(cx);
139 view
139 view
140 }
140 }
141
141
@@ -165,9 +165,10 @@ impl DevicesView {
165 .detach();
165 .detach();
166 }
166 }
167
167
168 fn start_preview(&mut self) {
168 fn start_preview(&mut self, cx: &Context<Self>) {
169 if !self.preview_blocked {
169 if !self.preview_blocked {
170 self.preview.start(&self.camera);
170 let quality = self.app.read(cx).call_video_quality;
171 self.preview.start(&self.camera, quality);
171 }
172 }
172 }
173 }
173
174
@@ -180,7 +181,7 @@ impl DevicesView {
180 if blocked {
181 if blocked {
181 self.preview.stop(cx);
182 self.preview.stop(cx);
182 } else {
183 } else {
183 self.start_preview();
184 self.start_preview(cx);
184 }
185 }
185 cx.notify();
186 cx.notify();
186 }
187 }
@@ -189,7 +190,7 @@ impl DevicesView {
189 self.camera = camera.clone();
190 self.camera = camera.clone();
190 self.app
191 self.app
191 .update(cx, |state, cx| state.select_call_camera(camera, cx));
192 .update(cx, |state, cx| state.select_call_camera(camera, cx));
192 self.start_preview();
193 self.start_preview(cx);
193 cx.notify();
194 cx.notify();
194 }
195 }
195
196
crates/app/src/views/call_extras.rs +68 −26
@@ -1,3 +1,4 @@
1 use crate::i18n::{tr, tr_args};
1 2 use crate::views::image_memory::bounded;
2 3 use std::path::PathBuf;
3 4
@@ -61,7 +62,7 @@ pub fn return_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyEle
61 62 let app = app.clone();
62 63 Some(
63 64 Button::new("call-return-main")
64 .label("Return to main meeting")
65 .label(tr("calls.chrome.return_main"))
65 66 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.return_to_main_meeting(cx)))
66 67 .into_any_element(),
67 68 )
@@ -74,7 +75,7 @@ pub fn room_chip(model: &CallModel) -> Option<AnyElement> {
74 75 .flex_none()
75 76 .text_size(px(13.))
76 77 .text_color(theme::text_muted())
77 .child("Breakout room")
78 .child(tr("calls.chrome.breakout_room"))
78 79 .into_any_element(),
79 80 )
80 81 }
@@ -83,21 +84,21 @@ pub fn hold_panel(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElemen
83 84 let (title, detail) = match model.hold {
84 85 HoldState::Active => return None,
85 86 HoldState::Local => (
86 "On hold".to_owned(),
87 tr("calls.chrome.on_hold"),
87 88 format!(
88 89 "{} cannot hear you and you cannot hear them.",
89 90 model.peer_name
90 91 ),
91 92 ),
92 93 HoldState::Remote => (
93 "You're on hold".to_owned(),
94 tr("calls.chrome.you_on_hold"),
94 95 format!("{} put the call on hold.", model.peer_name),
95 96 ),
96 97 };
97 98 let resume = (model.hold == HoldState::Local).then(|| {
98 99 let app = app.clone();
99 100 Button::new("call-resume")
100 .label("Resume")
101 .label(tr("common.resume"))
101 102 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_hold(cx)))
102 103 });
103 104 Some(
@@ -140,7 +141,7 @@ pub fn whiteboard_stage(app: &Entity<AppState>, model: &CallModel) -> Option<Any
140 141 let open = model.whiteboard_url().is_some().then(|| {
141 142 let app = app.clone();
142 143 Button::new("call-whiteboard-open")
143 .label("Open in browser")
144 .label(tr("calls.chrome.open_in_browser"))
144 145 .icon(IconName::ExternalLink)
145 146 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.open_call_whiteboard(cx)))
146 147 });
@@ -180,7 +181,7 @@ pub fn consult_banner(app: &Entity<AppState>, state: &AppState) -> Option<AnyEle
180 181 .unwrap_or("call")
181 182 .to_owned();
182 183 let (transfer_app, resume_app) = (app.clone(), app.clone());
183 let transfer = pill("call-consult-transfer", "Transfer", true)
184 let transfer = pill("call-consult-transfer", tr("calls.chrome.transfer"), true)
184 185 .debug_selector(|| "shell/islands/main/call-header/call-consult/transfer".into());
185 186 let transfer = if ready {
186 187 transfer.on_click(move |_, _, cx| {
@@ -189,9 +190,17 @@ pub fn consult_banner(app: &Entity<AppState>, state: &AppState) -> Option<AnyEle
189 190 } else {
190 191 transfer.opacity(0.5).cursor_default()
191 192 };
192 let resume = pill("call-consult-resume", format!("Resume {first_name}"), false)
193 .debug_selector(|| "shell/islands/main/call-header/call-consult/resume".into())
194 .on_click(move |_, _, cx| resume_app.update(cx, |state, cx| state.resume_held_call(cx)));
193 let resume = {
194 let mut args = std::collections::HashMap::new();
195 args.insert("name".to_owned(), first_name);
196 pill(
197 "call-consult-resume",
198 tr_args("calls.chrome.resume_person", &args),
199 false,
200 )
201 }
202 .debug_selector(|| "shell/islands/main/call-header/call-consult/resume".into())
203 .on_click(move |_, _, cx| resume_app.update(cx, |state, cx| state.resume_held_call(cx)));
195 204 Some(
196 205 h_flex()
197 206 .id("call-consult-banner")
@@ -259,19 +268,19 @@ pub fn consent_overlay(app: &Entity<AppState>, model: &CallModel) -> Option<AnyE
259 268 div()
260 269 .text_size(px(16.))
261 270 .font_weight(FontWeight::SEMIBOLD)
262 .child("This meeting is being recorded"),
271 .child(tr("calls.chrome.recording_notice")),
263 272 ),
264 273 )
265 274 .child(
266 275 div()
267 276 .text_size(px(13.))
268 277 .text_color(theme::text_muted())
269 .child("Your microphone and camera stay off until you accept."),
278 .child(tr("calls.chrome.recording_accept_hint")),
270 279 )
271 280 .child(
272 281 h_flex().w_full().justify_end().child(
273 282 Button::new("call-consent-ok")
274 .label("OK")
283 .label(tr("common.ok"))
275 284 .on_click(move |_, _, cx| {
276 285 app.update(cx, |state, cx| state.accept_recording_notice(cx))
277 286 }),
@@ -295,8 +304,8 @@ pub fn confirm_record_action(
295 304 let app = app.clone();
296 305 window.open_alert_dialog(cx, move |alert, _, _| {
297 306 let app = app.clone();
298 let cancel = Button::new("recording-cancel").label("Cancel").on_click(|_, window, cx| window.close_dialog(cx));
299 let stop = Button::new("recording-stop").label("Stop").danger().on_click(move |_, window, cx| {
307 let cancel = Button::new("recording-cancel").label(tr("common.cancel")).on_click(|_, window, cx| window.close_dialog(cx));
308 let stop = Button::new("recording-stop").label(tr("common.stop")).danger().on_click(move |_, window, cx| {
300 309 app.update(cx, |state, cx| state.run_call_record_action(action, cx));
301 310 window.close_dialog(cx);
302 311 });
@@ -332,6 +341,7 @@ pub struct CameraMenu {
332 341 pub images: Vec<(String, String, Option<PathBuf>)>,
333 342 pub customs: Vec<PathBuf>,
334 343 pub effects: CameraEffects,
344 pub quality: calling::VideoQuality,
335 345 }
336 346
337 347 impl CameraMenu {
@@ -352,10 +362,42 @@ impl CameraMenu {
352 362 .collect(),
353 363 customs: library.customs.clone(),
354 364 effects: state.call_effects,
365 quality: state.call_video_quality,
355 366 }
356 367 }
357 368 }
358 369
370 pub fn quality_items(
371 popup: PopupMenu,
372 app: &Entity<AppState>,
373 current: calling::VideoQuality,
374 ) -> PopupMenu {
375 let choices = [
376 (calling::VideoQuality::Auto, "Auto"),
377 (calling::VideoQuality::P720, "720p"),
378 (calling::VideoQuality::P1080, "1080p"),
379 ];
380 let mut popup = popup
381 .separator()
382 .item(PopupMenuItem::label(tr("calls.chrome.video_quality")));
383 for (quality, label) in choices {
384 let app = app.clone();
385 let menu_label = if quality == calling::VideoQuality::Auto {
386 tr("calls.chrome.auto")
387 } else {
388 label.to_owned()
389 };
390 popup = popup.item(
391 PopupMenuItem::new(menu_label)
392 .checked(current == quality)
393 .on_click(move |_, _, cx| {
394 app.update(cx, |state, cx| state.set_call_video_quality(quality, cx))
395 }),
396 );
397 }
398 popup
399 }
400
359 401 fn thumbnail(
360 402 app: &Entity<AppState>,
361 403 index: usize,
@@ -412,7 +454,7 @@ fn effect_change(
412 454 fn effect_switch_item(
413 455 app: &Entity<AppState>,
414 456 id: &'static str,
415 label: &'static str,
457 label: String,
416 458 on: bool,
417 459 change: fn(&mut CameraEffects),
418 460 ) -> PopupMenuItem {
@@ -423,7 +465,7 @@ fn effect_switch_item(
423 465 .gap(px(16.))
424 466 .items_center()
425 467 .justify_between()
426 .child(label)
468 .child(label.clone())
427 469 .child(Switch::new(id).checked(on))
428 470 })
429 471 .on_click(effect_change(app, change))
@@ -432,32 +474,32 @@ fn effect_switch_item(
432 474 pub fn effect_items(popup: PopupMenu, app: &Entity<AppState>, effects: CameraEffects) -> PopupMenu {
433 475 popup
434 476 .separator()
435 .item(PopupMenuItem::label("Effects"))
477 .item(PopupMenuItem::label(tr("calls.chrome.effects")))
436 478 .item(effect_switch_item(
437 479 app,
438 480 "call-effect-mirror",
439 "Mirror my video",
481 tr("calls.chrome.mirror_video"),
440 482 effects.mirror,
441 483 |effects| effects.mirror = !effects.mirror,
442 484 ))
443 485 .item(effect_switch_item(
444 486 app,
445 487 "call-effect-framing",
446 "Auto framing",
488 tr("calls.chrome.auto_framing"),
447 489 effects.auto_framing,
448 490 |effects| effects.auto_framing = !effects.auto_framing,
449 491 ))
450 492 .item(effect_switch_item(
451 493 app,
452 494 "call-effect-brightness",
453 "Adjust brightness",
495 tr("calls.chrome.adjust_brightness"),
454 496 effects.adjust_brightness,
455 497 |effects| effects.adjust_brightness = !effects.adjust_brightness,
456 498 ))
457 499 .item(effect_switch_item(
458 500 app,
459 501 "call-effect-soft-focus",
460 "Soft focus",
502 tr("calls.chrome.soft_focus"),
461 503 effects.soft_focus,
462 504 |effects| effects.soft_focus = !effects.soft_focus,
463 505 ))
@@ -469,9 +511,9 @@ pub fn background_items(popup: PopupMenu, app: &Entity<AppState>, menu: &CameraM
469 511 let grid_menu = menu.clone();
470 512 let mut popup = popup
471 513 .separator()
472 .item(PopupMenuItem::label("Background"))
514 .item(PopupMenuItem::label(tr("calls.chrome.background")))
473 515 .item(
474 PopupMenuItem::new("None")
516 PopupMenuItem::new(tr("calls.chrome.background_none"))
475 517 .checked(menu.pick == BackgroundPick::None)
476 518 .on_click(move |_, _, cx| {
477 519 none_app.update(cx, |state, cx| {
@@ -480,7 +522,7 @@ pub fn background_items(popup: PopupMenu, app: &Entity<AppState>, menu: &CameraM
480 522 }),
481 523 )
482 524 .item(
483 PopupMenuItem::new("Blur")
525 PopupMenuItem::new(tr("calls.chrome.background_blur"))
484 526 .checked(menu.pick.is_blur())
485 527 .on_click(move |_, _, cx| {
486 528 blur_app.update(cx, |state, cx| {
@@ -527,7 +569,7 @@ pub fn background_items(popup: PopupMenu, app: &Entity<AppState>, menu: &CameraM
527 569 }));
528 570 }
529 571 popup.item(
530 PopupMenuItem::new("Add image...")
572 PopupMenuItem::new(tr("calls.chrome.add_image"))
531 573 .icon(IconName::Plus)
532 574 .on_click(move |_, _, cx| {
533 575 add_app.update(cx, |state, cx| state.add_call_background(cx))
@@ -1,3 +1,4 @@
1use crate::i18n::{tr, tr_args};
1use crate::views::image_memory::bounded;
2use crate::views::image_memory::bounded;
2use std::path::PathBuf;
3use std::path::PathBuf;
3
4
@@ -61,7 +62,7 @@ pub fn return_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyEle
61 let app = app.clone();
62 let app = app.clone();
62 Some(
63 Some(
63 Button::new("call-return-main")
64 Button::new("call-return-main")
64 .label("Return to main meeting")
65 .label(tr("calls.chrome.return_main"))
65 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.return_to_main_meeting(cx)))
66 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.return_to_main_meeting(cx)))
66 .into_any_element(),
67 .into_any_element(),
67 )
68 )
@@ -74,7 +75,7 @@ pub fn room_chip(model: &CallModel) -> Option<AnyElement> {
74 .flex_none()
75 .flex_none()
75 .text_size(px(13.))
76 .text_size(px(13.))
76 .text_color(theme::text_muted())
77 .text_color(theme::text_muted())
77 .child("Breakout room")
78 .child(tr("calls.chrome.breakout_room"))
78 .into_any_element(),
79 .into_any_element(),
79 )
80 )
80}
81}
@@ -83,21 +84,21 @@ pub fn hold_panel(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElemen
83 let (title, detail) = match model.hold {
84 let (title, detail) = match model.hold {
84 HoldState::Active => return None,
85 HoldState::Active => return None,
85 HoldState::Local => (
86 HoldState::Local => (
86 "On hold".to_owned(),
87 tr("calls.chrome.on_hold"),
87 format!(
88 format!(
88 "{} cannot hear you and you cannot hear them.",
89 "{} cannot hear you and you cannot hear them.",
89 model.peer_name
90 model.peer_name
90 ),
91 ),
91 ),
92 ),
92 HoldState::Remote => (
93 HoldState::Remote => (
93 "You're on hold".to_owned(),
94 tr("calls.chrome.you_on_hold"),
94 format!("{} put the call on hold.", model.peer_name),
95 format!("{} put the call on hold.", model.peer_name),
95 ),
96 ),
96 };
97 };
97 let resume = (model.hold == HoldState::Local).then(|| {
98 let resume = (model.hold == HoldState::Local).then(|| {
98 let app = app.clone();
99 let app = app.clone();
99 Button::new("call-resume")
100 Button::new("call-resume")
100 .label("Resume")
101 .label(tr("common.resume"))
101 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_hold(cx)))
102 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_hold(cx)))
102 });
103 });
103 Some(
104 Some(
@@ -140,7 +141,7 @@ pub fn whiteboard_stage(app: &Entity<AppState>, model: &CallModel) -> Option<Any
140 let open = model.whiteboard_url().is_some().then(|| {
141 let open = model.whiteboard_url().is_some().then(|| {
141 let app = app.clone();
142 let app = app.clone();
142 Button::new("call-whiteboard-open")
143 Button::new("call-whiteboard-open")
143 .label("Open in browser")
144 .label(tr("calls.chrome.open_in_browser"))
144 .icon(IconName::ExternalLink)
145 .icon(IconName::ExternalLink)
145 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.open_call_whiteboard(cx)))
146 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.open_call_whiteboard(cx)))
146 });
147 });
@@ -180,7 +181,7 @@ pub fn consult_banner(app: &Entity<AppState>, state: &AppState) -> Option<AnyEle
180 .unwrap_or("call")
181 .unwrap_or("call")
181 .to_owned();
182 .to_owned();
182 let (transfer_app, resume_app) = (app.clone(), app.clone());
183 let (transfer_app, resume_app) = (app.clone(), app.clone());
183 let transfer = pill("call-consult-transfer", "Transfer", true)
184 let transfer = pill("call-consult-transfer", tr("calls.chrome.transfer"), true)
184 .debug_selector(|| "shell/islands/main/call-header/call-consult/transfer".into());
185 .debug_selector(|| "shell/islands/main/call-header/call-consult/transfer".into());
185 let transfer = if ready {
186 let transfer = if ready {
186 transfer.on_click(move |_, _, cx| {
187 transfer.on_click(move |_, _, cx| {
@@ -189,9 +190,17 @@ pub fn consult_banner(app: &Entity<AppState>, state: &AppState) -> Option<AnyEle
189 } else {
190 } else {
190 transfer.opacity(0.5).cursor_default()
191 transfer.opacity(0.5).cursor_default()
191 };
192 };
192 let resume = pill("call-consult-resume", format!("Resume {first_name}"), false)
193 let resume = {
193 .debug_selector(|| "shell/islands/main/call-header/call-consult/resume".into())
194 let mut args = std::collections::HashMap::new();
194 .on_click(move |_, _, cx| resume_app.update(cx, |state, cx| state.resume_held_call(cx)));
195 args.insert("name".to_owned(), first_name);
196 pill(
197 "call-consult-resume",
198 tr_args("calls.chrome.resume_person", &args),
199 false,
200 )
201 }
202 .debug_selector(|| "shell/islands/main/call-header/call-consult/resume".into())
203 .on_click(move |_, _, cx| resume_app.update(cx, |state, cx| state.resume_held_call(cx)));
195 Some(
204 Some(
196 h_flex()
205 h_flex()
197 .id("call-consult-banner")
206 .id("call-consult-banner")
@@ -259,19 +268,19 @@ pub fn consent_overlay(app: &Entity<AppState>, model: &CallModel) -> Option<AnyE
259 div()
268 div()
260 .text_size(px(16.))
269 .text_size(px(16.))
261 .font_weight(FontWeight::SEMIBOLD)
270 .font_weight(FontWeight::SEMIBOLD)
262 .child("This meeting is being recorded"),
271 .child(tr("calls.chrome.recording_notice")),
263 ),
272 ),
264 )
273 )
265 .child(
274 .child(
266 div()
275 div()
267 .text_size(px(13.))
276 .text_size(px(13.))
268 .text_color(theme::text_muted())
277 .text_color(theme::text_muted())
269 .child("Your microphone and camera stay off until you accept."),
278 .child(tr("calls.chrome.recording_accept_hint")),
270 )
279 )
271 .child(
280 .child(
272 h_flex().w_full().justify_end().child(
281 h_flex().w_full().justify_end().child(
273 Button::new("call-consent-ok")
282 Button::new("call-consent-ok")
274 .label("OK")
283 .label(tr("common.ok"))
275 .on_click(move |_, _, cx| {
284 .on_click(move |_, _, cx| {
276 app.update(cx, |state, cx| state.accept_recording_notice(cx))
285 app.update(cx, |state, cx| state.accept_recording_notice(cx))
277 }),
286 }),
@@ -295,8 +304,8 @@ pub fn confirm_record_action(
295 let app = app.clone();
304 let app = app.clone();
296 window.open_alert_dialog(cx, move |alert, _, _| {
305 window.open_alert_dialog(cx, move |alert, _, _| {
297 let app = app.clone();
306 let app = app.clone();
298 let cancel = Button::new("recording-cancel").label("Cancel").on_click(|_, window, cx| window.close_dialog(cx));
307 let cancel = Button::new("recording-cancel").label(tr("common.cancel")).on_click(|_, window, cx| window.close_dialog(cx));
299 let stop = Button::new("recording-stop").label("Stop").danger().on_click(move |_, window, cx| {
308 let stop = Button::new("recording-stop").label(tr("common.stop")).danger().on_click(move |_, window, cx| {
300 app.update(cx, |state, cx| state.run_call_record_action(action, cx));
309 app.update(cx, |state, cx| state.run_call_record_action(action, cx));
301 window.close_dialog(cx);
310 window.close_dialog(cx);
302 });
311 });
@@ -332,6 +341,7 @@ pub struct CameraMenu {
332 pub images: Vec<(String, String, Option<PathBuf>)>,
341 pub images: Vec<(String, String, Option<PathBuf>)>,
333 pub customs: Vec<PathBuf>,
342 pub customs: Vec<PathBuf>,
334 pub effects: CameraEffects,
343 pub effects: CameraEffects,
344 pub quality: calling::VideoQuality,
335}
345}
336
346
337impl CameraMenu {
347impl CameraMenu {
@@ -352,10 +362,42 @@ impl CameraMenu {
352 .collect(),
362 .collect(),
353 customs: library.customs.clone(),
363 customs: library.customs.clone(),
354 effects: state.call_effects,
364 effects: state.call_effects,
365 quality: state.call_video_quality,
355 }
366 }
356 }
367 }
357}
368}
358
369
370pub fn quality_items(
371 popup: PopupMenu,
372 app: &Entity<AppState>,
373 current: calling::VideoQuality,
374) -> PopupMenu {
375 let choices = [
376 (calling::VideoQuality::Auto, "Auto"),
377 (calling::VideoQuality::P720, "720p"),
378 (calling::VideoQuality::P1080, "1080p"),
379 ];
380 let mut popup = popup
381 .separator()
382 .item(PopupMenuItem::label(tr("calls.chrome.video_quality")));
383 for (quality, label) in choices {
384 let app = app.clone();
385 let menu_label = if quality == calling::VideoQuality::Auto {
386 tr("calls.chrome.auto")
387 } else {
388 label.to_owned()
389 };
390 popup = popup.item(
391 PopupMenuItem::new(menu_label)
392 .checked(current == quality)
393 .on_click(move |_, _, cx| {
394 app.update(cx, |state, cx| state.set_call_video_quality(quality, cx))
395 }),
396 );
397 }
398 popup
399}
400
359fn thumbnail(
401fn thumbnail(
360 app: &Entity<AppState>,
402 app: &Entity<AppState>,
361 index: usize,
403 index: usize,
@@ -412,7 +454,7 @@ fn effect_change(
412fn effect_switch_item(
454fn effect_switch_item(
413 app: &Entity<AppState>,
455 app: &Entity<AppState>,
414 id: &'static str,
456 id: &'static str,
415 label: &'static str,
457 label: String,
416 on: bool,
458 on: bool,
417 change: fn(&mut CameraEffects),
459 change: fn(&mut CameraEffects),
418) -> PopupMenuItem {
460) -> PopupMenuItem {
@@ -423,7 +465,7 @@ fn effect_switch_item(
423 .gap(px(16.))
465 .gap(px(16.))
424 .items_center()
466 .items_center()
425 .justify_between()
467 .justify_between()
426 .child(label)
468 .child(label.clone())
427 .child(Switch::new(id).checked(on))
469 .child(Switch::new(id).checked(on))
428 })
470 })
429 .on_click(effect_change(app, change))
471 .on_click(effect_change(app, change))
@@ -432,32 +474,32 @@ fn effect_switch_item(
432pub fn effect_items(popup: PopupMenu, app: &Entity<AppState>, effects: CameraEffects) -> PopupMenu {
474pub fn effect_items(popup: PopupMenu, app: &Entity<AppState>, effects: CameraEffects) -> PopupMenu {
433 popup
475 popup
434 .separator()
476 .separator()
435 .item(PopupMenuItem::label("Effects"))
477 .item(PopupMenuItem::label(tr("calls.chrome.effects")))
436 .item(effect_switch_item(
478 .item(effect_switch_item(
437 app,
479 app,
438 "call-effect-mirror",
480 "call-effect-mirror",
439 "Mirror my video",
481 tr("calls.chrome.mirror_video"),
440 effects.mirror,
482 effects.mirror,
441 |effects| effects.mirror = !effects.mirror,
483 |effects| effects.mirror = !effects.mirror,
442 ))
484 ))
443 .item(effect_switch_item(
485 .item(effect_switch_item(
444 app,
486 app,
445 "call-effect-framing",
487 "call-effect-framing",
446 "Auto framing",
488 tr("calls.chrome.auto_framing"),
447 effects.auto_framing,
489 effects.auto_framing,
448 |effects| effects.auto_framing = !effects.auto_framing,
490 |effects| effects.auto_framing = !effects.auto_framing,
449 ))
491 ))
450 .item(effect_switch_item(
492 .item(effect_switch_item(
451 app,
493 app,
452 "call-effect-brightness",
494 "call-effect-brightness",
453 "Adjust brightness",
495 tr("calls.chrome.adjust_brightness"),
454 effects.adjust_brightness,
496 effects.adjust_brightness,
455 |effects| effects.adjust_brightness = !effects.adjust_brightness,
497 |effects| effects.adjust_brightness = !effects.adjust_brightness,
456 ))
498 ))
457 .item(effect_switch_item(
499 .item(effect_switch_item(
458 app,
500 app,
459 "call-effect-soft-focus",
501 "call-effect-soft-focus",
460 "Soft focus",
502 tr("calls.chrome.soft_focus"),
461 effects.soft_focus,
503 effects.soft_focus,
462 |effects| effects.soft_focus = !effects.soft_focus,
504 |effects| effects.soft_focus = !effects.soft_focus,
463 ))
505 ))
@@ -469,9 +511,9 @@ pub fn background_items(popup: PopupMenu, app: &Entity<AppState>, menu: &CameraM
469 let grid_menu = menu.clone();
511 let grid_menu = menu.clone();
470 let mut popup = popup
512 let mut popup = popup
471 .separator()
513 .separator()
472 .item(PopupMenuItem::label("Background"))
514 .item(PopupMenuItem::label(tr("calls.chrome.background")))
473 .item(
515 .item(
474 PopupMenuItem::new("None")
516 PopupMenuItem::new(tr("calls.chrome.background_none"))
475 .checked(menu.pick == BackgroundPick::None)
517 .checked(menu.pick == BackgroundPick::None)
476 .on_click(move |_, _, cx| {
518 .on_click(move |_, _, cx| {
477 none_app.update(cx, |state, cx| {
519 none_app.update(cx, |state, cx| {
@@ -480,7 +522,7 @@ pub fn background_items(popup: PopupMenu, app: &Entity<AppState>, menu: &CameraM
480 }),
522 }),
481 )
523 )
482 .item(
524 .item(
483 PopupMenuItem::new("Blur")
525 PopupMenuItem::new(tr("calls.chrome.background_blur"))
484 .checked(menu.pick.is_blur())
526 .checked(menu.pick.is_blur())
485 .on_click(move |_, _, cx| {
527 .on_click(move |_, _, cx| {
486 blur_app.update(cx, |state, cx| {
528 blur_app.update(cx, |state, cx| {
@@ -527,7 +569,7 @@ pub fn background_items(popup: PopupMenu, app: &Entity<AppState>, menu: &CameraM
527 }));
569 }));
528 }
570 }
529 popup.item(
571 popup.item(
530 PopupMenuItem::new("Add image...")
572 PopupMenuItem::new(tr("calls.chrome.add_image"))
531 .icon(IconName::Plus)
573 .icon(IconName::Plus)
532 .on_click(move |_, _, cx| {
574 .on_click(move |_, _, cx| {
533 add_app.update(cx, |state, cx| state.add_call_background(cx))
575 add_app.update(cx, |state, cx| state.add_call_background(cx))
crates/app/src/views/call_organizer.rs +10 −5
@@ -20,6 +20,7 @@ use super::call_view::{BANNER_HEIGHT, MENU_WIDTH};
20 20 use super::widgets::{Corner, corner_badge, count_badge, icon};
21 21 use crate::app_state::AppState;
22 22 use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus, contain_size};
23 use crate::i18n::tr;
23 24 use crate::notice::truncated;
24 25 use crate::theme;
25 26
@@ -98,7 +99,7 @@ fn lobby_list(app: &Entity<AppState>, guests: &[(String, String)]) -> Div {
98 99 )
99 100 .child(
100 101 Button::new(SharedString::from(format!("lobby-admit-{mri}")))
101 .label("Admit")
102 .label(tr("common.admit"))
102 103 .on_click(move |_, _, cx| {
103 104 admit_app.update(cx, |state, cx| {
104 105 state.admit_call_guest(admit_mri.clone(), cx)
@@ -107,7 +108,7 @@ fn lobby_list(app: &Entity<AppState>, guests: &[(String, String)]) -> Div {
107 108 )
108 109 .child(
109 110 Button::new(SharedString::from(format!("lobby-deny-{mri}")))
110 .label("Deny")
111 .label(tr("common.deny"))
111 112 .ghost()
112 113 .on_click(move |_, _, cx| {
113 114 deny_app
@@ -192,10 +193,10 @@ fn confirm_remove(
192 193 let app = app.clone();
193 194 let mri = mri.clone();
194 195 let cancel = Button::new("remove-cancel")
195 .label("Cancel")
196 .label(tr("common.cancel"))
196 197 .on_click(|_, window, cx| window.close_dialog(cx));
197 198 let remove = Button::new("remove-confirm")
198 .label("Remove")
199 .label(tr("common.remove"))
199 200 .danger()
200 201 .on_click(move |_, window, cx| {
201 202 app.update(cx, |state, cx| {
@@ -634,7 +635,11 @@ fn camera_menu(
634 635 popup = popup.item(item);
635 636 }
636 637 background_items(
637 effect_items(popup, app, backgrounds.effects),
638 effect_items(
639 super::call_extras::quality_items(popup, app, backgrounds.quality),
640 app,
641 backgrounds.effects,
642 ),
638 643 app,
639 644 backgrounds,
640 645 )
@@ -20,6 +20,7 @@ use super::call_view::{BANNER_HEIGHT, MENU_WIDTH};
20use super::widgets::{Corner, corner_badge, count_badge, icon};
20use super::widgets::{Corner, corner_badge, count_badge, icon};
21use crate::app_state::AppState;
21use crate::app_state::AppState;
22use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus, contain_size};
22use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus, contain_size};
23use crate::i18n::tr;
23use crate::notice::truncated;
24use crate::notice::truncated;
24use crate::theme;
25use crate::theme;
25
26
@@ -98,7 +99,7 @@ fn lobby_list(app: &Entity<AppState>, guests: &[(String, String)]) -> Div {
98 )
99 )
99 .child(
100 .child(
100 Button::new(SharedString::from(format!("lobby-admit-{mri}")))
101 Button::new(SharedString::from(format!("lobby-admit-{mri}")))
101 .label("Admit")
102 .label(tr("common.admit"))
102 .on_click(move |_, _, cx| {
103 .on_click(move |_, _, cx| {
103 admit_app.update(cx, |state, cx| {
104 admit_app.update(cx, |state, cx| {
104 state.admit_call_guest(admit_mri.clone(), cx)
105 state.admit_call_guest(admit_mri.clone(), cx)
@@ -107,7 +108,7 @@ fn lobby_list(app: &Entity<AppState>, guests: &[(String, String)]) -> Div {
107 )
108 )
108 .child(
109 .child(
109 Button::new(SharedString::from(format!("lobby-deny-{mri}")))
110 Button::new(SharedString::from(format!("lobby-deny-{mri}")))
110 .label("Deny")
111 .label(tr("common.deny"))
111 .ghost()
112 .ghost()
112 .on_click(move |_, _, cx| {
113 .on_click(move |_, _, cx| {
113 deny_app
114 deny_app
@@ -192,10 +193,10 @@ fn confirm_remove(
192 let app = app.clone();
193 let app = app.clone();
193 let mri = mri.clone();
194 let mri = mri.clone();
194 let cancel = Button::new("remove-cancel")
195 let cancel = Button::new("remove-cancel")
195 .label("Cancel")
196 .label(tr("common.cancel"))
196 .on_click(|_, window, cx| window.close_dialog(cx));
197 .on_click(|_, window, cx| window.close_dialog(cx));
197 let remove = Button::new("remove-confirm")
198 let remove = Button::new("remove-confirm")
198 .label("Remove")
199 .label(tr("common.remove"))
199 .danger()
200 .danger()
200 .on_click(move |_, window, cx| {
201 .on_click(move |_, window, cx| {
201 app.update(cx, |state, cx| {
202 app.update(cx, |state, cx| {
@@ -634,7 +635,11 @@ fn camera_menu(
634 popup = popup.item(item);
635 popup = popup.item(item);
635 }
636 }
636 background_items(
637 background_items(
637 effect_items(popup, app, backgrounds.effects),
638 effect_items(
639 super::call_extras::quality_items(popup, app, backgrounds.quality),
640 app,
641 backgrounds.effects,
642 ),
638 app,
643 app,
639 backgrounds,
644 backgrounds,
640 )
645 )
crates/app/src/views/prejoin_view.rs +51 −23
@@ -12,10 +12,11 @@ use gpui_kit::prelude::FluentBuilder as _;
12 12 use gpui_kit::*;
13 13
14 14 use super::avatar::person_avatar;
15 use super::call_extras::{CameraMenu, background_items};
15 use super::call_extras::{CameraMenu, background_items, quality_items};
16 16 use super::call_view::{device_items, round_control};
17 17 use crate::app_state::AppState;
18 18 use crate::call::{AudioChoice, CameraPreview, JoinOptions, PendingJoin};
19 use crate::i18n::{tr, tr_args};
19 20 use crate::theme;
20 21
21 22 const CONTENT_WIDTH: f32 = 560.;
@@ -28,8 +29,6 @@ const PANE_PADDING: f32 = 12.;
28 29 const PREVIEW_MIN_HEIGHT: f32 = 60.;
29 30 const FRAME_TICK: Duration = Duration::from_millis(100);
30 31 const FPS_TICK: Duration = Duration::from_millis(500);
31 const CAMERA_OFF_TEXT: &str = "Your camera is off";
32 const DEFAULT_LABEL: &str = "Default device";
33 32 const DEMO_MICROPHONES: [&str; 2] = ["Headset microphone", "Laptop microphone"];
34 33 const DEMO_SPEAKERS: [&str; 2] = ["Headset earphones", "Laptop speakers"];
35 34
@@ -45,6 +44,7 @@ pub struct PrejoinView {
45 44 input: DeviceChoice,
46 45 output: DeviceChoice,
47 46 applied_background: crate::call::BackgroundPick,
47 applied_quality: calling::VideoQuality,
48 48 tick: u32,
49 49 _subscription: Subscription,
50 50 _release: Subscription,
@@ -52,7 +52,7 @@ pub struct PrejoinView {
52 52
53 53 struct DeviceSelect {
54 54 id: &'static str,
55 label: &'static str,
55 label: String,
56 56 entries: Vec<DeviceEntry>,
57 57 current: DeviceChoice,
58 58 enabled: bool,
@@ -82,7 +82,10 @@ fn label_of(entries: &[DeviceEntry], choice: &DeviceChoice) -> String {
82 82 entries
83 83 .iter()
84 84 .find(|entry| &entry.choice == choice)
85 .map_or_else(|| DEFAULT_LABEL.to_owned(), |entry| entry.label.clone())
85 .map_or_else(
86 || tr("calls.prejoin.default_device"),
87 |entry| entry.label.clone(),
88 )
86 89 }
87 90
88 91 impl PrejoinView {
@@ -92,7 +95,10 @@ impl PrejoinView {
92 95 _window: &mut Window,
93 96 cx: &mut Context<Self>,
94 97 ) -> Self {
95 let subscription = cx.observe(&app, |view, _, cx| view.sync_background(cx));
98 let subscription = cx.observe(&app, |view, _, cx| {
99 view.sync_background(cx);
100 view.sync_quality(cx);
101 });
96 102 let release = cx.on_release(|view, cx| view.preview.stop(cx));
97 103 let (preview, mut updates) = CameraPreview::new();
98 104 let state = app.read(cx);
@@ -102,6 +108,7 @@ impl PrejoinView {
102 108 options.camera_on = options.camera_on && !state.mode.read_only;
103 109 let camera = state.call_camera.clone();
104 110 let (input, output) = (state.call_input.clone(), state.call_output.clone());
111 let applied_quality = state.call_video_quality;
105 112 let mut view = PrejoinView {
106 113 pending_id: pending.id,
107 114 demo,
@@ -117,6 +124,7 @@ impl PrejoinView {
117 124 input,
118 125 output,
119 126 applied_background: crate::call::BackgroundPick::None,
127 applied_quality,
120 128 tick: 0,
121 129 _subscription: subscription,
122 130 _release: release,
@@ -159,7 +167,7 @@ impl PrejoinView {
159 167 view.load_devices(cx);
160 168 }
161 169 view.sync_background(cx);
162 view.restart_preview();
170 view.restart_preview(cx);
163 171 view
164 172 }
165 173
@@ -196,9 +204,10 @@ impl PrejoinView {
196 204 .detach();
197 205 }
198 206
199 fn restart_preview(&mut self) {
207 fn restart_preview(&mut self, cx: &Context<Self>) {
200 208 if self.options.camera_on && !self.demo {
201 self.preview.start(&self.camera);
209 let quality = self.app.read(cx).call_video_quality;
210 self.preview.start(&self.camera, quality);
202 211 }
203 212 }
204 213
@@ -215,10 +224,20 @@ impl PrejoinView {
215 224 cx.notify();
216 225 }
217 226
227 fn sync_quality(&mut self, cx: &mut Context<Self>) {
228 let quality = self.app.read(cx).call_video_quality;
229 if quality == self.applied_quality {
230 return;
231 }
232 self.applied_quality = quality;
233 self.restart_preview(cx);
234 cx.notify();
235 }
236
218 237 fn toggle_camera(&mut self, cx: &mut Context<Self>) {
219 238 self.options.camera_on = !self.options.camera_on;
220 239 if self.options.camera_on {
221 self.restart_preview();
240 self.restart_preview(cx);
222 241 } else {
223 242 self.preview.stop(cx);
224 243 }
@@ -239,7 +258,7 @@ impl PrejoinView {
239 258 self.camera = choice.clone();
240 259 self.app
241 260 .update(cx, |state, cx| state.select_call_camera(choice, cx));
242 self.restart_preview();
261 self.restart_preview(cx);
243 262 cx.notify();
244 263 }
245 264
@@ -270,8 +289,12 @@ impl PrejoinView {
270 289
271 290 fn preview_status(&self) -> String {
272 291 match self.preview.failure() {
273 Some(reason) => format!("Camera could not start: {reason}"),
274 None => "Starting camera...".to_owned(),
292 Some(reason) => {
293 let mut args = std::collections::HashMap::new();
294 args.insert("detail".to_owned(), reason.clone());
295 tr_args("calls.prejoin.camera_failed", &args)
296 }
297 None => tr("calls.prejoin.starting_camera"),
275 298 }
276 299 }
277 300
@@ -295,14 +318,15 @@ impl PrejoinView {
295 318 .child(person_avatar(
296 319 &state.directory,
297 320 me.as_ref().map(|me| me.user_id.as_str()),
298 me.as_ref().map_or("You", |me| me.display_name.as_str()),
321 me.as_ref()
322 .map_or(tr("common.you").as_str(), |me| me.display_name.as_str()),
299 323 AVATAR_SIZE,
300 324 ))
301 325 .child(
302 326 div()
303 327 .text_size(px(13.))
304 328 .text_color(theme::text_muted())
305 .child(CAMERA_OFF_TEXT),
329 .child(tr("calls.prejoin.camera_off")),
306 330 )
307 331 .into_any_element(),
308 332 };
@@ -362,10 +386,14 @@ impl PrejoinView {
362 386 .child(
363 387 Button::new("prejoin-background")
364 388 .outline()
365 .label("Background")
389 .label(tr("calls.prejoin.background"))
366 390 .icon(IconName::ChevronDown)
367 391 .dropdown_menu(move |menu: PopupMenu, _, _| {
368 background_items(menu, &background_app, &backgrounds)
392 background_items(
393 quality_items(menu, &background_app, backgrounds.quality),
394 &background_app,
395 &backgrounds,
396 )
369 397 }),
370 398 )
371 399 }
@@ -473,7 +501,7 @@ impl Render for PrejoinView {
473 501 .child(self.select(
474 502 DeviceSelect {
475 503 id: "prejoin-camera-select",
476 label: "Camera",
504 label: tr("calls.prejoin.camera"),
477 505 entries: cameras,
478 506 current: camera,
479 507 enabled: true,
@@ -484,7 +512,7 @@ impl Render for PrejoinView {
484 512 .child(self.select(
485 513 DeviceSelect {
486 514 id: "prejoin-mic-select",
487 label: "Microphone",
515 label: tr("calls.prejoin.microphone"),
488 516 entries: inputs,
489 517 current: input,
490 518 enabled: audio_on,
@@ -495,7 +523,7 @@ impl Render for PrejoinView {
495 523 .child(self.select(
496 524 DeviceSelect {
497 525 id: "prejoin-speaker-select",
498 label: "Speaker",
526 label: tr("calls.prejoin.speaker"),
499 527 entries: outputs,
500 528 current: output,
501 529 enabled: audio_on,
@@ -520,13 +548,13 @@ impl Render for PrejoinView {
520 548 .child(
521 549 Button::new("prejoin-cancel")
522 550 .ghost()
523 .label("Cancel")
551 .label(tr("common.cancel"))
524 552 .on_click(move |_, _, cx| cancel_view.update(cx, |view, cx| view.cancel(cx))),
525 553 )
526 554 .child(
527 555 Button::new("prejoin-join")
528 556 .primary()
529 .label("Join now")
557 .label(tr("calls.prejoin.join_now"))
530 558 .on_click(move |_, _, cx| join_view.update(cx, |view, cx| view.join(cx))),
531 559 );
532 560 v_flex()
@@ -563,7 +591,7 @@ impl Render for PrejoinView {
563 591 .truncate()
564 592 .text_size(px(13.))
565 593 .text_color(theme::text_muted())
566 .child("Choose your video and audio settings, then join"),
594 .child(tr("calls.prejoin.choose_av")),
567 595 ),
568 596 )
569 597 .child(self.preview_box(cx))
@@ -12,10 +12,11 @@ use gpui_kit::prelude::FluentBuilder as _;
12use gpui_kit::*;
12use gpui_kit::*;
13
13
14use super::avatar::person_avatar;
14use super::avatar::person_avatar;
15use super::call_extras::{CameraMenu, background_items};
15use super::call_extras::{CameraMenu, background_items, quality_items};
16use super::call_view::{device_items, round_control};
16use super::call_view::{device_items, round_control};
17use crate::app_state::AppState;
17use crate::app_state::AppState;
18use crate::call::{AudioChoice, CameraPreview, JoinOptions, PendingJoin};
18use crate::call::{AudioChoice, CameraPreview, JoinOptions, PendingJoin};
19use crate::i18n::{tr, tr_args};
19use crate::theme;
20use crate::theme;
20
21
21const CONTENT_WIDTH: f32 = 560.;
22const CONTENT_WIDTH: f32 = 560.;
@@ -28,8 +29,6 @@ const PANE_PADDING: f32 = 12.;
28const PREVIEW_MIN_HEIGHT: f32 = 60.;
29const PREVIEW_MIN_HEIGHT: f32 = 60.;
29const FRAME_TICK: Duration = Duration::from_millis(100);
30const FRAME_TICK: Duration = Duration::from_millis(100);
30const FPS_TICK: Duration = Duration::from_millis(500);
31const FPS_TICK: Duration = Duration::from_millis(500);
31const CAMERA_OFF_TEXT: &str = "Your camera is off";
32const DEFAULT_LABEL: &str = "Default device";
33const DEMO_MICROPHONES: [&str; 2] = ["Headset microphone", "Laptop microphone"];
32const DEMO_MICROPHONES: [&str; 2] = ["Headset microphone", "Laptop microphone"];
34const DEMO_SPEAKERS: [&str; 2] = ["Headset earphones", "Laptop speakers"];
33const DEMO_SPEAKERS: [&str; 2] = ["Headset earphones", "Laptop speakers"];
35
34
@@ -45,6 +44,7 @@ pub struct PrejoinView {
45 input: DeviceChoice,
44 input: DeviceChoice,
46 output: DeviceChoice,
45 output: DeviceChoice,
47 applied_background: crate::call::BackgroundPick,
46 applied_background: crate::call::BackgroundPick,
47 applied_quality: calling::VideoQuality,
48 tick: u32,
48 tick: u32,
49 _subscription: Subscription,
49 _subscription: Subscription,
50 _release: Subscription,
50 _release: Subscription,
@@ -52,7 +52,7 @@ pub struct PrejoinView {
52
52
53struct DeviceSelect {
53struct DeviceSelect {
54 id: &'static str,
54 id: &'static str,
55 label: &'static str,
55 label: String,
56 entries: Vec<DeviceEntry>,
56 entries: Vec<DeviceEntry>,
57 current: DeviceChoice,
57 current: DeviceChoice,
58 enabled: bool,
58 enabled: bool,
@@ -82,7 +82,10 @@ fn label_of(entries: &[DeviceEntry], choice: &DeviceChoice) -> String {
82 entries
82 entries
83 .iter()
83 .iter()
84 .find(|entry| &entry.choice == choice)
84 .find(|entry| &entry.choice == choice)
85 .map_or_else(|| DEFAULT_LABEL.to_owned(), |entry| entry.label.clone())
85 .map_or_else(
86 || tr("calls.prejoin.default_device"),
87 |entry| entry.label.clone(),
88 )
86}
89}
87
90
88impl PrejoinView {
91impl PrejoinView {
@@ -92,7 +95,10 @@ impl PrejoinView {
92 _window: &mut Window,
95 _window: &mut Window,
93 cx: &mut Context<Self>,
96 cx: &mut Context<Self>,
94 ) -> Self {
97 ) -> Self {
95 let subscription = cx.observe(&app, |view, _, cx| view.sync_background(cx));
98 let subscription = cx.observe(&app, |view, _, cx| {
99 view.sync_background(cx);
100 view.sync_quality(cx);
101 });
96 let release = cx.on_release(|view, cx| view.preview.stop(cx));
102 let release = cx.on_release(|view, cx| view.preview.stop(cx));
97 let (preview, mut updates) = CameraPreview::new();
103 let (preview, mut updates) = CameraPreview::new();
98 let state = app.read(cx);
104 let state = app.read(cx);
@@ -102,6 +108,7 @@ impl PrejoinView {
102 options.camera_on = options.camera_on && !state.mode.read_only;
108 options.camera_on = options.camera_on && !state.mode.read_only;
103 let camera = state.call_camera.clone();
109 let camera = state.call_camera.clone();
104 let (input, output) = (state.call_input.clone(), state.call_output.clone());
110 let (input, output) = (state.call_input.clone(), state.call_output.clone());
111 let applied_quality = state.call_video_quality;
105 let mut view = PrejoinView {
112 let mut view = PrejoinView {
106 pending_id: pending.id,
113 pending_id: pending.id,
107 demo,
114 demo,
@@ -117,6 +124,7 @@ impl PrejoinView {
117 input,
124 input,
118 output,
125 output,
119 applied_background: crate::call::BackgroundPick::None,
126 applied_background: crate::call::BackgroundPick::None,
127 applied_quality,
120 tick: 0,
128 tick: 0,
121 _subscription: subscription,
129 _subscription: subscription,
122 _release: release,
130 _release: release,
@@ -159,7 +167,7 @@ impl PrejoinView {
159 view.load_devices(cx);
167 view.load_devices(cx);
160 }
168 }
161 view.sync_background(cx);
169 view.sync_background(cx);
162 view.restart_preview();
170 view.restart_preview(cx);
163 view
171 view
164 }
172 }
165
173
@@ -196,9 +204,10 @@ impl PrejoinView {
196 .detach();
204 .detach();
197 }
205 }
198
206
199 fn restart_preview(&mut self) {
207 fn restart_preview(&mut self, cx: &Context<Self>) {
200 if self.options.camera_on && !self.demo {
208 if self.options.camera_on && !self.demo {
201 self.preview.start(&self.camera);
209 let quality = self.app.read(cx).call_video_quality;
210 self.preview.start(&self.camera, quality);
202 }
211 }
203 }
212 }
204
213
@@ -215,10 +224,20 @@ impl PrejoinView {
215 cx.notify();
224 cx.notify();
216 }
225 }
217
226
227 fn sync_quality(&mut self, cx: &mut Context<Self>) {
228 let quality = self.app.read(cx).call_video_quality;
229 if quality == self.applied_quality {
230 return;
231 }
232 self.applied_quality = quality;
233 self.restart_preview(cx);
234 cx.notify();
235 }
236
218 fn toggle_camera(&mut self, cx: &mut Context<Self>) {
237 fn toggle_camera(&mut self, cx: &mut Context<Self>) {
219 self.options.camera_on = !self.options.camera_on;
238 self.options.camera_on = !self.options.camera_on;
220 if self.options.camera_on {
239 if self.options.camera_on {
221 self.restart_preview();
240 self.restart_preview(cx);
222 } else {
241 } else {
223 self.preview.stop(cx);
242 self.preview.stop(cx);
224 }
243 }
@@ -239,7 +258,7 @@ impl PrejoinView {
239 self.camera = choice.clone();
258 self.camera = choice.clone();
240 self.app
259 self.app
241 .update(cx, |state, cx| state.select_call_camera(choice, cx));
260 .update(cx, |state, cx| state.select_call_camera(choice, cx));
242 self.restart_preview();
261 self.restart_preview(cx);
243 cx.notify();
262 cx.notify();
244 }
263 }
245
264
@@ -270,8 +289,12 @@ impl PrejoinView {
270
289
271 fn preview_status(&self) -> String {
290 fn preview_status(&self) -> String {
272 match self.preview.failure() {
291 match self.preview.failure() {
273 Some(reason) => format!("Camera could not start: {reason}"),
292 Some(reason) => {
274 None => "Starting camera...".to_owned(),
293 let mut args = std::collections::HashMap::new();
294 args.insert("detail".to_owned(), reason.clone());
295 tr_args("calls.prejoin.camera_failed", &args)
296 }
297 None => tr("calls.prejoin.starting_camera"),
275 }
298 }
276 }
299 }
277
300
@@ -295,14 +318,15 @@ impl PrejoinView {
295 .child(person_avatar(
318 .child(person_avatar(
296 &state.directory,
319 &state.directory,
297 me.as_ref().map(|me| me.user_id.as_str()),
320 me.as_ref().map(|me| me.user_id.as_str()),
298 me.as_ref().map_or("You", |me| me.display_name.as_str()),
321 me.as_ref()
322 .map_or(tr("common.you").as_str(), |me| me.display_name.as_str()),
299 AVATAR_SIZE,
323 AVATAR_SIZE,
300 ))
324 ))
301 .child(
325 .child(
302 div()
326 div()
303 .text_size(px(13.))
327 .text_size(px(13.))
304 .text_color(theme::text_muted())
328 .text_color(theme::text_muted())
305 .child(CAMERA_OFF_TEXT),
329 .child(tr("calls.prejoin.camera_off")),
306 )
330 )
307 .into_any_element(),
331 .into_any_element(),
308 };
332 };
@@ -362,10 +386,14 @@ impl PrejoinView {
362 .child(
386 .child(
363 Button::new("prejoin-background")
387 Button::new("prejoin-background")
364 .outline()
388 .outline()
365 .label("Background")
389 .label(tr("calls.prejoin.background"))
366 .icon(IconName::ChevronDown)
390 .icon(IconName::ChevronDown)
367 .dropdown_menu(move |menu: PopupMenu, _, _| {
391 .dropdown_menu(move |menu: PopupMenu, _, _| {
368 background_items(menu, &background_app, &backgrounds)
392 background_items(
393 quality_items(menu, &background_app, backgrounds.quality),
394 &background_app,
395 &backgrounds,
396 )
369 }),
397 }),
370 )
398 )
371 }
399 }
@@ -473,7 +501,7 @@ impl Render for PrejoinView {
473 .child(self.select(
501 .child(self.select(
474 DeviceSelect {
502 DeviceSelect {
475 id: "prejoin-camera-select",
503 id: "prejoin-camera-select",
476 label: "Camera",
504 label: tr("calls.prejoin.camera"),
477 entries: cameras,
505 entries: cameras,
478 current: camera,
506 current: camera,
479 enabled: true,
507 enabled: true,
@@ -484,7 +512,7 @@ impl Render for PrejoinView {
484 .child(self.select(
512 .child(self.select(
485 DeviceSelect {
513 DeviceSelect {
486 id: "prejoin-mic-select",
514 id: "prejoin-mic-select",
487 label: "Microphone",
515 label: tr("calls.prejoin.microphone"),
488 entries: inputs,
516 entries: inputs,
489 current: input,
517 current: input,
490 enabled: audio_on,
518 enabled: audio_on,
@@ -495,7 +523,7 @@ impl Render for PrejoinView {
495 .child(self.select(
523 .child(self.select(
496 DeviceSelect {
524 DeviceSelect {
497 id: "prejoin-speaker-select",
525 id: "prejoin-speaker-select",
498 label: "Speaker",
526 label: tr("calls.prejoin.speaker"),
499 entries: outputs,
527 entries: outputs,
500 current: output,
528 current: output,
501 enabled: audio_on,
529 enabled: audio_on,
@@ -520,13 +548,13 @@ impl Render for PrejoinView {
520 .child(
548 .child(
521 Button::new("prejoin-cancel")
549 Button::new("prejoin-cancel")
522 .ghost()
550 .ghost()
523 .label("Cancel")
551 .label(tr("common.cancel"))
524 .on_click(move |_, _, cx| cancel_view.update(cx, |view, cx| view.cancel(cx))),
552 .on_click(move |_, _, cx| cancel_view.update(cx, |view, cx| view.cancel(cx))),
525 )
553 )
526 .child(
554 .child(
527 Button::new("prejoin-join")
555 Button::new("prejoin-join")
528 .primary()
556 .primary()
529 .label("Join now")
557 .label(tr("calls.prejoin.join_now"))
530 .on_click(move |_, _, cx| join_view.update(cx, |view, cx| view.join(cx))),
558 .on_click(move |_, _, cx| join_view.update(cx, |view, cx| view.join(cx))),
531 );
559 );
532 v_flex()
560 v_flex()
@@ -563,7 +591,7 @@ impl Render for PrejoinView {
563 .truncate()
591 .truncate()
564 .text_size(px(13.))
592 .text_size(px(13.))
565 .text_color(theme::text_muted())
593 .text_color(theme::text_muted())
566 .child("Choose your video and audio settings, then join"),
594 .child(tr("calls.prejoin.choose_av")),
567 ),
595 ),
568 )
596 )
569 .child(self.preview_box(cx))
597 .child(self.preview_box(cx))
crates/calling/src/video_quality.rs added +69 −0
@@ -0,0 +1,69 @@
1 /// User-facing camera / stage video quality ceiling. No 4K mode.
2 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
3 pub enum VideoQuality {
4 #[default]
5 Auto,
6 P720,
7 P1080,
8 }
9
10 impl VideoQuality {
11 /// Preferred capture height for this choice (Auto prefers 1080).
12 pub fn capture_height(self) -> u32 {
13 match self {
14 Self::P720 => 720,
15 Self::Auto | Self::P1080 => 1080,
16 }
17 }
18
19 pub fn capture_width(self) -> u32 {
20 self.capture_height() * 16 / 9
21 }
22
23 /// Highest sensor height we may open before downscaling to the capture ceiling.
24 pub fn largest_sensor_height(self) -> u32 {
25 match self {
26 Self::P720 => 1080,
27 Self::Auto | Self::P1080 => 1440,
28 }
29 }
30
31 pub fn from_meta(value: &str) -> Self {
32 match value {
33 "720" => Self::P720,
34 "1080" => Self::P1080,
35 _ => Self::Auto,
36 }
37 }
38
39 pub fn to_meta(self) -> &'static str {
40 match self {
41 Self::Auto => "auto",
42 Self::P720 => "720",
43 Self::P1080 => "1080",
44 }
45 }
46 }
47
48 #[cfg(test)]
49 mod tests {
50 use super::*;
51
52 #[test]
53 fn auto_and_1080_share_a_1080_capture_ceiling() {
54 assert_eq!(VideoQuality::Auto.capture_height(), 1080);
55 assert_eq!(VideoQuality::P1080.capture_height(), 1080);
56 assert_eq!(VideoQuality::P720.capture_height(), 720);
57 assert_eq!(VideoQuality::Auto.capture_width(), 1920);
58 assert_eq!(VideoQuality::P720.capture_width(), 1280);
59 }
60
61 #[test]
62 fn meta_round_trips() {
63 for quality in [VideoQuality::Auto, VideoQuality::P720, VideoQuality::P1080] {
64 assert_eq!(VideoQuality::from_meta(quality.to_meta()), quality);
65 }
66 assert_eq!(VideoQuality::from_meta(""), VideoQuality::Auto);
67 assert_eq!(VideoQuality::from_meta("garbage"), VideoQuality::Auto);
68 }
69 }
@@ -0,0 +1,69 @@
1/// User-facing camera / stage video quality ceiling. No 4K mode.
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
3pub enum VideoQuality {
4 #[default]
5 Auto,
6 P720,
7 P1080,
8}
9
10impl VideoQuality {
11 /// Preferred capture height for this choice (Auto prefers 1080).
12 pub fn capture_height(self) -> u32 {
13 match self {
14 Self::P720 => 720,
15 Self::Auto | Self::P1080 => 1080,
16 }
17 }
18
19 pub fn capture_width(self) -> u32 {
20 self.capture_height() * 16 / 9
21 }
22
23 /// Highest sensor height we may open before downscaling to the capture ceiling.
24 pub fn largest_sensor_height(self) -> u32 {
25 match self {
26 Self::P720 => 1080,
27 Self::Auto | Self::P1080 => 1440,
28 }
29 }
30
31 pub fn from_meta(value: &str) -> Self {
32 match value {
33 "720" => Self::P720,
34 "1080" => Self::P1080,
35 _ => Self::Auto,
36 }
37 }
38
39 pub fn to_meta(self) -> &'static str {
40 match self {
41 Self::Auto => "auto",
42 Self::P720 => "720",
43 Self::P1080 => "1080",
44 }
45 }
46}
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn auto_and_1080_share_a_1080_capture_ceiling() {
54 assert_eq!(VideoQuality::Auto.capture_height(), 1080);
55 assert_eq!(VideoQuality::P1080.capture_height(), 1080);
56 assert_eq!(VideoQuality::P720.capture_height(), 720);
57 assert_eq!(VideoQuality::Auto.capture_width(), 1920);
58 assert_eq!(VideoQuality::P720.capture_width(), 1280);
59 }
60
61 #[test]
62 fn meta_round_trips() {
63 for quality in [VideoQuality::Auto, VideoQuality::P720, VideoQuality::P1080] {
64 assert_eq!(VideoQuality::from_meta(quality.to_meta()), quality);
65 }
66 assert_eq!(VideoQuality::from_meta(""), VideoQuality::Auto);
67 assert_eq!(VideoQuality::from_meta("garbage"), VideoQuality::Auto);
68 }
69}
crates/calling/src/video_receive.rs +22 −1
@@ -17,6 +17,7 @@ use crate::video_layout::{
17 17 Assignment, SlotTable, SourceRequest, TileDetail, VideoRouter, VideoWant, plan_receive,
18 18 prioritize, requests_for,
19 19 };
20 use crate::video_quality::VideoQuality;
20 21
21 22 const HISTORY_LIMIT: usize = 16;
22 23 const REQUEST_LABEL: &str = "POST applyChannelParameters";
@@ -134,6 +135,8 @@ pub struct VideoReceive {
134 135 wants: Option<Vec<VideoWant>>,
135 136 requester: Option<SourceRequester>,
136 137 incoming_enabled: bool,
138 quality: VideoQuality,
139 refresh_limits: bool,
137 140 }
138 141
139 142 impl VideoReceive {
@@ -148,6 +151,8 @@ impl VideoReceive {
148 151 wants: None,
149 152 requester: None,
150 153 incoming_enabled: true,
154 quality: VideoQuality::default(),
155 refresh_limits: false,
151 156 }
152 157 }
153 158
@@ -155,6 +160,15 @@ impl VideoReceive {
155 160 self.incoming_enabled = enabled;
156 161 }
157 162
163 pub fn set_video_quality(&mut self, quality: VideoQuality) -> bool {
164 if self.quality == quality {
165 return false;
166 }
167 self.quality = quality;
168 self.refresh_limits = true;
169 true
170 }
171
158 172 pub fn set_wants(&mut self, wants: Vec<VideoWant>) -> bool {
159 173 let changed = self.wants.as_ref() != Some(&wants);
160 174 self.wants = Some(wants);
@@ -204,7 +218,12 @@ impl VideoReceive {
204 218 Vec::new()
205 219 };
206 220 let next = plan_receive(&self.held, &candidates);
207 for request in requests_for(&self.held, &next, &self.table.people) {
221 let current = if self.refresh_limits {
222 vec![None; self.held.len()]
223 } else {
224 self.held.clone()
225 };
226 for request in requests_for(&current, &next, &self.table.people, self.quality) {
208 227 let slot = self
209 228 .table
210 229 .people
@@ -225,6 +244,7 @@ impl VideoReceive {
225 244 requester.send(request, route_after);
226 245 }
227 246 self.held = next;
247 self.refresh_limits = false;
228 248 if let Some(slot) = &self.table.screen {
229 249 let wanted = roster
230 250 .screen_share(&self.own_mri)
@@ -243,6 +263,7 @@ impl VideoReceive {
243 263 source: wanted.as_ref().map(|assignment| assignment.source),
244 264 screen: true,
245 265 detail: TileDetail::Stage,
266 quality: self.quality,
246 267 },
247 268 route_after,
248 269 );
@@ -17,6 +17,7 @@ use crate::video_layout::{
17 Assignment, SlotTable, SourceRequest, TileDetail, VideoRouter, VideoWant, plan_receive,
17 Assignment, SlotTable, SourceRequest, TileDetail, VideoRouter, VideoWant, plan_receive,
18 prioritize, requests_for,
18 prioritize, requests_for,
19};
19};
20use crate::video_quality::VideoQuality;
20
21
21const HISTORY_LIMIT: usize = 16;
22const HISTORY_LIMIT: usize = 16;
22const REQUEST_LABEL: &str = "POST applyChannelParameters";
23const REQUEST_LABEL: &str = "POST applyChannelParameters";
@@ -134,6 +135,8 @@ pub struct VideoReceive {
134 wants: Option<Vec<VideoWant>>,
135 wants: Option<Vec<VideoWant>>,
135 requester: Option<SourceRequester>,
136 requester: Option<SourceRequester>,
136 incoming_enabled: bool,
137 incoming_enabled: bool,
138 quality: VideoQuality,
139 refresh_limits: bool,
137}
140}
138
141
139impl VideoReceive {
142impl VideoReceive {
@@ -148,6 +151,8 @@ impl VideoReceive {
148 wants: None,
151 wants: None,
149 requester: None,
152 requester: None,
150 incoming_enabled: true,
153 incoming_enabled: true,
154 quality: VideoQuality::default(),
155 refresh_limits: false,
151 }
156 }
152 }
157 }
153
158
@@ -155,6 +160,15 @@ impl VideoReceive {
155 self.incoming_enabled = enabled;
160 self.incoming_enabled = enabled;
156 }
161 }
157
162
163 pub fn set_video_quality(&mut self, quality: VideoQuality) -> bool {
164 if self.quality == quality {
165 return false;
166 }
167 self.quality = quality;
168 self.refresh_limits = true;
169 true
170 }
171
158 pub fn set_wants(&mut self, wants: Vec<VideoWant>) -> bool {
172 pub fn set_wants(&mut self, wants: Vec<VideoWant>) -> bool {
159 let changed = self.wants.as_ref() != Some(&wants);
173 let changed = self.wants.as_ref() != Some(&wants);
160 self.wants = Some(wants);
174 self.wants = Some(wants);
@@ -204,7 +218,12 @@ impl VideoReceive {
204 Vec::new()
218 Vec::new()
205 };
219 };
206 let next = plan_receive(&self.held, &candidates);
220 let next = plan_receive(&self.held, &candidates);
207 for request in requests_for(&self.held, &next, &self.table.people) {
221 let current = if self.refresh_limits {
222 vec![None; self.held.len()]
223 } else {
224 self.held.clone()
225 };
226 for request in requests_for(&current, &next, &self.table.people, self.quality) {
208 let slot = self
227 let slot = self
209 .table
228 .table
210 .people
229 .people
@@ -225,6 +244,7 @@ impl VideoReceive {
225 requester.send(request, route_after);
244 requester.send(request, route_after);
226 }
245 }
227 self.held = next;
246 self.held = next;
247 self.refresh_limits = false;
228 if let Some(slot) = &self.table.screen {
248 if let Some(slot) = &self.table.screen {
229 let wanted = roster
249 let wanted = roster
230 .screen_share(&self.own_mri)
250 .screen_share(&self.own_mri)
@@ -243,6 +263,7 @@ impl VideoReceive {
243 source: wanted.as_ref().map(|assignment| assignment.source),
263 source: wanted.as_ref().map(|assignment| assignment.source),
244 screen: true,
264 screen: true,
245 detail: TileDetail::Stage,
265 detail: TileDetail::Stage,
266 quality: self.quality,
246 },
267 },
247 route_after,
268 route_after,
248 );
269 );