summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice/api1
diff options
context:
space:
mode:
Diffstat (limited to 'services/camera/libcameraservice/api1')
-rw-r--r--services/camera/libcameraservice/api1/Camera2Client.cpp8
-rw-r--r--services/camera/libcameraservice/api1/Camera2Client.h2
-rw-r--r--services/camera/libcameraservice/api1/CameraClient.cpp55
-rw-r--r--services/camera/libcameraservice/api1/CameraClient.h2
-rw-r--r--services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp4
-rw-r--r--services/camera/libcameraservice/api1/client2/JpegProcessor.cpp3
-rw-r--r--services/camera/libcameraservice/api1/client2/Parameters.cpp32
-rw-r--r--services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp19
-rw-r--r--services/camera/libcameraservice/api1/client2/StreamingProcessor.h2
-rw-r--r--services/camera/libcameraservice/api1/client2/ZslProcessor.cpp6
-rw-r--r--services/camera/libcameraservice/api1/client2/ZslProcessor.h3
-rw-r--r--services/camera/libcameraservice/api1/client2/ZslProcessor3.h3
12 files changed, 68 insertions, 71 deletions
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index 0ed5586..6f44aee 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -67,7 +67,7 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
mLegacyMode = legacyMode;
}
-status_t Camera2Client::initialize(camera_module_t *module)
+status_t Camera2Client::initialize(CameraModule *module)
{
ATRACE_CALL();
ALOGV("%s: Initializing client for camera %d", __FUNCTION__, mCameraId);
@@ -163,11 +163,9 @@ Camera2Client::~Camera2Client() {
status_t Camera2Client::dump(int fd, const Vector<String16>& args) {
String8 result;
- result.appendFormat("Client2[%d] (%p) Client: %s PID: %d, dump:\n",
- mCameraId,
+ result.appendFormat("Client2[%d] (%p) PID: %d, dump:\n", mCameraId,
(getRemoteCallback() != NULL ?
(IInterface::asBinder(getRemoteCallback()).get()) : NULL),
- String8(mClientPackageName).string(),
mClientPid);
result.append(" State: ");
#define CASE_APPEND_ENUM(x) case x: result.append(#x "\n"); break;
@@ -1959,7 +1957,7 @@ size_t Camera2Client::calculateBufferSize(int width, int height,
return width * height * 2;
case HAL_PIXEL_FORMAT_RGBA_8888:
return width * height * 4;
- case HAL_PIXEL_FORMAT_RAW_SENSOR:
+ case HAL_PIXEL_FORMAT_RAW16:
return width * height * 2;
default:
ALOGE("%s: Unknown preview format: %x",
diff --git a/services/camera/libcameraservice/api1/Camera2Client.h b/services/camera/libcameraservice/api1/Camera2Client.h
index d68bb29..5a8241f 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.h
+++ b/services/camera/libcameraservice/api1/Camera2Client.h
@@ -94,7 +94,7 @@ public:
virtual ~Camera2Client();
- status_t initialize(camera_module_t *module);
+ status_t initialize(CameraModule *module);
virtual status_t dump(int fd, const Vector<String16>& args);
diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp
index bbb2fe0..e552633 100644
--- a/services/camera/libcameraservice/api1/CameraClient.cpp
+++ b/services/camera/libcameraservice/api1/CameraClient.cpp
@@ -59,7 +59,7 @@ CameraClient::CameraClient(const sp<CameraService>& cameraService,
LOG1("CameraClient::CameraClient X (pid %d, id %d)", callingPid, cameraId);
}
-status_t CameraClient::initialize(camera_module_t *module) {
+status_t CameraClient::initialize(CameraModule *module) {
int callingPid = getCallingPid();
status_t res;
@@ -75,7 +75,7 @@ status_t CameraClient::initialize(camera_module_t *module) {
snprintf(camera_device_name, sizeof(camera_device_name), "%d", mCameraId);
mHardware = new CameraHardwareInterface(camera_device_name);
- res = mHardware->initialize(&module->common);
+ res = mHardware->initialize(module);
if (res != OK) {
ALOGE("%s: Camera %d: unable to initialize device: %s (%d)",
__FUNCTION__, mCameraId, strerror(-res), res);
@@ -99,12 +99,7 @@ status_t CameraClient::initialize(camera_module_t *module) {
// tear down the client
CameraClient::~CameraClient() {
- // this lock should never be NULL
- Mutex* lock = mCameraService->getClientLockById(mCameraId);
- lock->lock();
mDestructionStarted = true;
- // client will not be accessed from callback. should unlock to prevent dead-lock in disconnect
- lock->unlock();
int callingPid = getCallingPid();
LOG1("CameraClient::~CameraClient E (pid %d, this %p)", callingPid, this);
@@ -116,11 +111,11 @@ status_t CameraClient::dump(int fd, const Vector<String16>& args) {
const size_t SIZE = 256;
char buffer[SIZE];
- size_t len = snprintf(buffer, SIZE, "Client[%d] (%p) PID: %d\n",
+ size_t len = snprintf(buffer, SIZE, "Client[%d] (%p) with UID %d\n",
mCameraId,
(getRemoteCallback() != NULL ?
IInterface::asBinder(getRemoteCallback()).get() : NULL),
- mClientPid);
+ mClientUid);
len = (len > SIZE - 1) ? SIZE - 1 : len;
write(fd, buffer, len);
@@ -677,6 +672,13 @@ bool CameraClient::lockIfMessageWanted(int32_t msgType) {
LOG1("lockIfMessageWanted(%d): waited for %d ms",
msgType, sleepCount * CHECK_MESSAGE_INTERVAL);
}
+
+ // If messages are no longer enabled after acquiring lock, release and drop message
+ if ((mMsgEnabled & msgType) == 0) {
+ mLock.unlock();
+ break;
+ }
+
return true;
}
if (sleepCount++ == 0) {
@@ -702,26 +704,13 @@ bool CameraClient::lockIfMessageWanted(int32_t msgType) {
// (others) c->dataCallback
// dataCallbackTimestamp
// (others) c->dataCallbackTimestamp
-//
-// NOTE: the *Callback functions grab mLock of the client before passing
-// control to handle* functions. So the handle* functions must release the
-// lock before calling the ICameraClient's callbacks, so those callbacks can
-// invoke methods in the Client class again (For example, the preview frame
-// callback may want to releaseRecordingFrame). The handle* functions must
-// release the lock after all accesses to member variables, so it must be
-// handled very carefully.
void CameraClient::notifyCallback(int32_t msgType, int32_t ext1,
int32_t ext2, void* user) {
LOG2("notifyCallback(%d)", msgType);
- Mutex* lock = getClientLockFromCookie(user);
- if (lock == NULL) return;
- Mutex::Autolock alock(*lock);
-
- CameraClient* client =
- static_cast<CameraClient*>(getClientFromCookie(user));
- if (client == NULL) return;
+ sp<CameraClient> client = static_cast<CameraClient*>(getClientFromCookie(user).get());
+ if (client.get() == nullptr) return;
if (!client->lockIfMessageWanted(msgType)) return;
@@ -740,13 +729,8 @@ void CameraClient::dataCallback(int32_t msgType,
const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata, void* user) {
LOG2("dataCallback(%d)", msgType);
- Mutex* lock = getClientLockFromCookie(user);
- if (lock == NULL) return;
- Mutex::Autolock alock(*lock);
-
- CameraClient* client =
- static_cast<CameraClient*>(getClientFromCookie(user));
- if (client == NULL) return;
+ sp<CameraClient> client = static_cast<CameraClient*>(getClientFromCookie(user).get());
+ if (client.get() == nullptr) return;
if (!client->lockIfMessageWanted(msgType)) return;
if (dataPtr == 0 && metadata == NULL) {
@@ -778,13 +762,8 @@ void CameraClient::dataCallbackTimestamp(nsecs_t timestamp,
int32_t msgType, const sp<IMemory>& dataPtr, void* user) {
LOG2("dataCallbackTimestamp(%d)", msgType);
- Mutex* lock = getClientLockFromCookie(user);
- if (lock == NULL) return;
- Mutex::Autolock alock(*lock);
-
- CameraClient* client =
- static_cast<CameraClient*>(getClientFromCookie(user));
- if (client == NULL) return;
+ sp<CameraClient> client = static_cast<CameraClient*>(getClientFromCookie(user).get());
+ if (client.get() == nullptr) return;
if (!client->lockIfMessageWanted(msgType)) return;
diff --git a/services/camera/libcameraservice/api1/CameraClient.h b/services/camera/libcameraservice/api1/CameraClient.h
index 63a9d0f..95616b2 100644
--- a/services/camera/libcameraservice/api1/CameraClient.h
+++ b/services/camera/libcameraservice/api1/CameraClient.h
@@ -68,7 +68,7 @@ public:
bool legacyMode = false);
~CameraClient();
- status_t initialize(camera_module_t *module);
+ status_t initialize(CameraModule *module);
status_t dump(int fd, const Vector<String16>& args);
diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
index eadaa00..5c8f750 100644
--- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
@@ -154,8 +154,8 @@ status_t CallbackProcessor::updateStream(const Parameters &params) {
params.previewWidth, params.previewHeight,
callbackFormat, params.previewFormat);
res = device->createStream(mCallbackWindow,
- params.previewWidth, params.previewHeight,
- callbackFormat, &mCallbackStreamId);
+ params.previewWidth, params.previewHeight, callbackFormat,
+ HAL_DATASPACE_JFIF, CAMERA3_STREAM_ROTATION_0, &mCallbackStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create output stream for callbacks: "
"%s (%d)", __FUNCTION__, mId,
diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
index 2772267..34798bf 100644
--- a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
@@ -145,7 +145,8 @@ status_t JpegProcessor::updateStream(const Parameters &params) {
// Create stream for HAL production
res = device->createStream(mCaptureWindow,
params.pictureWidth, params.pictureHeight,
- HAL_PIXEL_FORMAT_BLOB, &mCaptureStreamId);
+ HAL_PIXEL_FORMAT_BLOB, HAL_DATASPACE_JFIF,
+ CAMERA3_STREAM_ROTATION_0, &mCaptureStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create output stream for capture: "
"%s (%d)", __FUNCTION__, mId,
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
index 4f4cfb0..6b0f8b5 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
+++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
@@ -65,15 +65,29 @@ status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) {
const Size MAX_PREVIEW_SIZE = { MAX_PREVIEW_WIDTH, MAX_PREVIEW_HEIGHT };
// Treat the H.264 max size as the max supported video size.
MediaProfiles *videoEncoderProfiles = MediaProfiles::getInstance();
- int32_t maxVideoWidth = videoEncoderProfiles->getVideoEncoderParamByName(
- "enc.vid.width.max", VIDEO_ENCODER_H264);
- int32_t maxVideoHeight = videoEncoderProfiles->getVideoEncoderParamByName(
- "enc.vid.height.max", VIDEO_ENCODER_H264);
- const Size MAX_VIDEO_SIZE = {maxVideoWidth, maxVideoHeight};
+ Vector<video_encoder> encoders = videoEncoderProfiles->getVideoEncoders();
+ int32_t maxVideoWidth = 0;
+ int32_t maxVideoHeight = 0;
+ for (size_t i = 0; i < encoders.size(); i++) {
+ int width = videoEncoderProfiles->getVideoEncoderParamByName(
+ "enc.vid.width.max", encoders[i]);
+ int height = videoEncoderProfiles->getVideoEncoderParamByName(
+ "enc.vid.height.max", encoders[i]);
+ // Treat width/height separately here to handle the case where different
+ // profile might report max size of different aspect ratio
+ if (width > maxVideoWidth) {
+ maxVideoWidth = width;
+ }
+ if (height > maxVideoHeight) {
+ maxVideoHeight = height;
+ }
+ }
+ // This is just an upper bound and may not be an actually valid video size
+ const Size VIDEO_SIZE_UPPER_BOUND = {maxVideoWidth, maxVideoHeight};
res = getFilteredSizes(MAX_PREVIEW_SIZE, &availablePreviewSizes);
if (res != OK) return res;
- res = getFilteredSizes(MAX_VIDEO_SIZE, &availableVideoSizes);
+ res = getFilteredSizes(VIDEO_SIZE_UPPER_BOUND, &availableVideoSizes);
if (res != OK) return res;
// Select initial preview and video size that's under the initial bound and
@@ -182,9 +196,9 @@ status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) {
supportedPreviewFormats +=
CameraParameters::PIXEL_FORMAT_YUV420SP;
break;
- // Not advertizing JPEG, RAW_SENSOR, etc, for preview formats
+ // Not advertizing JPEG, RAW16, etc, for preview formats
case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
- case HAL_PIXEL_FORMAT_RAW_SENSOR:
+ case HAL_PIXEL_FORMAT_RAW16:
case HAL_PIXEL_FORMAT_BLOB:
addComma = false;
break;
@@ -2253,7 +2267,7 @@ const char* Parameters::formatEnumToString(int format) {
case HAL_PIXEL_FORMAT_RGBA_8888: // RGBA8888
fmt = CameraParameters::PIXEL_FORMAT_RGBA8888;
break;
- case HAL_PIXEL_FORMAT_RAW_SENSOR:
+ case HAL_PIXEL_FORMAT_RAW16:
ALOGW("Raw sensor preview format requested.");
fmt = CameraParameters::PIXEL_FORMAT_BAYER_RGGB;
break;
diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
index 470624b..b6071f6 100644
--- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
@@ -27,6 +27,7 @@
#include <utils/Log.h>
#include <utils/Trace.h>
+#include <gui/BufferItem.h>
#include <gui/Surface.h>
#include <media/hardware/MetadataBufferType.h>
@@ -181,7 +182,8 @@ status_t StreamingProcessor::updatePreviewStream(const Parameters &params) {
if (mPreviewStreamId == NO_STREAM) {
res = device->createStream(mPreviewWindow,
params.previewWidth, params.previewHeight,
- CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, &mPreviewStreamId);
+ CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, HAL_DATASPACE_UNKNOWN,
+ CAMERA3_STREAM_ROTATION_0, &mPreviewStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Unable to create preview stream: %s (%d)",
__FUNCTION__, mId, strerror(-res), res);
@@ -420,9 +422,12 @@ status_t StreamingProcessor::updateRecordingStream(const Parameters &params) {
if (mRecordingStreamId == NO_STREAM) {
mRecordingFrameCount = 0;
+ // Selecting BT.709 colorspace by default
+ // TODO: Wire this in from encoder side
res = device->createStream(mRecordingWindow,
params.videoWidth, params.videoHeight,
- CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, &mRecordingStreamId);
+ CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, HAL_DATASPACE_BT709,
+ CAMERA3_STREAM_ROTATION_0, &mRecordingStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create output stream for recording: "
"%s (%d)", __FUNCTION__, mId,
@@ -675,7 +680,7 @@ status_t StreamingProcessor::processRecordingFrame() {
sp<Camera2Client> client = mClient.promote();
if (client == 0) {
// Discard frames during shutdown
- BufferItemConsumer::BufferItem imgBuffer;
+ BufferItem imgBuffer;
res = mRecordingConsumer->acquireBuffer(&imgBuffer, 0);
if (res != OK) {
if (res != BufferItemConsumer::NO_BUFFER_AVAILABLE) {
@@ -693,7 +698,7 @@ status_t StreamingProcessor::processRecordingFrame() {
with Camera2Client code calling into StreamingProcessor */
SharedParameters::Lock l(client->getParameters());
Mutex::Autolock m(mMutex);
- BufferItemConsumer::BufferItem imgBuffer;
+ BufferItem imgBuffer;
res = mRecordingConsumer->acquireBuffer(&imgBuffer, 0);
if (res != OK) {
if (res != BufferItemConsumer::NO_BUFFER_AVAILABLE) {
@@ -819,8 +824,7 @@ void StreamingProcessor::releaseRecordingFrame(const sp<IMemory>& mem) {
size_t itemIndex;
for (itemIndex = 0; itemIndex < mRecordingBuffers.size(); itemIndex++) {
- const BufferItemConsumer::BufferItem item =
- mRecordingBuffers[itemIndex];
+ const BufferItem item = mRecordingBuffers[itemIndex];
if (item.mBuf != BufferItemConsumer::INVALID_BUFFER_SLOT &&
item.mGraphicBuffer->handle == imgHandle) {
break;
@@ -864,8 +868,7 @@ void StreamingProcessor::releaseAllRecordingFramesLocked() {
size_t releasedCount = 0;
for (size_t itemIndex = 0; itemIndex < mRecordingBuffers.size(); itemIndex++) {
- const BufferItemConsumer::BufferItem item =
- mRecordingBuffers[itemIndex];
+ const BufferItem item = mRecordingBuffers[itemIndex];
if (item.mBuf != BufferItemConsumer::INVALID_BUFFER_SLOT) {
res = mRecordingConsumer->releaseBuffer(mRecordingBuffers[itemIndex]);
if (res != OK) {
diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
index 1d679a4..2474062 100644
--- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
@@ -124,7 +124,7 @@ class StreamingProcessor:
static const size_t kDefaultRecordingHeapCount = 8;
size_t mRecordingHeapCount;
- Vector<BufferItemConsumer::BufferItem> mRecordingBuffers;
+ Vector<BufferItem> mRecordingBuffers;
size_t mRecordingHeapHead, mRecordingHeapFree;
virtual bool threadLoop();
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
index 8b7e4b4..a03f9c7 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
@@ -185,8 +185,8 @@ status_t ZslProcessor::updateStream(const Parameters &params) {
(int)CAMERA2_HAL_PIXEL_FORMAT_ZSL :
(int)HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
res = device->createStream(mZslWindow,
- params.fastInfo.arrayWidth, params.fastInfo.arrayHeight,
- streamType, &mZslStreamId);
+ params.fastInfo.arrayWidth, params.fastInfo.arrayHeight, streamType,
+ HAL_DATASPACE_UNKNOWN, CAMERA3_STREAM_ROTATION_0, &mZslStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create output stream for ZSL: "
"%s (%d)", __FUNCTION__, mId,
@@ -440,7 +440,7 @@ status_t ZslProcessor::processNewZslBuffer() {
zslConsumer = mZslConsumer;
}
ALOGVV("Trying to get next buffer");
- BufferItemConsumer::BufferItem item;
+ BufferItem item;
res = zslConsumer->acquireBuffer(&item, 0);
if (res != OK) {
if (res != BufferItemConsumer::NO_BUFFER_AVAILABLE) {
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.h b/services/camera/libcameraservice/api1/client2/ZslProcessor.h
index 2099c38..5f50d7b 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.h
@@ -22,6 +22,7 @@
#include <utils/Vector.h>
#include <utils/Mutex.h>
#include <utils/Condition.h>
+#include <gui/BufferItem.h>
#include <gui/BufferItemConsumer.h>
#include <camera/CameraMetadata.h>
#include <camera/CaptureResult.h>
@@ -103,7 +104,7 @@ class ZslProcessor:
sp<ANativeWindow> mZslWindow;
struct ZslPair {
- BufferItemConsumer::BufferItem buffer;
+ BufferItem buffer;
CameraMetadata frame;
};
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h
index fc9f70c..2960478 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h
@@ -22,6 +22,7 @@
#include <utils/Vector.h>
#include <utils/Mutex.h>
#include <utils/Condition.h>
+#include <gui/BufferItem.h>
#include <gui/BufferItemConsumer.h>
#include <camera/CameraMetadata.h>
@@ -104,7 +105,7 @@ class ZslProcessor3 :
sp<camera3::Camera3ZslStream> mZslStream;
struct ZslPair {
- BufferItemConsumer::BufferItem buffer;
+ BufferItem buffer;
CameraMetadata frame;
};