• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_CAMERA_HCAMERA_SERVICE_STUB_H
17 #define OHOS_CAMERA_HCAMERA_SERVICE_STUB_H
18 
19 #include <mutex>
20 #include "icamera_service.h"
21 #include "iremote_stub.h"
22 #include "input/camera_death_recipient.h"
23 #include "input/i_standard_camera_listener.h"
24 
25 namespace OHOS {
26 namespace CameraStandard {
27 class HCameraServiceStub : public IRemoteStub<ICameraService> {
28 public:
29     HCameraServiceStub();
30     ~HCameraServiceStub();
31     int OnRemoteRequest(uint32_t code, MessageParcel &data,
32                         MessageParcel &reply, MessageOption &option) override;
33 
34 private:
35     int HandleGetCameras(MessageParcel &data, MessageParcel &reply);
36     int HandleCreateCameraDevice(MessageParcel &data, MessageParcel &reply);
37     int HandleSetCallback(MessageParcel &data, MessageParcel &reply);
38     int HandleSetMuteCallback(MessageParcel &data, MessageParcel &reply);
39     int HandleCreateCaptureSession(MessageParcel &data, MessageParcel &reply);
40     int HandleCreatePhotoOutput(MessageParcel &data, MessageParcel &reply);
41     int HandleCreatePreviewOutput(MessageParcel &data, MessageParcel &reply);
42     int HandleCreateDeferredPreviewOutput(MessageParcel &data, MessageParcel &reply);
43     int HandleCreateMetadataOutput(MessageParcel &data, MessageParcel &reply);
44     int HandleCreateVideoOutput(MessageParcel &data, MessageParcel &reply);
45     int HandleMuteCamera(MessageParcel &data, MessageParcel &reply);
46     int HandleIsCameraMuted(MessageParcel &data, MessageParcel &reply);
47     int DestroyStubForPid(pid_t pid);
48     void ClientDied(pid_t pid);
49     int SetListenerObject(const sptr<IRemoteObject> &object) override;
50     int SetListenerObject(MessageParcel &data, MessageParcel &reply);
51     int32_t CheckRequestCode(const uint32_t code, MessageParcel &data,
52                                                  MessageParcel &reply, MessageOption &option);
53     void RegisterMethod();
54     virtual int32_t UnSetCallback(pid_t pid);
55     virtual int32_t CloseCameraForDestory(pid_t pid);
56 
57     std::mutex mutex_;
58     std::map<pid_t, sptr<CameraDeathRecipient>> deathRecipientMap_;
59     std::map<pid_t, sptr<IStandardCameraListener>> cameraListenerMap_;
60 
61     typedef int (HCameraServiceStub::* HandleMethod)(MessageParcel &, MessageParcel &);
62     std::map<uint32_t, HandleMethod> methodFactory;
63 };
64 } // namespace CameraStandard
65 } // namespace OHOS
66 #endif // OHOS_CAMERA_HCAMERA_SERVICE_STUB_H
67 
68