⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 236963 in webkit


Ignore:
Timestamp:
Oct 9, 2018, 8:44:34 AM (8 years ago)
Author:
youenn@apple.com
Message:

Add support for IceCandidate stats
https://bugs.webkit.org/show_bug.cgi?id=190329

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

Export new stats kType values.

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

Source/WebCore:

Convert IceCandidate stats gathered by libwebrtc.
Since networkType might be sensitive information, we currently do not expose it.
We do not expose address either if it is a host or prflx candidate.

Test: webrtc/candidate-stats.html

  • Modules/mediastream/RTCStatsReport.h:
  • Modules/mediastream/RTCStatsReport.idl:
  • Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:

(WebCore::iceCandidateState):
(WebCore::fillRTCIceCandidateStats):
(WebCore::LibWebRTCStatsCollector::OnStatsDelivered):

LayoutTests:

  • webrtc/candidate-stats-expected.txt: Added.
  • webrtc/candidate-stats.html: Added.
  • webrtc/routines.js:
  • webrtc/video-stats.html:
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r236961 r236963  
     12018-10-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add support for IceCandidate stats
     4        https://bugs.webkit.org/show_bug.cgi?id=190329
     5
     6        Reviewed by Eric Carlson.
     7
     8        * webrtc/candidate-stats-expected.txt: Added.
     9        * webrtc/candidate-stats.html: Added.
     10        * webrtc/routines.js:
     11        * webrtc/video-stats.html:
     12
    1132018-10-09  Philippe Normand  <pnormand@igalia.com>
    214
  • trunk/LayoutTests/webrtc/routines.js

    r236821 r236963  
    212212    }).join('\r\n');
    213213}
     214
     215async function getTypedStats(connection, type)
     216{
     217    const report = await connection.getStats();
     218    var stats;
     219    report.forEach((statItem) => {
     220        if (statItem.type === type)
     221            stats = statItem;
     222    });
     223    return stats;
     224}
  • trunk/LayoutTests/webrtc/video-stats.html

    r236346 r236963  
    138138
    139139    let types = await getStatsType(firstConnection);
    140     assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "outbound-rtp", "track"]);
     140    assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "local-candidate", "outbound-rtp", "remote-candidate", "track"]);
    141141
    142142    types = await getStatsType(secondConnection);
    143     assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "outbound-rtp", "track"]);
     143    assert_array_equals(types, ["candidate-pair", "certificate", "codec", "inbound-rtp", "local-candidate", "outbound-rtp", "remote-candidate", "track"]);
    144144}, "Basic video stats");
    145145
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r236898 r236963  
     12018-10-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add support for IceCandidate stats
     4        https://bugs.webkit.org/show_bug.cgi?id=190329
     5
     6        Reviewed by Eric Carlson.
     7
     8        Export new stats kType values.
     9
     10        * Configurations/libwebrtc.iOS.exp:
     11        * Configurations/libwebrtc.iOSsim.exp:
     12        * Configurations/libwebrtc.mac.exp:
     13
    1142018-10-06  Dan Bernstein  <mitz@apple.com>
    215
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp

    r236821 r236963  
    217217__ZN6webrtc9RtpSourceD1Ev
    218218__ZN6webrtc11field_trial25InitFieldTrialsFromStringEPKc
     219__ZN6webrtc25RTCLocalIceCandidateStats5kTypeE
     220__ZN6webrtc26RTCRemoteIceCandidateStats5kTypeE
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp

    r236821 r236963  
    218218__ZN6webrtc9RtpSourceD1Ev
    219219__ZN6webrtc11field_trial25InitFieldTrialsFromStringEPKc
     220__ZN6webrtc25RTCLocalIceCandidateStats5kTypeE
     221__ZN6webrtc26RTCRemoteIceCandidateStats5kTypeE
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp

    r236821 r236963  
    218218__ZN6webrtc9RtpSourceD1Ev
    219219__ZN6webrtc11field_trial25InitFieldTrialsFromStringEPKc
     220__ZN6webrtc25RTCLocalIceCandidateStats5kTypeE
     221__ZN6webrtc26RTCRemoteIceCandidateStats5kTypeE
  • trunk/Source/WebCore/ChangeLog

    r236961 r236963  
     12018-10-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add support for IceCandidate stats
     4        https://bugs.webkit.org/show_bug.cgi?id=190329
     5
     6        Reviewed by Eric Carlson.
     7
     8        Convert IceCandidate stats gathered by libwebrtc.
     9        Since networkType might be sensitive information, we currently do not expose it.
     10        We do not expose address either if it is a host or prflx candidate.
     11
     12        Test: webrtc/candidate-stats.html
     13
     14        * Modules/mediastream/RTCStatsReport.h:
     15        * Modules/mediastream/RTCStatsReport.idl:
     16        * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
     17        (WebCore::iceCandidateState):
     18        (WebCore::fillRTCIceCandidateStats):
     19        (WebCore::LibWebRTCStatsCollector::OnStatsDelivered):
     20
    1212018-10-09  Philippe Normand  <pnormand@igalia.com>
    222
  • trunk/Source/WebCore/Modules/mediastream/RTCStatsReport.h

    r236346 r236963  
    178178    };
    179179
     180    enum class IceCandidateType { Host, Srflx, Prflx, Relay };
     181
     182    struct IceCandidateStats : Stats {
     183        String transportId;
     184        String address;
     185        std::optional<int32_t> port;
     186        String protocol;
     187        std::optional<IceCandidateType> candidateType;
     188        std::optional<int32_t> priority;
     189        String url;
     190        bool deleted { false };
     191    };
     192
    180193    struct CertificateStats : Stats {
    181194        CertificateStats() { type = RTCStatsReport::Type::Certificate; }
  • trunk/Source/WebCore/Modules/mediastream/RTCStatsReport.idl

    r236346 r236963  
    166166};
    167167
     168enum RTCIceCandidateType {
     169    "host",
     170    "srflx",
     171    "prflx",
     172    "relay"
     173};
     174
     175[ JSGenerateToJSObject ]
     176dictionary RTCIceCandidateStats : RTCStats {
     177    DOMString transportId;
     178    // FIXME: decide whether to expose networkType
     179    // FIXME: Expose relayProtocol
     180    DOMString address;
     181    long port;
     182    DOMString protocol;
     183    RTCIceCandidateType candidateType;
     184    long priority;
     185    DOMString url;
     186    boolean deleted = false;
     187};
     188
    168189[ JSGenerateToJSObject ]
    169190dictionary RTCCertificateStats : RTCStats {
     
    195216// FIXME 169662: missing RTCTransportStats
    196217// FIXME 169662: missing RTCIceCandidateStats
    197 // FIXME 169662: missing RTCStatsIceCandidatePairState
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp

    r236346 r236963  
    279279}
    280280
     281static inline std::optional<RTCStatsReport::IceCandidateType> iceCandidateState(const std::string& state)
     282{
     283    if (state == "host")
     284        return RTCStatsReport::IceCandidateType::Host;
     285    if (state == "srflx")
     286        return RTCStatsReport::IceCandidateType::Srflx;
     287    if (state == "prflx")
     288        return RTCStatsReport::IceCandidateType::Prflx;
     289    if (state == "relay")
     290        return RTCStatsReport::IceCandidateType::Relay;
     291
     292    return { };
     293}
     294
     295static inline void fillRTCIceCandidateStats(RTCStatsReport::IceCandidateStats& stats, const webrtc::RTCIceCandidateStats& rtcStats)
     296{
     297    stats.type = rtcStats.type() == webrtc::RTCRemoteIceCandidateStats::kType ? RTCStatsReport::Type::RemoteCandidate : RTCStatsReport::Type::LocalCandidate;
     298
     299    fillRTCStats(stats, rtcStats);
     300
     301    if (rtcStats.transport_id.is_defined())
     302        stats.transportId = fromStdString(*rtcStats.transport_id);
     303    if (rtcStats.ip.is_defined())
     304        stats.address = fromStdString(*rtcStats.ip);
     305    if (rtcStats.port.is_defined())
     306        stats.port = *rtcStats.port;
     307    if (rtcStats.protocol.is_defined())
     308        stats.protocol = fromStdString(*rtcStats.protocol);
     309
     310    if (rtcStats.candidate_type.is_defined())
     311        stats.candidateType = iceCandidateState(*rtcStats.candidate_type);
     312
     313    if (stats.candidateType == RTCStatsReport::IceCandidateType::Prflx)
     314        stats.candidateType = { };
     315    if (stats.candidateType == RTCStatsReport::IceCandidateType::Prflx || stats.candidateType == RTCStatsReport::IceCandidateType::Host)
     316        stats.address = { };
     317
     318    if (rtcStats.priority.is_defined())
     319        stats.priority = *rtcStats.priority;
     320    if (rtcStats.url.is_defined())
     321        stats.url = fromStdString(*rtcStats.url);
     322    if (rtcStats.deleted.is_defined())
     323        stats.deleted = *rtcStats.deleted;
     324}
     325
    281326static inline void fillRTCCertificateStats(RTCStatsReport::CertificateStats& stats, const webrtc::RTCCertificateStats& rtcStats)
    282327{
     
    341386                fillRTCIceCandidatePairStats(stats, static_cast<const webrtc::RTCIceCandidatePairStats&>(rtcStats));
    342387                report->addStats<IDLDictionary<RTCStatsReport::IceCandidatePairStats>>(WTFMove(stats));
     388            } else if (rtcStats.type() == webrtc::RTCRemoteIceCandidateStats::kType || rtcStats.type() == webrtc::RTCLocalIceCandidateStats::kType) {
     389                RTCStatsReport::IceCandidateStats stats;
     390                fillRTCIceCandidateStats(stats, static_cast<const webrtc::RTCIceCandidateStats&>(rtcStats));
     391                report->addStats<IDLDictionary<RTCStatsReport::IceCandidateStats>>(WTFMove(stats));
    343392            } else if (rtcStats.type() == webrtc::RTCCertificateStats::kType) {
    344393                RTCStatsReport::CertificateStats stats;
Note: See TracChangeset for help on using the changeset viewer.