Bjorn A Mellem | bc3eebc | 2019-09-23 14:53:54 -0700 | [diff] [blame] | 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 | |
Niels Möller | bfcec4c | 2019-09-25 10:00:34 +0200 | [diff] [blame] | 14 | #include "api/transport/data_channel_transport_interface.h" |
Bjorn A Mellem | bc3eebc | 2019-09-23 14:53:54 -0700 | [diff] [blame] | 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 | |
| 42 | cricket::SctpTransportInternal* const sctp_transport_; |
| 43 | |
| 44 | DataChannelSink* sink_ = nullptr; |
| 45 | bool ready_to_send_ = false; |
| 46 | }; |
| 47 | |
| 48 | } // namespace webrtc |
| 49 | |
| 50 | #endif // PC_SCTP_DATA_CHANNEL_TRANSPORT_H_ |