Skip to content

Commit 50f3a8b

Browse files
committed
[+] add some camera setting UI codes
1 parent 800d432 commit 50f3a8b

24 files changed

+887
-40
lines changed

Cargo.lock

Lines changed: 139 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ indexmap = "2.12"
110110
thiserror = "2.0"
111111
crossbeam = "0.8"
112112
byteorder = "1.5"
113+
photon-rs = "0.3"
114+
imageproc = "0.26"
113115
tokio-util = "0.7"
114116
spin_sleep = "1.3"
115117
stunclient = "0.4"
@@ -128,9 +130,6 @@ rodio = { version = "0.21", default-features = false }
128130
rustls = { version = "0.23", default-features = false }
129131
tokio-rustls = { version = "0.26", default-features = false }
130132

131-
photon-rs = "0.3"
132-
imageproc = "0.25"
133-
134133
mp4m = { path = "lib/mp4m" }
135134
wrtc = { path = "lib/wrtc" }
136135
srtmp = { path = "lib/srtmp" }

lib/recorder/src/resolution.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use std::fmt;
2121
pub enum Resolution {
2222
/// Keep original resolution with specified dimensions
2323
Original((u32, u32)),
24+
/// 480p resolution (480x640 pixels)
25+
P480,
2426
/// 720p resolution (1280x720 pixels)
2527
P720,
2628
/// 1080p resolution (1920x1080 pixels)
@@ -64,6 +66,10 @@ impl Resolution {
6466
pub fn dimensions(&self, original_width: u32, original_height: u32) -> (u32, u32) {
6567
match self {
6668
Resolution::Original(_) => (original_width, original_height),
69+
Resolution::P480 => Self::calculate_scaled_dimensions(
70+
(original_width, original_height),
71+
Resolution::P480.to_dimension(),
72+
),
6773
Resolution::P720 => Self::calculate_scaled_dimensions(
6874
(original_width, original_height),
6975
Resolution::P720.to_dimension(),
@@ -174,14 +180,16 @@ impl Resolution {
174180
/// assert!(matches!(res, Resolution::Original((800, 600))));
175181
/// ```
176182
pub fn preference_resolution(width: u32, height: u32) -> Self {
177-
if width >= 2160 {
183+
if height >= 2160 {
178184
Resolution::P4K
179-
} else if width >= 1440 {
185+
} else if height >= 1440 {
180186
Resolution::P2K
181-
} else if width >= 1080 {
187+
} else if height >= 1080 {
182188
Resolution::P1080
183-
} else if width >= 720 {
189+
} else if height >= 720 {
184190
Resolution::P720
191+
} else if height >= 480 {
192+
Resolution::P480
185193
} else {
186194
Resolution::Original((width, height))
187195
}
@@ -210,6 +218,7 @@ impl Resolution {
210218
Resolution::P2K => (2560, 1440),
211219
Resolution::P1080 => (1920, 1080),
212220
Resolution::P720 => (1280, 720),
221+
Resolution::P480 => (640, 480),
213222
}
214223
}
215224
}
@@ -231,6 +240,7 @@ impl fmt::Display for Resolution {
231240
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
232241
match self {
233242
Resolution::Original((w, h)) => write!(f, "Original({}x{})", w, h),
243+
Resolution::P480 => write!(f, "480p (640x480)"),
234244
Resolution::P720 => write!(f, "720p (1280x720)"),
235245
Resolution::P1080 => write!(f, "1080p (1920x1080)"),
236246
Resolution::P2K => write!(f, "2K (2560x1440)"),

wayshot/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ cutil = { workspace = true, features = ["str", "time", "number", "fs"] }
4040
open.workspace = true
4141
wrtc.workspace = true
4242
mp4m.workspace = true
43+
camera.workspace = true
4344
tempfile.workspace = true
4445
recorder.workspace = true
4546
clipboard.workspace = true

0 commit comments

Comments
 (0)