2020-03-25 22:30:22 +01:00
|
|
|
use serde::{Serialize, Deserialize};
|
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,
|
|
|
|
pub priority: u16,
|
|
|
|
pub length: u32,
|
|
|
|
pub options: EOptions,
|
|
|
|
}
|
2020-03-26 18:33:46 +01:00
|
|
|
impl WDesc {
|
|
|
|
pub fn new(file_url: &str, priority: Option<u16>, length: u32, options: Option<EOptions>) -> Self {
|
|
|
|
WDesc {
|
2020-03-26 01:39:22 +01:00
|
|
|
file_url: file_url.to_string(),
|
|
|
|
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 {
|
|
|
|
pub mode: EMode,
|
2020-03-26 18:33:46 +01:00
|
|
|
pub resolution: Option<Resolution>,
|
2020-03-26 01:39:22 +01:00
|
|
|
pub color_depth: EColorDepth,
|
|
|
|
pub enable_fwd_keyframe: bool,
|
|
|
|
pub kf_min_dist: Option<u16>,
|
|
|
|
pub kf_max_dist: Option<u16>,
|
|
|
|
pub two_pass: bool,
|
|
|
|
pub speed: u8
|
2020-03-25 02:14:49 +01:00
|
|
|
}
|
|
|
|
impl Default for EOptions {
|
|
|
|
fn default() -> Self {
|
|
|
|
EOptions{
|
|
|
|
mode: EMode::default(),
|
2020-03-26 18:33:46 +01:00
|
|
|
resolution: Option::default(),
|
2020-03-25 02:14:49 +01:00
|
|
|
color_depth: EColorDepth::default(),
|
|
|
|
enable_fwd_keyframe: true,
|
|
|
|
kf_min_dist: Option::default(),
|
|
|
|
kf_max_dist: Option::default(),
|
|
|
|
two_pass: false,
|
|
|
|
speed: 3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 01:39:22 +01:00
|
|
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
|
|
|
pub enum EMode {
|
2020-03-25 02:14:49 +01:00
|
|
|
// Quality (CRF), Constrained Quality, Variable Bitrate, Constant Bitrate
|
|
|
|
Q(u8),
|
|
|
|
CQ(u8),
|
|
|
|
VBR(u32),
|
|
|
|
CBR(u32)
|
|
|
|
}
|
|
|
|
impl Default for EMode {
|
|
|
|
fn default() -> Self {
|
|
|
|
EMode::Q(30)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 01:39:22 +01:00
|
|
|
#[derive(Default, Debug, Serialize, Deserialize, Clone)]
|
|
|
|
pub struct Resolution {
|
2020-03-26 18:33:46 +01:00
|
|
|
pub width: u16,
|
|
|
|
pub height: u16
|
2020-03-25 02:14:49 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 01:39:22 +01:00
|
|
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
|
|
|
pub enum EColorDepth {
|
2020-03-25 02:14:49 +01:00
|
|
|
Eight = 8,
|
|
|
|
Ten = 10,
|
|
|
|
Twelve = 12
|
|
|
|
}
|
|
|
|
impl Default for EColorDepth {
|
|
|
|
fn default() -> Self {
|
|
|
|
EColorDepth::Ten
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-26 01:39:22 +01:00
|
|
|
Reserved(Client),
|
2020-03-25 02:14:49 +01:00
|
|
|
Completed
|
|
|
|
}
|
|
|
|
impl Default for EStatus {
|
|
|
|
fn default() -> Self {
|
|
|
|
EStatus::Queued
|
|
|
|
}
|
2020-03-26 01:39:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type Client = String;
|