/// Opens and initializes a specific DRM `Display`.
///
/// `path` is the path to a DRM device that supports VAAPI, e.g. `/dev/dri/renderD128`.
/// Opens and initializes a specific DRM `Display`.
///
/// `path` is the path to a DRM device that supports VAAPI, e.g. `/dev/dri/renderD128`.
// Safe because fd represents a valid file descriptor and the pointer is checked for
// NULL afterwards.
let display = unsafe { bindings::vaGetDisplayDRM(file.as_raw_fd()) };
if display.is_null() {
// The File will close the DRM fd on drop.
// Safe because fd represents a valid file descriptor and the pointer is checked for
// NULL afterwards.
let display = unsafe { bindings::vaGetDisplayDRM(file.as_raw_fd()) };
if display.is_null() {
// The File will close the DRM fd on drop.
}
let mut major = 0i32;
let mut minor = 0i32;
// Safe because we ensure that the display is valid (i.e not NULL) before calling
// vaInitialize. The File will close the DRM fd on drop.
}
let mut major = 0i32;
let mut minor = 0i32;
// Safe because we ensure that the display is valid (i.e not NULL) before calling
// vaInitialize. The File will close the DRM fd on drop.
// Safe because `self` represents a valid VADisplay.
let mut max_num_profiles = unsafe { bindings::vaMaxNumProfiles(self.handle) };
let mut profiles = Vec::with_capacity(max_num_profiles as usize);
// Safe because `self` represents a valid `VADisplay` and the vector has `max_num_profiles`
// as capacity.
// Safe because `self` represents a valid VADisplay.
let mut max_num_profiles = unsafe { bindings::vaMaxNumProfiles(self.handle) };
let mut profiles = Vec::with_capacity(max_num_profiles as usize);
// Safe because `self` represents a valid `VADisplay` and the vector has `max_num_profiles`
// as capacity.
pub fn query_config_entrypoints(
&self,
profile: bindings::VAProfile::Type,
pub fn query_config_entrypoints(
&self,
profile: bindings::VAProfile::Type,
// Safe because `self` represents a valid VADisplay.
let mut max_num_entrypoints = unsafe { bindings::vaMaxNumEntrypoints(self.handle) };
let mut entrypoints = Vec::with_capacity(max_num_entrypoints as usize);
// Safe because `self` represents a valid VADisplay and the vector has `max_num_entrypoints`
// as capacity.
// Safe because `self` represents a valid VADisplay.
let mut max_num_entrypoints = unsafe { bindings::vaMaxNumEntrypoints(self.handle) };
let mut entrypoints = Vec::with_capacity(max_num_entrypoints as usize);
// Safe because `self` represents a valid VADisplay and the vector has `max_num_entrypoints`
// as capacity.
profile: bindings::VAProfile::Type,
entrypoint: bindings::VAEntrypoint::Type,
attributes: &mut [bindings::VAConfigAttrib],
profile: bindings::VAProfile::Type,
entrypoint: bindings::VAEntrypoint::Type,
attributes: &mut [bindings::VAConfigAttrib],
// Safe because `self` represents a valid VADisplay. The slice length is passed to the C
// function, so it is impossible to write past the end of the slice's storage by mistake.
// Safe because `self` represents a valid VADisplay. The slice length is passed to the C
// function, so it is impossible to write past the end of the slice's storage by mistake.
attrs: Vec<bindings::VAConfigAttrib>,
profile: bindings::VAProfile::Type,
entrypoint: bindings::VAEntrypoint::Type,
attrs: Vec<bindings::VAConfigAttrib>,
profile: bindings::VAProfile::Type,
entrypoint: bindings::VAEntrypoint::Type,
Config::new(Rc::clone(self), attrs, profile, entrypoint)
}
/// Returns available image formats for this display by wrapping around `vaQueryImageFormats`.
Config::new(Rc::clone(self), attrs, profile, entrypoint)
}
/// Returns available image formats for this display by wrapping around `vaQueryImageFormats`.
// Safe because `self` represents a valid VADisplay.
let mut num_image_formats = unsafe { bindings::vaMaxNumImageFormats(self.handle) };
let mut image_formats = Vec::with_capacity(num_image_formats as usize);
// Safe because `self` represents a valid VADisplay.
let mut num_image_formats = unsafe { bindings::vaMaxNumImageFormats(self.handle) };
let mut image_formats = Vec::with_capacity(num_image_formats as usize);
// Safe because `self` represents a valid VADisplay. The `image_formats` vector is properly
// initialized and a valid size is passed to the C function, so it is impossible to write
// past the end of their storage by mistake.
// Safe because `self` represents a valid VADisplay. The `image_formats` vector is properly
// initialized and a valid size is passed to the C function, so it is impossible to write
// past the end of their storage by mistake.
bindings::vaQueryImageFormats(
self.handle,
image_formats.as_mut_ptr(),
bindings::vaQueryImageFormats(
self.handle,
image_formats.as_mut_ptr(),