donut snapshot
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index b3cbda1..6613700 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -64,15 +64,22 @@
     init();
 }
 
-Camera::Camera(const sp<ICamera>& camera)
+// construct a camera client from an existing camera remote
+sp<Camera> Camera::create(const sp<ICamera>& camera)
 {
-    init();
-    // connect this client to existing camera remote
-    if (camera->connect(this) == NO_ERROR) {
-        mStatus = NO_ERROR;
-        mCamera = camera;
-        camera->asBinder()->linkToDeath(this);
+     LOGV("create");
+     if (camera == 0) {
+         LOGE("camera remote is a NULL pointer");
+         return 0;
+     }
+
+    sp<Camera> c = new Camera();
+    if (camera->connect(c) == NO_ERROR) {
+        c->mStatus = NO_ERROR;
+        c->mCamera = camera;
+        camera->asBinder()->linkToDeath(c);
     }
+    return c;
 }
 
 void Camera::init()
@@ -330,63 +337,65 @@
     mErrorCallbackCookie = cookie;
 }
 
-void Camera::autoFocusCallback(bool focused)
+// callback from camera service
+void Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
 {
-    LOGV("autoFocusCallback");
-    if (mAutoFocusCallback) {
-        mAutoFocusCallback(focused, mAutoFocusCallbackCookie);
+    switch(msgType) {
+    case CAMERA_MSG_ERROR:
+        LOGV("errorCallback");
+        if (mErrorCallback) {
+            mErrorCallback((status_t)ext1, mErrorCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_FOCUS:
+        LOGV("autoFocusCallback");
+        if (mAutoFocusCallback) {
+            mAutoFocusCallback((bool)ext1, mAutoFocusCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_SHUTTER:
+        LOGV("shutterCallback");
+        if (mShutterCallback) {
+            mShutterCallback(mShutterCallbackCookie);
+        }
+        break;
+    default:
+        LOGV("notifyCallback(%d, %d, %d)", msgType, ext1, ext2);
+        break;
     }
 }
 
-void Camera::shutterCallback()
+// callback from camera service when frame or image is ready
+void Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr)
 {
-    LOGV("shutterCallback");
-    if (mShutterCallback) {
-        mShutterCallback(mShutterCallbackCookie);
-    }
-}
-
-void Camera::rawCallback(const sp<IMemory>& picture)
-{
-    LOGV("rawCallback");
-    if (mRawCallback) {
-        mRawCallback(picture, mRawCallbackCookie);
-    }
-}
-
-// callback from camera service when image is ready
-void Camera::jpegCallback(const sp<IMemory>& picture)
-{
-    LOGV("jpegCallback");
-    if (mJpegCallback) {
-        mJpegCallback(picture, mJpegCallbackCookie);
-    }
-}
-
-// callback from camera service when preview frame is ready
-void Camera::previewCallback(const sp<IMemory>& frame)
-{
-    LOGV("frameCallback");
-    if (mPreviewCallback) {
-        mPreviewCallback(frame, mPreviewCallbackCookie);
-    }
-}
-
-// callback from camera service when a recording frame is ready
-void Camera::recordingCallback(const sp<IMemory>& frame)
-{
-    LOGV("recordingCallback");
-    if (mRecordingCallback) {
-        mRecordingCallback(frame, mRecordingCallbackCookie);
-    }
-}
-
-// callback from camera service when an error occurs in preview or takePicture
-void Camera::errorCallback(status_t error)
-{
-    LOGV("errorCallback");
-    if (mErrorCallback) {
-        mErrorCallback(error, mErrorCallbackCookie);
+    switch(msgType) {
+    case CAMERA_MSG_PREVIEW_FRAME:
+        LOGV("previewCallback");
+        if (mPreviewCallback) {
+            mPreviewCallback(dataPtr, mPreviewCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_VIDEO_FRAME:
+        LOGV("recordingCallback");
+        if (mRecordingCallback) {
+            mRecordingCallback(dataPtr, mRecordingCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_RAW_IMAGE:
+        LOGV("rawCallback");
+        if (mRawCallback) {
+            mRawCallback(dataPtr, mRawCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_COMPRESSED_IMAGE:
+        LOGV("jpegCallback");
+        if (mJpegCallback) {
+            mJpegCallback(dataPtr, mJpegCallbackCookie);
+        }
+        break;
+    default:
+        LOGV("dataCallback(%d, %p)", msgType, dataPtr.get());
+        break;
     }
 }
 
diff --git a/libs/ui/ICameraClient.cpp b/libs/ui/ICameraClient.cpp
index 4bec9d2..c6cf75c 100644
--- a/libs/ui/ICameraClient.cpp
+++ b/libs/ui/ICameraClient.cpp
@@ -25,13 +25,8 @@
 namespace android {
 
 enum {
-    SHUTTER_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
-    RAW_CALLBACK,
-    JPEG_CALLBACK,
-    PREVIEW_CALLBACK,
-    ERROR_CALLBACK,
-    AUTOFOCUS_CALLBACK,
-    RECORDING_CALLBACK,
+    NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
+    DATA_CALLBACK,
 };
 
 class BpCameraClient: public BpInterface<ICameraClient>
@@ -42,74 +37,29 @@
     {
     }
 
-    // callback to let the app know the shutter has closed, ideal for playing the shutter sound
-    void shutterCallback()
+    // generic callback from camera service to app
+    void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
     {
-        LOGV("shutterCallback");
+        LOGV("notifyCallback");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        remote()->transact(SHUTTER_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
+        data.writeInt32(msgType);
+        data.writeInt32(ext1);
+        data.writeInt32(ext2);
+        remote()->transact(NOTIFY_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
     }
 
-    // callback from camera service to app with picture data
-    void rawCallback(const sp<IMemory>& picture)
+    // generic data callback from camera service to app with image data
+    void dataCallback(int32_t msgType, const sp<IMemory>& imageData)
     {
-        LOGV("rawCallback");
+        LOGV("dataCallback");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(picture->asBinder());
-        remote()->transact(RAW_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
+        data.writeInt32(msgType);
+        data.writeStrongBinder(imageData->asBinder());
+        remote()->transact(DATA_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
     }
 
-    // callback from camera service to app with picture data
-    void jpegCallback(const sp<IMemory>& picture)
-    {
-        LOGV("jpegCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(picture->asBinder());
-        remote()->transact(JPEG_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with preview frame data
-    void previewCallback(const sp<IMemory>& frame)
-    {
-        LOGV("previewCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(frame->asBinder());
-        remote()->transact(PREVIEW_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with recording frame data
-    void recordingCallback(const sp<IMemory>& frame)
-    {
-        LOGV("recordingCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(frame->asBinder());
-        remote()->transact(RECORDING_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app to report error
-    void errorCallback(status_t error)
-    {
-        LOGV("errorCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeInt32(error);
-        remote()->transact(ERROR_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app to report autofocus completion
-    void autoFocusCallback(bool focused)
-    {
-        LOGV("autoFocusCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeInt32(focused);
-        remote()->transact(AUTOFOCUS_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
 };
 
 IMPLEMENT_META_INTERFACE(CameraClient, "android.hardware.ICameraClient");
@@ -126,52 +76,21 @@
     uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
 {
     switch(code) {
-        case SHUTTER_CALLBACK: {
-            LOGV("SHUTTER_CALLBACK");
+        case NOTIFY_CALLBACK: {
+            LOGV("NOTIFY_CALLBACK");
             CHECK_INTERFACE(ICameraClient, data, reply);
-            shutterCallback();
+            int32_t msgType = data.readInt32();
+            int32_t ext1 = data.readInt32();
+            int32_t ext2 = data.readInt32();
+            notifyCallback(msgType, ext1, ext2);
             return NO_ERROR;
         } break;
-        case RAW_CALLBACK: {
+        case DATA_CALLBACK: {
             LOGV("RAW_CALLBACK");
             CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> picture = interface_cast<IMemory>(data.readStrongBinder());
-            rawCallback(picture);
-            return NO_ERROR;
-        } break;
-        case JPEG_CALLBACK: {
-            LOGV("JPEG_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> picture = interface_cast<IMemory>(data.readStrongBinder());
-            jpegCallback(picture);
-            return NO_ERROR;
-        } break;
-        case PREVIEW_CALLBACK: {
-            LOGV("PREVIEW_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder());
-            previewCallback(frame);
-            return NO_ERROR;
-        } break;
-        case RECORDING_CALLBACK: {
-            LOGV("RECORDING_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder());
-            recordingCallback(frame);
-            return NO_ERROR;
-        } break;
-        case ERROR_CALLBACK: {
-            LOGV("ERROR_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            status_t error = data.readInt32();
-            errorCallback(error);
-            return NO_ERROR;
-        } break;
-        case AUTOFOCUS_CALLBACK: {
-            LOGV("AUTOFOCUS_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            bool focused = (bool)data.readInt32();
-            autoFocusCallback(focused);
+            int32_t msgType = data.readInt32();
+            sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder());
+            dataCallback(msgType, imageData);
             return NO_ERROR;
         } break;
         default: