1 /* 2 * Copyright (C) 2021 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_DCAMERA_CLIENT_H 17 #define OHOS_DCAMERA_CLIENT_H 18 19 #include "icamera_operator.h" 20 21 #include "camera_info.h" 22 #include "camera_input.h" 23 #include "camera_manager.h" 24 #include "capture_input.h" 25 #include "capture_output.h" 26 #include "capture_session.h" 27 #include "photo_output.h" 28 #include "preview_output.h" 29 #include "video_output.h" 30 31 #include "dcamera_photo_surface_listener.h" 32 #include "dcamera_video_surface_listener.h" 33 34 namespace OHOS { 35 namespace DistributedHardware { 36 class DCameraClient : public ICameraOperator { 37 public: 38 explicit DCameraClient(const std::string& dhId); 39 ~DCameraClient(); 40 41 int32_t Init() override; 42 int32_t UnInit() override; 43 int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) override; 44 int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos) override; 45 int32_t StopCapture() override; 46 int32_t SetStateCallback(std::shared_ptr<StateCallback>& callback) override; 47 int32_t SetResultCallback(std::shared_ptr<ResultCallback>& callback) override; 48 49 private: 50 int32_t ConfigCaptureSession(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos); 51 int32_t ConfigCaptureSessionInner(); 52 int32_t CreateCaptureOutput(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos); 53 int32_t CreatePhotoOutput(std::shared_ptr<DCameraCaptureInfo>& info); 54 int32_t CreateVideoOutput(std::shared_ptr<DCameraCaptureInfo>& info); 55 int32_t StartCaptureInner(std::shared_ptr<DCameraCaptureInfo>& info); 56 int32_t StartPhotoOutput(std::shared_ptr<DCameraCaptureInfo>& info); 57 int32_t StartVideoOutput(); 58 59 bool isInit_; 60 std::string cameraId_; 61 sptr<Surface> photoSurface_; 62 sptr<Surface> videoSurface_; 63 sptr<CameraStandard::CameraInfo> cameraInfo_; 64 sptr<CameraStandard::CameraManager> cameraManager_; 65 sptr<CameraStandard::CaptureSession> captureSession_; 66 sptr<CameraStandard::CaptureInput> cameraInput_; 67 sptr<CameraStandard::CaptureOutput> photoOutput_; 68 sptr<CameraStandard::CaptureOutput> previewOutput_; 69 sptr<CameraStandard::CaptureOutput> videoOutput_; 70 std::shared_ptr<StateCallback> stateCallback_; 71 std::shared_ptr<ResultCallback> resultCallback_; 72 std::shared_ptr<DCameraPhotoSurfaceListener> photoListener_; 73 std::shared_ptr<DCameraVideoSurfaceListener> videoListener_; 74 }; 75 } // namespace DistributedHardware 76 } // namespace OHOS 77 #endif // OHOS_DCAMERA_CLIENT_H