2020-03-25 22:30:22 +01:00
|
|
|
use serde::{Serialize, Deserialize};
|
2020-03-27 01:50:01 +01:00
|
|
|
use serde_repr::*;
|
2020-03-26 18:33:46 +01:00
|
|
|
use uuid::Uuid;
|
2020-03-25 02:14:49 +01:00
|
|
|
|
2020-03-26 01:39:22 +01:00
|
|
|
#[derive(Default, Debug, Serialize, Deserialize, Clone)]
|
2020-03-25 02:14:49 +01:00
|
|
|
pub struct WUnit {
|
2020-03-26 18:33:46 +01:00
|
|
|
pub id: Uuid,
|
|
|
|
pub description: WDesc,
|
|
|
|
pub status: EStatus
|
|
|
|
}
|
|
|
|
impl WUnit {
|
2020-03-26 21:55:13 +01:00
|
|
|
pub fn new(id: Uuid, description: WDesc) -> Self {
|
2020-03-26 18:33:46 +01:00
|
|
|
WUnit {
|
2020-03-26 21:55:13 +01:00
|
|
|
id: id,
|
2020-03-26 18:33:46 +01:00
|
|
|
description: description,
|
|
|
|
status: EStatus::Queued
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default, Debug, Serialize, Deserialize, Clone)]
|
|
|
|
pub struct WDesc {
|
2020-03-26 01:39:22 +01:00
|
|
|
pub file_url: String,
|
2020-03-27 01:50:01 +01:00
|
|
|
pub file_name: String,
|
2020-03-26 01:39:22 +01:00
|
|
|
pub priority: u16,
|
|
|
|
pub length: u32,
|
|
|
|
pub options: EOptions,
|
|
|
|
}
|
2020-03-26 18:33:46 +01:00
|
|
|
impl WDesc {
|
2020-03-27 01:50:01 +01:00
|
|
|
pub fn new(file_url: &str, file_name: &str, priority: Option<u16>, length: u32, options: Option<EOptions>) -> Self {
|
2020-03-26 18:33:46 +01:00
|
|
|
WDesc {
|
2020-03-26 01:39:22 +01:00
|
|
|
file_url: file_url.to_string(),
|
2020-03-27 01:50:01 +01:00
|
|
|
file_name: file_name.to_string(),
|
2020-03-26 01:39:22 +01:00
|
|
|
priority: priority.unwrap_or(0),
|
|
|
|
length: length,
|
2020-03-26 18:33:46 +01:00
|
|
|
options: options.unwrap_or(EOptions::default()),
|
2020-03-26 01:39:22 +01:00
|
|
|
}
|
|
|
|
}
|
2020-03-25 02:14:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-26 01:39:22 +01:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
pub struct EOptions {
|
2020-03-28 02:55:31 +01:00
|
|
|
pub ffmpeg: String,
|
|
|
|
pub aomenc: String,
|
|
|
|
pub two_pass: bool
|
2020-03-25 02:14:49 +01:00
|
|
|
}
|
|
|
|
impl Default for EOptions {
|
|
|
|
fn default() -> Self {
|
|
|
|
EOptions{
|
2020-03-28 02:55:31 +01:00
|
|
|
ffmpeg: String::default(),
|
|
|
|
aomenc: "--lag-in-frames=25 --tile-columns=0 --tile-rows=0 --enable-fwd-kf=1 --bit-depth=10 --cpu-used=3 --cq-level=30 --end-usage=q".to_string(),
|
|
|
|
two_pass: false
|
2020-03-25 02:14:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 01:39:22 +01:00
|
|
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
|
|
|
pub enum EStatus {
|
2020-03-25 02:14:49 +01:00
|
|
|
Queued,
|
2020-03-28 02:55:31 +01:00
|
|
|
Reserved(String),
|
|
|
|
Completed(String),
|
|
|
|
Cancelled,
|
|
|
|
Error(String)
|
2020-03-25 02:14:49 +01:00
|
|
|
}
|
|
|
|
impl Default for EStatus {
|
|
|
|
fn default() -> Self {
|
|
|
|
EStatus::Queued
|
|
|
|
}
|
2020-03-28 02:55:31 +01:00
|
|
|
}
|