Coverage Report

Created: 2022-07-04 16:17

src/requests/custom/transitions.rs
Line
Count
Source (jump to first uncovered line)
1
//! Additional structs for use with [`crate::client::Inputs::set_settings`].
2
3
use std::path::Path;
4
5
use rgb::RGBA8;
6
use serde::Serialize;
7
use serde_repr::Serialize_repr;
8
9
/// Identifier for swipe transitions.
10
pub const TYPE_SWIPE: &str = "swipe_transition";
11
/// Identifier for slide transitions.
12
pub const TYPE_SLIDE: &str = "slide_transition";
13
/// Identifier for stinger transitions.
14
pub const TYPE_STINGER: &str = "obs_stinger_transition";
15
/// Identifier for fade to color transitions.
16
pub const TYPE_FADE_TO_COLOR: &str = "fade_to_color_transition";
17
/// Identifier for luma wipe transitions.
18
pub const TYPE_WIPE: &str = "wipe_transition";
19
20
/// Options for a swipe transition. A swipe describes one scene hovering over another and making
21
/// the other scene visible by moving in/out of the scene.
22
0
#[derive(Debug, Default, Serialize)]
Unexecuted instantiation: <obws::requests::custom::transitions::Swipe as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::Swipe as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::Swipe as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::Swipe as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::Swipe as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::Swipe as serde::ser::Serialize>::serialize::<_>
23
pub struct Swipe {
24
    /// Direction of the swipe.
25
    pub direction: Direction,
26
    /// Let the new scene swipe into the screen over the current scene. Otherwise the current scene
27
    /// swipes out with the new scene behind it becoming visible.
28
    pub swipe_in: bool,
29
}
30
31
/// Options for a slide transition. A slide describes two scene directly next to each other making
32
/// one visible by "pushing" the other one away.
33
0
#[derive(Debug, Default, Serialize)]
Unexecuted instantiation: <obws::requests::custom::transitions::Slide as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::Slide as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::Slide as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::Slide as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::Slide as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::Slide as serde::ser::Serialize>::serialize::<_>
34
pub struct Slide {
35
    /// Direction of the slide.
36
    pub direction: Direction,
37
}
38
39
/// The direction for a [`Swipe`] or [`Slide].
40
0
#[derive(Clone, Copy, Debug, Serialize)]
Unexecuted instantiation: <obws::requests::custom::transitions::Direction as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::custom::transitions::Direction as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::custom::transitions::Direction as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::Direction as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::Direction as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::Direction as serde::ser::Serialize>::serialize::<_>
41
#[serde(rename_all = "lowercase")]
42
pub enum Direction {
43
    /// From/to the left.
44
    Left,
45
    /// From/to the right.
46
    Right,
47
    /// From/to the top.
48
    Up,
49
    /// From/to the bottom.
50
    Down,
51
}
52
53
impl Default for Direction {
54
0
    fn default() -> Self {
55
0
        Self::Left
56
0
    }
Unexecuted instantiation: <obws::requests::custom::transitions::Direction as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::Direction as core::default::Default>::default
57
}
58
59
/// Options for a stinger transition. A stinger describes a video being used to hide the old scene
60
/// completely, then switch the scene while only the video is visible. Afterwards the video moves
61
/// out of the view again to make the new scene visible.
62
0
#[derive(Serialize)]
Unexecuted instantiation: <obws::requests::custom::transitions::Stinger as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::Stinger as serde::ser::Serialize>::serialize::<_>
63
pub struct Stinger<'a> {
64
    /// Location of the video file.
65
    pub path: &'a Path,
66
    /// The type of value that [`Self::transition_point`] stands for.
67
    pub tp_type: TransitionPointType,
68
    /// Point at which the scene transition triggers. What unit of this value depends on the set
69
    /// [`Self::tp_type`].
70
    pub transition_point: u32,
71
    /// The kind of audio monitoring to apply. This means whether to send the audio to the output
72
    /// stream, only play it locally or do it both.
73
    pub audio_monitoring: AudioMonitoring,
74
    /// The way audio is gradually swapped between two scenes.
75
    pub audio_fade_style: AudioFadeStyle,
