mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
Issue #2332 - Hyphenate rtc stats type as per spec
Backport of https://bugzilla.mozilla.org/show_bug.cgi?id=1322503
This commit is contained in:
parent
4edd2f91b4
commit
9f63203a43
7 changed files with 57 additions and 42 deletions
|
|
@ -308,13 +308,20 @@ RTCStatsReport.prototype = {
|
|||
// Since maplike is recent, we still also make the stats available as legacy
|
||||
// enumerable read-only properties directly on our content-facing object.
|
||||
// Must be called after our webidl sandwich is made.
|
||||
_specToLegacyFieldMapping: {
|
||||
'inbound-rtp' : 'inboundrtp',
|
||||
'outbound-rtp':'outboundrtp',
|
||||
'candidate-pair':'candidatepair',
|
||||
'local-candidate':'localcandidate',
|
||||
'remote-candidate':'remotecandidate'
|
||||
},
|
||||
|
||||
makeStatsPublic: function(warnNullable) {
|
||||
let legacyProps = {};
|
||||
for (let key in this._report) {
|
||||
this.setInternal(key, Cu.cloneInto(this._report[key], this._win));
|
||||
let value = Cu.cloneInto(this._report[key], this._win);
|
||||
this.setInternal(key, value);
|
||||
|
||||
value.type = this._specToLegacyFieldMapping[value.type] || value.type;
|
||||
legacyProps[key] = {
|
||||
enumerable: true, configurable: false,
|
||||
get: Cu.exportFunction(function() {
|
||||
|
|
|
|||
|
|
@ -1417,12 +1417,12 @@ PeerConnectionWrapper.prototype = {
|
|||
waitForRtpFlow(track) {
|
||||
var hasFlow = stats => {
|
||||
var rtp = stats.get([...stats.keys()].find(key =>
|
||||
!stats.get(key).isRemote && stats.get(key).type.endsWith("boundrtp")));
|
||||
!stats.get(key).isRemote && stats.get(key).type.endsWith("bound-rtp")));
|
||||
ok(rtp, "Should have RTP stats for track " + track.id);
|
||||
if (!rtp) {
|
||||
return false;
|
||||
}
|
||||
var nrPackets = rtp[rtp.type == "outboundrtp" ? "packetsSent"
|
||||
var nrPackets = rtp[rtp.type == "outbound-rtp" ? "packetsSent"
|
||||
: "packetsReceived"];
|
||||
info("Track " + track.id + " has " + nrPackets + " " +
|
||||
rtp.type + " RTP packets.");
|
||||
|
|
@ -1559,15 +1559,15 @@ PeerConnectionWrapper.prototype = {
|
|||
counters[res.type] = (counters[res.type] || 0) + 1;
|
||||
|
||||
switch (res.type) {
|
||||
case "inboundrtp":
|
||||
case "outboundrtp": {
|
||||
case "inbound-rtp":
|
||||
case "outbound-rtp": {
|
||||
// ssrc is a 32 bit number returned as a string by spec
|
||||
ok(res.ssrc.length > 0, "Ssrc has length");
|
||||
ok(res.ssrc.length < 11, "Ssrc not lengthy");
|
||||
ok(!/[^0-9]/.test(res.ssrc), "Ssrc numeric");
|
||||
ok(parseInt(res.ssrc) < Math.pow(2,32), "Ssrc within limits");
|
||||
|
||||
if (res.type == "outboundrtp") {
|
||||
if (res.type == "outbound-rtp") {
|
||||
ok(res.packetsSent !== undefined, "Rtp packetsSent");
|
||||
// We assume minimum payload to be 1 byte (guess from RFC 3550)
|
||||
ok(res.bytesSent >= res.packetsSent, "Rtp bytesSent");
|
||||
|
|
@ -1576,11 +1576,11 @@ PeerConnectionWrapper.prototype = {
|
|||
ok(res.bytesReceived >= res.packetsReceived, "Rtp bytesReceived");
|
||||
}
|
||||
if (res.remoteId) {
|
||||
var rem = stats[res.remoteId];
|
||||
var rem = stats.get(res.remoteId);
|
||||
ok(rem.isRemote, "Remote is rtcp");
|
||||
ok(rem.remoteId == res.id, "Remote backlink match");
|
||||
if(res.type == "outboundrtp") {
|
||||
ok(rem.type == "inboundrtp", "Rtcp is inbound");
|
||||
if(res.type == "outbound-rtp") {
|
||||
ok(rem.type == "inbound-rtp", "Rtcp is inbound");
|
||||
ok(rem.packetsReceived !== undefined, "Rtcp packetsReceived");
|
||||
ok(rem.packetsLost !== undefined, "Rtcp packetsLost");
|
||||
ok(rem.bytesReceived >= rem.packetsReceived, "Rtcp bytesReceived");
|
||||
|
|
@ -1593,7 +1593,7 @@ PeerConnectionWrapper.prototype = {
|
|||
ok(rem.mozRtt >= 0, "Rtcp rtt " + rem.mozRtt + " >= 0");
|
||||
ok(rem.mozRtt < 60000, "Rtcp rtt " + rem.mozRtt + " < 1 min");
|
||||
} else {
|
||||
ok(rem.type == "outboundrtp", "Rtcp is outbound");
|
||||
ok(rem.type == "outbound-rtp", "Rtcp is outbound");
|
||||
ok(rem.packetsSent !== undefined, "Rtcp packetsSent");
|
||||
// We may have received more than outdated Rtcp packetsSent
|
||||
ok(rem.bytesSent >= rem.packetsSent, "Rtcp bytesSent");
|
||||
|
|
@ -1607,6 +1607,13 @@ PeerConnectionWrapper.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
var legacyToSpecMapping = {
|
||||
'inboundrtp':'inbound-rtp',
|
||||
'outboundrtp':'outbound-rtp',
|
||||
'candidatepair':'candidate-pair',
|
||||
'localcandidate':'local-candidate',
|
||||
'remotecandidate':'remote-candidate'
|
||||
};
|
||||
// Use legacy way of enumerating stats
|
||||
var counters2 = {};
|
||||
for (let key in stats) {
|
||||
|
|
@ -1614,8 +1621,9 @@ PeerConnectionWrapper.prototype = {
|
|||
continue;
|
||||
}
|
||||
var res = stats[key];
|
||||
var type = legacyToSpecMapping[res.type] || res.type;
|
||||
if (!res.isRemote) {
|
||||
counters2[res.type] = (counters2[res.type] || 0) + 1;
|
||||
counters2[type] = (counters2[type] || 0) + 1;
|
||||
}
|
||||
}
|
||||
is(JSON.stringify(counters), JSON.stringify(counters2),
|
||||
|
|
@ -1624,21 +1632,21 @@ PeerConnectionWrapper.prototype = {
|
|||
var nout = Object.keys(this.expectedLocalTrackInfoById).length;
|
||||
var ndata = this.dataChannels.length;
|
||||
|
||||
// TODO(Bug 957145): Restore stronger inboundrtp test once Bug 948249 is fixed
|
||||
//is((counters["inboundrtp"] || 0), nin, "Have " + nin + " inboundrtp stat(s)");
|
||||
ok((counters.inboundrtp || 0) >= nin, "Have at least " + nin + " inboundrtp stat(s) *");
|
||||
// TODO(Bug 957145): Restore stronger inbound-rtp test once Bug 948249 is fixed
|
||||
//is((counters["inbound-rtp"] || 0), nin, "Have " + nin + " inbound-rtp stat(s)");
|
||||
ok((counters["inbound-rtp"] || 0) >= nin, "Have at least " + nin + " inbound-rtp stat(s) *");
|
||||
|
||||
is(counters.outboundrtp || 0, nout, "Have " + nout + " outboundrtp stat(s)");
|
||||
is(counters["outbound-rtp"] || 0, nout, "Have " + nout + " outbound-rtp stat(s)");
|
||||
|
||||
var numLocalCandidates = counters.localcandidate || 0;
|
||||
var numRemoteCandidates = counters.remotecandidate || 0;
|
||||
var numLocalCandidates = counters["local-candidate"] || 0;
|
||||
var numRemoteCandidates = counters["remote-candidate"] || 0;
|
||||
// If there are no tracks, there will be no stats either.
|
||||
if (nin + nout + ndata > 0) {
|
||||
ok(numLocalCandidates, "Have localcandidate stat(s)");
|
||||
ok(numRemoteCandidates, "Have remotecandidate stat(s)");
|
||||
ok(numLocalCandidates, "Have local-candidate stat(s)");
|
||||
ok(numRemoteCandidates, "Have remote-candidate stat(s)");
|
||||
} else {
|
||||
is(numLocalCandidates, 0, "Have no localcandidate stats");
|
||||
is(numRemoteCandidates, 0, "Have no remotecandidate stats");
|
||||
is(numLocalCandidates, 0, "Have no local-candidate stats");
|
||||
is(numRemoteCandidates, 0, "Have no remote-candidate stats");
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -1653,7 +1661,7 @@ PeerConnectionWrapper.prototype = {
|
|||
let lId;
|
||||
let rId;
|
||||
for (let stat of stats.values()) {
|
||||
if (stat.type == "candidatepair" && stat.selected) {
|
||||
if (stat.type == "candidate-pair" && stat.selected) {
|
||||
lId = stat.localCandidateId;
|
||||
rId = stat.remoteCandidateId;
|
||||
break;
|
||||
|
|
@ -1704,8 +1712,8 @@ PeerConnectionWrapper.prototype = {
|
|||
checkStatsIceConnections : function(stats,
|
||||
offerConstraintsList, offerOptions, testOptions) {
|
||||
var numIceConnections = 0;
|
||||
Object.keys(stats).forEach(key => {
|
||||
if ((stats[key].type === "candidatepair") && stats[key].selected) {
|
||||
stats.forEach(stat => {
|
||||
if ((stat.type === "candidate-pair") && stat.selected) {
|
||||
numIceConnections += 1;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -90,12 +90,12 @@ function checkTrackStats(pc, rtpSenderOrReceiver, outbound) {
|
|||
(audio ? "audio" : "video") + " rtp track id " + track.id;
|
||||
return pc.getStats(track).then(stats => {
|
||||
ok(pc.hasStat(stats, {
|
||||
type: outbound ? "outboundrtp" : "inboundrtp",
|
||||
type: outbound ? "outbound-rtp" : "inbound-rtp",
|
||||
isRemote: false,
|
||||
mediaType: audio ? "audio" : "video"
|
||||
}), msg + " - found expected stats");
|
||||
ok(!pc.hasStat(stats, {
|
||||
type: outbound ? "inboundrtp" : "outboundrtp",
|
||||
type: outbound ? "inbound-rtp" : "outbound-rtp",
|
||||
isRemote: false
|
||||
}), msg + " - did not find extra stats with wrong direction");
|
||||
ok(!pc.hasStat(stats, {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ template<>
|
|||
struct ParamTraits<mozilla::dom::RTCStatsType> :
|
||||
public ContiguousEnumSerializer<
|
||||
mozilla::dom::RTCStatsType,
|
||||
mozilla::dom::RTCStatsType::Inboundrtp,
|
||||
mozilla::dom::RTCStatsType::Inbound_rtp,
|
||||
mozilla::dom::RTCStatsType::EndGuard_>
|
||||
{};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@
|
|||
*/
|
||||
|
||||
enum RTCStatsType {
|
||||
"inboundrtp",
|
||||
"outboundrtp",
|
||||
"inbound-rtp",
|
||||
"outbound-rtp",
|
||||
"session",
|
||||
"track",
|
||||
"transport",
|
||||
"candidatepair",
|
||||
"localcandidate",
|
||||
"remotecandidate"
|
||||
"candidate-pair",
|
||||
"local-candidate",
|
||||
"remote-candidate"
|
||||
};
|
||||
|
||||
dictionary RTCStats {
|
||||
|
|
|
|||
|
|
@ -3602,7 +3602,7 @@ static void ToRTCIceCandidateStats(
|
|||
cand.mPortNumber.Construct(c->cand_addr.port);
|
||||
cand.mTransport.Construct(
|
||||
NS_ConvertASCIItoUTF16(c->cand_addr.transport.c_str()));
|
||||
if (candidateType == RTCStatsType::Localcandidate) {
|
||||
if (candidateType == RTCStatsType::Local_candidate) {
|
||||
cand.mMozLocalTransport.Construct(
|
||||
NS_ConvertASCIItoUTF16(c->local_addr.transport.c_str()));
|
||||
}
|
||||
|
|
@ -3636,7 +3636,7 @@ static void RecordIceStats_s(
|
|||
s.mId.Construct(codeword);
|
||||
s.mComponentId.Construct(componentId);
|
||||
s.mTimestamp.Construct(now);
|
||||
s.mType.Construct(RTCStatsType::Candidatepair);
|
||||
s.mType.Construct(RTCStatsType::Candidate_pair);
|
||||
s.mLocalCandidateId.Construct(localCodeword);
|
||||
s.mRemoteCandidateId.Construct(remoteCodeword);
|
||||
s.mNominated.Construct(p->nominated);
|
||||
|
|
@ -3649,7 +3649,7 @@ static void RecordIceStats_s(
|
|||
std::vector<NrIceCandidate> candidates;
|
||||
if (NS_SUCCEEDED(mediaStream.GetLocalCandidates(&candidates))) {
|
||||
ToRTCIceCandidateStats(candidates,
|
||||
RTCStatsType::Localcandidate,
|
||||
RTCStatsType::Local_candidate,
|
||||
componentId,
|
||||
now,
|
||||
report);
|
||||
|
|
@ -3658,7 +3658,7 @@ static void RecordIceStats_s(
|
|||
|
||||
if (NS_SUCCEEDED(mediaStream.GetRemoteCandidates(&candidates))) {
|
||||
ToRTCIceCandidateStats(candidates,
|
||||
RTCStatsType::Remotecandidate,
|
||||
RTCStatsType::Remote_candidate,
|
||||
componentId,
|
||||
now,
|
||||
report);
|
||||
|
|
@ -3710,7 +3710,7 @@ PeerConnectionImpl::ExecuteStatsQuery_s(RTCStatsQuery *query) {
|
|||
RTCInboundRTPStreamStats s;
|
||||
s.mTimestamp.Construct(timestamp);
|
||||
s.mId.Construct(remoteId);
|
||||
s.mType.Construct(RTCStatsType::Inboundrtp);
|
||||
s.mType.Construct(RTCStatsType::Inbound_rtp);
|
||||
if (ssrc.Length()) {
|
||||
s.mSsrc.Construct(ssrc);
|
||||
}
|
||||
|
|
@ -3731,7 +3731,7 @@ PeerConnectionImpl::ExecuteStatsQuery_s(RTCStatsQuery *query) {
|
|||
RTCOutboundRTPStreamStats s;
|
||||
s.mTimestamp.Construct(query->now);
|
||||
s.mId.Construct(localId);
|
||||
s.mType.Construct(RTCStatsType::Outboundrtp);
|
||||
s.mType.Construct(RTCStatsType::Outbound_rtp);
|
||||
if (ssrc.Length()) {
|
||||
s.mSsrc.Construct(ssrc);
|
||||
}
|
||||
|
|
@ -3784,7 +3784,7 @@ PeerConnectionImpl::ExecuteStatsQuery_s(RTCStatsQuery *query) {
|
|||
RTCOutboundRTPStreamStats s;
|
||||
s.mTimestamp.Construct(timestamp);
|
||||
s.mId.Construct(remoteId);
|
||||
s.mType.Construct(RTCStatsType::Outboundrtp);
|
||||
s.mType.Construct(RTCStatsType::Outbound_rtp);
|
||||
if (ssrc.Length()) {
|
||||
s.mSsrc.Construct(ssrc);
|
||||
}
|
||||
|
|
@ -3801,7 +3801,7 @@ PeerConnectionImpl::ExecuteStatsQuery_s(RTCStatsQuery *query) {
|
|||
RTCInboundRTPStreamStats s;
|
||||
s.mTimestamp.Construct(query->now);
|
||||
s.mId.Construct(localId);
|
||||
s.mType.Construct(RTCStatsType::Inboundrtp);
|
||||
s.mType.Construct(RTCStatsType::Inbound_rtp);
|
||||
if (ssrc.Length()) {
|
||||
s.mSsrc.Construct(ssrc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1066,7 +1066,7 @@ static void StoreLongTermICEStatisticsImpl_m(
|
|||
uint32_t candBitmask = GetCandidateIpAndTransportMask(&cand);
|
||||
|
||||
// Note: shift values need to result in the above enum table
|
||||
if (cand.mType.Value() == RTCStatsType::Localcandidate) {
|
||||
if (cand.mType.Value() == RTCStatsType::Local_candidate) {
|
||||
candBitmask <<= kLocalShift;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue