1use super::track::{RtcAudioTrack, RtcVideoTrack};
2use futures::Stream;
3use livekit::webrtc as real;
4use std::{
5 pin::Pin,
6 task::{Context, Poll},
7};
8
9pub mod video_stream {
10 use super::*;
11
12 pub mod native {
13 use super::*;
14 use real::video_frame::BoxVideoFrame;
15
16 pub struct NativeVideoStream {
17 pub track: RtcVideoTrack,
18 }
19
20 impl NativeVideoStream {
21 pub fn new(track: RtcVideoTrack) -> Self {
22 Self { track }
23 }
24 }
25
26 impl Stream for NativeVideoStream {
27 type Item = BoxVideoFrame;
28
29 fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> {
30 Poll::Pending
31 }
32 }
33 }
34}
35
36pub mod audio_stream {
37 use super::*;
38
39 pub mod native {
40 use super::*;
41 use real::audio_frame::AudioFrame;
42
43 pub struct NativeAudioStream {
44 pub track: RtcAudioTrack,
45 }
46
47 impl NativeAudioStream {
48 pub fn new(track: RtcAudioTrack, _sample_rate: i32, _num_channels: i32) -> Self {
49 Self { track }
50 }
51 }
52
53 impl Stream for NativeAudioStream {
54 type Item = AudioFrame<'static>;
55
56 fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> {
57 Poll::Pending
58 }
59 }
60 }
61}
62
63pub mod audio_source {
64 use super::*;
65
66 pub use real::audio_source::AudioSourceOptions;
67
68 pub mod native {
69 use std::sync::Arc;
70
71 use super::*;
72 use real::{audio_frame::AudioFrame, RtcError};
73
74 #[derive(Clone)]
75 pub struct NativeAudioSource {
76 pub options: Arc<AudioSourceOptions>,
77 pub sample_rate: u32,
78 pub num_channels: u32,
79 }
80
81 impl NativeAudioSource {
82 pub fn new(
83 options: AudioSourceOptions,
84 sample_rate: u32,
85 num_channels: u32,
86 _queue_size_ms: u32,
87 ) -> Self {
88 Self {
89 options: Arc::new(options),
90 sample_rate,
91 num_channels,
92 }
93 }
94
95 pub async fn capture_frame(&self, _frame: &AudioFrame<'_>) -> Result<(), RtcError> {
96 Ok(())
97 }
98 }
99 }
100
101 pub enum RtcAudioSource {
102 Native(native::NativeAudioSource),
103 }
104}
105
106pub use livekit::webrtc::audio_frame;
107pub use livekit::webrtc::video_frame;
108
109pub mod video_source {
110 use super::*;
111 pub use real::video_source::VideoResolution;
112
113 pub struct RTCVideoSource;
114
115 pub mod native {
116 use super::*;
117 use real::video_frame::{VideoBuffer, VideoFrame};
118
119 #[derive(Clone)]
120 pub struct NativeVideoSource {
121 pub resolution: VideoResolution,
122 }
123
124 impl NativeVideoSource {
125 pub fn new(resolution: super::VideoResolution) -> Self {
126 Self { resolution }
127 }
128
129 pub fn capture_frame<T: AsRef<dyn VideoBuffer>>(&self, _frame: &VideoFrame<T>) {}
130 }
131 }
132
133 pub enum RtcVideoSource {
134 Native(native::NativeVideoSource),
135 }
136}