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_VIDEO_SESSION_H
17 #define OHOS_CAMERA_VIDEO_SESSION_H
18 
19 #include "camera_output_capability.h"
20 #include "capture_session.h"
21 #include "icapture_session.h"
22 
23 namespace OHOS {
24 namespace CameraStandard {
25 class VideoSession : public CaptureSession {
26 public:
VideoSession(sptr<ICaptureSession> & videoSession)27     explicit VideoSession(sptr<ICaptureSession> &videoSession): CaptureSession(videoSession) {}
28     ~VideoSession() = 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 Video-Session can set frame rate range.
39      *
40      * @param minFps Min frame rate of range.
41      * @param minFps Max frame rate of range.
42      */
43     bool CanSetFrameRateRange(int32_t minFps, int32_t maxFps, CaptureOutput* curOutput) override;
44 
45     /**
46      * @brief Check the preconfig type is supported or not.
47      *
48      * @param preconfigType The target preconfig type.
49      * @param preconfigRatio The target ratio enum
50      *
51      * @return True if the preconfig type is supported, false otherwise.
52      */
53     bool CanPreconfig(PreconfigType preconfigType, ProfileSizeRatio preconfigRatio) override;
54 
55     /**
56      * @brief Set the preconfig type.
57      *
58      * @param preconfigType The target preconfig type.
59      * @param preconfigRatio The target ratio enum
60      *
61      * @return Camera error code.
62      */
63     int32_t Preconfig(PreconfigType preconfigType, ProfileSizeRatio preconfigRatio) 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     bool IsVideoProfileLegal(sptr<CameraDevice>& device, VideoProfile& videoProfile);
74 };
75 } // namespace CameraStandard
76 } // namespace OHOS
77 #endif // OHOS_CAMERA_VIDEO_SESSION_H