本讲是Android Camera Native Framework专题的第21讲,我们介绍ICameraDeviceUser.aidl详解。
更多资源:
| 资源 | 描述 |
|---|---|
| 在线课程 | 极客笔记在线课程 |
| 知识星球 | 星球名称:深入浅出Android Camera 星球ID: 17296815 |
| 极客笔记圈 |
什么是ICameraDeviceUser
Camera app执行open camera后, Camera Java FW调用ICameraService的connectDevice方法获取到一个ICameraDeviceUser对象
ICameraDeviceUser代表的就是一颗CameraDevice,后续的Camera操作流程就是基于ICameraDeviceUser对象。

ICameraDeviceUser类图
Java端:

C++端:

ICameraDeviceUser.aidl接口详解
| ICameraDeviceUser API | Camera2 Java API | Description |
|---|---|---|
| void waitUntilIdle(); | CameraDevice的createCaptureSession | createCaptureSession时会先调stopRepeating,然后用该API等待上一次Session为IDLE |
| void beginConfigure() | CameraDevice#createCaptureSession | 开始创建Session |
| int createStream(in OutputConfiguration outputConfiguration); | CameraDevice的createCaptureSession | 根据OutputConfiguration 创建Output Stream |
| void deleteStream(int streamId); | CameraDevice的createCaptureSession | 根据streamId删除未配置的Stream |
| int createInputStream(int width, int height, int format, boolean isMultiResolution); | CameraDevice的createCaptureSession | 在Reprocess流程中,根据宽/高/format等信息创建Input Stream |
| int[] endConfigure(int operatingMode, in CameraMetadataNative sessionParams, long startTimeMs); | CameraDevice的createCaptureSession | 结束创建Session |
| boolean isSessionConfigurationSupported(in SessionConfiguration sessionConfiguration); | CameraDevice的isSessionConfigurationSupported | 判断指定的SessionConfiguration是否支持 |
| void prepare(int streamId); | CameraCaptureSession的prepare | 预申请某路Stream的Buffers, 这样能提升第一帧到来的性能 |
| void prepare2(int maxCount, int streamId); | CameraCaptureSession的prepare | 预申请某路Stream的Buffers,可以指定最大张数 |
| void tearDown(int streamId); | CameraCaptureSession的tearDown(Hide API) | 释放暂时未被填充Image的Buffers,目的是为了释放Memory峰值压力,会以latency和性能作为代价 |
| void updateOutputConfiguration(int streamId, in OutputConfiguration outputConfiguration); | CameraCaptureSession 的 updateOutputConfiguration | 更新OutputConfiguration |
| void finalizeOutputConfigurations(int streamId, in OutputConfiguration outputConfiguration); | CameraCaptureSession 的 finalizeOutputConfigurations | 最终决定OutputConfiguration |
| CameraMetadataNative createDefaultRequest(int templateId); | CameraDevice的createCaptureRequest | 根据templateId创建默认的CaptureRequest |
| SubmitInfo submitRequest(in CaptureRequest request, boolean streaming) | NA | 废弃了,不使用 |
| SubmitInfo submitRequestList(in CaptureRequest[] requestList, boolean streaming) | CameraCaptureSession的 capture / captureBurst setRepeatingRequest / setRepeatingBurst | 向Framework送CaptureRequests |
| long cancelRequest(int requestId) | CameraCaptureSession的stopRepeating | 取消正在repeating的CaptureRequest |
| long flush(); | CameraCaptureSession的abortCaptures | 放弃正在处理队列中,未被处理的Requests |
| ICameraOfflineSession switchToOffline(in ICameraDeviceCallbacks callbacks, in int[] offlineOutputIds); | CameraCaptureSession 的 switchToOffline | 将当前的CameraCaptureSession切换到后台继续运行 |
| Surface getInputSurface(); | CameraCaptureSession的getInputSurface | 在Reprocess流程中,创建接受Input Buffer的Surface |
| void setCameraAudioRestriction(int mode); | CameraDevice 的 setCameraAudioRestriction | 设置当前Camera Device的Audio限制策略 |
| int getGlobalAudioRestriction(); | CameraDevice的 getCameraAudioRestriction | 获取当前Camera Device的Audio限制策略 |
| void disconnect() | CameraDevice#close | 关闭Camera Device |
| CameraMetadataNative getCameraInfo(); | NA | 废弃了,不使用 |
极客笔记