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_METADATA_METADATA_READER_H_ 18 #define DEFAULT_CAMERA_HAL_METADATA_METADATA_READER_H_ 19 20 #include <memory> 21 #include <set> 22 #include <vector> 23 24 #include <android-base/macros.h> 25 #include <camera/CameraMetadata.h> 26 #include "types.h" 27 28 namespace default_camera_hal { 29 30 // A MetadataReader reads and converts/validates various metadata entries. 31 class MetadataReader { 32 public: 33 MetadataReader(std::unique_ptr<const android::CameraMetadata> metadata); 34 virtual ~MetadataReader(); 35 36 // Get a pointer to the underlying metadata being read. 37 // The pointer is valid only as long as this object is alive. 38 // The "locking" here only causes non-const methods to fail, 39 // which is not a problem since the CameraMetadata being locked 40 // is already const. This could be a problem if the metadata was 41 // shared more widely, but |metadata_| is a unique_ptr, 42 // guaranteeing the safety of this. Destructing automatically "unlocks". raw_metadata()43 virtual const camera_metadata_t* raw_metadata() const { 44 return metadata_->getAndLock(); 45 } 46 47 // All accessor methods must be given a valid pointer. They will return: 48 // 0: Success. 49 // -ENOENT: The necessary entry is missing. 50 // -EINVAL: The entry value is invalid. 51 // -ENODEV: Some other error occured. 52 53 // The |facing| returned will be one of the enum values from system/camera.h. 54 virtual int Facing(int* facing) const; 55 virtual int Orientation(int* orientation) const; 56 virtual int MaxInputStreams(int32_t* max_input_streams) const; 57 virtual int MaxOutputStreams(int32_t* max_raw_output_streams, 58 int32_t* max_non_stalling_output_streams, 59 int32_t* max_stalling_output_streams) const; 60 virtual int RequestCapabilities(std::set<uint8_t>* capabilites) const; 61 virtual int StreamConfigurations( 62 std::vector<StreamConfiguration>* configs) const; 63 virtual int StreamStallDurations( 64 std::vector<StreamStallDuration>* stalls) const; 65 virtual int ReprocessFormats(ReprocessFormatMap* reprocess_map) const; 66 67 private: 68 std::unique_ptr<const android::CameraMetadata> metadata_; 69 70 DISALLOW_COPY_AND_ASSIGN(MetadataReader); 71 }; 72 73 } // namespace default_camera_hal 74 75 #endif // DEFAULT_CAMERA_HAL_METADATA_METADATA_READER_H_ 76