1 /*
2  * Copyright (c) 2023-2023 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_PHOTO_SESSION_H
17 #define OHOS_CAMERA_PHOTO_SESSION_H
18 
19 #include <cstdint>
20 #include "capture_session.h"
21 #include "icapture_session.h"
22 
23 namespace OHOS {
24 namespace CameraStandard {
25 class PhotoSession : public CaptureSession {
26 public:
PhotoSession(sptr<ICaptureSession> & photoSession)27     explicit PhotoSession(sptr<ICaptureSession> &photoSession): CaptureSession(photoSession) {}
28     ~PhotoSession() = default;
29 
30     /**
31      * @brief Determine if the given Ouput can be added to session.
32      *
33      * @param CaptureOutput to be added to session.
34      */
35     bool CanAddOutput(sptr<CaptureOutput>& output) override;
36 
37     /**
38      * @brief Check the preconfig type is supported or not.
39      *
40      * @param preconfigType The target preconfig type.
41      * @param preconfigRatio The target ratio enum
42      *
43      * @return True if the preconfig type is supported, false otherwise.
44      */
45     bool CanPreconfig(PreconfigType preconfigType, ProfileSizeRatio preconfigRatio) override;
46 
47     /**
48      * @brief Set the preconfig type.
49      *
50      * @param preconfigType The target preconfig type.
51      * @param preconfigRatio The target ratio enum
52      *
53      * @return Camera error code.
54      */
55     int32_t Preconfig(PreconfigType preconfigType, ProfileSizeRatio preconfigRatio) override;
56 
57     /**
58      * @brief Photo-Session can set frame rate range.
59      *
60      * @param minFps Min frame rate of range.
61      * @param minFps Max frame rate of range.
62      */
63     bool CanSetFrameRateRange(int32_t minFps, int32_t maxFps, CaptureOutput* curOutput) override;
64 
65 protected:
66     std::shared_ptr<PreconfigProfiles> GeneratePreconfigProfiles(
67         PreconfigType preconfigType, ProfileSizeRatio preconfigRatio) override;
68 
69 private:
70     bool IsPreconfigProfilesLegal(std::shared_ptr<PreconfigProfiles> configs);
71     bool IsPhotoProfileLegal(sptr<CameraDevice>& device, Profile& photoProfile);
72     bool IsPreviewProfileLegal(sptr<CameraDevice>& device, Profile& previewProfile);
73 };
74 } // namespace CameraStandard
75 } // namespace OHOS
76 #endif // OHOS_CAMERA_PHOTO_SESSION_H