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