Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2023 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 ANDROID_COMPANION_VIRTUALCAMERA_UTIL_H |
| 18 | #define ANDROID_COMPANION_VIRTUALCAMERA_UTIL_H |
| 19 | |
| 20 | #include <cstdint> |
| 21 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 22 | #include "aidl/android/companion/virtualcamera/Format.h" |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 23 | #include "aidl/android/hardware/camera/common/Status.h" |
| 24 | #include "aidl/android/hardware/camera/device/StreamBuffer.h" |
| 25 | #include "android/binder_auto_utils.h" |
| 26 | #include "ui/Fence.h" |
| 27 | |
| 28 | namespace android { |
| 29 | namespace companion { |
| 30 | namespace virtualcamera { |
| 31 | |
| 32 | // Converts camera AIDL status to ndk::ScopedAStatus |
| 33 | inline ndk::ScopedAStatus cameraStatus( |
| 34 | const ::aidl::android::hardware::camera::common::Status status) { |
| 35 | return ndk::ScopedAStatus::fromServiceSpecificError( |
| 36 | static_cast<int32_t>(status)); |
| 37 | } |
| 38 | |
| 39 | // Import Fence from AIDL NativeHandle. |
| 40 | // |
| 41 | // If the handle can't be used to construct Fence (is empty or doesn't contain |
| 42 | // only single fd) this function will return Fence instance in invalid state. |
| 43 | sp<Fence> importFence( |
| 44 | const ::aidl::android::hardware::common::NativeHandle& handle); |
| 45 | |
Jan Sebechlebsky | 042d1fb | 2023-12-12 16:37:00 +0100 | [diff] [blame] | 46 | // Returns true if specified pixel format is supported for virtual camera input. |
| 47 | bool isPixelFormatSupportedForInput( |
| 48 | ::aidl::android::companion::virtualcamera::Format format); |
| 49 | |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 50 | // Returns true if specified format is supported for virtual camera input. |
| 51 | bool isFormatSupportedForInput( |
| 52 | int width, int height, |
Biswarup Pal | 6152a30 | 2023-12-19 12:44:09 +0000 | [diff] [blame^] | 53 | ::aidl::android::companion::virtualcamera::Format format, int maxFps); |
Jan Sebechlebsky | 3b478c4 | 2023-11-23 13:15:56 +0100 | [diff] [blame] | 54 | |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 55 | } // namespace virtualcamera |
| 56 | } // namespace companion |
| 57 | } // namespace android |
| 58 | |
| 59 | #endif // ANDROID_COMPANION_VIRTUALCAMERA_UTIL_H |