A tool to get a HLS video stream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

72 lines
1.7 KiB

use std::path::PathBuf;
use http::Uri;
use tokio::sync::oneshot;
use crate::client_new::DownloadState;
use super::error::ClientActorError;
type ActionIndex = u64;
pub(super) type DownloadResult = Result<DownloadState, ClientActorError>;
#[derive(Debug)]
pub(super) enum ClientActorMessage {
Download {
filename: PathBuf,
uri: Uri,
respond_to: oneshot::Sender<DownloadResult>,
},
GetData {
uri: Uri,
respond_to: oneshot::Sender<Option<Vec<u8>>>,
},
}
#[derive(Clone, Debug)]
pub(super) enum ClientActorMessageHandle {
Download {
filename: PathBuf,
uri: Uri,
state: DownloadState,
message: ActionIndex,
},
GetData {
uri: Uri,
buffer: Option<Vec<u8>>,
message: ActionIndex,
},
}
impl ClientActorMessageHandle {
pub(super) fn set_state(&mut self, new_state: DownloadState) {
match self {
Self::Download { ref mut state, .. } => *state = new_state,
_ => panic!("Called with invalid variant"),
};
}
pub(super) fn filename(&self) -> PathBuf {
match self {
Self::Download { ref filename, .. } => filename.clone(),
_ => panic!("Called with invalid variant"),
}
}
pub(super) fn uri(&self) -> Uri {
match self {
Self::Download { ref uri, .. } => uri.clone(),
Self::GetData { ref uri, .. } => uri.clone(),
}
}
pub(super) fn buffer_mut(&mut self) -> &mut Option<Vec<u8>> {
match self {
Self::GetData { ref mut buffer, .. } => buffer,
_ => panic!("Called with invalid variant"),
}
}
}