Bug 1481851 - Add kind to RTCRtpStreamStats as alias to mediaType. r=ng,smaug
authorPhilipp Hancke <fippo@appear.in>
Wed, 08 Aug 2018 17:30:40 +0200
changeset 487988 87b754ac0db00abdd8286253d28eca0150f9a769
parent 487987 0971297169a65b6bb7728acc926e277d34c34c04
child 487989 a77c322a5422ace5a0763f3beb45d93baa79536b
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersng, smaug
bugs1481851
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1481851 - Add kind to RTCRtpStreamStats as alias to mediaType. r=ng,smaug spec change in https://github.com/w3c/webrtc-stats/issues/301
dom/media/tests/mochitest/test_peerConnection_stats.html
dom/media/webrtc/WebrtcGlobal.h
dom/webidl/RTCStatsReport.webidl
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
--- a/dom/media/tests/mochitest/test_peerConnection_stats.html
+++ b/dom/media/tests/mochitest/test_peerConnection_stats.html
@@ -8,30 +8,30 @@
 <script type="application/javascript">
   createHTML({
     bug: "1337525",
     title: "webRtc Stats composition and sanity"
   });
 var statsExpectedByType = {
   "inbound-rtp": {
     expected: ["id", "timestamp", "type", "ssrc", "isRemote", "mediaType",
-      "packetsReceived", "packetsLost", "bytesReceived", "jitter",],
+      "kind", "packetsReceived", "packetsLost", "bytesReceived", "jitter",],
     optional: ["roundTripTime", "remoteId", "nackCount",],
     localVideoOnly: ["discardedPackets", "framerateStdDev", "framerateMean",
       "bitrateMean", "bitrateStdDev", "firCount", "pliCount", "framesDecoded",],
     unimplemented: ["mediaTrackId", "transportId", "codecId",
       "packetsDiscarded", "associateStatsId",
       "sliCount", "qpSum", "packetsRepaired", "fractionLost",
       "burstPacketsLost", "burstLossCount", "burstDiscardCount",
       "gapDiscardRate", "gapLossRate",],
     deprecated: ["mozRtt"],
   },
   "outbound-rtp": {
     expected: ["id", "timestamp", "type", "ssrc", "isRemote", "mediaType",
-      "packetsSent", "bytesSent", "remoteId",],
+      "kind", "packetsSent", "bytesSent", "remoteId",],
     optional: ["remoteId", "nackCount",],
     localVideoOnly: ["droppedFrames", "bitrateMean", "bitrateStdDev",
       "framerateMean", "framerateStdDev", "framesEncoded", "firCount",
       "pliCount",],
     unimplemented: ["mediaTrackId", "transportId", "codecId",
       "sliCount", "qpSum", "targetBitrate",],
     deprecated: [],
   },
