blob: d5aac364b16575c7e1bbb6b76be9cc5b98401c67 [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();
31
32 // Parse and add an entry
33 int addUInt8(uint32_t tag, int count, uint8_t *data);
34 int addInt32(uint32_t tag, int count, int32_t *data);
35 int addFloat(uint32_t tag, int count, float *data);
36 int addInt64(uint32_t tag, int count, int64_t *data);
37 int addDouble(uint32_t tag, int count, double *data);
38 int addRational(uint32_t tag, int count,
39 camera_metadata_rational_t *data);
40 // Generate a camera_metadata structure and fill it with internal data
41 camera_metadata_t *generate();
42
43 private:
44 // Validate the tag, type and count for a metadata entry
45 bool validate(uint32_t tag, int tag_type, int count);
46 // Add a verified tag with data to this Metadata structure
47 int add(uint32_t tag, int count, void *tag_data);
48
49 class Entry {
50 public:
51 Entry(uint32_t tag, void *data, int count);
52 ~Entry();
53 Entry *mNext;
54 Entry *mPrev;
55 const uint32_t mTag;
56 const void *mData;
57 const int mCount;
58 void insertAfter(Entry *e);
59 };
60 // List ends
61 Entry *mHead;
62 Entry *mTail;
63 // Append entry to list
64 void push(Entry *e);
65 // Total of entries and entry data size
66 int mEntryCount;
67 int mDataCount;
68 // Save generated metadata, invalidated on update
69 camera_metadata_t *mGenerated;
70 // Lock protecting the Metadata object for modifications
71 pthread_mutex_t mMutex;
72};
73} // namespace default_camera_hal
74
75#endif // METADATA_H_