Add missed WebRTC media-source and remote-inbound-rtp stats
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jun 2020 18:10:01 +0000 (18:10 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jun 2020 18:10:01 +0000 (18:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=206645
<rdar://problem/58833958>

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

* Configurations/libwebrtc.iOS.exp:
* Configurations/libwebrtc.iOSsim.exp:
* Configurations/libwebrtc.mac.exp:

Source/WebCore:

Update stats according latest spec and webrtc backend.
We still expose obsolete trackId for consistency with existing WPT tests.
Covered by existing and updated tests.

* Modules/mediastream/RTCStatsReport.h:
(WebCore::RTCStatsReport::InboundRtpStreamStats::InboundRtpStreamStats):
(WebCore::RTCStatsReport::RemoteInboundRtpStreamStats::RemoteInboundRtpStreamStats):
(WebCore::RTCStatsReport::OutboundRtpStreamStats::OutboundRtpStreamStats):
(WebCore::RTCStatsReport::InboundRTPStreamStats::InboundRTPStreamStats): Deleted.
(WebCore::RTCStatsReport::OutboundRTPStreamStats::OutboundRTPStreamStats): Deleted.
* Modules/mediastream/RTCStatsReport.idl:
* Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
(WebCore::fillRtpStreamStats):
(WebCore::fillReceivedRtpStreamStats):
(WebCore::fillInboundRtpStreamStats):
(WebCore::fillRemoteInboundRtpStreamStats):
(WebCore::fillSentRtpStreamStats):
(WebCore::fillOutboundRtpStreamStats):
(WebCore::initializeRTCStatsReportBackingMap):
(WebCore::fillRTCRTPStreamStats): Deleted.
(WebCore::fillInboundRTPStreamStats): Deleted.
(WebCore::fillOutboundRTPStreamStats): Deleted.

LayoutTests:

* webrtc/video-stats.html:
qpSum is no longer guaranteed to be there.
Also, we loop over stats to ensure we get all of them.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262726 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webrtc/video-stats.html
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCStatsReport.h
Source/WebCore/Modules/mediastream/RTCStatsReport.idl
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp

index 30f5b2e..d07415f 100644 (file)
@@ -1,3 +1,15 @@
+2020-06-08  Youenn Fablet  <youenn@apple.com>
+
+        Add missed WebRTC media-source and remote-inbound-rtp stats
+        https://bugs.webkit.org/show_bug.cgi?id=206645
+        <rdar://problem/58833958>
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-stats.html:
+        qpSum is no longer guaranteed to be there.
+        Also, we loop over stats to ensure we get all of them.
+
 2020-06-08  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] Add support for min/max-width/height
index ccafd76..72b3647 100644 (file)
@@ -152,25 +152,36 @@ promise_test(async (test) => {
     let stats = await getOutboundRTPStats(firstConnection);
     assert_true(!!stats, "outbound-rtp stats should not be null");
     assert_true(Number.isInteger(stats.framesEncoded), "framesEncoded should be an integer");
-    assert_true(Number.isInteger(stats.qpSum), "outbound qpSum should be an integer");
+    assert_true(!stats.qpSum || Number.isInteger(stats.qpSum), "outbound qpSum should be an integer");
     assert_true(typeof stats.timestamp === "number", "timestamp should be a double");
     statsFirstConnection = stats;
 
     stats = await getInboundRTPStats(secondConnection);
     assert_true(!!stats, "inbound-rtp stats should not be null");
     assert_true(Number.isInteger(stats.framesDecoded), "framesDecoded should be an integer");
-    assert_true(Number.isInteger(stats.qpSum), "inbound qpSum should be an integer");
+    assert_true(!stats.qpSum || Number.isInteger(stats.qpSum), "inbound qpSum should be an integer");
     assert_true(typeof stats.timestamp === "number", "timestamp should be a double");
     statsSecondConnection = stats;
 
     await checkInboundFramesNumberIncreased(secondConnection, statsSecondConnection, 0);
     await checkOutboundFramesNumberIncreased(firstConnection, statsFirstConnection, 0);
 
-    let types = await getStatsType(firstConnection);
-    assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "local-candidate", "media-source", "outbound-rtp", "peer-connection", "remote-candidate", "track", "transport"]);
+    let types;
+    do {
+        types = await getStatsType(firstConnection);
+        if (types.length != 12)
+            types = undefined;
+    } while(!types);
 
-    types = await getStatsType(secondConnection);
-    assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "local-candidate", "media-source", "outbound-rtp", "peer-connection", "remote-candidate", "track", "transport"]);
+    assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "local-candidate", "media-source", "outbound-rtp", "peer-connection", "remote-candidate", "remote-inbound-rtp", "track", "transport"], "first connection");
+
+    do {
+        types = await getStatsType(secondConnection);
+        if (types.length != 12)
+            types = undefined;
+    } while(!types);
+
+    assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "local-candidate", "media-source", "outbound-rtp", "peer-connection", "remote-candidate", "remote-inbound-rtp", "track", "transport"], "second connection");
 
      const audioSourceStats = await getAudioSourceStats(firstConnection);
      assert_true(!!audioSourceStats, "audio source presence");
