src/requests/custom/source_settings.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! Additional structs for use with |
2 | | //! [`crate::client::Inputs::set_settings`]. |
3 | | |
4 | | use std::path::Path; |
5 | | |
6 | | use rgb::RGBA8; |
7 | | use serde::{ser::SerializeStruct, Serialize, Serializer}; |
8 | | use serde_repr::Serialize_repr; |
9 | | use time::Duration; |
10 | | |
11 | | use crate::common::FontFlags; |
12 | | |
13 | | /// Identifier for input capture sources. |
14 | | pub const SOURCE_COREAUDIO_INPUT_CAPTURE: &str = "coreaudio_input_capture"; |
15 | | /// Identifier for output capture sources. |
16 | | pub const SOURCE_COREAUDIO_OUTPUT_CAPTURE: &str = "coreaudio_output_capture"; |
17 | | /// Identifier for browser sources. |
18 | | pub const SOURCE_BROWSER_SOURCE: &str = "browser_source"; |
19 | | /// Identifier for color sources. |
20 | | pub const SOURCE_COLOR_SOURCE_V3: &str = "color_source_v3"; |
21 | | /// Identifier for display capture sources. |
22 | | pub const SOURCE_DISPLAY_CAPTURE: &str = "display_capture"; |
23 | | /// Identifier for image sources. |
24 | | pub const SOURCE_IMAGE_SOURCE: &str = "image_source"; |
25 | | /// Identifier for image slide-show sources. |
26 | | pub const SOURCE_SLIDESHOW: &str = "slideshow"; |
27 | | /// Identifier for FFmpeg video sources. |
28 | | pub const SOURCE_FFMPEG_SOURCE: &str = "ffmpeg_source"; |
29 | | /// Identifier for FreeType2 text sources. |
30 | | pub const SOURCE_TEXT_FT2_SOURCE_V2: &str = "text_ft2_source_v2"; |
31 | | /// Identifier for VLC video sources. |
32 | | pub const SOURCE_VLC_SOURCE: &str = "vlc_source"; |
33 | | /// Identifier for audio/video input capture sources. |
34 | | pub const SOURCE_AV_CAPTURE_INPUT_V2: &str = "av_capture_input_v2"; |
35 | | /// Identifier for source window capture sources. |
36 | | pub const SOURCE_WINDOW_CAPTURE: &str = "window_capture"; |
37 | | |
38 | | /// Settings specific to a **CoreAudio** input capture source. |
39 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::CoreaudioInputCapture as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::CoreaudioInputCapture as serde::ser::Serialize>::serialize::<_> |
40 | | pub struct CoreaudioInputCapture<'a> { |
41 | | /// Input device identifier. |
42 | | pub device_id: &'a str, |
43 | | } |
44 | | |
45 | | /// Settings specific to a **CoreAudio** output capture source. |
46 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::CoreaudioOutputCapture as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::CoreaudioOutputCapture as serde::ser::Serialize>::serialize::<_> |
47 | | pub struct CoreaudioOutputCapture<'a> { |
48 | | /// Output device identifier. |
49 | | pub device_id: &'a str, |
50 | | } |
51 | | |
52 | | /// Settings specific to a browser source. |
53 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::BrowserSource as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::BrowserSource as serde::ser::Serialize>::serialize::<_> |
54 | | pub struct BrowserSource<'a> { |
55 | | /// Whether to use a local file instead of a remote location. |
56 | | /// |
57 | | /// If true, the [`Self::local_file`] setting is used, [`Self::url`] otherwise. |
58 | | pub is_local_file: bool, |
59 | | /// Local file to open as web page. Only used if [`Self::is_local_file`] is set to `true`. |
60 | | pub local_file: &'a Path, |
61 | | /// Remote location of a web page. Only used if [`Self::is_local_file`] is set to `false`. |
62 | | pub url: &'a str, |
63 | | /// Browser window width in pixels. |
64 | | pub width: u32, |
65 | | /// Browser window height in pixels. |
66 | | pub height: u32, |
67 | | /// Use custom frame rate. |
68 | | pub fps_custom: bool, |
69 | | /// Custom FPS, only used if [`Self::fps_custom`] is set to `true`. |
70 | | pub fps: u16, |
71 | | /// Control audio via OBS. |
72 | | pub reroute_audio: bool, |
73 | | /// Custom CSS. |
74 | | pub css: &'a str, |
75 | | /// Shutdown source when not visible. |
76 | | pub shutdown: bool, |
77 | | /// Refresh browser when scene becomes active. |
78 | | pub restart_when_active: bool, |
79 | | } |
80 | | |
81 | | impl<'a> Default for BrowserSource<'a> { |
82 | 0 | fn default() -> Self { |
83 | 0 | Self { |
84 | 0 | is_local_file: false, |
85 | 0 | local_file: Path::new(""), |
86 | 0 | url: "https://obsproject.com/browser-source", |
87 | 0 | width: 800, |
88 | 0 | height: 600, |
89 | 0 | fps_custom: false, |
90 | 0 | fps: 30, |
91 | 0 | reroute_audio: false, |
92 | 0 | css: "body { background-color: rgba(0, 0, 0, 0); margin: 0px auto; overflow: hidden; }", |
93 | 0 | shutdown: false, |
94 | 0 | restart_when_active: false, |
95 | 0 | } |
96 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::BrowserSource as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::BrowserSource as core::default::Default>::default |
97 | | } |
98 | | |
99 | | /// Settings specific to a color source. |
100 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::ColorSourceV3 as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::ColorSourceV3 as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::ColorSourceV3 as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::ColorSourceV3 as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> |
101 | | pub struct ColorSourceV3 { |
102 | | /// Color to display. |
103 | | #[serde(with = "crate::serde::rgba8_inverse")] |
104 | | pub color: RGBA8, |
105 | | /// Source width in pixels. |
106 | | pub width: u32, |
107 | | /// Source height in pixels. |
108 | | pub height: u32, |
109 | | } |
110 | | |
111 | | impl Default for ColorSourceV3 { |
112 | 0 | fn default() -> Self { |
113 | 0 | Self { |
114 | 0 | color: RGBA8::new(209, 209, 209, 255), |
115 | 0 | width: 0, |
116 | 0 | height: 0, |
117 | 0 | } |
118 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::ColorSourceV3 as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::ColorSourceV3 as core::default::Default>::default |
119 | | } |
120 | | |
121 | | /// Settings specific to a display capture source. |
122 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::DisplayCapture as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::DisplayCapture as serde::ser::Serialize>::serialize::<_> |
123 | | pub struct DisplayCapture<'a> { |
124 | | /// Index of the display to capture. Usually `0` for the main display. |
125 | | pub display: u8, |
126 | | /// Whether to show the cursor on the captured input. |
127 | | pub show_cursor: bool, |
128 | | /// Cropping of the window input. |
129 | | #[serde(flatten)] |
130 | | pub crop_mode: CropMode<'a>, |
131 | | } |
132 | | |
133 | | /// The capture cropping for a [`DisplayCapture`] source. |
134 | | pub enum CropMode<'a> { |
135 | | /// Disable any cropping. |
136 | | None, |
137 | | /// Manual cropping by pixel dimensions. |
138 | | Manual { |
139 | | /// Left side cropping. |
140 | | left: f64, |
141 | | /// Top side cropping. |
142 | | top: f64, |
143 | | /// Right side cropping. |
144 | | right: f64, |
145 | | /// Bottom side cropping. |
146 | | bottom: f64, |
147 | | }, |
148 | | /// Crop the capture to a specific window on the screen. |
149 | | ToWindow { |
150 | | /// Owner of the window. Usually the program name. |
151 | | owner_name: &'a str, |
152 | | /// Title of the window. Depending on the OS usually found at the top window corner. |
153 | | window_name: &'a str, |
154 | | /// ID of the window. |
155 | | window: u32, |
156 | | /// List up windows with empty names in the UI drop-down selection. |
157 | | show_empty_names: bool, |
158 | | }, |
159 | | /// A combination of [`Self::ToWindow`] and [`Self::Manual`], cropping to the window first, then |
160 | | /// applying manual cropping. |
161 | | ToWindowAndManual { |
162 | | /// Owner of the window. Usually the program name. |
163 | | owner_name: &'a str, |
164 | | /// Title of the window. Depending on the OS usually found at the top window corner. |
165 | | window_name: &'a str, |
166 | | /// ID of the window. |
167 | | window: u32, |
168 | | /// List up windows with empty names in the UI drop-down selection. |
169 | | show_empty_names: bool, |
170 | | /// Left side cropping. |
171 | | left: f64, |
172 | | /// Top side cropping. |
173 | | top: f64, |
174 | | /// Right side cropping. |
175 | | right: f64, |
176 | | /// Bottom side cropping. |
177 | | bottom: f64, |
178 | | }, |
179 | | } |
180 | | |
181 | | impl<'a> Serialize for CropMode<'a> { |
182 | 0 | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> |
183 | 0 | where |
184 | 0 | S: Serializer, |
185 | 0 | { |
186 | 0 | match self { |
187 | 0 | Self::None => { |
188 | 0 | let mut s = serializer.serialize_struct("CropMode", 1)?; |
189 | 0 | s.serialize_field("crop_mode", &0u8)?; |
190 | 0 | s.end() |
191 | | } |
192 | 0 | Self::Manual { |
193 | 0 | left, |
194 | 0 | top, |
195 | 0 | right, |
196 | 0 | bottom, |
197 | 0 | } => { |
198 | 0 | let mut s = serializer.serialize_struct("CropMode", 5)?; |
199 | 0 | s.serialize_field("crop_mode", &1u8)?; |
200 | 0 | s.serialize_field("manual.origin.x", left)?; |
201 | 0 | s.serialize_field("manual.origin.y", top)?; |
202 | 0 | s.serialize_field("manual.size.width", right)?; |
203 | 0 | s.serialize_field("manual.size.height", bottom)?; |
204 | 0 | s.end() |
205 | | } |
206 | 0 | Self::ToWindow { |
207 | 0 | owner_name, |
208 | 0 | window_name, |
209 | 0 | window, |
210 | 0 | show_empty_names, |
211 | 0 | } => { |
212 | 0 | let mut s = serializer.serialize_struct("CropMode", 5)?; |
213 | 0 | s.serialize_field("crop_mode", &2u8)?; |
214 | 0 | s.serialize_field("owner_name", owner_name)?; |
215 | 0 | s.serialize_field("window_name", window_name)?; |
216 | 0 | s.serialize_field("window", window)?; |
217 | 0 | s.serialize_field("show_empty_names", show_empty_names)?; |
218 | 0 | s.end() |
219 | | } |
220 | | CropMode::ToWindowAndManual { |
221 | 0 | owner_name, |
222 | 0 | window_name, |
223 | 0 | window, |
224 | 0 | show_empty_names, |
225 | 0 | left, |
226 | 0 | top, |
227 | 0 | right, |
228 | 0 | bottom, |
229 | | } => { |
230 | 0 | let mut s = serializer.serialize_struct("CropMode", 9)?; |
231 | 0 | s.serialize_field("crop_mode", &3u8)?; |
232 | 0 | s.serialize_field("owner_name", owner_name)?; |
233 | 0 | s.serialize_field("window_name", window_name)?; |
234 | 0 | s.serialize_field("window", window)?; |
235 | 0 | s.serialize_field("show_empty_names", show_empty_names)?; |
236 | 0 | s.serialize_field("window.origin.x", left)?; |
237 | 0 | s.serialize_field("window.origin.y", top)?; |
238 | 0 | s.serialize_field("window.size.width", right)?; |
239 | 0 | s.serialize_field("window.size.height", bottom)?; |
240 | 0 | s.end() |
241 | | } |
242 | | } |
243 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::CropMode as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::CropMode as serde::ser::Serialize>::serialize::<_> |
244 | | } |
245 | | |
246 | | /// Settings specific to an image source. |
247 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::ImageSource as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::ImageSource as serde::ser::Serialize>::serialize::<_> |
248 | | pub struct ImageSource<'a> { |
249 | | /// Location of the file to display. |
250 | | pub file: &'a Path, |
251 | | /// Unload the image file when the source isn't visible. |
252 | | pub unload: bool, |
253 | | } |
254 | | |
255 | | impl<'a> Default for ImageSource<'a> { |
256 | 0 | fn default() -> Self { |
257 | 0 | Self { |
258 | 0 | file: Path::new(""), |
259 | 0 | unload: false, |
260 | 0 | } |
261 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::ImageSource as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::ImageSource as core::default::Default>::default |
262 | | } |
263 | | |
264 | | /// Settings specific to an image slide-show source. |
265 | 0 | #[derive(Serialize)] Unexecuted instantiation: <<obws::requests::custom::source_settings::Slideshow as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::Slideshow as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::Slideshow as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::Slideshow as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::Slideshow as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::Slideshow as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> |
266 | | pub struct Slideshow<'a> { |
267 | | /// Behavior of playback in relation to visibility. |
268 | | pub playback_behavior: PlaybackBehavior, |
269 | | /// Control mode to change between pictures. |
270 | | pub slide_mode: SlideMode, |
271 | | /// Swapping animation between current and next picture. |
272 | | pub transition: Transition, |
273 | | /// Time between Slides. Minimum value is `50ms`. |
274 | | #[serde(with = "crate::serde::duration_millis")] |
275 | | pub slide_time: Duration, |
276 | | /// Minimum value is `0ms`. |
277 | | #[serde(with = "crate::serde::duration_millis")] |
278 | | pub transition_speed: Duration, |
279 | | /// Whether to endlessly loop the slide-show images. |
280 | | #[serde(rename = "loop")] |
281 | | pub loop_: bool, |
282 | | /// Hide when slide-show is done. |
283 | | pub hide: bool, |
284 | | /// Randomize playback. |
285 | | pub randomize: bool, |
286 | | /// Bounding Size / Aspect Ratio. |
287 | | pub use_custom_size: CustomSize, |
288 | | /// Image files. |
289 | | pub files: &'a [SlideshowFile<'a>], |
290 | | } |
291 | | |
292 | | impl<'a> Default for Slideshow<'a> { |
293 | 0 | fn default() -> Self { |
294 | 0 | Self { |
295 | 0 | playback_behavior: PlaybackBehavior::AlwaysPlay, |
296 | 0 | slide_mode: SlideMode::default(), |
297 | 0 | transition: Transition::default(), |
298 | 0 | slide_time: Duration::seconds(8), |
299 | 0 | transition_speed: Duration::milliseconds(700), |
300 | 0 | loop_: true, |
301 | 0 | hide: false, |
302 | 0 | randomize: false, |
303 | 0 | use_custom_size: CustomSize::default(), |
304 | 0 | files: &[], |
305 | 0 | } |
306 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::Slideshow as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::Slideshow as core::default::Default>::default |
307 | | } |
308 | | |
309 | | /// Single file as part of a [`Slideshow`]. |
310 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::SlideshowFile as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::SlideshowFile as serde::ser::Serialize>::serialize::<_> |
311 | | pub struct SlideshowFile<'a> { |
312 | | /// Location of the file to display. |
313 | | pub value: &'a Path, |
314 | | /// Whether the file is currently visible in the source. |
315 | | pub hidden: bool, |
316 | | /// Whether the file is currently selected. |
317 | | pub selected: bool, |
318 | | } |
319 | | |
320 | | impl<'a> Default for SlideshowFile<'a> { |
321 | 0 | fn default() -> Self { |
322 | 0 | Self { |
323 | 0 | value: Path::new(""), |
324 | 0 | hidden: false, |
325 | 0 | selected: false, |
326 | 0 | } |
327 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::SlideshowFile as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::SlideshowFile as core::default::Default>::default |
328 | | } |
329 | | |
330 | | /// Playback behavior setting for use in [`Slideshow`]. |
331 | 0 | #[derive(Clone, Copy, Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::PlaybackBehavior as core::clone::Clone>::clone Unexecuted instantiation: <obws::requests::custom::source_settings::PlaybackBehavior as core::clone::Clone>::clone Unexecuted instantiation: <obws::requests::custom::source_settings::PlaybackBehavior as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::PlaybackBehavior as serde::ser::Serialize>::serialize::<_> |
332 | | #[serde(rename_all = "snake_case")] |
333 | | pub enum PlaybackBehavior { |
334 | | /// Always play even when not visible. |
335 | | AlwaysPlay, |
336 | | /// Stop when not visible, restart when visible. |
337 | | StopRestart, |
338 | | /// Pause when not visible, un-pause when visible |
339 | | PauseUnpause, |
340 | | } |
341 | | |
342 | | /// Playback control mode for use in [`Slideshow`]. |
343 | 0 | #[derive(Clone, Copy, Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::SlideMode as core::clone::Clone>::clone Unexecuted instantiation: <obws::requests::custom::source_settings::SlideMode as core::clone::Clone>::clone Unexecuted instantiation: <obws::requests::custom::source_settings::SlideMode as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::SlideMode as serde::ser::Serialize>::serialize::<_> |
344 | | #[serde(rename_all = "snake_case")] |
345 | | pub enum SlideMode { |
346 | | /// Automatic. |
347 | | ModeAuto, |
348 | | /// Manual (Use hotkeys to control slide-show). |
349 | | ModeManual, |
350 | | } |
351 | | |
352 | | impl Default for SlideMode { |
353 | 0 | fn default() -> Self { |
354 | 0 | Self::ModeAuto |
355 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::SlideMode as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::SlideMode as core::default::Default>::default |
356 | | } |
357 | | |
358 | | /// Transition animation between images in a [`Slideshow`]. |
359 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::Transition as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::Transition as serde::ser::Serialize>::serialize::<_> |
360 | | #[serde(rename_all = "snake_case")] |
361 | | pub enum Transition { |
362 | | /// Immediately replace without animation. |
363 | | Cut, |
364 | | /// Gradually fade between the two images until the new one is fully visible. |
365 | | Fade, |
366 | | /// Swipe the new image over the old one. |
367 | | Swipe, |
368 | | /// Slide out the old and slide in the new image. |
369 | | Slide, |
370 | | } |
371 | | |
372 | | impl Default for Transition { |
373 | 0 | fn default() -> Self { |
374 | 0 | Self::Fade |
375 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::Transition as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::Transition as core::default::Default>::default |
376 | | } |
377 | | |
378 | | /// Aspect ratios and bounding sizes for use in [`Slideshow`]. |
379 | 0 | #[derive(Clone, Copy, Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::CustomSize as core::clone::Clone>::clone Unexecuted instantiation: <obws::requests::custom::source_settings::CustomSize as core::clone::Clone>::clone Unexecuted instantiation: <obws::requests::custom::source_settings::CustomSize as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::CustomSize as serde::ser::Serialize>::serialize::<_> |
380 | | #[serde(into = "String")] |
381 | | pub enum CustomSize { |
382 | | /// Automatically detect a ratio based on the input. |
383 | | Automatic, |
384 | | /// 16:9 aspect ratio. |
385 | | SixteenToNine, |
386 | | /// 16:10 aspect ratio. |
387 | | SixteenToTen, |
388 | | /// 4:3 aspect ratio. |
389 | | FourToThree, |
390 | | /// 1:1 aspect ratio. |
391 | | OneToOne, |
392 | | /// Custom width:height ratio. |
393 | | CustomRatio(u32, u32), |
394 | | /// Custom width x height size. |
395 | | CustomSize(u32, u32), |
396 | | } |
397 | | |
398 | | impl Default for CustomSize { |
399 | 0 | fn default() -> Self { |
400 | 0 | Self::Automatic |
401 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::CustomSize as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::CustomSize as core::default::Default>::default |
402 | | } |
403 | | |
404 | | impl From<CustomSize> for String { |
405 | 0 | fn from(s: CustomSize) -> Self { |
406 | 0 | match s { |
407 | 0 | CustomSize::Automatic => "Automatic".to_owned(), |
408 | 0 | CustomSize::SixteenToNine => "16:9".to_owned(), |
409 | 0 | CustomSize::SixteenToTen => "16:10".to_owned(), |
410 | 0 | CustomSize::FourToThree => "4:3".to_owned(), |
411 | 0 | CustomSize::OneToOne => "1:1".to_owned(), |
412 | 0 | CustomSize::CustomRatio(w, h) => format!("{}:{}", w, h), |
413 | 0 | CustomSize::CustomSize(w, h) => format!("{}x{}", w, h), |
414 | | } |
415 | 0 | } Unexecuted instantiation: <alloc::string::String as core::convert::From<obws::requests::custom::source_settings::CustomSize>>::from Unexecuted instantiation: <alloc::string::String as core::convert::From<obws::requests::custom::source_settings::CustomSize>>::from |
416 | | } |
417 | | |
418 | | /// Settings specific to a **FFmpeg** video source. |
419 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::FfmpegSource as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::FfmpegSource as serde::ser::Serialize>::serialize::<_> |
420 | | pub struct FfmpegSource<'a> { |
421 | | /// Whether the source is a local file or remote. |
422 | | pub is_local_file: bool, |
423 | | /// Location of a local media file. Only used if [`Self::is_local_file`] is set to `true`. |
424 | | pub local_file: &'a Path, |
425 | | /// Endlessly play the media. Only used if [`Self::is_local_file`] is set to `true`. |
426 | | pub looping: bool, |
427 | | /// Network buffering in Megabytes. Only used if [`Self::is_local_file`] is set to `false`. |
428 | | pub buffering_mb: u8, |
429 | | /// URL of the remote media file. Only used if [`Self::is_local_file`] is set to `false`. |
430 | | pub input: &'a str, |
431 | | /// Format of the remote media. Only used if [`Self::is_local_file`] is set to `false`. |
432 | | pub input_format: &'a str, |
433 | | /// Reconnect delay in seconds. Only used if [`Self::is_local_file`] is set to `false`. |
434 | | pub reconnect_delay_sec: u8, |
435 | | /// Restart playback when source becomes active. Only used if [`Self::is_local_file`] is set to |
436 | | /// `true`. |
437 | | pub restart_on_activate: bool, |
438 | | /// Show nothing when playback ends. |
439 | | pub clear_on_media_end: bool, |
440 | | /// Close file when inactive. |
441 | | pub close_when_inactive: bool, |
442 | | /// Playback speed as percentage. Only used if [`Self::is_local_file`] is set to `true`. |
443 | | pub speed_percent: u8, |
444 | | /// YUV color range. |
445 | | pub color_range: ColorRange, |
446 | | /// Whether the media source is seek-able. Only used if [`Self::is_local_file`] is set to |
447 | | /// `false`. |
448 | | pub seekable: bool, |
449 | | } |
450 | | |
451 | | /// YUV color range of a [`FfmpegSource`]. |
452 | 0 | #[derive(Serialize_repr)] Unexecuted instantiation: <obws::requests::custom::source_settings::ColorRange as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::ColorRange as serde::ser::Serialize>::serialize::<_> |
453 | | #[repr(u8)] |
454 | | pub enum ColorRange { |
455 | | /// Automatic detection. |
456 | | Auto = 0, |
457 | | /// Partial color range. |
458 | | Partial = 1, |
459 | | /// Full color range. |
460 | | Full = 2, |
461 | | } |
462 | | |
463 | | impl Default for ColorRange { |
464 | 0 | fn default() -> Self { |
465 | 0 | Self::Auto |
466 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::ColorRange as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::ColorRange as core::default::Default>::default |
467 | | } |
468 | | |
469 | | /// Settings specific to a **FreeType2** text source. |
470 | 0 | #[derive(Serialize)] Unexecuted instantiation: <<obws::requests::custom::source_settings::TextFt2SourceV2 as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::TextFt2SourceV2 as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::TextFt2SourceV2 as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::TextFt2SourceV2 as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::TextFt2SourceV2 as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::TextFt2SourceV2 as serde::ser::Serialize>::serialize::<_> |
471 | | pub struct TextFt2SourceV2<'a> { |
472 | | /// Draw the text with smoothed corners. |
473 | | pub antialiasing: bool, |
474 | | /// Top color of the text. |
475 | | #[serde(with = "crate::serde::rgba8_inverse")] |
476 | | pub color1: RGBA8, |
477 | | /// Bottom color of the text. |
478 | | #[serde(with = "crate::serde::rgba8_inverse")] |
479 | | pub color2: RGBA8, |
480 | | /// Custom width (seems to have no effect). |
481 | | pub custom_width: u32, |
482 | | /// Draw a dark blurred shadow effect behind the text. |
483 | | pub drop_shadow: bool, |
484 | | /// Settings for the font. |
485 | | pub font: Font<'a>, |
486 | | /// Load the text from a file (must be set in combination with [`Self::text_file`]). |
487 | | pub from_file: bool, |
488 | | /// Amount of log lines if [`Self::log_mode`] is `true`. Minimum value is `1`. |
489 | | pub log_lines: u32, |
490 | | /// Log mode (not sure what this does). |
491 | | pub log_mode: bool, |
492 | | /// Draw a black border around the text corners. |
493 | | pub outline: bool, |
494 | | /// Text to display (only used if [`Self::from_file`] is `false`). |
495 | | pub text: &'a str, |
496 | | /// File to load the display text from ([`Self::from_file`] must be `true`). The |
497 | | /// content must be in either **UTF-8** or **UTF-16** encoding. |
498 | | pub text_file: &'a Path, |
499 | | /// Wrap the words within the boundaries of the scene item. |
500 | | pub word_wrap: bool, |
501 | | } |
502 | | |
503 | | impl<'a> Default for TextFt2SourceV2<'a> { |
504 | 0 | fn default() -> Self { |
505 | 0 | Self { |
506 | 0 | antialiasing: true, |
507 | 0 | color1: RGBA8::new(255, 255, 255, 255), |
508 | 0 | color2: RGBA8::new(255, 255, 255, 255), |
509 | 0 | custom_width: 0, |
510 | 0 | drop_shadow: false, |
511 | 0 | font: Font::default(), |
512 | 0 | from_file: false, |
513 | 0 | log_lines: 6, |
514 | 0 | log_mode: false, |
515 | 0 | outline: false, |
516 | 0 | text: "", |
517 | 0 | text_file: Path::new(""), |
518 | 0 | word_wrap: false, |
519 | 0 | } |
520 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::TextFt2SourceV2 as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::TextFt2SourceV2 as core::default::Default>::default |
521 | | } |
522 | | |
523 | | /// Font settings for a [`TextFt2SourceV2`]. |
524 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::Font as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::Font as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::Font as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::Font as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> |
525 | | pub struct Font<'a> { |
526 | | /// Font face. |
527 | | pub face: &'a str, |
528 | | /// Flags for different display styles. |
529 | | #[serde(with = "crate::serde::bitflags_u8")] |
530 | | pub flags: FontFlags, |
531 | | /// Display size. |
532 | | pub size: u32, |
533 | | /// Specific font style. Must eventually be set together with [`Self::flags`]. |
534 | | /// |
535 | | /// For example: |
536 | | /// - [`FontFlags::BOLD`] and style `"Bold"`. |
537 | | /// - [`FontFlags::ITALIC`] and style `"Italic"`. |
538 | | pub style: &'a str, |
539 | | } |
540 | | |
541 | | impl<'a> Default for Font<'a> { |
542 | 0 | fn default() -> Self { |
543 | 0 | Self { |
544 | 0 | face: "Helvetica", |
545 | 0 | flags: FontFlags::empty(), |
546 | 0 | size: 256, |
547 | 0 | style: "Regular", |
548 | 0 | } |
549 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::Font as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::Font as core::default::Default>::default |
550 | | } |
551 | | |
552 | | /// Settings specific to a **VLC** video source. |
553 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::VlcSource as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::VlcSource as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::VlcSource as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::VlcSource as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> |
554 | | pub struct VlcSource<'a> { |
555 | | /// Loop play-list. |
556 | | #[serde(rename = "bool")] |
557 | | pub loop_: bool, |
558 | | /// Shuffle play-list. |
559 | | pub shuffle: bool, |
560 | | /// Visibility behavior. |
561 | | pub playback_behavior: PlaybackBehavior, |
562 | | /// List of files to play. |
563 | | pub playlist: &'a [SlideshowFile<'a>], |
564 | | /// Network caching time. Minimum value is `100ms`. |
565 | | #[serde(with = "crate::serde::duration_millis")] |
566 | | pub network_caching: Duration, |
567 | | /// Audio track. Minimum value is `1`. |
568 | | pub track: u32, |
569 | | /// Subtitles enabled. |
570 | | pub subtitle_enable: bool, |
571 | | /// Subtitle track. Minimum value is `1`. |
572 | | pub subtitle: u32, |
573 | | } |
574 | | |
575 | | impl<'a> Default for VlcSource<'a> { |
576 | 0 | fn default() -> Self { |
577 | 0 | Self { |
578 | 0 | loop_: true, |
579 | 0 | shuffle: false, |
580 | 0 | playback_behavior: PlaybackBehavior::StopRestart, |
581 | 0 | playlist: &[], |
582 | 0 | network_caching: Duration::milliseconds(400), |
583 | 0 | track: 1, |
584 | 0 | subtitle_enable: false, |
585 | 0 | subtitle: 1, |
586 | 0 | } |
587 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::VlcSource as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::VlcSource as core::default::Default>::default |
588 | | } |
589 | | |
590 | | /// Settings specific to an audio/video input capture source. |
591 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::AvCaptureInputV2 as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::AvCaptureInputV2 as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <<obws::requests::custom::source_settings::AvCaptureInputV2 as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::AvCaptureInputV2 as serde::ser::Serialize>::serialize::<_> |
592 | | pub struct AvCaptureInputV2<'a> { |
593 | | /// Whether to use buffering. |
594 | | pub buffering: bool, |
595 | | /// Specific color space of the video. Only used if [`Self::use_preset`] is |
596 | | /// `false`). |
597 | | pub color_space: ColorSpace, |
598 | | /// Device identifier. |
599 | | pub device: &'a str, |
600 | | /// Name of the capture device. |
601 | | pub device_name: &'a str, |
602 | | /// Frame rate of the capture. Only used if [`Self::use_preset`] is `false`). |
603 | | pub frame_rate: FrameRate, |
604 | | /// Encoded input format. Only used if [`Self::use_preset`] is `false`). |
605 | | pub input_format: u32, |
606 | | /// Pre-configured setting. Only used if [`Self::use_preset`] is `true`). |
607 | | pub preset: AvPreset, |
608 | | /// Video resolution. Only used if [`Self::use_preset`] is `false`). |
609 | | #[serde(with = "crate::serde::json_string")] |
610 | | pub resolution: Resolution, |
611 | | /// Whether to use a setting preset. |
612 | | pub use_preset: bool, |
613 | | /// Video color range. Only used if [`Self::use_preset`] is `false`). |
614 | | pub video_range: VideoRange, |
615 | | } |
616 | | |
617 | | /// Color space as part of an [`AvCaptureInputV2`]. |
618 | 0 | #[derive(Serialize_repr)] Unexecuted instantiation: <obws::requests::custom::source_settings::ColorSpace as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::ColorSpace as serde::ser::Serialize>::serialize::<_> |
619 | | #[repr(i8)] |
620 | | pub enum ColorSpace { |
621 | | /// Automatic detection. |
622 | | Auto = -1, |
623 | | /// Rec. 601 color space. |
624 | | Rec601 = 1, |
625 | | /// Rec. 709 color space. |
626 | | Rec709 = 2, |
627 | | } |
628 | | |
629 | | impl Default for ColorSpace { |
630 | 0 | fn default() -> Self { |
631 | 0 | Self::Auto |
632 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::ColorSpace as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::ColorSpace as core::default::Default>::default |
633 | | } |
634 | | |
635 | | /// Video color range as part of an [`AvCaptureInputV2`]. |
636 | 0 | #[derive(Serialize_repr)] Unexecuted instantiation: <obws::requests::custom::source_settings::VideoRange as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::VideoRange as serde::ser::Serialize>::serialize::<_> |
637 | | #[repr(i8)] |
638 | | pub enum VideoRange { |
639 | | /// Automatic detection. |
640 | | Auto = -1, |
641 | | /// Partial color range. |
642 | | Partial = 1, |
643 | | /// Full color range. |
644 | | Full = 2, |
645 | | } |
646 | | |
647 | | impl Default for VideoRange { |
648 | 0 | fn default() -> Self { |
649 | 0 | Self::Auto |
650 | 0 | } Unexecuted instantiation: <obws::requests::custom::source_settings::VideoRange as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::VideoRange as core::default::Default>::default |
651 | | } |
652 | | |
653 | | /// Different presets for the [`AvCaptureInputV2`]. |
654 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::AvPreset as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::AvPreset as serde::ser::Serialize>::serialize::<_> |
655 | | pub enum AvPreset { |
656 | | /// Preset for resolution _3840x2160_ (may not be available). |
657 | | #[serde(rename = "AVCaptureSessionPreset3840x2160")] |
658 | | Res3840x2160, |
659 | | /// Preset for resolution _1920x1080_ (may not be available). |
660 | | #[serde(rename = "AVCaptureSessionPreset1920x1080")] |
661 | | Res1920x1080, |
662 | | /// Preset for resolution _1280x720_. |
663 | | #[serde(rename = "AVCaptureSessionPreset1280x720")] |
664 | | Res1280x720, |
665 | | /// Preset for resolution _960x540_. |
666 | | #[serde(rename = "AVCaptureSessionPreset960x540")] |
667 | | Res960x540, |
668 | | /// Preset for resolution _640x480_. |
669 | | #[serde(rename = "AVCaptureSessionPreset640x480")] |
670 | | Res640x480, |
671 | | /// Preset for resolution _352x288_. |
672 | | #[serde(rename = "AVCaptureSessionPreset352x288")] |
673 | | Res352x288, |
674 | | /// Preset for resolution _320x240_. |
675 | | #[serde(rename = "AVCaptureSessionPreset320x240")] |
676 | | Res320x240, |
677 | | /// Preset for high quality. |
678 | | #[serde(rename = "AVCaptureSessionPresetHigh")] |
679 | | High, |
680 | | /// Preset for medium quality (may not be available). |
681 | | #[serde(rename = "AVCaptureSessionPresetMedium")] |
682 | | Medium, |
683 | | /// Preset for low quality (may not be available). |
684 | | #[serde(rename = "AVCaptureSessionPresetLow")] |
685 | | Low, |
686 | | } |
687 | | |
688 | | /// Video frame rate of an [`AvCaptureInputV2`]. |
689 | | /// |
690 | | /// The value is split into numerator and denominator as integer values instead of a floating point |
691 | | /// value. To calculate the frame rate as FPS divide the `numerator` by the `denominator`. |
692 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::FrameRate as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::FrameRate as serde::ser::Serialize>::serialize::<_> |
693 | | pub struct FrameRate { |
694 | | /// The numerator to form the frame rate. |
695 | | pub numerator: u64, |
696 | | /// Denominator to form the frame rate. |
697 | | pub denominator: u64, |
698 | | } |
699 | | |
700 | | /// Video resolution for an [`AvCaptureInputV2`]. |
701 | 0 | #[derive(Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::Resolution as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::Resolution as serde::ser::Serialize>::serialize::<_> |
702 | | pub struct Resolution { |
703 | | /// Video width. |
704 | | pub width: u32, |
705 | | /// Video height. |
706 | | pub height: u32, |
707 | | } |
708 | | |
709 | | /// Settings specific to a window capture source. |
710 | 0 | #[derive(Default, Serialize)] Unexecuted instantiation: <obws::requests::custom::source_settings::WindowCapture as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::WindowCapture as core::default::Default>::default Unexecuted instantiation: <obws::requests::custom::source_settings::WindowCapture as serde::ser::Serialize>::serialize::<_> Unexecuted instantiation: <obws::requests::custom::source_settings::WindowCapture as serde::ser::Serialize>::serialize::<_> |
711 | | pub struct WindowCapture<'a> { |
712 | | /// Name of the owning process. |
713 | | pub owner_name: &'a str, |
714 | | /// Name of the window, usually seen in the title bar of the window frame. |
715 | | pub window_name: &'a str, |
716 | | /// Unique ID of the window. |
717 | | pub window: u16, |
718 | | /// Show windows with empty names. |
719 | | pub show_empty_names: bool, |
720 | | /// Show window shadow. |
721 | | pub show_shadow: bool, |
722 | | } |