blob: 22d2f223175bafc0bae619cb1146d231a4fbe8b4 [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
20#include <hardware/camera3.h>
21#include <hardware/gralloc.h>
22#include <system/camera_metadata.h>
23#include <system/graphics.h>
24
25namespace default_camera_hal {
26// Metadata is a convenience class for dealing with libcamera_metadata
27class Metadata {
28 public:
29 Metadata();
30 ~Metadata();
Alex Ray89a82662013-05-28 20:32:48 -070031 // Constructor used for request metadata templates
32 Metadata(uint8_t mode, uint8_t intent);
Alex Rayb0be1032013-05-28 15:52:47 -070033
34 // Parse and add an entry
35 int addUInt8(uint32_t tag, int count, uint8_t *data);
36 int addInt32(uint32_t tag, int count, int32_t *data);
37 int addFloat(uint32_t tag, int count, float *data);
38 int addInt64(uint32_t tag, int count, int64_t *data);
39 int addDouble(uint32_t tag, int count, double *data);
40 int addRational(uint32_t tag, int count,
41 camera_metadata_rational_t *data);
42 // Generate a camera_metadata structure and fill it with internal data
43 camera_metadata_t *generate();
44
45 private:
46 // Validate the tag, type and count for a metadata entry
47 bool validate(uint32_t tag, int tag_type, int count);
48 // Add a verified tag with data to this Metadata structure
49 int add(uint32_t tag, int count, void *tag_data);
50
51 class Entry {
52 public:
53 Entry(uint32_t tag, void *data, int count);
54 ~Entry();
55 Entry *mNext;
56 Entry *mPrev;
57 const uint32_t mTag;
58 const void *mData;
59 const int mCount;
60 void insertAfter(Entry *e);
61 };
62 // List ends
63 Entry *mHead;
64 Entry *mTail;
65 // Append entry to list
66 void push(Entry *e);
67 // Total of entries and entry data size
68 int mEntryCount;
69 int mDataCount;
70 // Save generated metadata, invalidated on update
71 camera_metadata_t *mGenerated;
Alex Ray0d2a5222013-07-02 15:47:24 -070072 // Flag to force metadata regeneration
73 bool mDirty;
Alex Rayb0be1032013-05-28 15:52:47 -070074 // Lock protecting the Metadata object for modifications
75 pthread_mutex_t mMutex;
76};
77} // namespace default_camera_hal
78
79#endif // METADATA_H_