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); |
Harald Alvestrand | 2697ac1 | 2019-12-16 10:37:04 +0100 | [diff] [blame] | 41 | void OnClosedAbruptly(); |
Bjorn A Mellem | bc3eebc | 2019-09-23 14:53:54 -0700 | [diff] [blame] | 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_ |