blob: 80e965d9dbd32606329ea3cf8a3bcc9a2caa6f8f [file] [log] [blame]
Avichal Rakeshfcb78cb2022-10-27 15:45:54 -07001/*
2 * Copyright (C) 2022 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 FRAMEWORKS_AV_SERVICES_CAMERA_LIBCAMERASERVICE_AIDL_AIDLCAMERASERVICE_H_
18#define FRAMEWORKS_AV_SERVICES_CAMERA_LIBCAMERASERVICE_AIDL_AIDLCAMERASERVICE_H_
19
20#include <CameraService.h>
21#include <aidl/android/frameworks/cameraservice/common/Status.h>
22#include <aidl/android/frameworks/cameraservice/service/BnCameraService.h>
23
24namespace android::frameworks::cameraservice::service::implementation {
25
26// VNDK classes
27using SBnCameraService = ::aidl::android::frameworks::cameraservice::service::BnCameraService;
28using SCameraMetadata = ::aidl::android::frameworks::cameraservice::device::CameraMetadata;
29using SCameraStatusAndId = ::aidl::android::frameworks::cameraservice::service::CameraStatusAndId;
30using SICameraDeviceCallback =
31 ::aidl::android::frameworks::cameraservice::device::ICameraDeviceCallback;
32using SICameraDeviceUser = ::aidl::android::frameworks::cameraservice::device::ICameraDeviceUser;
33using SICameraServiceListener =
34 ::aidl::android::frameworks::cameraservice::service::ICameraServiceListener;
35using SProviderIdAndVendorTagSections =
36 ::aidl::android::frameworks::cameraservice::common::ProviderIdAndVendorTagSections;
37using SStatus = ::aidl::android::frameworks::cameraservice::common::Status;
38// NDK classes
39using UICameraServiceListener = ::android::hardware::ICameraServiceListener;
40
41class AidlCameraService: public SBnCameraService {
42 public:
43 static bool registerService(::android::CameraService* cameraService);
44
45 explicit AidlCameraService(::android::CameraService* cameraService);
46 ~AidlCameraService() override = default;
47 ndk::ScopedAStatus getCameraCharacteristics(const std::string& in_cameraId,
48 SCameraMetadata* _aidl_return) override;
49
50 ndk::ScopedAStatus connectDevice(const std::shared_ptr<SICameraDeviceCallback>& in_callback,
51 const std::string& in_cameraId,
52 std::shared_ptr<SICameraDeviceUser>* _aidl_return) override;
53
54 ndk::ScopedAStatus addListener(const std::shared_ptr<SICameraServiceListener>& in_listener,
55 std::vector<SCameraStatusAndId>* _aidl_return) override;
56
57 ndk::ScopedAStatus getCameraVendorTagSections(
58 std::vector<SProviderIdAndVendorTagSections>* _aidl_return) override;
59
60 ndk::ScopedAStatus removeListener(
61 const std::shared_ptr<SICameraServiceListener>& in_listener) override;
62
Jyoti Bhayana1f9600b2024-10-29 20:25:32 -070063 ndk::ScopedAStatus connectDeviceV2(const std::shared_ptr<SICameraDeviceCallback>& in_callback,
64 const std::string& in_cameraId, bool sharedMode,
65 std::shared_ptr<SICameraDeviceUser>* _aidl_return);
Avichal Rakeshfcb78cb2022-10-27 15:45:54 -070066 private:
67 void addToListenerCacheLocked(std::shared_ptr<SICameraServiceListener> stableCsListener,
68 sp<hardware::ICameraServiceListener> csListener);
69
70 sp<UICameraServiceListener> searchListenerCacheLocked(
71 const std::shared_ptr<SICameraServiceListener>& listener, bool removeIfFound = false);
72
73 SStatus addListenerInternal(const std::shared_ptr<SICameraServiceListener>& listener,
74 std::vector<hardware::CameraStatus>* cameraStatusAndIds);
75
Jyoti Bhayana1f9600b2024-10-29 20:25:32 -070076 ndk::ScopedAStatus connectDeviceImpl(const std::shared_ptr<SICameraDeviceCallback>& in_callback,
77 const std::string& in_cameraId, bool sharedMode,
78 std::shared_ptr<SICameraDeviceUser>* _aidl_return);
Avichal Rakeshfcb78cb2022-10-27 15:45:54 -070079
80 ::android::CameraService* mCameraService;
81
82 Mutex mListenerListLock;
83 std::list<std::pair<std::shared_ptr<SICameraServiceListener>,
84 sp<UICameraServiceListener>>> mListeners;
85 int mVndkVersion = -1;
86
87};
88
89} // namespace android::frameworks::cameraservice::service::implementation
90
91#endif // FRAMEWORKS_AV_SERVICES_CAMERA_LIBCAMERASERVICE_AIDL_AIDLCAMERASERVICE_H_