blob: 623a490053f9b093dc5a015d59d1ecb289c6d14f [file] [log] [blame]
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -07001/*
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öllerbfcec4c2019-09-25 10:00:34 +020014#include "api/transport/data_channel_transport_interface.h"
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -070015#include "media/sctp/sctp_transport_internal.h"
16#include "rtc_base/third_party/sigslot/sigslot.h"
17
18namespace webrtc {
19
20// SCTP implementation of DataChannelTransportInterface.
21class 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 Alvestrand2697ac12019-12-16 10:37:04 +010041 void OnClosedAbruptly();
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -070042
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_