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_SCREEN_SINK_TRANS_H 17 #define OHOS_SCREEN_SINK_TRANS_H 18 19 #include <string> 20 #include <memory> 21 22 #include "iscreen_sink_trans.h" 23 #include "iscreen_sink_trans_callback.h" 24 #include "iimage_sink_processor.h" 25 #include "iscreen_channel.h" 26 27 namespace OHOS { 28 namespace DistributedHardware { 29 class ScreenSinkTrans : public IScreenSinkTrans, 30 public IScreenChannelListener, 31 public IImageSinkProcessorListener, 32 public std::enable_shared_from_this<ScreenSinkTrans> { 33 public: 34 ScreenSinkTrans() = default; 35 ~ScreenSinkTrans() = default; 36 37 int32_t SetUp(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId) override; 38 int32_t Release() override; 39 int32_t Start() override; 40 int32_t Stop() override; 41 int32_t RegisterStateCallback(const std::shared_ptr<IScreenSinkTransCallback> &callBack) override; 42 int32_t SetImageSurface(const sptr<Surface> &surface) override; 43 44 void OnSessionOpened() override; 45 void OnSessionClosed() override; 46 void OnDataReceived(const std::shared_ptr<DataBuffer> &data) override; 47 void OnProcessorStateNotify(int32_t state) override; 48 49 private: 50 int32_t CheckVideoParam(const VideoParam ¶m); 51 int32_t CheckTransParam(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId); 52 int32_t InitScreenTrans(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId); 53 int32_t RegisterChannelListener(); 54 int32_t RegisterProcessorListener(const VideoParam &localParam, const VideoParam &remoteParam, 55 const std::string &peerDevId); 56 57 private: 58 static const constexpr char *LOG_TAG = "ScreenSinkTrans"; 59 60 sptr<Surface> decoderSurface_; 61 std::shared_ptr<IImageSinkProcessor> imageProcessor_; 62 std::shared_ptr<IScreenChannel> screenChannel_; 63 std::weak_ptr<IScreenSinkTransCallback> transCallback_; 64 }; 65 } // namespace DistributedHardware 66 } // namespace OHOS 67 #endif