pub struct AImageFrame { /* private fields */ }Available on Android only.
Expand description
AImage* with extracted AHB + per-frame metadata.
Implementations§
Source§impl AImageFrame
impl AImageFrame
Sourcepub unsafe fn try_from_raw(
image: *mut c_void,
hardware: *mut c_void,
timestamp_ns: i64,
crop: Option<(i32, i32, i32, i32)>,
format: PixelFormat,
color: Option<ColorMetadata>,
keep_alive: Option<KeepAlive>,
) -> Result<Self, InvalidHandleError>
pub unsafe fn try_from_raw( image: *mut c_void, hardware: *mut c_void, timestamp_ns: i64, crop: Option<(i32, i32, i32, i32)>, format: PixelFormat, color: Option<ColorMetadata>, keep_alive: Option<KeepAlive>, ) -> Result<Self, InvalidHandleError>
Wrap an AImage* together with the AHardwareBuffer* extracted
from it. Borrowing: the handle is stored non-owningly, this type
has no Drop, and every obligation below extends to each
Clone.
§Safety
imagemust point to a liveAImagethat has not beenAImage_deleted, andhardwareto theAHardwareBuffer*obtained from thatAImageviaAImage_getHardwareBuffer. Both nulls are rejected asInvalidHandleError::NullPointerand are not caller obligations.AImage_getHardwareBufferreturns a borrowed pointer. The returned buffer’s reference belongs to theAImageand is invalidated byAImage_delete. Neither pointer is retained here and there is noDrop, sokeep_alivemust hold whatever keeps theAImage— and therefore the buffer — alive for the lifetime of this value and everyCloneof it. Withkeep_alive == Nonethe caller carries that directly. Releasing the image while a clone survives is a use-after-free in the importer.crop, whenSome, must be(left, top, right, bottom)fromAImage_getCropRectand must lie inside the buffer’s dimensions; consumers sample only that rectangle.formatmust be the buffer’s real layout andtimestamp_nsthe value fromAImage_getTimestamp.color, whenSome, overrides the AHB driver’s suggestedYCbCrmodel on the compute-unpack path (see the field docs above). It must be the stream’s true matrix and range: a wrong value is not unsound, but it silently decodes with the wrong matrix, which is exactly the failure it exists to prevent.- No thread affinity for the handle itself; the usual acquire-fence discipline still applies before reading the buffer’s pixels.
pub fn image(&self) -> *mut c_void
pub fn hardware(&self) -> *mut c_void
pub fn timestamp_ns(&self) -> i64
pub fn crop(&self) -> Option<(i32, i32, i32, i32)>
pub fn format(&self) -> PixelFormat
Sourcepub fn color(&self) -> Option<ColorMetadata>
pub fn color(&self) -> Option<ColorMetadata>
Caller-known color metadata, when the producer signalled it. See the field docs — authoritative over the AHB driver’s suggested YCbCr model on the compute-unpack path.
pub fn keep_alive(&self) -> Option<&KeepAlive>
Trait Implementations§
Source§impl Clone for AImageFrame
impl Clone for AImageFrame
Source§impl Debug for AImageFrame
impl Debug for AImageFrame
impl Send for AImageFrame
impl Sync for AImageFrame
Auto Trait Implementations§
impl !RefUnwindSafe for AImageFrame
impl !UnwindSafe for AImageFrame
impl Freeze for AImageFrame
impl Unpin for AImageFrame
impl UnsafeUnpin for AImageFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more