index dac389f..a375d9c 100644 (file)
@@ -1,3 +1,15 @@
+2020-06-08  Youenn Fablet  <youenn@apple.com>
+
+        Add missed WebRTC media-source and remote-inbound-rtp stats
+        https://bugs.webkit.org/show_bug.cgi?id=206645
+        <rdar://problem/58833958>
+
+        Reviewed by Eric Carlson.
+
+        * Configurations/libwebrtc.iOS.exp:
+        * Configurations/libwebrtc.iOSsim.exp:
+        * Configurations/libwebrtc.mac.exp:
+
 2020-06-05  Youenn Fablet  <youenn@apple.com>
 
         Ad support for media-source stats
index b8005a6..c51700e 100644 (file)
@@ -35,6 +35,7 @@ __ZN6webrtc24RTCMediaStreamTrackStats5kTypeE
 __ZN6webrtc25RTCOutboundRTPStreamStats5kTypeE
 __ZN6webrtc19RTCAudioSourceStats5kTypeE
 __ZN6webrtc19RTCVideoSourceStats5kTypeE
+__ZN6webrtc30RTCRemoteInboundRtpStreamStats5kTypeE
 __ZN6webrtc27SessionDescriptionInterface6kOfferE
 __ZN6webrtc27SessionDescriptionInterface7kAnswerE
 __ZN6webrtc27SessionDescriptionInterface9kPrAnswerE
index b8005a6..c51700e 100644 (file)
@@ -35,6 +35,7 @@ __ZN6webrtc24RTCMediaStreamTrackStats5kTypeE
 __ZN6webrtc25RTCOutboundRTPStreamStats5kTypeE
 __ZN6webrtc19RTCAudioSourceStats5kTypeE
 __ZN6webrtc19RTCVideoSourceStats5kTypeE
+__ZN6webrtc30RTCRemoteInboundRtpStreamStats5kTypeE
 __ZN6webrtc27SessionDescriptionInterface6kOfferE
 __ZN6webrtc27SessionDescriptionInterface7kAnswerE
 __ZN6webrtc27SessionDescriptionInterface9kPrAnswerE
index 74d81b3..a47d962 100644 (file)
@@ -35,6 +35,7 @@ __ZN6webrtc24RTCMediaStreamTrackStats5kTypeE
 __ZN6webrtc25RTCOutboundRTPStreamStats5kTypeE
 __ZN6webrtc19RTCAudioSourceStats5kTypeE
 __ZN6webrtc19RTCVideoSourceStats5kTypeE
+__ZN6webrtc30RTCRemoteInboundRtpStreamStats5kTypeE
 __ZN6webrtc27SessionDescriptionInterface6kOfferE
 __ZN6webrtc27SessionDescriptionInterface7kAnswerE
 __ZN6webrtc27SessionDescriptionInterface9kPrAnswerE
index f4fed72..1044c1b 100644 (file)
@@ -1,3 +1,34 @@
+2020-06-08  Youenn Fablet  <youenn@apple.com>
+
+        Add missed WebRTC media-source and remote-inbound-rtp stats
+        https://bugs.webkit.org/show_bug.cgi?id=206645
+        <rdar://problem/58833958>
+
+        Reviewed by Eric Carlson.
+
+        Update stats according latest spec and webrtc backend.
+        We still expose obsolete trackId for consistency with existing WPT tests.
+        Covered by existing and updated tests.
+
+        * Modules/mediastream/RTCStatsReport.h:
+        (WebCore::RTCStatsReport::InboundRtpStreamStats::InboundRtpStreamStats):
+        (WebCore::RTCStatsReport::RemoteInboundRtpStreamStats::RemoteInboundRtpStreamStats):
+        (WebCore::RTCStatsReport::OutboundRtpStreamStats::OutboundRtpStreamStats):
+        (WebCore::RTCStatsReport::InboundRTPStreamStats::InboundRTPStreamStats): Deleted.
+        (WebCore::RTCStatsReport::OutboundRTPStreamStats::OutboundRTPStreamStats): Deleted.
+        * Modules/mediastream/RTCStatsReport.idl:
+        * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+        (WebCore::fillRtpStreamStats):
+        (WebCore::fillReceivedRtpStreamStats):
+        (WebCore::fillInboundRtpStreamStats):
+        (WebCore::fillRemoteInboundRtpStreamStats):
+        (WebCore::fillSentRtpStreamStats):
+        (WebCore::fillOutboundRtpStreamStats):
+        (WebCore::initializeRTCStatsReportBackingMap):
+        (WebCore::fillRTCRTPStreamStats): Deleted.
+        (WebCore::fillInboundRTPStreamStats): Deleted.
+        (WebCore::fillOutboundRTPStreamStats): Deleted.
+
 2020-06-08  Jonathan Bedard  <jbedard@apple.com>
 
         WebCore: Add tvOS and watchOS SPI headers
