BlueGit

ict rusty-teams

fix(calls): shared screen stays visible, share strip shows everyone

- Shared screen keeps its last frame while the share runs. Static content sends a frame only on change (every 2-12 s live), so the 2.5 s stale timeout flipped the stage back to "Loading the shared screen...". Forgotten when the sharer changes or stops.
- Share frames are no longer downscaled to 1600 px (cap 2560), so 1080p shares render at full resolution.
- The screen route is set before the source request, so the first keyframe after subscribing is not dropped.
- Share strip fits as many 16:9 tiles as the height allows (min 90 px), then a "+N" tile; no scrolling, own tile always visible. Video wants list only the shown tiles.
- Meeting bots (caption / recording bot, 28:) get no tile; it showed as a nameless "?" tile. The called Echo bot keeps its tile.
- Roster entries without a display name get it from known chat members / the store.
- Stats timeline line reports share decoded frames, keyframes, size, fps, PLI, FIR, freezes. Share packet counter counts only the plan's share mids (mid 2 is a camera slot in meetings).
- Demo sharing scene: 9 guests plus a caption bot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-14 · 6 weeks ago

Hash
88a64f5426c51877a728b6906644e2b40f8cc34b
Parent
af5aab51
13 files changed +189 −50
crates/app/src/call/actions.rs +27 −0
@@ -386,12 +386,35 @@ impl AppState {
386 386 }
387 387 }
388 388
389 fn with_known_names(&self, update: CallUpdate) -> CallUpdate {
390 let mut entries = match update {
391 CallUpdate::Roster(entries) => entries,
392 other => return other,
393 };
394 let user_id = |entry: &calling::RosterEntry| entry.mri.strip_prefix(ORGID_PREFIX).map(str::to_owned);
395 let missing: Vec<String> = entries
396 .iter()
397 .filter(|entry| entry.display_name.is_empty())
398 .filter_map(user_id)
399 .collect();
400 if !missing.is_empty() {
401 let names = crate::people::resolve_names(self, &missing);
402 for entry in entries.iter_mut().filter(|entry| entry.display_name.is_empty()) {
403 if let Some(name) = user_id(entry).and_then(|id| names.get(&id)) {
404 entry.display_name = name.clone();
405 }
406 }
407 }
408 CallUpdate::Roster(entries)
409 }
410
389 411 pub(super) fn apply_call_update(
390 412 &mut self,
391 413 call_id: u64,
392 414 update: CallUpdate,
393 415 cx: &mut Context<Self>,
394 416 ) {
417 let update = self.with_known_names(update);
395 418 let media = self.call_media.clone();
396 419 let Some(call) = self.call.as_mut().filter(|call| call.id == call_id) else {
397 420 return;
@@ -447,7 +470,11 @@ impl AppState {
447 470 };
448 471 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
449 472 }
473 let sharer_before = call.model.screen_sharer.clone();
450 474 call.model.apply(update);
475 if call.model.screen_sharer != sharer_before {
476 call.pictures.forget(&VideoKey::Screen, cx);
477 }
451 478 if let Some(language) = call.model.take_ready_caption_language() {
452 479 let _ = call.commands.send(CallCommand::SetCaptionLanguage(language));
453 480 }
@@ -386,12 +386,35 @@ impl AppState {
386 }
386 }
387 }
387 }
388
388
389 fn with_known_names(&self, update: CallUpdate) -> CallUpdate {
390 let mut entries = match update {
391 CallUpdate::Roster(entries) => entries,
392 other => return other,
393 };
394 let user_id = |entry: &calling::RosterEntry| entry.mri.strip_prefix(ORGID_PREFIX).map(str::to_owned);
395 let missing: Vec<String> = entries
396 .iter()
397 .filter(|entry| entry.display_name.is_empty())
398 .filter_map(user_id)
399 .collect();
400 if !missing.is_empty() {
401 let names = crate::people::resolve_names(self, &missing);
402 for entry in entries.iter_mut().filter(|entry| entry.display_name.is_empty()) {
403 if let Some(name) = user_id(entry).and_then(|id| names.get(&id)) {
404 entry.display_name = name.clone();
405 }
406 }
407 }
408 CallUpdate::Roster(entries)
409 }
410
389 pub(super) fn apply_call_update(
411 pub(super) fn apply_call_update(
390 &mut self,
412 &mut self,
391 call_id: u64,
413 call_id: u64,
392 update: CallUpdate,
414 update: CallUpdate,
393 cx: &mut Context<Self>,
415 cx: &mut Context<Self>,
394 ) {
416 ) {
417 let update = self.with_known_names(update);
395 let media = self.call_media.clone();
418 let media = self.call_media.clone();
396 let Some(call) = self.call.as_mut().filter(|call| call.id == call_id) else {
419 let Some(call) = self.call.as_mut().filter(|call| call.id == call_id) else {
397 return;
420 return;
@@ -447,7 +470,11 @@ impl AppState {
447 };
470 };
448 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
471 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
449 }
472 }
473 let sharer_before = call.model.screen_sharer.clone();
450 call.model.apply(update);
474 call.model.apply(update);
475 if call.model.screen_sharer != sharer_before {
476 call.pictures.forget(&VideoKey::Screen, cx);
477 }
451 if let Some(language) = call.model.take_ready_caption_language() {
478 if let Some(language) = call.model.take_ready_caption_language() {
452 let _ = call.commands.send(CallCommand::SetCaptionLanguage(language));
479 let _ = call.commands.send(CallCommand::SetCaptionLanguage(language));
453 }
480 }
crates/app/src/call/demo.rs +4 −1
@@ -146,7 +146,7 @@ impl DemoScene {
146 146 }
147 147
148 148 pub const DEMO_GALLERY_GUESTS: usize = 12;
149 const DEMO_SHARING_GUESTS: usize = 6;
149 const DEMO_SHARING_GUESTS: usize = 9;
150 150 const BREAKOUT_AT_TICKS: u32 = 20;
151 151 const WHITEBOARD_AT_TICKS: u32 = 5;
152 152 const DEMO_BOARD_URL: &str = "https://app.whiteboard.microsoft.com/me/whiteboards/demo";
@@ -309,6 +309,9 @@ async fn run_demo_call(mut control: CallControl, script: DemoCall, scene: DemoSc
309 309 control.send(CallUpdate::Lobby(false));
310 310 }
311 311 let mut roster = roster_of(&people, scene.cameras());
312 if scene == DemoScene::Sharing {
313 roster.push(RosterEntry { mri: calling::captions::RECORDING_BOT_MRI.to_owned(), ..RosterEntry::default() });
314 }
312 315 if matches!(script, DemoCall::People(_)) {
313 316 control.send(CallUpdate::ReplacementLink(
314 317 DEMO_REPLACEMENT_LINK.to_owned(),
@@ -146,7 +146,7 @@ impl DemoScene {
146}
146}
147
147
148pub const DEMO_GALLERY_GUESTS: usize = 12;
148pub const DEMO_GALLERY_GUESTS: usize = 12;
149const DEMO_SHARING_GUESTS: usize = 6;
149const DEMO_SHARING_GUESTS: usize = 9;
150const BREAKOUT_AT_TICKS: u32 = 20;
150const BREAKOUT_AT_TICKS: u32 = 20;
151const WHITEBOARD_AT_TICKS: u32 = 5;
151const WHITEBOARD_AT_TICKS: u32 = 5;
152const DEMO_BOARD_URL: &str = "https://app.whiteboard.microsoft.com/me/whiteboards/demo";
152const DEMO_BOARD_URL: &str = "https://app.whiteboard.microsoft.com/me/whiteboards/demo";
@@ -309,6 +309,9 @@ async fn run_demo_call(mut control: CallControl, script: DemoCall, scene: DemoSc
309 control.send(CallUpdate::Lobby(false));
309 control.send(CallUpdate::Lobby(false));
310 }
310 }
311 let mut roster = roster_of(&people, scene.cameras());
311 let mut roster = roster_of(&people, scene.cameras());
312 if scene == DemoScene::Sharing {
313 roster.push(RosterEntry { mri: calling::captions::RECORDING_BOT_MRI.to_owned(), ..RosterEntry::default() });
314 }
312 if matches!(script, DemoCall::People(_)) {
315 if matches!(script, DemoCall::People(_)) {
313 control.send(CallUpdate::ReplacementLink(
316 control.send(CallUpdate::ReplacementLink(
314 DEMO_REPLACEMENT_LINK.to_owned(),
317 DEMO_REPLACEMENT_LINK.to_owned(),
crates/app/src/call/mod.rs +1 −1
@@ -70,7 +70,7 @@ pub use share_view::{SHARE_MOTION_META_KEY, SHARE_STANDOUT_META_KEY, STRIP_DEFAU
70 70 pub use preview::{CameraPreview, preview_backgrounds};
71 71 pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};
72 72 pub use ring::{MissedCall, RingEntry, Rings};
73 pub use stage_layout::{FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, contain_size, filmstrip, focus_stage_size, gallery_grid, split_overflow};
73 pub use stage_layout::{FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, contain_size, filmstrip, focus_stage_size, gallery_grid, share_strip, split_overflow};
74 74 pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
75 75 pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
76 76 pub use report::load_enabled as load_report_enabled;
@@ -70,7 +70,7 @@ pub use share_view::{SHARE_MOTION_META_KEY, SHARE_STANDOUT_META_KEY, STRIP_DEFAU
70pub use preview::{CameraPreview, preview_backgrounds};
70pub use preview::{CameraPreview, preview_backgrounds};
71pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};
71pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};
72pub use ring::{MissedCall, RingEntry, Rings};
72pub use ring::{MissedCall, RingEntry, Rings};
73pub use stage_layout::{FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, contain_size, filmstrip, focus_stage_size, gallery_grid, split_overflow};
73pub use stage_layout::{FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, contain_size, filmstrip, focus_stage_size, gallery_grid, share_strip, split_overflow};
74pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
74pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
75pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
75pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
76pub use report::load_enabled as load_report_enabled;
76pub use report::load_enabled as load_report_enabled;
crates/app/src/call/model.rs +19 −0
@@ -28,6 +28,7 @@ pub const TEST_CALL_TITLE: &str = "Test call";
28 28 pub const ECHO_NAME: &str = "Teams echo";
29 29 pub const ECHO_MRI: &str = calling::signaling::ECHO_BOT_MRI;
30 30 const ORGID_PREFIX: &str = "8:orgid:";
31 const BOT_PREFIX: &str = "28:";
31 32 const AVATAR_SHARE: f32 = 0.42;
32 33 const MIN_AVATAR: f32 = 32.;
33 34 const MAX_AVATAR: f32 = 96.;
@@ -778,6 +779,7 @@ impl CallModel {
778 779 tile.name = entry.display_name.clone();
779 780 }
780 781 }
782 None if entry.mri.starts_with(BOT_PREFIX) => {}
781 783 None => self.tiles.push(Tile {
782 784 mri: entry.mri.clone(),
783 785 user_id: entry.mri.strip_prefix(ORGID_PREFIX).map(str::to_owned),
@@ -1434,6 +1436,23 @@ mod tests {
1434 1436 assert_eq!(model.tiles[0].name, "Bo");
1435 1437 }
1436 1438
1439 #[test]
1440 fn meeting_bots_get_no_tile_but_the_called_echo_bot_keeps_its_own() {
1441 let mut model = meeting_with_me();
1442 model.apply(CallUpdate::Roster(vec![
1443 entry("8:orgid:me", "Me", false, false),
1444 entry("8:orgid:a", "Ana", false, false),
1445 entry("28:bdd75849-e0a6-4cce-8fc1-d7c0d4da43e5", "", false, false),
1446 ]));
1447 let names: Vec<&str> = model.strip_tiles().iter().map(|tile| tile.name.as_str()).collect();
1448 assert_eq!(names, vec!["Ana"]);
1449 assert_eq!(model.present_others(), 1);
1450 let mut echo = CallModel::people(ECHO_NAME, &[(ECHO_MRI.into(), ECHO_NAME.into())]);
1451 echo.apply(CallUpdate::Roster(vec![entry(ECHO_MRI, "", false, false)]));
1452 assert_eq!(echo.tiles.len(), 1);
1453 assert_eq!(echo.tiles[0].state, TileState::Present);
1454 }
1455
1437 1456 #[test]
1438 1457 fn an_invited_callee_who_leaves_stays_as_left() {
1439 1458 let mut model = CallModel::people("Bea", &[("8:orgid:b".into(), "Bea".into())]);
@@ -28,6 +28,7 @@ pub const TEST_CALL_TITLE: &str = "Test call";
28pub const ECHO_NAME: &str = "Teams echo";
28pub const ECHO_NAME: &str = "Teams echo";
29pub const ECHO_MRI: &str = calling::signaling::ECHO_BOT_MRI;
29pub const ECHO_MRI: &str = calling::signaling::ECHO_BOT_MRI;
30const ORGID_PREFIX: &str = "8:orgid:";
30const ORGID_PREFIX: &str = "8:orgid:";
31const BOT_PREFIX: &str = "28:";
31const AVATAR_SHARE: f32 = 0.42;
32const AVATAR_SHARE: f32 = 0.42;
32const MIN_AVATAR: f32 = 32.;
33const MIN_AVATAR: f32 = 32.;
33const MAX_AVATAR: f32 = 96.;
34const MAX_AVATAR: f32 = 96.;
@@ -778,6 +779,7 @@ impl CallModel {
778 tile.name = entry.display_name.clone();
779 tile.name = entry.display_name.clone();
779 }
780 }
780 }
781 }
782 None if entry.mri.starts_with(BOT_PREFIX) => {}
781 None => self.tiles.push(Tile {
783 None => self.tiles.push(Tile {
782 mri: entry.mri.clone(),
784 mri: entry.mri.clone(),
783 user_id: entry.mri.strip_prefix(ORGID_PREFIX).map(str::to_owned),
785 user_id: entry.mri.strip_prefix(ORGID_PREFIX).map(str::to_owned),
@@ -1434,6 +1436,23 @@ mod tests {
1434 assert_eq!(model.tiles[0].name, "Bo");
1436 assert_eq!(model.tiles[0].name, "Bo");
1435 }
1437 }
1436
1438
1439 #[test]
1440 fn meeting_bots_get_no_tile_but_the_called_echo_bot_keeps_its_own() {
1441 let mut model = meeting_with_me();
1442 model.apply(CallUpdate::Roster(vec![
1443 entry("8:orgid:me", "Me", false, false),
1444 entry("8:orgid:a", "Ana", false, false),
1445 entry("28:bdd75849-e0a6-4cce-8fc1-d7c0d4da43e5", "", false, false),
1446 ]));
1447 let names: Vec<&str> = model.strip_tiles().iter().map(|tile| tile.name.as_str()).collect();
1448 assert_eq!(names, vec!["Ana"]);
1449 assert_eq!(model.present_others(), 1);
1450 let mut echo = CallModel::people(ECHO_NAME, &[(ECHO_MRI.into(), ECHO_NAME.into())]);
1451 echo.apply(CallUpdate::Roster(vec![entry(ECHO_MRI, "", false, false)]));
1452 assert_eq!(echo.tiles.len(), 1);
1453 assert_eq!(echo.tiles[0].state, TileState::Present);
1454 }
1455
1437 #[test]
1456 #[test]
1438 fn an_invited_callee_who_leaves_stays_as_left() {
1457 fn an_invited_callee_who_leaves_stays_as_left() {
1439 let mut model = CallModel::people("Bea", &[("8:orgid:b".into(), "Bea".into())]);
1458 let mut model = CallModel::people("Bea", &[("8:orgid:b".into(), "Bea".into())]);
crates/app/src/call/pictures.rs +1 −1
@@ -46,7 +46,7 @@ impl CallPictures {
46 46 pub fn live(&self, key: &VideoKey, now: Instant) -> Option<Arc<RenderImage>> {
47 47 self.shown
48 48 .get(key)
49 .filter(|shown| now.saturating_duration_since(shown.updated) < STALE_AFTER)
49 .filter(|shown| *key == VideoKey::Screen || now.saturating_duration_since(shown.updated) < STALE_AFTER)
50 50 .map(|shown| shown.image.clone())
51 51 }
52 52
@@ -46,7 +46,7 @@ impl CallPictures {
46 pub fn live(&self, key: &VideoKey, now: Instant) -> Option<Arc<RenderImage>> {
46 pub fn live(&self, key: &VideoKey, now: Instant) -> Option<Arc<RenderImage>> {
47 self.shown
47 self.shown
48 .get(key)
48 .get(key)
49 .filter(|shown| now.saturating_duration_since(shown.updated) < STALE_AFTER)
49 .filter(|shown| *key == VideoKey::Screen || now.saturating_duration_since(shown.updated) < STALE_AFTER)
50 .map(|shown| shown.image.clone())
50 .map(|shown| shown.image.clone())
51 }
51 }
52
52
crates/app/src/call/stage_layout.rs +38 −0
@@ -10,6 +10,8 @@ pub const SPEAKER_HOLD: Duration = Duration::from_millis(1500);
10 10 pub const SPEAKER_SWITCH_AFTER: Duration = Duration::from_millis(800);
11 11 pub const RECENT_SPEAKER: Duration = Duration::from_secs(3);
12 12 const TILE_ASPECT: f32 = 16. / 9.;
13 pub const STRIP_MIN_TILE_HEIGHT: f32 = 90.;
14 const FIT_TOLERANCE: f32 = 0.001;
13 15
14 16 #[derive(Debug, Clone, Copy, PartialEq)]
15 17 pub struct GalleryGrid {
@@ -104,6 +106,19 @@ pub fn filmstrip(
104 106 }
105 107 }
106 108
109 pub fn share_strip(others: usize, own_cells: usize, strip: (f32, f32), gap: f32) -> Filmstrip {
110 let full_height = strip.0 / TILE_ASPECT;
111 let cells = (others + own_cells).max(1);
112 let height_for_all = (strip.1 - gap * (cells - 1) as f32) / cells as f32;
113 let tile_height = height_for_all.clamp(STRIP_MIN_TILE_HEIGHT.min(full_height), full_height).max(0.);
114 let capacity = (((strip.1 + gap) / (tile_height + gap) + FIT_TOLERANCE) as usize).max(1);
115 Filmstrip {
116 tile_width: tile_height * TILE_ASPECT,
117 tile_height,
118 overflow: split_overflow(others, own_cells, capacity),
119 }
120 }
121
107 122 #[derive(Debug, Clone, Default)]
108 123 pub struct VisibleRotation {
109 124 order: Vec<String>,
@@ -338,6 +353,29 @@ mod tests {
338 353 );
339 354 }
340 355
356 #[test]
357 fn a_tall_share_strip_shows_everyone_at_full_width() {
358 let plan = share_strip(3, 1, (232., 800.), 12.);
359 assert_eq!(plan.overflow, Overflow { shown: 3, hidden: 0 });
360 assert!((plan.tile_width - 232.).abs() < 0.01);
361 }
362
363 #[test]
364 fn a_share_strip_shrinks_tiles_so_nine_people_and_me_fit() {
365 let plan = share_strip(9, 1, (232., 1100.), 12.);
366 assert_eq!(plan.overflow, Overflow { shown: 9, hidden: 0 });
367 assert!(plan.tile_height >= STRIP_MIN_TILE_HEIGHT);
368 assert!(10. * plan.tile_height + 9. * 12. <= 1100.01);
369 }
370
371 #[test]
372 fn a_short_share_strip_stops_at_the_minimum_height_and_adds_a_plus_tile() {
373 let plan = share_strip(9, 1, (232., 600.), 12.);
374 assert!((plan.tile_height - STRIP_MIN_TILE_HEIGHT).abs() < 0.01);
375 let capacity = ((600. + 12.) / (STRIP_MIN_TILE_HEIGHT + 12.)) as usize;
376 assert_eq!(plan.overflow, Overflow { shown: capacity - 2, hidden: 9 - (capacity - 2) });
377 }
378
341 379 #[test]
342 380 fn the_filmstrip_holds_six_tiles_then_a_plus_tile() {
343 381 let strip = filmstrip(5, 1, 1600., 12., 240.);
@@ -10,6 +10,8 @@ pub const SPEAKER_HOLD: Duration = Duration::from_millis(1500);
10pub const SPEAKER_SWITCH_AFTER: Duration = Duration::from_millis(800);
10pub const SPEAKER_SWITCH_AFTER: Duration = Duration::from_millis(800);
11pub const RECENT_SPEAKER: Duration = Duration::from_secs(3);
11pub const RECENT_SPEAKER: Duration = Duration::from_secs(3);
12const TILE_ASPECT: f32 = 16. / 9.;
12const TILE_ASPECT: f32 = 16. / 9.;
13pub const STRIP_MIN_TILE_HEIGHT: f32 = 90.;
14const FIT_TOLERANCE: f32 = 0.001;
13
15
14#[derive(Debug, Clone, Copy, PartialEq)]
16#[derive(Debug, Clone, Copy, PartialEq)]
15pub struct GalleryGrid {
17pub struct GalleryGrid {
@@ -104,6 +106,19 @@ pub fn filmstrip(
104 }
106 }
105}
107}
106
108
109pub fn share_strip(others: usize, own_cells: usize, strip: (f32, f32), gap: f32) -> Filmstrip {
110 let full_height = strip.0 / TILE_ASPECT;
111 let cells = (others + own_cells).max(1);
112 let height_for_all = (strip.1 - gap * (cells - 1) as f32) / cells as f32;
113 let tile_height = height_for_all.clamp(STRIP_MIN_TILE_HEIGHT.min(full_height), full_height).max(0.);
114 let capacity = (((strip.1 + gap) / (tile_height + gap) + FIT_TOLERANCE) as usize).max(1);
115 Filmstrip {
116 tile_width: tile_height * TILE_ASPECT,
117 tile_height,
118 overflow: split_overflow(others, own_cells, capacity),
119 }
120}
121
107#[derive(Debug, Clone, Default)]
122#[derive(Debug, Clone, Default)]
108pub struct VisibleRotation {
123pub struct VisibleRotation {
109 order: Vec<String>,
124 order: Vec<String>,
@@ -338,6 +353,29 @@ mod tests {
338 );
353 );
339 }
354 }
340
355
356 #[test]
357 fn a_tall_share_strip_shows_everyone_at_full_width() {
358 let plan = share_strip(3, 1, (232., 800.), 12.);
359 assert_eq!(plan.overflow, Overflow { shown: 3, hidden: 0 });
360 assert!((plan.tile_width - 232.).abs() < 0.01);
361 }
362
363 #[test]
364 fn a_share_strip_shrinks_tiles_so_nine_people_and_me_fit() {
365 let plan = share_strip(9, 1, (232., 1100.), 12.);
366 assert_eq!(plan.overflow, Overflow { shown: 9, hidden: 0 });
367 assert!(plan.tile_height >= STRIP_MIN_TILE_HEIGHT);
368 assert!(10. * plan.tile_height + 9. * 12. <= 1100.01);
369 }
370
371 #[test]
372 fn a_short_share_strip_stops_at_the_minimum_height_and_adds_a_plus_tile() {
373 let plan = share_strip(9, 1, (232., 600.), 12.);
374 assert!((plan.tile_height - STRIP_MIN_TILE_HEIGHT).abs() < 0.01);
375 let capacity = ((600. + 12.) / (STRIP_MIN_TILE_HEIGHT + 12.)) as usize;
376 assert_eq!(plan.overflow, Overflow { shown: capacity - 2, hidden: 9 - (capacity - 2) });
377 }
378
341 #[test]
379 #[test]
342 fn the_filmstrip_holds_six_tiles_then_a_plus_tile() {
380 fn the_filmstrip_holds_six_tiles_then_a_plus_tile() {
343 let strip = filmstrip(5, 1, 1600., 12., 240.);
381 let strip = filmstrip(5, 1, 1600., 12., 240.);
crates/app/src/call/view_actions.rs +2 −1
@@ -78,10 +78,11 @@ impl AppState {
78 78 }
79 79
80 80 fn sync_video_wants(&mut self) {
81 let strip_width = self.call_strip_width;
81 82 let Some(call) = self.call.as_mut() else {
82 83 return;
83 84 };
84 let wants = video_wants(&call.model, measured_stage(call));
85 let wants = video_wants(&call.model, measured_stage(call), strip_width);
85 86 if wants != call.sent_wants {
86 87 let _ = call.commands.send(CallCommand::SetVideoWants(wants.clone()));
87 88 call.sent_wants = wants;
@@ -78,10 +78,11 @@ impl AppState {
78 }
78 }
79
79
80 fn sync_video_wants(&mut self) {
80 fn sync_video_wants(&mut self) {
81 let strip_width = self.call_strip_width;
81 let Some(call) = self.call.as_mut() else {
82 let Some(call) = self.call.as_mut() else {
82 return;
83 return;
83 };
84 };
84 let wants = video_wants(&call.model, measured_stage(call));
85 let wants = video_wants(&call.model, measured_stage(call), strip_width);
85 if wants != call.sent_wants {
86 if wants != call.sent_wants {
86 let _ = call.commands.send(CallCommand::SetVideoWants(wants.clone()));
87 let _ = call.commands.send(CallCommand::SetVideoWants(wants.clone()));
87 call.sent_wants = wants;
88 call.sent_wants = wants;
crates/app/src/views/call_layouts.rs +55 −33
@@ -14,13 +14,13 @@ use gpui_kit::*;
14 14 use super::avatar::person_avatar;
15 15 use super::call_organizer::render_focus_stage;
16 16 use super::call_view::{
17 GRID_PADDING, STRIP_GAP, STRIP_VISIBLE, TILE_GAP, own_tile, person_tile,
17 GRID_PADDING, STRIP_GAP, TILE_GAP, own_tile, person_tile,
18 18 };
19 19 use super::widgets::icon;
20 20 use crate::app_state::AppState;
21 21 use crate::call::{
22 22 ActiveCall, CallLayout, CallModel, FILMSTRIP_MAX, Filmstrip, Focus, GALLERY_MAX, Overflow, Tile, TileSize,
23 filmstrip, focus_stage_size, gallery_grid, shown_bubbles, split_overflow,
23 filmstrip, focus_stage_size, gallery_grid, share_strip, shown_bubbles, split_overflow,
24 24 };
25 25 use calling::{TileDetail, VideoWant};
26 26 use crate::theme;
@@ -497,33 +497,52 @@ fn speaker_body(
497 497 .into_any_element()
498 498 }
499 499
500 struct StripSplit<'a> {
501 width: f32,
502 others: Vec<&'a Tile>,
503 plan: Filmstrip,
504 }
505
506 fn strip_split(model: &CallModel, strip_width: f32, stage: (f32, f32)) -> StripSplit<'_> {
507 let available = (stage.0 - 2. * GRID_PADDING, (stage.1 - 2. * GRID_PADDING).max(0.));
508 let width = strip_width.min(((available.0 - TILE_GAP) / 2.).max(0.));
509 let others: Vec<&Tile> = model
510 .strip_tiles()
511 .into_iter()
512 .filter(|tile| !model.hidden_for_no_video(tile))
513 .collect();
514 let plan = share_strip(others.len(), model.own_cells(), (width, available.1), STRIP_GAP);
515 StripSplit { width, others, plan }
516 }
517
500 518 fn people_strip(
501 519 app: &Entity<AppState>,
502 520 state: &AppState,
503 521 model: &CallModel,
504 522 now: Instant,
505 available: (f32, f32),
523 stage: (f32, f32),
506 524 ) -> Stateful<Div> {
507 let strip_width = state.call_strip_width.min(((available.0 - TILE_GAP) / 2.).max(0.));
508 let tile = TileSize::sixteen_by_nine(strip_width);
509 let mut cells: Vec<AnyElement> = model
510 .strip_tiles()
511 .into_iter()
512 .filter(|tile_model| !model.hidden_for_no_video(tile_model))
513 .map(|remote| person_tile(app, state, model, remote, tile, now))
525 let StripSplit { width, others, plan } = strip_split(model, state.call_strip_width, stage);
526 let size = TileSize::sixteen_by_nine(plan.tile_width);
527 let shown = &others[..plan.overflow.shown];
528 let mut cells: Vec<AnyElement> = shown
529 .iter()
530 .map(|remote| person_tile(app, state, model, remote, size, now))
514 531 .collect();
515 532 if model.own_cells() > 0 {
516 533 let own_index = model.own_cell_index(cells.len());
517 cells.insert(own_index, own_tile(app, state, model, tile, now));
534 cells.insert(own_index, own_tile(app, state, model, size, now));
535 }
536 if plan.overflow.hidden > 0 {
537 cells.push(overflow_tile(app, state, size, &others[plan.overflow.shown..]));
518 538 }
519 539 v_flex()
520 540 .id("call-strip")
521 541 .debug_selector(|| "shell/islands/main/call-stage/share-strip".into())
522 542 .flex_none()
523 .w(px(tile.width))
524 .max_h(px((STRIP_VISIBLE * (tile.height + STRIP_GAP) - STRIP_GAP).min(available.1)))
543 .w(px(width))
544 .items_center()
525 545 .gap(px(STRIP_GAP))
526 .overflow_y_scroll()
527 546 .children(cells)
528 547 }
529 548
@@ -582,13 +601,7 @@ fn share_body(
582 601 })
583 602 .child(share)
584 603 .when(layout != CallLayout::Content, |row| {
585 row.child(strip_divider(app, dragging)).child(people_strip(
586 app,
587 state,
588 model,
589 now,
590 (stage.0 - 2. * GRID_PADDING, stage.1 - 2. * GRID_PADDING),
591 ))
604 row.child(strip_divider(app, dragging)).child(people_strip(app, state, model, now, stage))
592 605 })
593 606 .into_any_element()
594 607 }
@@ -599,15 +612,14 @@ fn want(tile: &Tile, detail: TileDetail) -> VideoWant {
599 612 VideoWant { mri: tile.mri.clone(), detail }
600 613 }
601 614
602 pub fn video_wants(model: &CallModel, stage: (f32, f32)) -> Vec<VideoWant> {
615 pub fn video_wants(model: &CallModel, stage: (f32, f32), strip_width: f32) -> Vec<VideoWant> {
603 616 if model.has_content() {
604 617 if model.effective_layout() == CallLayout::Content {
605 618 return Vec::new();
606 619 }
607 return model
608 .strip_tiles()
609 .into_iter()
610 .filter(|tile| !model.hidden_for_no_video(tile))
620 let split = strip_split(model, strip_width, stage);
621 return split.others[..split.plan.overflow.shown]
622 .iter()
611 623 .map(|tile| want(tile, TileDetail::Small))
612 624 .collect();
613 625 }
@@ -675,6 +687,7 @@ mod tests {
675 687 CallLayout, CallModel, FILMSTRIP_TILE_MAX, GALLERY_MAX, GRID_PADDING, TILE_GAP, filmstrip, split_overflow,
676 688 video_wants,
677 689 };
690 use crate::call::STRIP_DEFAULT_WIDTH;
678 691
679 692 const STAGE: (f32, f32) = (1400., 800.);
680 693
@@ -711,7 +724,7 @@ mod tests {
711 724
712 725 #[test]
713 726 fn a_small_gallery_asks_for_large_pictures() {
714 let wants = video_wants(&crowd(3), STAGE);
727 let wants = video_wants(&crowd(3), STAGE, STRIP_DEFAULT_WIDTH);
715 728 assert_eq!(wants.len(), 3);
716 729 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Stage));
717 730 }
@@ -719,7 +732,7 @@ mod tests {
719 732 #[test]
720 733 fn a_big_gallery_asks_for_small_pictures_and_skips_the_plus_n_people() {
721 734 let model = crowd(14);
722 let wants = video_wants(&model, STAGE);
735 let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
723 736 assert_eq!(wants.len(), split_overflow(14, 1, GALLERY_MAX).shown);
724 737 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));
725 738 let hidden: Vec<&str> = model.layout_tiles()[wants.len()..].iter().map(|tile| tile.mri.as_str()).collect();
@@ -730,7 +743,7 @@ mod tests {
730 743 fn people_hidden_for_having_no_video_get_no_picture_request() {
731 744 let mut model = meeting(vec![person(0, true), person(1, false), person(2, false)]);
732 745 model.view.hide_no_video = true;
733 let wants = video_wants(&model, STAGE);
746 let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
734 747 assert_eq!(wants.iter().map(|want| want.mri.as_str()).collect::<Vec<_>>(), vec!["8:orgid:p0"]);
735 748 }
736 749
@@ -740,7 +753,7 @@ mod tests {
740 753 model.view.choose(CallLayout::Speaker);
741 754 model.refresh_layout(Instant::now());
742 755 let focus = model.speaker_focus().expect("a stage person").mri;
743 let wants = video_wants(&model, STAGE);
756 let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
744 757 assert_eq!(wants[0], VideoWant { mri: focus.clone(), detail: TileDetail::Stage });
745 758 assert_eq!(wants.len(), 5);
746 759 assert!(wants[1..].iter().all(|want| want.detail == TileDetail::Small && want.mri != focus));
@@ -751,7 +764,7 @@ mod tests {
751 764 let mut model = crowd(12);
752 765 model.view.choose(CallLayout::Speaker);
753 766 model.refresh_layout(Instant::now());
754 let wants = video_wants(&model, (500., 800.));
767 let wants = video_wants(&model, (500., 800.), STRIP_DEFAULT_WIDTH);
755 768 let fitting = filmstrip(11, 1, 500. - 2. * GRID_PADDING, TILE_GAP, FILMSTRIP_TILE_MAX).overflow.shown;
756 769 assert!(fitting < 11);
757 770 assert_eq!(wants.len(), 1 + fitting);
@@ -761,10 +774,19 @@ mod tests {
761 774 fn next_to_shared_content_everybody_in_the_strip_is_small_and_content_focus_wants_nobody() {
762 775 let mut model = crowd(3);
763 776 model.apply(CallUpdate::ScreenShare(Some("8:orgid:p1".into())));
764 let wants = video_wants(&model, STAGE);
777 let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
765 778 assert_eq!(wants.len(), 3);
766 779 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));
767 780 model.view.choose(CallLayout::Content);
768 assert!(video_wants(&model, STAGE).is_empty());
781 assert!(video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH).is_empty());
782 }
783
784 #[test]
785 fn a_full_share_strip_wants_video_for_every_shown_tile_and_none_behind_the_plus_tile() {
786 let mut model = crowd(9);
787 model.apply(CallUpdate::ScreenShare(Some("8:orgid:p1".into())));
788 assert_eq!(video_wants(&model, (1400., 1100.), STRIP_DEFAULT_WIDTH).len(), 9);
789 let short = video_wants(&model, (1400., 600.), STRIP_DEFAULT_WIDTH);
790 assert!(short.len() >= 3 && short.len() < 9, "{} wants", short.len());
769 791 }
770 792 }
@@ -14,13 +14,13 @@ use gpui_kit::*;
14use super::avatar::person_avatar;
14use super::avatar::person_avatar;
15use super::call_organizer::render_focus_stage;
15use super::call_organizer::render_focus_stage;
16use super::call_view::{
16use super::call_view::{
17 GRID_PADDING, STRIP_GAP, STRIP_VISIBLE, TILE_GAP, own_tile, person_tile,
17 GRID_PADDING, STRIP_GAP, TILE_GAP, own_tile, person_tile,
18};
18};
19use super::widgets::icon;
19use super::widgets::icon;
20use crate::app_state::AppState;
20use crate::app_state::AppState;
21use crate::call::{
21use crate::call::{
22 ActiveCall, CallLayout, CallModel, FILMSTRIP_MAX, Filmstrip, Focus, GALLERY_MAX, Overflow, Tile, TileSize,
22 ActiveCall, CallLayout, CallModel, FILMSTRIP_MAX, Filmstrip, Focus, GALLERY_MAX, Overflow, Tile, TileSize,
23 filmstrip, focus_stage_size, gallery_grid, shown_bubbles, split_overflow,
23 filmstrip, focus_stage_size, gallery_grid, share_strip, shown_bubbles, split_overflow,
24};
24};
25use calling::{TileDetail, VideoWant};
25use calling::{TileDetail, VideoWant};
26use crate::theme;
26use crate::theme;
@@ -497,33 +497,52 @@ fn speaker_body(
497 .into_any_element()
497 .into_any_element()
498}
498}
499
499
500struct StripSplit<'a> {
501 width: f32,
502 others: Vec<&'a Tile>,
503 plan: Filmstrip,
504}
505
506fn strip_split(model: &CallModel, strip_width: f32, stage: (f32, f32)) -> StripSplit<'_> {
507 let available = (stage.0 - 2. * GRID_PADDING, (stage.1 - 2. * GRID_PADDING).max(0.));
508 let width = strip_width.min(((available.0 - TILE_GAP) / 2.).max(0.));
509 let others: Vec<&Tile> = model
510 .strip_tiles()
511 .into_iter()
512 .filter(|tile| !model.hidden_for_no_video(tile))
513 .collect();
514 let plan = share_strip(others.len(), model.own_cells(), (width, available.1), STRIP_GAP);
515 StripSplit { width, others, plan }
516}
517
500fn people_strip(
518fn people_strip(
501 app: &Entity<AppState>,
519 app: &Entity<AppState>,
502 state: &AppState,
520 state: &AppState,
503 model: &CallModel,
521 model: &CallModel,
504 now: Instant,
522 now: Instant,
505 available: (f32, f32),
523 stage: (f32, f32),
506) -> Stateful<Div> {
524) -> Stateful<Div> {
507 let strip_width = state.call_strip_width.min(((available.0 - TILE_GAP) / 2.).max(0.));
525 let StripSplit { width, others, plan } = strip_split(model, state.call_strip_width, stage);
508 let tile = TileSize::sixteen_by_nine(strip_width);
526 let size = TileSize::sixteen_by_nine(plan.tile_width);
509 let mut cells: Vec<AnyElement> = model
527 let shown = &others[..plan.overflow.shown];
510 .strip_tiles()
528 let mut cells: Vec<AnyElement> = shown
511 .into_iter()
529 .iter()
512 .filter(|tile_model| !model.hidden_for_no_video(tile_model))
530 .map(|remote| person_tile(app, state, model, remote, size, now))
513 .map(|remote| person_tile(app, state, model, remote, tile, now))
514 .collect();
531 .collect();
515 if model.own_cells() > 0 {
532 if model.own_cells() > 0 {
516 let own_index = model.own_cell_index(cells.len());
533 let own_index = model.own_cell_index(cells.len());
517 cells.insert(own_index, own_tile(app, state, model, tile, now));
534 cells.insert(own_index, own_tile(app, state, model, size, now));
535 }
536 if plan.overflow.hidden > 0 {
537 cells.push(overflow_tile(app, state, size, &others[plan.overflow.shown..]));
518 }
538 }
519 v_flex()
539 v_flex()
520 .id("call-strip")
540 .id("call-strip")
521 .debug_selector(|| "shell/islands/main/call-stage/share-strip".into())
541 .debug_selector(|| "shell/islands/main/call-stage/share-strip".into())
522 .flex_none()
542 .flex_none()
523 .w(px(tile.width))
543 .w(px(width))
524 .max_h(px((STRIP_VISIBLE * (tile.height + STRIP_GAP) - STRIP_GAP).min(available.1)))
544 .items_center()
525 .gap(px(STRIP_GAP))
545 .gap(px(STRIP_GAP))
526 .overflow_y_scroll()
527 .children(cells)
546 .children(cells)
528}
547}
529
548
@@ -582,13 +601,7 @@ fn share_body(
582 })
601 })
583 .child(share)
602 .child(share)
584 .when(layout != CallLayout::Content, |row| {
603 .when(layout != CallLayout::Content, |row| {
585 row.child(strip_divider(app, dragging)).child(people_strip(
604 row.child(strip_divider(app, dragging)).child(people_strip(app, state, model, now, stage))
586 app,
587 state,
588 model,
589 now,
590 (stage.0 - 2. * GRID_PADDING, stage.1 - 2. * GRID_PADDING),
591 ))
592 })
605 })
593 .into_any_element()
606 .into_any_element()
594}
607}
@@ -599,15 +612,14 @@ fn want(tile: &Tile, detail: TileDetail) -> VideoWant {
599 VideoWant { mri: tile.mri.clone(), detail }
612 VideoWant { mri: tile.mri.clone(), detail }
600}
613}
601
614
602pub fn video_wants(model: &CallModel, stage: (f32, f32)) -> Vec<VideoWant> {
615pub fn video_wants(model: &CallModel, stage: (f32, f32), strip_width: f32) -> Vec<VideoWant> {
603 if model.has_content() {
616 if model.has_content() {
604 if model.effective_layout() == CallLayout::Content {
617 if model.effective_layout() == CallLayout::Content {
605 return Vec::new();
618 return Vec::new();
606 }
619 }
607 return model
620 let split = strip_split(model, strip_width, stage);
608 .strip_tiles()
621 return split.others[..split.plan.overflow.shown]
609 .into_iter()
622 .iter()
610 .filter(|tile| !model.hidden_for_no_video(tile))
611 .map(|tile| want(tile, TileDetail::Small))
623 .map(|tile| want(tile, TileDetail::Small))
612 .collect();
624 .collect();
613 }
625 }
@@ -675,6 +687,7 @@ mod tests {
675 CallLayout, CallModel, FILMSTRIP_TILE_MAX, GALLERY_MAX, GRID_PADDING, TILE_GAP, filmstrip, split_overflow,
687 CallLayout, CallModel, FILMSTRIP_TILE_MAX, GALLERY_MAX, GRID_PADDING, TILE_GAP, filmstrip, split_overflow,
676 video_wants,
688 video_wants,
677 };
689 };
690 use crate::call::STRIP_DEFAULT_WIDTH;
678
691
679 const STAGE: (f32, f32) = (1400., 800.);
692 const STAGE: (f32, f32) = (1400., 800.);
680
693
@@ -711,7 +724,7 @@ mod tests {
711
724
712 #[test]
725 #[test]
713 fn a_small_gallery_asks_for_large_pictures() {
726 fn a_small_gallery_asks_for_large_pictures() {
714 let wants = video_wants(&crowd(3), STAGE);
727 let wants = video_wants(&crowd(3), STAGE, STRIP_DEFAULT_WIDTH);
715 assert_eq!(wants.len(), 3);
728 assert_eq!(wants.len(), 3);
716 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Stage));
729 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Stage));
717 }
730 }
@@ -719,7 +732,7 @@ mod tests {
719 #[test]
732 #[test]
720 fn a_big_gallery_asks_for_small_pictures_and_skips_the_plus_n_people() {
733 fn a_big_gallery_asks_for_small_pictures_and_skips_the_plus_n_people() {
721 let model = crowd(14);
734 let model = crowd(14);
722 let wants = video_wants(&model, STAGE);
735 let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
723 assert_eq!(wants.len(), split_overflow(14, 1, GALLERY_MAX).shown);
736 assert_eq!(wants.len(), split_overflow(14, 1, GALLERY_MAX).shown);
724 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));
737 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));
725 let hidden: Vec<&str> = model.layout_tiles()[wants.len()..].iter().map(|tile| tile.mri.as_str()).collect();
738 let hidden: Vec<&str> = model.layout_tiles()[wants.len()..].iter().map(|tile| tile.mri.as_str()).collect();
@@ -730,7 +743,7 @@ mod tests {
730 fn people_hidden_for_having_no_video_get_no_picture_request() {
743 fn people_hidden_for_having_no_video_get_no_picture_request() {
731 let mut model = meeting(vec![person(0, true), person(1, false), person(2, false)]);
744 let mut model = meeting(vec![person(0, true), person(1, false), person(2, false)]);
732 model.view.hide_no_video = true;
745 model.view.hide_no_video = true;
733 let wants = video_wants(&model, STAGE);
746 let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
734 assert_eq!(wants.iter().map(|want| want.mri.as_str()).collect::<Vec<_>>(), vec!["8:orgid:p0"]);
747 assert_eq!(wants.iter().map(|want| want.mri.as_str()).collect::<Vec<_>>(), vec!["8:orgid:p0"]);
735 }
748 }
736
749
@@ -740,7 +753,7 @@ mod tests {
740 model.view.choose(CallLayout::Speaker);
753 model.view.choose(CallLayout::Speaker);
741 model.refresh_layout(Instant::now());
754 model.refresh_layout(Instant::now());
742 let focus = model.speaker_focus().expect("a stage person").mri;
755 let focus = model.speaker_focus().expect("a stage person").mri;
743 let wants = video_wants(&model, STAGE);
756 let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
744 assert_eq!(wants[0], VideoWant { mri: focus.clone(), detail: TileDetail::Stage });
757 assert_eq!(wants[0], VideoWant { mri: focus.clone(), detail: TileDetail::Stage });
745 assert_eq!(wants.len(), 5);
758 assert_eq!(wants.len(), 5);
746 assert!(wants[1..].iter().all(|want| want.detail == TileDetail::Small && want.mri != focus));
759 assert!(wants[1..].iter().all(|want| want.detail == TileDetail::Small && want.mri != focus));
@@ -751,7 +764,7 @@ mod tests {
751 let mut model = crowd(12);
764 let mut model = crowd(12);
752 model.view.choose(CallLayout::Speaker);
765 model.view.choose(CallLayout::Speaker);
753 model.refresh_layout(Instant::now());
766 model.refresh_layout(Instant::now());
754 let wants = video_wants(&model, (500., 800.));
767 let wants = video_wants(&model, (500., 800.), STRIP_DEFAULT_WIDTH);
755 let fitting = filmstrip(11, 1, 500. - 2. * GRID_PADDING, TILE_GAP, FILMSTRIP_TILE_MAX).overflow.shown;
768 let fitting = filmstrip(11, 1, 500. - 2. * GRID_PADDING, TILE_GAP, FILMSTRIP_TILE_MAX).overflow.shown;
756 assert!(fitting < 11);
769 assert!(fitting < 11);
757 assert_eq!(wants.len(), 1 + fitting);
770 assert_eq!(wants.len(), 1 + fitting);
@@ -761,10 +774,19 @@ mod tests {
761 fn next_to_shared_content_everybody_in_the_strip_is_small_and_content_focus_wants_nobody() {
774 fn next_to_shared_content_everybody_in_the_strip_is_small_and_content_focus_wants_nobody() {
762 let mut model = crowd(3);
775 let mut model = crowd(3);
763 model.apply(CallUpdate::ScreenShare(Some("8:orgid:p1".into())));
776 model.apply(CallUpdate::ScreenShare(Some("8:orgid:p1".into())));
764 let wants = video_wants(&model, STAGE);
777 let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
765 assert_eq!(wants.len(), 3);
778 assert_eq!(wants.len(), 3);
766 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));
779 assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));
767 model.view.choose(CallLayout::Content);
780 model.view.choose(CallLayout::Content);
768 assert!(video_wants(&model, STAGE).is_empty());
781 assert!(video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH).is_empty());
782 }
783
784 #[test]
785 fn a_full_share_strip_wants_video_for_every_shown_tile_and_none_behind_the_plus_tile() {
786 let mut model = crowd(9);
787 model.apply(CallUpdate::ScreenShare(Some("8:orgid:p1".into())));
788 assert_eq!(video_wants(&model, (1400., 1100.), STRIP_DEFAULT_WIDTH).len(), 9);
789 let short = video_wants(&model, (1400., 600.), STRIP_DEFAULT_WIDTH);
790 assert!(short.len() >= 3 && short.len() < 9, "{} wants", short.len());
769 }
791 }
770}
792}
crates/app/src/views/call_view.rs +0 −1
@@ -55,7 +55,6 @@ pub(super) const DISABLED_OPACITY: f32 = 0.4;
55 55 pub(super) const TILE_GAP: f32 = 20.;
56 56 pub(super) const GRID_PADDING: f32 = 24.;
57 57 pub(super) const STRIP_GAP: f32 = 12.;
58 pub(super) const STRIP_VISIBLE: f32 = 4.;
59 58 const TILE_RADIUS: f32 = 12.;
60 59 const NAME_PLATE_BACKGROUND: f32 = 0.6;
61 60 pub const NO_MICROPHONE_HINT: &str = "No microphone found";
@@ -55,7 +55,6 @@ pub(super) const DISABLED_OPACITY: f32 = 0.4;
55pub(super) const TILE_GAP: f32 = 20.;
55pub(super) const TILE_GAP: f32 = 20.;
56pub(super) const GRID_PADDING: f32 = 24.;
56pub(super) const GRID_PADDING: f32 = 24.;
57pub(super) const STRIP_GAP: f32 = 12.;
57pub(super) const STRIP_GAP: f32 = 12.;
58pub(super) const STRIP_VISIBLE: f32 = 4.;
59const TILE_RADIUS: f32 = 12.;
58const TILE_RADIUS: f32 = 12.;
60const NAME_PLATE_BACKGROUND: f32 = 0.6;
59const NAME_PLATE_BACKGROUND: f32 = 0.6;
61pub const NO_MICROPHONE_HINT: &str = "No microphone found";
60pub const NO_MICROPHONE_HINT: &str = "No microphone found";
crates/calling/src/call.rs +40 −7
@@ -56,7 +56,7 @@ use crate::timeline::{Timeline, TimelineEntry};
56 56 use crate::transfer::{TransferEvent, TransferTarget};
57 57 use crate::video_frame::VideoKey;
58 58 use crate::video_layout::{
59 CAMERA_MID, MediaDescription, ONE_TO_ONE_SHARE_MID, SlotTable, VideoLines, VideoRouter, add_one_to_one_lines, add_video_lines, is_share_mid, offer_plan, one_to_one_plan,
59 CAMERA_MID, MediaDescription, ONE_TO_ONE_SHARE_MID, SlotTable, VideoLines, VideoRouter, add_one_to_one_lines, add_video_lines, offer_plan, one_to_one_plan,
60 60 };
61 61 use crate::send_control::{RequestFilter, parse_request};
62 62 use crate::video_send::{LocalVideo, SendSource, VideoMode};
@@ -1721,7 +1721,7 @@ async fn drive(
1721 1721 }
1722 1722 },
1723 1723 _ = stats_tick.tick(), if remote_set => {
1724 let snapshot = collect_stats(&current.peer).await;
1724 let snapshot = collect_stats(&current.peer, &layout_plan.screen_share_mids).await;
1725 1725 ticks += 1;
1726 1726 if caption_deadline.is_some_and(|deadline| Instant::now() >= deadline) {
1727 1727 caption_deadline = None;
@@ -1805,11 +1805,12 @@ async fn drive(
1805 1805 timeline.record(
1806 1806 "stats",
1807 1807 format!(
1808 "in packets={} bytes={} level={:.3} rms={decoded_rms:.3} tone={ratio:.2} out packets={} mic={:.3} erle={:.1} dtls={} video in packets={} decoded={} {}x{} out packets={} encoded={} {}x{} mixer reports {} (rtt {:.0} ms)",
1808 "in packets={} bytes={} level={:.3} rms={decoded_rms:.3} tone={ratio:.2} out packets={} mic={:.3} erle={:.1} dtls={} video in packets={} decoded={} {}x{} out packets={} encoded={} {}x{} mixer reports {} (rtt {:.0} ms){}",
1809 1809 snapshot.inbound_packets, snapshot.inbound_bytes, snapshot.audio_level, snapshot.outbound_packets, snapshot.local_level, snapshot.echo_return_loss_enhancement, snapshot.dtls_state,
1810 1810 snapshot.video.inbound_packets, snapshot.video.inbound_frames_decoded, snapshot.video.inbound_width, snapshot.video.inbound_height,
1811 1811 snapshot.video.outbound_packets, snapshot.video.outbound_frames_encoded, snapshot.video.outbound_width, snapshot.video.outbound_height,
1812 snapshot.video.remote_reports, snapshot.video.remote_round_trip_ms
1812 snapshot.video.remote_reports, snapshot.video.remote_round_trip_ms,
1813 snapshot.share_receive.as_ref().filter(|_| snapshot.share_inbound_packets > 0).map(ShareReceive::summary).unwrap_or_default()
1813 1814 ),
1814 1815 );
1815 1816 }
@@ -2609,6 +2610,7 @@ struct StatsSnapshot {
2609 2610 video: VideoReport,
2610 2611 share_inbound_packets: u64,
2611 2612 share_outbound_packets: u64,
2613 share_receive: Option<ShareReceive>,
2612 2614 dtls_state: String,
2613 2615 tls_version: String,
2614 2616 dtls_cipher: String,
@@ -2618,7 +2620,28 @@ struct StatsSnapshot {
2618 2620 transport: TransportDetails,
2619 2621 }
2620 2622
2621 async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
2623 #[derive(Debug, Default)]
2624 struct ShareReceive {
2625 frames_decoded: u32,
2626 key_frames_decoded: u32,
2627 width: u32,
2628 height: u32,
2629 frames_per_second: f64,
2630 pli_count: u32,
2631 fir_count: u32,
2632 freeze_count: u32,
2633 }
2634
2635 impl ShareReceive {
2636 fn summary(&self) -> String {
2637 format!(
2638 " share in decoded={} keyframes={} {}x{} fps={:.0} pli={} fir={} freezes={}",
2639 self.frames_decoded, self.key_frames_decoded, self.width, self.height, self.frames_per_second, self.pli_count, self.fir_count, self.freeze_count
2640 )
2641 }
2642 }
2643
2644 async fn collect_stats(peer: &PeerConnection, share_mids: &[String]) -> StatsSnapshot {
2622 2645 let Ok(stats) = peer.get_stats().await else {
2623 2646 return StatsSnapshot::default();
2624 2647 };
@@ -2641,8 +2664,18 @@ async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
2641 2664 }
2642 2665 RtcStats::InboundRtp(inbound) if inbound.stream.kind == "video" => {
2643 2666 snapshot.video.inbound_packets += inbound.received.packets_received;
2644 if is_share_mid(&inbound.inbound.mid) {
2667 if share_mids.contains(&inbound.inbound.mid) {
2645 2668 snapshot.share_inbound_packets += inbound.received.packets_received;
2669 snapshot.share_receive = Some(ShareReceive {
2670 frames_decoded: inbound.inbound.frames_decoded,
2671 key_frames_decoded: inbound.inbound.key_frames_decoded,
2672 width: inbound.inbound.frame_width,
2673 height: inbound.inbound.frame_height,
2674 frames_per_second: inbound.inbound.frames_per_second,
2675 pli_count: inbound.inbound.pli_count,
2676 fir_count: inbound.inbound.fir_count,
2677 freeze_count: inbound.inbound.freeze_count,
2678 });
2646 2679 }
2647 2680 snapshot.video.inbound_frames_decoded += u64::from(inbound.inbound.frames_decoded);
2648 2681 snapshot.video.inbound_width = snapshot.video.inbound_width.max(inbound.inbound.frame_width);
@@ -2654,7 +2687,7 @@ async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
2654 2687 }
2655 2688 RtcStats::OutboundRtp(outbound) if outbound.stream.kind == "video" => {
2656 2689 snapshot.video.outbound_packets += outbound.sent.packets_sent;
2657 if is_share_mid(&outbound.outbound.mid) {
2690 if share_mids.contains(&outbound.outbound.mid) {
2658 2691 snapshot.share_outbound_packets += outbound.sent.packets_sent;
2659 2692 }
2660 2693 snapshot.video.outbound_frames_encoded += u64::from(outbound.outbound.frames_encoded);
@@ -56,7 +56,7 @@ use crate::timeline::{Timeline, TimelineEntry};
56use crate::transfer::{TransferEvent, TransferTarget};
56use crate::transfer::{TransferEvent, TransferTarget};
57use crate::video_frame::VideoKey;
57use crate::video_frame::VideoKey;
58use crate::video_layout::{
58use crate::video_layout::{
59 CAMERA_MID, MediaDescription, ONE_TO_ONE_SHARE_MID, SlotTable, VideoLines, VideoRouter, add_one_to_one_lines, add_video_lines, is_share_mid, offer_plan, one_to_one_plan,
59 CAMERA_MID, MediaDescription, ONE_TO_ONE_SHARE_MID, SlotTable, VideoLines, VideoRouter, add_one_to_one_lines, add_video_lines, offer_plan, one_to_one_plan,
60};
60};
61use crate::send_control::{RequestFilter, parse_request};
61use crate::send_control::{RequestFilter, parse_request};
62use crate::video_send::{LocalVideo, SendSource, VideoMode};
62use crate::video_send::{LocalVideo, SendSource, VideoMode};
@@ -1721,7 +1721,7 @@ async fn drive(
1721 }
1721 }
1722 },
1722 },
1723 _ = stats_tick.tick(), if remote_set => {
1723 _ = stats_tick.tick(), if remote_set => {
1724 let snapshot = collect_stats(&current.peer).await;
1724 let snapshot = collect_stats(&current.peer, &layout_plan.screen_share_mids).await;
1725 ticks += 1;
1725 ticks += 1;
1726 if caption_deadline.is_some_and(|deadline| Instant::now() >= deadline) {
1726 if caption_deadline.is_some_and(|deadline| Instant::now() >= deadline) {
1727 caption_deadline = None;
1727 caption_deadline = None;
@@ -1805,11 +1805,12 @@ async fn drive(
1805 timeline.record(
1805 timeline.record(
1806 "stats",
1806 "stats",
1807 format!(
1807 format!(
1808 "in packets={} bytes={} level={:.3} rms={decoded_rms:.3} tone={ratio:.2} out packets={} mic={:.3} erle={:.1} dtls={} video in packets={} decoded={} {}x{} out packets={} encoded={} {}x{} mixer reports {} (rtt {:.0} ms)",
1808 "in packets={} bytes={} level={:.3} rms={decoded_rms:.3} tone={ratio:.2} out packets={} mic={:.3} erle={:.1} dtls={} video in packets={} decoded={} {}x{} out packets={} encoded={} {}x{} mixer reports {} (rtt {:.0} ms){}",
1809 snapshot.inbound_packets, snapshot.inbound_bytes, snapshot.audio_level, snapshot.outbound_packets, snapshot.local_level, snapshot.echo_return_loss_enhancement, snapshot.dtls_state,
1809 snapshot.inbound_packets, snapshot.inbound_bytes, snapshot.audio_level, snapshot.outbound_packets, snapshot.local_level, snapshot.echo_return_loss_enhancement, snapshot.dtls_state,
1810 snapshot.video.inbound_packets, snapshot.video.inbound_frames_decoded, snapshot.video.inbound_width, snapshot.video.inbound_height,
1810 snapshot.video.inbound_packets, snapshot.video.inbound_frames_decoded, snapshot.video.inbound_width, snapshot.video.inbound_height,
1811 snapshot.video.outbound_packets, snapshot.video.outbound_frames_encoded, snapshot.video.outbound_width, snapshot.video.outbound_height,
1811 snapshot.video.outbound_packets, snapshot.video.outbound_frames_encoded, snapshot.video.outbound_width, snapshot.video.outbound_height,
1812 snapshot.video.remote_reports, snapshot.video.remote_round_trip_ms
1812 snapshot.video.remote_reports, snapshot.video.remote_round_trip_ms,
1813 snapshot.share_receive.as_ref().filter(|_| snapshot.share_inbound_packets > 0).map(ShareReceive::summary).unwrap_or_default()
1813 ),
1814 ),
1814 );
1815 );
1815 }
1816 }
@@ -2609,6 +2610,7 @@ struct StatsSnapshot {
2609 video: VideoReport,
2610 video: VideoReport,
2610 share_inbound_packets: u64,
2611 share_inbound_packets: u64,
2611 share_outbound_packets: u64,
2612 share_outbound_packets: u64,
2613 share_receive: Option<ShareReceive>,
2612 dtls_state: String,
2614 dtls_state: String,
2613 tls_version: String,
2615 tls_version: String,
2614 dtls_cipher: String,
2616 dtls_cipher: String,
@@ -2618,7 +2620,28 @@ struct StatsSnapshot {
2618 transport: TransportDetails,
2620 transport: TransportDetails,
2619}
2621}
2620
2622
2621async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
2623#[derive(Debug, Default)]
2624struct ShareReceive {
2625 frames_decoded: u32,
2626 key_frames_decoded: u32,
2627 width: u32,
2628 height: u32,
2629 frames_per_second: f64,
2630 pli_count: u32,
2631 fir_count: u32,
2632 freeze_count: u32,
2633}
2634
2635impl ShareReceive {
2636 fn summary(&self) -> String {
2637 format!(
2638 " share in decoded={} keyframes={} {}x{} fps={:.0} pli={} fir={} freezes={}",
2639 self.frames_decoded, self.key_frames_decoded, self.width, self.height, self.frames_per_second, self.pli_count, self.fir_count, self.freeze_count
2640 )
2641 }
2642}
2643
2644async fn collect_stats(peer: &PeerConnection, share_mids: &[String]) -> StatsSnapshot {
2622 let Ok(stats) = peer.get_stats().await else {
2645 let Ok(stats) = peer.get_stats().await else {
2623 return StatsSnapshot::default();
2646 return StatsSnapshot::default();
2624 };
2647 };
@@ -2641,8 +2664,18 @@ async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
2641 }
2664 }
2642 RtcStats::InboundRtp(inbound) if inbound.stream.kind == "video" => {
2665 RtcStats::InboundRtp(inbound) if inbound.stream.kind == "video" => {
2643 snapshot.video.inbound_packets += inbound.received.packets_received;
2666 snapshot.video.inbound_packets += inbound.received.packets_received;
2644 if is_share_mid(&inbound.inbound.mid) {
2667 if share_mids.contains(&inbound.inbound.mid) {
2645 snapshot.share_inbound_packets += inbound.received.packets_received;
2668 snapshot.share_inbound_packets += inbound.received.packets_received;
2669 snapshot.share_receive = Some(ShareReceive {
2670 frames_decoded: inbound.inbound.frames_decoded,
2671 key_frames_decoded: inbound.inbound.key_frames_decoded,
2672 width: inbound.inbound.frame_width,
2673 height: inbound.inbound.frame_height,
2674 frames_per_second: inbound.inbound.frames_per_second,
2675 pli_count: inbound.inbound.pli_count,
2676 fir_count: inbound.inbound.fir_count,
2677 freeze_count: inbound.inbound.freeze_count,
2678 });
2646 }
2679 }
2647 snapshot.video.inbound_frames_decoded += u64::from(inbound.inbound.frames_decoded);
2680 snapshot.video.inbound_frames_decoded += u64::from(inbound.inbound.frames_decoded);
2648 snapshot.video.inbound_width = snapshot.video.inbound_width.max(inbound.inbound.frame_width);
2681 snapshot.video.inbound_width = snapshot.video.inbound_width.max(inbound.inbound.frame_width);
@@ -2654,7 +2687,7 @@ async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
2654 }
2687 }
2655 RtcStats::OutboundRtp(outbound) if outbound.stream.kind == "video" => {
2688 RtcStats::OutboundRtp(outbound) if outbound.stream.kind == "video" => {
2656 snapshot.video.outbound_packets += outbound.sent.packets_sent;
2689 snapshot.video.outbound_packets += outbound.sent.packets_sent;
2657 if is_share_mid(&outbound.outbound.mid) {
2690 if share_mids.contains(&outbound.outbound.mid) {
2658 snapshot.share_outbound_packets += outbound.sent.packets_sent;
2691 snapshot.share_outbound_packets += outbound.sent.packets_sent;
2659 }
2692 }
2660 snapshot.video.outbound_frames_encoded += u64::from(outbound.outbound.frames_encoded);
2693 snapshot.video.outbound_frames_encoded += u64::from(outbound.outbound.frames_encoded);
crates/calling/src/video_frame.rs +1 −1
@@ -11,7 +11,7 @@ use crate::control::CallUpdate;
11 11 pub const PERSON_FPS: u32 = 30;
12 12 pub const SCREEN_FPS: u32 = 15;
13 13 pub const PERSON_MAX_WIDTH: u32 = 640;
14 pub const SCREEN_MAX_WIDTH: u32 = 1600;
14 pub const SCREEN_MAX_WIDTH: u32 = 2560;
15 15 const BYTES_PER_PIXEL: usize = 4;
16 16
17 17 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -11,7 +11,7 @@ use crate::control::CallUpdate;
11pub const PERSON_FPS: u32 = 30;
11pub const PERSON_FPS: u32 = 30;
12pub const SCREEN_FPS: u32 = 15;
12pub const SCREEN_FPS: u32 = 15;
13pub const PERSON_MAX_WIDTH: u32 = 640;
13pub const PERSON_MAX_WIDTH: u32 = 640;
14pub const SCREEN_MAX_WIDTH: u32 = 1600;
14pub const SCREEN_MAX_WIDTH: u32 = 2560;
15const BYTES_PER_PIXEL: usize = 4;
15const BYTES_PER_PIXEL: usize = 4;
16
16
17#[derive(Debug, Clone, PartialEq, Eq, Hash)]
17#[derive(Debug, Clone, PartialEq, Eq, Hash)]
crates/calling/src/video_layout.rs +0 −3
@@ -17,9 +17,6 @@ pub const CAMERA_MID: &str = "1";
17 17 pub const SHARE_MID: &str = "11";
18 18 pub const ONE_TO_ONE_SHARE_MID: &str = "2";
19 19
20 pub fn is_share_mid(mid: &str) -> bool {
21 mid == SHARE_MID || mid == ONE_TO_ONE_SHARE_MID
22 }
23 20 const CAMERA_LINE_LABEL: &str = "main-video";
24 21 const SHARE_LINE_LABEL: &str = "applicationsharing-video";
25 22 const CAMERA_STREAM: &str = "camera";
@@ -17,9 +17,6 @@ pub const CAMERA_MID: &str = "1";
17pub const SHARE_MID: &str = "11";
17pub const SHARE_MID: &str = "11";
18pub const ONE_TO_ONE_SHARE_MID: &str = "2";
18pub const ONE_TO_ONE_SHARE_MID: &str = "2";
19
19
20pub fn is_share_mid(mid: &str) -> bool {
21 mid == SHARE_MID || mid == ONE_TO_ONE_SHARE_MID
22}
23const CAMERA_LINE_LABEL: &str = "main-video";
20const CAMERA_LINE_LABEL: &str = "main-video";
24const SHARE_LINE_LABEL: &str = "applicationsharing-video";
21const SHARE_LINE_LABEL: &str = "applicationsharing-video";
25const CAMERA_STREAM: &str = "camera";
22const CAMERA_STREAM: &str = "camera";
crates/calling/src/video_receive.rs +1 −1
@@ -196,7 +196,7 @@ impl VideoReceive {
196 196 .map(|(mri, source)| Assignment { mri, source, detail: TileDetail::Stage });
197 197 if wanted != self.screen_held {
198 198 let route_after = wanted.as_ref().map(|_| VideoKey::Screen);
199 self.router.set(&slot.mid, None);
199 self.router.set(&slot.mid, route_after.clone());
200 200 requester.send(
201 201 SourceRequest {
202 202 mid: slot.mid.clone(),
@@ -196,7 +196,7 @@ impl VideoReceive {
196 .map(|(mri, source)| Assignment { mri, source, detail: TileDetail::Stage });
196 .map(|(mri, source)| Assignment { mri, source, detail: TileDetail::Stage });
197 if wanted != self.screen_held {
197 if wanted != self.screen_held {
198 let route_after = wanted.as_ref().map(|_| VideoKey::Screen);
198 let route_after = wanted.as_ref().map(|_| VideoKey::Screen);
199 self.router.set(&slot.mid, None);
199 self.router.set(&slot.mid, route_after.clone());
200 requester.send(
200 requester.send(
201 SourceRequest {
201 SourceRequest {
202 mid: slot.mid.clone(),
202 mid: slot.mid.clone(),