auto record outgoing (#9711)

* Add option auto record outgoing session
* In the same connection, all displays and all windows share the same
  recording state.

todo:

Android check external storage permission

Known issue:

* Sciter old issue, stop the process directly without stop record, the record file can't play.

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-10-21 14:34:06 +08:00
committed by GitHub
parent 289076aa70
commit e8187588c1
65 changed files with 442 additions and 322 deletions

View File

@@ -487,6 +487,8 @@ fn run(vs: VideoService) -> ResultType<()> {
let repeat_encode_max = 10;
let mut encode_fail_counter = 0;
let mut first_frame = true;
let capture_width = c.width;
let capture_height = c.height;
while sp.ok() {
#[cfg(windows)]
@@ -576,6 +578,8 @@ fn run(vs: VideoService) -> ResultType<()> {
recorder.clone(),
&mut encode_fail_counter,
&mut first_frame,
capture_width,
capture_height,
)?;
frame_controller.set_send(now, send_conn_ids);
}
@@ -632,6 +636,8 @@ fn run(vs: VideoService) -> ResultType<()> {
recorder.clone(),
&mut encode_fail_counter,
&mut first_frame,
capture_width,
capture_height,
)?;
frame_controller.set_send(now, send_conn_ids);
}
@@ -722,7 +728,13 @@ fn setup_encoder(
);
Encoder::set_fallback(&encoder_cfg);
let codec_format = Encoder::negotiated_codec();
let recorder = get_recorder(c.width, c.height, &codec_format, record_incoming);
let recorder = get_recorder(
c.width,
c.height,
&codec_format,
record_incoming,
display_idx,
);
let use_i444 = Encoder::use_i444(&encoder_cfg);
let encoder = Encoder::new(encoder_cfg.clone(), use_i444)?;
Ok((encoder, encoder_cfg, codec_format, use_i444, recorder))
@@ -809,6 +821,7 @@ fn get_recorder(
height: usize,
codec_format: &CodecFormat,
record_incoming: bool,
display: usize,
) -> Arc<Mutex<Option<Recorder>>> {
#[cfg(windows)]
let root = crate::platform::is_root();
@@ -828,10 +841,7 @@ fn get_recorder(
server: true,
id: Config::get_id(),
dir: crate::ui_interface::video_save_directory(root),
filename: "".to_owned(),
width,
height,
format: codec_format.clone(),
display,
tx,
})
.map_or(Default::default(), |r| Arc::new(Mutex::new(Some(r))))
@@ -910,6 +920,8 @@ fn handle_one_frame(
recorder: Arc<Mutex<Option<Recorder>>>,
encode_fail_counter: &mut usize,
first_frame: &mut bool,
width: usize,
height: usize,
) -> ResultType<HashSet<i32>> {
sp.snapshot(|sps| {
// so that new sub and old sub share the same encoder after switch
@@ -933,7 +945,7 @@ fn handle_one_frame(
.lock()
.unwrap()
.as_mut()
.map(|r| r.write_message(&msg));
.map(|r| r.write_message(&msg, width, height));
send_conn_ids = sp.send_video_frame(msg);
}
Err(e) => {