CameraService: Refactor Camera2Client to share a base with ProCameraClient
Change-Id: I249e2a0fc47ae84f29c9d9c4a223fba13da3ee66
diff --git a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
index 9a14758..30c14ef 100644
--- a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
@@ -278,11 +278,12 @@
// Call outside parameter lock to allow re-entrancy from notification
{
- Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
- if (l.mCameraClient != 0) {
+ Camera2Client::SharedCameraCallbacks::Lock
+ l(client->mSharedCameraCallbacks);
+ if (l.mRemoteCallback != 0) {
ALOGV("%s: Camera %d: Invoking client data callback",
__FUNCTION__, client->getCameraId());
- l.mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_FRAME,
+ l.mRemoteCallback->dataCallback(CAMERA_MSG_PREVIEW_FRAME,
mCallbackHeap->mBuffers[heapIdx], NULL);
}
}
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
index 513a47e..1880912 100644
--- a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
@@ -271,10 +271,11 @@
}
if (mCaptureBuffer != 0 && res == OK) {
- Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
+ Camera2Client::SharedCameraCallbacks::Lock
+ l(client->mSharedCameraCallbacks);
ALOGV("%s: Sending still image to client", __FUNCTION__);
- if (l.mCameraClient != 0) {
- l.mCameraClient->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE,
+ if (l.mRemoteCallback != 0) {
+ l.mRemoteCallback->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE,
mCaptureBuffer, NULL);
} else {
ALOGV("%s: No client!", __FUNCTION__);
@@ -344,7 +345,7 @@
}
SharedParameters::Lock l(client->getParameters());
- /* warning: this also locks a SharedCameraClient */
+ /* warning: this also locks a SharedCameraCallbacks */
shutterNotifyLocked(l.mParameters, client, mMsgType);
mShutterNotified = true;
mTimeoutCount = kMaxTimeoutsForCaptureEnd;
@@ -496,7 +497,7 @@
}
if (mNewFrameReceived && !mShutterNotified) {
SharedParameters::Lock l(client->getParameters());
- /* warning: this also locks a SharedCameraClient */
+ /* warning: this also locks a SharedCameraCallbacks */
shutterNotifyLocked(l.mParameters, client, mMsgType);
mShutterNotified = true;
}
@@ -651,16 +652,17 @@
}
{
- Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
+ Camera2Client::SharedCameraCallbacks::Lock
+ l(client->mSharedCameraCallbacks);
ALOGV("%s: Notifying of shutter close to client", __FUNCTION__);
- if (l.mCameraClient != 0) {
+ if (l.mRemoteCallback != 0) {
// ShutterCallback
- l.mCameraClient->notifyCallback(CAMERA_MSG_SHUTTER,
+ l.mRemoteCallback->notifyCallback(CAMERA_MSG_SHUTTER,
/*ext1*/0, /*ext2*/0);
// RawCallback with null buffer
- l.mCameraClient->notifyCallback(CAMERA_MSG_RAW_IMAGE_NOTIFY,
+ l.mRemoteCallback->notifyCallback(CAMERA_MSG_RAW_IMAGE_NOTIFY,
/*ext1*/0, /*ext2*/0);
} else {
ALOGV("%s: No client!", __FUNCTION__);
diff --git a/services/camera/libcameraservice/camera2/FrameProcessor.cpp b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
index 1f2659c..09b4b27 100644
--- a/services/camera/libcameraservice/camera2/FrameProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
@@ -195,7 +195,7 @@
entry = frame.find(ANDROID_STATISTICS_FACE_RECTANGLES);
if (entry.count == 0) {
// No faces this frame
- /* warning: locks SharedCameraClient */
+ /* warning: locks SharedCameraCallbacks */
callbackFaceDetection(client, metadata);
return OK;
}
@@ -286,7 +286,7 @@
metadata.faces = faces.editArray();
}
- /* warning: locks SharedCameraClient */
+ /* warning: locks SharedCameraCallbacks */
callbackFaceDetection(client, metadata);
return OK;
@@ -297,9 +297,9 @@
/* Filter out repeated 0-face callbacks, but not when the last frame was >0 */
if (metadata.number_of_faces != 0 || mLastFrameNumberOfFaces != metadata.number_of_faces) {
- Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
- if (l.mCameraClient != NULL) {
- l.mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_METADATA,
+ Camera2Client::SharedCameraCallbacks::Lock l(client->mSharedCameraCallbacks);
+ if (l.mRemoteCallback != NULL) {
+ l.mRemoteCallback->dataCallback(CAMERA_MSG_PREVIEW_METADATA,
NULL, &metadata);
}
}
diff --git a/services/camera/libcameraservice/camera2/ProFrameProcessor.cpp b/services/camera/libcameraservice/camera2/ProFrameProcessor.cpp
index 8d4933c..742577a 100644
--- a/services/camera/libcameraservice/camera2/ProFrameProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/ProFrameProcessor.cpp
@@ -22,7 +22,7 @@
#include <utils/Trace.h>
#include "ProFrameProcessor.h"
-#include "../Camera2Device.h"
+#include "../CameraDeviceBase.h"
#include "../ProCamera2Client.h"
namespace android {
@@ -62,7 +62,7 @@
return OK;
}
-void ProFrameProcessor::dump(int fd, const Vector<String16>& args) {
+void ProFrameProcessor::dump(int fd, const Vector<String16>& /*args*/) {
String8 result(" Latest received frame:\n");
write(fd, result.string(), result.size());
mLastFrame.dump(fd, 2, 6);
@@ -71,7 +71,7 @@
bool ProFrameProcessor::threadLoop() {
status_t res;
- sp<Camera2Device> device;
+ sp<CameraDeviceBase> device;
{
sp<ProCamera2Client> client = mClient.promote();
if (client == 0) return false;
@@ -125,7 +125,6 @@
status_t ProFrameProcessor::processListeners(const CameraMetadata &frame,
sp<ProCamera2Client> &client) {
- status_t res;
ATRACE_CALL();
camera_metadata_ro_entry_t entry;
diff --git a/services/camera/libcameraservice/camera2/StreamingProcessor.cpp b/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
index 6a4b95d..fbc5b93 100644
--- a/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
@@ -556,9 +556,9 @@
}
// Call outside locked parameters to allow re-entrancy from notification
- Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
- if (l.mCameraClient != 0) {
- l.mCameraClient->dataCallbackTimestamp(timestamp,
+ Camera2Client::SharedCameraCallbacks::Lock l(client->mSharedCameraCallbacks);
+ if (l.mRemoteCallback != 0) {
+ l.mRemoteCallback->dataCallbackTimestamp(timestamp,
CAMERA_MSG_VIDEO_FRAME,
recordingHeap->mBuffers[heapIdx]);
}