From 0c719fb46296cf3c345c318e8488bd52e909eee5 Mon Sep 17 00:00:00 2001 From: Nico Grunbaum Date: Thu, 22 Nov 2018 00:14:36 +0000 Subject: [PATCH] Bug 1489040 Update WebRTC ICE candidate stats field name ipAddress to address r=mjf,jib,smaug Bug 1489040 - P1 - Update WebRTC ICE candidate stats field ipAddress to new name, address Bug 1489040 - P2 - adjust WebRTC stats mochitest for new stat name 'address' Bug 1489040 - P3 - add test for legacy WebRTC stat names Differential Revision: https://phabricator.services.mozilla.com/D5560 --HG-- extra : moz-landing-system : lando --- dom/media/PeerConnection.js | 11 +++++++++++ .../mochitest/test_peerConnection_stats.html | 16 ++++++++-------- dom/media/webrtc/WebrtcGlobal.h | 4 ++-- dom/webidl/RTCStatsReport.webidl | 2 +- .../src/peerconnection/MediaTransportHandler.cpp | 2 +- .../peerconnection/WebrtcGlobalInformation.cpp | 4 ++-- toolkit/content/aboutwebrtc/aboutWebrtc.js | 2 +- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index 374fe5e8f3b2..0f6115392bae 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -306,6 +306,17 @@ class RTCStatsReport { makeStatsPublic(warnNullable, warnRemoteNullable, isLegacy) { let legacyProps = {}; for (let key in this._report) { + const underlying = this._report[key]; + // Add legacy names for renamed stats + if (underlying.type == "local-candidate" || underlying.type == "remote-candidate") { + // Copy stat.address to the legacy field name + underlying.ipAddress = underlying.address; + if (isLegacy) { + // Callback stats are frozen to have legacy names + delete underlying.address; + } + } + let internal = Cu.cloneInto(this._report[key], this._win); if (isLegacy) { internal.type = this._specToLegacyFieldMapping[internal.type] || internal.type; diff --git a/dom/media/tests/mochitest/test_peerConnection_stats.html b/dom/media/tests/mochitest/test_peerConnection_stats.html index 1888139e78a3..1f44c5f5699b 100644 --- a/dom/media/tests/mochitest/test_peerConnection_stats.html +++ b/dom/media/tests/mochitest/test_peerConnection_stats.html @@ -57,20 +57,20 @@ var statsExpectedByType = { deprecated: [], }, "local-candidate": { - expected: ["id", "timestamp", "type", "componentId", "ipAddress", - "transport", "mozLocalTransport", "portNumber", + expected: ["id", "timestamp", "type", "componentId", "address", + "ipAddress", "transport", "mozLocalTransport", "portNumber", "candidateType"], optional: [], - unimplemented: ["address", "port", "networkType", "protocol", - "relayProtocol", "priority", "url"], + unimplemented: ["port", "networkType", "protocol", "relayProtocol", + "priority", "url"], deprecated: ["candidateId"], }, "remote-candidate": { - expected: ["id", "timestamp", "type", "componentId", "ipAddress", - "transport", "portNumber", "candidateType"], + expected: ["id", "timestamp", "type", "componentId", "address", + "ipAddress", "transport", "portNumber", "candidateType"], optional: [], - unimplemented: ["address", "port", "networkType", "protocol", - "relayProtocol", "priority", "url"], + unimplemented: ["port", "networkType", "protocol", "relayProtocol", + "priority", "url"], deprecated: ["candidateId"], }, "certificate": { skip: true }, diff --git a/dom/media/webrtc/WebrtcGlobal.h b/dom/media/webrtc/WebrtcGlobal.h index d9ed86c08383..d8d7db532853 100644 --- a/dom/media/webrtc/WebrtcGlobal.h +++ b/dom/media/webrtc/WebrtcGlobal.h @@ -211,7 +211,7 @@ struct ParamTraits { WriteParam(aMsg, aParam.mCandidateId); WriteParam(aMsg, aParam.mCandidateType); WriteParam(aMsg, aParam.mComponentId); - WriteParam(aMsg, aParam.mIpAddress); + WriteParam(aMsg, aParam.mAddress); WriteParam(aMsg, aParam.mMozLocalTransport); WriteParam(aMsg, aParam.mRelayProtocol); WriteParam(aMsg, aParam.mPortNumber); @@ -224,7 +224,7 @@ struct ParamTraits { if (!ReadParam(aMsg, aIter, &(aResult->mCandidateId)) || !ReadParam(aMsg, aIter, &(aResult->mCandidateType)) || !ReadParam(aMsg, aIter, &(aResult->mComponentId)) || - !ReadParam(aMsg, aIter, &(aResult->mIpAddress)) || + !ReadParam(aMsg, aIter, &(aResult->mAddress)) || !ReadParam(aMsg, aIter, &(aResult->mMozLocalTransport)) || !ReadParam(aMsg, aIter, &(aResult->mRelayProtocol)) || !ReadParam(aMsg, aIter, &(aResult->mPortNumber)) || diff --git a/dom/webidl/RTCStatsReport.webidl b/dom/webidl/RTCStatsReport.webidl index 4bdcf67a3388..17785bd76689 100644 --- a/dom/webidl/RTCStatsReport.webidl +++ b/dom/webidl/RTCStatsReport.webidl @@ -153,7 +153,7 @@ enum RTCStatsIceCandidateType { dictionary RTCIceCandidateStats : RTCStats { DOMString componentId; DOMString candidateId; - DOMString ipAddress; + DOMString address; DOMString transport; DOMString mozLocalTransport; // obsoleted by relayProtocol DOMString relayProtocol; diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp b/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp index d28e13555057..c01c0a3b9b03 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp @@ -591,7 +591,7 @@ static void ToRTCIceCandidateStats( cand.mTimestamp.Construct(now); cand.mCandidateType.Construct( dom::RTCStatsIceCandidateType(candidate.type)); - cand.mIpAddress.Construct( + cand.mAddress.Construct( NS_ConvertASCIItoUTF16(candidate.cand_addr.host.c_str())); cand.mPortNumber.Construct(candidate.cand_addr.port); cand.mTransport.Construct( diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp index 791c57f6501c..88312158b118 100644 --- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp +++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp @@ -991,7 +991,7 @@ static uint32_t GetCandidateIpAndTransportMask(const RTCIceCandidateStats *cand) res |= CANDIDATE_BITMASK_TCP; } - if (cand->mIpAddress.Value().FindChar(':') != -1) { + if (cand->mAddress.Value().FindChar(':') != -1) { res |= CANDIDATE_BITMASK_IPV6; } @@ -1050,7 +1050,7 @@ static void StoreLongTermICEStatisticsImpl_m( if (!cand.mType.WasPassed() || !cand.mCandidateType.WasPassed() || !cand.mTransport.WasPassed() || - !cand.mIpAddress.WasPassed() || + !cand.mAddress.WasPassed() || !cand.mComponentId.WasPassed()) { // Crash on debug, ignore this candidate otherwise. MOZ_CRASH(); diff --git a/toolkit/content/aboutwebrtc/aboutWebrtc.js b/toolkit/content/aboutwebrtc/aboutWebrtc.js index 8e8446762b51..c6304c68344c 100644 --- a/toolkit/content/aboutwebrtc/aboutWebrtc.js +++ b/toolkit/content/aboutwebrtc/aboutWebrtc.js @@ -853,7 +853,7 @@ ICEStats.prototype = { type = `${c.candidateType}-${c.relayProtocol}`; } - return `${c.ipAddress}:${c.portNumber}/${c.transport}(${type})`; + return `${c.address}:${c.portNumber}/${c.transport}(${type})`; }, };