blob: a3ed6bfa8431707540e0d028662136994b3fe426 [file] [log] [blame]
Ari Hausman-Cohen407cca92016-08-02 11:03:15 -07001/*
2 * Copyright (C) 2016 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 V4L2_CAMERA_HAL_METADATA_PROPERTY_H_
18#define V4L2_CAMERA_HAL_METADATA_PROPERTY_H_
19
20#include "../common.h"
Ari Hausman-Cohene55f0c72016-08-05 15:49:22 -070021#include "metadata_common.h"
Ari Hausman-Cohen407cca92016-08-02 11:03:15 -070022#include "tagged_partial_metadata.h"
23
24namespace v4l2_camera_hal {
25
26// A Property is a PartialMetadata that only has a single static tag.
27template <typename T>
28class Property : public TaggedPartialMetadata {
29 public:
30 Property(int32_t tag) : TaggedPartialMetadata({tag}, {}, {}){};
31
32 virtual int PopulateStaticFields(
33 android::CameraMetadata* metadata) const override {
34 HAL_LOG_ENTER();
35 return UpdateMetadata(metadata, Tag(), Value());
36 };
37
38 virtual int PopulateDynamicFields(
39 android::CameraMetadata* metadata) const override {
40 HAL_LOG_ENTER();
41 return 0;
42 };
43
44 virtual bool SupportsRequestValues(
45 const android::CameraMetadata& metadata) const override {
46 HAL_LOG_ENTER();
47 return true;
48 };
49
50 virtual int SetRequestValues(
51 const android::CameraMetadata& metadata) override {
52 HAL_LOG_ENTER();
53 return 0;
54 };
55
56 protected:
57 // Simpler access to tag.
58 inline int32_t Tag() const { return StaticTags()[0]; }
59 // Get the value associated with this property.
60 virtual const T& Value() const = 0;
61};
62
63} // namespace v4l2_camera_hal
64
65#endif // V4L2_CAMERA_HAL_METADATA_PROPERTY_H_