separed video stream oss in scopes

This commit is contained in:
Valmo Trindade
2025-04-07 01:28:10 -03:00
parent db16d94596
commit 10d0b6f86c

View File

@@ -25,12 +25,14 @@ pub fn start_stream(
) -> &'static str {
#[cfg(target_os = "linux")]
{
return ctx.callback_null(
ctx.callback_null(
"armatak_video_error",
"Screen capture is only supported on Windows",
);
}
#[cfg(target_os = "windows")]
{
let (tx, rx): (Sender<()>, Receiver<()>) = mpsc::channel();
let rtsp_url = format!(
"rtsp://{}:{}@{}:{}/{}",
@@ -53,24 +55,12 @@ pub fn start_stream(
&rtsp_url_clone,
]);
#[cfg(target_os = "windows")]
let mut child = match cmd.creation_flags(CREATE_NO_WINDOW).spawn() {
Ok(child) => child,
Err(e) => {
let _ = ctx.callback_data(
"armatak_video_error",
"Failed to Start FFmpeg",
e.to_string(),
);
return;
}
};
let mut child = cmd.creation_flags(CREATE_NO_WINDOW).spawn().unwrap();
if rx.recv().is_err() {
let _ = ctx.callback_null("armatak_video_error", "Error receiving stop signal");
}
#[cfg(target_os = "windows")]
if let Err(e) = child.kill() {
let _ = ctx.callback_data(
"armatak_video_error",
@@ -86,6 +76,7 @@ pub fn start_stream(
eprintln!("Failed to acquire lock: {}", e);
}
}
}
"starting video stream"
}