1/*
2 * Copyright (c) 2020-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#ifndef OHOS_CAMERA_IMPL_H
16#define OHOS_CAMERA_IMPL_H
17
18#include "camera.h"
19#include "camera_ability.h"
20#include "camera_info.h"
21#include "camera_device_client.h"
22#include "camera_state_callback.h"
23
24namespace OHOS {
25namespace Media {
26class CameraImpl : public Camera {
27public:
28    CameraImpl() = delete;
29    CameraImpl(const std::string &id, const CameraAbility *ability, const CameraInfo *info);
30    ~CameraImpl() = default;
31
32    std::string GetCameraId() override;
33    const CameraConfig *GetCameraConfig() const override;
34    FrameConfig *GetFrameConfig(int32_t type) override;
35
36    void Configure(CameraConfig &config) override;
37    void Release() override;
38
39    int32_t TriggerLoopingCapture(FrameConfig &fc) override;
40    void StopLoopingCapture(int32_t type) override;
41    int32_t TriggerSingleCapture(FrameConfig &fc) override;
42
43    const CameraAbility *GetAbility();
44    const CameraInfo *GetInfo();
45    void OnCreate(std::string cameraId);
46    void OnCreateFailed();
47    void OnFrameFinished(int32_t ret, FrameConfig &fc);
48    void OnConfigured(int32_t ret, CameraConfig &config);
49    void RegistCb(CameraStateCallback &callback, EventHandler &handler);
50
51private:
52    std::string id_;
53    std::list<FrameConfig *> frameConfigs_;
54    CameraConfig *config_ = nullptr;
55    CameraStateCallback *stateCb_ = nullptr;
56    EventHandler *handler_ = nullptr;
57    const CameraAbility *ability_ = nullptr;
58    const CameraInfo *info_ = nullptr;
59    CameraDeviceClient *deviceClient_ = nullptr;
60};
61} // namespace Media
62} // namespace OHOS
63#endif // OHOS_CAMERA_IMPL_H