sctp_data_channel_transport.h 1.8 KB

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