`

android framework之Camera

 
阅读更多

Camera

Android's camera Hardware Abstraction Layer (HAL) connects the higher level camera framework APIs in android.hardware to your underlying camera driver and hardware. The camera subsystem includes implementations for camera pipeline components while the camera HAL provides interfaces for use in implementing your version of these components.

For the most up-to-date information, refer to the following resources:

Architecture


The following figure and list describe the HAL components:



 

Figure 1. Camera architecture

Application framework
At the application framework level is the app's code, which utilizes the android.hardware.Camera API to interact with the camera hardware. Internally, this code calls a corresponding JNI glue class to access the native code that interacts with the camera.
JNI
The JNI code associated with android.hardware.Camera is located inframeworks/base/core/jni/android_hardware_Camera.cpp. This code calls the lower level native code to obtain access to the physical camera and returns data that is used to create the android.hardware.Cameraobject at the framework level.
Native framework
The native framework defined in frameworks/av/camera/Camera.cpp provides a native equivalent to theandroid.hardware.Camera class. This class calls the IPC binder proxies to obtain access to the camera service.
Binder IPC proxies
The IPC binder proxies facilitate communication over process boundaries. There are three camera binder classes that are located in frameworks/av/camera directory that calls into camera service. ICameraService is the interface to the camera service, ICamera is the interface to a specific opened camera device, and ICameraClient is the device's interface back to the application framework.
Camera service
The camera service, located in frameworks/av/services/camera/libcameraservice/CameraService.cpp, is the actual code that interacts with the HAL.
HAL
The hardware abstraction layer defines the standard interface that the camera service calls into and that you must implement to have your camera hardware function correctly.
Kernel driver
The camera's driver interacts with the actual camera hardware and your implementation of the HAL. The camera and driver must support YV12 and NV21 image formats to provide support for previewing the camera image on the display and video recording.

Implementing the HAL


The HAL sits between the camera driver and the higher level Android framework and defines an interface you must implement so apps can correctly operate the camera hardware. The HAL interface is defined in thehardware/libhardware/include/hardware/camera.h and hardware/libhardware/include/hardware/camera_common.hheader files.

camera_common.h defines camera_module, a standard structure to obtain general information about the camera, such as the camera ID and properties common to all cameras (i.e., whether it is a front- or back-facing camera).

camera.h contains code that corresponds to android.hardware.Camera. This header file declares a camera_devicestruct that in turn contains a camera_device_ops struct with pointers to functions that implement the HAL interface. For documentation on the camera parameters developers can set, refer toframeworks/av/include/camera/CameraParameters.h. These parameters are set with the function pointed to by int (*set_parameters)(struct camera_device *, const char *parms) in the HAL.

For an example of a HAL implementation, refer to the implementation for the Galaxy Nexus HAL inhardware/ti/omap4xxx/camera.

Configuring the shared library


Set up the Android build system to correctly package the HAL implementation into a shared library and copy it to the appropriate location by creating an Android.mk file:

  1. Create a device/<company_name>/<device_name>/camera directory to contain your library's source files.
  2. Create an Android.mk file to build the shared library. Ensure the Makefile contains the following lines:
    LOCAL_MODULE := camera.<device_name>
    LOCAL_MODULE_RELATIVE_PATH := hw

    Your library must be named camera.<device_name> (.so is appended automatically), so Android can correctly load the library. For an example, see the Makefile for the Galaxy Nexus camera located inhardware/ti/omap4xxx/Android.mk.

  3. Specify your device has camera features by copying the necessary feature XML files in theframeworks/native/data/etc directory with your device's Makefile. For example, to specify your device has a camera flash and can autofocus, add the following lines in your device's<device>/<company_name>/<device_name>/device.mk Makefile:
    PRODUCT_COPY_FILES := \ ...
    
    PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:system/etc/permissions/android.hardware.camera.flash-autofocus.xml \
    

    For an example of a device Makefile, see device/samsung/tuna/device.mk.

  4. Declare your camera’s media codec, format, and resolution capabilities indevice/<company_name>/<device_name>/media_profiles.xml anddevice/<company_name>/<device_name>/media_codecs.xml XML files. For details, see Exposing codecs to the framework.
  5. Add the following lines in your device's device/<company_name>/<device_name>/device.mk Makefile to copy themedia_profiles.xml and media_codecs.xml files to the appropriate location:
    # media config xml file
    PRODUCT_COPY_FILES +=\
        <device>/<company>/<device>/media_profiles.xml:system/etc/media_profiles.xml
    
    # media codec config xml file
    PRODUCT_COPY_FILES +=\
        <device>/<company>/<device>/media_codecs.xml:system/etc/media_codecs.xml
  6. To include the Camera app in your device's system image, specify it in the PRODUCT_PACKAGES variable in your device's device/<company>/<device>/device.mk Makefile:
    PRODUCT_PACKAGES :=\
    Gallery2\
    ...

 

 

  • 大小: 111.1 KB
分享到:
评论

相关推荐

    android framework camera分析

    ### Android Framework Camera模块详解 #### 一、Android Camera模块概述 Android系统中的Camera模块是一个重要的组成部分,主要用于处理视频输入功能。该模块被设计为一个框架层(framework),旨在支持多种不同...

    Android Camera Framework

    在深入解析三星方案Android Camera Framework之前,我们需要先了解Android Camera Framework整体的概念,再针对三星的特定实现进行详细探讨。Android Camera Framework是Android操作系统中用于管理相机硬件的一个...

    Android Camera 架构学习(Binder)

    其中,Camera Framework 是 Android 操作系统中负责处理 CAMERA 相关功能的框架,Camera HAL 是 CAMERA 硬件抽象层,Camera Client 是应用程序与 Camera Framework 之间的接口。 Camera Architecture(Binder 机制...

    RTSP-Camera-for-Android-视频监控demo

    RTSP camera aims to establish an Android platform as a streaming server for the device's camera output. In order to register for receiving the camera stream, the Real-Time streaming protocol (RTSP) is...

    Android Camera框架

    在Android系统中,客户端应用程序可以通过调用Framework层提供的`android.hardware.camera`类来实现摄像头相关的功能。最终,这些Java应用程序会被打包成APK文件。在Framework层中,`android.hardware.camera`类提供...

    Android Camera2 Framework层分析.docx

    承担着于用户直接进行交互的责任,承接来自用户直接或者间接的比如预览/拍照/录像等一系列具体需求,一旦接收到用户相关UI操作,便会通过Camera Api v2标准接口将需求发送至Camera Framework部分,并且等待Camera ...

    camera-framework

    android camera framework结构图

    Android Framework 框架分析

    Android Framework的复杂性与精妙设计是其成为全球最广泛使用的移动操作系统之一的关键。通过对框架核心组件的深入分析,我们不仅能更好地理解Android系统的运作机制,还能在开发过程中做出更优化的设计决策,提升...

    android_camera_framework_stream

    ### Android Camera Framework Stream详解 #### 一、概述 在深入探讨`android_camera_framework_stream`之前,我们先简要了解一下此主题的基本概念与重要性。在Android系统中,摄像头功能是移动设备的重要组成部分...

    学习 camera framework 总结

    在 Android 环境下,Camera Framework 是一个非常重要的组成部分,它为开发者提供了与摄像头硬件交互的接口。本文将深入探讨 Camera Framework 的架构、工作原理以及如何实现 Camera Framework 来支持不同的硬件驱动...

    第七章_Android_Camera架构.zip_andriod_android camera_camera

    4. **Camera Framework**:这部分是Android系统的一部分,为应用程序提供API接口。它位于Camera Service之上,提供了诸如捕获图片、录制视频等功能的调用方法。主要分为Camera1和Camera2两个API版本。 - **Camera1...

    Android camera架构介绍

    Android Camera 模块作为移动设备上的核心功能之一,在系统架构设计上显得尤为重要。为了更好地理解其内部工作原理,我们首先需要对它的整体架构有一个清晰的认识。 **Android Camera 模块**主要由两大部分组成:...

    Android Camera架构及源码解析

    自己总结的Android Camera系统架构及源码分析,以framework和hal为主。

    Android Framework 分析

    Android Framework 是 Android 操作系统的核心组件之一,负责提供基本的系统服务和功能。下面将对 Android Framework 进行深入分析,涵盖其目录树、camera HAL 接口库、cmds 命令、runtime 环境等多方面的知识点。 ...

    Android camera 资料合集(物有所值)

    (精品)Android Camera分析(整理).pdf Android 的Camera架构介绍.pdf Camera模块解析驱动.pdf ...学习camera framework 总结.pdf Android框架下Camera的设计与实现.pdf android_Camera框架分析.pdf

    android_Camera.7z

    "android_Camera.7z"这个压缩包包含的资源,主要是对Android相机框架的深入分析,特别是聚焦于framework层面的重点流程。让我们详细探讨一下Android相机系统的关键知识点。 1. **Android相机框架概述**:Android...

    安卓Android源码——camera,修改过可以在4.0系统上运行。.zip

    在安卓(Android)平台上,相机(Camera)是操作系统与硬件之间的重要接口,使得开发者能够创建丰富的拍照和视频录制应用。这份“安卓Android源码——camera,修改过可以在4.0系统上运行”的压缩包,提供了Android ...

    android_camera_framework_stream.pdf

    android_camera_framework_stream.pdf

    android_camera_framework_stream汇编.pdf

    android_camera_framework_stream汇编.pdf

    Android框架揭秘(完整版pdf)

    Android框架揭秘 金泰延 宋亨周 朴知勋 李白 林起永 著 武传海译 《Android框架揭秘》通过对Android...Android服务框架的结构与理解,通过Camera Service、Activity Manager Service等服务分析实际的Android服务等。

Global site tag (gtag.js) - Google Analytics