index ba76094..561a480 100644 (file)
@@ -49,6 +49,7 @@ public:
         OutboundRtp,
         PeerConnection,
         RemoteCandidate,
+        RemoteInboundRtp,
         Track,
         Transport
     };
@@ -58,50 +59,141 @@ public:
         String id;
     };
 
-    struct RTCRTPStreamStats : Stats {
-        Optional<uint32_t> ssrc;
-        bool isRemote { false };
+    struct RtpStreamStats : Stats {
+        uint32_t ssrc { 0 };
+        String kind;
         String mediaType;
-
-        String trackId;
         String transportId;
         String codecId;
-        Optional<uint32_t> firCount;
-        Optional<uint32_t> pliCount;
-        Optional<uint32_t> nackCount;
-        Optional<uint32_t> sliCount;
-        Optional<uint64_t> qpSum;
     };
 
-    struct InboundRTPStreamStats : RTCRTPStreamStats {
-        InboundRTPStreamStats() { type = RTCStatsReport::Type::InboundRtp; }
-
-        Optional<uint32_t> packetsReceived;
-        Optional<uint64_t> bytesReceived;
-        Optional<uint32_t> packetsLost;
+    struct ReceivedRtpStreamStats : RtpStreamStats {
+        Optional<uint64_t> packetsReceived;
+        Optional<int64_t> packetsLost;
         Optional<double> jitter;
-        Optional<double> fractionLost;
-        Optional<uint32_t> packetsDiscarded;
-        Optional<uint32_t> packetsRepaired;
-        Optional<uint32_t> burstPacketsLost;
-        Optional<uint32_t> burstPacketsDiscarded;
+        Optional<uint64_t> packetsDiscarded;
+        Optional<uint64_t> packetsRepaired;
+        Optional<uint64_t> burstPacketsLost;
+        Optional<uint64_t> burstPacketsDiscarded;
         Optional<uint32_t> burstLossCount;
         Optional<uint32_t> burstDiscardCount;
         Optional<double> burstLossRate;
         Optional<double> burstDiscardRate;
         Optional<double> gapLossRate;
         Optional<double> gapDiscardRate;
+        Optional<uint32_t> framesDropped;
+        Optional<uint32_t> partialFramesLost;
+        Optional<uint32_t> fullFramesLost;
+    };
+
+    struct InboundRtpStreamStats : ReceivedRtpStreamStats {
+        InboundRtpStreamStats() { type = RTCStatsReport::Type::InboundRtp; }
+
+        String receiverId;
+        String remoteId;
         Optional<uint32_t> framesDecoded;
+        Optional<uint32_t> keyFramesDecoded;
+        Optional<uint32_t> frameWidth;
+        Optional<uint32_t> frameHeight;
+        Optional<uint32_t> frameBitDepth;
+        Optional<double> framesPerSecond;
+        Optional<uint64_t> qpSum;
+        Optional<double> totalDecodeTime;
+        Optional<double> totalInterFrameDelay;
+        Optional<double> totalSquaredInterFrameDelay;
+        Optional<bool>  voiceActivityFlag;
+        Optional<double> lastPacketReceivedTimestamp;
+        Optional<double> averageRtcpInterval;
+        Optional<uint64_t> headerBytesReceived;
+        Optional<uint64_t> fecPacketsReceived;
+        Optional<uint64_t> fecPacketsDiscarded;
+        Optional<uint64_t> bytesReceived;
+        Optional<uint64_t> packetsFailedDecryption;
+        Optional<uint64_t> packetsDuplicated;
+        Optional<uint32_t> nackCount;
+        Optional<uint32_t> firCount;
+        Optional<uint32_t> pliCount;
+        Optional<uint32_t> sliCount;
+        Optional<double> estimatedPlayoutTimestamp;
+        Optional<double> jitterBufferDelay;
+        Optional<uint64_t> jitterBufferEmittedCount;
+        Optional<uint64_t> totalSamplesReceived;
+        Optional<uint64_t> samplesDecodedWithSilk;
+        Optional<uint64_t> samplesDecodedWithCelt;
+        Optional<uint64_t> concealedSamples;
+        Optional<uint64_t> silentConcealedSamples;
+        Optional<uint64_t> concealmentEvents;
+        Optional<uint64_t> insertedSamplesForDeceleration;
+        Optional<uint64_t> removedSamplesForAcceleration;
+        Optional<double> audioLevel;
+        Optional<double> totalAudioEnergy;
+        Optional<double> totalSamplesDuration;
+        Optional<uint32_t> framesReceived;
+
+        String trackId;
     };
 
-    struct OutboundRTPStreamStats : RTCRTPStreamStats {
-        OutboundRTPStreamStats() { type = RTCStatsReport::Type::OutboundRtp; }
+    struct RemoteInboundRtpStreamStats : ReceivedRtpStreamStats {
+        RemoteInboundRtpStreamStats() { type = RTCStatsReport::Type::RemoteInboundRtp; }
 
+        String localId;
+        Optional<double> roundTripTime;
+        Optional<double> totalRoundTripTime;
+        Optional<double> fractionLost;
+        Optional<uint64_t> reportsReceived;
+        Optional<uint64_t> roundTripTimeMeasurements;
+    };
+
+    struct SentRtpStreamStats : RtpStreamStats {
         Optional<uint32_t> packetsSent;
         Optional<uint64_t> bytesSent;
+    };
+
+    struct OutboundRtpStreamStats : SentRtpStreamStats {
+        OutboundRtpStreamStats() { type = RTCStatsReport::Type::OutboundRtp; }
+
+        Optional<uint32_t> rtxSsrc;
+        String mediaSourceId;
+        String senderId;
+        String remoteId;
+        String rid;
+        Optional<double> lastPacketSentTimestamp;
+        Optional<uint64_t> headerBytesSent;
+        Optional<uint32_t> packetsDiscardedOnSend;
+        Optional<uint64_t> bytesDiscardedOnSend;
+        Optional<uint32_t> fecPacketsSent;
+        Optional<uint64_t> retransmittedPacketsSent;
+        Optional<uint64_t> retransmittedBytesSent;
         Optional<double> targetBitrate;
+        Optional<uint64_t> totalEncodedBytesTarget;
+        Optional<uint32_t> frameWidth;
+        Optional<uint32_t> frameHeight;
+        Optional<uint32_t> frameBitDepth;
+        Optional<double> framesPerSecond;
+        Optional<uint32_t> framesSent;
+        Optional<uint32_t> hugeFramesSent;
         Optional<uint32_t> framesEncoded;
-        String mediaSourceId;
+        Optional<uint32_t> keyFramesEncoded;
+        Optional<uint32_t> framesDiscardedOnSend;
+        Optional<uint64_t> qpSum;
+        Optional<uint64_t> totalSamplesSent;
+        Optional<uint64_t> samplesEncodedWithSilk;
+        Optional<uint64_t> samplesEncodedWithCelt;
+        Optional<bool> voiceActivityFlag;
+        Optional<double> totalEncodeTime;
+        Optional<double> totalPacketSendDelay;
+        Optional<double> averageRtcpInterval;
+        // Optional<RTCQualityLimitationReason qualityLimitationReason;
+        // Optional<record<DOMString, double> qualityLimitationDurations;
+        Optional<uint32_t> qualityLimitationResolutionChanges;
+        // Optional<record<USVString, unsigned long long> perDscpPacketsSent;
+        Optional<uint32_t> nackCount;
+        Optional<uint32_t> firCount;
+        Optional<uint32_t> pliCount;
+        Optional<uint32_t> sliCount;
+        // DOMString encoderImplementation;
+
+        String trackId;
     };
 
     struct MediaStreamTrackStats : Stats {
index d0e46e7..f2a13c0 100644 (file)
@@ -42,6 +42,7 @@ enum RTCStatsType {
     "outbound-rtp",
     "peer-connection",
     "remote-candidate",
+    "remote-inbound-rtp",
     "track",
     "transport"
 };
@@ -55,48 +56,146 @@ dictionary RTCStats {
 
 };
 
-dictionary RTCRTPStreamStats : RTCStats {
-    unsigned long ssrc;
-    boolean isRemote = false;
-    DOMString mediaType;
-    DOMString trackId;
+[ JSGenerateToJSObject ]
+dictionary RTCRtpStreamStats : RTCStats {
+    required unsigned long ssrc;
+    required DOMString kind;
+    // We should obsolete this field
+    required DOMString mediaType;
     DOMString transportId;
     DOMString codecId;
-    unsigned long firCount;
-    unsigned long pliCount;
-    unsigned long nackCount;
-    unsigned long sliCount;
-    unsigned long long qpSum;
 };
 
 [ JSGenerateToJSObject ]
-dictionary RTCInboundRTPStreamStats : RTCRTPStreamStats {
-    unsigned long packetsReceived;
-    unsigned long long bytesReceived;
-    unsigned long packetsLost;
+dictionary RTCReceivedRtpStreamStats : RTCRtpStreamStats {
+    unsigned long long packetsReceived;
+    long long packetsLost;
     double jitter;
-    double fractionLost;
-    unsigned long packetsDiscarded;
-    unsigned long packetsRepaired;
-    unsigned long burstPacketsLost;
-    unsigned long burstPacketsDiscarded;
+    unsigned long long packetsDiscarded;
+    unsigned long long packetsRepaired;
+    unsigned long long burstPacketsLost;
+    unsigned long long burstPacketsDiscarded;
     unsigned long burstLossCount;
     unsigned long burstDiscardCount;
     double burstLossRate;
     double burstDiscardRate;
     double gapLossRate;
     double gapDiscardRate;
+    unsigned long framesDropped;
+    unsigned long partialFramesLost;
+    unsigned long fullFramesLost;
+};
+
+[ JSGenerateToJSObject ]
+dictionary RTCInboundRtpStreamStats : RTCReceivedRtpStreamStats {
+    // required DOMString receiverId;
+    DOMString remoteId;
     unsigned long framesDecoded;
+    unsigned long keyFramesDecoded;
+    unsigned long frameWidth;
+    unsigned long frameHeight;
+    unsigned long frameBitDepth;
+    double framesPerSecond;
+    unsigned long long qpSum;
+    double totalDecodeTime;
+    double totalInterFrameDelay;
+    double totalSquaredInterFrameDelay;
+    boolean voiceActivityFlag;
+    DOMHighResTimeStamp lastPacketReceivedTimestamp;
+    double averageRtcpInterval;
+    unsigned long long headerBytesReceived;
+    unsigned long long fecPacketsReceived;
+    unsigned long long fecPacketsDiscarded;
+    unsigned long long bytesReceived;
+    unsigned long long packetsFailedDecryption;
+    unsigned long long packetsDuplicated;
+    // record<USVString, unsigned long long> perDscpPacketsReceived;
+    unsigned long nackCount;
+    unsigned long firCount;
+    unsigned long pliCount;
+    unsigned long sliCount;
+    DOMHighResTimeStamp estimatedPlayoutTimestamp;
+    double jitterBufferDelay;
+    unsigned long long jitterBufferEmittedCount;
+    unsigned long long totalSamplesReceived;
+    unsigned long long samplesDecodedWithSilk;
+    unsigned long long samplesDecodedWithCelt;
+    unsigned long long concealedSamples;
+    unsigned long long silentConcealedSamples;
+    unsigned long long concealmentEvents;
+    unsigned long long insertedSamplesForDeceleration;
+    unsigned long long removedSamplesForAcceleration;
+    double audioLevel;
+    double totalAudioEnergy;
+    double totalSamplesDuration;
+    unsigned long framesReceived;
+    // DOMString decoderImplementation;
+
+    // To be removed as obsolete.
+    DOMString trackId;
 };
 
 [ JSGenerateToJSObject ]
-dictionary RTCOutboundRTPStreamStats : RTCRTPStreamStats {
+dictionary RTCRemoteInboundRtpStreamStats : RTCReceivedRtpStreamStats {
+    DOMString localId;
+    double roundTripTime;
+    double totalRoundTripTime;
+    double fractionLost;
+    unsigned long long reportsReceived;
+    unsigned long long roundTripTimeMeasurements;
+};
+
+[ JSGenerateToJSObject ]
+dictionary RTCSentRtpStreamStats : RTCRtpStreamStats {
     unsigned long packetsSent;
     unsigned long long bytesSent;
+};
+
+[ JSGenerateToJSObject ]
+dictionary RTCOutboundRtpStreamStats : RTCSentRtpStreamStats {
+    unsigned long rtxSsrc;
+    DOMString mediaSourceId;
+    DOMString senderId;
+    DOMString remoteId;
+    DOMString rid;
+    DOMHighResTimeStamp lastPacketSentTimestamp;
+    unsigned long long headerBytesSent;
+    unsigned long packetsDiscardedOnSend;
+    unsigned long long bytesDiscardedOnSend;
+    unsigned long fecPacketsSent;
+    unsigned long long retransmittedPacketsSent;
+    unsigned long long retransmittedBytesSent;
     double targetBitrate;
-    // FIXME 169662: missing roundTripTime
+    unsigned long long totalEncodedBytesTarget;
+    unsigned long frameWidth;
+    unsigned long frameHeight;
+    unsigned long frameBitDepth;
+    double framesPerSecond;
+    unsigned long framesSent;
+    unsigned long hugeFramesSent;
     unsigned long framesEncoded;
-    DOMString mediaSourceId;
+    unsigned long keyFramesEncoded;
+    unsigned long framesDiscardedOnSend;
+    unsigned long long qpSum;
+    unsigned long long totalSamplesSent;
+    unsigned long long samplesEncodedWithSilk;
+    unsigned long long samplesEncodedWithCelt;
+    boolean voiceActivityFlag;
+    double totalEncodeTime;
+    double totalPacketSendDelay;
+    double averageRtcpInterval;
+    // RTCQualityLimitationReason qualityLimitationReason;
+    // record<DOMString, double> qualityLimitationDurations;
+    unsigned long qualityLimitationResolutionChanges;
+    // record<USVString, unsigned long long> perDscpPacketsSent;
+    unsigned long nackCount;
+    unsigned long firCount;
+    unsigned long pliCount;
+    unsigned long sliCount;
+    // DOMString encoderImplementation;
+
+    // To be removed as obsolete.
+    DOMString trackId;
 };
 
 [ JSGenerateToJSObject ]
index fe518b2..c52f09a 100644 (file)
@@ -60,49 +60,32 @@ static inline void fillRTCStats(RTCStatsReport::Stats& stats, const webrtc::RTCS
     stats.id = fromStdString(rtcStats.id());
 }
 
-static inline void fillRTCRTPStreamStats(RTCStatsReport::RTCRTPStreamStats& stats, const webrtc::RTCRTPStreamStats& rtcStats)
+static inline void fillRtpStreamStats(RTCStatsReport::RtpStreamStats& stats, const webrtc::RTCRTPStreamStats& rtcStats)
 {
     fillRTCStats(stats, rtcStats);
 
     if (rtcStats.ssrc.is_defined())
         stats.ssrc = *rtcStats.ssrc;
-    if (rtcStats.is_remote.is_defined())
-        stats.isRemote = *rtcStats.is_remote;
-    if (rtcStats.media_type.is_defined())
-        stats.mediaType = fromStdString(*rtcStats.media_type);
-    if (rtcStats.track_id.is_defined())
-        stats.trackId = fromStdString(*rtcStats.track_id);
     if (rtcStats.transport_id.is_defined())
         stats.transportId = fromStdString(*rtcStats.transport_id);
     if (rtcStats.codec_id.is_defined())
         stats.codecId = fromStdString(*rtcStats.codec_id);
-    if (rtcStats.fir_count.is_defined())
-        stats.firCount = *rtcStats.fir_count;
-    if (rtcStats.pli_count.is_defined())
-        stats.pliCount = *rtcStats.pli_count;
-    if (rtcStats.nack_count.is_defined())
-        stats.nackCount = *rtcStats.nack_count;
-    if (rtcStats.sli_count.is_defined())
-        stats.sliCount = *rtcStats.sli_count;
-    if (rtcStats.qp_sum.is_defined())
-        stats.qpSum = *rtcStats.qp_sum;
-    stats.qpSum = 0;
+    if (rtcStats.media_type.is_defined()) {
+        stats.mediaType = fromStdString(*rtcStats.media_type);
+        stats.kind = stats.mediaType;
+    }
 }
 
-static inline void fillInboundRTPStreamStats(RTCStatsReport::InboundRTPStreamStats& stats, const webrtc::RTCInboundRTPStreamStats& rtcStats)
+static inline void fillReceivedRtpStreamStats(RTCStatsReport::ReceivedRtpStreamStats& stats, const webrtc::RTCInboundRTPStreamStats& rtcStats)
 {
-    fillRTCRTPStreamStats(stats, rtcStats);
+    fillRtpStreamStats(stats, rtcStats);
 
-    // FIXME: Add support for decoder_implementation
     if (rtcStats.packets_received.is_defined())
         stats.packetsReceived = *rtcStats.packets_received;
-    if (rtcStats.bytes_received.is_defined())
-        stats.bytesReceived = *rtcStats.bytes_received;
     if (rtcStats.packets_lost.is_defined())
         stats.packetsLost = *rtcStats.packets_lost;
     if (rtcStats.jitter.is_defined())
         stats.jitter = *rtcStats.jitter;
-    // FIXME: Add support back for fractionLost.
     if (rtcStats.packets_discarded.is_defined())
         stats.packetsDiscarded = *rtcStats.packets_discarded;
     if (rtcStats.packets_repaired.is_defined())
@@ -123,25 +106,130 @@ static inline void fillInboundRTPStreamStats(RTCStatsReport::InboundRTPStreamSta
         stats.gapLossRate = *rtcStats.gap_loss_rate;
     if (rtcStats.gap_discard_rate.is_defined())
         stats.gapDiscardRate = *rtcStats.gap_discard_rate;
+    // Add frames_dropped and full_frames_lost.
+}
+
+static inline void fillInboundRtpStreamStats(RTCStatsReport::InboundRtpStreamStats& stats, const webrtc::RTCInboundRTPStreamStats& rtcStats)
+{
+    fillReceivedRtpStreamStats(stats, rtcStats);
+
+    // receiverId
+    // remoteId
     if (rtcStats.frames_decoded.is_defined())
         stats.framesDecoded = *rtcStats.frames_decoded;
+    if (rtcStats.key_frames_decoded.is_defined())
+        stats.keyFramesDecoded = *rtcStats.key_frames_decoded;
+    // frameWidth, frameHeight, frameBitDepth, framesPerSecond
+    if (rtcStats.qp_sum.is_defined())
+        stats.qpSum = *rtcStats.qp_sum;
+    if (rtcStats.total_decode_time.is_defined())
+        stats.totalDecodeTime = *rtcStats.total_decode_time;
+    if (rtcStats.total_inter_frame_delay.is_defined())
+        stats.totalInterFrameDelay = *rtcStats.total_inter_frame_delay;
+    if (rtcStats.total_squared_inter_frame_delay.is_defined())
+        stats.totalSquaredInterFrameDelay = *rtcStats.total_squared_inter_frame_delay;
+    // voiceActivityFlag, lastPacketReceivedTimestamp, averageRtcpInterval
+    if (rtcStats.header_bytes_received.is_defined())
+        stats.headerBytesReceived = *rtcStats.header_bytes_received;
+    if (rtcStats.fec_packets_received.is_defined())
+        stats.fecPacketsReceived = *rtcStats.fec_packets_received;
+    if (rtcStats.fec_packets_discarded.is_defined())
+        stats.fecPacketsDiscarded = *rtcStats.fec_packets_discarded;
+    if (rtcStats.bytes_received.is_defined())
+        stats.bytesReceived = *rtcStats.bytes_received;
+    // packetsFailedDecryption, packetsDuplicated
+    if (rtcStats.fir_count.is_defined())
+        stats.firCount = *rtcStats.fir_count;
+    if (rtcStats.pli_count.is_defined())
+        stats.pliCount = *rtcStats.pli_count;
+    if (rtcStats.nack_count.is_defined())
+        stats.nackCount = *rtcStats.nack_count;
+    if (rtcStats.sli_count.is_defined())
+        stats.sliCount = *rtcStats.sli_count;
+    // estimatedPlayoutTimestamp, jitterBufferDelay, jitterBufferEmittedCount, totalSamplesReceived, samplesDecodedWithSilk, samplesDecodedWithCelt
+    // concealedSamples, silentConcealedSamples, concealmentEvents, insertedSamplesForDeceleration, removedSamplesForAcceleration
+    // audioLevel, totalAudioEnergy, totalSamplesDuration, framesReceived
+
+    if (rtcStats.track_id.is_defined())
+        stats.trackId = fromStdString(*rtcStats.track_id);
 }
 
-static inline void fillOutboundRTPStreamStats(RTCStatsReport::OutboundRTPStreamStats& stats, const webrtc::RTCOutboundRTPStreamStats& rtcStats)
+static inline void fillRemoteInboundRtpStreamStats(RTCStatsReport::RemoteInboundRtpStreamStats& stats, const webrtc::RTCRemoteInboundRtpStreamStats& rtcStats)
 {
-    fillRTCRTPStreamStats(stats, rtcStats);
+    fillRTCStats(stats, rtcStats);
+
+    // FIXME: this should be filled in fillRtpStreamStats.
+    if (rtcStats.ssrc.is_defined())
+        stats.ssrc = *rtcStats.ssrc;
+    if (rtcStats.transport_id.is_defined())
+        stats.transportId = fromStdString(*rtcStats.transport_id);
+    if (rtcStats.codec_id.is_defined())
+        stats.codecId = fromStdString(*rtcStats.codec_id);
+    if (rtcStats.kind.is_defined())
+        stats.kind = stats.kind;
+
+    if (rtcStats.local_id.is_defined())
+        stats.localId = fromStdString(*rtcStats.local_id);
+    if (rtcStats.round_trip_time.is_defined())
+        stats.roundTripTime = *rtcStats.round_trip_time;
+
+    // totalRoundTripTime, fractionLost, reportsReceived, roundTripTimeMeasurements
+}
+
+static inline void fillSentRtpStreamStats(RTCStatsReport::SentRtpStreamStats& stats, const webrtc::RTCOutboundRTPStreamStats& rtcStats)
+{
+    fillRtpStreamStats(stats, rtcStats);
 
-    // FIXME: Add support for encoder_implementation
     if (rtcStats.packets_sent.is_defined())
         stats.packetsSent = *rtcStats.packets_sent;
     if (rtcStats.bytes_sent.is_defined())
         stats.bytesSent = *rtcStats.bytes_sent;
+}
+
+static inline void fillOutboundRtpStreamStats(RTCStatsReport::OutboundRtpStreamStats& stats, const webrtc::RTCOutboundRTPStreamStats& rtcStats)
+{
+    fillSentRtpStreamStats(stats, rtcStats);
+
+    // rtxSsrc
+    if (rtcStats.media_source_id.is_defined())
+        stats.mediaSourceId = fromStdString(*rtcStats.media_source_id);
+    // senderId
+    if (rtcStats.remote_id.is_defined())
+        stats.remoteId = fromStdString(*rtcStats.remote_id);
+    // rid, packetsDiscardedOnSend
+    if (rtcStats.header_bytes_sent.is_defined())
+        stats.headerBytesSent = *rtcStats.header_bytes_sent;
+    // packetsDiscardedOnSend, bytesDiscardedOnSend, fecPacketsSent;
+    if (rtcStats.retransmitted_packets_sent.is_defined())
+        stats.retransmittedPacketsSent = *rtcStats.retransmitted_packets_sent;
+    if (rtcStats.retransmitted_bytes_sent.is_defined())
+        stats.retransmittedBytesSent = *rtcStats.retransmitted_bytes_sent;
     if (rtcStats.target_bitrate.is_defined())
         stats.targetBitrate = *rtcStats.target_bitrate;
+    // totalEncodedBytesTarget, frameWidth, frameHeight, frameBitDepth, framesPerSecond, framesSent, hugeFramesSent
     if (rtcStats.frames_encoded.is_defined())
         stats.framesEncoded = *rtcStats.frames_encoded;
-    if (rtcStats.media_source_id.is_defined())
-        stats.mediaSourceId = fromStdString(*rtcStats.media_source_id);
+    if (rtcStats.key_frames_encoded.is_defined())
+        stats.keyFramesEncoded = *rtcStats.key_frames_encoded;
+    // framesDiscardedOnSend;
+    if (rtcStats.qp_sum.is_defined())
+        stats.qpSum = *rtcStats.qp_sum;
+    // totalEncodedBytesTarget, frameWidth, frameHeight, frameBitDepth, framesPerSecond, framesSent, hugeFramesSent
+    // totalSamplesSent, samplesEncodedWithSilk, samplesEncodedWithCelt, voiceActivityFlag, totalEncodeTime
+    if (rtcStats.total_packet_send_delay.is_defined())
+        stats.totalPacketSendDelay = *rtcStats.total_packet_send_delay;
+    // averageRtcpInterval, qualityLimitationResolutionChanges
+    if (rtcStats.nack_count.is_defined())
+        stats.nackCount = *rtcStats.nack_count;
+    if (rtcStats.fir_count.is_defined())
+        stats.firCount = *rtcStats.fir_count;
+    if (rtcStats.pli_count.is_defined())
+        stats.pliCount = *rtcStats.pli_count;
+    if (rtcStats.sli_count.is_defined())
+        stats.sliCount = *rtcStats.sli_count;
+
+    if (rtcStats.track_id.is_defined())
+        stats.trackId = fromStdString(*rtcStats.track_id);
 }
 
 static inline void fillRTCMediaStreamTrackStats(RTCStatsReport::MediaStreamTrackStats& stats, const webrtc::RTCMediaStreamTrackStats& rtcStats)
@@ -419,13 +507,13 @@ static inline void initializeRTCStatsReportBackingMap(DOMMapAdapter& report, con
 {
     for (const auto& rtcStats : rtcReport) {
         if (rtcStats.type() == webrtc::RTCInboundRTPStreamStats::kType) {
-            RTCStatsReport::InboundRTPStreamStats stats;
-            fillInboundRTPStreamStats(stats, static_cast<const webrtc::RTCInboundRTPStreamStats&>(rtcStats));
-            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::InboundRTPStreamStats>>(stats.id, WTFMove(stats));
+            RTCStatsReport::InboundRtpStreamStats stats;
+            fillInboundRtpStreamStats(stats, static_cast<const webrtc::RTCInboundRTPStreamStats&>(rtcStats));
+            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::InboundRtpStreamStats>>(stats.id, WTFMove(stats));
         } else if (rtcStats.type() == webrtc::RTCOutboundRTPStreamStats::kType) {
-            RTCStatsReport::OutboundRTPStreamStats stats;
-            fillOutboundRTPStreamStats(stats, static_cast<const webrtc::RTCOutboundRTPStreamStats&>(rtcStats));
-            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::OutboundRTPStreamStats>>(stats.id, WTFMove(stats));
+            RTCStatsReport::OutboundRtpStreamStats stats;
+            fillOutboundRtpStreamStats(stats, static_cast<const webrtc::RTCOutboundRTPStreamStats&>(rtcStats));
+            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::OutboundRtpStreamStats>>(stats.id, WTFMove(stats));
         } else if (rtcStats.type() == webrtc::RTCMediaStreamTrackStats::kType) {
             RTCStatsReport::MediaStreamTrackStats stats;
             fillRTCMediaStreamTrackStats(stats, static_cast<const webrtc::RTCMediaStreamTrackStats&>(rtcStats));
@@ -466,6 +554,10 @@ static inline void initializeRTCStatsReportBackingMap(DOMMapAdapter& report, con
             RTCStatsReport::VideoSourceStats stats;
             fillRTCVideoSourceStats(stats, static_cast<const webrtc::RTCVideoSourceStats&>(rtcStats));
             report.set<IDLDOMString, IDLDictionary<RTCStatsReport::VideoSourceStats>>(stats.id, WTFMove(stats));
+        } else if (rtcStats.type() == webrtc::RTCRemoteInboundRtpStreamStats::kType) {
+            RTCStatsReport::RemoteInboundRtpStreamStats stats;
+            fillRemoteInboundRtpStreamStats(stats, static_cast<const webrtc::RTCRemoteInboundRtpStreamStats&>(rtcStats));
+            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::RemoteInboundRtpStreamStats>>(stats.id, WTFMove(stats));
         }
     }
 }