BlueGit

ict rusty-teams

fix(calls): the peer's camera tile shows the avatar as soon as the camera stops

- a 1:1 renegotiation offer without sent main video withdraws the remote picture at once
- before, the last frame stayed frozen for 2.5 s, then vanished, then came back

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-10 · 3 weeks ago

Hash
548a534f5430b21ea05e8809102a786667c079b9
Parent
910b8ef4
4 files changed +39 −3
crates/app-call-model/src/model.rs +1 −1
@@ -495,7 +495,7 @@ impl CallModel {
495 495 CallUpdate::Lobby(lobby) => self.lobby = lobby,
496 496 CallUpdate::OwnIdentity { mri } => self.own_mri = Some(mri),
497 497 CallUpdate::ScreenShare(sharer) => self.screen_sharer = sharer,
498 CallUpdate::VideoReady | CallUpdate::Notice(_) => {}
498 CallUpdate::VideoReady | CallUpdate::VideoStopped(_) | CallUpdate::Notice(_) => {}
499 499 CallUpdate::Camera(on) => self.camera_on = on,
500 500 CallUpdate::Cameras(cameras) => self.cameras = cameras,
501 501 CallUpdate::LocalShare(label) => {
@@ -495,7 +495,7 @@ impl CallModel {
495 CallUpdate::Lobby(lobby) => self.lobby = lobby,
495 CallUpdate::Lobby(lobby) => self.lobby = lobby,
496 CallUpdate::OwnIdentity { mri } => self.own_mri = Some(mri),
496 CallUpdate::OwnIdentity { mri } => self.own_mri = Some(mri),
497 CallUpdate::ScreenShare(sharer) => self.screen_sharer = sharer,
497 CallUpdate::ScreenShare(sharer) => self.screen_sharer = sharer,
498 CallUpdate::VideoReady | CallUpdate::Notice(_) => {}
498 CallUpdate::VideoReady | CallUpdate::VideoStopped(_) | CallUpdate::Notice(_) => {}
499 CallUpdate::Camera(on) => self.camera_on = on,
499 CallUpdate::Camera(on) => self.camera_on = on,
500 CallUpdate::Cameras(cameras) => self.cameras = cameras,
500 CallUpdate::Cameras(cameras) => self.cameras = cameras,
501 CallUpdate::LocalShare(label) => {
501 CallUpdate::LocalShare(label) => {
crates/app-state/src/call/actions.rs +28 −0
@@ -474,6 +474,11 @@ impl AppState {
474 474 CallMedia::changed(&media, cx);
475 475 return;
476 476 }
477 CallUpdate::VideoStopped(key) => {
478 call.pictures.forget(&key, cx);
479 CallMedia::changed(&media, cx);
480 return;
481 }
477 482 CallUpdate::Stats { .. } => return,
478 483 CallUpdate::Levels { local, remote } => {
479 484 let before = (call.model.local_speaking, call.model.remote_speaking);
@@ -1512,6 +1517,29 @@ mod tests {
1512 1517 assert_eq!(emitted.load(std::sync::atomic::Ordering::SeqCst), 1);
1513 1518 }
1514 1519
1520 #[gpui_kit::test]
1521 fn a_camera_the_peer_stops_leaves_the_tile_at_once(cx: &mut TestAppContext) {
1522 let app = app_with_call(cx);
1523 let key = calling::VideoKey::Person("8:orgid:peer".into());
1524 let shown = |app: &Entity<AppState>, cx: &mut TestAppContext| {
1525 cx.update(|cx| app.read(cx).call.as_ref().unwrap().pictures.live(&key, Instant::now()).is_some())
1526 };
1527 cx.update(|cx| {
1528 app.update(cx, |state, cx| {
1529 let hub = state.call.as_ref().unwrap().video.clone();
1530 hub.publish(key.clone(), calling::VideoPicture::solid(4, 4, 10, 20, 30));
1531 state.apply_call_update(7, CallUpdate::VideoReady, cx);
1532 })
1533 });
1534 assert!(shown(&app, cx));
1535 cx.update(|cx| {
1536 app.update(cx, |state, cx| {
1537 state.apply_call_update(7, CallUpdate::VideoStopped(key.clone()), cx)
1538 })
1539 });
1540 assert!(!shown(&app, cx));
1541 }
1542
1515 1543 #[gpui_kit::test]
1516 1544 fn the_computer_sound_switch_is_remembered_and_sent_to_the_call(cx: &mut TestAppContext) {
1517 1545 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
@@ -474,6 +474,11 @@ impl AppState {
474 CallMedia::changed(&media, cx);
474 CallMedia::changed(&media, cx);
475 return;
475 return;
476 }
476 }
477 CallUpdate::VideoStopped(key) => {
478 call.pictures.forget(&key, cx);
479 CallMedia::changed(&media, cx);
480 return;
481 }
477 CallUpdate::Stats { .. } => return,
482 CallUpdate::Stats { .. } => return,
478 CallUpdate::Levels { local, remote } => {
483 CallUpdate::Levels { local, remote } => {
479 let before = (call.model.local_speaking, call.model.remote_speaking);
484 let before = (call.model.local_speaking, call.model.remote_speaking);
@@ -1512,6 +1517,29 @@ mod tests {
1512 assert_eq!(emitted.load(std::sync::atomic::Ordering::SeqCst), 1);
1517 assert_eq!(emitted.load(std::sync::atomic::Ordering::SeqCst), 1);
1513 }
1518 }
1514
1519
1520 #[gpui_kit::test]
1521 fn a_camera_the_peer_stops_leaves_the_tile_at_once(cx: &mut TestAppContext) {
1522 let app = app_with_call(cx);
1523 let key = calling::VideoKey::Person("8:orgid:peer".into());
1524 let shown = |app: &Entity<AppState>, cx: &mut TestAppContext| {
1525 cx.update(|cx| app.read(cx).call.as_ref().unwrap().pictures.live(&key, Instant::now()).is_some())
1526 };
1527 cx.update(|cx| {
1528 app.update(cx, |state, cx| {
1529 let hub = state.call.as_ref().unwrap().video.clone();
1530 hub.publish(key.clone(), calling::VideoPicture::solid(4, 4, 10, 20, 30));
1531 state.apply_call_update(7, CallUpdate::VideoReady, cx);
1532 })
1533 });
1534 assert!(shown(&app, cx));
1535 cx.update(|cx| {
1536 app.update(cx, |state, cx| {
1537 state.apply_call_update(7, CallUpdate::VideoStopped(key.clone()), cx)
1538 })
1539 });
1540 assert!(!shown(&app, cx));
1541 }
1542
1515 #[gpui_kit::test]
1543 #[gpui_kit::test]
1516 fn the_computer_sound_switch_is_remembered_and_sent_to_the_call(cx: &mut TestAppContext) {
1544 fn the_computer_sound_switch_is_remembered_and_sent_to_the_call(cx: &mut TestAppContext) {
1517 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1545 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
crates/calling/src/call.rs +8 −1
@@ -36,7 +36,7 @@ use crate::end::EndKind;
36 36 use crate::engine::{CallEngine, EngineConfig, Inner};
37 37 use crate::error::{Error, Result};
38 38 use crate::health::{CallHealth, HealthCounters, HealthSampler, QualityTracker, TransportDetails, health_from_stats};
39 use crate::hold::{HoldState, INACTIVE, MediaLine, accepted_modalities, direction_of, offer_modalities, is_hold, keep_media_running, rewrite_directions, stop_sending_on};
39 use crate::hold::{HoldState, INACTIVE, MediaLine, accepted_modalities, direction_of, offer_modalities, is_hold, keep_media_running, offer_sends_video, rewrite_directions, stop_sending_on};
40 40 use crate::mic_processing::MicSettings;
41 41 use crate::mute::{MuteCommand, MuteEffect};
42 42 use crate::push::CallNotification;
@@ -1401,6 +1401,13 @@ async fn drive(
1401 1401 remote_direct_share = answered.receiving_share_mid.clone();
1402 1402 control.send(CallUpdate::ScreenShare(remote_direct_share.as_ref().and(peer_mri.clone())));
1403 1403 }
1404 if layout == Layout::OneToOne
1405 && !offer_sends_video(&renegotiation.sdp)
1406 && let Some(key) = main_video_mid(&answered.remote).and_then(|mid| video.router().key_for(&mid))
1407 {
1408 control.video.forget(&key);
1409 control.send(CallUpdate::VideoStopped(key));
1410 }
1404 1411 let held = is_hold(&renegotiation.sdp).unwrap_or(false);
1405 1412 if held != remote_hold {
1406 1413 remote_hold = held;
@@ -36,7 +36,7 @@ use crate::end::EndKind;
36use crate::engine::{CallEngine, EngineConfig, Inner};
36use crate::engine::{CallEngine, EngineConfig, Inner};
37use crate::error::{Error, Result};
37use crate::error::{Error, Result};
38use crate::health::{CallHealth, HealthCounters, HealthSampler, QualityTracker, TransportDetails, health_from_stats};
38use crate::health::{CallHealth, HealthCounters, HealthSampler, QualityTracker, TransportDetails, health_from_stats};
39use crate::hold::{HoldState, INACTIVE, MediaLine, accepted_modalities, direction_of, offer_modalities, is_hold, keep_media_running, rewrite_directions, stop_sending_on};
39use crate::hold::{HoldState, INACTIVE, MediaLine, accepted_modalities, direction_of, offer_modalities, is_hold, keep_media_running, offer_sends_video, rewrite_directions, stop_sending_on};
40use crate::mic_processing::MicSettings;
40use crate::mic_processing::MicSettings;
41use crate::mute::{MuteCommand, MuteEffect};
41use crate::mute::{MuteCommand, MuteEffect};
42use crate::push::CallNotification;
42use crate::push::CallNotification;
@@ -1401,6 +1401,13 @@ async fn drive(
1401 remote_direct_share = answered.receiving_share_mid.clone();
1401 remote_direct_share = answered.receiving_share_mid.clone();
1402 control.send(CallUpdate::ScreenShare(remote_direct_share.as_ref().and(peer_mri.clone())));
1402 control.send(CallUpdate::ScreenShare(remote_direct_share.as_ref().and(peer_mri.clone())));
1403 }
1403 }
1404 if layout == Layout::OneToOne
1405 && !offer_sends_video(&renegotiation.sdp)
1406 && let Some(key) = main_video_mid(&answered.remote).and_then(|mid| video.router().key_for(&mid))
1407 {
1408 control.video.forget(&key);
1409 control.send(CallUpdate::VideoStopped(key));
1410 }
1404 let held = is_hold(&renegotiation.sdp).unwrap_or(false);
1411 let held = is_hold(&renegotiation.sdp).unwrap_or(false);
1405 if held != remote_hold {
1412 if held != remote_hold {
1406 remote_hold = held;
1413 remote_hold = held;
crates/calling/src/control.rs +2 −1
@@ -25,7 +25,7 @@ use crate::signaling::{Callee, MeetingTarget};
25 25 use crate::transfer::Replacement;
26 26 use crate::state::CallState;
27 27 use crate::video_layout::VideoWant;
28 use crate::video_frame::{VideoHub, VideoPicture};
28 use crate::video_frame::{VideoHub, VideoKey, VideoPicture};
29 29 use crate::whiteboard::ContentShare;
30 30
31 31 #[derive(Debug, Clone, PartialEq, Eq)]
@@ -102,6 +102,7 @@ pub enum CallUpdate {
102 102 Lobby(bool),
103 103 OwnIdentity { mri: String },
104 104 VideoReady,
105 VideoStopped(VideoKey),
105 106 ScreenShare(Option<String>),
106 107 Camera(bool),
107 108 Cameras(Vec<CameraDevice>),
@@ -25,7 +25,7 @@ use crate::signaling::{Callee, MeetingTarget};
25use crate::transfer::Replacement;
25use crate::transfer::Replacement;
26use crate::state::CallState;
26use crate::state::CallState;
27use crate::video_layout::VideoWant;
27use crate::video_layout::VideoWant;
28use crate::video_frame::{VideoHub, VideoPicture};
28use crate::video_frame::{VideoHub, VideoKey, VideoPicture};
29use crate::whiteboard::ContentShare;
29use crate::whiteboard::ContentShare;
30
30
31#[derive(Debug, Clone, PartialEq, Eq)]
31#[derive(Debug, Clone, PartialEq, Eq)]
@@ -102,6 +102,7 @@ pub enum CallUpdate {
102 Lobby(bool),
102 Lobby(bool),
103 OwnIdentity { mri: String },
103 OwnIdentity { mri: String },
104 VideoReady,
104 VideoReady,
105 VideoStopped(VideoKey),
105 ScreenShare(Option<String>),
106 ScreenShare(Option<String>),
106 Camera(bool),
107 Camera(bool),
107 Cameras(Vec<CameraDevice>),
108 Cameras(Vec<CameraDevice>),