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();
        }
    }

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

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

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

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

Cython封装Callback函数 示例

  • 2014年01月17日 19:49
  • 1KB
  • 下载

c++回调函数 callback

C++中实现回调机制的几种方式 (1)Callback方式 Callback的本质是设置一个函数指针进去,然后在需要需要触发某个事件时调用该方法, 比如Windows的窗口消息处理函数就是这种...

Android中callback(接口回调)机制

其实,callback 机制在Android 中无处不在,特别是以Handler、Callback、Listener这三个词结尾的,都是利用callback机制来实现的。比如点击事件onClickLi...
  • Kern_
  • Kern_
  • 2015年06月12日 16:41
  • 2278

callback例子

  • 2014年06月14日 00:43
  • 545B
  • 下载

callback.h

  • 2014年08月24日 20:37
  • 1KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:camera callback
举报原因:
原因补充:

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