76
}
77
78
/// Different units that are used together with a value to define scene switching point of a video
79
/// transition.
80
0
#[derive(Clone, Copy, Debug, Serialize_repr)]
Unexecuted instantiation: <obws::requests::custom::transitions::TransitionPointType as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::custom::transitions::TransitionPointType as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::custom::transitions::TransitionPointType as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::TransitionPointType as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::TransitionPointType as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::TransitionPointType as serde::ser::Serialize>::serialize::<_>
81
#[repr(u8)]
82
pub enum TransitionPointType {
83
    /// Time in milliseconds.
84
    Time = 0,
85
    /// Frames (single images) of the video.
86
    Frame = 1,
87
}
88
89
impl Default for TransitionPointType {
90
0
    fn default() -> Self {
91
0
        Self::Time
92
0
    }
Unexecuted instantiation: <obws::requests::custom::transitions::TransitionPointType as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::TransitionPointType as core::default::Default>::default
93
}
94
95
/// Setting for the audio monitoring which defines whether audio is send to the stream, played
96
/// locally or both at the same time.
97
0
#[derive(Clone, Copy, Debug, Serialize_repr)]
Unexecuted instantiation: <obws::requests::custom::transitions::AudioMonitoring as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::custom::transitions::AudioMonitoring as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::custom::transitions::AudioMonitoring as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::AudioMonitoring as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::AudioMonitoring as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::AudioMonitoring as serde::ser::Serialize>::serialize::<_>
98
#[repr(u8)]
99
pub enum AudioMonitoring {
100
    /// No monitoring, means to insert the audio into the output stream but not playing it on the
101
    /// local machine.
102
    MonitorOff = 0,
103
    /// The opposite of [`Self::MonitorOff`], playing the audio locally but not sending it to
104
    /// the stream.
105
    MonitorOnly = 1,
106
    /// A combination of the other options where audio is send to the stream as well as played
107
    /// locally.
108
    MonitorAndOutput = 2,
109
}
110
111
impl Default for AudioMonitoring {
112
0
    fn default() -> Self {
113
0
        Self::MonitorOff
114
0
    }
Unexecuted instantiation: <obws::requests::custom::transitions::AudioMonitoring as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::AudioMonitoring as core::default::Default>::default
115
}
116
117
/// Describes the way in which the audio is faded between two scenes with a [`Stinger`] transition.
118
0
#[derive(Clone, Copy, Debug, Serialize_repr)]
Unexecuted instantiation: <obws::requests::custom::transitions::AudioFadeStyle as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::custom::transitions::AudioFadeStyle as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::custom::transitions::AudioFadeStyle as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::AudioFadeStyle as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::requests::custom::transitions::AudioFadeStyle as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::AudioFadeStyle as serde::ser::Serialize>::serialize::<_>
119
#[repr(u8)]
120
pub enum AudioFadeStyle {
121
    /// Fade out to transition point then fade in.
122
    FadeOutFadeIn = 0,
123
    /// Fade out the audio from the old scene and fade in the new scene's audio at the same time,
124
    /// creating a slight overlap.
125
    Crossfade = 1,
126
}
127
128
impl Default for AudioFadeStyle {
129
0
    fn default() -> Self {
130
0
        Self::FadeOutFadeIn
131
0
    }
Unexecuted instantiation: <obws::requests::custom::transitions::AudioFadeStyle as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::AudioFadeStyle as core::default::Default>::default
132
}
133
134
/// Options for a fade to color transition. A color fading describes one scene being blended with
135
/// a given color until only the color is visible and then blend from the color to the new scene
136
/// until the color is fully gone.
137
0
#[derive(Serialize)]
Unexecuted instantiation: <obws::requests::custom::transitions::FadeToColor as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::custom::transitions::FadeToColor as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::FadeToColor as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::custom::transitions::FadeToColor as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_>
138
pub struct FadeToColor {
139
    /// Color to blend in/out.
140
    #[serde(with = "crate::serde::rgba8_inverse")]
141
    pub color: RGBA8,
142
    /// The point at which the scenes are swapped. Maximum value is `100`.
143
    pub switch_point: u8,
144
}
145
146
/// Options for a luma wipe transition. A luma wipe describes one scene being gradually displayed
147
/// over the other, where the luma image defines a certain animation to do so.
148
0
#[derive(Serialize)]
Unexecuted instantiation: <obws::requests::custom::transitions::Wipe as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::Wipe as serde::ser::Serialize>::serialize::<_>
149
pub struct Wipe {
150
    /// The image to use. This describes the animation that is used.
151
    pub luma_image: LumaImage,
152
    /// Invert the animation.
153
    pub luma_invert: bool,
154
    /// Softness of the edges inside the animation where old and new scene "touch".
155
    pub luma_softness: f64,
156
}
157
158
/// A luma image that defines the animation of a [`Wipe`].
159
0
#[derive(Serialize)]
Unexecuted instantiation: <obws::requests::custom::transitions::LumaImage as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::custom::transitions::LumaImage as serde::ser::Serialize>::serialize::<_>
160
pub enum LumaImage {
161
    /// Barn door animation diagonal from the bottom left.
162
    #[serde(rename = "barndoor-botleft.png")]
163
    BarndoorBottomLeft,
164
    /// Horizontal barn door animation.
165
    #[serde(rename = "barndoor-h.png")]
166
    BarndoorHorizontal,
167
    /// Barn door animation diagonal from the top left.
168
    #[serde(rename = "barndoor-topleft.png")]
169
    BarndoorTopLeft,
170
    /// Vertical barn door animation.
171
    #[serde(rename = "barndoor-v.png")]
172
    BarndoorVertical,
173
    #[serde(rename = "blinds-h.png")]
174
    /// Horizontal blinds animation.
175
    BlindsHorizontal,
176
    /// Box animation from the bottom left.
177
    #[serde(rename = "box-botleft.png")]
178
    BoxBottomLeft,
179
    /// Box animation from the bottom right.
180
    #[serde(rename = "box-botright.png")]
181
    BoxBottomRight,
182
    /// Box animation from the top left.
183
    #[serde(rename = "box-topleft.png")]
184
    BoxTopLeft,
185
    /// Box animation from the top right.
186
    #[serde(rename = "box-topright.png")]
187
    BoxTopRight,
188
    /// Burst animation.
189
    #[serde(rename = "burst.png")]
190
    Burst,
191
    /// Small checkerboard animation.
192
    #[serde(rename = "checkerboard-small.png")]
193
    CheckerboardSmall,
194
    /// Circles animation.
195
    #[serde(rename = "circles.png")]
196
    Circles,
197
    /// Clock sweep animation.
198
    #[serde(rename = "clock.png")]
199
    Clock,
200
    /// Cloud animation.
201
    #[serde(rename = "cloud.png")]
202
    Cloud,
203
    /// Curtain animation.
204
    #[serde(rename = "curtain.png")]
205
    Curtain,
206
    /// Fan animation.
207
    #[serde(rename = "fan.png")]
208
    Fan,
209
    /// Fractal animation.
210
    #[serde(rename = "fractal.png")]
211
    Fractal,
212
    /// Iris animation.
213
    #[serde(rename = "iris.png")]
214
    Iris,
215
    /// Horizontal linear animation.
216
    #[serde(rename = "linear-h.png")]
217
    LinearHorizontal,
218
    /// Linear animation from the top left.
219
    #[serde(rename = "linear-topleft.png")]
220
    LinearTopLeft,
221
    /// Linear animation from the top right.
222
    #[serde(rename = "linear-topright.png")]
223
    LinearTopRight,
224
    /// Vertical liner animation.
225
    #[serde(rename = "linear-v.png")]
226
    LinearVertical,
227
    /// Horizontal parallel zig-zag animation.
228
    #[serde(rename = "parallel-zigzag-h.png")]
229
    ParallelZigzagHorizontal,
230
    /// Vertical parallel zig-zag animation.
231
    #[serde(rename = "parallel-zigzag-v.png")]
232
    ParallelZigzagVertical,
233
    /// Sinus9 animation.
234
    #[serde(rename = "sinus9.png")]
235
    Sinus9,
236
    /// Spiral animation.
237
    #[serde(rename = "spiral.png")]
238
    Spiral,
239
    /// Square animation.
240
    #[serde(rename = "square.png")]
241
    Square,
242
    /// Squares animation.
243
    #[serde(rename = "squares.png")]
244
    Squares,
245
    /// Stripes animation.
246
    #[serde(rename = "stripes.png")]
247
    Stripes,
248
    /// Horizontal strips animation.
249
    #[serde(rename = "strips-h.png")]
250
    StripsHorizontal,
251
    /// Vertical strips animation.
252
    #[serde(rename = "strips-v.png")]
253
    StripsVertical,
254
    /// Watercolor animation.
255
    #[serde(rename = "watercolor.png")]
256
    Watercolor,
257
    /// Horizontal zig-zag animation.
258
    #[serde(rename = "zigzag-h.png")]
259
    ZigzagHorizontal,
260
    /// Vertical zig-zag animation.
261
    #[serde(rename = "zigzag-v.png")]
262
    ZigzagVertical,
263
}
264
265
impl Default for LumaImage {
266
0
    fn default() -> Self {
267
0
        Self::LinearHorizontal
268
0
    }
Unexecuted instantiation: <obws::requests::custom::transitions::LumaImage as core::default::Default>::default
Unexecuted instantiation: <obws::requests::custom::transitions::LumaImage as core::default::Default>::default
269
}