Modify camera framework to use new streamlined binder interface.
This is the second half of bug 1837832. Modifies the camera client
and camera service to use the new binder interface. Removes the
old binder interface. There will be one more part to this change
to surface the undefined callbacks to the Java layer so that
partners can implement new features without having to touch the
stack.
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index ed4f3b8..6613700 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -337,76 +337,66 @@
mErrorCallbackCookie = cookie;
}
-void Camera::autoFocusCallback(bool focused)
-{
- LOGV("autoFocusCallback");
- if (mAutoFocusCallback) {
- mAutoFocusCallback(focused, mAutoFocusCallbackCookie);
- }
-}
-
-void Camera::shutterCallback()
-{
- 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);
- }
-}
-
// callback from camera service
void Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
{
- LOGV("notifyCallback");
+ 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;
+ }
}
-// callback from camera service when image is ready
-void Camera::dataCallback(int32_t msgType, const sp<IMemory>& frame)
+// callback from camera service when frame or image is ready
+void Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr)
{
- LOGV("dataCallback");
+ 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;
+ }
}
void Camera::binderDied(const wp<IBinder>& who) {