/* * Copyright 2020 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef PC_SCTP_DATA_CHANNEL_H_ #define PC_SCTP_DATA_CHANNEL_H_ #include <stdint.h> #include <memory> #include <set> #include <string> #include "absl/types/optional.h" #include "api/data_channel_interface.h" #include "api/priority.h" #include "api/rtc_error.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/transport/data_channel_transport_interface.h" #include "pc/data_channel_utils.h" #include "pc/sctp_utils.h" #include "rtc_base/containers/flat_set.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/ssl_stream_adapter.h" // For SSLRole #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/weak_ptr.h" namespace webrtc { class SctpDataChannel; // Interface that acts as a bridge from the data channel to the transport. // All methods in this interface need to be invoked on the network thread. class SctpDataChannelControllerInterface { … }; struct InternalDataChannelInit : public DataChannelInit { … }; // Helper class to allocate unique IDs for SCTP DataChannels. class SctpSidAllocator { … }; // SctpDataChannel is an implementation of the DataChannelInterface based on // SctpTransport. It provides an implementation of unreliable or // reliable data channels. // DataChannel states: // kConnecting: The channel has been created the transport might not yet be // ready. // kOpen: The open handshake has been performed (if relevant) and the data // channel is able to send messages. // kClosing: DataChannelInterface::Close has been called, or the remote side // initiated the closing procedure, but the closing procedure has not // yet finished. // kClosed: The closing handshake is finished (possibly initiated from this, // side, possibly from the peer). // // How the closing procedure works for SCTP: // 1. Alice calls Close(), state changes to kClosing. // 2. Alice finishes sending any queued data. // 3. Alice calls RemoveSctpDataStream, sends outgoing stream reset. // 4. Bob receives incoming stream reset; OnClosingProcedureStartedRemotely // called. // 5. Bob sends outgoing stream reset. // 6. Alice receives incoming reset, Bob receives acknowledgement. Both receive // OnClosingProcedureComplete callback and transition to kClosed. class SctpDataChannel : public DataChannelInterface { … }; } // namespace webrtc #endif // PC_SCTP_DATA_CHANNEL_H_