fix client side record

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-10-18 22:39:28 +08:00
parent 510cffb305
commit 7a5bc864fa
10 changed files with 119 additions and 59 deletions

View File

@@ -999,16 +999,19 @@ pub struct VideoHandler {
pub rgb: ImageRgb,
recorder: Arc<Mutex<Option<Recorder>>>,
record: bool,
_display: usize, // useful for debug
}
impl VideoHandler {
/// Create a new video handler.
pub fn new() -> Self {
pub fn new(_display: usize) -> Self {
log::info!("new video handler for display #{_display}");
VideoHandler {
decoder: Decoder::new(),
rgb: ImageRgb::new(ImageFormat::ARGB, crate::DST_STRIDE_RGBA),
recorder: Default::default(),
record: false,
_display,
}
}
@@ -1900,7 +1903,7 @@ where
if handler_controller_map.len() <= display {
for _i in handler_controller_map.len()..=display {
handler_controller_map.push(VideoHandlerController {
handler: VideoHandler::new(),
handler: VideoHandler::new(_i),
count: 0,
duration: std::time::Duration::ZERO,
skip_beginning: 0,
@@ -1960,6 +1963,7 @@ where
}
}
MediaData::RecordScreen(start, display, w, h, id) => {
log::info!("record screen command: start:{start}, display:{display}");
if handler_controller_map.len() == 1 {
// Compatible with the sciter version(single ui session).
// For the sciter version, there're no multi-ui-sessions for one connection.

View File

@@ -2104,7 +2104,7 @@ impl Connection {
display,
video_service::OPTION_REFRESH,
super::service::SERVICE_OPTION_VALUE_TRUE,
)
);
});
}
@@ -2145,6 +2145,7 @@ impl Connection {
// Send display changed message.
// For compatibility with old versions ( < 1.2.4 ).
// sciter need it in new version
if let Some(msg_out) = video_service::make_display_changed_msg(self.display_idx, None) {
self.send(msg_out).await;
}

View File

@@ -299,14 +299,22 @@ class Header: Reactor.Component {
header.update();
handler.record_status(recording);
// 0 is just a dummy value. It will be ignored by the handler.
if (recording)
if (recording) {
handler.refresh_video(0);
else
handler.record_screen(false, 0, display_width, display_height);
if (handler.version_cmp(pi.version, '1.2.4') >= 0) handler.record_screen(recording, pi.current_display, display_width, display_height);
}
else {
handler.record_screen(recording, pi.current_display, display_width, display_height);
}
}
event click $(#screen) (_, me) {
if (pi.current_display == me.index) return;
if (recording) {
recording = false;
handler.record_screen(false, pi.current_display, display_width, display_height);
handler.record_status(false);
}
handler.switch_display(me.index);
}

View File

@@ -243,6 +243,7 @@ impl InvokeUiSession for SciterHandler {
pi_sciter.set_item("sas_enabled", pi.sas_enabled);
pi_sciter.set_item("displays", Self::make_displays_array(&pi.displays));
pi_sciter.set_item("current_display", pi.current_display);
pi_sciter.set_item("version", pi.version.clone());
self.call("updatePi", &make_args!(pi_sciter));
}
@@ -469,6 +470,7 @@ impl sciter::EventHandler for SciterSession {
fn restart_remote_device();
fn request_voice_call();
fn close_voice_call();
fn version_cmp(String, String);
}
}
@@ -757,6 +759,10 @@ impl SciterSession {
log::error!("Failed to spawn IP tunneling: {}", err);
}
}
fn version_cmp(&self, v1: String, v2: String) -> i32 {
(hbb_common::get_version_number(&v1) - hbb_common::get_version_number(&v2)) as i32
}
}
pub fn make_fd(id: i32, entries: &Vec<FileEntry>, only_count: bool) -> Value {