diff options
author | Igor Murashkin <iam@google.com> | 2013-02-13 15:53:56 -0800 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2013-02-22 10:50:14 -0800 |
commit | 7efa520c76e6a1f6b3146404cc6aca5a8353583a (patch) | |
tree | db2c59948bb0c344584706d6b6e36c86a42d9abf /services | |
parent | 99c2f923f6b04efffe949d1daf9cb7148e3cc201 (diff) | |
download | frameworks_av-7efa520c76e6a1f6b3146404cc6aca5a8353583a.zip frameworks_av-7efa520c76e6a1f6b3146404cc6aca5a8353583a.tar.gz frameworks_av-7efa520c76e6a1f6b3146404cc6aca5a8353583a.tar.bz2 |
Camera: Move CameraMetadata.h from service to client library
Change-Id: I940ce86f318f37ae5b73f912a6e589415150125f
Diffstat (limited to 'services')
14 files changed, 10 insertions, 484 deletions
diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk index 5245983..b6ebd02 100644 --- a/services/camera/libcameraservice/Android.mk +++ b/services/camera/libcameraservice/Android.mk @@ -11,7 +11,6 @@ LOCAL_SRC_FILES:= \ CameraClient.cpp \ Camera2Client.cpp \ Camera2Device.cpp \ - camera2/CameraMetadata.cpp \ camera2/Parameters.cpp \ camera2/FrameProcessor.cpp \ camera2/StreamingProcessor.cpp \ diff --git a/services/camera/libcameraservice/Camera2Client.h b/services/camera/libcameraservice/Camera2Client.h index 4669958..a4d4478 100644 --- a/services/camera/libcameraservice/Camera2Client.h +++ b/services/camera/libcameraservice/Camera2Client.h @@ -157,7 +157,6 @@ private: mutable Mutex mICameraLock; typedef camera2::Parameters Parameters; - typedef camera2::CameraMetadata CameraMetadata; status_t setPreviewWindowL(const sp<IBinder>& binder, sp<ANativeWindow> window); diff --git a/services/camera/libcameraservice/Camera2Device.cpp b/services/camera/libcameraservice/Camera2Device.cpp index 5bfa085..921c8fc 100644 --- a/services/camera/libcameraservice/Camera2Device.cpp +++ b/services/camera/libcameraservice/Camera2Device.cpp @@ -202,7 +202,7 @@ status_t Camera2Device::dump(int fd, const Vector<String16>& args) { return res; } -const camera2::CameraMetadata& Camera2Device::info() const { +const CameraMetadata& Camera2Device::info() const { ALOGVV("%s: E", __FUNCTION__); return mDeviceInfo; diff --git a/services/camera/libcameraservice/Camera2Device.h b/services/camera/libcameraservice/Camera2Device.h index 41df2e4..86ff80f 100644 --- a/services/camera/libcameraservice/Camera2Device.h +++ b/services/camera/libcameraservice/Camera2Device.h @@ -27,14 +27,12 @@ #include <utils/Vector.h> #include "hardware/camera2.h" -#include "camera2/CameraMetadata.h" +#include "camera/CameraMetadata.h" namespace android { class Camera2Device : public virtual RefBase { public: - typedef camera2::CameraMetadata CameraMetadata; - Camera2Device(int id); ~Camera2Device(); diff --git a/services/camera/libcameraservice/camera2/BurstCapture.h b/services/camera/libcameraservice/camera2/BurstCapture.h index dfc45eb..a2cc893 100644 --- a/services/camera/libcameraservice/camera2/BurstCapture.h +++ b/services/camera/libcameraservice/camera2/BurstCapture.h @@ -17,7 +17,7 @@ #ifndef ANDROID_SERVERS_CAMERA_BURST_CAPTURE_H #define ANDROID_SERVERS_CAMERA_BURST_CAPTURE_H -#include "camera2/CameraMetadata.h" +#include "camera/CameraMetadata.h" #include <binder/MemoryBase.h> #include <binder/MemoryHeapBase.h> #include <gui/CpuConsumer.h> diff --git a/services/camera/libcameraservice/camera2/CallbackProcessor.h b/services/camera/libcameraservice/camera2/CallbackProcessor.h index c2a1372..e68bb75 100644 --- a/services/camera/libcameraservice/camera2/CallbackProcessor.h +++ b/services/camera/libcameraservice/camera2/CallbackProcessor.h @@ -24,7 +24,7 @@ #include <utils/Condition.h> #include <gui/CpuConsumer.h> #include "Parameters.h" -#include "CameraMetadata.h" +#include "camera/CameraMetadata.h" #include "Camera2Heap.h" namespace android { diff --git a/services/camera/libcameraservice/camera2/CameraMetadata.cpp b/services/camera/libcameraservice/camera2/CameraMetadata.cpp deleted file mode 100644 index 835587d..0000000 --- a/services/camera/libcameraservice/camera2/CameraMetadata.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (C) 2012 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 "Camera2-Metadata" -#include <utils/Log.h> -#include <utils/Errors.h> - -#include "CameraMetadata.h" - -namespace android { - -namespace camera2 { -CameraMetadata::CameraMetadata() : - mBuffer(NULL) { -} - -CameraMetadata::CameraMetadata(size_t entryCapacity, size_t dataCapacity) -{ - mBuffer = allocate_camera_metadata(entryCapacity, dataCapacity); -} - -CameraMetadata::CameraMetadata(const CameraMetadata &other) { - mBuffer = clone_camera_metadata(other.mBuffer); -} - -CameraMetadata &CameraMetadata::operator=(const CameraMetadata &other) { - return operator=(other.mBuffer); -} - -CameraMetadata &CameraMetadata::operator=(const camera_metadata_t *buffer) { - if (CC_LIKELY(buffer != mBuffer)) { - camera_metadata_t *newBuffer = clone_camera_metadata(buffer); - clear(); - mBuffer = newBuffer; - } - return *this; -} - -CameraMetadata::~CameraMetadata() { - clear(); -} - -camera_metadata_t* CameraMetadata::release() { - camera_metadata_t *released = mBuffer; - mBuffer = NULL; - return released; -} - -void CameraMetadata::clear() { - if (mBuffer) { - free_camera_metadata(mBuffer); - mBuffer = NULL; - } -} - -void CameraMetadata::acquire(camera_metadata_t *buffer) { - clear(); - mBuffer = buffer; -} - -void CameraMetadata::acquire(CameraMetadata &other) { - acquire(other.release()); -} - -status_t CameraMetadata::append(const CameraMetadata &other) { - return append_camera_metadata(mBuffer, other.mBuffer); -} - -size_t CameraMetadata::entryCount() const { - return (mBuffer == NULL) ? 0 : - get_camera_metadata_entry_count(mBuffer); -} - -bool CameraMetadata::isEmpty() const { - return entryCount() == 0; -} - -status_t CameraMetadata::sort() { - return sort_camera_metadata(mBuffer); -} - -status_t CameraMetadata::checkType(uint32_t tag, uint8_t expectedType) { - int tagType = get_camera_metadata_tag_type(tag); - if ( CC_UNLIKELY(tagType == -1)) { - ALOGE("Update metadata entry: Unknown tag %d", tag); - return INVALID_OPERATION; - } - if ( CC_UNLIKELY(tagType != expectedType) ) { - ALOGE("Mismatched tag type when updating entry %s (%d) of type %s; " - "got type %s data instead ", - get_camera_metadata_tag_name(tag), tag, - camera_metadata_type_names[tagType], - camera_metadata_type_names[expectedType]); - return INVALID_OPERATION; - } - return OK; -} - -status_t CameraMetadata::update(uint32_t tag, - const int32_t *data, size_t data_count) { - status_t res; - if ( (res = checkType(tag, TYPE_INT32)) != OK) { - return res; - } - return update(tag, (const void*)data, data_count); -} - -status_t CameraMetadata::update(uint32_t tag, - const uint8_t *data, size_t data_count) { - status_t res; - if ( (res = checkType(tag, TYPE_BYTE)) != OK) { - return res; - } - return update(tag, (const void*)data, data_count); -} - -status_t CameraMetadata::update(uint32_t tag, - const float *data, size_t data_count) { - status_t res; - if ( (res = checkType(tag, TYPE_FLOAT)) != OK) { - return res; - } - return update(tag, (const void*)data, data_count); -} - -status_t CameraMetadata::update(uint32_t tag, - const int64_t *data, size_t data_count) { - status_t res; - if ( (res = checkType(tag, TYPE_INT64)) != OK) { - return res; - } - return update(tag, (const void*)data, data_count); -} - -status_t CameraMetadata::update(uint32_t tag, - const double *data, size_t data_count) { - status_t res; - if ( (res = checkType(tag, TYPE_DOUBLE)) != OK) { - return res; - } - return update(tag, (const void*)data, data_count); -} - -status_t CameraMetadata::update(uint32_t tag, - const camera_metadata_rational_t *data, size_t data_count) { - status_t res; - if ( (res = checkType(tag, TYPE_RATIONAL)) != OK) { - return res; - } - return update(tag, (const void*)data, data_count); -} - -status_t CameraMetadata::update(uint32_t tag, - const String8 &string) { - status_t res; - if ( (res = checkType(tag, TYPE_BYTE)) != OK) { - return res; - } - return update(tag, (const void*)string.string(), string.size()); -} - -status_t CameraMetadata::update(uint32_t tag, const void *data, - size_t data_count) { - status_t res; - int type = get_camera_metadata_tag_type(tag); - if (type == -1) { - ALOGE("%s: Tag %d not found", __FUNCTION__, tag); - return BAD_VALUE; - } - size_t data_size = calculate_camera_metadata_entry_data_size(type, - data_count); - - res = resizeIfNeeded(1, data_size); - - if (res == OK) { - camera_metadata_entry_t entry; - res = find_camera_metadata_entry(mBuffer, tag, &entry); - if (res == NAME_NOT_FOUND) { - res = add_camera_metadata_entry(mBuffer, - tag, data, data_count); - } else if (res == OK) { - res = update_camera_metadata_entry(mBuffer, - entry.index, data, data_count, NULL); - } - } - - if (res != OK) { - ALOGE("%s: Unable to update metadata entry %s.%s (%x): %s (%d)", - __FUNCTION__, get_camera_metadata_section_name(tag), - get_camera_metadata_tag_name(tag), tag, strerror(-res), res); - } - return res; -} - -camera_metadata_entry_t CameraMetadata::find(uint32_t tag) { - status_t res; - camera_metadata_entry entry; - res = find_camera_metadata_entry(mBuffer, tag, &entry); - if (CC_UNLIKELY( res != OK )) { - entry.count = 0; - entry.data.u8 = NULL; - } - return entry; -} - -camera_metadata_ro_entry_t CameraMetadata::find(uint32_t tag) const { - status_t res; - camera_metadata_ro_entry entry; - res = find_camera_metadata_ro_entry(mBuffer, tag, &entry); - if (CC_UNLIKELY( res != OK )) { - entry.count = 0; - entry.data.u8 = NULL; - } - return entry; -} - -status_t CameraMetadata::erase(uint32_t tag) { - camera_metadata_entry_t entry; - status_t res; - res = find_camera_metadata_entry(mBuffer, tag, &entry); - if (res == NAME_NOT_FOUND) { - return OK; - } else if (res != OK) { - ALOGE("%s: Error looking for entry %s.%s (%x): %s %d", - __FUNCTION__, - get_camera_metadata_section_name(tag), - get_camera_metadata_tag_name(tag), tag, strerror(-res), res); - return res; - } - res = delete_camera_metadata_entry(mBuffer, entry.index); - if (res != OK) { - ALOGE("%s: Error deleting entry %s.%s (%x): %s %d", - __FUNCTION__, - get_camera_metadata_section_name(tag), - get_camera_metadata_tag_name(tag), tag, strerror(-res), res); - } - return res; -} - -void CameraMetadata::dump(int fd, int verbosity, int indentation) const { - dump_indented_camera_metadata(mBuffer, fd, verbosity, indentation); -} - -status_t CameraMetadata::resizeIfNeeded(size_t extraEntries, size_t extraData) { - if (mBuffer == NULL) { - mBuffer = allocate_camera_metadata(extraEntries * 2, extraData * 2); - if (mBuffer == NULL) { - ALOGE("%s: Can't allocate larger metadata buffer", __FUNCTION__); - return NO_MEMORY; - } - } else { - size_t currentEntryCount = get_camera_metadata_entry_count(mBuffer); - size_t currentEntryCap = get_camera_metadata_entry_capacity(mBuffer); - size_t newEntryCount = currentEntryCount + - extraEntries; - newEntryCount = (newEntryCount > currentEntryCap) ? - newEntryCount * 2 : currentEntryCap; - - size_t currentDataCount = get_camera_metadata_data_count(mBuffer); - size_t currentDataCap = get_camera_metadata_data_capacity(mBuffer); - size_t newDataCount = currentDataCount + - extraData; - newDataCount = (newDataCount > currentDataCap) ? - newDataCount * 2 : currentDataCap; - - if (newEntryCount > currentEntryCap || - newDataCount > currentDataCap) { - camera_metadata_t *oldBuffer = mBuffer; - mBuffer = allocate_camera_metadata(newEntryCount, - newDataCount); - if (mBuffer == NULL) { - ALOGE("%s: Can't allocate larger metadata buffer", __FUNCTION__); - return NO_MEMORY; - } - append_camera_metadata(mBuffer, oldBuffer); - free_camera_metadata(oldBuffer); - } - } - return OK; -} - -}; // namespace camera2 -}; // namespace android diff --git a/services/camera/libcameraservice/camera2/CameraMetadata.h b/services/camera/libcameraservice/camera2/CameraMetadata.h deleted file mode 100644 index aee6cd7..0000000 --- a/services/camera/libcameraservice/camera2/CameraMetadata.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2012 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_CAMERA2METADATA_CPP -#define ANDROID_SERVERS_CAMERA_CAMERA2METADATA_CPP - -#include "system/camera_metadata.h" -#include <utils/String8.h> -#include <utils/Vector.h> - -namespace android { -namespace camera2 { - -/** - * A convenience wrapper around the C-based camera_metadata_t library. - */ -class CameraMetadata { - public: - /** Creates an empty object; best used when expecting to acquire contents - * from elsewhere */ - CameraMetadata(); - /** Creates an object with space for entryCapacity entries, with - * dataCapacity extra storage */ - CameraMetadata(size_t entryCapacity, size_t dataCapacity = 10); - - ~CameraMetadata(); - - /** Takes ownership of passed-in buffer */ - CameraMetadata(camera_metadata_t *buffer); - /** Clones the metadata */ - CameraMetadata(const CameraMetadata &other); - - /** - * Assignment clones metadata buffer. - */ - CameraMetadata &operator=(const CameraMetadata &other); - CameraMetadata &operator=(const camera_metadata_t *buffer); - - /** - * Release a raw metadata buffer to the caller. After this call, - * CameraMetadata no longer references the buffer, and the caller takes - * responsibility for freeing the raw metadata buffer (using - * free_camera_metadata()), or for handing it to another CameraMetadata - * instance. - */ - camera_metadata_t* release(); - - /** - * Clear the metadata buffer and free all storage used by it - */ - void clear(); - - /** - * Acquire a raw metadata buffer from the caller. After this call, - * the caller no longer owns the raw buffer, and must not free or manipulate it. - * If CameraMetadata already contains metadata, it is freed. - */ - void acquire(camera_metadata_t* buffer); - - /** - * Acquires raw buffer from other CameraMetadata object. After the call, the argument - * object no longer has any metadata. - */ - void acquire(CameraMetadata &other); - - /** - * Append metadata from another CameraMetadata object. - */ - status_t append(const CameraMetadata &other); - - /** - * Number of metadata entries. - */ - size_t entryCount() const; - - /** - * Is the buffer empty (no entires) - */ - bool isEmpty() const; - - /** - * Sort metadata buffer for faster find - */ - status_t sort(); - - /** - * Update metadata entry. Will create entry if it doesn't exist already, and - * will reallocate the buffer if insufficient space exists. Overloaded for - * the various types of valid data. - */ - status_t update(uint32_t tag, - const uint8_t *data, size_t data_count); - status_t update(uint32_t tag, - const int32_t *data, size_t data_count); - status_t update(uint32_t tag, - const float *data, size_t data_count); - status_t update(uint32_t tag, - const int64_t *data, size_t data_count); - status_t update(uint32_t tag, - const double *data, size_t data_count); - status_t update(uint32_t tag, - const camera_metadata_rational_t *data, size_t data_count); - status_t update(uint32_t tag, - const String8 &string); - - template<typename T> - status_t update(uint32_t tag, Vector<T> data) { - return update(tag, data.array(), data.size()); - } - - /** - * Get metadata entry by tag id - */ - camera_metadata_entry find(uint32_t tag); - - /** - * Get metadata entry by tag id, with no editing - */ - camera_metadata_ro_entry find(uint32_t tag) const; - - /** - * Delete metadata entry by tag - */ - status_t erase(uint32_t tag); - - /** - * Dump contents into FD for debugging. The verbosity levels are - * 0: Tag entry information only, no data values - * 1: Level 0 plus at most 16 data values per entry - * 2: All information - * - * The indentation parameter sets the number of spaces to add to the start - * each line of output. - */ - void dump(int fd, int verbosity = 1, int indentation = 0) const; - - private: - camera_metadata_t *mBuffer; - - /** - * Check if tag has a given type - */ - status_t checkType(uint32_t tag, uint8_t expectedType); - - /** - * Base update entry method - */ - status_t update(uint32_t tag, const void *data, size_t data_count); - - /** - * Resize metadata buffer if needed by reallocating it and copying it over. - */ - status_t resizeIfNeeded(size_t extraEntries, size_t extraData); - -}; - -}; // namespace camera2 -}; // namespace android - -#endif diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.h b/services/camera/libcameraservice/camera2/CaptureSequencer.h index c42df05..7db8007 100644 --- a/services/camera/libcameraservice/camera2/CaptureSequencer.h +++ b/services/camera/libcameraservice/camera2/CaptureSequencer.h @@ -23,7 +23,7 @@ #include <utils/Vector.h> #include <utils/Mutex.h> #include <utils/Condition.h> -#include "CameraMetadata.h" +#include "camera/CameraMetadata.h" #include "Parameters.h" #include "FrameProcessor.h" diff --git a/services/camera/libcameraservice/camera2/FrameProcessor.h b/services/camera/libcameraservice/camera2/FrameProcessor.h index 3bd4e25..66e3cda 100644 --- a/services/camera/libcameraservice/camera2/FrameProcessor.h +++ b/services/camera/libcameraservice/camera2/FrameProcessor.h @@ -22,7 +22,7 @@ #include <utils/Vector.h> #include <utils/KeyedVector.h> #include <utils/List.h> -#include "CameraMetadata.h" +#include "camera/CameraMetadata.h" struct camera_frame_metadata; diff --git a/services/camera/libcameraservice/camera2/JpegProcessor.h b/services/camera/libcameraservice/camera2/JpegProcessor.h index 836bd02..2283f28 100644 --- a/services/camera/libcameraservice/camera2/JpegProcessor.h +++ b/services/camera/libcameraservice/camera2/JpegProcessor.h @@ -24,7 +24,7 @@ #include <utils/Condition.h> #include <gui/CpuConsumer.h> #include "Parameters.h" -#include "CameraMetadata.h" +#include "camera/CameraMetadata.h" namespace android { diff --git a/services/camera/libcameraservice/camera2/Parameters.h b/services/camera/libcameraservice/camera2/Parameters.h index 9f5f03b..fe3ec1d 100644 --- a/services/camera/libcameraservice/camera2/Parameters.h +++ b/services/camera/libcameraservice/camera2/Parameters.h @@ -25,8 +25,7 @@ #include <utils/Vector.h> #include <utils/KeyedVector.h> #include <camera/CameraParameters.h> - -#include "CameraMetadata.h" +#include <camera/CameraMetadata.h> namespace android { namespace camera2 { diff --git a/services/camera/libcameraservice/camera2/StreamingProcessor.h b/services/camera/libcameraservice/camera2/StreamingProcessor.h index 96b100f..e5732ad 100644 --- a/services/camera/libcameraservice/camera2/StreamingProcessor.h +++ b/services/camera/libcameraservice/camera2/StreamingProcessor.h @@ -22,7 +22,7 @@ #include <gui/BufferItemConsumer.h> #include "Parameters.h" -#include "CameraMetadata.h" +#include "camera/CameraMetadata.h" namespace android { diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.h b/services/camera/libcameraservice/camera2/ZslProcessor.h index c80e7f4..ec16eef 100644 --- a/services/camera/libcameraservice/camera2/ZslProcessor.h +++ b/services/camera/libcameraservice/camera2/ZslProcessor.h @@ -25,7 +25,7 @@ #include <gui/BufferItemConsumer.h> #include "Parameters.h" #include "FrameProcessor.h" -#include "CameraMetadata.h" +#include "camera/CameraMetadata.h" #include "Camera2Heap.h" #include "../Camera2Device.h" |