From a1512e6889b6fa579a833e2f5437dce4ded9c613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Wed, 25 Mar 2020 02:14:49 +0100 Subject: [PATCH] work units --- Rocket.toml | 0 src/main.rs | 16 ++++++++-- src/workunit.rs | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 Rocket.toml create mode 100644 src/workunit.rs diff --git a/Rocket.toml b/Rocket.toml new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs index 4a04e66..1c84519 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,12 +2,22 @@ #[macro_use] extern crate rocket; +use std::path::PathBuf; + +mod workunit; +use workunit::WUnit; + #[get("/")] fn index() -> &'static str { - "Hello, world!" + "Welcome to the AV1 Encoder Master Server" +} + +#[get("/get_work/")] +fn getJobs(max_length: u32, ) -> Result { + let mut work = WUnit::default(); + Ok(format!("{:#?}", work)) } fn main() { - - rocket::ignite().mount("/", routes![index]).launch(); + rocket::ignite().mount("/", routes![index, getJobs]).launch(); } \ No newline at end of file diff --git a/src/workunit.rs b/src/workunit.rs new file mode 100644 index 0000000..6fd08a9 --- /dev/null +++ b/src/workunit.rs @@ -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, + kf_max_dist: Option, + 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, + height: Option +} + +#[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 + } +} \ No newline at end of file