Scan and generate Video HLS playlists on startup
Refactored and improved video path state. Bumped versions of some dependencies.
This commit is contained in:
11
src/state.rs
11
src/state.rs
@@ -1,11 +1,14 @@
|
||||
use crate::video::{PlaylistGenerator, VideoPlaylistManager};
|
||||
use crate::StreamActor;
|
||||
use actix::{Actor, Addr};
|
||||
use std::{env, sync::Arc};
|
||||
|
||||
pub struct AppState {
|
||||
pub stream_manager: Arc<Addr<StreamActor>>,
|
||||
pub playlist_manager: Arc<Addr<VideoPlaylistManager>>,
|
||||
pub base_path: String,
|
||||
pub thumbnail_path: String,
|
||||
pub video_path: String,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
@@ -13,11 +16,18 @@ impl AppState {
|
||||
stream_manager: Arc<Addr<StreamActor>>,
|
||||
base_path: String,
|
||||
thumbnail_path: String,
|
||||
video_path: String,
|
||||
) -> Self {
|
||||
let playlist_generator = PlaylistGenerator::new();
|
||||
let video_playlist_manager =
|
||||
VideoPlaylistManager::new(video_path.clone(), playlist_generator.start());
|
||||
|
||||
Self {
|
||||
stream_manager,
|
||||
playlist_manager: Arc::new(video_playlist_manager.start()),
|
||||
base_path,
|
||||
thumbnail_path,
|
||||
video_path,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +38,7 @@ impl Default for AppState {
|
||||
Arc::new(StreamActor {}.start()),
|
||||
env::var("BASE_PATH").expect("BASE_PATH was not set in the env"),
|
||||
env::var("THUMBNAILS").expect("THUMBNAILS was not set in the env"),
|
||||
env::var("VIDEO_PATH").expect("VIDEO_PATH was not set in the env"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user