Ari Hausman-Cohen | f45f8d4 | 2016-09-07 15:35:53 -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 DEFAULT_CAMERA_HAL_STATIC_PROPERTIES_H_ |
| 18 | #define DEFAULT_CAMERA_HAL_STATIC_PROPERTIES_H_ |
| 19 | |
| 20 | #include <memory> |
| 21 | |
| 22 | #include "common.h" |
| 23 | #include "metadata/metadata_reader.h" |
| 24 | |
| 25 | namespace default_camera_hal { |
| 26 | |
| 27 | // StaticProperties provides a wrapper around useful static metadata entries. |
| 28 | class StaticProperties { |
| 29 | public: |
| 30 | // Use this method to create StaticProperties objects. |
| 31 | // Functionally equivalent to "new StaticProperties", |
| 32 | // except that it may return nullptr in case of failure (missing entries). |
| 33 | static StaticProperties* NewStaticProperties( |
| 34 | std::unique_ptr<const MetadataReader> metadata_reader); |
| 35 | virtual ~StaticProperties(){}; |
| 36 | |
| 37 | int facing() const { return facing_; }; |
| 38 | int orientation() const { return orientation_; }; |
| 39 | // Carrying on the promise of the underlying reader, |
| 40 | // the returned pointer is valid only as long as this object is alive. |
| 41 | const camera_metadata_t* raw_metadata() const { |
| 42 | return metadata_reader_->raw_metadata(); |
| 43 | }; |
| 44 | |
| 45 | private: |
| 46 | // Constructor private to allow failing on bad input. |
| 47 | // Use NewStaticProperties instead. |
| 48 | StaticProperties(std::unique_ptr<const MetadataReader> metadata_reader, |
| 49 | int facing, |
| 50 | int orientation); |
| 51 | |
| 52 | const std::unique_ptr<const MetadataReader> metadata_reader_; |
| 53 | const int facing_; |
| 54 | const int orientation_; |
| 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(StaticProperties); |
| 57 | }; |
| 58 | |
| 59 | } // namespace default_camera_hal |
| 60 | |
| 61 | #endif // DEFAULT_CAMERA_HAL_STATIC_PROPERTIES_H_ |