#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct StreamInfo {
pub width: u32,
pub height: u32,
pub is_keyframe: bool,
}
impl From<vpx_sys::vpx_codec_stream_info> for StreamInfo {
fn from(value: vpx_sys::vpx_codec_stream_info) -> Self {
Self {
width: value.w,
height: value.h,
is_keyframe: value.is_kf != 0,
}
}
}
pub(crate) fn get_stream_info(
ctx: &mut vpx_sys::vpx_codec_ctx,
) -> Option<StreamInfo> {
let mut si = vpx_sys::vpx_codec_stream_info {
sz: size_of::<vpx_sys::vpx_codec_stream_info>() as _,
w: 0,
h: 0,
is_kf: 0,
};
let error = unsafe { vpx_sys::vpx_codec_get_stream_info(ctx, &mut si) };
(error == vpx_sys::VPX_CODEC_OK).then(|| si.into())
}