blob: 1a0a45816668c72ddfab87cf5b71a8f89a463952 [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
22#include "aidl/android/hardware/camera/common/Status.h"
23#include "aidl/android/hardware/camera/device/StreamBuffer.h"
24#include "android/binder_auto_utils.h"
25#include "ui/Fence.h"
26
27namespace android {
28namespace companion {
29namespace virtualcamera {
30
31// Converts camera AIDL status to ndk::ScopedAStatus
32inline ndk::ScopedAStatus cameraStatus(
33 const ::aidl::android::hardware::camera::common::Status status) {
34 return ndk::ScopedAStatus::fromServiceSpecificError(
35 static_cast<int32_t>(status));
36}
37
38// Import Fence from AIDL NativeHandle.
39//
40// If the handle can't be used to construct Fence (is empty or doesn't contain
41// only single fd) this function will return Fence instance in invalid state.
42sp<Fence> importFence(
43 const ::aidl::android::hardware::common::NativeHandle& handle);
44
45} // namespace virtualcamera
46} // namespace companion
47} // namespace android
48
49#endif // ANDROID_COMPANION_VIRTUALCAMERA_UTIL_H