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_V1_0_H
17 #define OHOS_DSCREEN_SCREEN_REGION_V1_0_H
18 
19 #include <mutex>
20 
21 #include "surface.h"
22 
23 #include "iscreen_sink_trans_callback.h"
24 #include "iscreen_sink_trans.h"
25 #include "dscreen_maprelation.h"
26 #include "screen_client_common.h"
27 #include "video_param.h"
28 
29 namespace OHOS {
30 namespace DistributedHardware {
31 namespace V1_0 {
32 class ScreenSinkTransCallback : public IScreenSinkTransCallback {
33 public:
~ScreenSinkTransCallback()34     ~ScreenSinkTransCallback() override {};
35     virtual void OnTransError(int32_t err, const std::string &content) = 0;
OnError(int32_t err,const std::string & content)36     void OnError(int32_t err, const std::string &content) override
37     {
38         OnTransError(err, content);
39     }
40 };
41 
42 class ScreenRegion : public ScreenSinkTransCallback, public std::enable_shared_from_this<ScreenRegion> {
43 public:
44     ScreenRegion(const std::string &remoteDevId, uint64_t screenId, uint64_t displayId);
45     ~ScreenRegion() override;
46     void OnTransError(int32_t err, const std::string &content) override;
47     void SetVideoParam(std::shared_ptr<VideoParam> &videoParam);
48     void SetMapRelation(std::shared_ptr<DScreenMapRelation> &mapRelation);
49     std::string GetRemoteDevId();
50     uint64_t GetScreenId();
51     uint64_t GetDisplayId();
52     std::shared_ptr<VideoParam> GetVideoParam();
53     int32_t GetWindowId();
54     int32_t SetUpWindow();
55     int32_t SetUp(const std::string &version);
56     int32_t Start();
57     int32_t Stop();
58     std::shared_ptr<WindowProperty> GetWindowProperty();
59 
60 private:
61     std::string remoteDevId_;
62     uint64_t screenId_; // local screen id
63     uint64_t displayId_; // local display id
64     bool isRunning = false;
65 
66     std::shared_ptr<VideoParam> videoParam_ = nullptr;
67     std::shared_ptr<DScreenMapRelation> mapRelation_ = nullptr;
68     sptr<OHOS::Surface> surface_ = nullptr;
69     int32_t windowId_ = INVALID_WINDOW_ID;
70     std::shared_ptr<IScreenSinkTrans> sinkTrans_ = nullptr;
71     std::shared_ptr<WindowProperty> windowProperty_ = nullptr;
72 };
73 } // namespace V1_0
74 } // namespace DistributedHardware
75 } // namespace OHOS
76 #endif