xref: /aosp_15_r20/frameworks/av/services/camera/libcameraservice/device3/aidl/AidlCamera3SharedDevice.h (revision ec779b8e0859a360c3d303172224686826e6e0e1)
1 /*
2  * Copyright (C) 2024 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_SERVERS_AIDLCAMERA3SHAREDDEVICE_H
18 #define ANDROID_SERVERS_AIDLCAMERA3SHAREDDEVICE_H
19 
20 #include <camera/camera2/OutputConfiguration.h>
21 #include "../Camera3SharedOutputStream.h"
22 #include "AidlCamera3Device.h"
23 namespace android {
24 
25 /**
26  * Shared CameraDevice for AIDL HAL devices.
27  */
28 using ::android::camera3::Camera3SharedOutputStream;
29 class AidlCamera3SharedDevice :
30         public AidlCamera3Device {
31   public:
32     static sp<AidlCamera3SharedDevice> getInstance(
33             std::shared_ptr<CameraServiceProxyWrapper>& cameraServiceProxyWrapper,
34             std::shared_ptr<AttributionAndPermissionUtils> attributionAndPermissionUtils,
35             const std::string& id, bool overrideForPerfClass, int rotationOverride,
36             bool legacyClient = false);
37     status_t initialize(sp<CameraProviderManager> manager,
38             const std::string& monitorTags) override;
39     status_t disconnectClient(int clientUid) override;
40     status_t beginConfigure() override;
41     status_t getSharedStreamId(const OutputConfiguration &config, int *streamId) override;
42     status_t addSharedSurfaces(int streamId,
43             const std::vector<android::camera3::OutputStreamInfo> &outputInfo,
44             const std::vector<SurfaceHolder>& surfaces,
45             std::vector<int> *surfaceIds = nullptr) override;
46     status_t removeSharedSurfaces(int streamId,
47             const std::vector<size_t> &surfaceIds) override;
48   private:
49     static std::map<std::string, sp<AidlCamera3SharedDevice>> sSharedDevices;
50     static std::map<std::string, std::unordered_set<int>> sClientsUid;
AidlCamera3SharedDevice(std::shared_ptr<CameraServiceProxyWrapper> & cameraServiceProxyWrapper,std::shared_ptr<AttributionAndPermissionUtils> attributionAndPermissionUtils,const std::string & id,bool overrideForPerfClass,int rotationOverride,bool legacyClient)51     AidlCamera3SharedDevice(
52             std::shared_ptr<CameraServiceProxyWrapper>& cameraServiceProxyWrapper,
53             std::shared_ptr<AttributionAndPermissionUtils> attributionAndPermissionUtils,
54             const std::string& id, bool overrideForPerfClass, int rotationOverride,
55             bool legacyClient)
56         : AidlCamera3Device(cameraServiceProxyWrapper, attributionAndPermissionUtils, id,
57                   overrideForPerfClass, rotationOverride, legacyClient) {}
58     std::vector<OutputConfiguration> getSharedOutputConfiguration();
59     std::vector<OutputConfiguration> mSharedOutputConfigurations;
60     std::vector<int> mSharedSurfaceIds;
61     std::vector<sp<Surface>> mSharedSurfaces;
62     std::vector<sp<Camera3SharedOutputStream>> mSharedStreams;
63     KeyedVector<int32_t, OutputConfiguration> mConfiguredOutputs;
64 }; // class AidlCamera3SharedDevice
65 }; // namespace android
66 #endif
67