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/rtc_error.h" 15 #include "api/transport/data_channel_transport_interface.h" 16 #include "media/base/media_channel.h" 17 #include "media/sctp/sctp_transport_internal.h" 18 #include "rtc_base/copy_on_write_buffer.h" 19 #include "rtc_base/third_party/sigslot/sigslot.h" 20 21 namespace webrtc { 22 23 // SCTP implementation of DataChannelTransportInterface. 24 class SctpDataChannelTransport : public DataChannelTransportInterface, 25 public sigslot::has_slots<> { 26 public: 27 explicit SctpDataChannelTransport( 28 cricket::SctpTransportInternal* sctp_transport); 29 30 RTCError OpenChannel(int channel_id) override; 31 RTCError SendData(int channel_id, 32 const SendDataParams& params, 33 const rtc::CopyOnWriteBuffer& buffer) override; 34 RTCError CloseChannel(int channel_id) override; 35 void SetDataSink(DataChannelSink* sink) override; 36 bool IsReadyToSend() const override; 37 38 private: 39 void OnReadyToSendData(); 40 void OnDataReceived(const cricket::ReceiveDataParams& params, 41 const rtc::CopyOnWriteBuffer& buffer); 42 void OnClosingProcedureStartedRemotely(int channel_id); 43 void OnClosingProcedureComplete(int channel_id); 44 void OnClosedAbruptly(); 45 46 cricket::SctpTransportInternal* const sctp_transport_; 47 48 DataChannelSink* sink_ = nullptr; 49 bool ready_to_send_ = false; 50 }; 51 52 } // namespace webrtc 53 54 #endif // PC_SCTP_DATA_CHANNEL_TRANSPORT_H_ 55