camera callback

原创 2011年01月20日 20:47:00

 
android_hardware_Camera.cpp

void JNICameraContext::notify(int32_t msgType, int32_t ext1, int32_t ext2){
    env->CallStaticVoidMethod(mCameraJClass, fields.post_event, mCameraJObjectWeak, msgType, ext1, ext2, NULL);
}


----------->

fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative", "(Ljava/lang/Object;IIILjava/lang/Object;)V");

----------->frameworks/base/core/java/android/hardware/camera.java


    private static void postEventFromNative(Object camera_ref,
                                            int what, int arg1, int arg2, Object obj)
    {
        Camera c = (Camera)((WeakReference)camera_ref).get();
        if (c == null)
            return;

        if (c.mEventHandler != null) {
            Message m = c.mEventHandler.obtainMessage(what, arg1, arg2, obj);
            c.mEventHandler.sendMessage(m);
        }
    }

----------->

   mEventHandler = new EventHandler(this, looper);

----------->
    private class EventHandler extends Handler
    {
        private Camera mCamera;

        public EventHandler(Camera c, Looper looper) {
            super(looper);
            mCamera = c;
        }

        @Override
        public void handleMessage(Message msg) {
            switch(msg.what) {
            case CAMERA_MSG_SHUTTER:
                if (mShutterCallback != null) {
                    mShutterCallback.onShutter();
                }
                return;
    .
    .
    .
        }
    }

---------->

    public final void takePicture(ShutterCallback shutter, PictureCallback raw,
            PictureCallback postview, PictureCallback jpeg) {
        mShutterCallback = shutter;
        mRawImageCallback = raw;
        mPostviewCallback = postview;
        mJpegCallback = jpeg;
        native_takePicture();
    }


--------->packages/apps/camera/src/com/android/camera/camera.java
framework层的takePicture在这里初调用。

    mCameraDevice.takePicture(mShutterCallback, mRawPictureCallback, mPostViewPictureCallback, new JpegPictureCallback(loc));

--------->

    private final ShutterCallback mShutterCallback = new ShutterCallback();

--------->

    private final class ShutterCallback
            implements android.hardware.Camera.ShutterCallback {
        public void onShutter() {
            mShutterCallbackTime = System.currentTimeMillis();
            mShutterLag = mShutterCallbackTime - mCaptureStartTime;
            Log.v(TAG, "mShutterLag = " + mShutterLag + "ms");
            clearFocusState();
        }
    }

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Android4.4 Camera callback注册和回调过程分析

一、注册过程camera的callback是在cameraclient中的initialize接口中注册的,而这个接口是由上层初始化调用的。status_t CameraClient::initial...

Android图形系统之Surface、SurfaceView、SurfaceHolder及SurfaceHolder.Callback之间的联系 && camera的takePicture实例

Android图形系统之Surface、SurfaceView、SurfaceHolder及SurfaceHolder.Callback之间的联系 && camera的takePicture实例

何时使用WINAPI,CALLBACK 以及_stdcall _cdecl _pascal 等的用法区别总结

#define   CALLBACK         __stdcall  #define   WINAPI     ...

jQuery源码解析(2)—— Callback、Deferred异步编程

闲话这篇文章,一个月前就该出炉了。跳票的原因,是因为好奇标准的promise/A+规范,于是学习了es6的promise,由于兴趣,又完整的学习了《ECMAScript 6入门》。本文目的在于解析jQ...

callback例子

  • 2014-06-14 00:43
  • 545B
  • 下载

callback.h

内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)