Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 1 | /* |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 2 | * Copyright 2023 The Android Open Source Project |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 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 | // #define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "VirtualCameraDevice" |
| 19 | #include "VirtualCameraDevice.h" |
| 20 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 21 | #include <algorithm> |
| 22 | #include <array> |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 23 | #include <chrono> |
| 24 | #include <cstdint> |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 25 | #include <iterator> |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 26 | #include <numeric> |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 27 | #include <optional> |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 28 | #include <string> |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 29 | #include <vector> |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 30 | |
| 31 | #include "VirtualCameraSession.h" |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 32 | #include "aidl/android/companion/virtualcamera/SupportedStreamConfiguration.h" |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 33 | #include "aidl/android/companion/virtualcamera/VirtualCameraConfiguration.h" |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 34 | #include "aidl/android/hardware/camera/common/Status.h" |
| 35 | #include "aidl/android/hardware/camera/device/CameraMetadata.h" |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 36 | #include "aidl/android/hardware/camera/device/StreamConfiguration.h" |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 37 | #include "android/binder_auto_utils.h" |
| 38 | #include "android/binder_status.h" |
| 39 | #include "log/log.h" |
| 40 | #include "system/camera_metadata.h" |
Jan Sebechlebsky | 4ce3208 | 2024-02-14 16:02:11 +0100 | [diff] [blame] | 41 | #include "util/MetadataUtil.h" |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 42 | #include "util/Util.h" |
| 43 | |
| 44 | namespace android { |
| 45 | namespace companion { |
| 46 | namespace virtualcamera { |
| 47 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 48 | using ::aidl::android::companion::virtualcamera::Format; |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 49 | using ::aidl::android::companion::virtualcamera::IVirtualCameraCallback; |
Biswarup Pal | 112458f | 2023-12-28 19:50:17 +0000 | [diff] [blame] | 50 | using ::aidl::android::companion::virtualcamera::LensFacing; |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 51 | using ::aidl::android::companion::virtualcamera::SensorOrientation; |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 52 | using ::aidl::android::companion::virtualcamera::SupportedStreamConfiguration; |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 53 | using ::aidl::android::companion::virtualcamera::VirtualCameraConfiguration; |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 54 | using ::aidl::android::hardware::camera::common::CameraResourceCost; |
| 55 | using ::aidl::android::hardware::camera::common::Status; |
| 56 | using ::aidl::android::hardware::camera::device::CameraMetadata; |
| 57 | using ::aidl::android::hardware::camera::device::ICameraDeviceCallback; |
| 58 | using ::aidl::android::hardware::camera::device::ICameraDeviceSession; |
| 59 | using ::aidl::android::hardware::camera::device::ICameraInjectionSession; |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 60 | using ::aidl::android::hardware::camera::device::Stream; |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 61 | using ::aidl::android::hardware::camera::device::StreamConfiguration; |
| 62 | using ::aidl::android::hardware::camera::device::StreamRotation; |
| 63 | using ::aidl::android::hardware::camera::device::StreamType; |
| 64 | using ::aidl::android::hardware::graphics::common::PixelFormat; |
| 65 | |
| 66 | namespace { |
| 67 | |
| 68 | using namespace std::chrono_literals; |
| 69 | |
| 70 | // Prefix of camera name - "device@1.1/virtual/{numerical_id}" |
| 71 | const char* kDevicePathPrefix = "device@1.1/virtual/"; |
| 72 | |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 73 | constexpr int32_t kMaxJpegSize = 3 * 1024 * 1024 /*3MiB*/; |
| 74 | |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 75 | constexpr int32_t kMinFps = 15; |
| 76 | |
| 77 | constexpr std::chrono::nanoseconds kMaxFrameDuration = |
| 78 | std::chrono::duration_cast<std::chrono::nanoseconds>(1e9ns / kMinFps); |
| 79 | |
| 80 | constexpr uint8_t kPipelineMaxDepth = 2; |
| 81 | |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 82 | constexpr MetadataBuilder::ControlRegion kDefaultEmptyControlRegion{}; |
| 83 | |
Jan Sebechlebsky | 4ce3208 | 2024-02-14 16:02:11 +0100 | [diff] [blame] | 84 | const std::array<Resolution, 5> kStandardJpegThumbnailSizes{ |
| 85 | Resolution(176, 144), Resolution(240, 144), Resolution(256, 144), |
| 86 | Resolution(240, 160), Resolution(240, 180)}; |
| 87 | |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 88 | const std::array<PixelFormat, 3> kOutputFormats{ |
| 89 | PixelFormat::IMPLEMENTATION_DEFINED, PixelFormat::YCBCR_420_888, |
| 90 | PixelFormat::BLOB}; |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 91 | |
Jan Sebechlebsky | 4c9bb1e | 2024-02-28 16:32:39 +0100 | [diff] [blame] | 92 | // The resolutions below will used to extend the set of supported output formats. |
| 93 | // All resolutions with lower pixel count and same aspect ratio as some supported |
| 94 | // input resolution will be added to the set of supported output resolutions. |
| 95 | const std::array<Resolution, 10> kOutputResolutions{ |
| 96 | Resolution(320, 240), Resolution(640, 360), Resolution(640, 480), |
| 97 | Resolution(720, 480), Resolution(720, 576), Resolution(800, 600), |
| 98 | Resolution(1024, 576), Resolution(1280, 720), Resolution(1280, 960), |
| 99 | Resolution(1280, 1080), |
| 100 | }; |
Jan Sebechlebsky | 4ce3208 | 2024-02-14 16:02:11 +0100 | [diff] [blame] | 101 | |
| 102 | std::vector<Resolution> getSupportedJpegThumbnailSizes( |
| 103 | const std::vector<SupportedStreamConfiguration>& configs) { |
| 104 | auto isSupportedByAnyInputConfig = |
| 105 | [&configs](const Resolution thumbnailResolution) { |
| 106 | return std::any_of( |
| 107 | configs.begin(), configs.end(), |
| 108 | [thumbnailResolution](const SupportedStreamConfiguration& config) { |
| 109 | return isApproximatellySameAspectRatio( |
| 110 | thumbnailResolution, Resolution(config.width, config.height)); |
| 111 | }); |
| 112 | }; |
| 113 | |
| 114 | std::vector<Resolution> supportedThumbnailSizes({Resolution(0, 0)}); |
| 115 | std::copy_if(kStandardJpegThumbnailSizes.begin(), |
| 116 | kStandardJpegThumbnailSizes.end(), |
| 117 | std::back_insert_iterator(supportedThumbnailSizes), |
| 118 | isSupportedByAnyInputConfig); |
| 119 | return supportedThumbnailSizes; |
| 120 | } |
| 121 | |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 122 | bool isSupportedOutputFormat(const PixelFormat pixelFormat) { |
| 123 | return std::find(kOutputFormats.begin(), kOutputFormats.end(), pixelFormat) != |
| 124 | kOutputFormats.end(); |
| 125 | } |
| 126 | |
Vadim Caen | 11dfd93 | 2024-03-05 09:57:20 +0100 | [diff] [blame^] | 127 | std::vector<FpsRange> fpsRangesForInputConfig( |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 128 | const std::vector<SupportedStreamConfiguration>& configs) { |
Vadim Caen | 11dfd93 | 2024-03-05 09:57:20 +0100 | [diff] [blame^] | 129 | std::set<FpsRange> availableRanges; |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 130 | |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 131 | for (const SupportedStreamConfiguration& config : configs) { |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 132 | availableRanges.insert({.minFps = kMinFps, .maxFps = config.maxFps}); |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 133 | availableRanges.insert({.minFps = config.maxFps, .maxFps = config.maxFps}); |
| 134 | } |
| 135 | |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 136 | if (std::any_of(configs.begin(), configs.end(), |
| 137 | [](const SupportedStreamConfiguration& config) { |
| 138 | return config.maxFps >= 30; |
| 139 | })) { |
| 140 | availableRanges.insert({.minFps = kMinFps, .maxFps = 30}); |
| 141 | availableRanges.insert({.minFps = 30, .maxFps = 30}); |
| 142 | } |
| 143 | |
Vadim Caen | 11dfd93 | 2024-03-05 09:57:20 +0100 | [diff] [blame^] | 144 | return std::vector<FpsRange>(availableRanges.begin(), availableRanges.end()); |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 145 | } |
| 146 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 147 | std::optional<Resolution> getMaxResolution( |
| 148 | const std::vector<SupportedStreamConfiguration>& configs) { |
| 149 | auto itMax = std::max_element(configs.begin(), configs.end(), |
| 150 | [](const SupportedStreamConfiguration& a, |
| 151 | const SupportedStreamConfiguration& b) { |
| 152 | return a.width * b.height < a.width * b.height; |
| 153 | }); |
| 154 | if (itMax == configs.end()) { |
| 155 | ALOGE( |
| 156 | "%s: empty vector of supported configurations, cannot find largest " |
| 157 | "resolution.", |
| 158 | __func__); |
| 159 | return std::nullopt; |
| 160 | } |
| 161 | |
| 162 | return Resolution(itMax->width, itMax->height); |
| 163 | } |
| 164 | |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 165 | // Returns a map of unique resolution to maximum maxFps for all streams with |
| 166 | // that resolution. |
| 167 | std::map<Resolution, int> getResolutionToMaxFpsMap( |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 168 | const std::vector<SupportedStreamConfiguration>& configs) { |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 169 | std::map<Resolution, int> resolutionToMaxFpsMap; |
| 170 | |
| 171 | for (const SupportedStreamConfiguration& config : configs) { |
| 172 | Resolution resolution(config.width, config.height); |
| 173 | if (resolutionToMaxFpsMap.find(resolution) == resolutionToMaxFpsMap.end()) { |
| 174 | resolutionToMaxFpsMap[resolution] = config.maxFps; |
| 175 | } else { |
| 176 | int currentMaxFps = resolutionToMaxFpsMap[resolution]; |
| 177 | resolutionToMaxFpsMap[resolution] = std::max(currentMaxFps, config.maxFps); |
| 178 | } |
| 179 | } |
| 180 | |
Jan Sebechlebsky | 4c9bb1e | 2024-02-28 16:32:39 +0100 | [diff] [blame] | 181 | std::map<Resolution, int> additionalResolutionToMaxFpsMap; |
| 182 | // Add additional resolutions we can support by downscaling input streams with |
| 183 | // same aspect ratio. |
| 184 | for (const Resolution& outputResolution : kOutputResolutions) { |
| 185 | for (const auto& [resolution, maxFps] : resolutionToMaxFpsMap) { |
| 186 | if (resolutionToMaxFpsMap.find(outputResolution) != |
| 187 | resolutionToMaxFpsMap.end()) { |
| 188 | // Resolution is already in the map, skip it. |
| 189 | continue; |
| 190 | } |
| 191 | |
| 192 | if (outputResolution < resolution && |
| 193 | isApproximatellySameAspectRatio(outputResolution, resolution)) { |
| 194 | // Lower resolution with same aspect ratio, we can achieve this by |
| 195 | // downscaling, let's add it to the map. |
| 196 | ALOGD( |
| 197 | "Extending set of output resolutions with %dx%d which has same " |
| 198 | "aspect ratio as supported input %dx%d.", |
| 199 | outputResolution.width, outputResolution.height, resolution.width, |
| 200 | resolution.height); |
| 201 | additionalResolutionToMaxFpsMap[outputResolution] = maxFps; |
| 202 | break; |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | // Add all resolution we can achieve by downscaling to the map. |
| 208 | resolutionToMaxFpsMap.insert(additionalResolutionToMaxFpsMap.begin(), |
| 209 | additionalResolutionToMaxFpsMap.end()); |
| 210 | |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 211 | return resolutionToMaxFpsMap; |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 212 | } |
| 213 | |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 214 | // TODO(b/301023410) - Populate camera characteristics according to camera configuration. |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 215 | std::optional<CameraMetadata> initCameraCharacteristics( |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 216 | const std::vector<SupportedStreamConfiguration>& supportedInputConfig, |
Biswarup Pal | 112458f | 2023-12-28 19:50:17 +0000 | [diff] [blame] | 217 | const SensorOrientation sensorOrientation, const LensFacing lensFacing) { |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 218 | if (!std::all_of(supportedInputConfig.begin(), supportedInputConfig.end(), |
| 219 | [](const SupportedStreamConfiguration& config) { |
Jan Sebechlebsky | 042d1fb | 2023-12-12 16:37:00 +0100 | [diff] [blame] | 220 | return isFormatSupportedForInput( |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 221 | config.width, config.height, config.pixelFormat, |
| 222 | config.maxFps); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 223 | })) { |
Jan Sebechlebsky | 042d1fb | 2023-12-12 16:37:00 +0100 | [diff] [blame] | 224 | ALOGE("%s: input configuration contains unsupported format", __func__); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 225 | return std::nullopt; |
| 226 | } |
| 227 | |
| 228 | MetadataBuilder builder = |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 229 | MetadataBuilder() |
| 230 | .setSupportedHardwareLevel( |
| 231 | ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL) |
| 232 | .setFlashAvailable(false) |
Biswarup Pal | 112458f | 2023-12-28 19:50:17 +0000 | [diff] [blame] | 233 | .setLensFacing( |
| 234 | static_cast<camera_metadata_enum_android_lens_facing>(lensFacing)) |
Biswarup Pal | 8ad8bc5 | 2024-02-08 13:41:44 +0000 | [diff] [blame] | 235 | .setAvailableFocalLengths({VirtualCameraDevice::kFocalLength}) |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 236 | .setSensorOrientation(static_cast<int32_t>(sensorOrientation)) |
Jan Sebechlebsky | a984ffb | 2024-02-01 09:12:37 +0100 | [diff] [blame] | 237 | .setSensorReadoutTimestamp( |
| 238 | ANDROID_SENSOR_READOUT_TIMESTAMP_NOT_SUPPORTED) |
Jan Sebechlebsky | ad8d35f | 2024-02-05 11:58:59 +0100 | [diff] [blame] | 239 | .setSensorTimestampSource(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN) |
Biswarup Pal | d9be04d | 2024-01-31 14:35:15 +0000 | [diff] [blame] | 240 | .setSensorPhysicalSize(36.0, 24.0) |
Jan Sebechlebsky | ab37820 | 2024-02-26 10:50:42 +0100 | [diff] [blame] | 241 | .setAvailableAberrationCorrectionModes( |
| 242 | {ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF}) |
| 243 | .setAvailableNoiseReductionModes({ANDROID_NOISE_REDUCTION_MODE_OFF}) |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 244 | .setAvailableFaceDetectModes({ANDROID_STATISTICS_FACE_DETECT_MODE_OFF}) |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 245 | .setAvailableTestPatternModes({ANDROID_SENSOR_TEST_PATTERN_MODE_OFF}) |
Jan Sebechlebsky | b0119fa | 2023-12-04 10:29:06 +0100 | [diff] [blame] | 246 | .setAvailableMaxDigitalZoom(1.0) |
| 247 | .setControlAvailableModes({ANDROID_CONTROL_MODE_AUTO}) |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 248 | .setControlAfAvailableModes({ANDROID_CONTROL_AF_MODE_OFF}) |
Jan Sebechlebsky | 4425a73 | 2024-01-31 11:31:54 +0100 | [diff] [blame] | 249 | .setControlAvailableSceneModes({ANDROID_CONTROL_SCENE_MODE_DISABLED}) |
| 250 | .setControlAvailableEffects({ANDROID_CONTROL_EFFECT_MODE_OFF}) |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 251 | .setControlAvailableVideoStabilizationModes( |
| 252 | {ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF}) |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 253 | .setControlAeAvailableModes({ANDROID_CONTROL_AE_MODE_ON}) |
| 254 | .setControlAeAvailableAntibandingModes( |
| 255 | {ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO}) |
| 256 | .setControlAeAvailableFpsRanges( |
| 257 | fpsRangesForInputConfig(supportedInputConfig)) |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 258 | .setControlMaxRegions(0, 0, 0) |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 259 | .setControlAfRegions({kDefaultEmptyControlRegion}) |
| 260 | .setControlAeRegions({kDefaultEmptyControlRegion}) |
| 261 | .setControlAwbRegions({kDefaultEmptyControlRegion}) |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 262 | .setControlAeCompensationRange(0, 0) |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 263 | .setControlAeCompensationStep(camera_metadata_rational_t{0, 1}) |
Jan Sebechlebsky | 4425a73 | 2024-01-31 11:31:54 +0100 | [diff] [blame] | 264 | .setControlAwbLockAvailable(false) |
| 265 | .setControlAeLockAvailable(false) |
| 266 | .setControlAvailableAwbModes({ANDROID_CONTROL_AWB_MODE_AUTO}) |
Jan Sebechlebsky | 6ab07fe | 2023-12-05 15:23:34 +0100 | [diff] [blame] | 267 | .setControlZoomRatioRange(/*min=*/1.0, /*max=*/1.0) |
Jan Sebechlebsky | ab37820 | 2024-02-26 10:50:42 +0100 | [diff] [blame] | 268 | .setCroppingType(ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY) |
Jan Sebechlebsky | 4ce3208 | 2024-02-14 16:02:11 +0100 | [diff] [blame] | 269 | .setJpegAvailableThumbnailSizes( |
| 270 | getSupportedJpegThumbnailSizes(supportedInputConfig)) |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 271 | .setMaxJpegSize(kMaxJpegSize) |
Jan Sebechlebsky | ab37820 | 2024-02-26 10:50:42 +0100 | [diff] [blame] | 272 | .setMaxFaceCount(0) |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 273 | .setMaxFrameDuration(kMaxFrameDuration) |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 274 | .setMaxNumberOutputStreams( |
| 275 | VirtualCameraDevice::kMaxNumberOfRawStreams, |
| 276 | VirtualCameraDevice::kMaxNumberOfProcessedStreams, |
| 277 | VirtualCameraDevice::kMaxNumberOfStallStreams) |
Jan Sebechlebsky | ab37820 | 2024-02-26 10:50:42 +0100 | [diff] [blame] | 278 | .setRequestPartialResultCount(1) |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 279 | .setPipelineMaxDepth(kPipelineMaxDepth) |
Jan Sebechlebsky | 4425a73 | 2024-01-31 11:31:54 +0100 | [diff] [blame] | 280 | .setSyncMaxLatency(ANDROID_SYNC_MAX_LATENCY_UNKNOWN) |
Jan Sebechlebsky | 4be2bd0 | 2024-02-26 18:35:18 +0100 | [diff] [blame] | 281 | .setAvailableRequestKeys({ANDROID_COLOR_CORRECTION_ABERRATION_MODE, |
| 282 | ANDROID_CONTROL_CAPTURE_INTENT, |
Jan Sebechlebsky | 4ce3208 | 2024-02-14 16:02:11 +0100 | [diff] [blame] | 283 | ANDROID_CONTROL_AE_MODE, |
| 284 | ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, |
| 285 | ANDROID_CONTROL_AE_TARGET_FPS_RANGE, |
| 286 | ANDROID_CONTROL_AE_ANTIBANDING_MODE, |
| 287 | ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, |
| 288 | ANDROID_CONTROL_AF_TRIGGER, |
| 289 | ANDROID_CONTROL_AF_MODE, |
| 290 | ANDROID_CONTROL_AWB_MODE, |
| 291 | ANDROID_SCALER_CROP_REGION, |
| 292 | ANDROID_CONTROL_EFFECT_MODE, |
| 293 | ANDROID_CONTROL_MODE, |
| 294 | ANDROID_CONTROL_SCENE_MODE, |
| 295 | ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, |
| 296 | ANDROID_CONTROL_ZOOM_RATIO, |
Jan Sebechlebsky | 4ce3208 | 2024-02-14 16:02:11 +0100 | [diff] [blame] | 297 | ANDROID_FLASH_MODE, |
| 298 | ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, |
| 299 | ANDROID_JPEG_QUALITY, |
Jan Sebechlebsky | 4be2bd0 | 2024-02-26 18:35:18 +0100 | [diff] [blame] | 300 | ANDROID_JPEG_THUMBNAIL_QUALITY, |
| 301 | ANDROID_NOISE_REDUCTION_MODE, |
| 302 | ANDROID_STATISTICS_FACE_DETECT_MODE}) |
Vadim Caen | 11dfd93 | 2024-03-05 09:57:20 +0100 | [diff] [blame^] | 303 | .setAvailableResultKeys({ |
| 304 | ANDROID_COLOR_CORRECTION_ABERRATION_MODE, |
| 305 | ANDROID_CONTROL_AE_ANTIBANDING_MODE, |
| 306 | ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, |
| 307 | ANDROID_CONTROL_AE_LOCK, |
| 308 | ANDROID_CONTROL_AE_MODE, |
| 309 | ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, |
| 310 | ANDROID_CONTROL_AE_STATE, |
| 311 | ANDROID_CONTROL_AE_TARGET_FPS_RANGE, |
| 312 | ANDROID_CONTROL_AF_MODE, |
| 313 | ANDROID_CONTROL_AF_STATE, |
| 314 | ANDROID_CONTROL_AF_TRIGGER, |
| 315 | ANDROID_CONTROL_AWB_LOCK, |
| 316 | ANDROID_CONTROL_AWB_MODE, |
| 317 | ANDROID_CONTROL_AWB_STATE, |
| 318 | ANDROID_CONTROL_CAPTURE_INTENT, |
| 319 | ANDROID_CONTROL_EFFECT_MODE, |
| 320 | ANDROID_CONTROL_MODE, |
| 321 | ANDROID_CONTROL_SCENE_MODE, |
| 322 | ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, |
| 323 | ANDROID_STATISTICS_FACE_DETECT_MODE, |
| 324 | ANDROID_FLASH_MODE, |
| 325 | ANDROID_FLASH_STATE, |
| 326 | ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, |
| 327 | ANDROID_JPEG_QUALITY, |
| 328 | ANDROID_JPEG_THUMBNAIL_QUALITY, |
| 329 | ANDROID_LENS_FOCAL_LENGTH, |
| 330 | ANDROID_LENS_OPTICAL_STABILIZATION_MODE, |
| 331 | ANDROID_NOISE_REDUCTION_MODE, |
| 332 | ANDROID_REQUEST_PIPELINE_DEPTH, |
| 333 | ANDROID_SENSOR_TIMESTAMP, |
| 334 | ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE, |
| 335 | ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, |
| 336 | ANDROID_STATISTICS_SCENE_FLICKER, |
| 337 | }) |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 338 | .setAvailableCapabilities( |
Jan Sebechlebsky | ad8d35f | 2024-02-05 11:58:59 +0100 | [diff] [blame] | 339 | {ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE}); |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 340 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 341 | // Active array size must correspond to largest supported input resolution. |
| 342 | std::optional<Resolution> maxResolution = |
| 343 | getMaxResolution(supportedInputConfig); |
| 344 | if (!maxResolution.has_value()) { |
| 345 | return std::nullopt; |
| 346 | } |
| 347 | builder.setSensorActiveArraySize(0, 0, maxResolution->width, |
| 348 | maxResolution->height); |
Biswarup Pal | d9be04d | 2024-01-31 14:35:15 +0000 | [diff] [blame] | 349 | builder.setSensorPixelArraySize(maxResolution->width, maxResolution->height); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 350 | |
| 351 | std::vector<MetadataBuilder::StreamConfiguration> outputConfigurations; |
| 352 | |
| 353 | // TODO(b/301023410) Add also all "standard" resolutions we can rescale the |
| 354 | // streams to (all standard resolutions with same aspect ratio). |
| 355 | |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 356 | std::map<Resolution, int> resolutionToMaxFpsMap = |
| 357 | getResolutionToMaxFpsMap(supportedInputConfig); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 358 | |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 359 | // Add configurations for all unique input resolutions and output formats. |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 360 | for (const PixelFormat format : kOutputFormats) { |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 361 | std::transform( |
| 362 | resolutionToMaxFpsMap.begin(), resolutionToMaxFpsMap.end(), |
| 363 | std::back_inserter(outputConfigurations), [format](const auto& entry) { |
| 364 | Resolution resolution = entry.first; |
| 365 | int maxFps = entry.second; |
| 366 | return MetadataBuilder::StreamConfiguration{ |
| 367 | .width = resolution.width, |
| 368 | .height = resolution.height, |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 369 | .format = static_cast<int32_t>(format), |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 370 | .minFrameDuration = std::chrono::nanoseconds(1s) / maxFps, |
| 371 | .minStallDuration = 0s}; |
| 372 | }); |
| 373 | } |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 374 | |
| 375 | ALOGV("Adding %zu output configurations", outputConfigurations.size()); |
| 376 | builder.setAvailableOutputStreamConfigurations(outputConfigurations); |
| 377 | |
Jan Sebechlebsky | ad8d35f | 2024-02-05 11:58:59 +0100 | [diff] [blame] | 378 | auto metadata = builder.setAvailableCharacteristicKeys().build(); |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 379 | if (metadata == nullptr) { |
| 380 | ALOGE("Failed to build metadata!"); |
| 381 | return CameraMetadata(); |
| 382 | } |
| 383 | |
| 384 | return std::move(*metadata); |
| 385 | } |
| 386 | |
| 387 | } // namespace |
| 388 | |
| 389 | VirtualCameraDevice::VirtualCameraDevice( |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 390 | const uint32_t cameraId, const VirtualCameraConfiguration& configuration) |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 391 | : mCameraId(cameraId), |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame] | 392 | mVirtualCameraClientCallback(configuration.virtualCameraCallback), |
| 393 | mSupportedInputConfigurations(configuration.supportedStreamConfigs) { |
| 394 | std::optional<CameraMetadata> metadata = initCameraCharacteristics( |
Biswarup Pal | 112458f | 2023-12-28 19:50:17 +0000 | [diff] [blame] | 395 | mSupportedInputConfigurations, configuration.sensorOrientation, |
| 396 | configuration.lensFacing); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 397 | if (metadata.has_value()) { |
| 398 | mCameraCharacteristics = *metadata; |
| 399 | } else { |
| 400 | ALOGE( |
| 401 | "%s: Failed to initialize camera characteristic based on provided " |
| 402 | "configuration.", |
| 403 | __func__); |
| 404 | } |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | ndk::ScopedAStatus VirtualCameraDevice::getCameraCharacteristics( |
| 408 | CameraMetadata* _aidl_return) { |
| 409 | ALOGV("%s", __func__); |
| 410 | if (_aidl_return == nullptr) { |
| 411 | return cameraStatus(Status::ILLEGAL_ARGUMENT); |
| 412 | } |
| 413 | |
| 414 | *_aidl_return = mCameraCharacteristics; |
| 415 | return ndk::ScopedAStatus::ok(); |
| 416 | } |
| 417 | |
| 418 | ndk::ScopedAStatus VirtualCameraDevice::getPhysicalCameraCharacteristics( |
| 419 | const std::string& in_physicalCameraId, CameraMetadata* _aidl_return) { |
| 420 | ALOGV("%s: physicalCameraId %s", __func__, in_physicalCameraId.c_str()); |
| 421 | (void)_aidl_return; |
| 422 | |
| 423 | // VTS tests expect this call to fail with illegal argument status for |
| 424 | // all publicly advertised camera ids. |
| 425 | // Because we don't support physical camera ids, we just always |
| 426 | // fail with illegal argument (there's no valid argument to provide). |
| 427 | return cameraStatus(Status::ILLEGAL_ARGUMENT); |
| 428 | } |
| 429 | |
| 430 | ndk::ScopedAStatus VirtualCameraDevice::getResourceCost( |
| 431 | CameraResourceCost* _aidl_return) { |
| 432 | ALOGV("%s", __func__); |
| 433 | if (_aidl_return == nullptr) { |
| 434 | return cameraStatus(Status::ILLEGAL_ARGUMENT); |
| 435 | } |
| 436 | _aidl_return->resourceCost = 100; // ¯\_(ツ)_/¯ |
| 437 | return ndk::ScopedAStatus::ok(); |
| 438 | } |
| 439 | |
| 440 | ndk::ScopedAStatus VirtualCameraDevice::isStreamCombinationSupported( |
| 441 | const StreamConfiguration& in_streams, bool* _aidl_return) { |
| 442 | ALOGV("%s", __func__); |
| 443 | |
| 444 | if (_aidl_return == nullptr) { |
| 445 | return cameraStatus(Status::ILLEGAL_ARGUMENT); |
| 446 | } |
| 447 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 448 | *_aidl_return = isStreamCombinationSupported(in_streams); |
| 449 | return ndk::ScopedAStatus::ok(); |
| 450 | }; |
| 451 | |
| 452 | bool VirtualCameraDevice::isStreamCombinationSupported( |
| 453 | const StreamConfiguration& streamConfiguration) const { |
Jan Sebechlebsky | 39129f8 | 2024-01-19 16:42:11 +0100 | [diff] [blame] | 454 | if (streamConfiguration.streams.empty()) { |
| 455 | ALOGE("%s: Querying empty configuration", __func__); |
| 456 | return false; |
| 457 | } |
| 458 | |
Jan Sebechlebsky | 4c9bb1e | 2024-02-28 16:32:39 +0100 | [diff] [blame] | 459 | const std::vector<Stream>& streams = streamConfiguration.streams; |
| 460 | |
| 461 | Resolution firstStreamResolution(streams[0].width, streams[0].height); |
| 462 | auto isSameAspectRatioAsFirst = [firstStreamResolution](const Stream& stream) { |
| 463 | return isApproximatellySameAspectRatio( |
| 464 | firstStreamResolution, Resolution(stream.width, stream.height)); |
| 465 | }; |
| 466 | if (!std::all_of(streams.begin(), streams.end(), isSameAspectRatioAsFirst)) { |
| 467 | ALOGW( |
| 468 | "%s: Requested streams do not have same aspect ratio. Different aspect " |
| 469 | "ratios are currently " |
| 470 | "not supported by virtual camera. Stream configuration: %s", |
| 471 | __func__, streamConfiguration.toString().c_str()); |
| 472 | return false; |
| 473 | } |
| 474 | |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 475 | int numberOfProcessedStreams = 0; |
| 476 | int numberOfStallStreams = 0; |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 477 | for (const Stream& stream : streamConfiguration.streams) { |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 478 | ALOGV("%s: Configuration queried: %s", __func__, stream.toString().c_str()); |
| 479 | |
| 480 | if (stream.streamType == StreamType::INPUT) { |
| 481 | ALOGW("%s: Input stream type is not supported", __func__); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 482 | return false; |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 483 | } |
| 484 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 485 | if (stream.rotation != StreamRotation::ROTATION_0 || |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 486 | !isSupportedOutputFormat(stream.format)) { |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 487 | ALOGV("Unsupported output stream type"); |
| 488 | return false; |
| 489 | } |
| 490 | |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 491 | if (stream.format == PixelFormat::BLOB) { |
| 492 | numberOfStallStreams++; |
| 493 | } else { |
| 494 | numberOfProcessedStreams++; |
| 495 | } |
| 496 | |
Jan Sebechlebsky | 4c9bb1e | 2024-02-28 16:32:39 +0100 | [diff] [blame] | 497 | Resolution requestedResolution(stream.width, stream.height); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 498 | auto matchesSupportedInputConfig = |
Jan Sebechlebsky | 4c9bb1e | 2024-02-28 16:32:39 +0100 | [diff] [blame] | 499 | [requestedResolution](const SupportedStreamConfiguration& config) { |
| 500 | Resolution supportedInputResolution(config.width, config.height); |
| 501 | return requestedResolution <= supportedInputResolution && |
| 502 | isApproximatellySameAspectRatio(requestedResolution, |
| 503 | supportedInputResolution); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 504 | }; |
| 505 | if (std::none_of(mSupportedInputConfigurations.begin(), |
| 506 | mSupportedInputConfigurations.end(), |
| 507 | matchesSupportedInputConfig)) { |
| 508 | ALOGV("Requested config doesn't match any supported input config"); |
| 509 | return false; |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 510 | } |
| 511 | } |
Jan Sebechlebsky | 8ae2359 | 2024-02-02 16:08:18 +0100 | [diff] [blame] | 512 | |
| 513 | if (numberOfProcessedStreams > kMaxNumberOfProcessedStreams) { |
| 514 | ALOGE("%s: %d processed streams exceeds the supported maximum of %d", |
| 515 | __func__, numberOfProcessedStreams, kMaxNumberOfProcessedStreams); |
| 516 | return false; |
| 517 | } |
| 518 | |
| 519 | if (numberOfStallStreams > kMaxNumberOfStallStreams) { |
| 520 | ALOGE("%s: %d stall streams exceeds the supported maximum of %d", __func__, |
| 521 | numberOfStallStreams, kMaxNumberOfStallStreams); |
| 522 | return false; |
| 523 | } |
| 524 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 525 | return true; |
| 526 | } |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 527 | |
| 528 | ndk::ScopedAStatus VirtualCameraDevice::open( |
| 529 | const std::shared_ptr<ICameraDeviceCallback>& in_callback, |
| 530 | std::shared_ptr<ICameraDeviceSession>* _aidl_return) { |
| 531 | ALOGV("%s", __func__); |
| 532 | |
| 533 | *_aidl_return = ndk::SharedRefBase::make<VirtualCameraSession>( |
Jan Sebechlebsky | 0bb5e09 | 2023-12-08 16:17:54 +0100 | [diff] [blame] | 534 | sharedFromThis(), in_callback, mVirtualCameraClientCallback); |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 535 | |
| 536 | return ndk::ScopedAStatus::ok(); |
| 537 | }; |
| 538 | |
| 539 | ndk::ScopedAStatus VirtualCameraDevice::openInjectionSession( |
| 540 | const std::shared_ptr<ICameraDeviceCallback>& in_callback, |
| 541 | std::shared_ptr<ICameraInjectionSession>* _aidl_return) { |
| 542 | ALOGV("%s", __func__); |
| 543 | |
| 544 | (void)in_callback; |
| 545 | (void)_aidl_return; |
| 546 | return cameraStatus(Status::OPERATION_NOT_SUPPORTED); |
| 547 | } |
| 548 | |
| 549 | ndk::ScopedAStatus VirtualCameraDevice::setTorchMode(bool in_on) { |
| 550 | ALOGV("%s: on = %s", __func__, in_on ? "on" : "off"); |
| 551 | return cameraStatus(Status::OPERATION_NOT_SUPPORTED); |
| 552 | } |
| 553 | |
| 554 | ndk::ScopedAStatus VirtualCameraDevice::turnOnTorchWithStrengthLevel( |
| 555 | int32_t in_torchStrength) { |
| 556 | ALOGV("%s: torchStrength = %d", __func__, in_torchStrength); |
| 557 | return cameraStatus(Status::OPERATION_NOT_SUPPORTED); |
| 558 | } |
| 559 | |
| 560 | ndk::ScopedAStatus VirtualCameraDevice::getTorchStrengthLevel( |
| 561 | int32_t* _aidl_return) { |
| 562 | (void)_aidl_return; |
| 563 | return cameraStatus(Status::OPERATION_NOT_SUPPORTED); |
| 564 | } |
| 565 | |
| 566 | binder_status_t VirtualCameraDevice::dump(int fd, const char** args, |
| 567 | uint32_t numArgs) { |
| 568 | // TODO(b/301023410) Implement. |
| 569 | (void)fd; |
| 570 | (void)args; |
| 571 | (void)numArgs; |
| 572 | return STATUS_OK; |
| 573 | } |
| 574 | |
| 575 | std::string VirtualCameraDevice::getCameraName() const { |
| 576 | return std::string(kDevicePathPrefix) + std::to_string(mCameraId); |
| 577 | } |
| 578 | |
Jan Sebechlebsky | c3e1a63 | 2024-02-06 14:19:05 +0100 | [diff] [blame] | 579 | const std::vector<SupportedStreamConfiguration>& |
| 580 | VirtualCameraDevice::getInputConfigs() const { |
| 581 | return mSupportedInputConfigurations; |
| 582 | } |
| 583 | |
Jan Sebechlebsky | bb01c1d | 2024-02-12 11:41:37 +0100 | [diff] [blame] | 584 | Resolution VirtualCameraDevice::getMaxInputResolution() const { |
| 585 | std::optional<Resolution> maxResolution = |
| 586 | getMaxResolution(mSupportedInputConfigurations); |
| 587 | if (!maxResolution.has_value()) { |
| 588 | ALOGE( |
| 589 | "%s: Cannot determine sensor size for virtual camera - input " |
| 590 | "configurations empty?", |
| 591 | __func__); |
| 592 | return Resolution(0, 0); |
| 593 | } |
| 594 | return maxResolution.value(); |
| 595 | } |
| 596 | |
Jan Sebechlebsky | 0bb5e09 | 2023-12-08 16:17:54 +0100 | [diff] [blame] | 597 | std::shared_ptr<VirtualCameraDevice> VirtualCameraDevice::sharedFromThis() { |
| 598 | // SharedRefBase which BnCameraDevice inherits from breaks |
| 599 | // std::enable_shared_from_this. This is recommended replacement for |
| 600 | // shared_from_this() per documentation in binder_interface_utils.h. |
| 601 | return ref<VirtualCameraDevice>(); |
| 602 | } |
| 603 | |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 604 | } // namespace virtualcamera |
| 605 | } // namespace companion |
| 606 | } // namespace android |