1#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
11pub struct StreamInfo {
12 pub width: u32,
14 pub height: u32,
16 pub is_keyframe: bool,
18}
19
20impl From<vpx_sys::vpx_codec_stream_info> for StreamInfo {
21 fn from(value: vpx_sys::vpx_codec_stream_info) -> Self {
22 Self {
23 width: value.w,
24 height: value.h,
25 is_keyframe: value.is_kf != 0,
26 }
27 }
28}
29
30pub(crate) fn get_stream_info(
31 ctx: &mut vpx_sys::vpx_codec_ctx,
32) -> Option<StreamInfo> {
33 let mut si = vpx_sys::vpx_codec_stream_info {
34 sz: size_of::<vpx_sys::vpx_codec_stream_info>() as _,
35 w: 0,
36 h: 0,
37 is_kf: 0,
38 };
39 let error = unsafe { vpx_sys::vpx_codec_get_stream_info(ctx, &mut si) };
40 (error == vpx_sys::VPX_CODEC_OK).then(|| si.into())
41}