diff options
author | Alex Ray <aray@google.com> | 2013-05-28 20:32:48 -0700 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2013-07-02 15:47:50 -0700 |
commit | 89a82661e07c49eaab07013be5ea03b84ea2715a (patch) | |
tree | 04455a8d577de9e063e87cb5e54e02ec18e2e83f /modules/camera/Metadata.cpp | |
parent | b5622ae96026431ca2789e9a264944e3f08222ed (diff) | |
download | hardware_libhardware-89a82661e07c49eaab07013be5ea03b84ea2715a.zip hardware_libhardware-89a82661e07c49eaab07013be5ea03b84ea2715a.tar.gz hardware_libhardware-89a82661e07c49eaab07013be5ea03b84ea2715a.tar.bz2 |
modules: camera: default request templates
Change-Id: I0a4b389e1850c10e12a65b3c8a5670c78c6746f7
Diffstat (limited to 'modules/camera/Metadata.cpp')
-rw-r--r-- | modules/camera/Metadata.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/modules/camera/Metadata.cpp b/modules/camera/Metadata.cpp index 77f5405..ad97b26 100644 --- a/modules/camera/Metadata.cpp +++ b/modules/camera/Metadata.cpp @@ -43,6 +43,33 @@ Metadata::~Metadata() { } +Metadata::Metadata(uint8_t mode, uint8_t intent) + : mHead(NULL), + mTail(NULL), + mEntryCount(0), + mDataCount(0) +{ + pthread_mutex_init(&mMutex, NULL); + + if (validate(ANDROID_CONTROL_MODE, TYPE_BYTE, 1)) { + int res = add(ANDROID_CONTROL_MODE, 1, &mode); + if (res != 0) { + ALOGE("%s: Unable to add mode to template!", __func__); + } + } else { + ALOGE("%s: Invalid mode constructing template!", __func__); + } + + if (validate(ANDROID_CONTROL_CAPTURE_INTENT, TYPE_BYTE, 1)) { + int res = add(ANDROID_CONTROL_CAPTURE_INTENT, 1, &intent); + if (res != 0) { + ALOGE("%s: Unable to add capture intent to template!", __func__); + } + } else { + ALOGE("%s: Invalid capture intent constructing template!", __func__); + } +} + int Metadata::addUInt8(uint32_t tag, int count, uint8_t *data) { if (!validate(tag, TYPE_BYTE, count)) return -EINVAL; @@ -113,9 +140,11 @@ int Metadata::add(uint32_t tag, int count, void *tag_data) return -ENOMEM; memcpy(data, tag_data, count * type_sz); + pthread_mutex_lock(&mMutex); mEntryCount++; mDataCount += calculate_camera_metadata_entry_data_size(tag_type, count); push(new Entry(tag, data, count)); + pthread_mutex_unlock(&mMutex); return 0; } |