Skip to content

Commit 31ee78f

Browse files
committed
add port, reconnect options
1 parent 0b0c72c commit 31ee78f

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src-tauri/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,12 @@ async fn on_start_check_epg(
406406

407407
#[tauri::command]
408408
async fn start_restream(
409+
port: u16,
409410
state: State<'_, Mutex<AppState>>,
410411
app: AppHandle,
411412
channel: Channel,
412413
) -> Result<(), String> {
413-
crate::restream::start_restream(state, app, channel)
414+
crate::restream::start_restream(port, state, app, channel)
414415
.await
415416
.map_err(map_err_frontend)
416417
}

src-tauri/src/restream.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ fn start_ffmpeg_listening(channel: Channel, restream_dir: PathBuf) -> Result<Chi
6363
.arg("6")
6464
.arg("-hls_flags")
6565
.arg("delete_segments")
66+
.arg("-reconnect")
67+
.arg("1")
68+
.arg("-reconnect_at_eof")
69+
.arg("1")
70+
.arg("-reconnect_streamed")
71+
.arg("1")
72+
.arg("-reconnect_on_network_error")
73+
.arg("1")
74+
.arg("-reconnect_max_retries")
75+
.arg("3")
6676
.arg(playlist_dir)
6777
.stdout(Stdio::null())
6878
.stderr(Stdio::null())
@@ -72,18 +82,20 @@ fn start_ffmpeg_listening(channel: Channel, restream_dir: PathBuf) -> Result<Chi
7282

7383
async fn start_web_server(
7484
restream_dir: PathBuf,
85+
port: u16,
7586
) -> Result<(Sender<bool>, tokio::task::JoinHandle<()>)> {
7687
let file_server = warp::fs::dir(restream_dir);
7788
let (tx, rx) = oneshot::channel::<bool>();
7889
let (_, server) =
79-
warp::serve(file_server).bind_with_graceful_shutdown(([0, 0, 0, 0], 3000), async {
90+
warp::serve(file_server).bind_with_graceful_shutdown(([0, 0, 0, 0], port), async {
8091
rx.await.ok();
8192
});
8293
let handle = tokio::spawn(server);
8394
return Ok((tx, handle));
8495
}
8596

8697
pub async fn start_restream(
98+
port: u16,
8799
state: State<'_, Mutex<AppState>>,
88100
app: AppHandle,
89101
channel: Channel,
@@ -93,7 +105,7 @@ pub async fn start_restream(
93105
let restream_dir = get_restream_folder()?;
94106
delete_old_segments(&restream_dir).await?;
95107
let mut ffmpeg_child = start_ffmpeg_listening(channel, restream_dir.clone())?;
96-
let (web_server_tx, web_server_handle) = start_web_server(restream_dir).await?;
108+
let (web_server_tx, web_server_handle) = start_web_server(restream_dir, port).await?;
97109
let _ = app.emit("restream_started", true);
98110
while !stop.load(std::sync::atomic::Ordering::Relaxed)
99111
&& ffmpeg_child

src/app/restream-modal/restream-modal.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class RestreamModalComponent implements OnInit, OnDestroy {
4242
async start() {
4343
this.loading = true;
4444
try {
45-
await invoke("start_restream", { channel: this.channel });
45+
await invoke("start_restream", { channel: this.channel, port: this.networkInfo!.port });
4646
} catch (e) {
4747
this.error.handleError(e);
4848
}

0 commit comments

Comments
 (0)