• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_V2_0_H
17 #define OHOS_DSCREEN_SCREEN_REGION_V2_0_H
18 
19 #include <mutex>
20 
21 #include "surface.h"
22 
23 #include "2.0/include/av_receiver_engine_adapter.h"
24 #include "distributed_hardware_fwk_kit.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 V2_0 {
32 class ScreenRegion :  public AVReceiverAdapterCallback, public std::enable_shared_from_this<ScreenRegion> {
33 public:
34     ScreenRegion(const std::string &remoteDevId);
35     ~ScreenRegion();
36 
37     // interfaces from AVReceiverAdapterCallback
38     void OnEngineEvent(DScreenEventType event, const std::string &content) override;
39     void OnEngineMessage(const std::shared_ptr<AVTransMessage> &message) override;
40     void OnEngineDataDone(const std::shared_ptr<AVTransBuffer> &buffer) override;
41     void GetWSBuffer(sptr<OHOS::SurfaceBuffer> &wsBuffer, const std::shared_ptr<AVTransBuffer> &buffer);
42 
43     int32_t Release();
44     int32_t InitReceiverEngine(IAVEngineProvider *providerPtr);
45     int32_t GetWindowId();
46     uint64_t GetScreenId();
47     std::string GetRemoteDevId();
48     std::shared_ptr<VideoParam> GetVideoParam();
49     std::shared_ptr<WindowProperty> GetWindowProperty();
50 
51 private:
52     int32_t StartReceiverEngine(const std::string &content);
53     int32_t StopReceiverEngine();
54     int32_t SetUp(const std::string &content);
55     int32_t ConfigWindow();
56     bool CheckContentJson(json &contentJson);
57     void PublishMessage(const DHTopic topic, const uint64_t &screenId, const std::string &remoteDevId,
58         const int32_t &windowId, std::shared_ptr<WindowProperty> windowProperty);
59 
60 private:
61     uint64_t screenId_;
62     uint64_t displayId_;
63     std::string remoteDevId_;
64     int32_t windowId_ = INVALID_WINDOW_ID;
65     uint32_t alignedHeight_ = 0;
66     bool isRunning = false;
67     std::atomic<uint32_t> frameNumber_;
68 
69     sptr<OHOS::Surface> windowSurface_ = nullptr;
70     std::shared_ptr<VideoParam> videoParam_ = nullptr;
71     std::shared_ptr<WindowProperty> windowProperty_ = nullptr;
72     std::shared_ptr<DScreenMapRelation> mapRelation_ = nullptr;
73     std::shared_ptr<AVTransReceiverAdapter> receiverAdapter_ = nullptr;
74 };
75 } // namespace V2_0
76 } // namespace DistributedHardware
77 } // namespace OHOS
78 #endif