1 /* 2 * Copyright 2019 The WebRTC Project Authors. All rights reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef PC_SCTP_DATA_CHANNEL_TRANSPORT_H_ 12 #define PC_SCTP_DATA_CHANNEL_TRANSPORT_H_ 13 14 #include "api/transport/data_channel_transport_interface.h" 15 #include "media/sctp/sctp_transport_internal.h" 16 #include "rtc_base/third_party/sigslot/sigslot.h" 17 18 namespace webrtc { 19 20 // SCTP implementation of DataChannelTransportInterface. 21 class SctpDataChannelTransport : public DataChannelTransportInterface, 22 public sigslot::has_slots<> { 23 public: 24 explicit SctpDataChannelTransport( 25 cricket::SctpTransportInternal* sctp_transport); 26 27 RTCError OpenChannel(int channel_id) override; 28 RTCError SendData(int channel_id, 29 const SendDataParams& params, 30 const rtc::CopyOnWriteBuffer& buffer) override; 31 RTCError CloseChannel(int channel_id) override; 32 void SetDataSink(DataChannelSink* sink) override; 33 bool IsReadyToSend() const override; 34 35 private: 36 void OnReadyToSendData(); 37 void OnDataReceived(const cricket::ReceiveDataParams& params, 38 const rtc::CopyOnWriteBuffer& buffer); 39 void OnClosingProcedureStartedRemotely(int channel_id); 40 void OnClosingProcedureComplete(int channel_id); 41 void OnClosedAbruptly(); 42 43 cricket::SctpTransportInternal* const sctp_transport_; 44 45 DataChannelSink* sink_ = nullptr; 46 bool ready_to_send_ = false; 47 }; 48 49 } // namespace webrtc 50 51 #endif // PC_SCTP_DATA_CHANNEL_TRANSPORT_H_ 52