Scan and generate Video HLS playlists on startup

Refactored and improved video path state. Bumped versions of some dependencies.
This commit is contained in:
Cameron
2024-12-05 20:19:03 -05:00
parent 2b2a811cae
commit 0419aa2323
6 changed files with 593 additions and 62 deletions

View File

@@ -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"),
)
}
}