1
- use std:: sync:: Mutex ;
2
-
3
1
use anyhow:: Error ;
4
2
use tauri:: {
5
3
menu:: { Menu , MenuItem } ,
6
4
tray:: { MouseButton , MouseButtonState , TrayIconBuilder , TrayIconEvent } ,
7
5
AppHandle , Manager , State ,
8
6
} ;
7
+ use tokio:: sync:: Mutex ;
9
8
use types:: {
10
9
AppState , Channel , CustomChannel , CustomChannelExtraData , EPGNotify , Filters , Group , IdName ,
11
10
Settings , Source , EPG ,
@@ -16,6 +15,7 @@ pub mod log;
16
15
pub mod m3u;
17
16
pub mod media_type;
18
17
pub mod mpv;
18
+ pub mod restream;
19
19
pub mod settings;
20
20
pub mod share;
21
21
pub mod source_type;
@@ -80,7 +80,9 @@ pub fn run() {
80
80
add_epg,
81
81
remove_epg,
82
82
get_epg_ids,
83
- on_start_check_epg
83
+ on_start_check_epg,
84
+ start_restream,
85
+ stop_restream
84
86
] )
85
87
. setup ( |app| {
86
88
app. manage ( Mutex :: new ( AppState {
@@ -95,14 +97,14 @@ pub fn run() {
95
97
. on_menu_event ( |app, event| match event. id . as_ref ( ) {
96
98
"quit" => {
97
99
app. exit ( 0 ) ;
98
- } ,
100
+ }
99
101
"show" => {
100
102
if let Some ( window) = app. get_webview_window ( "main" ) {
101
103
let _ = window. unminimize ( ) ;
102
104
let _ = window. show ( ) ;
103
105
let _ = window. set_focus ( ) ;
104
106
}
105
- } ,
107
+ }
106
108
_ => { }
107
109
} )
108
110
. on_tray_icon_event ( |tray, event| match event {
@@ -362,30 +364,53 @@ async fn download(app: AppHandle, channel: Channel) -> Result<(), String> {
362
364
. map_err ( map_err_frontend)
363
365
}
364
366
365
- #[ tauri:: command( async ) ]
366
- fn add_epg (
367
+ #[ tauri:: command]
368
+ async fn add_epg (
367
369
state : State < ' _ , Mutex < AppState > > ,
368
370
app : AppHandle ,
369
371
epg : EPGNotify ,
370
372
) -> Result < ( ) , String > {
371
- epg:: add_epg ( state, app, epg) . map_err ( map_err_frontend)
373
+ epg:: add_epg ( state, app, epg)
374
+ . await
375
+ . map_err ( map_err_frontend)
372
376
}
373
377
374
378
#[ tauri:: command( async ) ]
375
- fn remove_epg (
379
+ async fn remove_epg (
376
380
state : State < ' _ , Mutex < AppState > > ,
377
381
app : AppHandle ,
378
382
epg_id : String ,
379
383
) -> Result < ( ) , String > {
380
- epg:: remove_epg ( state, app, epg_id) . map_err ( map_err_frontend)
384
+ epg:: remove_epg ( state, app, epg_id)
385
+ . await
386
+ . map_err ( map_err_frontend)
381
387
}
382
388
383
389
#[ tauri:: command( async ) ]
384
390
fn get_epg_ids ( ) -> Result < Vec < String > , String > {
385
391
sql:: get_epg_ids ( ) . map_err ( map_err_frontend)
386
392
}
387
393
388
- #[ tauri:: command( async ) ]
389
- fn on_start_check_epg ( state : State < ' _ , Mutex < AppState > > , app : AppHandle ) -> Result < ( ) , String > {
390
- epg:: on_start_check_epg ( state, app) . map_err ( map_err_frontend)
394
+ #[ tauri:: command]
395
+ async fn on_start_check_epg (
396
+ state : State < ' _ , Mutex < AppState > > ,
397
+ app : AppHandle ,
398
+ ) -> Result < ( ) , String > {
399
+ epg:: on_start_check_epg ( state, app)
400
+ . await
401
+ . map_err ( map_err_frontend)
402
+ }
403
+
404
+ #[ tauri:: command]
405
+ async fn start_restream ( state : State < ' _ , Mutex < AppState > > , channel : Channel ) -> Result < ( ) , String > {
406
+ crate :: restream:: start_restream ( state, channel)
407
+ . await
408
+ . map_err ( map_err_frontend)
409
+ }
410
+
411
+ #[ tauri:: command]
412
+ async fn stop_restream ( state : State < ' _ , Mutex < AppState > > ) -> Result < ( ) , String > {
413
+ crate :: restream:: stop_restream ( state)
414
+ . await
415
+ . map_err ( map_err_frontend)
391
416
}
0 commit comments