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_DATA_CHANNEL_IMPL_H 17 #define OHOS_SCREEN_DATA_CHANNEL_IMPL_H 18 19 #include <memory> 20 #include <string> 21 22 #include "data_buffer.h" 23 #include "iscreen_channel.h" 24 #include "softbus_adapter.h" 25 26 namespace OHOS { 27 namespace DistributedHardware { 28 class ScreenDataChannelImpl : public IScreenChannel, 29 public ISoftbusListener, 30 public std::enable_shared_from_this<ScreenDataChannelImpl> { 31 public: ScreenDataChannelImpl(std::string peerDevId)32 ScreenDataChannelImpl(std::string peerDevId) : peerDevId_(peerDevId) {}; 33 ~ScreenDataChannelImpl() = default; 34 35 int32_t CreateSession(const std::shared_ptr<IScreenChannelListener> &listener) override; 36 int32_t ReleaseSession() override; 37 int32_t OpenSession() override; 38 int32_t CloseSession() override; 39 int32_t SendData(const std::shared_ptr<DataBuffer> &screenData) override; 40 41 void OnSessionOpened(int32_t sessionId, int32_t result) override; 42 void OnSessionClosed(int32_t sessionId) override; 43 void OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) override; 44 void OnStreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext, 45 const StreamFrameInfo *param) override; 46 47 private: 48 static const constexpr char *LOG_TAG = "ScreenDataChannel"; 49 50 const std::string peerDevId_; 51 int32_t sessionId_ = 0; 52 std::weak_ptr<IScreenChannelListener> channelListener_; 53 }; 54 } // namespace DistributedHardware 55 } // namespace OHOS 56 #endif