#ifndef TGCALLS_SCTP_DATA_CHANNEL_PROVIDER_IMPL_H #define TGCALLS_SCTP_DATA_CHANNEL_PROVIDER_IMPL_H #include "media/sctp/sctp_transport_factory.h" #include "api/turn_customizer.h" #include "api/data_channel_interface.h" #include "pc/sctp_data_channel.h" #include "media/sctp/sctp_transport_factory.h" #include "pc/sctp_transport.h" #include "StaticThreads.h" namespace cricket { class DtlsTransport; } // namespace cricket namespace tgcalls { class SctpDataChannelProviderInterfaceImpl : public sigslot::has_slots<>, public webrtc::SctpDataChannelControllerInterface, public webrtc::DataChannelObserver, public webrtc::DataChannelSink { public: SctpDataChannelProviderInterfaceImpl( rtc::PacketTransportInternal *transportChannel, bool isOutgoing, std::function onStateChanged, std::function onTerminated, std::function onMessageReceived, std::shared_ptr threads ); virtual ~SctpDataChannelProviderInterfaceImpl(); void updateIsConnected(bool isConnected); void sendDataChannelMessage(std::string const &message); virtual void OnStateChange() override; virtual void OnMessage(const webrtc::DataBuffer& buffer) override; virtual bool SendData( int sid, const webrtc::SendDataParams& params, const rtc::CopyOnWriteBuffer& payload, cricket::SendDataResult* result) override; virtual bool ConnectDataChannel(webrtc::SctpDataChannel *data_channel) override; virtual void DisconnectDataChannel(webrtc::SctpDataChannel* data_channel) override; virtual void AddSctpDataStream(int sid) override; virtual void RemoveSctpDataStream(int sid) override; virtual bool ReadyToSendData() const override; virtual void OnDataReceived(int channel_id, webrtc::DataMessageType type, const rtc::CopyOnWriteBuffer& buffer) override; virtual void OnReadyToSend() override; virtual void OnTransportClosed(webrtc::RTCError error) override; // Unused virtual void OnChannelClosing(int channel_id) override{} virtual void OnChannelClosed(int channel_id) override{} private: std::shared_ptr _threads; std::function _onStateChanged; std::function _onTerminated; std::function _onMessageReceived; std::unique_ptr _sctpTransportFactory; std::unique_ptr _sctpTransport; rtc::scoped_refptr _dataChannel; bool _isSctpTransportStarted = false; bool _isDataChannelOpen = false; }; } // namespace tgcalls #endif