1 /*
2  * Copyright (c) 2023-2024 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_SOFTBUS_ADAPTER
17 #define OHOS_SOFTBUS_ADAPTER
18 
19 #include <mutex>
20 #include <map>
21 #include <set>
22 
23 #include "session.h"
24 #include "socket.h"
25 #include "dm_single_instance.h"
26 namespace OHOS {
27 namespace DistributedHardware {
28 class SoftbusAdapter {
29     DM_DECLARE_SINGLE_INSTANCE_BASE(SoftbusAdapter);
30 public:
31     SoftbusAdapter();
32     ~SoftbusAdapter();
33     int32_t CreateSoftbusSessionServer(const std::string &pkgname, const std::string &sessionName);
34     int32_t RemoveSoftbusSessionServer(const std::string &pkgname, const std::string &sessionName);
35 
36     void OnSoftbusSessionOpened(int32_t socket, PeerSocketInfo info);
37     void OnSoftbusSessionClosed(int32_t socket, ShutdownReason reason);
38     void OnBytesReceived(int32_t socket, const void *data, uint32_t dataLen);
39     void OnStreamReceived(int32_t socket, const StreamData *data, const StreamData *ext,
40         const StreamFrameInfo *frameInfo);
41     void OnMessageReceived(int32_t socket, const void *data, unsigned int dataLen) const;
42     void OnQosEvent(int32_t socket, QoSEvent eventId, const QosTV *qos, uint32_t qosCount) const;
43 
44 private:
45     ISocketListener iSocketListener_;
46 };
47 } // namespace DistributedHardware
48 } // namespace OHOS
49 #endif