1 /*
2  * Copyright (c) 2022-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_DSCREEN_SCREEN_REGION_MGR_V2_0_H
17 #define OHOS_DSCREEN_SCREEN_REGION_MGR_V2_0_H
18 
19 #include <map>
20 #include <mutex>
21 
22 #include "single_instance.h"
23 #include "screenregion.h"
24 #include "idscreen_source.h"
25 
26 namespace OHOS {
27 namespace DistributedHardware {
28 namespace V2_0 {
29 class EngineProviderListener : public IAVEngineProviderCallback {
30 public:
EngineProviderListener()31     EngineProviderListener() {};
32     ~EngineProviderListener() = default;
33 
34     // interfaces from IAVEngineProviderCallback
35     int32_t OnProviderEvent(const AVTransEvent& event) override;
36 };
37 
38 class ScreenRegionManager {
39 DECLARE_SINGLE_INSTANCE_BASE(ScreenRegionManager);
40 public:
41     ScreenRegionManager();
42     ~ScreenRegionManager();
43 
44     int32_t Initialize();
45     int32_t Release();
46     int32_t CreateDScreenRegion(const std::string &peerDevId);
47     int32_t DestoryDScreenRegion(const std::string &peerDevId);
48     void GetScreenDumpInfo(std::string &result);
49 
50 private:
51     int32_t LoadAVReceiverEngineProvider();
52     int32_t UnloadAVReceiverEngineProvider();
53 
54 private:
55     std::vector<std::shared_ptr<ScreenRegion>> screenRegions_;
56     std::mutex screenRegionsMtx_;
57     std::string localDevId_;
58 
59     IAVEngineProvider *providerPtr_ = nullptr;
60 };
61 } // namespace V2_0
62 } // namespace DistributedHardware
63 } // namespace OHOS
64 #endif