Bug 1373450: report if MaxMessageSize was set in SDP. r?jesup
MozReview-Commit-ID: OqspJsw1Bw
--- a/media/webrtc/signaling/src/jsep/JsepCodecDescription.h
+++ b/media/webrtc/signaling/src/jsep/JsepCodecDescription.h
@@ -809,27 +809,27 @@ class JsepApplicationCodecDescription :
}
}
bool
Negotiate(const std::string& pt, const SdpMediaSection& remoteMsection) override
{
JsepCodecDescription::Negotiate(pt, remoteMsection);
- uint32_t message_size = remoteMsection.GetMaxMessageSize();
- if (message_size) {
+ uint32_t message_size;
+ mRemoteMMSSet = remoteMsection.GetMaxMessageSize(&message_size);
+ if (mRemoteMMSSet) {
mRemoteMaxMessageSize = message_size;
+ } else {
+ mRemoteMaxMessageSize = WEBRTC_DATACHANELL_MAX_MESSAGE_SIZE_DEFAULT;
}
int sctp_port = remoteMsection.GetSctpPort();
if (sctp_port) {
mRemotePort = sctp_port;
- if (!message_size) {
- mRemoteMaxMessageSize = WEBRTC_DATACHANELL_MAX_MESSAGE_SIZE_DEFAULT;
- }
return true;
}
const SdpSctpmapAttributeList::Sctpmap* sctp_map(
remoteMsection.GetSctpmap());
if (sctp_map) {
mRemotePort = std::stoi(sctp_map->pt);
return true;
@@ -838,13 +838,14 @@ class JsepApplicationCodecDescription :
return false;
}
uint16_t mLocalPort;
uint32_t mLocalMaxMessageSize;
uint16_t mRemotePort;
uint32_t mRemoteMaxMessageSize;
+ bool mRemoteMMSSet;
};
} // namespace mozilla
#endif
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -1079,17 +1079,18 @@ PeerConnectionImpl::ConfigureJsepSession
}
// Data channels won't work without a window, so in order for the C++ unit
// tests to work (it doesn't have a window available) we ifdef the following
// two implementations.
NS_IMETHODIMP
PeerConnectionImpl::EnsureDataConnection(uint16_t aLocalPort,
uint16_t aNumstreams,
- uint32_t aMaxMessageSize)
+ uint32_t aMaxMessageSize,
+ bool aMMSSet)
{
PC_AUTO_ENTER_API_CALL(false);
if (mDataConnection) {
CSFLogDebug(logTag,"%s DataConnection already connected",__FUNCTION__);
// Ignore the request to connect when already connected. This entire
// implementation is temporary. Ignore aNumstreams as it's merely advisory
// and we increase the number of streams dynamically as needed.
@@ -1106,16 +1107,17 @@ PeerConnectionImpl::EnsureDataConnection
}
nsresult
PeerConnectionImpl::GetDatachannelParameters(
uint32_t* channels,
uint16_t* localport,
uint16_t* remoteport,
uint32_t* remotemaxmessagesize,
+ bool* mmsset,
uint16_t* level) const {
auto trackPairs = mJsepSession->GetNegotiatedTrackPairs();
for (auto& trackPair : trackPairs) {
bool sendDataChannel =
trackPair.mSending &&
trackPair.mSending->GetMediaType() == SdpMediaSection::kApplication;
bool recvDataChannel =
@@ -1160,30 +1162,33 @@ PeerConnectionImpl::GetDatachannelParame
*channels = WEBRTC_DATACHANNEL_STREAMS_DEFAULT;
}
*localport =
static_cast<const JsepApplicationCodecDescription*>(codec)->mLocalPort;
*remoteport =
static_cast<const JsepApplicationCodecDescription*>(codec)->mRemotePort;
*remotemaxmessagesize = static_cast<const JsepApplicationCodecDescription*>
(codec)->mRemoteMaxMessageSize;
+ *mmsset = static_cast<const JsepApplicationCodecDescription*>
+ (codec)->mRemoteMMSSet;
if (trackPair.HasBundleLevel()) {
*level = static_cast<uint16_t>(trackPair.BundleLevel());
} else {
*level = static_cast<uint16_t>(trackPair.mLevel);
}
return NS_OK;
}
}
}
*channels = 0;
*localport = 0;
*remoteport = 0;
*remotemaxmessagesize = 0;
+ *mmsset = false;
*level = 0;
return NS_ERROR_FAILURE;
}
/* static */
void
PeerConnectionImpl::DeferredAddTrackToJsepSession(
const std::string& pcHandle,
@@ -1234,30 +1239,31 @@ PeerConnectionImpl::InitializeDataChanne
{
PC_AUTO_ENTER_API_CALL(false);
CSFLogDebug(logTag, "%s", __FUNCTION__);
uint32_t channels = 0;
uint16_t localport = 0;
uint16_t remoteport = 0;
uint32_t remotemaxmessagesize = 0;
+ bool mmsset = false;
uint16_t level = 0;
nsresult rv = GetDatachannelParameters(&channels, &localport, &remoteport,
- &remotemaxmessagesize, &level);
+ &remotemaxmessagesize, &mmsset, &level);
if (NS_FAILED(rv)) {
CSFLogDebug(logTag, "%s: We did not negotiate datachannel", __FUNCTION__);
return NS_OK;
}
if (channels > MAX_NUM_STREAMS) {
channels = MAX_NUM_STREAMS;
}
- rv = EnsureDataConnection(localport, channels, remotemaxmessagesize);
+ rv = EnsureDataConnection(localport, channels, remotemaxmessagesize, mmsset);
if (NS_SUCCEEDED(rv)) {
// use the specified TransportFlow
RefPtr<TransportFlow> flow = mMedia->GetTransportFlow(level, false).get();
CSFLogDebug(logTag, "Transportflow[%u] = %p",
static_cast<unsigned>(level), flow.get());
if (flow) {
if (mDataConnection->ConnectViaTransportFlow(flow,
localport,
@@ -1305,17 +1311,18 @@ PeerConnectionImpl::CreateDataChannel(co
MOZ_ASSERT(aRetval);
RefPtr<DataChannel> dataChannel;
DataChannelConnection::Type theType =
static_cast<DataChannelConnection::Type>(aType);
nsresult rv = EnsureDataConnection(WEBRTC_DATACHANNEL_PORT_DEFAULT,
WEBRTC_DATACHANNEL_STREAMS_DEFAULT,
- WEBRTC_DATACHANELL_MAX_MESSAGE_SIZE_DEFAULT);
+ WEBRTC_DATACHANELL_MAX_MESSAGE_SIZE_DEFAULT,
+ false);
if (NS_FAILED(rv)) {
return rv;
}
dataChannel = mDataConnection->Open(
NS_ConvertUTF16toUTF8(aLabel), NS_ConvertUTF16toUTF8(aProtocol), theType,
ordered,
aType == DataChannelConnection::PARTIAL_RELIABLE_REXMIT ? aMaxNum :
(aType == DataChannelConnection::PARTIAL_RELIABLE_TIMED ? aMaxTime : 0),
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -642,17 +642,17 @@ private:
virtual ~PeerConnectionImpl();
PeerConnectionImpl(const PeerConnectionImpl&rhs);
PeerConnectionImpl& operator=(PeerConnectionImpl);
nsresult CalculateFingerprint(const std::string& algorithm,
std::vector<uint8_t>* fingerprint) const;
nsresult ConfigureJsepSessionCodecs();
NS_IMETHODIMP EnsureDataConnection(uint16_t aLocalPort, uint16_t aNumstreams,
- uint32_t aMaxMessageSize);
+ uint32_t aMaxMessageSize, bool aMMSSet);
nsresult CloseInt();
nsresult CheckApiState(bool assert_ice_ready) const;
void CheckThread() const {
MOZ_ASSERT(CheckThreadInt(), "Wrong thread");
}
bool CheckThreadInt() const {
bool on;
@@ -676,16 +676,17 @@ private:
const std::string& mid,
const std::string& candidate);
nsresult GetDatachannelParameters(
uint32_t* channels,
uint16_t* localport,
uint16_t* remoteport,
uint32_t* maxmessagesize,
+ bool* mmsset,
uint16_t* level) const;
static void DeferredAddTrackToJsepSession(const std::string& pcHandle,
SdpMediaSection::MediaType type,
const std::string& streamId,
const std::string& trackId);
nsresult AddTrackToJsepSession(SdpMediaSection::MediaType type,
--- a/media/webrtc/signaling/src/sdp/SdpMediaSection.cpp
+++ b/media/webrtc/signaling/src/sdp/SdpMediaSection.cpp
@@ -105,25 +105,28 @@ SdpMediaSection::GetSctpPort() const
auto& attrs = GetAttributeList();
if (!attrs.HasAttribute(SdpAttribute::kSctpPortAttribute)) {
return 0;
}
return attrs.GetSctpPort();
}
-uint32_t
-SdpMediaSection::GetMaxMessageSize() const
+bool
+SdpMediaSection::GetMaxMessageSize(uint32_t* size) const
{
+ *size = 0;
+
auto& attrs = GetAttributeList();
if (!attrs.HasAttribute(SdpAttribute::kMaxMessageSizeAttribute)) {
- return 0;
+ return false;
}
- return attrs.GetMaxMessageSize();
+ *size = attrs.GetMaxMessageSize();
+ return true;
}
bool
SdpMediaSection::HasRtcpFb(const std::string& pt,
SdpRtcpFbAttributeList::Type type,
const std::string& subType) const
{
const SdpAttributeList& attrs(GetAttributeList());
--- a/media/webrtc/signaling/src/sdp/SdpMediaSection.h
+++ b/media/webrtc/signaling/src/sdp/SdpMediaSection.h
@@ -153,17 +153,17 @@ public:
}
const SdpFmtpAttributeList::Parameters* FindFmtp(const std::string& pt) const;
void SetFmtp(const SdpFmtpAttributeList::Fmtp& fmtp);
void RemoveFmtp(const std::string& pt);
const SdpRtpmapAttributeList::Rtpmap* FindRtpmap(const std::string& pt) const;
const SdpSctpmapAttributeList::Sctpmap* GetSctpmap() const;
uint32_t GetSctpPort() const;
- uint32_t GetMaxMessageSize() const;
+ bool GetMaxMessageSize(uint32_t* size) const;
bool HasRtcpFb(const std::string& pt,
SdpRtcpFbAttributeList::Type type,
const std::string& subType) const;
SdpRtcpFbAttributeList GetRtcpFbs() const;
void SetRtcpFbs(const SdpRtcpFbAttributeList& rtcpfbs);
bool HasFormat(const std::string& format) const
{
return std::find(GetFormats().begin(), GetFormats().end(), format) !=