gosuto_libwebrtc/
video_stream.rs1use crate::imp::video_stream as stream_imp;
16
17#[cfg(not(target_arch = "wasm32"))]
21pub mod native {
22 use std::{
23 fmt::Debug,
24 pin::Pin,
25 task::{Context, Poll},
26 };
27
28 use super::stream_imp;
29 use crate::{video_frame::BoxVideoFrame, video_track::RtcVideoTrack};
30 use livekit_runtime::Stream;
31
32 pub struct NativeVideoStream {
33 pub(crate) handle: stream_imp::NativeVideoStream,
34 }
35
36 impl Debug for NativeVideoStream {
37 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
38 f.debug_struct("NativeVideoStream").field("track", &self.track()).finish()
39 }
40 }
41
42 impl NativeVideoStream {
43 pub fn new(video_track: RtcVideoTrack) -> Self {
44 Self { handle: stream_imp::NativeVideoStream::new(video_track) }
45 }
46
47 pub fn track(&self) -> RtcVideoTrack {
48 self.handle.track()
49 }
50
51 pub fn close(&mut self) {
52 self.handle.close();
53 }
54 }
55
56 impl Stream for NativeVideoStream {
57 type Item = BoxVideoFrame;
58
59 fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
60 Pin::new(&mut self.get_mut().handle).poll_next(cx)
61 }
62 }
63}
64
65#[cfg(target_arch = "wasm32")]
66pub mod web {}