fix last commit, snapshot for sending to new subscribers (#6762)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-12-29 13:41:33 +08:00 committed by GitHub
parent 3e78aacc7e
commit 6953efc2d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -741,15 +741,12 @@ fn try_broadcast_display_changed(
) { ) {
log::info!("Display {} changed", display); log::info!("Display {} changed", display);
if let Some(msg_out) = make_display_changed_msg(display_idx, Some(display)) { if let Some(msg_out) = make_display_changed_msg(display_idx, Some(display)) {
// switch display may occur before the first video frame, add snapshot to ensure successful send sp.send(msg_out.clone());
sp.snapshot(|sps| { // switch display may occur before the first video frame, add snapshot to send to new subscribers
// so that new sub and old sub share the same encoder after switch sp.snapshot(move |sps| {
if sps.has_subscribes() { sps.send(msg_out.clone());
bail!("SWITCH");
}
Ok(()) Ok(())
})?; })?;
sp.send(msg_out);
bail!("SWITCH"); bail!("SWITCH");
} }
} }