Source/ThirdParty/libwebrtc:
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jun 2020 07:19:50 +0000 (07:19 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jun 2020 07:19:50 +0000 (07:19 +0000)
Ad support for media-source stats
https://bugs.webkit.org/show_bug.cgi?id=212702

Reviewed by Eric Carlson.

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

Source/WebCore:
Ad support for media-source stats
https://bugs.webkit.org/show_bug.cgi?id=212702

Reviewed by Eric Carlson.

Expose 'media-source' stats which come in audio and video flavours.
Covered by updated test.

* Modules/mediastream/RTCStatsReport.h:
(WebCore::RTCStatsReport::AudioSourceStats::AudioSourceStats):
(WebCore::RTCStatsReport::VideoSourceStats::VideoSourceStats):
* Modules/mediastream/RTCStatsReport.idl:
* Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
(WebCore::fillRTCRTPStreamStats):
(WebCore::fillRTCMediaSourceStats):
(WebCore::fillRTCAudioSourceStats):
(WebCore::fillRTCVideoSourceStats):
(WebCore::initializeRTCStatsReportBackingMap):

LayoutTests:
Add support for media-source stats
https://bugs.webkit.org/show_bug.cgi?id=212702

Reviewed by Eric Carlson.

* webrtc/video-stats.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262605 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 6988e16..bb4486d 100644 (file)
@@ -1,5 +1,14 @@
 2020-06-05  Youenn Fablet  <youenn@apple.com>
 
+        Add support for media-source stats
+        https://bugs.webkit.org/show_bug.cgi?id=212702
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-stats.html:
+
+2020-06-05  Youenn Fablet  <youenn@apple.com>
+
         Mark some service worker tests as slow in iOS
         https://bugs.webkit.org/show_bug.cgi?id=212743
 
index d2b7c5a..ccafd76 100644 (file)
@@ -29,6 +29,34 @@ function checkStatsReportIterator(report)
         assert_equals(pair.length, 2);
 }
 
