blob: c0d9492d1d25b280da9a11b43dfbb10b15c9ab8d [file] [log] [blame]
Alex Rayb0be1032013-05-28 15:52:47 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef METADATA_H_
18#define METADATA_H_
19
Alex Ray7915e972013-10-17 21:52:03 -070020#include <pthread.h>
Alex Rayb0be1032013-05-28 15:52:47 -070021#include <hardware/camera3.h>
22#include <hardware/gralloc.h>
23#include <system/camera_metadata.h>
24#include <system/graphics.h>
25
26namespace default_camera_hal {
27// Metadata is a convenience class for dealing with libcamera_metadata
28class Metadata {
29 public:
30 Metadata();
31 ~Metadata();
Alex Ray89a82662013-05-28 20:32:48 -070032 // Constructor used for request metadata templates
33 Metadata(uint8_t mode, uint8_t intent);
Alex Rayb0be1032013-05-28 15:52:47 -070034
35 // Parse and add an entry
36 int addUInt8(uint32_t tag, int count, uint8_t *data);
37 int addInt32(uint32_t tag, int count, int32_t *data);
38 int addFloat(uint32_t tag, int count, float *data);
39 int addInt64(uint32_t tag, int count, int64_t *data);
40 int addDouble(uint32_t tag, int count, double *data);
41 int addRational(uint32_t tag, int count,
42 camera_metadata_rational_t *data);
43 // Generate a camera_metadata structure and fill it with internal data
44 camera_metadata_t *generate();
45
46 private:
47 // Validate the tag, type and count for a metadata entry
48 bool validate(uint32_t tag, int tag_type, int count);
49 // Add a verified tag with data to this Metadata structure
50 int add(uint32_t tag, int count, void *tag_data);
51
52 class Entry {
53 public:
54 Entry(uint32_t tag, void *data, int count);
55 ~Entry();
56 Entry *mNext;
57 Entry *mPrev;
58 const uint32_t mTag;
59 const void *mData;
60 const int mCount;
61 void insertAfter(Entry *e);
62 };
63 // List ends
64 Entry *mHead;
65 Entry *mTail;
66 // Append entry to list
67 void push(Entry *e);
68 // Total of entries and entry data size
69 int mEntryCount;
70 int mDataCount;
71 // Save generated metadata, invalidated on update
72 camera_metadata_t *mGenerated;
Alex Ray0d2a5222013-07-02 15:47:24 -070073 // Flag to force metadata regeneration
74 bool mDirty;
Alex Rayb0be1032013-05-28 15:52:47 -070075 // Lock protecting the Metadata object for modifications
76 pthread_mutex_t mMutex;
77};
78} // namespace default_camera_hal
79
80#endif // METADATA_H_