/* * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include "camera.h" #include "v1_1/types.h" #include "metadata_utils.h" #include "v1_1/icamera_host.h" #include "v1_1/icamera_device.h" #include "v1_1/istream_operator.h" #include "v1_1/camera_host_proxy.h" namespace OHOS::Camera { using namespace OHOS::HDI::Camera::V1_0; class CameraManager { public: void Init(); void Open(); void Close(); void GetCameraMetadata(); OHOS::sptr service = nullptr; OHOS::sptr serviceV1_1 = nullptr; OHOS::sptr hostCallback = nullptr; OHOS::sptr cameraDevice = nullptr; OHOS::sptr deviceCallback = nullptr; OHOS::sptr cameraDeviceV1_1 = nullptr; int32_t rc; std::vector cameraIds; std::vector abilityVec = {}; std::shared_ptr ability = nullptr; using ResultCallback = std::function)>; static ResultCallback resultCallback_; class TestStreamOperatorCallback : public IStreamOperatorCallback { public: TestStreamOperatorCallback() = default; virtual ~TestStreamOperatorCallback() = default; int32_t OnCaptureStarted(int32_t captureId, const std::vector &streamId) override; int32_t OnCaptureEnded(int32_t captureId, const std::vector &infos) override; int32_t OnCaptureError(int32_t captureId, const std::vector &infos) override; int32_t OnFrameShutter(int32_t captureId, const std::vector &streamIds, uint64_t timestamp) override; }; class DemoCameraDeviceCallback : public ICameraDeviceCallback { public: DemoCameraDeviceCallback() = default; virtual ~DemoCameraDeviceCallback() = default; int32_t OnError(ErrorType type, int32_t errorMsg) override; int32_t OnResult(uint64_t timestamp, const std::vector &result) override; }; class TestCameraHostCallback : public ICameraHostCallback { public: TestCameraHostCallback() = default; virtual ~TestCameraHostCallback() = default; int32_t OnCameraStatus(const std::string& cameraId, CameraStatus status) override; int32_t OnFlashlightStatus(const std::string& cameraId, FlashlightStatus status) override; int32_t OnCameraEvent(const std::string& cameraId, CameraEvent event) override; }; }; }