Android Camera子系统之源代码View
本文基于Android 4.2.2+Linux3.6.9+SAMA5D3 SoC从源代码的角度审视Android Camera子系统。
应用层
Androd原生Camera应用
/system/app/LegacyCamera.apk
http://androidxref.com/4.2.2_r1/xref/packages/apps/LegacyCamera/
Camera应用调用Android应用框架提供的Camera API
import android.hardware.Camera;
import android.hardware.Camera.Area;
import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.Face;
import android.hardware.Camera.FaceDetectionListener;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.Size;
应用框架层
/system/framework/framework.jar
http://androidxref.com/4.2.2_r1/xref/frameworks/base/core/java/android/hardware/Camera.java
JNI
/system/lib/libandroid_runtime.so
http://androidxref.com/4.2.2_r1/xref/frameworks/base/core/jni/android_hardware_Camera.cpp
Camera Service Binder Proxy
Camera Service Binder Proxy是Camera Client和Camera Service之间通信的统一通道。Camera Client和Camera Service都会调用Camera Service Binder Proxy。
/system/lib/libcamera_client.so
头文件目录
http://androidxref.com/4.2.2_r1/xref/frameworks/av/include/camera/
源文件目录
http://androidxref.com/4.2.2_r1/xref/frameworks/av/camera/
Camera Service
Camera Service与Camera HAL交互,通过Binder Service的方式为Camera Client提供服务。
/system/lib/libcameraservice.so
http://androidxref.com/4.2.2_r1/xref/frameworks/av/services/camera/libcameraservice/
HAL
Camera硬件抽象层定义并实现供Camera Service调用的标准接口,保证Camera硬件的功能能够正常发挥。
/system/lib/hw/camera.sama5d3-ek.so
头文件
http://androidxref.com/4.2.2_r1/xref/hardware/libhardware/include/hardware/camera.h
源文件目录
https://github.com/Android4SAM/platform_hardware_atmel/tree/master/sama5d3/camera
Kernel Driver
Camera驱动程序与Camera硬件和HAL交互。Camera硬件和驱动程序必须支持YV12和NV21图像格式以支持预览和录像。
The V4L2driver for Atmel Linux
https://github.com/Android4SAM/linux-at91/blob/android4sam_v4.0/drivers/media/video/atmel-isi.c
SoC Cameradriver for Omni Vision 2640 sensor
https://github.com/Android4SAM/linux-at91/blob/android4sam_v4.0/drivers/media/video/ov2640.c