summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioMixer.cpp6
-rw-r--r--services/camera/libcameraservice/Android.mk2
-rw-r--r--services/camera/libcameraservice/Camera2Client.cpp28
-rw-r--r--services/camera/libcameraservice/Camera2Client.h20
-rw-r--r--services/camera/libcameraservice/Camera2Device.cpp65
-rw-r--r--services/camera/libcameraservice/Camera2Device.h199
-rw-r--r--services/camera/libcameraservice/Camera3Device.cpp375
-rw-r--r--services/camera/libcameraservice/Camera3Device.h133
-rw-r--r--services/camera/libcameraservice/CameraClient.h5
-rw-r--r--services/camera/libcameraservice/CameraDeviceBase.cpp30
-rw-r--r--services/camera/libcameraservice/CameraDeviceBase.h204
-rw-r--r--services/camera/libcameraservice/CameraHardwareInterface.h19
-rw-r--r--services/camera/libcameraservice/CameraService.cpp136
-rw-r--r--services/camera/libcameraservice/CameraService.h37
-rw-r--r--services/camera/libcameraservice/ProCamera2Client.cpp68
-rw-r--r--services/camera/libcameraservice/ProCamera2Client.h5
-rw-r--r--services/camera/libcameraservice/camera2/CallbackProcessor.cpp6
-rw-r--r--services/camera/libcameraservice/camera2/FrameProcessor.cpp4
-rw-r--r--services/camera/libcameraservice/camera2/JpegProcessor.cpp6
-rw-r--r--services/camera/libcameraservice/camera2/StreamingProcessor.cpp12
-rw-r--r--services/camera/libcameraservice/camera2/ZslProcessor.cpp12
-rw-r--r--services/camera/libcameraservice/camera2/ZslProcessor.h4
22 files changed, 1117 insertions, 259 deletions
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index 2a8a955..17b6a8a 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -1113,12 +1113,6 @@ void AudioMixer::process__genericNoResampling(state_t* state, int64_t pts)
e0 &= ~(1<<i);
track_t& t = state->tracks[i];
t.buffer.frameCount = state->frameCount;
- int valid = t.bufferProvider->getValid();
- if (valid != AudioBufferProvider::kValid) {
- ALOGE("invalid bufferProvider=%p name=%d frameCount=%d valid=%#x enabledTracks=%#x",
- t.bufferProvider, i, t.buffer.frameCount, valid, enabledTracks);
- // expect to crash
- }
t.bufferProvider->getNextBuffer(&t.buffer, pts);
t.frameCount = t.buffer.frameCount;
t.in = t.buffer.raw;
diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk
index f76c861..d6ad889 100644
--- a/services/camera/libcameraservice/Android.mk
+++ b/services/camera/libcameraservice/Android.mk
@@ -11,7 +11,9 @@ LOCAL_SRC_FILES:= \
CameraClient.cpp \
Camera2Client.cpp \
ProCamera2Client.cpp \
+ CameraDeviceBase.cpp \
Camera2Device.cpp \
+ Camera3Device.cpp \
camera2/Parameters.cpp \
camera2/FrameProcessor.cpp \
camera2/StreamingProcessor.cpp \
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
index 38d6949..8295905 100644
--- a/services/camera/libcameraservice/Camera2Client.cpp
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -25,6 +25,8 @@
#include <gui/Surface.h>
#include "camera2/Parameters.h"
#include "Camera2Client.h"
+#include "Camera2Device.h"
+#include "Camera3Device.h"
#define ALOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
#define ALOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
@@ -45,7 +47,8 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
int cameraFacing,
int clientPid,
uid_t clientUid,
- int servicePid):
+ int servicePid,
+ int deviceVersion):
Client(cameraService, cameraClient, clientPackageName,
cameraId, cameraFacing, clientPid, clientUid, servicePid),
mSharedCameraClient(cameraClient),
@@ -54,7 +57,20 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
ATRACE_CALL();
ALOGI("Camera %d: Opened", cameraId);
- mDevice = new Camera2Device(cameraId);
+ switch (deviceVersion) {
+ case CAMERA_DEVICE_API_VERSION_2_0:
+ mDevice = new Camera2Device(cameraId);
+ break;
+ case CAMERA_DEVICE_API_VERSION_3_0:
+ mDevice = new Camera3Device(cameraId);
+ break;
+ default:
+ ALOGE("Camera %d: Unknown HAL device version %d",
+ cameraId, deviceVersion);
+ mDevice = NULL;
+ break;
+ }
+
SharedParameters::Lock l(mParameters);
l.mParameters.state = Parameters::DISCONNECTED;
@@ -81,6 +97,12 @@ status_t Camera2Client::initialize(camera_module_t *module)
return res;
}
+ if (mDevice == NULL) {
+ ALOGE("%s: Camera %d: No device connected",
+ __FUNCTION__, mCameraId);
+ return NO_INIT;
+ }
+
res = mDevice->initialize(module);
if (res != OK) {
ALOGE("%s: Camera %d: unable to initialize device: %s (%d)",
@@ -1465,7 +1487,7 @@ int Camera2Client::getCameraId() const {
return mCameraId;
}
-const sp<Camera2Device>& Camera2Client::getCameraDevice() {
+const sp<CameraDeviceBase>& Camera2Client::getCameraDevice() {
return mDevice;
}
diff --git a/services/camera/libcameraservice/Camera2Client.h b/services/camera/libcameraservice/Camera2Client.h
index 173b65e..80b88f4 100644
--- a/services/camera/libcameraservice/Camera2Client.h
+++ b/services/camera/libcameraservice/Camera2Client.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H
#define ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H
-#include "Camera2Device.h"
+#include "CameraDeviceBase.h"
#include "CameraService.h"
#include "camera2/Parameters.h"
#include "camera2/FrameProcessor.h"
@@ -31,12 +31,12 @@ namespace android {
class IMemory;
/**
- * Implements the android.hardware.camera API on top of
- * camera device HAL version 2.
+ * Interface between android.hardware.Camera API and Camera HAL device for versions
+ * CAMERA_DEVICE_API_VERSION_2_0 and 3_0.
*/
class Camera2Client :
public CameraService::Client,
- public Camera2Device::NotificationListener
+ public CameraDeviceBase::NotificationListener
{
public:
/**
@@ -77,7 +77,9 @@ public:
int cameraFacing,
int clientPid,
uid_t clientUid,
- int servicePid);
+ int servicePid,
+ int deviceVersion);
+
virtual ~Camera2Client();
status_t initialize(camera_module_t *module);
@@ -85,7 +87,7 @@ public:
virtual status_t dump(int fd, const Vector<String16>& args);
/**
- * Interface used by Camera2Device
+ * Interface used by CameraDeviceBase
*/
virtual void notifyError(int errorCode, int arg1, int arg2);
@@ -99,7 +101,7 @@ public:
*/
int getCameraId() const;
- const sp<Camera2Device>& getCameraDevice();
+ const sp<CameraDeviceBase>& getCameraDevice();
const sp<CameraService>& getCameraService();
camera2::SharedParameters& getParameters();
@@ -211,9 +213,9 @@ private:
bool mAfInMotion;
- /** Camera2Device instance wrapping HAL2 entry */
+ /** CameraDevice instance, wraps HAL camera device */
- sp<Camera2Device> mDevice;
+ sp<CameraDeviceBase> mDevice;
/** Utility members */
diff --git a/services/camera/libcameraservice/Camera2Device.cpp b/services/camera/libcameraservice/Camera2Device.cpp
index 921c8fc..81e58ca 100644
--- a/services/camera/libcameraservice/Camera2Device.cpp
+++ b/services/camera/libcameraservice/Camera2Device.cpp
@@ -34,7 +34,7 @@ namespace android {
Camera2Device::Camera2Device(int id):
mId(id),
- mDevice(NULL)
+ mHal2Device(NULL)
{
ATRACE_CALL();
ALOGV("%s: Created device for camera %d", __FUNCTION__, id);
@@ -51,7 +51,7 @@ status_t Camera2Device::initialize(camera_module_t *module)
{
ATRACE_CALL();
ALOGV("%s: Initializing device for camera %d", __FUNCTION__, mId);
- if (mDevice != NULL) {
+ if (mHal2Device != NULL) {
ALOGE("%s: Already initialized!", __FUNCTION__);
return INVALID_OPERATION;
}
@@ -131,7 +131,7 @@ status_t Camera2Device::initialize(camera_module_t *module)
}
mDeviceInfo = info.static_camera_characteristics;
- mDevice = device;
+ mHal2Device = device;
return OK;
}
@@ -139,23 +139,23 @@ status_t Camera2Device::initialize(camera_module_t *module)
status_t Camera2Device::disconnect() {
ATRACE_CALL();
status_t res = OK;
- if (mDevice) {
+ if (mHal2Device) {
ALOGV("%s: Closing device for camera %d", __FUNCTION__, mId);
- int inProgressCount = mDevice->ops->get_in_progress_count(mDevice);
+ int inProgressCount = mHal2Device->ops->get_in_progress_count(mHal2Device);
if (inProgressCount > 0) {
ALOGW("%s: Closing camera device %d with %d requests in flight!",
__FUNCTION__, mId, inProgressCount);
}
mReprocessStreams.clear();
mStreams.clear();
- res = mDevice->common.close(&mDevice->common);
+ res = mHal2Device->common.close(&mHal2Device->common);
if (res != OK) {
ALOGE("%s: Could not close camera %d: %s (%d)",
__FUNCTION__,
mId, strerror(-res), res);
}
- mDevice = NULL;
+ mHal2Device = NULL;
ALOGV("%s: Shutdown complete", __FUNCTION__);
}
return res;
@@ -197,7 +197,7 @@ status_t Camera2Device::dump(int fd, const Vector<String16>& args) {
write(fd, result.string(), result.size());
status_t res;
- res = mDevice->ops->dump(mDevice, fd);
+ res = mHal2Device->ops->dump(mHal2Device, fd);
return res;
}
@@ -240,7 +240,7 @@ status_t Camera2Device::createStream(sp<ANativeWindow> consumer,
status_t res;
ALOGV("%s: E", __FUNCTION__);
- sp<StreamAdapter> stream = new StreamAdapter(mDevice);
+ sp<StreamAdapter> stream = new StreamAdapter(mHal2Device);
res = stream->connectToDevice(consumer, width, height, format, size);
if (res != OK) {
@@ -276,7 +276,7 @@ status_t Camera2Device::createReprocessStreamFromStream(int outputId, int *id) {
return BAD_VALUE;
}
- sp<ReprocessStreamAdapter> stream = new ReprocessStreamAdapter(mDevice);
+ sp<ReprocessStreamAdapter> stream = new ReprocessStreamAdapter(mHal2Device);
res = stream->connectToDevice((*streamI));
if (res != OK) {
@@ -401,8 +401,8 @@ status_t Camera2Device::createDefaultRequest(int templateId,
status_t err;
ALOGV("%s: E", __FUNCTION__);
camera_metadata_t *rawRequest;
- err = mDevice->ops->construct_default_request(
- mDevice, templateId, &rawRequest);
+ err = mHal2Device->ops->construct_default_request(
+ mHal2Device, templateId, &rawRequest);
request->acquire(rawRequest);
return err;
}
@@ -417,12 +417,12 @@ status_t Camera2Device::waitUntilDrained() {
// TODO: Set up notifications from HAL, instead of sleeping here
uint32_t totalTime = 0;
- while (mDevice->ops->get_in_progress_count(mDevice) > 0) {
+ while (mHal2Device->ops->get_in_progress_count(mHal2Device) > 0) {
usleep(kSleepTime);
totalTime += kSleepTime;
if (totalTime > kMaxSleepTime) {
ALOGE("%s: Waited %d us, %d requests still in flight", __FUNCTION__,
- mDevice->ops->get_in_progress_count(mDevice), totalTime);
+ mHal2Device->ops->get_in_progress_count(mHal2Device), totalTime);
return TIMED_OUT;
}
}
@@ -433,7 +433,7 @@ status_t Camera2Device::waitUntilDrained() {
status_t Camera2Device::setNotifyCallback(NotificationListener *listener) {
ATRACE_CALL();
status_t res;
- res = mDevice->ops->set_notify_callback(mDevice, notificationCallback,
+ res = mHal2Device->ops->set_notify_callback(mHal2Device, notificationCallback,
reinterpret_cast<void*>(listener) );
if (res != OK) {
ALOGE("%s: Unable to set notification callback!", __FUNCTION__);
@@ -497,7 +497,7 @@ status_t Camera2Device::triggerAutofocus(uint32_t id) {
ATRACE_CALL();
status_t res;
ALOGV("%s: Triggering autofocus, id %d", __FUNCTION__, id);
- res = mDevice->ops->trigger_action(mDevice,
+ res = mHal2Device->ops->trigger_action(mHal2Device,
CAMERA2_TRIGGER_AUTOFOCUS, id, 0);
if (res != OK) {
ALOGE("%s: Error triggering autofocus (id %d)",
@@ -510,7 +510,7 @@ status_t Camera2Device::triggerCancelAutofocus(uint32_t id) {
ATRACE_CALL();
status_t res;
ALOGV("%s: Canceling autofocus, id %d", __FUNCTION__, id);
- res = mDevice->ops->trigger_action(mDevice,
+ res = mHal2Device->ops->trigger_action(mHal2Device,
CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, id, 0);
if (res != OK) {
ALOGE("%s: Error canceling autofocus (id %d)",
@@ -523,7 +523,7 @@ status_t Camera2Device::triggerPrecaptureMetering(uint32_t id) {
ATRACE_CALL();
status_t res;
ALOGV("%s: Triggering precapture metering, id %d", __FUNCTION__, id);
- res = mDevice->ops->trigger_action(mDevice,
+ res = mHal2Device->ops->trigger_action(mHal2Device,
CAMERA2_TRIGGER_PRECAPTURE_METERING, id, 0);
if (res != OK) {
ALOGE("%s: Error triggering precapture metering (id %d)",
@@ -560,18 +560,11 @@ status_t Camera2Device::pushReprocessBuffer(int reprocessStreamId,
}
/**
- * Camera2Device::NotificationListener
- */
-
-Camera2Device::NotificationListener::~NotificationListener() {
-}
-
-/**
* Camera2Device::MetadataQueue
*/
Camera2Device::MetadataQueue::MetadataQueue():
- mDevice(NULL),
+ mHal2Device(NULL),
mFrameCount(0),
mLatestRequestId(0),
mCount(0),
@@ -602,7 +595,7 @@ status_t Camera2Device::MetadataQueue::setConsumerDevice(camera2_device_t *d) {
res = d->ops->set_request_queue_src_ops(d,
this);
if (res != OK) return res;
- mDevice = d;
+ mHal2Device = d;
return OK;
}
@@ -835,12 +828,12 @@ status_t Camera2Device::MetadataQueue::signalConsumerLocked() {
ATRACE_CALL();
status_t res = OK;
notEmpty.signal();
- if (mSignalConsumer && mDevice != NULL) {
+ if (mSignalConsumer && mHal2Device != NULL) {
mSignalConsumer = false;
mMutex.unlock();
ALOGV("%s: Signaling consumer", __FUNCTION__);
- res = mDevice->ops->notify_request_queue_not_empty(mDevice);
+ res = mHal2Device->ops->notify_request_queue_not_empty(mHal2Device);
mMutex.lock();
}
return res;
@@ -939,7 +932,7 @@ int Camera2Device::MetadataQueue::producer_enqueue(
Camera2Device::StreamAdapter::StreamAdapter(camera2_device_t *d):
mState(RELEASED),
- mDevice(d),
+ mHal2Device(d),
mId(-1),
mWidth(0), mHeight(0), mFormat(0), mSize(0), mUsage(0),
mMaxProducerBuffers(0), mMaxConsumerBuffers(0),
@@ -990,7 +983,7 @@ status_t Camera2Device::StreamAdapter::connectToDevice(
uint32_t formatActual;
uint32_t usage;
uint32_t maxBuffers = 2;
- res = mDevice->ops->allocate_stream(mDevice,
+ res = mHal2Device->ops->allocate_stream(mHal2Device,
mWidth, mHeight, mFormatRequested, getStreamOps(),
&id, &formatActual, &usage, &maxBuffers);
if (res != OK) {
@@ -1106,7 +1099,7 @@ status_t Camera2Device::StreamAdapter::connectToDevice(
}
ALOGV("%s: Registering %d buffers with camera HAL", __FUNCTION__, mTotalBuffers);
- res = mDevice->ops->register_stream_buffers(mDevice,
+ res = mHal2Device->ops->register_stream_buffers(mHal2Device,
mId,
mTotalBuffers,
buffers);
@@ -1138,7 +1131,7 @@ status_t Camera2Device::StreamAdapter::release() {
status_t res;
ALOGV("%s: Releasing stream %d", __FUNCTION__, mId);
if (mState >= ALLOCATED) {
- res = mDevice->ops->release_stream(mDevice, mId);
+ res = mHal2Device->ops->release_stream(mHal2Device, mId);
if (res != OK) {
ALOGE("%s: Unable to release stream %d",
__FUNCTION__, mId);
@@ -1319,7 +1312,7 @@ int Camera2Device::StreamAdapter::set_crop(const camera2_stream_ops_t* w,
Camera2Device::ReprocessStreamAdapter::ReprocessStreamAdapter(camera2_device_t *d):
mState(RELEASED),
- mDevice(d),
+ mHal2Device(d),
mId(-1),
mWidth(0), mHeight(0), mFormat(0),
mActiveBuffers(0),
@@ -1361,7 +1354,7 @@ status_t Camera2Device::ReprocessStreamAdapter::connectToDevice(
// Allocate device-side stream interface
uint32_t id;
- res = mDevice->ops->allocate_reprocess_stream_from_stream(mDevice,
+ res = mHal2Device->ops->allocate_reprocess_stream_from_stream(mHal2Device,
outputStream->getId(), getStreamOps(),
&id);
if (res != OK) {
@@ -1385,7 +1378,7 @@ status_t Camera2Device::ReprocessStreamAdapter::release() {
status_t res;
ALOGV("%s: Releasing stream %d", __FUNCTION__, mId);
if (mState >= ACTIVE) {
- res = mDevice->ops->release_reprocess_stream(mDevice, mId);
+ res = mHal2Device->ops->release_reprocess_stream(mHal2Device, mId);
if (res != OK) {
ALOGE("%s: Unable to release stream %d",
__FUNCTION__, mId);
diff --git a/services/camera/libcameraservice/Camera2Device.h b/services/camera/libcameraservice/Camera2Device.h
index 86ff80f..1adb7a9 100644
--- a/services/camera/libcameraservice/Camera2Device.h
+++ b/services/camera/libcameraservice/Camera2Device.h
@@ -21,184 +21,53 @@
#include <utils/Errors.h>
#include <utils/List.h>
#include <utils/Mutex.h>
-#include <utils/RefBase.h>
-#include <utils/String8.h>
-#include <utils/String16.h>
-#include <utils/Vector.h>
-#include "hardware/camera2.h"
-#include "camera/CameraMetadata.h"
+#include "CameraDeviceBase.h"
namespace android {
-class Camera2Device : public virtual RefBase {
+/**
+ * CameraDevice for HAL devices with version CAMERA_DEVICE_API_VERSION_2_0
+ */
+class Camera2Device: public CameraDeviceBase {
public:
Camera2Device(int id);
- ~Camera2Device();
-
- status_t initialize(camera_module_t *module);
- status_t disconnect();
-
- status_t dump(int fd, const Vector<String16>& args);
-
- /**
- * The device's static characteristics metadata buffer
- */
- const CameraMetadata& info() const;
-
- /**
- * Submit request for capture. The Camera2Device takes ownership of the
- * passed-in buffer.
- */
- status_t capture(CameraMetadata &request);
-
- /**
- * Submit request for streaming. The Camera2Device makes a copy of the
- * passed-in buffer and the caller retains ownership.
- */
- status_t setStreamingRequest(const CameraMetadata &request);
-
- /**
- * Clear the streaming request slot.
- */
- status_t clearStreamingRequest();
-
- /**
- * Wait until a request with the given ID has been dequeued by the
- * HAL. Returns TIMED_OUT if the timeout duration is reached. Returns
- * immediately if the latest request received by the HAL has this id.
- */
- status_t waitUntilRequestReceived(int32_t requestId, nsecs_t timeout);
+ virtual ~Camera2Device();
/**
- * Create an output stream of the requested size and format.
- *
- * If format is CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, then the HAL device selects
- * an appropriate format; it can be queried with getStreamInfo.
- *
- * If format is HAL_PIXEL_FORMAT_COMPRESSED, the size parameter must be
- * equal to the size in bytes of the buffers to allocate for the stream. For
- * other formats, the size parameter is ignored.
+ * CameraDevice interface
*/
- status_t createStream(sp<ANativeWindow> consumer,
+ virtual status_t initialize(camera_module_t *module);
+ virtual status_t disconnect();
+ virtual status_t dump(int fd, const Vector<String16>& args);
+ virtual const CameraMetadata& info() const;
+ virtual status_t capture(CameraMetadata &request);
+ virtual status_t setStreamingRequest(const CameraMetadata &request);
+ virtual status_t clearStreamingRequest();
+ virtual status_t waitUntilRequestReceived(int32_t requestId, nsecs_t timeout);
+ virtual status_t createStream(sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, int format, size_t size,
int *id);
-
- /**
- * Create an input reprocess stream that uses buffers from an existing
- * output stream.
- */
- status_t createReprocessStreamFromStream(int outputId, int *id);
-
- /**
- * Get information about a given stream.
- */
- status_t getStreamInfo(int id,
+ virtual status_t createReprocessStreamFromStream(int outputId, int *id);
+ virtual status_t getStreamInfo(int id,
uint32_t *width, uint32_t *height, uint32_t *format);
-
- /**
- * Set stream gralloc buffer transform
- */
- status_t setStreamTransform(int id, int transform);
-
- /**
- * Delete stream. Must not be called if there are requests in flight which
- * reference that stream.
- */
- status_t deleteStream(int id);
-
- /**
- * Delete reprocess stream. Must not be called if there are requests in
- * flight which reference that stream.
- */
- status_t deleteReprocessStream(int id);
-
- /**
- * Create a metadata buffer with fields that the HAL device believes are
- * best for the given use case
- */
- status_t createDefaultRequest(int templateId, CameraMetadata *request);
-
- /**
- * Wait until all requests have been processed. Returns INVALID_OPERATION if
- * the streaming slot is not empty, or TIMED_OUT if the requests haven't
- * finished processing in 10 seconds.
- */
- status_t waitUntilDrained();
-
- /**
- * Abstract class for HAL notification listeners
- */
- class NotificationListener {
- public:
- // Refer to the Camera2 HAL definition for notification definitions
- virtual void notifyError(int errorCode, int arg1, int arg2) = 0;
- virtual void notifyShutter(int frameNumber, nsecs_t timestamp) = 0;
- virtual void notifyAutoFocus(uint8_t newState, int triggerId) = 0;
- virtual void notifyAutoExposure(uint8_t newState, int triggerId) = 0;
- virtual void notifyAutoWhitebalance(uint8_t newState, int triggerId) = 0;
- protected:
- virtual ~NotificationListener();
- };
-
- /**
- * Connect HAL notifications to a listener. Overwrites previous
- * listener. Set to NULL to stop receiving notifications.
- */
- status_t setNotifyCallback(NotificationListener *listener);
-
- /**
- * Wait for a new frame to be produced, with timeout in nanoseconds.
- * Returns TIMED_OUT when no frame produced within the specified duration
- */
- status_t waitForNextFrame(nsecs_t timeout);
-
- /**
- * Get next metadata frame from the frame queue. Returns NULL if the queue
- * is empty; caller takes ownership of the metadata buffer.
- */
- status_t getNextFrame(CameraMetadata *frame);
-
- /**
- * Trigger auto-focus. The latest ID used in a trigger autofocus or cancel
- * autofocus call will be returned by the HAL in all subsequent AF
- * notifications.
- */
- status_t triggerAutofocus(uint32_t id);
-
- /**
- * Cancel auto-focus. The latest ID used in a trigger autofocus/cancel
- * autofocus call will be returned by the HAL in all subsequent AF
- * notifications.
- */
- status_t triggerCancelAutofocus(uint32_t id);
-
- /**
- * Trigger pre-capture metering. The latest ID used in a trigger pre-capture
- * call will be returned by the HAL in all subsequent AE and AWB
- * notifications.
- */
- status_t triggerPrecaptureMetering(uint32_t id);
-
- /**
- * Abstract interface for clients that want to listen to reprocess buffer
- * release events
- */
- struct BufferReleasedListener: public virtual RefBase {
- virtual void onBufferReleased(buffer_handle_t *handle) = 0;
- };
-
- /**
- * Push a buffer to be reprocessed into a reprocessing stream, and
- * provide a listener to call once the buffer is returned by the HAL
- */
- status_t pushReprocessBuffer(int reprocessStreamId,
+ virtual status_t setStreamTransform(int id, int transform);
+ virtual status_t deleteStream(int id);
+ virtual status_t deleteReprocessStream(int id);
+ virtual status_t createDefaultRequest(int templateId, CameraMetadata *request);
+ virtual status_t waitUntilDrained();
+ virtual status_t setNotifyCallback(NotificationListener *listener);
+ virtual status_t waitForNextFrame(nsecs_t timeout);
+ virtual status_t getNextFrame(CameraMetadata *frame);
+ virtual status_t triggerAutofocus(uint32_t id);
+ virtual status_t triggerCancelAutofocus(uint32_t id);
+ virtual status_t triggerPrecaptureMetering(uint32_t id);
+ virtual status_t pushReprocessBuffer(int reprocessStreamId,
buffer_handle_t *buffer, wp<BufferReleasedListener> listener);
-
private:
const int mId;
- camera2_device_t *mDevice;
+ camera2_device_t *mHal2Device;
CameraMetadata mDeviceInfo;
vendor_tag_query_ops_t *mVendorTagOps;
@@ -249,7 +118,7 @@ class Camera2Device : public virtual RefBase {
status_t freeBuffers(List<camera_metadata_t*>::iterator start,
List<camera_metadata_t*>::iterator end);
- camera2_device_t *mDevice;
+ camera2_device_t *mHal2Device;
Mutex mMutex;
Condition notEmpty;
@@ -341,7 +210,7 @@ class Camera2Device : public virtual RefBase {
} mState;
sp<ANativeWindow> mConsumerInterface;
- camera2_device_t *mDevice;
+ camera2_device_t *mHal2Device;
uint32_t mId;
uint32_t mWidth;
@@ -435,7 +304,7 @@ class Camera2Device : public virtual RefBase {
List<QueueEntry> mInFlightQueue;
- camera2_device_t *mDevice;
+ camera2_device_t *mHal2Device;
uint32_t mId;
uint32_t mWidth;
diff --git a/services/camera/libcameraservice/Camera3Device.cpp b/services/camera/libcameraservice/Camera3Device.cpp
new file mode 100644
index 0000000..2a1be09
--- /dev/null
+++ b/services/camera/libcameraservice/Camera3Device.cpp
@@ -0,0 +1,375 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "Camera3-Device"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+//#define LOG_NNDEBUG 0 // Per-frame verbose logging
+
+#ifdef LOG_NNDEBUG
+#define ALOGVV(...) ALOGV(__VA_ARGS__)
+#else
+#define ALOGVV(...) ((void)0)
+#endif
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+#include <utils/Timers.h>
+#include "Camera3Device.h"
+
+namespace android {
+
+
+Camera3Device::Camera3Device(int id):
+ mId(id),
+ mHal3Device(NULL)
+{
+ ATRACE_CALL();
+ camera3_callback_ops::notify = &sNotify;
+ camera3_callback_ops::process_capture_result = &sProcessCaptureResult;
+ ALOGV("%s: Created device for camera %d", __FUNCTION__, id);
+}
+
+Camera3Device::~Camera3Device()
+{
+ ATRACE_CALL();
+ ALOGV("%s: Tearing down for camera id %d", __FUNCTION__, mId);
+ disconnect();
+}
+
+status_t Camera3Device::initialize(camera_module_t *module)
+{
+ ATRACE_CALL();
+ ALOGV("%s: Initializing device for camera %d", __FUNCTION__, mId);
+ if (mHal3Device != NULL) {
+ ALOGE("%s: Already initialized!", __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+
+ /** Open HAL device */
+
+ status_t res;
+ String8 deviceName = String8::format("%d", mId);
+
+ camera3_device_t *device;
+
+ res = module->common.methods->open(&module->common, deviceName.string(),
+ reinterpret_cast<hw_device_t**>(&device));
+
+ if (res != OK) {
+ ALOGE("%s: Could not open camera %d: %s (%d)", __FUNCTION__,
+ mId, strerror(-res), res);
+ return res;
+ }
+
+ /** Cross-check device version */
+
+ if (device->common.version != CAMERA_DEVICE_API_VERSION_3_0) {
+ ALOGE("%s: Could not open camera %d: "
+ "Camera device is not version %x, reports %x instead",
+ __FUNCTION__, mId, CAMERA_DEVICE_API_VERSION_3_0,
+ device->common.version);
+ device->common.close(&device->common);
+ return BAD_VALUE;
+ }
+
+ camera_info info;
+ res = module->get_camera_info(mId, &info);
+ if (res != OK) return res;
+
+ if (info.device_version != device->common.version) {
+ ALOGE("%s: HAL reporting mismatched camera_info version (%x)"
+ " and device version (%x).", __FUNCTION__,
+ device->common.version, info.device_version);
+ device->common.close(&device->common);
+ return BAD_VALUE;
+ }
+
+ /** Initialize device with callback functions */
+
+ res = device->ops->initialize(device, this);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to initialize HAL device: %s (%d)",
+ __FUNCTION__, mId, strerror(-res), res);
+ device->common.close(&device->common);
+ return BAD_VALUE;
+ }
+
+ /** Get vendor metadata tags */
+
+ mVendorTagOps.get_camera_vendor_section_name = NULL;
+
+ device->ops->get_metadata_vendor_tag_ops(device, &mVendorTagOps);
+
+ if (mVendorTagOps.get_camera_vendor_section_name != NULL) {
+ res = set_camera_metadata_vendor_tag_ops(&mVendorTagOps);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to set tag ops: %s (%d)",
+ __FUNCTION__, mId, strerror(-res), res);
+ device->common.close(&device->common);
+ return res;
+ }
+ }
+
+ /** Start up request queue thread */
+
+ requestThread = new RequestThread(this);
+ res = requestThread->run(String8::format("C3Dev-%d-ReqQueue", mId).string());
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to start request queue thread: %s (%d)",
+ __FUNCTION__, mId, strerror(-res), res);
+ device->common.close(&device->common);
+ return res;
+ }
+
+ /** Everything is good to go */
+
+ mDeviceInfo = info.static_camera_characteristics;
+ mHal3Device = device;
+
+ return OK;
+}
+
+status_t Camera3Device::disconnect() {
+ ATRACE_CALL();
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::dump(int fd, const Vector<String16> &args) {
+ ATRACE_CALL();
+ (void)args;
+
+ mHal3Device->ops->dump(mHal3Device, fd);
+
+ return OK;
+}
+
+const CameraMetadata& Camera3Device::info() const {
+ ALOGVV("%s: E", __FUNCTION__);
+
+ return mDeviceInfo;
+}
+
+status_t Camera3Device::capture(CameraMetadata &request) {
+ ATRACE_CALL();
+ (void)request;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+
+status_t Camera3Device::setStreamingRequest(const CameraMetadata &request) {
+ ATRACE_CALL();
+ (void)request;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::clearStreamingRequest() {
+ ATRACE_CALL();
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::waitUntilRequestReceived(int32_t requestId, nsecs_t timeout) {
+ ATRACE_CALL();
+ (void)requestId; (void)timeout;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::createStream(sp<ANativeWindow> consumer,
+ uint32_t width, uint32_t height, int format, size_t size, int *id) {
+ ATRACE_CALL();
+ (void)consumer; (void)width; (void)height; (void)format;
+ (void)size; (void)id;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::createReprocessStreamFromStream(int outputId, int *id) {
+ ATRACE_CALL();
+ (void)outputId; (void)id;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+
+status_t Camera3Device::getStreamInfo(int id,
+ uint32_t *width, uint32_t *height, uint32_t *format) {
+ ATRACE_CALL();
+ (void)id; (void)width; (void)height; (void)format;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::setStreamTransform(int id,
+ int transform) {
+ ATRACE_CALL();
+ (void)id; (void)transform;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::deleteStream(int id) {
+ ATRACE_CALL();
+ (void)id;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::deleteReprocessStream(int id) {
+ ATRACE_CALL();
+ (void)id;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+
+status_t Camera3Device::createDefaultRequest(int templateId,
+ CameraMetadata *request) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+
+ const camera_metadata_t *rawRequest;
+ rawRequest = mHal3Device->ops->construct_default_request_settings(
+ mHal3Device, templateId);
+ if (rawRequest == NULL) return DEAD_OBJECT;
+ *request = rawRequest;
+
+ return OK;
+}
+
+status_t Camera3Device::waitUntilDrained() {
+ ATRACE_CALL();
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::setNotifyCallback(NotificationListener *listener) {
+ ATRACE_CALL();
+ (void)listener;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::waitForNextFrame(nsecs_t timeout) {
+ (void)timeout;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::getNextFrame(CameraMetadata *frame) {
+ ATRACE_CALL();
+ (void)frame;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::triggerAutofocus(uint32_t id) {
+ ATRACE_CALL();
+ (void)id;
+
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+status_t Camera3Device::triggerCancelAutofocus(uint32_t id) {
+ ATRACE_CALL();
+ (void)id;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+
+}
+
+status_t Camera3Device::triggerPrecaptureMetering(uint32_t id) {
+ ATRACE_CALL();
+ (void)id;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+
+}
+
+status_t Camera3Device::pushReprocessBuffer(int reprocessStreamId,
+ buffer_handle_t *buffer, wp<BufferReleasedListener> listener) {
+ ATRACE_CALL();
+ (void)reprocessStreamId; (void)buffer; (void)listener;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+ return INVALID_OPERATION;
+}
+
+Camera3Device::RequestThread::RequestThread(wp<Camera3Device> parent) :
+ Thread(false),
+ mParent(parent) {
+}
+
+bool Camera3Device::RequestThread::threadLoop() {
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+
+ return false;
+}
+
+void Camera3Device::processCaptureResult(const camera3_capture_result *result) {
+ (void)result;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+}
+
+void Camera3Device::notify(const camera3_notify_msg *msg) {
+ (void)msg;
+
+ ALOGE("%s: Unimplemented", __FUNCTION__);
+}
+
+/**
+ * Static callback forwarding methods from HAL to instance
+ */
+
+void Camera3Device::sProcessCaptureResult(const camera3_callback_ops *cb,
+ const camera3_capture_result *result) {
+ Camera3Device *d =
+ const_cast<Camera3Device*>(static_cast<const Camera3Device*>(cb));
+ d->processCaptureResult(result);
+}
+
+void Camera3Device::sNotify(const camera3_callback_ops *cb,
+ const camera3_notify_msg *msg) {
+ Camera3Device *d =
+ const_cast<Camera3Device*>(static_cast<const Camera3Device*>(cb));
+ d->notify(msg);
+}
+
+}; // namespace android
diff --git a/services/camera/libcameraservice/Camera3Device.h b/services/camera/libcameraservice/Camera3Device.h
new file mode 100644
index 0000000..2bc7cf0
--- /dev/null
+++ b/services/camera/libcameraservice/Camera3Device.h
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SERVERS_CAMERA_CAMERA3DEVICE_H
+#define ANDROID_SERVERS_CAMERA_CAMERA3DEVICE_H
+
+#include <utils/Condition.h>
+#include <utils/Errors.h>
+#include <utils/List.h>
+#include <utils/Mutex.h>
+#include <utils/Thread.h>
+
+#include "CameraDeviceBase.h"
+
+#include "hardware/camera3.h"
+
+/**
+ * Function pointer types with C calling convention to
+ * use for HAL callback functions.
+ */
+extern "C" {
+ typedef void (callbacks_process_capture_result_t)(
+ const struct camera3_callback_ops *,
+ const camera3_capture_result_t *);
+
+ typedef void (callbacks_notify_t)(
+ const struct camera3_callback_ops *,
+ const camera3_notify_msg_t *);
+}
+
+namespace android {
+
+/**
+ * CameraDevice for HAL devices with version CAMERA_DEVICE_API_VERSION_3_0
+ */
+class Camera3Device :
+ public CameraDeviceBase,
+ private camera3_callback_ops {
+ public:
+ Camera3Device(int id);
+
+ virtual ~Camera3Device();
+
+ /**
+ * CameraDevice interface
+ */
+ virtual status_t initialize(camera_module_t *module);
+ virtual status_t disconnect();
+ virtual status_t dump(int fd, const Vector<String16> &args);
+ virtual const CameraMetadata& info() const;
+ virtual status_t capture(CameraMetadata &request);
+ virtual status_t setStreamingRequest(const CameraMetadata &request);
+ virtual status_t clearStreamingRequest();
+ virtual status_t waitUntilRequestReceived(int32_t requestId, nsecs_t timeout);
+ virtual status_t createStream(sp<ANativeWindow> consumer,
+ uint32_t width, uint32_t height, int format, size_t size,
+ int *id);
+ virtual status_t createReprocessStreamFromStream(int outputId, int *id);
+ virtual status_t getStreamInfo(int id,
+ uint32_t *width, uint32_t *height, uint32_t *format);
+ virtual status_t setStreamTransform(int id, int transform);
+ virtual status_t deleteStream(int id);
+ virtual status_t deleteReprocessStream(int id);
+ virtual status_t createDefaultRequest(int templateId, CameraMetadata *request);
+ virtual status_t waitUntilDrained();
+ virtual status_t setNotifyCallback(NotificationListener *listener);
+ virtual status_t waitForNextFrame(nsecs_t timeout);
+ virtual status_t getNextFrame(CameraMetadata *frame);
+ virtual status_t triggerAutofocus(uint32_t id);
+ virtual status_t triggerCancelAutofocus(uint32_t id);
+ virtual status_t triggerPrecaptureMetering(uint32_t id);
+ virtual status_t pushReprocessBuffer(int reprocessStreamId,
+ buffer_handle_t *buffer, wp<BufferReleasedListener> listener);
+
+ private:
+ const int mId;
+ camera3_device_t *mHal3Device;
+
+ CameraMetadata mDeviceInfo;
+ vendor_tag_query_ops_t mVendorTagOps;
+
+ /**
+ * Thread for managing capture request submission to HAL device.
+ */
+ class RequestThread: public Thread {
+
+ public:
+
+ RequestThread(wp<Camera3Device> parent);
+
+ protected:
+
+ virtual bool threadLoop();
+
+ private:
+
+ wp<Camera3Device> mParent;
+
+ };
+ sp<RequestThread> requestThread;
+
+ /**
+ * Callback functions from HAL device
+ */
+ void processCaptureResult(const camera3_capture_result *result);
+
+ void notify(const camera3_notify_msg *msg);
+
+ /**
+ * Static callback forwarding methods from HAL to instance
+ */
+ static callbacks_process_capture_result_t sProcessCaptureResult;
+
+ static callbacks_notify_t sNotify;
+
+}; // class Camera3Device
+
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/CameraClient.h b/services/camera/libcameraservice/CameraClient.h
index 00dc90c..7f0cb29 100644
--- a/services/camera/libcameraservice/CameraClient.h
+++ b/services/camera/libcameraservice/CameraClient.h
@@ -24,6 +24,11 @@ namespace android {
class MemoryHeapBase;
class CameraHardwareInterface;
+/**
+ * Interface between android.hardware.Camera API and Camera HAL device for version
+ * CAMERA_DEVICE_API_VERSION_1_0.
+ */
+
class CameraClient : public CameraService::Client
{
public:
diff --git a/services/camera/libcameraservice/CameraDeviceBase.cpp b/services/camera/libcameraservice/CameraDeviceBase.cpp
new file mode 100644
index 0000000..6c4e87f
--- /dev/null
+++ b/services/camera/libcameraservice/CameraDeviceBase.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CameraDeviceBase.h"
+
+namespace android {
+
+/**
+ * Base class destructors
+ */
+CameraDeviceBase::~CameraDeviceBase() {
+}
+
+CameraDeviceBase::NotificationListener::~NotificationListener() {
+}
+
+} // namespace android
diff --git a/services/camera/libcameraservice/CameraDeviceBase.h b/services/camera/libcameraservice/CameraDeviceBase.h
new file mode 100644
index 0000000..8252af7
--- /dev/null
+++ b/services/camera/libcameraservice/CameraDeviceBase.h
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SERVERS_CAMERA_CAMERADEVICEBASE_H
+#define ANDROID_SERVERS_CAMERA_CAMERADEVICEBASE_H
+
+#include <utils/RefBase.h>
+#include <utils/String8.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+#include <utils/Timers.h>
+
+#include "hardware/camera2.h"
+#include "camera/CameraMetadata.h"
+
+namespace android {
+
+/**
+ * Base interface for version >= 2 camera device classes, which interface to
+ * camera HAL device versions >= 2.
+ */
+class CameraDeviceBase : public virtual RefBase {
+ public:
+ virtual ~CameraDeviceBase();
+
+ virtual status_t initialize(camera_module_t *module) = 0;
+ virtual status_t disconnect() = 0;
+
+ virtual status_t dump(int fd, const Vector<String16>& args) = 0;
+
+ /**
+ * The device's static characteristics metadata buffer
+ */
+ virtual const CameraMetadata& info() const = 0;
+
+ /**
+ * Submit request for capture. The CameraDevice takes ownership of the
+ * passed-in buffer.
+ */
+ virtual status_t capture(CameraMetadata &request) = 0;
+
+ /**
+ * Submit request for streaming. The CameraDevice makes a copy of the
+ * passed-in buffer and the caller retains ownership.
+ */
+ virtual status_t setStreamingRequest(const CameraMetadata &request) = 0;
+
+ /**
+ * Clear the streaming request slot.
+ */
+ virtual status_t clearStreamingRequest() = 0;
+
+ /**
+ * Wait until a request with the given ID has been dequeued by the
+ * HAL. Returns TIMED_OUT if the timeout duration is reached. Returns
+ * immediately if the latest request received by the HAL has this id.
+ */
+ virtual status_t waitUntilRequestReceived(int32_t requestId,
+ nsecs_t timeout) = 0;
+
+ /**
+ * Create an output stream of the requested size and format.
+ *
+ * If format is CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, then the HAL device selects
+ * an appropriate format; it can be queried with getStreamInfo.
+ *
+ * If format is HAL_PIXEL_FORMAT_COMPRESSED, the size parameter must be
+ * equal to the size in bytes of the buffers to allocate for the stream. For
+ * other formats, the size parameter is ignored.
+ */
+ virtual status_t createStream(sp<ANativeWindow> consumer,
+ uint32_t width, uint32_t height, int format, size_t size,
+ int *id) = 0;
+
+ /**
+ * Create an input reprocess stream that uses buffers from an existing
+ * output stream.
+ */
+ virtual status_t createReprocessStreamFromStream(int outputId, int *id) = 0;
+
+ /**
+ * Get information about a given stream.
+ */
+ virtual status_t getStreamInfo(int id,
+ uint32_t *width, uint32_t *height, uint32_t *format) = 0;
+
+ /**
+ * Set stream gralloc buffer transform
+ */
+ virtual status_t setStreamTransform(int id, int transform) = 0;
+
+ /**
+ * Delete stream. Must not be called if there are requests in flight which
+ * reference that stream.
+ */
+ virtual status_t deleteStream(int id) = 0;
+
+ /**
+ * Delete reprocess stream. Must not be called if there are requests in
+ * flight which reference that stream.
+ */
+ virtual status_t deleteReprocessStream(int id) = 0;
+
+ /**
+ * Create a metadata buffer with fields that the HAL device believes are
+ * best for the given use case
+ */
+ virtual status_t createDefaultRequest(int templateId,
+ CameraMetadata *request) = 0;
+
+ /**
+ * Wait until all requests have been processed. Returns INVALID_OPERATION if
+ * the streaming slot is not empty, or TIMED_OUT if the requests haven't
+ * finished processing in 10 seconds.
+ */
+ virtual status_t waitUntilDrained() = 0;
+
+ /**
+ * Abstract class for HAL notification listeners
+ */
+ class NotificationListener {
+ public:
+ // Refer to the Camera2 HAL definition for notification definitions
+ virtual void notifyError(int errorCode, int arg1, int arg2) = 0;
+ virtual void notifyShutter(int frameNumber, nsecs_t timestamp) = 0;
+ virtual void notifyAutoFocus(uint8_t newState, int triggerId) = 0;
+ virtual void notifyAutoExposure(uint8_t newState, int triggerId) = 0;
+ virtual void notifyAutoWhitebalance(uint8_t newState,
+ int triggerId) = 0;
+ protected:
+ virtual ~NotificationListener();
+ };
+
+ /**
+ * Connect HAL notifications to a listener. Overwrites previous
+ * listener. Set to NULL to stop receiving notifications.
+ */
+ virtual status_t setNotifyCallback(NotificationListener *listener) = 0;
+
+ /**
+ * Wait for a new frame to be produced, with timeout in nanoseconds.
+ * Returns TIMED_OUT when no frame produced within the specified duration
+ */
+ virtual status_t waitForNextFrame(nsecs_t timeout) = 0;
+
+ /**
+ * Get next metadata frame from the frame queue. Returns NULL if the queue
+ * is empty; caller takes ownership of the metadata buffer.
+ */
+ virtual status_t getNextFrame(CameraMetadata *frame) = 0;
+
+ /**
+ * Trigger auto-focus. The latest ID used in a trigger autofocus or cancel
+ * autofocus call will be returned by the HAL in all subsequent AF
+ * notifications.
+ */
+ virtual status_t triggerAutofocus(uint32_t id) = 0;
+
+ /**
+ * Cancel auto-focus. The latest ID used in a trigger autofocus/cancel
+ * autofocus call will be returned by the HAL in all subsequent AF
+ * notifications.
+ */
+ virtual status_t triggerCancelAutofocus(uint32_t id) = 0;
+
+ /**
+ * Trigger pre-capture metering. The latest ID used in a trigger pre-capture
+ * call will be returned by the HAL in all subsequent AE and AWB
+ * notifications.
+ */
+ virtual status_t triggerPrecaptureMetering(uint32_t id) = 0;
+
+ /**
+ * Abstract interface for clients that want to listen to reprocess buffer
+ * release events
+ */
+ struct BufferReleasedListener : public virtual RefBase {
+ virtual void onBufferReleased(buffer_handle_t *handle) = 0;
+ };
+
+ /**
+ * Push a buffer to be reprocessed into a reprocessing stream, and
+ * provide a listener to call once the buffer is returned by the HAL
+ */
+ virtual status_t pushReprocessBuffer(int reprocessStreamId,
+ buffer_handle_t *buffer, wp<BufferReleasedListener> listener) = 0;
+};
+
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/CameraHardwareInterface.h b/services/camera/libcameraservice/CameraHardwareInterface.h
index 167b37c..87b2807 100644
--- a/services/camera/libcameraservice/CameraHardwareInterface.h
+++ b/services/camera/libcameraservice/CameraHardwareInterface.h
@@ -47,7 +47,8 @@ typedef void (*data_callback_timestamp)(nsecs_t timestamp,
/**
* CameraHardwareInterface.h defines the interface to the
* camera hardware abstraction layer, used for setting and getting
- * parameters, live previewing, and taking pictures.
+ * parameters, live previewing, and taking pictures. It is used for
+ * HAL devices with version CAMERA_DEVICE_API_VERSION_1_0 only.
*
* It is a referenced counted interface with RefBase as its base class.
* CameraService calls openCameraHardware() to retrieve a strong pointer to the
@@ -56,24 +57,18 @@ typedef void (*data_callback_timestamp)(nsecs_t timestamp,
*
* -# After CameraService calls openCameraHardware(), getParameters() and
* setParameters() are used to initialize the camera instance.
- * CameraService calls getPreviewHeap() to establish access to the
- * preview heap so it can be registered with SurfaceFlinger for
- * efficient display updating while in preview mode.
- * -# startPreview() is called. The camera instance then periodically
- * sends the message CAMERA_MSG_PREVIEW_FRAME (if enabled) each time
- * a new preview frame is available. If data callback code needs to use
- * this memory after returning, it must copy the data.
+ * -# startPreview() is called.
*
- * Prior to taking a picture, CameraService calls autofocus(). When auto
+ * Prior to taking a picture, CameraService often calls autofocus(). When auto
* focusing has completed, the camera instance sends a CAMERA_MSG_FOCUS notification,
* which informs the application whether focusing was successful. The camera instance
* only sends this message once and it is up to the application to call autoFocus()
* again if refocusing is desired.
*
* CameraService calls takePicture() to request the camera instance take a
- * picture. At this point, if a shutter, postview, raw, and/or compressed callback
- * is desired, the corresponding message must be enabled. As with CAMERA_MSG_PREVIEW_FRAME,
- * any memory provided in a data callback must be copied if it's needed after returning.
+ * picture. At this point, if a shutter, postview, raw, and/or compressed
+ * callback is desired, the corresponding message must be enabled. Any memory
+ * provided in a data callback must be copied if it's needed after returning.
*/
class CameraHardwareInterface : public virtual RefBase {
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index ec1c3f0..8c4f619 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -77,6 +77,10 @@ CameraService::CameraService()
{
ALOGI("CameraService started (pid=%d)", getpid());
gCameraService = this;
+
+ for (size_t i = 0; i < MAX_CAMERAS; ++i) {
+ mStatusList[i] = ICameraServiceListener::STATUS_AVAILABLE;
+ }
}
void CameraService::onFirstRef()
@@ -155,6 +159,23 @@ int CameraService::getDeviceVersion(int cameraId, int* facing) {
return deviceVersion;
}
+bool CameraService::isValidCameraId(int cameraId) {
+ int facing;
+ int deviceVersion = getDeviceVersion(cameraId, &facing);
+
+ switch(deviceVersion) {
+ case CAMERA_DEVICE_API_VERSION_1_0:
+ case CAMERA_DEVICE_API_VERSION_2_0:
+ case CAMERA_DEVICE_API_VERSION_2_1:
+ case CAMERA_DEVICE_API_VERSION_3_0:
+ return true;
+ default:
+ return false;
+ }
+
+ return false;
+}
+
sp<ICamera> CameraService::connect(
const sp<ICameraClient>& cameraClient,
int cameraId,
@@ -236,6 +257,10 @@ sp<ICamera> CameraService::connect(
int facing = -1;
int deviceVersion = getDeviceVersion(cameraId, &facing);
+ if (isValidCameraId(cameraId)) {
+ updateStatus(ICameraServiceListener::STATUS_NOT_AVAILABLE, cameraId);
+ }
+
switch(deviceVersion) {
case CAMERA_DEVICE_API_VERSION_1_0:
client = new CameraClient(this, cameraClient,
@@ -244,9 +269,11 @@ sp<ICamera> CameraService::connect(
break;
case CAMERA_DEVICE_API_VERSION_2_0:
case CAMERA_DEVICE_API_VERSION_2_1:
+ case CAMERA_DEVICE_API_VERSION_3_0:
client = new Camera2Client(this, cameraClient,
clientPackageName, cameraId,
- facing, callingPid, clientUid, getpid());
+ facing, callingPid, clientUid, getpid(),
+ deviceVersion);
break;
case -1:
ALOGE("Invalid camera id %d", cameraId);
@@ -257,6 +284,9 @@ sp<ICamera> CameraService::connect(
}
if (client->initialize(mModule) != OK) {
+ // this is probably not recoverable.. but maybe the client can try again
+ updateStatus(ICameraServiceListener::STATUS_AVAILABLE, cameraId);
+
return NULL;
}
@@ -264,15 +294,21 @@ sp<ICamera> CameraService::connect(
mClient[cameraId] = client;
LOG1("CameraService::connect X (id %d, this pid is %d)", cameraId, getpid());
+
return client;
}
sp<IProCameraUser> CameraService::connect(
const sp<IProCameraCallbacks>& cameraCb,
- int cameraId)
+ int cameraId,
+ const String16& clientPackageName,
+ int clientUid)
{
+ String8 clientName8(clientPackageName);
int callingPid = getCallingPid();
+ // TODO: use clientPackageName and clientUid with appOpsMangr
+
LOG1("CameraService::connectPro E (pid %d, id %d)", callingPid, cameraId);
if (!mModule) {
@@ -295,6 +331,15 @@ sp<IProCameraUser> CameraService::connect(
return NULL;
}
+ // TODO: allow concurrent connections with a ProCamera
+ if (mBusy[cameraId]) {
+
+ ALOGW("CameraService::connectPro X (pid %d, \"%s\") rejected"
+ " (camera %d is still busy).", callingPid,
+ clientName8.string(), cameraId);
+ return NULL;
+ }
+
int facing = -1;
int deviceVersion = getDeviceVersion(cameraId, &facing);
@@ -327,9 +372,45 @@ sp<IProCameraUser> CameraService::connect(
LOG1("CameraService::connectPro X (id %d, this pid is %d)", cameraId,
getpid());
return client;
+}
+status_t CameraService::addListener(
+ const sp<ICameraServiceListener>& listener) {
+ ALOGV("%s: Add listener %p", __FUNCTION__, listener.get());
- return NULL;
+ Mutex::Autolock lock(mServiceLock);
+
+ Vector<sp<ICameraServiceListener> >::iterator it, end;
+ for (it = mListenerList.begin(); it != mListenerList.end(); ++it) {
+ if ((*it)->asBinder() == listener->asBinder()) {
+ ALOGW("%s: Tried to add listener %p which was already subscribed",
+ __FUNCTION__, listener.get());
+ return ALREADY_EXISTS;
+ }
+ }
+
+ mListenerList.push_back(listener);
+
+ return OK;
+}
+status_t CameraService::removeListener(
+ const sp<ICameraServiceListener>& listener) {
+ ALOGV("%s: Remove listener %p", __FUNCTION__, listener.get());
+
+ Mutex::Autolock lock(mServiceLock);
+
+ Vector<sp<ICameraServiceListener> >::iterator it;
+ for (it = mListenerList.begin(); it != mListenerList.end(); ++it) {
+ if ((*it)->asBinder() == listener->asBinder()) {
+ mListenerList.erase(it);
+ return OK;
+ }
+ }
+
+ ALOGW("%s: Tried to remove a listener %p which was not subscribed",
+ __FUNCTION__, listener.get());
+
+ return BAD_VALUE;
}
void CameraService::removeClientByRemote(const wp<IBinder>& remoteBinder) {
@@ -693,6 +774,8 @@ void CameraService::Client::notifyError() {
void CameraService::Client::disconnect() {
BasicClient::disconnect();
mCameraService->setCameraFree(mCameraId);
+ mCameraService->updateStatus(ICameraServiceListener::STATUS_AVAILABLE,
+ mCameraId);
}
CameraService::Client::OpsCallback::OpsCallback(wp<BasicClient> client):
@@ -768,6 +851,10 @@ bool CameraService::ProClient::hasExclusiveLock() {
return false;
}
+void CameraService::ProClient::onExclusiveLockStolen() {
+ ALOGE("%s: not implemented yet", __FUNCTION__);
+}
+
status_t CameraService::ProClient::submitRequest(camera_metadata_t* request, bool streaming) {
ALOGE("%s: not implemented yet", __FUNCTION__);
@@ -938,4 +1025,47 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) {
}
+void CameraService::updateStatus(ICameraServiceListener::Status status,
+ int32_t cameraId) {
+ // do not lock mServiceLock here or can get into a deadlock from
+ // connect() -> ProClient::disconnect -> updateStatus
+ Mutex::Autolock lock(mStatusMutex);
+ updateStatusUnsafe(status, cameraId);
+}
+
+void CameraService::updateStatusUnsafe(ICameraServiceListener::Status status,
+ int32_t cameraId) {
+
+ ICameraServiceListener::Status oldStatus = mStatusList[cameraId];
+
+ mStatusList[cameraId] = status;
+
+ if (oldStatus != status) {
+ ALOGV("%s: Status has changed for camera ID %d from 0x%x to 0x%x",
+ __FUNCTION__, cameraId, (uint32_t)oldStatus, (uint32_t)status);
+
+ /**
+ * ProClients lose their exclusive lock.
+ * - Done before the CameraClient can initialize the HAL device,
+ * since we want to be able to close it before they get to initialize
+ */
+ if (status == ICameraServiceListener::STATUS_NOT_AVAILABLE) {
+ Vector<wp<ProClient> > proClients(mProClientList[cameraId]);
+ Vector<wp<ProClient> >::const_iterator it;
+
+ for (it = proClients.begin(); it != proClients.end(); ++it) {
+ sp<ProClient> proCl = it->promote();
+ if (proCl.get() != NULL) {
+ proCl->onExclusiveLockStolen();
+ }
+ }
+ }
+
+ Vector<sp<ICameraServiceListener> >::const_iterator it;
+ for (it = mListenerList.begin(); it != mListenerList.end(); ++it) {
+ (*it)->onStatusChanged(status, cameraId);
+ }
+ }
+}
+
}; // namespace android
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index b017505..8acc63f 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -25,6 +25,13 @@
#include <camera/ICameraService.h>
#include <hardware/camera.h>
+#include <camera/ICamera.h>
+#include <camera/ICameraClient.h>
+#include <camera/IProCameraUser.h>
+#include <camera/IProCameraCallbacks.h>
+
+#include <camera/ICameraServiceListener.h>
+
/* This needs to be increased if we can have more cameras */
#define MAX_CAMERAS 2
@@ -60,7 +67,11 @@ public:
virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient, int cameraId,
const String16& clientPackageName, int clientUid);
virtual sp<IProCameraUser> connect(const sp<IProCameraCallbacks>& cameraCb,
- int cameraId);
+ int cameraId, const String16& clientPackageName, int clientUid);
+
+ virtual status_t addListener(const sp<ICameraServiceListener>& listener);
+ virtual status_t removeListener(
+ const sp<ICameraServiceListener>& listener);
// Extra permissions checks
virtual status_t onTransact(uint32_t code, const Parcel& data,
@@ -258,6 +269,9 @@ public:
virtual status_t requestStream(int streamId);
virtual status_t cancelStream(int streamId);
+ // Callbacks from camera service
+ virtual void onExclusiveLockStolen();
+
protected:
virtual void notifyError();
@@ -298,11 +312,30 @@ private:
camera_module_t *mModule;
+ Vector<sp<ICameraServiceListener> >
+ mListenerList;
+
+ // guard only mStatusList and the broadcasting of ICameraServiceListener
+ Mutex mStatusMutex;
+ ICameraServiceListener::Status
+ mStatusList[MAX_CAMERAS];
+
+ // Broadcast the new status if it changed (locks the service mutex)
+ void updateStatus(
+ ICameraServiceListener::Status status,
+ int32_t cameraId);
+ // Call this one when the service mutex is already held (idempotent)
+ void updateStatusUnsafe(
+ ICameraServiceListener::Status status,
+ int32_t cameraId);
+
// IBinder::DeathRecipient implementation
- virtual void binderDied(const wp<IBinder> &who);
+ virtual void binderDied(const wp<IBinder> &who);
// Helpers
int getDeviceVersion(int cameraId, int* facing);
+
+ bool isValidCameraId(int cameraId);
};
} // namespace android
diff --git a/services/camera/libcameraservice/ProCamera2Client.cpp b/services/camera/libcameraservice/ProCamera2Client.cpp
index eda3012..6fed8b4 100644
--- a/services/camera/libcameraservice/ProCamera2Client.cpp
+++ b/services/camera/libcameraservice/ProCamera2Client.cpp
@@ -115,6 +115,8 @@ status_t ProCamera2Client::exclusiveTryLock() {
Mutex::Autolock icl(mIProCameraUserLock);
SharedCameraCallbacks::Lock l(mSharedCameraCallbacks);
+ if (!mDevice.get()) return PERMISSION_DENIED;
+
if (!mExclusiveLock) {
mExclusiveLock = true;
@@ -144,6 +146,8 @@ status_t ProCamera2Client::exclusiveLock() {
Mutex::Autolock icl(mIProCameraUserLock);
SharedCameraCallbacks::Lock l(mSharedCameraCallbacks);
+ if (!mDevice.get()) return PERMISSION_DENIED;
+
/**
* TODO: this should asynchronously 'wait' until the lock becomes available
* if another client already has an exclusive lock.
@@ -197,12 +201,33 @@ bool ProCamera2Client::hasExclusiveLock() {
return mExclusiveLock;
}
+void ProCamera2Client::onExclusiveLockStolen() {
+ ALOGV("%s: ProClient lost exclusivity (id %d)",
+ __FUNCTION__, mCameraId);
+
+ Mutex::Autolock icl(mIProCameraUserLock);
+ SharedCameraCallbacks::Lock l(mSharedCameraCallbacks);
+
+ if (mExclusiveLock && mRemoteCallback.get() != NULL) {
+ mRemoteCallback->onLockStatusChanged(
+ IProCameraCallbacks::LOCK_STOLEN);
+ }
+
+ mExclusiveLock = false;
+
+ //TODO: we should not need to detach the device, merely reset it.
+ detachDevice();
+}
+
status_t ProCamera2Client::submitRequest(camera_metadata_t* request,
bool streaming) {
ATRACE_CALL();
ALOGV("%s", __FUNCTION__);
Mutex::Autolock icl(mIProCameraUserLock);
+
+ if (!mDevice.get()) return DEAD_OBJECT;
+
if (!mExclusiveLock) {
return PERMISSION_DENIED;
}
@@ -224,6 +249,9 @@ status_t ProCamera2Client::cancelRequest(int requestId) {
ALOGV("%s", __FUNCTION__);
Mutex::Autolock icl(mIProCameraUserLock);
+
+ if (!mDevice.get()) return DEAD_OBJECT;
+
if (!mExclusiveLock) {
return PERMISSION_DENIED;
}
@@ -247,6 +275,7 @@ status_t ProCamera2Client::cancelStream(int streamId) {
Mutex::Autolock icl(mIProCameraUserLock);
+ if (!mDevice.get()) return DEAD_OBJECT;
mDevice->clearStreamingRequest();
status_t code;
@@ -274,6 +303,8 @@ status_t ProCamera2Client::createStream(int width, int height, int format,
Mutex::Autolock icl(mIProCameraUserLock);
+ if (!mDevice.get()) return DEAD_OBJECT;
+
sp<IBinder> binder;
sp<ANativeWindow> window;
if (bufferProducer != 0) {
@@ -303,6 +334,8 @@ status_t ProCamera2Client::createDefaultRequest(int templateId,
Mutex::Autolock icl(mIProCameraUserLock);
+ if (!mDevice.get()) return DEAD_OBJECT;
+
CameraMetadata metadata;
if ( (res = mDevice->createDefaultRequest(templateId, &metadata) ) == OK) {
*request = metadata.release();
@@ -319,6 +352,10 @@ status_t ProCamera2Client::getCameraInfo(int cameraId,
return INVALID_OPERATION;
}
+ Mutex::Autolock icl(mIProCameraUserLock);
+
+ if (!mDevice.get()) return DEAD_OBJECT;
+
CameraMetadata deviceInfo = mDevice->info();
*info = deviceInfo.release();
@@ -341,6 +378,12 @@ status_t ProCamera2Client::dump(int fd, const Vector<String16>& args) {
result = " Device dump:\n";
write(fd, result.string(), result.size());
+ if (!mDevice.get()) {
+ result = " *** Device is detached\n";
+ write(fd, result.string(), result.size());
+ return NO_ERROR;
+ }
+
status_t res = mDevice->dump(fd, args);
if (res != OK) {
result = String8::format(" Error dumping device: %s (%d)",
@@ -363,9 +406,19 @@ void ProCamera2Client::disconnect() {
int callingPid = getCallingPid();
if (callingPid != mClientPid && callingPid != mServicePid) return;
+ ALOGV("Camera %d: Shutting down", mCameraId);
+
+ detachDevice();
+ ProClient::disconnect();
+
+ ALOGV("Camera %d: Shut down complete complete", mCameraId);
+}
+
+void ProCamera2Client::detachDevice() {
if (mDevice == 0) return;
- ALOGV("Camera %d: Shutting down", mCameraId);
+ ALOGV("Camera %d: Stopping processors", mCameraId);
+
mFrameProcessor->removeListener(FRAME_PROCESSOR_LISTENER_MIN_ID,
FRAME_PROCESSOR_LISTENER_MAX_ID,
/*listener*/this);
@@ -374,11 +427,22 @@ void ProCamera2Client::disconnect() {
mFrameProcessor->join();
ALOGV("Camera %d: Disconnecting device", mCameraId);
+ // WORKAROUND: HAL refuses to disconnect while there's streams in flight
+ {
+ mDevice->clearStreamingRequest();
+
+ status_t code;
+ if ((code = mDevice->waitUntilDrained()) != OK) {
+ ALOGE("%s: waitUntilDrained failed with code 0x%x", __FUNCTION__,
+ code);
+ }
+ }
+
mDevice->disconnect();
mDevice.clear();
- ProClient::disconnect();
+ ALOGV("Camera %d: Detach complete", mCameraId);
}
status_t ProCamera2Client::connect(const sp<IProCameraCallbacks>& client) {
diff --git a/services/camera/libcameraservice/ProCamera2Client.h b/services/camera/libcameraservice/ProCamera2Client.h
index 9f514f4..ff6f4e2 100644
--- a/services/camera/libcameraservice/ProCamera2Client.h
+++ b/services/camera/libcameraservice/ProCamera2Client.h
@@ -104,6 +104,9 @@ public:
const sp<Camera2Device>& getCameraDevice();
const sp<CameraService>& getCameraService();
+ // Callbacks from camera service
+ virtual void onExclusiveLockStolen();
+
/**
* Interface used by independent components of ProCamera2Client.
*/
@@ -167,6 +170,8 @@ private:
// - if no we can't modify the request queue.
// note that creating/deleting streams we own is still OK
bool mExclusiveLock;
+
+ void detachDevice();
};
}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
index c4055e0..9a14758 100644
--- a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
@@ -23,7 +23,7 @@
#include "CallbackProcessor.h"
#include <gui/Surface.h>
-#include "../Camera2Device.h"
+#include "../CameraDeviceBase.h"
#include "../Camera2Client.h"
@@ -58,7 +58,7 @@ status_t CallbackProcessor::updateStream(const Parameters &params) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return OK;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
if (mCallbackConsumer == 0) {
// Create CPU buffer queue endpoint
@@ -125,7 +125,7 @@ status_t CallbackProcessor::deleteStream() {
if (mCallbackStreamId != NO_STREAM) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return OK;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
device->deleteStream(mCallbackStreamId);
diff --git a/services/camera/libcameraservice/camera2/FrameProcessor.cpp b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
index 8ee5de7..3129a0b 100644
--- a/services/camera/libcameraservice/camera2/FrameProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
@@ -22,7 +22,7 @@
#include <utils/Trace.h>
#include "FrameProcessor.h"
-#include "../Camera2Device.h"
+#include "../CameraDeviceBase.h"
#include "../Camera2Client.h"
namespace android {
@@ -71,7 +71,7 @@ void FrameProcessor::dump(int fd, const Vector<String16>& /*args*/) {
bool FrameProcessor::threadLoop() {
status_t res;
- sp<Camera2Device> device;
+ sp<CameraDeviceBase> device;
{
sp<Camera2Client> client = mClient.promote();
if (client == 0) return false;
diff --git a/services/camera/libcameraservice/camera2/JpegProcessor.cpp b/services/camera/libcameraservice/camera2/JpegProcessor.cpp
index 1ec5694..286fac4 100644
--- a/services/camera/libcameraservice/camera2/JpegProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/JpegProcessor.cpp
@@ -27,7 +27,7 @@
#include "JpegProcessor.h"
#include <gui/Surface.h>
-#include "../Camera2Device.h"
+#include "../CameraDeviceBase.h"
#include "../Camera2Client.h"
@@ -66,7 +66,7 @@ status_t JpegProcessor::updateStream(const Parameters &params) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return OK;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
// Find out buffer size for JPEG
camera_metadata_ro_entry_t maxJpegSize =
@@ -145,7 +145,7 @@ status_t JpegProcessor::deleteStream() {
if (mCaptureStreamId != NO_STREAM) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return OK;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
device->deleteStream(mCaptureStreamId);
diff --git a/services/camera/libcameraservice/camera2/StreamingProcessor.cpp b/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
index a0d1093..6a4b95d 100644
--- a/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
@@ -26,7 +26,7 @@
#include "StreamingProcessor.h"
#include "Camera2Heap.h"
#include "../Camera2Client.h"
-#include "../Camera2Device.h"
+#include "../CameraDeviceBase.h"
namespace android {
namespace camera2 {
@@ -110,7 +110,7 @@ status_t StreamingProcessor::updatePreviewStream(const Parameters &params) {
status_t res;
sp<Camera2Client> client = mClient.promote();
if (client == 0) return INVALID_OPERATION;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
if (mPreviewStreamId != NO_STREAM) {
// Check if stream parameters have to change
@@ -176,7 +176,7 @@ status_t StreamingProcessor::deletePreviewStream() {
if (mPreviewStreamId != NO_STREAM) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return INVALID_OPERATION;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
ALOGV("%s: for cameraId %d on streamId %d",
__FUNCTION__, client->getCameraId(), mPreviewStreamId);
@@ -272,7 +272,7 @@ status_t StreamingProcessor::updateRecordingStream(const Parameters &params) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return INVALID_OPERATION;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
if (mRecordingConsumer == 0) {
// Create CPU buffer queue endpoint. We need one more buffer here so that we can
@@ -339,7 +339,7 @@ status_t StreamingProcessor::deleteRecordingStream() {
if (mRecordingStreamId != NO_STREAM) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return INVALID_OPERATION;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
res = device->waitUntilDrained();
if (res != OK) {
@@ -415,7 +415,7 @@ status_t StreamingProcessor::stopStream() {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return INVALID_OPERATION;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
res = device->clearStreamingRequest();
if (res != OK) {
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.cpp b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
index 900c099..769d9bd 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
@@ -30,7 +30,7 @@
#include "ZslProcessor.h"
#include <gui/Surface.h>
-#include "../Camera2Device.h"
+#include "../CameraDeviceBase.h"
#include "../Camera2Client.h"
@@ -114,7 +114,7 @@ status_t ZslProcessor::updateStream(const Parameters &params) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return OK;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
if (mZslConsumer == 0) {
// Create CPU buffer queue endpoint
@@ -202,7 +202,7 @@ status_t ZslProcessor::deleteStream() {
if (mZslStreamId != NO_STREAM) {
sp<Camera2Client> client = mClient.promote();
if (client == 0) return OK;
- sp<Camera2Device> device = client->getCameraDevice();
+ sp<CameraDeviceBase> device = client->getCameraDevice();
res = device->deleteReprocessStream(mZslReprocessStreamId);
if (res != OK) {
@@ -289,10 +289,12 @@ status_t ZslProcessor::pushToReprocess(int32_t requestId) {
uint8_t requestType = ANDROID_REQUEST_TYPE_REPROCESS;
res = request.update(ANDROID_REQUEST_TYPE,
&requestType, 1);
- uint8_t inputStreams[1] = { mZslReprocessStreamId };
+ uint8_t inputStreams[1] =
+ { static_cast<uint8_t>(mZslReprocessStreamId) };
if (res == OK) request.update(ANDROID_REQUEST_INPUT_STREAMS,
inputStreams, 1);
- uint8_t outputStreams[1] = { client->getCaptureStreamId() };
+ uint8_t outputStreams[1] =
+ { static_cast<uint8_t>(client->getCaptureStreamId()) };
if (res == OK) request.update(ANDROID_REQUEST_OUTPUT_STREAMS,
outputStreams, 1);
res = request.update(ANDROID_REQUEST_ID,
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.h b/services/camera/libcameraservice/camera2/ZslProcessor.h
index ec16eef..b2cf5b1 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.h
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.h
@@ -27,7 +27,7 @@
#include "FrameProcessor.h"
#include "camera/CameraMetadata.h"
#include "Camera2Heap.h"
-#include "../Camera2Device.h"
+#include "../CameraDeviceBase.h"
namespace android {
@@ -44,7 +44,7 @@ class ZslProcessor:
virtual public Thread,
virtual public BufferItemConsumer::FrameAvailableListener,
virtual public FrameProcessor::FilteredListener,
- virtual public Camera2Device::BufferReleasedListener {
+ virtual public CameraDeviceBase::BufferReleasedListener {
public:
ZslProcessor(wp<Camera2Client> client, wp<CaptureSequencer> sequencer);
~ZslProcessor();