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);
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.snapshot(|sps| {
// so that new sub and old sub share the same encoder after switch
if sps.has_subscribes() {
bail!("SWITCH");
}
sp.send(msg_out.clone());
// switch display may occur before the first video frame, add snapshot to send to new subscribers
sp.snapshot(move |sps| {
sps.send(msg_out.clone());
Ok(())
})?;
sp.send(msg_out);
bail!("SWITCH");
}
}