| 5 |
| #include "rtc_base/socket_address.h" |
| 6 | #include "rtc_base/copy_on_write_buffer.h" |
| 7 | #include "rtc_base/byte_buffer.h" |
| 8 | #include "media/base/media_channel.h" |
| 9 |
| 10 | #include <vector> |
| 11 |
| 12 | #include <absl/types/optional.h> |
| 13 |
| 14 | #include "StaticThreads.h" |
| 15 | #include "SignalingConnection.h" |
| 16 |
| 17 | #include "ikcp.h" |
| 18 |
| 19 | namespace rtc { |
| 20 | class Socket; |
| 21 | } |
| 22 |
| 23 | namespace cricket { |
| 24 | class SctpTransportFactory; |
| 25 | class SctpTransportInternal; |
| 26 | }; |
| 27 |
| 28 | namespace tgcalls { |
| 29 |
| 30 | class SignalingPacketTransport; |
| 31 |
| 32 | class SignalingKcpConnection : public sigslot::has_slots<>, public SignalingConnection, public std::enable_shared_from_this<SignalingKcpConnection> { |
| 33 | public: |
| 34 | SignalingKcpConnection(std::shared_ptr<Threads> threads, std::function<void(const std::vector<uint8_t> &)> onIncomingData, std::function<void(const std::vector<uint8_t> &)> emitData); |
| 35 | virtual ~SignalingKcpConnection(); |
| 36 |
| 37 | virtual void receiveExternal(const std::vector<uint8_t> &data) override; |
| 38 | virtual void start() override; |
| 39 | virtual void send(const std::vector<uint8_t> &data) override; |
| 40 |
| 41 | private: |
| 42 | void scheduleInternalUpdate(int timeoutMs); |
| 43 | void performInternalUpdate(); |
| 44 | static int udpOutput(const char *buf, int len, ikcpcb *kcp, void *user); |
| 45 |
| 46 | private: |
| 47 | std::shared_ptr<Threads> _threads; |
| 48 | std::function<void(const std::vector<uint8_t> &)> _emitData; |
| 49 | std::function<void(const std::vector<uint8_t> &)> _onIncomingData; |
| 50 |
| 51 | ikcpcb *_kcp = nullptr; |
| 52 | std::vector<uint8_t> _receiveBuffer; |
| 53 | }; |
| 54 |
| 55 | } // namespace tgcalls |
| 56 |
| 57 | #endif // TGCALLS_SIGNALING_SCTP_CONNECTION_H_ |
| 58 |