• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 <stdint.h>
21 #include <hardware/camera3.h>
22 #include <system/camera_metadata.h>
23 
24 namespace default_camera_hal {
25 // Metadata is a convenience class for dealing with libcamera_metadata
26 class Metadata {
27     public:
28         Metadata();
29         ~Metadata();
30         // Initialize with framework metadata
31         int init(const camera_metadata_t *metadata);
32 
33         // 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);
40         int addRational(uint32_t tag, int count,
41                 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();
46 
47     private:
48         // Actual internal storage
49         camera_metadata_t* mData;
50         // Destroy old metadata and replace with new
51         void replace(camera_metadata_t *m);
52         // Validate the tag, type and count for a metadata entry
53         bool validate(uint32_t tag, int tag_type, int count);
54         // Add a verified tag with data
55         int add(uint32_t tag, int count, const void *tag_data);
56 };
57 } // namespace default_camera_hal
58 
59 #endif // METADATA_H_
60