1 /*
2  * Copyright (c) 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_SCREEN_DECISION_CENTER_H
17 #define OHOS_SCREEN_DECISION_CENTER_H
18 
19 #include <time.h>
20 
21 #include "image_source_processor.h"
22 #include "jpeg_image_processor.h"
23 #include "surface_type.h"
24 #include "video_param.h"
25 
26 namespace OHOS {
27 namespace DistributedHardware {
28 class ScreenDecisionCenter {
29 public:
ScreenDecisionCenter(const VideoParam & configParam)30     explicit ScreenDecisionCenter(const VideoParam &configParam) : configParam_(configParam){};
31     ~ScreenDecisionCenter() = default;
32     bool IsDirtyRectValid(const std::vector<OHOS::Rect> &damages);
33     bool JudgeDirtyThreshold(const std::vector<OHOS::Rect> &damages);
34     bool LimitTime(uint32_t timethreshold);
35     int32_t InputBufferImage(sptr<SurfaceBuffer> &surfaceBuffer, const std::vector<OHOS::Rect> &damages);
36     int32_t ConfigureDecisionCenter(std::shared_ptr<IImageSourceProcessorListener> &listener,
37             std::shared_ptr<IImageSourceProcessor> &imageProcessor);
38     int32_t SetJpegSurface(sptr<Surface> &surface);
39 
40 private:
41     static const constexpr int32_t DIRTY_REGION_ARE_THRESHOLD = 260000;
42     static const constexpr int32_t FORCE_FULL_IMAGE_TIME_INTERAL = 10;  //10 seconds
43     static const constexpr int32_t MIN_SURPPORT_FRAME_COUNT = 10;  //10 frames
44     static const constexpr char *DSCREEN_LOG_TAG = "ScreenDecisionCenter";
45     std::shared_ptr<JpegImageProcessor> imageJpeg_ = nullptr;
46     std::shared_ptr<IImageSourceProcessor> imageProcessor_ = nullptr;
47     VideoParam configParam_;
48     int32_t frameCount_ = 0;
49     time_t sendFullTime_ = 0;
50 };
51 } // namespace DistributedHardware
52 } // namespace OHOS
53 #endif