use super::*;
#[derive(Clone, Copy, Data, Debug, Deserialize, Eq, Hash, New, PartialEq, Serialize)]
pub struct VideoColorInfo {
#[get(type(copy))]
pub(crate) primaries: ColorPrimaries,
#[get(type(copy))]
pub(crate) transfer: TransferCharacteristics,
#[get(type(copy))]
pub(crate) matrix: MatrixCoefficients,
#[get(type(copy))]
pub(crate) range: ColorRange,
#[get(type(copy))]
pub(crate) bit_depth: u8,
#[get(type(copy))]
pub(crate) max_cll_nits: u16,
#[get(type(copy))]
pub(crate) max_fall_nits: u16,
}
#[derive(Clone, Copy, Data, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct HardwareDecoderCapabilities {
#[get(type(copy))]
pub(crate) kind: HardwareDecoderKind,
#[get(type(copy))]
pub(crate) zero_copy_gpu_interop: bool,
#[get(type(copy))]
pub(crate) supports_h264: bool,
#[get(type(copy))]
pub(crate) supports_h265: bool,
#[get(type(copy))]
pub(crate) supports_vp9: bool,
#[get(type(copy))]
pub(crate) supports_av1: bool,
#[get(type(copy))]
pub(crate) supports_hdr10: bool,
#[get(type(copy))]
pub(crate) max_width: u32,
#[get(type(copy))]
pub(crate) max_height: u32,
}
#[derive(Clone, Copy, Debug, Default)]
pub struct HardwareDecoderProbe;
#[derive(Clone, Copy, Data, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct VideoGpuSurfaceHandle {
#[get(type(copy))]
pub(crate) surface_id: u64,
#[get(type(copy))]
pub(crate) device_id: u64,
#[get(type(copy))]
pub(crate) generation: u64,
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) height: u32,
#[get(type(copy))]
pub(crate) pixel_format: VideoPixelFormat,
#[get(type(copy))]
pub(crate) color_info: VideoColorInfo,
#[get(type(copy))]
pub(crate) fence_value: u64,
#[get(type(copy))]
pub(crate) zero_copy: bool,
#[get(type(copy))]
pub(crate) backend: HardwareDecoderKind,
}
#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
pub struct PooledVideoFrame {
#[get(type(copy))]
pub(crate) slot_id: usize,
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) height: u32,
pub(crate) pixels: Vec<u8>,
}
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
pub struct VideoFramePoolStats {
#[get(type(copy))]
pub(crate) capacity: usize,
#[get(type(copy))]
pub(crate) in_use: usize,
#[get(type(copy))]
pub(crate) available: usize,
#[get(type(copy))]
pub(crate) allocations: u64,
#[get(type(copy))]
pub(crate) reuse_hits: u64,
#[get(type(copy))]
pub(crate) backpressure_rejects: u64,
#[get(type(copy))]
pub(crate) recycled_count: u64,
}
#[derive(Clone, Data, Debug, Default)]
pub(crate) struct VideoFramePoolState {
#[get(type(copy))]
pub(crate) capacity: usize,
#[get(type(copy))]
pub(crate) in_use: usize,
#[get(type(copy))]
pub(crate) next_slot_id: usize,
pub(crate) free_buffers: Vec<PooledVideoFrame>,
#[get(type(copy))]
pub(crate) allocations: u64,
#[get(type(copy))]
pub(crate) reuse_hits: u64,
#[get(type(copy))]
pub(crate) backpressure_rejects: u64,
#[get(type(copy))]
pub(crate) recycled_count: u64,
}
#[derive(Clone, CustomDebug)]
pub struct VideoFramePool {
#[cfg(not(target_arch = "wasm32"))]
pub(crate) inner: Arc<Mutex<VideoFramePoolState>>,
#[cfg(target_arch = "wasm32")]
pub(crate) inner: Rc<RefCell<VideoFramePoolState>>,
}
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
pub struct Mp4Sample {
#[get(type(copy))]
pub(crate) index: usize,
#[get(type(copy))]
pub(crate) dts_us: i64,
#[get(type(copy))]
pub(crate) pts_us: i64,
#[get(type(copy))]
pub(crate) duration_us: u64,
#[get(type(copy))]
pub(crate) byte_offset: u64,
#[get(type(copy))]
pub(crate) byte_size: u32,
#[get(type(copy))]
pub(crate) is_keyframe: bool,
}
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct Mp4TrackInfo {
#[get(type(copy))]
pub(crate) track_id: u32,
#[get(type(copy))]
pub(crate) is_video: bool,
#[get(type(copy))]
pub(crate) video_codec: VideoCodec,
#[get(type(copy))]
pub(crate) audio_codec: AudioCodec,
pub(crate) codec_fourcc: String,
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) height: u32,
#[get(type(copy))]
pub(crate) timescale: u32,
#[get(type(copy))]
pub(crate) duration_us: u64,
#[get(type(copy))]
pub(crate) sample_rate_hz: u32,
#[get(type(copy))]
pub(crate) channels: u16,
#[get(type(copy))]
pub(crate) color_info: VideoColorInfo,
pub(crate) samples: Vec<Mp4Sample>,
}
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct Mp4Demuxer {
pub(crate) bytes: Vec<u8>,
pub(crate) major_brand: String,
pub(crate) compatible_brands: Vec<String>,
#[get(type(copy))]
pub(crate) movie_timescale: u32,
#[get(type(copy))]
pub(crate) movie_duration_us: u64,
pub(crate) video_track: Mp4TrackInfo,
#[get(skip)]
pub(crate) audio_track: Option<Mp4TrackInfo>,
}
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct Mp4BuilderSample {
#[get(type(copy))]
pub(crate) duration_ticks: u32,
#[get(type(copy))]
pub(crate) composition_offset_ticks: i32,
#[get(type(copy))]
pub(crate) is_keyframe: bool,
pub(crate) payload: Vec<u8>,
}
#[derive(Clone, Copy, Debug, Default)]
pub struct Mp4ContainerBuilder;
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
pub struct VideoDecoderConfig {
#[get(type(copy))]
pub(crate) codec: VideoCodec,
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) height: u32,
#[get(type(copy))]
pub(crate) color_info: VideoColorInfo,
}
#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
pub struct EncodedVideoPacket {
#[get(type(copy))]
pub(crate) sample_index: usize,
#[get(type(copy))]
pub(crate) generation: u64,
#[get(type(copy))]
pub(crate) dts_us: i64,
#[get(type(copy))]
pub(crate) pts_us: i64,
#[get(type(copy))]
pub(crate) duration_us: u64,
#[get(type(copy))]
pub(crate) is_keyframe: bool,
pub(crate) data: Vec<u8>,
}
#[derive(Clone, Data, Debug, PartialEq)]
pub struct DecodedVideoFrame {
#[get(type(copy))]
pub(crate) sample_index: usize,
#[get(type(copy))]
pub(crate) generation: u64,
#[get(type(copy))]
pub(crate) dts_us: i64,
#[get(type(copy))]
pub(crate) pts_us: i64,
#[get(type(copy))]
pub(crate) duration_us: u64,
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) height: u32,
#[get(type(copy))]
pub(crate) color_info: VideoColorInfo,
pub(crate) backing: VideoFrameBacking,
}
#[derive(Clone, Data, Debug, Default)]
pub struct SoftwareVideoDecoder {
#[get(type(copy))]
pub(crate) config: VideoDecoderConfig,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) reference_rgba: Vec<u8>,
#[get(type(copy))]
pub(crate) has_reference: bool,
#[get(type(copy))]
pub(crate) decoded_frames: u64,
}
#[derive(Clone, Data, Debug, Default)]
pub struct HardwareZeroCopyDecoder {
#[get(type(copy))]
pub(crate) kind: HardwareDecoderKind,
#[get(type(copy))]
pub(crate) device_id: u64,
#[get(type(copy))]
pub(crate) pixel_format: VideoPixelFormat,
#[get(type(copy))]
pub(crate) config: VideoDecoderConfig,
#[get(type(copy))]
pub(crate) next_surface_id: u64,
#[get(type(copy))]
pub(crate) next_fence_value: u64,
}
#[derive(Clone, Data, Debug, Default)]
pub struct PtsFrameQueue {
#[get(type(copy))]
pub(crate) capacity: usize,
pub(crate) frames: Vec<DecodedVideoFrame>,
#[get(type(copy))]
pub(crate) stale_generation_drops: u64,
}
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct AvSyncScheduler {
#[get(type(copy))]
pub(crate) clock_source: AvSyncClockSource,
#[get(type(copy))]
pub(crate) clock_pts_us: i64,
#[get(type(copy))]
pub(crate) playback_rate: f32,
#[get(type(copy))]
pub(crate) max_late_us: i64,
#[get(skip)]
pub(crate) last_presented_pts_us: Option<i64>,
#[get(type(copy))]
pub(crate) frames_presented: u64,
#[get(type(copy))]
pub(crate) frames_held_vsync: u64,
#[get(type(copy))]
pub(crate) frames_dropped_late: u64,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(CustomDebug, Data)]
pub(crate) struct VideoWorkerShared {
pub(crate) queue: PtsFrameQueue,
#[get(type(copy))]
pub(crate) active_generation: u64,
#[get(type(copy))]
pub(crate) next_sample_index: usize,
#[get(type(copy))]
pub(crate) seek_preroll_target_us: i64,
#[get(skip)]
pub(crate) pending_seek: Option<(u64, usize, i64)>,
#[get(type(copy))]
pub(crate) playing: bool,
#[get(type(copy))]
pub(crate) reached_eos: bool,
#[get(type(copy))]
pub(crate) shutdown: bool,
#[get(type(copy))]
pub(crate) packets_decoded: u64,
#[get(type(copy))]
pub(crate) seek_preroll_frames_discarded: u64,
#[get(skip)]
pub(crate) last_error: Option<String>,
}
#[derive(CustomDebug)]
pub struct VideoPlaybackPipeline {
pub(crate) demuxer: Mp4Demuxer,
pub(crate) pool: VideoFramePool,
pub(crate) scheduler: AvSyncScheduler,
pub(crate) backend_kind: HardwareDecoderKind,
pub(crate) color_info: VideoColorInfo,
pub(crate) state: PlaybackState,
pub(crate) current_frame: Option<DecodedVideoFrame>,
pub(crate) active_generation: u64,
#[cfg(not(target_arch = "wasm32"))]
#[debug(skip)]
pub(crate) worker_shared: Arc<(Mutex<VideoWorkerShared>, Condvar)>,
#[cfg(not(target_arch = "wasm32"))]
#[debug(skip)]
pub(crate) worker_handle: Option<JoinHandle<()>>,
#[cfg(target_arch = "wasm32")]
#[debug(skip)]
pub(crate) wasm_decoder: Box<dyn VideoDecoderBackend>,
#[cfg(target_arch = "wasm32")]
pub(crate) wasm_queue: PtsFrameQueue,
#[cfg(target_arch = "wasm32")]
pub(crate) wasm_next_sample: usize,
#[cfg(target_arch = "wasm32")]
pub(crate) wasm_preroll_target_us: i64,
#[cfg(target_arch = "wasm32")]
pub(crate) wasm_eos: bool,
#[cfg(target_arch = "wasm32")]
pub(crate) wasm_packets_decoded: u64,
#[cfg(target_arch = "wasm32")]
pub(crate) wasm_preroll_discarded: u64,
#[cfg(target_arch = "wasm32")]
pub(crate) wasm_last_error: Option<String>,
}
#[derive(Clone, Data, Debug, Default)]
pub(crate) struct Mp4SampleTableRaw {
pub(crate) stts: Vec<(u32, u32)>,
pub(crate) ctts: Vec<(u32, i32)>,
pub(crate) stss: Vec<u32>,
pub(crate) stsc: Vec<(u32, u32)>,
#[get(type(copy))]
pub(crate) default_sample_size: u32,
#[get(type(copy))]
pub(crate) sample_count: u32,
pub(crate) sample_sizes: Vec<u32>,
pub(crate) chunk_offsets: Vec<u64>,
}