gosuto_libwebrtc/
video_source.rs1use livekit_protocol::enum_dispatch;
16
17use crate::imp::video_source as vs_imp;
18
19#[derive(Debug, Clone)]
20pub struct VideoResolution {
21 pub width: u32,
22 pub height: u32,
23}
24
25impl Default for VideoResolution {
26 fn default() -> Self {
28 VideoResolution { width: 1280, height: 720 }
29 }
30}
31
32#[non_exhaustive]
33#[derive(Debug, Clone)]
34pub enum RtcVideoSource {
35 #[cfg(not(target_arch = "wasm32"))]
37 Native(native::NativeVideoSource),
38}
39
40impl RtcVideoSource {
42 enum_dispatch!(
43 [Native];
44 pub fn video_resolution(self: &Self) -> VideoResolution;
45 );
46}
47
48#[cfg(not(target_arch = "wasm32"))]
49pub mod native {
50 use std::fmt::{Debug, Formatter};
51
52 use super::*;
53 use crate::video_frame::{VideoBuffer, VideoFrame};
54
55 #[derive(Clone)]
56 pub struct NativeVideoSource {
57 pub(crate) handle: vs_imp::NativeVideoSource,
58 }
59
60 impl Debug for NativeVideoSource {
61 fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
62 f.debug_struct("NativeVideoSource").finish()
63 }
64 }
65
66 impl Default for NativeVideoSource {
67 fn default() -> Self {
68 Self::new(VideoResolution::default(), false)
69 }
70 }
71
72 impl NativeVideoSource {
73 pub fn new(resolution: VideoResolution, is_screencast: bool) -> Self {
74 Self { handle: vs_imp::NativeVideoSource::new(resolution, is_screencast) }
75 }
76
77 pub fn capture_frame<T: AsRef<dyn VideoBuffer>>(&self, frame: &VideoFrame<T>) {
78 self.handle.capture_frame(frame)
79 }
80
81 pub fn video_resolution(&self) -> VideoResolution {
82 self.handle.video_resolution()
83 }
84 }
85}
86
87#[cfg(target_arch = "wasm32")]
88pub mod web {}