1 /* 2 * Copyright (c) 2022 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_H 17 #define OHOS_DSCREEN_SCREEN_REGION_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 class ScreenSinkTransCallback : public IScreenSinkTransCallback { 32 public: ~ScreenSinkTransCallback()33 ~ScreenSinkTransCallback() override {}; 34 virtual void OnTransError(int32_t err, const std::string &content) = 0; OnError(int32_t err,const std::string & content)35 virtual void OnError(int32_t err, const std::string &content) override 36 { 37 OnTransError(err, content); 38 } 39 }; 40 41 class ScreenRegion : public ScreenSinkTransCallback, public std::enable_shared_from_this<ScreenRegion> { 42 public: 43 ScreenRegion(const std::string &remoteDevId, uint64_t screenId, uint64_t displayId); 44 ~ScreenRegion(); 45 void OnTransError(int32_t err, const std::string &content) override; 46 void SetVideoParam(std::shared_ptr<VideoParam> &videoParam); 47 void SetMapRelation(std::shared_ptr<DScreenMapRelation> &mapRElation); 48 std::string GetRemoteDevId(); 49 uint64_t GetScreenId(); 50 uint64_t GetDisplayId(); 51 std::shared_ptr<VideoParam> GetVideoParam(); 52 int32_t GetWindowId(); 53 int32_t SetUpWindow(); 54 int32_t SetUp(); 55 int32_t Start(); 56 int32_t Stop(); 57 std::shared_ptr<WindowProperty> GetWindowProperty(); 58 59 private: 60 std::string remoteDevId_; 61 uint64_t screenId_; // local screen id 62 uint64_t displayId_; // local display id 63 bool isRunning = false; 64 65 std::shared_ptr<VideoParam> videoParam_ = nullptr; 66 std::shared_ptr<DScreenMapRelation> mapRelation_ = nullptr; 67 sptr<OHOS::Surface> surface_ = nullptr; 68 int32_t windowId_ = INVALID_WINDOW_ID; 69 std::shared_ptr<IScreenSinkTrans> sinkTrans_ = nullptr; 70 std::shared_ptr<WindowProperty> windowProperty_ = nullptr; 71 }; 72 } // namespace DistributedHardware 73 } // namespace OHOS 74 #endif