+function getAudioSourceStats(connection)
+{
+    return connection.getStats().then((report) => {
+        checkStatsReportIterator(report);
+        var stats;
+        report.forEach((statItem) => {
+            if (statItem.type === "media-source" && statItem.kind === "audio") {
+                stats = statItem;
+            }
+        });
+        return stats;
+    });
+}
+
+function getVideoSourceStats(connection)
+{
+    return connection.getStats().then((report) => {
+        checkStatsReportIterator(report);
+        var stats;
+        report.forEach((statItem) => {
+            if (statItem.type === "media-source" && statItem.kind === "video") {
+                stats = statItem;
+            }
+        });
+        return stats;
+    });
+}
+
 function getInboundRTPStats(connection)
 {
     return connection.getStats().then((report) => {
@@ -104,13 +132,15 @@ promise_test(async (test) => {
     if (window.testRunner)
         testRunner.setUserMediaPermission(true);
 
-    const localStream = await navigator.mediaDevices.getUserMedia({ video: true});
+    const localStream = await navigator.mediaDevices.getUserMedia({ audio : true, video: true});
     await new Promise((resolve, reject) => {
         createConnections((connection) => {
             firstConnection = connection;
+            firstConnection.addTrack(localStream.getAudioTracks()[0], localStream);
             firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
         }, (connection) => {
             secondConnection = connection;
+            secondConnection.addTrack(localStream.getAudioTracks()[0], localStream);
             secondConnection.addTrack(localStream.getVideoTracks()[0], localStream);
             secondConnection.ontrack = (trackEvent) => {
                 resolve();
@@ -137,10 +167,16 @@ promise_test(async (test) => {
     await checkOutboundFramesNumberIncreased(firstConnection, statsFirstConnection, 0);
 
     let types = await getStatsType(firstConnection);
-    assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "local-candidate", "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", "track", "transport"]);
 
     types = await getStatsType(secondConnection);
-    assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "local-candidate", "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", "track", "transport"]);
+
+     const audioSourceStats = await getAudioSourceStats(firstConnection);
+     assert_true(!!audioSourceStats, "audio source presence");
+
+     const videoSourceStats = await getVideoSourceStats(firstConnection);
+     assert_true(!!videoSourceStats, "video source presence");
 }, "Basic video stats");
 
 promise_test(async (test) => {
index a56ff68..dac389f 100644 (file)
@@ -1,3 +1,14 @@
+2020-06-05  Youenn Fablet  <youenn@apple.com>
+
+        Ad support for media-source stats
+        https://bugs.webkit.org/show_bug.cgi?id=212702
+
+        Reviewed by Eric Carlson.
+
+        * Configurations/libwebrtc.iOS.exp:
+        * Configurations/libwebrtc.iOSsim.exp:
+        * Configurations/libwebrtc.mac.exp:
+
 2020-06-04  Tim Horton  <timothy_horton@apple.com>
 
         Work around broken system version macro
index d69fda6..b8005a6 100644 (file)
@@ -33,6 +33,8 @@ __ZN6webrtc24RTCIceCandidatePairStats5kTypeE
 __ZN6webrtc24RTCInboundRTPStreamStats5kTypeE
 __ZN6webrtc24RTCMediaStreamTrackStats5kTypeE
 __ZN6webrtc25RTCOutboundRTPStreamStats5kTypeE
+__ZN6webrtc19RTCAudioSourceStats5kTypeE
+__ZN6webrtc19RTCVideoSourceStats5kTypeE
 __ZN6webrtc27SessionDescriptionInterface6kOfferE
 __ZN6webrtc27SessionDescriptionInterface7kAnswerE
 __ZN6webrtc27SessionDescriptionInterface9kPrAnswerE
index d69fda6..b8005a6 100644 (file)
@@ -33,6 +33,8 @@ __ZN6webrtc24RTCIceCandidatePairStats5kTypeE
 __ZN6webrtc24RTCInboundRTPStreamStats5kTypeE
 __ZN6webrtc24RTCMediaStreamTrackStats5kTypeE
 __ZN6webrtc25RTCOutboundRTPStreamStats5kTypeE
+__ZN6webrtc19RTCAudioSourceStats5kTypeE
+__ZN6webrtc19RTCVideoSourceStats5kTypeE
 __ZN6webrtc27SessionDescriptionInterface6kOfferE
 __ZN6webrtc27SessionDescriptionInterface7kAnswerE
 __ZN6webrtc27SessionDescriptionInterface9kPrAnswerE
index 725bfb2..74d81b3 100644 (file)
@@ -33,6 +33,8 @@ __ZN6webrtc24RTCIceCandidatePairStats5kTypeE
 __ZN6webrtc24RTCInboundRTPStreamStats5kTypeE
 __ZN6webrtc24RTCMediaStreamTrackStats5kTypeE
 __ZN6webrtc25RTCOutboundRTPStreamStats5kTypeE
+__ZN6webrtc19RTCAudioSourceStats5kTypeE
+__ZN6webrtc19RTCVideoSourceStats5kTypeE
 __ZN6webrtc27SessionDescriptionInterface6kOfferE
 __ZN6webrtc27SessionDescriptionInterface7kAnswerE
 __ZN6webrtc27SessionDescriptionInterface9kPrAnswerE
index 4a0544d..8447f71 100644 (file)
@@ -1,3 +1,24 @@
+2020-06-05  Youenn Fablet  <youenn@apple.com>
+
+        Ad support for media-source stats
+        https://bugs.webkit.org/show_bug.cgi?id=212702
+
+        Reviewed by Eric Carlson.
+
+        Expose 'media-source' stats which come in audio and video flavours.
+        Covered by updated test.
+
+        * Modules/mediastream/RTCStatsReport.h:
+        (WebCore::RTCStatsReport::AudioSourceStats::AudioSourceStats):
+        (WebCore::RTCStatsReport::VideoSourceStats::VideoSourceStats):
+        * Modules/mediastream/RTCStatsReport.idl:
+        * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+        (WebCore::fillRTCRTPStreamStats):
+        (WebCore::fillRTCMediaSourceStats):
+        (WebCore::fillRTCAudioSourceStats):
+        (WebCore::fillRTCVideoSourceStats):
+        (WebCore::initializeRTCStatsReportBackingMap):
+
 2020-06-04  Sihui Liu  <sihui_liu@apple.com>
 
         Text manipulation: first and last unit in a paragraph should not contain only excluded tokens
index 6d3450f..ba76094 100644 (file)
@@ -39,17 +39,18 @@ public:
     void initializeMapLike(DOMMapAdapter& adapter) { m_mapInitializer(adapter); }
 
     enum class Type {
+        CandidatePair,
+        Certificate,
         Codec,
+        DataChannel,
         InboundRtp,
+        LocalCandidate,
+        MediaSource,
         OutboundRtp,
         PeerConnection,
-        DataChannel,
-        Track,
-        Transport,
-        CandidatePair,
-        LocalCandidate,
         RemoteCandidate,
-        Certificate
+        Track,
+        Transport
     };
     struct Stats {
         double timestamp;
@@ -100,6 +101,7 @@ public:
         Optional<uint64_t> bytesSent;
         Optional<double> targetBitrate;
         Optional<uint32_t> framesEncoded;
+        String mediaSourceId;
     };
 
     struct MediaStreamTrackStats : Stats {
@@ -233,6 +235,32 @@ public:
         Optional<uint32_t> dataChannelsClosed;
     };
 
+    struct MediaSourceStats : Stats {
+        String trackIdentifier;
+        String kind;
+        Optional<bool> relayedSource;
+    };
+
+    struct AudioSourceStats : MediaSourceStats {
+        AudioSourceStats() { type = RTCStatsReport::Type::MediaSource; }
+
+        Optional<double> audioLevel;
+        Optional<double> totalAudioEnergy;
+        Optional<double> totalSamplesDuration;
+        Optional<double> echoReturnLoss;
+        Optional<double> echoReturnLossEnhancement;
+    };
+
+    struct VideoSourceStats : MediaSourceStats {
+        VideoSourceStats() { type = RTCStatsReport::Type::MediaSource; }
+
+        Optional<unsigned long> width;
+        Optional<unsigned long> height;
+        Optional<unsigned long> bitDepth;
+        Optional<unsigned long> frames;
+        Optional<double> framesPerSecond;
+    };
+
 private:
     explicit RTCStatsReport(MapInitializer&&);
 
index 246ec3c..d0e46e7 100644 (file)
 };
 
 enum RTCStatsType {
+    "candidate-pair",
+    "certificate",
     "codec",
+    "data-channel",
     "inbound-rtp",
+    "local-candidate",
+    "media-source",
     "outbound-rtp",
     "peer-connection",
-    "data-channel",
-    "track",
-    "transport",
-    "candidate-pair",
-    "local-candidate",
     "remote-candidate",
-    "certificate"
+    "track",
+    "transport"
 };
 
 typedef double DOMHighResTimeStamp;
@@ -95,6 +96,7 @@ dictionary RTCOutboundRTPStreamStats : RTCRTPStreamStats {
     double targetBitrate;
     // FIXME 169662: missing roundTripTime
     unsigned long framesEncoded;
+    DOMString mediaSourceId;
 };
 
 [ JSGenerateToJSObject ]
@@ -237,4 +239,27 @@ dictionary RTCPeerConnectionStats : RTCStats {
     // unsigned long dataChannelsAccepted;
 };
 
+[ JSGenerateToJSObject ]
+dictionary RTCMediaSourceStats : RTCStats {
+    required DOMString  trackIdentifier;
+    required DOMString  kind;
+    boolean relayedSource;
+};
+
+dictionary RTCAudioSourceStats : RTCMediaSourceStats {
+    double audioLevel;
+    double totalAudioEnergy;
+    double totalSamplesDuration;
+    double echoReturnLoss;
+    double echoReturnLossEnhancement;
+};
+
+dictionary RTCVideoSourceStats : RTCMediaSourceStats {
+    unsigned long width;
+    unsigned long height;
+    unsigned long bitDepth;
+    unsigned long frames;
+    double framesPerSecond;
+};
+
 // FIXME 169662: missing RTCMediaStreamStats
index 33c44f8..fe518b2 100644 (file)
@@ -140,6 +140,8 @@ static inline void fillOutboundRTPStreamStats(RTCStatsReport::OutboundRTPStreamS
         stats.targetBitrate = *rtcStats.target_bitrate;
     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);
 }
 
 static inline void fillRTCMediaStreamTrackStats(RTCStatsReport::MediaStreamTrackStats& stats, const webrtc::RTCMediaStreamTrackStats& rtcStats)
@@ -379,6 +381,40 @@ static inline void fillRTCPeerConnectionStats(RTCStatsReport::PeerConnectionStat
         stats.dataChannelsClosed = *rtcStats.data_channels_closed;
 }
 
+static inline void fillRTCMediaSourceStats(RTCStatsReport::MediaSourceStats& stats, const webrtc::RTCMediaSourceStats& rtcStats)
+{
+    fillRTCStats(stats, rtcStats);
+    if (rtcStats.track_identifier.is_defined())
+        stats.trackIdentifier = fromStdString(*rtcStats.track_identifier);
+    if (rtcStats.kind.is_defined())
+        stats.kind = fromStdString(*rtcStats.kind);
+}
+
+static inline void fillRTCAudioSourceStats(RTCStatsReport::AudioSourceStats& stats, const webrtc::RTCAudioSourceStats& rtcStats)
+{
+    fillRTCMediaSourceStats(stats, rtcStats);
+    if (rtcStats.audio_level.is_defined())
+        stats.audioLevel = *rtcStats.audio_level;
+    if (rtcStats.total_audio_energy.is_defined())
+        stats.totalAudioEnergy = *rtcStats.total_audio_energy;
+    if (rtcStats.total_samples_duration.is_defined())
+        stats.totalSamplesDuration = *rtcStats.total_samples_duration;
+}
+
+static inline void fillRTCVideoSourceStats(RTCStatsReport::VideoSourceStats& stats, const webrtc::RTCVideoSourceStats& rtcStats)
+{
+    fillRTCMediaSourceStats(stats, rtcStats);
+
+    if (rtcStats.width.is_defined())
+        stats.width = *rtcStats.width;
+    if (rtcStats.height.is_defined())
+        stats.height = *rtcStats.height;
+    if (rtcStats.frames.is_defined())
+        stats.frames = *rtcStats.frames;
+    if (rtcStats.frames_per_second.is_defined())
+        stats.framesPerSecond = *rtcStats.frames_per_second;
+}
+
 static inline void initializeRTCStatsReportBackingMap(DOMMapAdapter& report, const webrtc::RTCStatsReport& rtcReport)
 {
     for (const auto& rtcStats : rtcReport) {
@@ -422,6 +458,14 @@ static inline void initializeRTCStatsReportBackingMap(DOMMapAdapter& report, con
             RTCStatsReport::PeerConnectionStats stats;
             fillRTCPeerConnectionStats(stats, static_cast<const webrtc::RTCPeerConnectionStats&>(rtcStats));
             report.set<IDLDOMString, IDLDictionary<RTCStatsReport::PeerConnectionStats>>(stats.id, WTFMove(stats));
+        } else if (rtcStats.type() == webrtc::RTCAudioSourceStats::kType) {
+            RTCStatsReport::AudioSourceStats stats;
+            fillRTCAudioSourceStats(stats, static_cast<const webrtc::RTCAudioSourceStats&>(rtcStats));
+            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::AudioSourceStats>>(stats.id, WTFMove(stats));
+        } else if (rtcStats.type() == webrtc::RTCVideoSourceStats::kType) {
+            RTCStatsReport::VideoSourceStats stats;
+            fillRTCVideoSourceStats(stats, static_cast<const webrtc::RTCVideoSourceStats&>(rtcStats));
+            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::VideoSourceStats>>(stats.id, WTFMove(stats));
         }
     }
 }