diff --git a/src/channel.cpp b/src/channel.cpp index 7173b08c4..a63f91501 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -17,7 +17,7 @@ Channel::~Channel() { impl()->resetCallbacks(); } Channel::Channel(impl_ptr impl) : CheshireCat(std::move(impl)) {} -size_t Channel::maxMessageSize() const { return DEFAULT_MAX_MESSAGE_SIZE; } +size_t Channel::maxMessageSize() const { return 0; } size_t Channel::bufferedAmount() const { return impl()->bufferedAmount; } diff --git a/src/impl/datachannel.cpp b/src/impl/datachannel.cpp index 78cd59cf2..044952280 100644 --- a/src/impl/datachannel.cpp +++ b/src/impl/datachannel.cpp @@ -153,7 +153,7 @@ bool DataChannel::isClosed(void) const { return mIsClosed; } size_t DataChannel::maxMessageSize() const { auto pc = mPeerConnection.lock(); - return pc ? pc->remoteMaxMessageSize() : DEFAULT_MAX_MESSAGE_SIZE; + return pc ? pc->remoteMaxMessageSize() : DEFAULT_REMOTE_MAX_MESSAGE_SIZE; } void DataChannel::assignStream(uint16_t stream) { diff --git a/src/impl/internals.hpp b/src/impl/internals.hpp index bbbb68b03..63341c9cc 100644 --- a/src/impl/internals.hpp +++ b/src/impl/internals.hpp @@ -39,7 +39,9 @@ const uint16_t MAX_SCTP_STREAMS_COUNT = 1024; // Max number of negotiated SCTP s // of memory, Chromium historically limits to 1024. const size_t DEFAULT_LOCAL_MAX_MESSAGE_SIZE = 256 * 1024; // Default local max message size -const size_t DEFAULT_MAX_MESSAGE_SIZE = 65536; // Remote max message size if not specified in SDP +const size_t DEFAULT_REMOTE_MAX_MESSAGE_SIZE = 65536; // Remote max message size if not in SDP + +const size_t DEFAULT_WS_MAX_MESSAGE_SIZE = 256 * 1024; // Default max message size for WebSockets const size_t RECV_QUEUE_LIMIT = 1024 * 1024; // Max per-channel queue size diff --git a/src/impl/peerconnection.cpp b/src/impl/peerconnection.cpp index a20446d1f..a85e5d67d 100644 --- a/src/impl/peerconnection.cpp +++ b/src/impl/peerconnection.cpp @@ -103,7 +103,7 @@ optional PeerConnection::remoteDescription() const { size_t PeerConnection::remoteMaxMessageSize() const { const size_t localMax = config.maxMessageSize.value_or(DEFAULT_LOCAL_MAX_MESSAGE_SIZE); - size_t remoteMax = DEFAULT_MAX_MESSAGE_SIZE; + size_t remoteMax = DEFAULT_REMOTE_MAX_MESSAGE_SIZE; std::lock_guard lock(mRemoteDescriptionMutex); if (mRemoteDescription) if (auto *application = mRemoteDescription->application()) diff --git a/src/impl/websocket.cpp b/src/impl/websocket.cpp index 1f7e2d0a4..70381a7e6 100644 --- a/src/impl/websocket.cpp +++ b/src/impl/websocket.cpp @@ -156,7 +156,7 @@ bool WebSocket::isOpen() const { return state == State::Open; } bool WebSocket::isClosed() const { return state == State::Closed; } -size_t WebSocket::maxMessageSize() const { return config.maxMessageSize.value_or(DEFAULT_MAX_MESSAGE_SIZE); } +size_t WebSocket::maxMessageSize() const { return config.maxMessageSize.value_or(DEFAULT_WS_MAX_MESSAGE_SIZE); } optional WebSocket::receive() { auto next = mRecvQueue.pop(); diff --git a/src/impl/wstransport.cpp b/src/impl/wstransport.cpp index f25d96290..1ddf629d5 100644 --- a/src/impl/wstransport.cpp +++ b/src/impl/wstransport.cpp @@ -53,7 +53,7 @@ WsTransport::WsTransport(LowerTransport lower, shared_ptr handshake std::visit(rtc::overloaded{[](auto l) { return l->isActive(); }, [](shared_ptr l) { return l->isClient(); }}, lower)), - mMaxMessageSize(config.maxMessageSize.value_or(DEFAULT_MAX_MESSAGE_SIZE)), + mMaxMessageSize(config.maxMessageSize.value_or(DEFAULT_WS_MAX_MESSAGE_SIZE)), mMaxOutstandingPings(config.maxOutstandingPings.value_or(0)) { onRecv(std::move(recvCallback));