| 1 | use std::sync::Arc; |
| 2 | use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; |
| 3 | use std::time::{Instant, SystemTime, UNIX_EPOCH}; |
| 4 | |
| 5 | use libwebrtc::media_stream_track::MediaStreamTrack; |
| 6 | use libwebrtc::peer_connection_factory::PeerConnectionFactory; |
| 7 | use libwebrtc::rtp_parameters::DegradationPreference; |
| 8 | use libwebrtc::rtp_sender::RtpSender; |
| 9 | use libwebrtc::rtp_transceiver::{RtpTransceiver, RtpTransceiverDirection}; |
| 10 | use libwebrtc::peer_connection_factory::native::PeerConnectionFactoryExt; |
| 11 | use libwebrtc::video_frame::{I420Buffer, VideoBuffer as _, VideoFrame, VideoRotation}; |
| 12 | use libwebrtc::video_source::VideoResolution; |
| 13 | use libwebrtc::video_source::native::NativeVideoSource; |
| 14 | use libwebrtc::video_track::RtcVideoTrack; |
| 15 | use tokio::sync::mpsc::UnboundedSender; |
| 16 | |
| 17 | use crate::background::BackgroundPicture; |
| 18 | use crate::blur::BlurSettings; |
| 19 | use crate::effects::CameraEffects; |
| 20 | use crate::camera::start_camera; |
| 21 | use crate::capture::Capture; |
| 22 | use crate::control::CallUpdate; |
| 23 | use crate::devices::DeviceChoice; |
| 24 | use crate::error::{Error, Result}; |
| 25 | use crate::screen::{ShareSource, start_screen_capture}; |
| 26 | use crate::send_control::{EncoderLimits, KEYFRAME_NUDGE, LayerPlan, SendLimit, encoder_limits, plan_layers}; |
| 27 | use crate::standout::StandoutOverlay; |
| 28 | use crate::video_frame::{FrameGate, PERSON_FPS, SCREEN_FPS, VideoHub, VideoKey, picture_from_i420}; |
| 29 | use crate::video_layout::VideoLines; |
| 30 | use crate::video_pattern::{PatternKind, spawn_pattern}; |
| 31 | |
| 32 | pub const VIDEO_MODE_ENV: &str = "CALLING_VIDEO"; |
| 33 | const CAMERA_LABEL: &str = "camera"; |
| 34 | const SCREEN_LABEL: &str = "screen"; |
| 35 | pub const SCREEN_SHARE_FPS: u32 = 15; |
| 36 | pub const MOTION_SHARE_FPS: u32 = 30; |
| 37 | |
| 38 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] |
| 39 | pub enum VideoMode { |
| 40 | #[default] |
| 41 | Platform, |
| 42 | Pattern, |
| 43 | Off, |
| 44 | } |
| 45 | |
| 46 | impl VideoMode { |
| 47 | pub fn from_env() -> Self { |
| 48 | Self::parse(std::env::var(VIDEO_MODE_ENV).ok().as_deref()) |
| 49 | } |
| 50 | |
| 51 | pub fn parse(value: Option<&str>) -> Self { |
| 52 | match value.map(str::to_ascii_lowercase).as_deref() { |
| 53 | Some("pattern") => VideoMode::Pattern, |
| 54 | Some("off") => VideoMode::Off, |
| 55 | _ => VideoMode::Platform, |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | /// Where a captured frame goes: the encoder source and, for the self view, the UI hub. |
| 61 | pub struct LocalSink { |
| 62 | source: NativeVideoSource, |
| 63 | self_view: Option<(Arc<VideoHub>, VideoKey, FrameGate)>, |
| 64 | mirror: Option<Arc<BlurSettings>>, |
| 65 | standout: Option<StandoutOverlay>, |
| 66 | frame_size: Option<Arc<AtomicU64>>, |
| 67 | } |
| 68 | |
| 69 | impl LocalSink { |
| 70 | pub fn new(source: NativeVideoSource, hub: Option<(Arc<VideoHub>, VideoKey)>) -> Self { |
| 71 | let self_view = hub.map(|(hub, key)| { |
| 72 | let fps = if matches!(key, VideoKey::LocalScreen) { SCREEN_FPS } else { PERSON_FPS }; |
| 73 | (hub, key, FrameGate::new(fps)) |
| 74 | }); |
| 75 | LocalSink { source, self_view, mirror: None, standout: None, frame_size: None } |
| 76 | } |
| 77 | |
| 78 | pub fn reporting_size(mut self, frame_size: Arc<AtomicU64>) -> Self { |
| 79 | self.frame_size = Some(frame_size); |
| 80 | self |
| 81 | } |
| 82 | |
| 83 | pub fn mirrored_by(mut self, settings: Arc<BlurSettings>) -> Self { |
| 84 | self.mirror = Some(settings); |
| 85 | self |
| 86 | } |
| 87 | |
| 88 | pub fn with_standout(mut self, settings: Arc<BlurSettings>) -> Self { |
| 89 | self.standout = Some(StandoutOverlay::new(settings)); |
| 90 | self |
| 91 | } |
| 92 | |
| 93 | pub fn push(&mut self, buffer: I420Buffer) { |
| 94 | let buffer = match &mut self.standout { |
| 95 | Some(overlay) => overlay.apply(buffer), |
| 96 | None => buffer, |
| 97 | }; |
| 98 | if let Some(frame_size) = &self.frame_size { |
| 99 | frame_size.store(pack_size(buffer.width(), buffer.height()), Ordering::Relaxed); |
| 100 | } |
| 101 | let mut frame = VideoFrame::new(VideoRotation::VideoRotation0, buffer); |
| 102 | frame.timestamp_us = SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, |elapsed| elapsed.as_micros() as i64); |
| 103 | self.source.capture_frame(&frame); |
| 104 | let Some((hub, key, gate)) = &mut self.self_view else { return }; |
| 105 | if gate.admit(Instant::now()) |
| 106 | && let Some(mut picture) = picture_from_i420(frame.buffer, key.max_width()) |
| 107 | { |
| 108 | if self.mirror.as_ref().is_some_and(|settings| settings.effects().mirror) { |
| 109 | picture.flip_horizontally(); |
| 110 | } |
| 111 | hub.publish(key.clone(), picture); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | fn pack_size(width: u32, height: u32) -> u64 { |
| 117 | (u64::from(width) << 32) | u64::from(height) |
| 118 | } |
| 119 | |
| 120 | fn unpack_size(packed: u64) -> Option<(u32, u32)> { |
| 121 | let (width, height) = ((packed >> 32) as u32, packed as u32); |
| 122 | (width > 0 && height > 0).then_some((width, height)) |
| 123 | } |
| 124 | |
| 125 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 126 | pub enum SendSource { |
| 127 | Camera, |
| 128 | Screen, |
| 129 | } |
| 130 | |
| 131 | struct Outgoing { |
| 132 | source: NativeVideoSource, |
| 133 | track: RtcVideoTrack, |
| 134 | capture: Option<Capture>, |
| 135 | frame_size: Arc<AtomicU64>, |
| 136 | requested: Option<RequestedLimits>, |
| 137 | } |
| 138 | |
| 139 | struct RequestedLimits { |
| 140 | limits: Vec<SendLimit>, |
| 141 | applied_for: Option<(u32, u32)>, |
| 142 | } |
| 143 | |
| 144 | impl Outgoing { |
| 145 | fn new(factory: &PeerConnectionFactory, label: &str, kind: PatternKind, screencast: bool) -> Self { |
| 146 | let (width, height) = kind.size(); |
| 147 | let source = NativeVideoSource::new(VideoResolution { width, height }, screencast); |
| 148 | let track = factory.create_video_track(label, source.clone()); |
| 149 | Outgoing { source, track, capture: None, frame_size: Arc::new(AtomicU64::new(0)), requested: None } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /// Camera and screen share of the local user; frames come from devices or a generated pattern. |
| 154 | pub struct LocalVideo { |
| 155 | mode: VideoMode, |
| 156 | hub: Arc<VideoHub>, |
| 157 | updates: UnboundedSender<CallUpdate>, |
| 158 | camera: Outgoing, |
| 159 | screen: Outgoing, |
| 160 | lines: Option<VideoLines>, |
| 161 | blur: Arc<BlurSettings>, |
| 162 | motion: bool, |
| 163 | share_fps: Arc<AtomicU32>, |
| 164 | } |
| 165 | |
| 166 | impl LocalVideo { |
| 167 | pub fn new(factory: &PeerConnectionFactory, mode: VideoMode, hub: Arc<VideoHub>, updates: UnboundedSender<CallUpdate>) -> Self { |
| 168 | LocalVideo { |
| 169 | mode, |
| 170 | hub, |
| 171 | updates, |
| 172 | camera: Outgoing::new(factory, CAMERA_LABEL, PatternKind::Camera, false), |
| 173 | screen: Outgoing::new(factory, SCREEN_LABEL, PatternKind::Screen, true), |
| 174 | lines: None, |
| 175 | blur: Arc::new(BlurSettings::default()), |
| 176 | motion: false, |
| 177 | share_fps: Arc::new(AtomicU32::new(SCREEN_SHARE_FPS)), |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | pub fn set_motion(&mut self, motion: bool) { |
| 182 | self.motion = motion; |
| 183 | self.share_fps.store(if motion { MOTION_SHARE_FPS } else { SCREEN_SHARE_FPS }, Ordering::Relaxed); |
| 184 | if let Some(share) = self.lines.as_ref().and_then(|lines| lines.share.as_ref()).filter(|_| self.sharing()) { |
| 185 | let _ = self.tune_share(&share.sender()); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | pub fn set_standout(&self, standout: bool) { |
| 190 | self.blur.set_standout(standout); |
| 191 | } |
| 192 | |
| 193 | fn tune_share(&self, sender: &RtpSender) -> Result<()> { |
| 194 | let mut parameters = sender.parameters(); |
| 195 | parameters.set_degradation_preference(if self.motion { |
| 196 | DegradationPreference::MaintainFramerate |
| 197 | } else { |
| 198 | DegradationPreference::MaintainResolution |
| 199 | }); |
| 200 | let fps = f64::from(self.share_fps.load(Ordering::Relaxed)); |
| 201 | for encoding in &mut parameters.encodings { |
| 202 | encoding.max_framerate = Some(fps); |
| 203 | } |
| 204 | sender.set_parameters(parameters).map_err(|error| Error::Webrtc(error.to_string())) |
| 205 | } |
| 206 | |
| 207 | fn sender_of(&self, source: SendSource) -> Option<RtpSender> { |
| 208 | let lines = self.lines.as_ref()?; |
| 209 | match source { |
| 210 | SendSource::Camera => Some(lines.camera.sender()), |
| 211 | SendSource::Screen => lines.share.as_ref().map(|share| share.sender()), |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | pub fn apply_send_limit(&mut self, source: SendSource, limits: &[SendLimit]) -> Result<Option<Vec<LayerPlan>>> { |
| 216 | let sending = match source { |
| 217 | SendSource::Camera => self.camera_on(), |
| 218 | SendSource::Screen => self.sharing(), |
| 219 | }; |
| 220 | let Some(sender) = self.sender_of(source).filter(|_| sending) else { return Ok(None) }; |
| 221 | let outgoing = match source { |
| 222 | SendSource::Camera => &mut self.camera, |
| 223 | SendSource::Screen => &mut self.screen, |
| 224 | }; |
| 225 | let frame = unpack_size(outgoing.frame_size.load(Ordering::Relaxed)); |
| 226 | outgoing.requested = Some(RequestedLimits { limits: limits.to_vec(), applied_for: frame }); |
| 227 | let rids: Vec<String> = sender.parameters().encodings.into_iter().map(|encoding| encoding.rid).collect(); |
| 228 | if rids.len() > 1 { |
| 229 | let plans = plan_layers(limits, frame, &rids); |
| 230 | if plans.iter().any(|plan| plan.keyframe) { |
| 231 | Self::set_layers(&sender, &plans, KEYFRAME_NUDGE)?; |
| 232 | } |
| 233 | Self::set_layers(&sender, &plans, 1.0)?; |
| 234 | return Ok(Some(plans)); |
| 235 | } |
| 236 | let Some(limit) = limits.first() else { return Ok(None) }; |
| 237 | let encoder = encoder_limits(limit, frame); |
| 238 | if limit.keyframe { |
| 239 | Self::set_limits(&sender, &encoder, KEYFRAME_NUDGE)?; |
| 240 | } |
| 241 | Self::set_limits(&sender, &encoder, 1.0)?; |
| 242 | Ok(Some(vec![LayerPlan { rid: rids.into_iter().next().unwrap_or_default(), active: true, limits: Some(encoder), keyframe: limit.keyframe }])) |
| 243 | } |
| 244 | |
| 245 | /// The mixer sends its limits once, often before the first frame tells the size to scale from. |
| 246 | pub fn refresh_send_limits(&mut self) -> Vec<(SendSource, Result<Option<Vec<LayerPlan>>>)> { |
| 247 | let mut refreshed = Vec::new(); |
| 248 | for source in [SendSource::Camera, SendSource::Screen] { |
| 249 | let outgoing = match source { |
| 250 | SendSource::Camera => &self.camera, |
| 251 | SendSource::Screen => &self.screen, |
| 252 | }; |
| 253 | let frame = unpack_size(outgoing.frame_size.load(Ordering::Relaxed)); |
| 254 | let Some(requested) = outgoing.requested.as_ref().filter(|requested| frame.is_some() && requested.applied_for != frame) else { |
| 255 | continue; |
| 256 | }; |
| 257 | let limits = requested.limits.clone(); |
| 258 | refreshed.push((source, self.apply_send_limit(source, &limits))); |
| 259 | } |
| 260 | refreshed |
| 261 | } |
| 262 | |
| 263 | fn set_layers(sender: &RtpSender, plans: &[LayerPlan], nudge: f64) -> Result<()> { |
| 264 | let mut parameters = sender.parameters(); |
| 265 | for encoding in &mut parameters.encodings { |
| 266 | let Some(plan) = plans.iter().find(|plan| plan.rid == encoding.rid) else { continue }; |
| 267 | let nudged = nudge != 1.0 && plan.keyframe; |
| 268 | encoding.active = plan.active; |
| 269 | let Some(limits) = &plan.limits else { continue }; |
| 270 | encoding.scale_resolution_down_by = Some(limits.scale_down_by * if nudged { nudge } else { 1.0 }); |
| 271 | if let Some(framerate) = limits.max_framerate { |
| 272 | encoding.max_framerate = Some(framerate); |
| 273 | } |
| 274 | encoding.max_bitrate = limits.max_bitrate; |
| 275 | } |
| 276 | sender.set_parameters(parameters).map_err(|error| Error::Webrtc(error.to_string())) |
| 277 | } |
| 278 | |
| 279 | fn set_limits(sender: &RtpSender, limits: &EncoderLimits, nudge: f64) -> Result<()> { |
| 280 | let mut parameters = sender.parameters(); |
| 281 | for encoding in &mut parameters.encodings { |
| 282 | encoding.scale_resolution_down_by = Some(limits.scale_down_by * nudge); |
| 283 | if let Some(framerate) = limits.max_framerate { |
| 284 | encoding.max_framerate = Some(framerate); |
| 285 | } |
| 286 | encoding.max_bitrate = limits.max_bitrate; |
| 287 | } |
| 288 | sender.set_parameters(parameters).map_err(|error| Error::Webrtc(error.to_string())) |
| 289 | } |
| 290 | |
| 291 | pub fn camera_size(&self) -> Option<(u32, u32)> { |
| 292 | unpack_size(self.camera.frame_size.load(Ordering::Relaxed)).filter(|_| self.camera_on()) |
| 293 | } |
| 294 | |
| 295 | pub fn set_background(&self, enabled: bool, picture: Option<Arc<BackgroundPicture>>) { |
| 296 | self.blur.set_picture(picture); |
| 297 | self.blur.set_enabled(enabled); |
| 298 | } |
| 299 | |
| 300 | pub fn set_effects(&self, effects: CameraEffects) { |
| 301 | self.blur.set_effects(effects); |
| 302 | } |
| 303 | |
| 304 | pub fn camera_track(&self) -> RtcVideoTrack { |
| 305 | self.camera.track.clone() |
| 306 | } |
| 307 | |
| 308 | pub fn blur_average_ms(&self) -> Option<f32> { |
| 309 | (self.camera_on() && self.blur.active()).then(|| self.blur.average_ms()) |
| 310 | } |
| 311 | |
| 312 | pub fn has_lines(&self) -> bool { |
| 313 | self.lines.is_some() |
| 314 | } |
| 315 | |
| 316 | pub fn share_mid(&self) -> Option<String> { |
| 317 | self.lines.as_ref().and_then(|lines| lines.share.as_ref()).and_then(|share| share.mid()) |
| 318 | } |
| 319 | |
| 320 | pub fn has_share_line(&self) -> bool { |
| 321 | self.lines.as_ref().is_some_and(|lines| lines.share.is_some()) |
| 322 | } |
| 323 | |
| 324 | pub fn add_share_line(&mut self, share: RtpTransceiver, camera: Option<RtpTransceiver>) -> Result<()> { |
| 325 | match (self.lines.as_mut(), camera) { |
| 326 | (Some(lines), _) => lines.share = Some(share), |
| 327 | (None, Some(camera)) => self.lines = Some(VideoLines { camera, share: Some(share) }), |
| 328 | (None, None) => return Err(Error::Webrtc("no video line negotiated".into())), |
| 329 | } |
| 330 | Ok(()) |
| 331 | } |
| 332 | |
| 333 | pub fn share_sending(&self) -> bool { |
| 334 | self.lines |
| 335 | .as_ref() |
| 336 | .and_then(|lines| lines.share.as_ref()) |
| 337 | .and_then(|share| share.current_direction()) |
| 338 | .is_some_and(|direction| matches!(direction, RtpTransceiverDirection::SendOnly | RtpTransceiverDirection::SendRecv)) |
| 339 | } |
| 340 | |
| 341 | pub fn is_available(&self) -> bool { |
| 342 | self.mode != VideoMode::Off |
| 343 | } |
| 344 | |
| 345 | pub fn camera_on(&self) -> bool { |
| 346 | self.camera.capture.is_some() |
| 347 | } |
| 348 | |
| 349 | pub fn sharing(&self) -> bool { |
| 350 | self.screen.capture.is_some() |
| 351 | } |
| 352 | |
| 353 | pub fn set_lines(&mut self, lines: VideoLines) -> Result<()> { |
| 354 | if self.camera_on() { |
| 355 | Self::begin_sending(&lines.camera.sender(), &self.camera.track)?; |
| 356 | } |
| 357 | if self.sharing() |
| 358 | && let Some(share) = &lines.share |
| 359 | { |
| 360 | Self::begin_sending(&share.sender(), &self.screen.track)?; |
| 361 | } |
| 362 | self.lines = Some(lines); |
| 363 | Ok(()) |
| 364 | } |
| 365 | |
| 366 | fn begin_sending(sender: &RtpSender, track: &RtcVideoTrack) -> Result<()> { |
| 367 | sender |
| 368 | .set_track(Some(MediaStreamTrack::Video(track.clone()))) |
| 369 | .map_err(|error| Error::Webrtc(error.to_string()))?; |
| 370 | Self::set_active(sender, true) |
| 371 | } |
| 372 | |
| 373 | fn set_active(sender: &RtpSender, active: bool) -> Result<()> { |
| 374 | let mut parameters = sender.parameters(); |
| 375 | for encoding in &mut parameters.encodings { |
| 376 | encoding.active = active; |
| 377 | } |
| 378 | sender.set_parameters(parameters).map_err(|error| Error::Webrtc(error.to_string())) |
| 379 | } |
| 380 | |
| 381 | fn camera_sink(&self) -> LocalSink { |
| 382 | LocalSink::new(self.camera.source.clone(), Some((self.hub.clone(), VideoKey::LocalCamera))) |
| 383 | .mirrored_by(self.blur.clone()) |
| 384 | .reporting_size(self.camera.frame_size.clone()) |
| 385 | } |
| 386 | |
| 387 | fn report_failure(&self, what: &'static str) -> impl FnOnce(String) + Send + 'static { |
| 388 | let updates = self.updates.clone(); |
| 389 | move |reason| { |
| 390 | let _ = updates.send(CallUpdate::Notice(format!("{what} stopped: {reason}"))); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | pub fn start_camera(&mut self, choice: &DeviceChoice) -> Result<()> { |
| 395 | let lines = self.lines.as_ref().ok_or_else(|| Error::Webrtc("no video line negotiated".into()))?; |
| 396 | if !self.is_available() { |
| 397 | return Err(Error::Webrtc("video is switched off".into())); |
| 398 | } |
| 399 | self.camera.capture = None; |
| 400 | let mut sink = self.camera_sink(); |
| 401 | let capture = match self.mode { |
| 402 | VideoMode::Pattern => Capture::Task(spawn_pattern(sink, PatternKind::Camera, Some(self.blur.clone()))), |
| 403 | _ => start_camera(choice, self.blur.clone(), move |buffer| sink.push(buffer), self.report_failure("Camera"))?, |
| 404 | }; |
| 405 | Self::begin_sending(&lines.camera.sender(), &self.camera.track)?; |
| 406 | self.camera.capture = Some(capture); |
| 407 | Ok(()) |
| 408 | } |
| 409 | |
| 410 | pub fn stop_camera(&mut self) { |
| 411 | self.camera.capture = None; |
| 412 | self.blur.set_cutout(None); |
| 413 | if let Some(lines) = &self.lines { |
| 414 | let _ = Self::set_active(&lines.camera.sender(), false); |
| 415 | } |
| 416 | self.hub.forget(&VideoKey::LocalCamera); |
| 417 | } |
| 418 | |
| 419 | pub fn start_share(&mut self, source: &ShareSource) -> Result<()> { |
| 420 | let lines = self.lines.as_ref().ok_or_else(|| Error::Webrtc("no video line negotiated".into()))?; |
| 421 | let share = lines.share.as_ref().ok_or_else(|| Error::Webrtc("sharing needs a meeting".into()))?; |
| 422 | if !self.is_available() { |
| 423 | return Err(Error::Webrtc("video is switched off".into())); |
| 424 | } |
| 425 | self.screen.capture = None; |
| 426 | let mut sink = LocalSink::new(self.screen.source.clone(), None) |
| 427 | .with_standout(self.blur.clone()) |
| 428 | .reporting_size(self.screen.frame_size.clone()); |
| 429 | let capture = match self.mode { |
| 430 | VideoMode::Pattern => Capture::Task(spawn_pattern(sink, PatternKind::Screen, None)), |
| 431 | _ => start_screen_capture(source.clone(), self.share_fps.clone(), move |buffer| sink.push(buffer), self.report_failure("Screen share"))?, |
| 432 | }; |
| 433 | Self::begin_sending(&share.sender(), &self.screen.track)?; |
| 434 | let _ = self.tune_share(&share.sender()); |
| 435 | self.screen.capture = Some(capture); |
| 436 | Ok(()) |
| 437 | } |
| 438 | |
| 439 | pub fn stop_share(&mut self) { |
| 440 | self.screen.capture = None; |
| 441 | if let Some(share) = self.lines.as_ref().and_then(|lines| lines.share.as_ref()) { |
| 442 | let _ = Self::set_active(&share.sender(), false); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | pub fn stop_all(&mut self) { |
| 447 | self.stop_camera(); |
| 448 | self.stop_share(); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | #[cfg(test)] |
| 453 | mod tests { |
| 454 | use super::*; |
| 455 | |
| 456 | #[test] |
| 457 | fn frame_sizes_survive_packing() { |
| 458 | assert_eq!(unpack_size(pack_size(1280, 720)), Some((1280, 720))); |
| 459 | assert_eq!(unpack_size(0), None); |
| 460 | } |
| 461 | |
| 462 | #[test] |
| 463 | fn the_video_mode_follows_the_environment_value() { |
| 464 | assert_eq!(VideoMode::parse(None), VideoMode::Platform); |
| 465 | assert_eq!(VideoMode::parse(Some("Pattern")), VideoMode::Pattern); |
| 466 | assert_eq!(VideoMode::parse(Some("off")), VideoMode::Off); |
| 467 | assert_eq!(VideoMode::parse(Some("whatever")), VideoMode::Platform); |
| 468 | } |
| 469 | } |