• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TAGGED_CONTROL_OPTIONS_H_
18 #define V4L2_CAMERA_HAL_METADATA_TAGGED_CONTROL_OPTIONS_H_
19 
20 #include <memory>
21 
22 #include "control_options_interface.h"
23 
24 namespace v4l2_camera_hal {
25 
26 // A constant tag with a value not used as a real tag
27 // (since all real tags are unsigned),  to indicate options
28 // that should not be reported.
29 // Any class working with TaggedControlOptions should check
30 // the tag against this value before using it.
31 static int32_t DO_NOT_REPORT_OPTIONS = -1;
32 
33 // A TaggedControlOptions wraps a ControlOptions and adds a tag.
34 template <typename T>
35 class TaggedControlOptions : public ControlOptionsInterface<T> {
36  public:
TaggedControlOptions(int32_t tag,std::unique_ptr<ControlOptionsInterface<T>> options)37   TaggedControlOptions(int32_t tag,
38                        std::unique_ptr<ControlOptionsInterface<T>> options)
39       : tag_(tag), options_(std::move(options)){};
40 
tag()41   int32_t tag() { return tag_; };
42 
MetadataRepresentation()43   virtual std::vector<T> MetadataRepresentation() override {
44     return options_->MetadataRepresentation();
45   };
IsSupported(const T & value)46   virtual bool IsSupported(const T& value) override {
47     return options_->IsSupported(value);
48   };
DefaultValueForTemplate(int template_type,T * default_value)49   virtual int DefaultValueForTemplate(int template_type,
50                                       T* default_value) override {
51     return options_->DefaultValueForTemplate(template_type, default_value);
52   }
53 
54  private:
55   const int32_t tag_;
56   std::unique_ptr<ControlOptionsInterface<T>> options_;
57 };
58 
59 }  // namespace v4l2_camera_hal
60 
61 #endif  // V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_H_
62