Skip to content

Commit

Permalink
DB: Implement FlipMode and Pixelformat enums
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxuser committed Jan 30, 2022
1 parent 5f0b3fe commit 6d36ed0
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions src/models/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,44 @@ impl Default for V4L2Standard {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase", deny_unknown_fields)]
pub enum FlipMode {
#[serde(rename = "NO_CHANGE")]
NoChange,
Horizontal,
Vertical,
Both,
}

impl Default for FlipMode {
fn default() -> Self {
Self::NoChange
}
}

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE", deny_unknown_fields)]
pub enum Pixelformat {
#[serde(rename = "NO_CHANGE")]
NoChange,
Yuyv,
Uyvy,
Bgr16,
Bgr24,
Rgb32,
Bgr32,
I420,
Nv12,
Mjpeg,
}

impl Default for Pixelformat {
fn default() -> Self {
Self::NoChange
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
#[serde(default, rename_all = "camelCase", deny_unknown_fields)]
pub struct GrabberV4L2 {
Expand All @@ -178,8 +216,8 @@ pub struct GrabberV4L2 {
pub standard: V4L2Standard,
pub width: u32,
pub height: u32,
pub encoding: String,
pub flip: String,
pub encoding: Pixelformat,
pub flip: FlipMode,
#[validate(range(min = 1))]
pub fps: u32,
pub fps_software_decimation: u32,
Expand Down Expand Up @@ -229,8 +267,8 @@ impl Default for GrabberV4L2 {
standard: Default::default(),
width: 0,
height: 0,
encoding: "NO_CHANGE".to_owned(),
flip: "NO_CHANGE".to_owned(),
encoding: Pixelformat::NoChange,
flip: FlipMode::NoChange,
fps: 15,
fps_software_decimation: 0,
size_decimation: 6,
Expand Down

0 comments on commit 6d36ed0

Please sign in to comment.