#include "pc/sctp_data_channel.h"
#include <limits>
#include <memory>
#include <string>
#include <utility>
#include "api/priority.h"
#include "media/sctp/sctp_transport_internal.h"
#include "pc/proxy.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/system/unused.h"
#include "rtc_base/thread.h"
namespace webrtc {
namespace {
static size_t kMaxQueuedReceivedDataBytes = …;
static std::atomic<int> g_unique_id{ … };
int GenerateUniqueId() { … }
BEGIN_PROXY_MAP(DataChannel)
PROXY_PRIMARY_THREAD_DESTRUCTOR()
BYPASS_PROXY_METHOD1(void, RegisterObserver, DataChannelObserver*)
BYPASS_PROXY_METHOD0(void, UnregisterObserver)
BYPASS_PROXY_CONSTMETHOD0(std::string, label)
BYPASS_PROXY_CONSTMETHOD0(bool, reliable)
BYPASS_PROXY_CONSTMETHOD0(bool, ordered)
BYPASS_PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime)
BYPASS_PROXY_CONSTMETHOD0(uint16_t, maxRetransmits)
BYPASS_PROXY_CONSTMETHOD0(absl::optional<int>, maxRetransmitsOpt)
BYPASS_PROXY_CONSTMETHOD0(absl::optional<int>, maxPacketLifeTime)
BYPASS_PROXY_CONSTMETHOD0(std::string, protocol)
BYPASS_PROXY_CONSTMETHOD0(bool, negotiated)
PROXY_SECONDARY_CONSTMETHOD0(int, id)
BYPASS_PROXY_CONSTMETHOD0(PriorityValue, priority)
BYPASS_PROXY_CONSTMETHOD0(DataState, state)
BYPASS_PROXY_CONSTMETHOD0(RTCError, error)
PROXY_SECONDARY_CONSTMETHOD0(uint32_t, messages_sent)
PROXY_SECONDARY_CONSTMETHOD0(uint64_t, bytes_sent)
PROXY_SECONDARY_CONSTMETHOD0(uint32_t, messages_received)
PROXY_SECONDARY_CONSTMETHOD0(uint64_t, bytes_received)
PROXY_SECONDARY_CONSTMETHOD0(uint64_t, buffered_amount)
PROXY_SECONDARY_METHOD0(void, Close)
PROXY_SECONDARY_METHOD1(bool, Send, const DataBuffer&)
BYPASS_PROXY_METHOD2(void,
SendAsync,
DataBuffer,
absl::AnyInvocable<void(RTCError) &&>)
END_PROXY_MAP(DataChannel)
}
InternalDataChannelInit::InternalDataChannelInit(const DataChannelInit& base)
: … { … }
bool InternalDataChannelInit::IsValid() const { … }
absl::optional<StreamId> SctpSidAllocator::AllocateSid(rtc::SSLRole role) { … }
bool SctpSidAllocator::ReserveSid(StreamId sid) { … }
void SctpSidAllocator::ReleaseSid(StreamId sid) { … }
class SctpDataChannel::ObserverAdapter : public DataChannelObserver { … };
rtc::scoped_refptr<SctpDataChannel> SctpDataChannel::Create(
rtc::WeakPtr<SctpDataChannelControllerInterface> controller,
const std::string& label,
bool connected_to_transport,
const InternalDataChannelInit& config,
rtc::Thread* signaling_thread,
rtc::Thread* network_thread) { … }
rtc::scoped_refptr<DataChannelInterface> SctpDataChannel::CreateProxy(
rtc::scoped_refptr<SctpDataChannel> channel,
rtc::scoped_refptr<PendingTaskSafetyFlag> signaling_safety) { … }
SctpDataChannel::SctpDataChannel(
const InternalDataChannelInit& config,
rtc::WeakPtr<SctpDataChannelControllerInterface> controller,
const std::string& label,
bool connected_to_transport,
rtc::Thread* signaling_thread,
rtc::Thread* network_thread)
: … { … }
SctpDataChannel::~SctpDataChannel() { … }
void SctpDataChannel::RegisterObserver(DataChannelObserver* observer) { … }
void SctpDataChannel::UnregisterObserver() { … }
std::string SctpDataChannel::label() const { … }
bool SctpDataChannel::reliable() const { … }
bool SctpDataChannel::ordered() const { … }
uint16_t SctpDataChannel::maxRetransmitTime() const { … }
uint16_t SctpDataChannel::maxRetransmits() const { … }
absl::optional<int> SctpDataChannel::maxPacketLifeTime() const { … }
absl::optional<int> SctpDataChannel::maxRetransmitsOpt() const { … }
std::string SctpDataChannel::protocol() const { … }
bool SctpDataChannel::negotiated() const { … }
int SctpDataChannel::id() const { … }
PriorityValue SctpDataChannel::priority() const { … }
uint64_t SctpDataChannel::buffered_amount() const { … }
void SctpDataChannel::Close() { … }
SctpDataChannel::DataState SctpDataChannel::state() const { … }
RTCError SctpDataChannel::error() const { … }
uint32_t SctpDataChannel::messages_sent() const { … }
uint64_t SctpDataChannel::bytes_sent() const { … }
uint32_t SctpDataChannel::messages_received() const { … }
uint64_t SctpDataChannel::bytes_received() const { … }
bool SctpDataChannel::Send(const DataBuffer& buffer) { … }
RTCError SctpDataChannel::SendImpl(DataBuffer buffer) { … }
void SctpDataChannel::SendAsync(
DataBuffer buffer,
absl::AnyInvocable<void(RTCError) &&> on_complete) { … }
void SctpDataChannel::SetSctpSid_n(StreamId sid) { … }
void SctpDataChannel::OnClosingProcedureStartedRemotely() { … }
void SctpDataChannel::OnClosingProcedureComplete() { … }
void SctpDataChannel::OnTransportChannelCreated() { … }
void SctpDataChannel::OnTransportChannelClosed(RTCError error) { … }
void SctpDataChannel::OnBufferedAmountLow() { … }
DataChannelStats SctpDataChannel::GetStats() const { … }
void SctpDataChannel::OnDataReceived(DataMessageType type,
const rtc::CopyOnWriteBuffer& payload) { … }
void SctpDataChannel::OnTransportReady() { … }
void SctpDataChannel::CloseAbruptlyWithError(RTCError error) { … }
void SctpDataChannel::CloseAbruptlyWithDataChannelFailure(
const std::string& message) { … }
void SctpDataChannel::UpdateState() { … }
void SctpDataChannel::SetState(DataState state) { … }
void SctpDataChannel::DeliverQueuedReceivedData() { … }
void SctpDataChannel::MaybeSendOnBufferedAmountChanged() { … }
RTCError SctpDataChannel::SendDataMessage(const DataBuffer& buffer,
bool queue_if_blocked) { … }
bool SctpDataChannel::SendControlMessage(const rtc::CopyOnWriteBuffer& buffer) { … }
void SctpDataChannel::ResetInternalIdAllocatorForTesting(int new_value) { … }
}