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_TYPES_H_ 18 #define DEFAULT_CAMERA_HAL_METADATA_TYPES_H_ 19 20 #include <array> 21 #include <map> 22 #include <set> 23 24 #include <hardware/camera3.h> 25 26 namespace default_camera_hal { 27 28 // A variety of Structs describing more complex metadata entries. 29 30 // StreamSpec describe the attributes of a single stream. 31 struct StreamSpec { 32 int32_t format; 33 int32_t width; 34 int32_t height; 35 StreamSpecStreamSpec36 StreamSpec(int32_t f, int32_t w, int32_t h) 37 : format(f), width(w), height(h) {} StreamSpecStreamSpec38 StreamSpec(const camera3_stream_t* stream) 39 : format(stream->format), width(stream->width), height(stream->height) {} 40 41 struct Compare { operatorStreamSpec::Compare42 bool operator()(const StreamSpec& left, const StreamSpec& right) const { 43 // Base equality/comparison first on format, then on width, then height. 44 return left.format < right.format || 45 (left.format == right.format && 46 (left.width < right.width || 47 (left.width == right.width && left.height < right.height))); 48 } 49 }; 50 }; 51 52 // StreamConfigurations indicate a possible direction configuration for 53 // a given set of stream specifications. 54 typedef std::array<int32_t, 4> RawStreamConfiguration; 55 struct StreamConfiguration { 56 StreamSpec spec; 57 int32_t direction; 58 StreamConfigurationStreamConfiguration59 StreamConfiguration(const RawStreamConfiguration& raw) 60 : spec({raw[0], raw[1], raw[2]}), direction(raw[3]) {} 61 }; 62 63 // StreamStallDurations indicate the stall duration (in ns) for 64 // when a stream with a given set of specifications is used as output. 65 typedef std::array<int64_t, 4> RawStreamStallDuration; 66 struct StreamStallDuration { 67 StreamSpec spec; 68 int64_t duration; 69 StreamStallDurationStreamStallDuration70 StreamStallDuration(const RawStreamStallDuration& raw) 71 : spec({static_cast<int32_t>(raw[0]), 72 static_cast<int32_t>(raw[1]), 73 static_cast<int32_t>(raw[2])}), 74 duration(raw[3]) {} 75 }; 76 77 // Map input formats to their supported reprocess output formats. 78 typedef std::map<int32_t, std::set<int32_t>> ReprocessFormatMap; 79 80 } // namespace default_camera_hal 81 82 #endif // DEFAULT_CAMERA_HAL_METADATA_TYPES_H_ 83