Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Ari Hausman-Cohen | e55f0c7 | 2016-08-05 15:49:22 -0700 | [diff] [blame] | 20 | #include "metadata_common.h" |
Ari Hausman-Cohen | fd0ecb7 | 2016-08-12 15:45:25 -0700 | [diff] [blame] | 21 | #include "partial_metadata_interface.h" |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 22 | |
| 23 | namespace v4l2_camera_hal { |
| 24 | |
| 25 | // A Property is a PartialMetadata that only has a single static tag. |
| 26 | template <typename T> |
Ari Hausman-Cohen | fd0ecb7 | 2016-08-12 15:45:25 -0700 | [diff] [blame] | 27 | class Property : public PartialMetadataInterface { |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 28 | public: |
Ari Hausman-Cohen | ffdc628 | 2016-08-19 12:54:22 -0700 | [diff] [blame] | 29 | Property(int32_t tag, T value) : tag_(tag), value_(std::move(value)){}; |
Ari Hausman-Cohen | fd0ecb7 | 2016-08-12 15:45:25 -0700 | [diff] [blame] | 30 | |
| 31 | virtual std::vector<int32_t> StaticTags() const override { return {tag_}; }; |
| 32 | |
| 33 | virtual std::vector<int32_t> ControlTags() const override { return {}; }; |
| 34 | |
| 35 | virtual std::vector<int32_t> DynamicTags() const override { return {}; }; |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 36 | |
| 37 | virtual int PopulateStaticFields( |
| 38 | android::CameraMetadata* metadata) const override { |
Ari Hausman-Cohen | fd0ecb7 | 2016-08-12 15:45:25 -0700 | [diff] [blame] | 39 | return UpdateMetadata(metadata, tag_, value_); |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | virtual int PopulateDynamicFields( |
Sergii Piatakov | 4d3eb7a | 2018-08-03 18:03:44 +0300 | [diff] [blame] | 43 | android::CameraMetadata* /*metadata*/) const override { |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 44 | return 0; |
| 45 | }; |
| 46 | |
Ari Hausman-Cohen | 1026477 | 2016-08-22 13:49:43 -0700 | [diff] [blame] | 47 | virtual int PopulateTemplateRequest( |
Sergii Piatakov | 4d3eb7a | 2018-08-03 18:03:44 +0300 | [diff] [blame] | 48 | int /*template_type*/, android::CameraMetadata* /*metadata*/) const override { |
Ari Hausman-Cohen | 1026477 | 2016-08-22 13:49:43 -0700 | [diff] [blame] | 49 | return 0; |
| 50 | }; |
| 51 | |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 52 | virtual bool SupportsRequestValues( |
Sergii Piatakov | 4d3eb7a | 2018-08-03 18:03:44 +0300 | [diff] [blame] | 53 | const android::CameraMetadata& /*metadata*/) const override { |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 54 | return true; |
| 55 | }; |
| 56 | |
| 57 | virtual int SetRequestValues( |
Sergii Piatakov | 4d3eb7a | 2018-08-03 18:03:44 +0300 | [diff] [blame] | 58 | const android::CameraMetadata& /*metadata*/) override { |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 59 | return 0; |
| 60 | }; |
| 61 | |
Ari Hausman-Cohen | fd0ecb7 | 2016-08-12 15:45:25 -0700 | [diff] [blame] | 62 | private: |
| 63 | int32_t tag_; |
| 64 | T value_; |
Ari Hausman-Cohen | 407cca9 | 2016-08-02 11:03:15 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | } // namespace v4l2_camera_hal |
| 68 | |
| 69 | #endif // V4L2_CAMERA_HAL_METADATA_PROPERTY_H_ |