use super::VideoFrame;
use crate::channels::display::DisplaySurface;
use std::any::Any;
use std::sync::Arc;
#[cfg(not(target_arch = "wasm32"))]
#[async_trait::async_trait]
#[allow(async_fn_in_trait)]
pub trait VideoOutput: Send + Sync {
async fn update_frame(&self, surface: &DisplaySurface);
async fn get_current_frame(&self) -> Option<VideoFrame>;
async fn get_frame_count(&self) -> u64;
fn as_any(&self) -> &dyn Any;
}
#[cfg(target_arch = "wasm32")]
#[async_trait::async_trait(?Send)]
#[allow(async_fn_in_trait)]
pub trait VideoOutput {
async fn update_frame(&self, surface: &DisplaySurface);
async fn get_current_frame(&self) -> Option<VideoFrame>;
async fn get_frame_count(&self) -> u64;
fn as_any(&self) -> &dyn Any;
}
pub fn create_video_output() -> Arc<dyn VideoOutput> {
#[cfg(not(target_arch = "wasm32"))]
{
Arc::new(super::native::NativeVideoOutput::new())
}
#[cfg(target_arch = "wasm32")]
{
Arc::new(super::wasm::WasmVideoOutput::new())
}
}
#[cfg(target_arch = "wasm32")]
pub fn create_wasm_video_output() -> Arc<super::wasm::WasmVideoOutput> {
Arc::new(super::wasm::WasmVideoOutput::new())
}