blob: b778321f9d5ad40891af2018f62a2cf049239498 [file] [log] [blame]
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +01001/*
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 Sebechlebsky3b478c42023-11-23 13:15:56 +010022#include "aidl/android/companion/virtualcamera/Format.h"
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010023#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
28namespace android {
29namespace companion {
30namespace virtualcamera {
31
32// Converts camera AIDL status to ndk::ScopedAStatus
33inline 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.
43sp<Fence> importFence(
44 const ::aidl::android::hardware::common::NativeHandle& handle);
45
Jan Sebechlebsky3b478c42023-11-23 13:15:56 +010046// Returns true if specified format is supported for virtual camera input.
47bool isFormatSupportedForInput(
48 int width, int height,
49 ::aidl::android::companion::virtualcamera::Format format);
50
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010051} // namespace virtualcamera
52} // namespace companion
53} // namespace android
54
55#endif // ANDROID_COMPANION_VIRTUALCAMERA_UTIL_H