work units

This commit is contained in:
Daniel Løvbrøtte Olsen 2020-03-25 02:14:49 +01:00
parent 53d016ceb6
commit a1512e6889
3 changed files with 94 additions and 3 deletions

0
Rocket.toml Normal file
View File

View File

@ -2,12 +2,22 @@
#[macro_use] extern crate rocket; #[macro_use] extern crate rocket;
use std::path::PathBuf;
mod workunit;
use workunit::WUnit;
#[get("/")] #[get("/")]
fn index() -> &'static str { fn index() -> &'static str {
"Hello, world!" "Welcome to the AV1 Encoder Master Server"
}
#[get("/get_work/<max_length>")]
fn getJobs(max_length: u32, ) -> Result<String, std::io::Error> {
let mut work = WUnit::default();
Ok(format!("{:#?}", work))
} }
fn main() { fn main() {
rocket::ignite().mount("/", routes![index, getJobs]).launch();
rocket::ignite().mount("/", routes![index]).launch();
} }

81
src/workunit.rs Normal file
View File

@ -0,0 +1,81 @@
use std::path::PathBuf;
#[derive(Default, Debug)]
pub struct WUnit {
file_name: PathBuf,
priority: u16,
length: u32,
options: EOptions,
status: EStatus
}
#[derive(Debug)]
struct EOptions {
mode: EMode,
resolution: Resolution,
color_depth: EColorDepth,
enable_fwd_keyframe: bool,
kf_min_dist: Option<u16>,
kf_max_dist: Option<u16>,
two_pass: bool,
speed: u8
}
impl Default for EOptions {
fn default() -> Self {
EOptions{
mode: EMode::default(),
resolution: Resolution::default(),
color_depth: EColorDepth::default(),
enable_fwd_keyframe: true,
kf_min_dist: Option::default(),
kf_max_dist: Option::default(),
two_pass: false,
speed: 3
}
}
}
#[derive(Debug)]
enum EMode {
// 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)
}
}
#[derive(Default, Debug)]
struct Resolution {
width: Option<u16>,
height: Option<u16>
}
#[derive(Debug)]
enum EColorDepth {
Eight = 8,
Ten = 10,
Twelve = 12
}
impl Default for EColorDepth {
fn default() -> Self {
EColorDepth::Ten
}
}
#[derive(Debug)]
enum EStatus {
Queued,
Reserved,
Completed
}
impl Default for EStatus {
fn default() -> Self {
EStatus::Queued
}
}