• 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_H_CAMERA_SERVICE_H
17 #define OHOS_CAMERA_H_CAMERA_SERVICE_H
18 
19 #include "hcamera_device.h"
20 #include "hcamera_host_manager.h"
21 #include "hcamera_service_stub.h"
22 #include "hcapture_session.h"
23 #include "hstream_capture.h"
24 #include "hstream_repeat.h"
25 #include "iremote_stub.h"
26 #include "system_ability.h"
27 
28 #include <iostream>
29 
30 namespace OHOS {
31 namespace CameraStandard {
32 class   HCameraService : public SystemAbility, public HCameraServiceStub, public HCameraHostManager::StatusCallback {
33     DECLARE_SYSTEM_ABILITY(HCameraService);
34 
35 public:
36     DISALLOW_COPY_AND_MOVE(HCameraService);
37 
38     explicit HCameraService(int32_t systemAbilityId, bool runOnCreate = true);
39     ~HCameraService() override;
40     int32_t GetCameras(std::vector<std::string> &cameraIds,
41         std::vector<std::shared_ptr<Camera::CameraMetadata>> &cameraAbilityList) override;
42     int32_t CreateCameraDevice(std::string cameraId, sptr<ICameraDeviceService> &device) override;
43     int32_t CreateCaptureSession(sptr<ICaptureSession> &session) override;
44     int32_t CreatePhotoOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
45                               sptr<IStreamCapture> &photoOutput) override;
46     int32_t CreatePreviewOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
47                                 sptr<IStreamRepeat> &previewOutput) override;
48     int32_t CreateCustomPreviewOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format, int32_t width,
49                                       int32_t height, sptr<IStreamRepeat> &previewOutput) override;
50     int32_t CreateVideoOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
51                               sptr<IStreamRepeat> &videoOutput) override;
52     int32_t SetCallback(sptr<ICameraServiceCallback> &callback) override;
53     void OnDump() override;
54     void OnStart() override;
55     void OnStop() override;
56     int32_t Dump(int fd, const std::vector<std::u16string>& args) override;
57 
58     // HCameraHostManager::StatusCallback
59     void OnCameraStatus(const std::string& cameraId, CameraStatus status) override;
60     void OnFlashlightStatus(const std::string& cameraId, FlashStatus status) override;
61 
62 protected:
HCameraService(sptr<HCameraHostManager> cameraHostManager)63     HCameraService(sptr<HCameraHostManager> cameraHostManager) : cameraHostManager_(cameraHostManager) {}
64 
65 private:
66     void CameraSummary(std::vector<std::string> cameraIds,
67         std::string& dumpString);
68     void CameraDumpAbility(common_metadata_header_t *metadataEntry,
69     std::string& dumpString);
70     void CameraDumpStreaminfo(common_metadata_header_t *metadataEntry,
71     std::string& dumpString);
72     void CameraDumpZoom(common_metadata_header_t *metadataEntry,
73     std::string& dumpString);
74     void CameraDumpFlash(common_metadata_header_t *metadataEntry,
75     std::string& dumpString);
76     void CameraDumpAF(common_metadata_header_t *metadataEntry,
77     std::string& dumpString);
78     void CameraDumpSensorInfo(common_metadata_header_t *metadataEntry,
79     std::string& dumpString);
80 
81     sptr<HCameraHostManager> cameraHostManager_;
82     sptr<CameraDeviceCallback> cameraDeviceCallback_;
83     sptr<StreamOperatorCallback> streamOperatorCallback_;
84     sptr<ICameraServiceCallback> cameraServiceCallback_;
85     std::map<std::string, sptr<HCameraDevice>> devices_;
86 };
87 } // namespace CameraStandard
88 } // namespace OHOS
89 #endif // OHOS_CAMERA_H_CAMERA_SERVICE_H
90