一、前言
Camera的buffer用途上主要分类:input buffer和output buffer。
- • input buffer是有实际内容的buffer,通过reprocess流程将其送到hal,hal读取它并进行一系列的处理。
- • output buffer是仅有一块buffer内存,里面没有具体数据,hal会将生成的数据填入到output buffer中。 在Camera2+HAL3的架构中,buffer是交由stream来管理的,configure stream流程配置的stream定义了HAL可以处理的buffer类型,每一个stream对应了系列同类型的buffer。看下Gogle对stream的定义:
什么是stream? (定义:hardware/libhardware/include/hardware/camera3.h)
A handle to a single camera input or output stream. A stream is defined by the framework by its buffer resolution and format, and additionally by the HAL with the gralloc usage flags and the maximum in-flight buffer count.
The stream structures are owned by the framework, but pointers to a camera3_stream passed into the HAL by configure_streams() are valid until the end of the first subsequent configure_streams() call that does not include that camera3_stream as an argument, or until the end of the close() call.
All camera3_stream framework-controlled members are immutable once the camera3_stream is passed into configure_streams(). The HAL may only change the HAL-controlled parameters during a configure_streams() call, except for the contents of the private pointer.
If a configure_streams() call returns a non-fatal error, all active streams remain valid as if configure_streams() had not been called.
The endpoint of the stream is not visible to the camera HAL device. In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream types) see the usage field below.
简单来说就是,stream有input stream和output stream两种类型,它定义了buffer的四个基本属性:(1) resolution (2) format (3) gralloc usage flags (4) maximun in-flight buffer count。
什么是 in-flight buff