Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(export): extract ExportSettings into settings module

Richie McIlroy2100f7fb7cdf
diff --git a/crates/export/src/lib.rs b/crates/export/src/lib.rs
index 24c4ee573..58d567229 100644
--- a/crates/export/src/lib.rs
+++ b/crates/export/src/lib.rs
@@ -2,6 +2,7 @@ pub mod gif;
pub mod mov;
pub mod mp4;
pub mod preview;
+pub mod settings;
use cap_editor::SegmentMedia;
use cap_project::{
diff --git a/crates/export/src/settings.rs b/crates/export/src/settings.rs
new file mode 100644
index 000000000..755f2a6c1
--- /dev/null
+++ b/crates/export/src/settings.rs
@@ -0,0 +1,41 @@
+use serde::{Deserialize, Serialize};
+use specta::Type;
+
+use crate::gif::GifExportSettings;
+use crate::mov::MovExportSettings;
+use crate::mp4::Mp4ExportSettings;
+
+#[derive(Serialize, Deserialize, Clone, Copy, Debug, Type)]
+#[serde(tag = "format")]
+pub enum ExportSettings {
+ #[serde(alias = "mp4")]
+ Mp4(Mp4ExportSettings),
+ #[serde(alias = "gif")]
+ Gif(GifExportSettings),
+ #[serde(alias = "mov")]
+ Mov(MovExportSettings),
+}
+
+impl ExportSettings {
+ pub fn fps(&self) -> u32 {
+ match self {
+ Self::Mp4(s) => s.fps,
+ Self::Gif(s) => s.fps,
+ Self::Mov(s) => s.fps,
+ }
+ }
+
+ pub fn force_ffmpeg_decoder(&self) -> bool {
+ match self {
+ Self::Mp4(s) => s.force_ffmpeg_decoder,
+ Self::Gif(_) | Self::Mov(_) => false,
+ }
+ }
+
+ pub fn cursor_only(&self) -> bool {
+ match self {
+ Self::Mov(s) => s.cursor_only,
+ _ => false,
+ }
+ }
+}