相机自带的code的基本逻辑 [英] Underlying logic of camera's native code

查看:162
本文介绍了相机自带的code的基本逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更好地了解相机的原生code的基本逻辑,但我似乎创下了死胡同寻找适合照相机:连接方法定义时,() Camera.h 申报等功能​​。

I'm trying to better understand the underlying logic of camera's native code, but I appear to be hitting a dead-end when looking for the method definition for Camera::connect() and other functions declared from Camera.h.

我遵循的步骤是这些:


  1. 在主分支<一个href=\"https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/Camera.java\"相对=nofollow>我所在的 Camera.java ,其中包含了解决相机,选择逻辑 CameraInfo.CAMERA_FACING_BACK 遇到时:

    • Camera.open()通话 Camera.getCameraInfo(INT,CameraInfo)每个诠释在 Camera.getNumberOfCameras()

    • Camera.getCameraInfo(INT,CameraInfo)依次调用本机的功能 Camera._getCameraInfo(INT,CameraInfo)

  1. In the master branch I located Camera.java, which contains the logic for resolving cameras, selecting CameraInfo.CAMERA_FACING_BACK when it is encountered:
    • Camera.open() calls Camera.getCameraInfo(int, CameraInfo) for each int in Camera.getNumberOfCameras().
    • Camera.getCameraInfo(int, CameraInfo) in turn calls the native function Camera._getCameraInfo(int, CameraInfo).

戴尔文<一个href=\"https://android.googlesource.com/platform/frameworks/base/+/master/core/jni/android_hardware_Camera.cpp\"相对=nofollow>进入JNI :


  • android_hardware_Camera_getCameraInfo(JNIEnv的*,jobject,jint,jobject)然后调用静态方法照相机:getCameraInfo(jint,CameraInfo * ),这似乎宣告通过:

  • android_hardware_Camera_getCameraInfo(JNIEnv*, jobject, jint, jobject) then invokes the static method Camera::getCameraInfo(jint, CameraInfo*), which appears to be declared through:

#include <camera/Camera.h>


浏览和搜索主分支似乎并没有给出任何安打相机/ Camera.h 。我能找到的唯一的结果是旧的标签,例如<一个href=\"https://android.googlesource.com/platform/frameworks/base/+/gingerbread/include/camera/Camera.h\"相对=姜饼分支nofollow的>。这里有只在方法声明:

Browsing and searching the master branch doesn't seem to give any hits for camera/Camera.h. The only result I could find was in older tags, for instance in the gingerbread branch. Here there's only a method declaration:

static  status_t    getCameraInfo(int cameraId,
                              struct CameraInfo* cameraInfo);


  • 然而,这种方法的身体没有出现在任何地方定义。

  • However, the method body doesn't appear to be defined anywhere.

    最后两个步骤是在那里我感到困惑。哪里是相机/ Camera.h 中定义的较新版本的Andr​​oid系统?最后,到哪里都是相机的方法体实际上界定?

    The last two steps are where I am confused. Where is camera/Camera.h defined for more recent versions of Android? And finally, where are the method bodies of Camera actually defined?

    推荐答案

    在ICS,相机:: getCameraInfo(jint,CameraInfo *)在框架/ AV /摄像头/ Camera.cpp定义为

    In ICS, the Camera::getCameraInfo(jint, CameraInfo*) is defined in frameworks/av/camera/Camera.cpp as

    status_t Camera::getCameraInfo(int cameraId,
                                   struct CameraInfo* cameraInfo) {
        const sp<ICameraService>& cs = getCameraService();
        if (cs == 0) return UNKNOWN_ERROR;
        return cs->getCameraInfo(cameraId, cameraInfo);
    }
    

    然后抓住 CameraService 的粘合剂对象并调用 getCameraInfo CameraService

    Then it grabs a binder object of CameraService and call the getCameraInfo on CameraService.

    status_t CameraService::getCameraInfo(int cameraId,
                                          struct CameraInfo* cameraInfo) {
        ...
        struct camera_info info;
        status_t rc = mModule->get_camera_info(cameraId, &info);
        ...
        return rc;
    }
    

    mModule 包含设备上的实际执行相机。不同的设备可以具有不同的实现。例如,你可以找到 QualcommCamera 在<一个href=\"https://android.googlesource.com/platform/hardware/qcom/camera/+/android-4.2.2_r1/QualcommCamera.cpp\"相对=nofollow>硬件/ QCOM /摄像头/ QualcommCamera.cpp 。

    The mModule contains the actual implementation of camera on your device. Different devices may have different implementations. For example you can find QualcommCamera under hardware/qcom/camera/QualcommCamera.cpp.

    再看看连接。在连接做类似的工作,最后调用 CameraService ::连接。在该方法中,有一个 CameraClient mModule 初始化。所以,当你与客户的东西,实际上是与特定设备的实施工作。

    Then take a look at connect. The connect does a similar work and finally calls CameraService::connect. In that method, there is a CameraClient initialized by the mModule. So when you do something with the Client, you are actually working with the device-specific implementation.

    还有一个字,该mModule由 hw_get_module CameraService :: onFirstRef 初始化。

    One more word, the mModule is initialized by hw_get_module in CameraService::onFirstRef.

    这篇关于相机自带的code的基本逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