@@ -143,20 +143,26 @@ var pedanticChecks = report => {
       //
 
       // SSRC
       ok(stat.ssrc, stat.type + ".ssrc has a value");
 
       // isRemote
       ok(stat.isRemote !== undefined, stat.type + ".isRemote exists.");
 
-      // mediaType
+      // kind
+      ok(["audio", "video"].includes(stat.kind),
+        stat.type + ".kind is 'audio' or 'video'");
+
+      // mediaType, renamed to kind but remains for backward compability.
       ok(["audio", "video"].includes(stat.mediaType),
         stat.type + ".mediaType is 'audio' or 'video'");
 
+      ok(stat.kind == stat.mediaType, "kind equals legacy mediaType");
+
       // remote id
       if (stat.remoteId) {
         ok(report.has(stat.remoteId), "remoteId exists in report.");
         is(report.get(stat.remoteId).ssrc, stat.ssrc,
           "remote ssrc and local ssrc match.");
         is(report.get(stat.remoteId).remoteId, stat.id,
           "remote object has local object as it's own remote object.");
       }
@@ -164,17 +170,17 @@ var pedanticChecks = report => {
       // nackCount
       if (!stat.inner.isRemote) {
         ok(stat.nackCount >= 0, stat.type + ".nackCount is sane.");
       } else {
         is(stat.nackCount, undefined, stat.type
           + ".nackCount is only set when isRemote is false");
       }
 
-      if (!stat.inner.isRemote && stat.inner.mediaType == "video") {
+      if (!stat.inner.isRemote && stat.inner.kind == "video") {
         // firCount
         ok(stat.firCount >= 0 && stat.firCount < 100,
           stat.type + ".firCount is a sane number for a short test. value="
           + stat.firCount);
 
         // pliCount
         ok(stat.pliCount >= 0 && stat.pliCount < 100,
           stat.type + ".pliCount is a sane number for a short test. value="
@@ -200,17 +206,17 @@ var pedanticChecks = report => {
         + stat.bytesReceived);
 
       // packetsLost
       ok(stat.packetsLost < 100,
         stat.type + ".packetsLost is a sane number for a short test. value="
         + stat.packetsLost);
 
       // This should be much lower for audio, TODO: Bug 1330575
-      let expectedJitter = stat.mediaType == "video" ? 0.5 : 1;
+      let expectedJitter = stat.kind == "video" ? 0.5 : 1;
       // jitter
       ok(stat.jitter < expectedJitter,
         stat.type + ".jitter is sane number for a local only test. value="
         + stat.jitter);
 
       // packetsDiscarded
       // special exception for, TODO: Bug 1335967
       // if (!stat.inner.isRemote && stat.discardedPackets !== undefined) {
@@ -235,30 +241,30 @@ var pedanticChecks = report => {
       } else {
         is(stat.roundTripTime, undefined, stat.type
           + ".roundTripTime is only set when isRemote is true");
       }
 
       //
       // Local video only stats
       //
-      if (stat.inner.isRemote || stat.inner.mediaType != "video") {
+      if (stat.inner.isRemote || stat.inner.kind != "video") {
         expectations.localVideoOnly.forEach(field => {
           if (stat.inner.isRemote) {
             ok(stat[field] === undefined, stat.type + " does not have field "
               + field + " when isRemote is true");
-          } else { // mediaType != video
+          } else { // kind != video
             ok(stat[field] === undefined, stat.type + " does not have field "
-              + field + " when mediaType is not 'video'");
+              + field + " when kind is not 'video'");
           }
         });
       } else {
         expectations.localVideoOnly.forEach(field => {
           ok(stat.inner[field] !== undefined, stat.type + " has field " + field
-            + " when mediaType is video");
+            + " when kind is video");
         });
         // discardedPackets
         ok(stat.discardedPackets < 100, stat.type
           + ".discardedPackets is a sane number for a short test. value="
           + stat.discardedPackets);
         // framesDecoded
         ok(stat.framesDecoded > 0 && stat.framesDecoded < 1000000, stat.type
           + ".framesDecoded is a sane number for a short test. value="
@@ -316,30 +322,30 @@ var pedanticChecks = report => {
 
       //
       // Optional fields
       //
 
       //
       // Local video only stats
       //
-      if (stat.inner.isRemote || stat.inner.mediaType != "video") {
+      if (stat.inner.isRemote || stat.inner.kind != "video") {
         expectations.localVideoOnly.forEach(field => {
           if (stat.inner.isRemote) {
             ok(stat[field] === undefined, stat.type + " does not have field "
               + field + " when isRemote is true");
-          } else { // mediaType != video
+          } else { // kind != video
             ok(stat[field] === undefined, stat.type + " does not have field "
-              + field + " when mediaType is not 'video'");
+              + field + " when kind is not 'video'");
           }
         });
       } else {
         expectations.localVideoOnly.forEach(field => {
           ok(stat.inner[field] !== undefined, stat.type + " has field " + field
-            + " when mediaType is video and isRemote is false");
+            + " when kind is video and isRemote is false");
         });
 
         // bitrateMean
         if (stat.bitrateMean !== undefined) {
           // TODO: uncomment when Bug 1341533 lands
           // ok(stat.bitrateMean >= 0 && stat.bitrateMean < 2 ** 25,
           //   stat.type + ".bitrateMean is sane. value="
           //   + stat.bitrateMean);
--- a/dom/media/webrtc/WebrtcGlobal.h
+++ b/dom/media/webrtc/WebrtcGlobal.h
@@ -287,16 +287,17 @@ static void WriteRTCRtpStreamStats(
     WriteParam(aMsg, aParam.mBitrateMean);
     WriteParam(aMsg, aParam.mBitrateStdDev);
     WriteParam(aMsg, aParam.mCodecId);
     WriteParam(aMsg, aParam.mFramerateMean);
     WriteParam(aMsg, aParam.mFramerateStdDev);
     WriteParam(aMsg, aParam.mIsRemote);
     WriteParam(aMsg, aParam.mMediaTrackId);
     WriteParam(aMsg, aParam.mMediaType);
+    WriteParam(aMsg, aParam.mKind);
     WriteParam(aMsg, aParam.mRemoteId);
     WriteParam(aMsg, aParam.mSsrc);
     WriteParam(aMsg, aParam.mTransportId);
 }
 
 static bool ReadRTCRtpStreamStats(
               const Message* aMsg, PickleIterator* aIter,
               mozilla::dom::RTCRtpStreamStats* aResult)
@@ -304,16 +305,17 @@ static bool ReadRTCRtpStreamStats(
   if (!ReadParam(aMsg, aIter, &(aResult->mBitrateMean)) ||
       !ReadParam(aMsg, aIter, &(aResult->mBitrateStdDev)) ||
       !ReadParam(aMsg, aIter, &(aResult->mCodecId)) ||
       !ReadParam(aMsg, aIter, &(aResult->mFramerateMean)) ||
       !ReadParam(aMsg, aIter, &(aResult->mFramerateStdDev)) ||
       !ReadParam(aMsg, aIter, &(aResult->mIsRemote)) ||
       !ReadParam(aMsg, aIter, &(aResult->mMediaTrackId)) ||
       !ReadParam(aMsg, aIter, &(aResult->mMediaType)) ||
+      !ReadParam(aMsg, aIter, &(aResult->mKind)) ||
       !ReadParam(aMsg, aIter, &(aResult->mRemoteId)) ||
       !ReadParam(aMsg, aIter, &(aResult->mSsrc)) ||
       !ReadParam(aMsg, aIter, &(aResult->mTransportId))) {
     return false;
   }
 
   return true;
 }
--- a/dom/webidl/RTCStatsReport.webidl
+++ b/dom/webidl/RTCStatsReport.webidl
@@ -24,16 +24,17 @@ dictionary RTCStats {
   DOMHighResTimeStamp timestamp;
   RTCStatsType type;
   DOMString id;
 };
 
 dictionary RTCRtpStreamStats : RTCStats {
   unsigned long ssrc;
   DOMString mediaType;
+  DOMString kind;
   DOMString remoteId;
   boolean isRemote = false;
   DOMString mediaTrackId;
   DOMString transportId;
   DOMString codecId;
 
   // Video encoder/decoder measurements, not present in RTCP case
   double bitrateMean;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -3428,19 +3428,19 @@ PeerConnectionImpl::ExecuteStatsQuery_s(
     MOZ_ASSERT(query->pipelines[p]);
     MOZ_ASSERT(query->pipelines[p]->Conduit());
     if (!query->pipelines[p] || !query->pipelines[p]->Conduit()) {
       // continue if we don't have a valid conduit
       continue;
     }
     const MediaPipeline& mp = *query->pipelines[p];
     bool isAudio = (mp.Conduit()->type() == MediaSessionConduit::AUDIO);
-    nsString mediaType = isAudio ?
+    nsString kind = isAudio ?
         NS_LITERAL_STRING("audio") : NS_LITERAL_STRING("video");
-    nsString idstr = mediaType;
+    nsString idstr = kind;
     idstr.AppendLiteral("_");
     idstr.AppendInt((uint32_t)p);
 
     // TODO(@@NG):ssrcs handle Conduits having multiple stats at the same level
     // This is pending spec work
     // Gather pipeline stats.
     switch (mp.Direction()) {
       case MediaPipeline::DirectionType::TRANSMIT: {
@@ -3467,17 +3467,18 @@ PeerConnectionImpl::ExecuteStatsQuery_s(
                                                   &packetsLost,
                                                   &rtt)) {
             remoteId = NS_LITERAL_STRING("outbound_rtcp_") + idstr;
             RTCInboundRTPStreamStats s;
             s.mTimestamp.Construct(timestamp);
             s.mId.Construct(remoteId);
             s.mType.Construct(RTCStatsType::Inbound_rtp);
             ssrc.apply([&s](uint32_t aSsrc){s.mSsrc.Construct(aSsrc);});
-            s.mMediaType.Construct(mediaType);
+            s.mMediaType.Construct(kind); // mediaType is the old name for kind.
+            s.mKind.Construct(kind);
             s.mJitter.Construct(double(jitterMs)/1000);
             s.mRemoteId.Construct(localId);
             s.mIsRemote = true;
             s.mPacketsReceived.Construct(packetsReceived);
             s.mBytesReceived.Construct(bytesReceived);
             s.mPacketsLost.Construct(packetsLost);
             if (rtt > 0) {
               s.mRoundTripTime.Construct(rtt);
@@ -3488,17 +3489,18 @@ PeerConnectionImpl::ExecuteStatsQuery_s(
         }
         // Then, fill in local side (with cross-link to remote only if present)
         {
           RTCOutboundRTPStreamStats s;
           s.mTimestamp.Construct(query->now);
           s.mId.Construct(localId);
           s.mType.Construct(RTCStatsType::Outbound_rtp);
           ssrc.apply([&s](uint32_t aSsrc){s.mSsrc.Construct(aSsrc);});
-          s.mMediaType.Construct(mediaType);
+          s.mMediaType.Construct(kind); // mediaType is the old name for kind.
+          s.mKind.Construct(kind);
           s.mRemoteId.Construct(remoteId);
           s.mIsRemote = false;
           s.mPacketsSent.Construct(mp.RtpPacketsSent());
           s.mBytesSent.Construct(mp.RtpBytesSent());
 
           // Fill in packet type statistics
           webrtc::RtcpPacketTypeCounter counters;
           if (mp.Conduit()->GetSendPacketTypeStats(&counters)) {
@@ -3553,32 +3555,34 @@ PeerConnectionImpl::ExecuteStatsQuery_s(
           if (mp.Conduit()->GetRTCPSenderReport(&timestamp,
                                                 &packetsSent, &bytesSent)) {
             remoteId = NS_LITERAL_STRING("inbound_rtcp_") + idstr;
             RTCOutboundRTPStreamStats s;
             s.mTimestamp.Construct(timestamp);
             s.mId.Construct(remoteId);
             s.mType.Construct(RTCStatsType::Outbound_rtp);
             ssrc.apply([&s](uint32_t aSsrc){s.mSsrc.Construct(aSsrc);});
-            s.mMediaType.Construct(mediaType);
+            s.mMediaType.Construct(kind); // mediaType is the old name for kind.
+            s.mKind.Construct(kind);
             s.mRemoteId.Construct(localId);
             s.mIsRemote = true;
             s.mPacketsSent.Construct(packetsSent);
             s.mBytesSent.Construct(bytesSent);
             query->report->mOutboundRTPStreamStats.Value().AppendElement(s,
                                                                          fallible);
           }
         }
         // Then, fill in local side (with cross-link to remote only if present)
         RTCInboundRTPStreamStats s;
         s.mTimestamp.Construct(query->now);
         s.mId.Construct(localId);
         s.mType.Construct(RTCStatsType::Inbound_rtp);
         ssrc.apply([&s](uint32_t aSsrc){s.mSsrc.Construct(aSsrc);});
-        s.mMediaType.Construct(mediaType);
+        s.mMediaType.Construct(kind); // mediaType is the old name for kind.
+        s.mKind.Construct(kind);
         unsigned int jitterMs, packetsLost;
         if (mp.Conduit()->GetRTPStats(&jitterMs, &packetsLost)) {
           s.mJitter.Construct(double(jitterMs)/1000);
           s.mPacketsLost.Construct(packetsLost);
         }
         if (remoteId.Length()) {
           s.mRemoteId.Construct(remoteId);
         }