blob: f432d04b2501bcf37251f9ddea1adadf58587871 [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 Ray62735082013-10-21 12:55:24 -070020#include <stdint.h>
Alex Rayb0be1032013-05-28 15:52:47 -070021#include <hardware/camera3.h>
Alex Rayb0be1032013-05-28 15:52:47 -070022#include <system/camera_metadata.h>
Alex Rayb0be1032013-05-28 15:52:47 -070023
24namespace default_camera_hal {
25// Metadata is a convenience class for dealing with libcamera_metadata
26class Metadata {
27 public:
28 Metadata();
29 ~Metadata();
Alex Ray62735082013-10-21 12:55:24 -070030 // Initialize with framework metadata
31 int init(const camera_metadata_t *metadata);
Alex Rayb0be1032013-05-28 15:52:47 -070032
Alex Ray62735082013-10-21 12:55:24 -070033 // Parse and add an entry. Allocates and copies new storage for *data.
34 int addUInt8(uint32_t tag, int count, const uint8_t *data);
35 int add1UInt8(uint32_t tag, const uint8_t data);
36 int addInt32(uint32_t tag, int count, const int32_t *data);
37 int addFloat(uint32_t tag, int count, const float *data);
38 int addInt64(uint32_t tag, int count, const int64_t *data);
39 int addDouble(uint32_t tag, int count, const double *data);
Alex Rayb0be1032013-05-28 15:52:47 -070040 int addRational(uint32_t tag, int count,
Alex Ray62735082013-10-21 12:55:24 -070041 const camera_metadata_rational_t *data);
42
43 // Get a handle to the current metadata
44 // This is not a durable handle, and may be destroyed by add*/init
45 camera_metadata_t* get();
Alex Rayb0be1032013-05-28 15:52:47 -070046
47 private:
Alex Ray62735082013-10-21 12:55:24 -070048 // Actual internal storage
49 camera_metadata_t* mData;
50 // Destroy old metadata and replace with new
51 void replace(camera_metadata_t *m);
Alex Rayb0be1032013-05-28 15:52:47 -070052 // Validate the tag, type and count for a metadata entry
53 bool validate(uint32_t tag, int tag_type, int count);
Alex Ray62735082013-10-21 12:55:24 -070054 // Add a verified tag with data
55 int add(uint32_t tag, int count, const void *tag_data);
Alex Rayb0be1032013-05-28 15:52:47 -070056};
57} // namespace default_camera_hal
58
59#endif // METADATA_H_