dcsctp: Add SetMaxMessageSize() to socket

An SCTP transport for Data Channels allows changing the maximum
message size through SDP.
See https://w3c.github.io/webrtc-pc/#sctp-transport-update-mms

Bug: webrtc:12614
Change-Id: I8cff33c5f9c1d60934a726c546bc9cbdcd9e22d9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217387
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33920}
This commit is contained in:
Florent Castelli
2021-05-04 20:12:52 +02:00
committed by WebRTC LUCI CQ
parent da3dc149b2
commit 0810b05104
4 changed files with 14 additions and 1 deletions

View File

@ -296,6 +296,9 @@ class DcSctpSocketInterface {
// The options it was created with.
virtual const DcSctpOptions& options() const = 0;
// Update the options max_message_size.
virtual void SetMaxMessageSize(size_t max_message_size) = 0;
// Sends the message `message` using the provided send options.
// Sending a message is an asynchrous operation, and the `OnError` callback
// may be invoked to indicate any errors in sending the message.

View File

@ -424,6 +424,10 @@ SocketState DcSctpSocket::state() const {
}
}
void DcSctpSocket::SetMaxMessageSize(size_t max_message_size) {
options_.max_message_size = max_message_size;
}
void DcSctpSocket::MaybeSendShutdownOnPacketReceived(const SctpPacket& packet) {
if (state_ == State::kShutdownSent) {
bool has_data_chunk =

View File

@ -92,6 +92,7 @@ class DcSctpSocket : public DcSctpSocketInterface {
rtc::ArrayView<const StreamID> outgoing_streams) override;
SocketState state() const override;
const DcSctpOptions& options() const override { return options_; }
void SetMaxMessageSize(size_t max_message_size) override;
// Returns this socket's verification tag, or zero if not yet connected.
VerificationTag verification_tag() const {
@ -244,7 +245,7 @@ class DcSctpSocket : public DcSctpSocketInterface {
const std::string log_prefix_;
const std::unique_ptr<PacketObserver> packet_observer_;
const DcSctpOptions options_;
DcSctpOptions options_;
// Enqueues callbacks and dispatches them just before returning to the caller.
CallbackDeferrer callbacks_;

View File

@ -1085,5 +1085,10 @@ TEST_F(DcSctpSocketTest, PassingHighWatermarkWillOnlyAcceptCumAckTsn) {
.Build());
}
TEST_F(DcSctpSocketTest, SetMaxMessageSize) {
sock_a_.SetMaxMessageSize(42u);
EXPECT_EQ(sock_a_.options().max_message_size, 42u);
}
} // namespace
} // namespace dcsctp