winsafe\gdi_mf\com_interfaces/
imfvideodisplaycontrol.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::decl::*;
4use crate::guard::*;
5use crate::kernel::privs::*;
6use crate::mf::vts::*;
7use crate::ole::privs::*;
8use crate::prelude::*;
9
10impl gdi_mf_IMFVideoDisplayControl for IMFVideoDisplayControl {}
11
12/// This trait is enabled with `gdi` and `mf` features, and provides methods
13/// for [`IMFVideoDisplayControl`](crate::IMFVideoDisplayControl).
14///
15/// Prefer importing this trait through the prelude:
16///
17/// ```no_run
18/// use winsafe::prelude::*;
19/// ```
20pub trait gdi_mf_IMFVideoDisplayControl: mf_IMFVideoDisplayControl {
21	/// [`GetCurrentImage`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-getcurrentimage)
22	/// method.
23	///
24	/// Returns bitmap description, DIB bytes and time stamp.
25	#[must_use]
26	fn GetCurrentImage(&self) -> HrResult<(BITMAPINFOHEADER, Vec<u8>, i64)> {
27		let mut bih = BITMAPINFOHEADER::default();
28		let mut dib_ptr = std::ptr::null_mut::<u8>();
29		let mut dib_sz = 0u32;
30		let mut time_stamp = 0i64;
31
32		ok_to_hrresult(unsafe {
33			(vt::<IMFVideoDisplayControlVT>(self).GetCurrentImage)(
34				self.ptr(),
35				pvoid(&mut bih),
36				&mut dib_ptr,
37				&mut dib_sz,
38				&mut time_stamp,
39			)
40		})
41		.map(|_| {
42			let dib_vec = unsafe { std::slice::from_raw_parts(dib_ptr, dib_sz as _) }.to_vec();
43			let _ = unsafe { CoTaskMemFreeGuard::new(dib_ptr as _, 0) };
44			(bih, dib_vec, time_stamp)
45		})
46	}
47}