Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (235575 => 235576)
--- trunk/Source/WebCore/CMakeLists.txt 2018-08-31 23:22:47 UTC (rev 235575)
+++ trunk/Source/WebCore/CMakeLists.txt 2018-08-31 23:27:20 UTC (rev 235576)
@@ -1560,6 +1560,7 @@
"${THIRDPARTY_DIR}/libwebrtc/Source/third_party/abseil-cpp")
list(APPEND WebCore_LIBRARIES webrtc)
list(APPEND WebCore_SOURCES
+ Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp
Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp
Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
Modified: trunk/Source/WebCore/ChangeLog (235575 => 235576)
--- trunk/Source/WebCore/ChangeLog 2018-08-31 23:22:47 UTC (rev 235575)
+++ trunk/Source/WebCore/ChangeLog 2018-08-31 23:27:20 UTC (rev 235576)
@@ -1,3 +1,40 @@
+2018-08-31 Youenn Fablet <[email protected]>
+
+ Move stats gathering out of LibWebRTCMediaEndpoint
+ https://bugs.webkit.org/show_bug.cgi?id=189180
+
+ Reviewed by Alejandro G. Castro.
+
+ Move stats gathering in LibWebRTCStatsCollector.
+ Make sure that the lambda given to the collector is always called and destroyed from the main thread.
+ This allows capturing the promise here instead of storing it into the peer connection backend.
+ No change of behavior.
+
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+ (WebCore::LibWebRTCMediaEndpoint::getStats):
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+ * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+ (WebCore::LibWebRTCPeerConnectionBackend::getStats):
+ (WebCore::LibWebRTCPeerConnectionBackend::doStop):
+ * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+ * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp: Added.
+ (WebCore::LibWebRTCStatsCollector::LibWebRTCStatsCollector):
+ (WebCore::LibWebRTCStatsCollector::~LibWebRTCStatsCollector):
+ (WebCore::fromStdString):
+ (WebCore::fillRTCStats):
+ (WebCore::fillRTCRTPStreamStats):
+ (WebCore::fillInboundRTPStreamStats):
+ (WebCore::fillOutboundRTPStreamStats):
+ (WebCore::fillRTCMediaStreamTrackStats):
+ (WebCore::fillRTCDataChannelStats):
+ (WebCore::iceCandidatePairState):
+ (WebCore::fillRTCIceCandidatePairStats):
+ (WebCore::fillRTCCertificateStats):
+ (WebCore::LibWebRTCStatsCollector::OnStatsDelivered):
+ * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h: Added.
+ (WebCore::LibWebRTCStatsCollector::create):
+ * WebCore.xcodeproj/project.pbxproj:
+
2018-08-31 Jer Noble <[email protected]>
Compile error in RealtimeOutgoingVideoSource.cpp; unused parameter in libwebrtc header
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (235575 => 235576)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2018-08-31 23:22:47 UTC (rev 235575)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2018-08-31 23:27:20 UTC (rev 235576)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@
#include "LibWebRTCDataChannelHandler.h"
#include "LibWebRTCPeerConnectionBackend.h"
#include "LibWebRTCProvider.h"
+#include "LibWebRTCStatsCollector.h"
#include "Logging.h"
#include "NotImplemented.h"
#include "Performance.h"
@@ -305,300 +306,20 @@
m_backend->CreateAnswer(&m_createSessionDescriptionObserver, nullptr);
}
-void LibWebRTCMediaEndpoint::getStats(MediaStreamTrack* track, const DeferredPromise& promise)
+void LibWebRTCMediaEndpoint::getStats(MediaStreamTrack*, Ref<DeferredPromise>&& promise)
{
- auto collector = StatsCollector::create(*this, promise, track);
- LibWebRTCProvider::callOnWebRTCSignalingThread([protectedThis = makeRef(*this), collector = WTFMove(collector)] {
- if (protectedThis->m_backend)
- protectedThis->m_backend->GetStats(collector.get());
- });
-}
+ auto collector = LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)](auto&& report) mutable {
+ ASSERT(isMainThread());
+ if (protectedThis->isStopped() || !report)
+ return false;
-LibWebRTCMediaEndpoint::StatsCollector::StatsCollector(Ref<LibWebRTCMediaEndpoint>&& endpoint, const DeferredPromise& promise, MediaStreamTrack* track)
- : m_endpoint(WTFMove(endpoint))
- , m_promise(promise)
-{
- if (track)
- m_id = track->id();
-}
-
-static inline void fillRTCStats(RTCStatsReport::Stats& stats, const webrtc::RTCStats& rtcStats)
-{
- stats.timestamp = Performance::reduceTimeResolution(Seconds::fromMicroseconds(rtcStats.timestamp_us())).milliseconds();
- stats.id = fromStdString(rtcStats.id());
-}
-
-static inline void fillRTCRTPStreamStats(RTCStatsReport::RTCRTPStreamStats& stats, const webrtc::RTCRTPStreamStats& rtcStats)
-{
- fillRTCStats(stats, rtcStats);
-
- if (rtcStats.ssrc.is_defined())
- stats.ssrc = *rtcStats.ssrc;
- if (rtcStats.associate_stats_id.is_defined())
- stats.associateStatsId = fromStdString(*rtcStats.associate_stats_id);
- 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.mediaTrackId = 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;
-}
-
-static inline void fillInboundRTPStreamStats(RTCStatsReport::InboundRTPStreamStats& stats, const webrtc::RTCInboundRTPStreamStats& rtcStats)
-{
- fillRTCRTPStreamStats(stats, rtcStats);
-
- 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;
- if (rtcStats.fraction_lost.is_defined())
- stats.fractionLost = *rtcStats.fraction_lost;
- if (rtcStats.packets_discarded.is_defined())
- stats.packetsDiscarded = *rtcStats.packets_discarded;
- if (rtcStats.packets_repaired.is_defined())
- stats.packetsRepaired = *rtcStats.packets_repaired;
- if (rtcStats.burst_packets_lost.is_defined())
- stats.burstPacketsLost = *rtcStats.burst_packets_lost;
- if (rtcStats.burst_packets_discarded.is_defined())
- stats.burstPacketsDiscarded = *rtcStats.burst_packets_discarded;
- if (rtcStats.burst_loss_count.is_defined())
- stats.burstLossCount = *rtcStats.burst_loss_count;
- if (rtcStats.burst_discard_count.is_defined())
- stats.burstDiscardCount = *rtcStats.burst_discard_count;
- if (rtcStats.burst_loss_rate.is_defined())
- stats.burstLossRate = *rtcStats.burst_loss_rate;
- if (rtcStats.burst_discard_rate.is_defined())
- stats.burstDiscardRate = *rtcStats.burst_discard_rate;
- if (rtcStats.gap_loss_rate.is_defined())
- stats.gapLossRate = *rtcStats.gap_loss_rate;
- if (rtcStats.gap_discard_rate.is_defined())
- stats.gapDiscardRate = *rtcStats.gap_discard_rate;
- if (rtcStats.frames_decoded.is_defined())
- stats.framesDecoded = *rtcStats.frames_decoded;
-}
-
-static inline void fillOutboundRTPStreamStats(RTCStatsReport::OutboundRTPStreamStats& stats, const webrtc::RTCOutboundRTPStreamStats& rtcStats)
-{
- fillRTCRTPStreamStats(stats, rtcStats);
-
- if (rtcStats.packets_sent.is_defined())
- stats.packetsSent = *rtcStats.packets_sent;
- if (rtcStats.bytes_sent.is_defined())
- stats.bytesSent = *rtcStats.bytes_sent;
- if (rtcStats.target_bitrate.is_defined())
- stats.targetBitrate = *rtcStats.target_bitrate;
- if (rtcStats.frames_encoded.is_defined())
- stats.framesEncoded = *rtcStats.frames_encoded;
-}
-
-static inline void fillRTCMediaStreamTrackStats(RTCStatsReport::MediaStreamTrackStats& stats, const webrtc::RTCMediaStreamTrackStats& rtcStats)
-{
- fillRTCStats(stats, rtcStats);
-
- if (rtcStats.track_identifier.is_defined())
- stats.trackIdentifier = fromStdString(*rtcStats.track_identifier);
- if (rtcStats.remote_source.is_defined())
- stats.remoteSource = *rtcStats.remote_source;
- if (rtcStats.ended.is_defined())
- stats.ended = *rtcStats.ended;
- if (rtcStats.detached.is_defined())
- stats.detached = *rtcStats.detached;
- if (rtcStats.frame_width.is_defined())
- stats.frameWidth = *rtcStats.frame_width;
- if (rtcStats.frame_height.is_defined())
- stats.frameHeight = *rtcStats.frame_height;
- if (rtcStats.frames_per_second.is_defined())
- stats.framesPerSecond = *rtcStats.frames_per_second;
- if (rtcStats.frames_sent.is_defined())
- stats.framesSent = *rtcStats.frames_sent;
- if (rtcStats.frames_received.is_defined())
- stats.framesReceived = *rtcStats.frames_received;
- if (rtcStats.frames_decoded.is_defined())
- stats.framesDecoded = *rtcStats.frames_decoded;
- if (rtcStats.frames_dropped.is_defined())
- stats.framesDropped = *rtcStats.frames_dropped;
- if (rtcStats.partial_frames_lost.is_defined())
- stats.partialFramesLost = *rtcStats.partial_frames_lost;
- if (rtcStats.full_frames_lost.is_defined())
- stats.fullFramesLost = *rtcStats.full_frames_lost;
- if (rtcStats.audio_level.is_defined())
- stats.audioLevel = *rtcStats.audio_level;
- if (rtcStats.echo_return_loss.is_defined())
- stats.echoReturnLoss = *rtcStats.echo_return_loss;
- if (rtcStats.echo_return_loss_enhancement.is_defined())
- stats.echoReturnLossEnhancement = *rtcStats.echo_return_loss_enhancement;
-}
-
-static inline void fillRTCDataChannelStats(RTCStatsReport::DataChannelStats& stats, const webrtc::RTCDataChannelStats& rtcStats)
-{
- fillRTCStats(stats, rtcStats);
-
- if (rtcStats.label.is_defined())
- stats.label = fromStdString(*rtcStats.label);
- if (rtcStats.protocol.is_defined())
- stats.protocol = fromStdString(*rtcStats.protocol);
- if (rtcStats.datachannelid.is_defined())
- stats.datachannelid = *rtcStats.datachannelid;
- if (rtcStats.state.is_defined())
- stats.state = fromStdString(*rtcStats.state);
- if (rtcStats.messages_sent.is_defined())
- stats.messagesSent = *rtcStats.messages_sent;
- if (rtcStats.bytes_sent.is_defined())
- stats.bytesSent = *rtcStats.bytes_sent;
- if (rtcStats.messages_received.is_defined())
- stats.messagesReceived = *rtcStats.messages_received;
- if (rtcStats.bytes_received.is_defined())
- stats.bytesReceived = *rtcStats.bytes_received;
-}
-
-static inline RTCStatsReport::IceCandidatePairState iceCandidatePairState(const std::string& state)
-{
- if (state == "frozen")
- return RTCStatsReport::IceCandidatePairState::Frozen;
- if (state == "waiting")
- return RTCStatsReport::IceCandidatePairState::Waiting;
- if (state == "in-progress")
- return RTCStatsReport::IceCandidatePairState::Inprogress;
- if (state == "failed")
- return RTCStatsReport::IceCandidatePairState::Failed;
- if (state == "succeeded")
- return RTCStatsReport::IceCandidatePairState::Succeeded;
- if (state == "cancelled")
- return RTCStatsReport::IceCandidatePairState::Cancelled;
- ASSERT_NOT_REACHED();
- return RTCStatsReport::IceCandidatePairState::Frozen;
-}
-
-static inline void fillRTCIceCandidatePairStats(RTCStatsReport::IceCandidatePairStats& stats, const webrtc::RTCIceCandidatePairStats& rtcStats)
-{
- fillRTCStats(stats, rtcStats);
-
- if (rtcStats.transport_id.is_defined())
- stats.transportId = fromStdString(*rtcStats.transport_id);
- if (rtcStats.local_candidate_id.is_defined())
- stats.localCandidateId = fromStdString(*rtcStats.local_candidate_id);
- if (rtcStats.remote_candidate_id.is_defined())
- stats.remoteCandidateId = fromStdString(*rtcStats.remote_candidate_id);
- if (rtcStats.state.is_defined())
- stats.state = iceCandidatePairState(*rtcStats.state);
-
- if (rtcStats.priority.is_defined())
- stats.priority = *rtcStats.priority;
- if (rtcStats.nominated.is_defined())
- stats.nominated = *rtcStats.nominated;
- if (rtcStats.writable.is_defined())
- stats.writable = *rtcStats.writable;
- if (rtcStats.readable.is_defined())
- stats.readable = *rtcStats.readable;
-
- if (rtcStats.bytes_sent.is_defined())
- stats.bytesSent = *rtcStats.bytes_sent;
- if (rtcStats.bytes_received.is_defined())
- stats.bytesReceived = *rtcStats.bytes_received;
- if (rtcStats.total_round_trip_time.is_defined())
- stats.totalRoundTripTime = *rtcStats.total_round_trip_time;
- if (rtcStats.current_round_trip_time.is_defined())
- stats.currentRoundTripTime = *rtcStats.current_round_trip_time;
- if (rtcStats.available_outgoing_bitrate.is_defined())
- stats.availableOutgoingBitrate = *rtcStats.available_outgoing_bitrate;
- if (rtcStats.available_incoming_bitrate.is_defined())
- stats.availableIncomingBitrate = *rtcStats.available_incoming_bitrate;
-
- if (rtcStats.requests_received.is_defined())
- stats.requestsReceived = *rtcStats.requests_received;
- if (rtcStats.requests_sent.is_defined())
- stats.requestsSent = *rtcStats.requests_sent;
- if (rtcStats.responses_received.is_defined())
- stats.responsesReceived = *rtcStats.responses_received;
- if (rtcStats.responses_sent.is_defined())
- stats.responsesSent = *rtcStats.responses_sent;
-
- if (rtcStats.requests_received.is_defined())
- stats.retransmissionsReceived = *rtcStats.requests_received;
- if (rtcStats.requests_sent.is_defined())
- stats.retransmissionsSent = *rtcStats.requests_sent;
- if (rtcStats.responses_received.is_defined())
- stats.consentRequestsReceived = *rtcStats.responses_received;
- if (rtcStats.responses_sent.is_defined())
- stats.consentRequestsSent = *rtcStats.responses_sent;
- if (rtcStats.responses_received.is_defined())
- stats.consentResponsesReceived = *rtcStats.responses_received;
- if (rtcStats.responses_sent.is_defined())
- stats.consentResponsesSent = *rtcStats.responses_sent;
-}
-
-static inline void fillRTCCertificateStats(RTCStatsReport::CertificateStats& stats, const webrtc::RTCCertificateStats& rtcStats)
-{
- fillRTCStats(stats, rtcStats);
-
- if (rtcStats.fingerprint.is_defined())
- stats.fingerprint = fromStdString(*rtcStats.fingerprint);
- if (rtcStats.fingerprint_algorithm.is_defined())
- stats.fingerprintAlgorithm = fromStdString(*rtcStats.fingerprint_algorithm);
- if (rtcStats.base64_certificate.is_defined())
- stats.base64Certificate = fromStdString(*rtcStats.base64_certificate);
- if (rtcStats.issuer_certificate_id.is_defined())
- stats.issuerCertificateId = fromStdString(*rtcStats.issuer_certificate_id);
-}
-
-void LibWebRTCMediaEndpoint::StatsCollector::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& rtcReport)
-{
- callOnMainThread([protectedThis = rtc::scoped_refptr<LibWebRTCMediaEndpoint::StatsCollector>(this), rtcReport] {
- if (protectedThis->m_endpoint->isStopped())
- return;
-
- auto report = RTCStatsReport::create();
- protectedThis->m_endpoint->m_peerConnectionBackend.getStatsSucceeded(protectedThis->m_promise, report.copyRef());
- ASSERT(report->backingMap());
-
- for (const auto& rtcStats : *rtcReport) {
- if (rtcStats.type() == webrtc::RTCInboundRTPStreamStats::kType) {
- RTCStatsReport::InboundRTPStreamStats stats;
- fillInboundRTPStreamStats(stats, static_cast<const webrtc::RTCInboundRTPStreamStats&>(rtcStats));
- report->addStats<IDLDictionary<RTCStatsReport::InboundRTPStreamStats>>(WTFMove(stats));
- } else if (rtcStats.type() == webrtc::RTCOutboundRTPStreamStats::kType) {
- RTCStatsReport::OutboundRTPStreamStats stats;
- fillOutboundRTPStreamStats(stats, static_cast<const webrtc::RTCOutboundRTPStreamStats&>(rtcStats));
- report->addStats<IDLDictionary<RTCStatsReport::OutboundRTPStreamStats>>(WTFMove(stats));
- } else if (rtcStats.type() == webrtc::RTCMediaStreamTrackStats::kType) {
- RTCStatsReport::MediaStreamTrackStats stats;
- fillRTCMediaStreamTrackStats(stats, static_cast<const webrtc::RTCMediaStreamTrackStats&>(rtcStats));
- report->addStats<IDLDictionary<RTCStatsReport::MediaStreamTrackStats>>(WTFMove(stats));
- } else if (rtcStats.type() == webrtc::RTCDataChannelStats::kType) {
- RTCStatsReport::DataChannelStats stats;
- fillRTCDataChannelStats(stats, static_cast<const webrtc::RTCDataChannelStats&>(rtcStats));
- report->addStats<IDLDictionary<RTCStatsReport::DataChannelStats>>(WTFMove(stats));
- } else if (rtcStats.type() == webrtc::RTCIceCandidatePairStats::kType) {
- RTCStatsReport::IceCandidatePairStats stats;
- fillRTCIceCandidatePairStats(stats, static_cast<const webrtc::RTCIceCandidatePairStats&>(rtcStats));
- report->addStats<IDLDictionary<RTCStatsReport::IceCandidatePairStats>>(WTFMove(stats));
- } else if (rtcStats.type() == webrtc::RTCCertificateStats::kType) {
- RTCStatsReport::CertificateStats stats;
- fillRTCCertificateStats(stats, static_cast<const webrtc::RTCCertificateStats&>(rtcStats));
- report->addStats<IDLDictionary<RTCStatsReport::CertificateStats>>(WTFMove(stats));
- }
- }
+ promise->resolve<IDLInterface<RTCStatsReport>>(report.releaseNonNull());
+ return true;
});
+ LibWebRTCProvider::callOnWebRTCSignalingThread([this, collector = WTFMove(collector)] {
+ if (m_backend)
+ m_backend->GetStats(collector.get());
+ });
}
static RTCSignalingState signalingState(webrtc::PeerConnectionInterface::SignalingState state)
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (235575 => 235576)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h 2018-08-31 23:22:47 UTC (rev 235575)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h 2018-08-31 23:27:20 UTC (rev 235576)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -83,7 +83,7 @@
void doSetRemoteDescription(RTCSessionDescription&);
void doCreateOffer(const RTCOfferOptions&);
void doCreateAnswer();
- void getStats(MediaStreamTrack*, const DeferredPromise&);
+ void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&);
std::unique_ptr<RTCDataChannelHandler> createDataChannel(const String&, const RTCDataChannelInit&);
bool addIceCandidate(webrtc::IceCandidateInterface& candidate) { return m_backend->AddIceCandidate(&candidate); }
@@ -154,20 +154,6 @@
Seconds statsLogInterval(int64_t) const;
#endif
- class StatsCollector : public webrtc::RTCStatsCollectorCallback {
- public:
- static rtc::scoped_refptr<StatsCollector> create(Ref<LibWebRTCMediaEndpoint>&& endpoint, const DeferredPromise& promise, MediaStreamTrack* track) { return new rtc::RefCountedObject<StatsCollector>(WTFMove(endpoint), promise, track); }
-
- StatsCollector(Ref<LibWebRTCMediaEndpoint>&&, const DeferredPromise&, MediaStreamTrack*);
-
- private:
- void OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>&) final;
-
- Ref<LibWebRTCMediaEndpoint> m_endpoint;
- const DeferredPromise& m_promise;
- String m_id;
- };
-
LibWebRTCPeerConnectionBackend& m_peerConnectionBackend;
webrtc::PeerConnectionFactoryInterface& m_peerConnectionFactory;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> m_backend;
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (235575 => 235576)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp 2018-08-31 23:22:47 UTC (rev 235575)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp 2018-08-31 23:27:20 UTC (rev 235576)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc.
+ * Copyright (C) 2017-2018 Apple Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,7 +29,6 @@
#include "Document.h"
#include "IceCandidate.h"
-#include "JSRTCStatsReport.h"
#include "LibWebRTCDataChannelHandler.h"
#include "LibWebRTCMediaEndpoint.h"
#include "MediaEndpointConfiguration.h"
@@ -128,28 +127,9 @@
void LibWebRTCPeerConnectionBackend::getStats(MediaStreamTrack* track, Ref<DeferredPromise>&& promise)
{
- if (m_endpoint->isStopped())
- return;
-
- auto& statsPromise = promise.get();
- m_statsPromises.add(&statsPromise, WTFMove(promise));
- m_endpoint->getStats(track, statsPromise);
+ m_endpoint->getStats(track, WTFMove(promise));
}
-void LibWebRTCPeerConnectionBackend::getStatsSucceeded(const DeferredPromise& promise, Ref<RTCStatsReport>&& report)
-{
- auto statsPromise = m_statsPromises.take(&promise);
- ASSERT(statsPromise);
- statsPromise.value()->resolve<IDLInterface<RTCStatsReport>>(WTFMove(report));
-}
-
-void LibWebRTCPeerConnectionBackend::getStatsFailed(const DeferredPromise& promise, Exception&& exception)
-{
- auto statsPromise = m_statsPromises.take(&promise);
- ASSERT(statsPromise);
- statsPromise.value()->reject(WTFMove(exception));
-}
-
void LibWebRTCPeerConnectionBackend::doSetLocalDescription(RTCSessionDescription& description)
{
m_endpoint->doSetLocalDescription(description);
@@ -200,7 +180,6 @@
m_audioSources.clear();
m_videoSources.clear();
- m_statsPromises.clear();
m_pendingReceivers.clear();
}
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h (235575 => 235576)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h 2018-08-31 23:22:47 UTC (rev 235575)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h 2018-08-31 23:27:20 UTC (rev 235576)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -86,7 +86,6 @@
void addVideoSource(Ref<RealtimeOutgoingVideoSource>&&);
void getStatsSucceeded(const DeferredPromise&, Ref<RTCStatsReport>&&);
- void getStatsFailed(const DeferredPromise&, Exception&&);
bool notifyAddedTrack(RTCRtpSender&) final;
void notifyRemovedTrack(RTCRtpSender&) final;
@@ -112,7 +111,6 @@
Vector<std::unique_ptr<webrtc::IceCandidateInterface>> m_pendingCandidates;
Vector<Ref<RealtimeOutgoingAudioSource>> m_audioSources;
Vector<Ref<RealtimeOutgoingVideoSource>> m_videoSources;
- HashMap<const DeferredPromise*, Ref<DeferredPromise>> m_statsPromises;
Vector<Ref<RTCRtpReceiver>> m_pendingReceivers;
};
Added: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp (0 => 235576)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp 2018-08-31 23:27:20 UTC (rev 235576)
@@ -0,0 +1,336 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LibWebRTCStatsCollector.h"
+
+#if USE(LIBWEBRTC)
+
+#include "JSRTCStatsReport.h"
+#include "Performance.h"
+#include <wtf/MainThread.h>
+
+namespace WebCore {
+
+LibWebRTCStatsCollector::LibWebRTCStatsCollector(CollectorCallback&& callback)
+ : m_callback(WTFMove(callback))
+{
+}
+
+LibWebRTCStatsCollector::~LibWebRTCStatsCollector()
+{
+ if (!m_callback)
+ return;
+
+ callOnMainThread([callback = WTFMove(m_callback)]() mutable {
+ callback({ });
+ });
+}
+
+static inline String fromStdString(const std::string& value)
+{
+ return String::fromUTF8(value.data(), value.length());
+}
+
+static inline void fillRTCStats(RTCStatsReport::Stats& stats, const webrtc::RTCStats& rtcStats)
+{
+ stats.timestamp = Performance::reduceTimeResolution(Seconds::fromMicroseconds(rtcStats.timestamp_us())).milliseconds();
+ stats.id = fromStdString(rtcStats.id());
+}
+
+static inline void fillRTCRTPStreamStats(RTCStatsReport::RTCRTPStreamStats& stats, const webrtc::RTCRTPStreamStats& rtcStats)
+{
+ fillRTCStats(stats, rtcStats);
+
+ if (rtcStats.ssrc.is_defined())
+ stats.ssrc = *rtcStats.ssrc;
+ if (rtcStats.associate_stats_id.is_defined())
+ stats.associateStatsId = fromStdString(*rtcStats.associate_stats_id);
+ 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.mediaTrackId = 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;
+}
+
+static inline void fillInboundRTPStreamStats(RTCStatsReport::InboundRTPStreamStats& stats, const webrtc::RTCInboundRTPStreamStats& rtcStats)
+{
+ fillRTCRTPStreamStats(stats, rtcStats);
+
+ 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;
+ if (rtcStats.fraction_lost.is_defined())
+ stats.fractionLost = *rtcStats.fraction_lost;
+ if (rtcStats.packets_discarded.is_defined())
+ stats.packetsDiscarded = *rtcStats.packets_discarded;
+ if (rtcStats.packets_repaired.is_defined())
+ stats.packetsRepaired = *rtcStats.packets_repaired;
+ if (rtcStats.burst_packets_lost.is_defined())
+ stats.burstPacketsLost = *rtcStats.burst_packets_lost;
+ if (rtcStats.burst_packets_discarded.is_defined())
+ stats.burstPacketsDiscarded = *rtcStats.burst_packets_discarded;
+ if (rtcStats.burst_loss_count.is_defined())
+ stats.burstLossCount = *rtcStats.burst_loss_count;
+ if (rtcStats.burst_discard_count.is_defined())
+ stats.burstDiscardCount = *rtcStats.burst_discard_count;
+ if (rtcStats.burst_loss_rate.is_defined())
+ stats.burstLossRate = *rtcStats.burst_loss_rate;
+ if (rtcStats.burst_discard_rate.is_defined())
+ stats.burstDiscardRate = *rtcStats.burst_discard_rate;
+ if (rtcStats.gap_loss_rate.is_defined())
+ stats.gapLossRate = *rtcStats.gap_loss_rate;
+ if (rtcStats.gap_discard_rate.is_defined())
+ stats.gapDiscardRate = *rtcStats.gap_discard_rate;
+ if (rtcStats.frames_decoded.is_defined())
+ stats.framesDecoded = *rtcStats.frames_decoded;
+}
+
+static inline void fillOutboundRTPStreamStats(RTCStatsReport::OutboundRTPStreamStats& stats, const webrtc::RTCOutboundRTPStreamStats& rtcStats)
+{
+ fillRTCRTPStreamStats(stats, rtcStats);
+
+ if (rtcStats.packets_sent.is_defined())
+ stats.packetsSent = *rtcStats.packets_sent;
+ if (rtcStats.bytes_sent.is_defined())
+ stats.bytesSent = *rtcStats.bytes_sent;
+ if (rtcStats.target_bitrate.is_defined())
+ stats.targetBitrate = *rtcStats.target_bitrate;
+ if (rtcStats.frames_encoded.is_defined())
+ stats.framesEncoded = *rtcStats.frames_encoded;
+}
+
+static inline void fillRTCMediaStreamTrackStats(RTCStatsReport::MediaStreamTrackStats& stats, const webrtc::RTCMediaStreamTrackStats& rtcStats)
+{
+ fillRTCStats(stats, rtcStats);
+
+ if (rtcStats.track_identifier.is_defined())
+ stats.trackIdentifier = fromStdString(*rtcStats.track_identifier);
+ if (rtcStats.remote_source.is_defined())
+ stats.remoteSource = *rtcStats.remote_source;
+ if (rtcStats.ended.is_defined())
+ stats.ended = *rtcStats.ended;
+ if (rtcStats.detached.is_defined())
+ stats.detached = *rtcStats.detached;
+ if (rtcStats.frame_width.is_defined())
+ stats.frameWidth = *rtcStats.frame_width;
+ if (rtcStats.frame_height.is_defined())
+ stats.frameHeight = *rtcStats.frame_height;
+ if (rtcStats.frames_per_second.is_defined())
+ stats.framesPerSecond = *rtcStats.frames_per_second;
+ if (rtcStats.frames_sent.is_defined())
+ stats.framesSent = *rtcStats.frames_sent;
+ if (rtcStats.frames_received.is_defined())
+ stats.framesReceived = *rtcStats.frames_received;
+ if (rtcStats.frames_decoded.is_defined())
+ stats.framesDecoded = *rtcStats.frames_decoded;
+ if (rtcStats.frames_dropped.is_defined())
+ stats.framesDropped = *rtcStats.frames_dropped;
+ if (rtcStats.partial_frames_lost.is_defined())
+ stats.partialFramesLost = *rtcStats.partial_frames_lost;
+ if (rtcStats.full_frames_lost.is_defined())
+ stats.fullFramesLost = *rtcStats.full_frames_lost;
+ if (rtcStats.audio_level.is_defined())
+ stats.audioLevel = *rtcStats.audio_level;
+ if (rtcStats.echo_return_loss.is_defined())
+ stats.echoReturnLoss = *rtcStats.echo_return_loss;
+ if (rtcStats.echo_return_loss_enhancement.is_defined())
+ stats.echoReturnLossEnhancement = *rtcStats.echo_return_loss_enhancement;
+}
+
+static inline void fillRTCDataChannelStats(RTCStatsReport::DataChannelStats& stats, const webrtc::RTCDataChannelStats& rtcStats)
+{
+ fillRTCStats(stats, rtcStats);
+
+ if (rtcStats.label.is_defined())
+ stats.label = fromStdString(*rtcStats.label);
+ if (rtcStats.protocol.is_defined())
+ stats.protocol = fromStdString(*rtcStats.protocol);
+ if (rtcStats.datachannelid.is_defined())
+ stats.datachannelid = *rtcStats.datachannelid;
+ if (rtcStats.state.is_defined())
+ stats.state = fromStdString(*rtcStats.state);
+ if (rtcStats.messages_sent.is_defined())
+ stats.messagesSent = *rtcStats.messages_sent;
+ if (rtcStats.bytes_sent.is_defined())
+ stats.bytesSent = *rtcStats.bytes_sent;
+ if (rtcStats.messages_received.is_defined())
+ stats.messagesReceived = *rtcStats.messages_received;
+ if (rtcStats.bytes_received.is_defined())
+ stats.bytesReceived = *rtcStats.bytes_received;
+}
+
+static inline RTCStatsReport::IceCandidatePairState iceCandidatePairState(const std::string& state)
+{
+ if (state == "frozen")
+ return RTCStatsReport::IceCandidatePairState::Frozen;
+ if (state == "waiting")
+ return RTCStatsReport::IceCandidatePairState::Waiting;
+ if (state == "in-progress")
+ return RTCStatsReport::IceCandidatePairState::Inprogress;
+ if (state == "failed")
+ return RTCStatsReport::IceCandidatePairState::Failed;
+ if (state == "succeeded")
+ return RTCStatsReport::IceCandidatePairState::Succeeded;
+ if (state == "cancelled")
+ return RTCStatsReport::IceCandidatePairState::Cancelled;
+ ASSERT_NOT_REACHED();
+ return RTCStatsReport::IceCandidatePairState::Frozen;
+}
+
+static inline void fillRTCIceCandidatePairStats(RTCStatsReport::IceCandidatePairStats& stats, const webrtc::RTCIceCandidatePairStats& rtcStats)
+{
+ fillRTCStats(stats, rtcStats);
+
+ if (rtcStats.transport_id.is_defined())
+ stats.transportId = fromStdString(*rtcStats.transport_id);
+ if (rtcStats.local_candidate_id.is_defined())
+ stats.localCandidateId = fromStdString(*rtcStats.local_candidate_id);
+ if (rtcStats.remote_candidate_id.is_defined())
+ stats.remoteCandidateId = fromStdString(*rtcStats.remote_candidate_id);
+ if (rtcStats.state.is_defined())
+ stats.state = iceCandidatePairState(*rtcStats.state);
+
+ if (rtcStats.priority.is_defined())
+ stats.priority = *rtcStats.priority;
+ if (rtcStats.nominated.is_defined())
+ stats.nominated = *rtcStats.nominated;
+ if (rtcStats.writable.is_defined())
+ stats.writable = *rtcStats.writable;
+ if (rtcStats.readable.is_defined())
+ stats.readable = *rtcStats.readable;
+
+ if (rtcStats.bytes_sent.is_defined())
+ stats.bytesSent = *rtcStats.bytes_sent;
+ if (rtcStats.bytes_received.is_defined())
+ stats.bytesReceived = *rtcStats.bytes_received;
+ if (rtcStats.total_round_trip_time.is_defined())
+ stats.totalRoundTripTime = *rtcStats.total_round_trip_time;
+ if (rtcStats.current_round_trip_time.is_defined())
+ stats.currentRoundTripTime = *rtcStats.current_round_trip_time;
+ if (rtcStats.available_outgoing_bitrate.is_defined())
+ stats.availableOutgoingBitrate = *rtcStats.available_outgoing_bitrate;
+ if (rtcStats.available_incoming_bitrate.is_defined())
+ stats.availableIncomingBitrate = *rtcStats.available_incoming_bitrate;
+
+ if (rtcStats.requests_received.is_defined())
+ stats.requestsReceived = *rtcStats.requests_received;
+ if (rtcStats.requests_sent.is_defined())
+ stats.requestsSent = *rtcStats.requests_sent;
+ if (rtcStats.responses_received.is_defined())
+ stats.responsesReceived = *rtcStats.responses_received;
+ if (rtcStats.responses_sent.is_defined())
+ stats.responsesSent = *rtcStats.responses_sent;
+
+ if (rtcStats.requests_received.is_defined())
+ stats.retransmissionsReceived = *rtcStats.requests_received;
+ if (rtcStats.requests_sent.is_defined())
+ stats.retransmissionsSent = *rtcStats.requests_sent;
+ if (rtcStats.responses_received.is_defined())
+ stats.consentRequestsReceived = *rtcStats.responses_received;
+ if (rtcStats.responses_sent.is_defined())
+ stats.consentRequestsSent = *rtcStats.responses_sent;
+ if (rtcStats.responses_received.is_defined())
+ stats.consentResponsesReceived = *rtcStats.responses_received;
+ if (rtcStats.responses_sent.is_defined())
+ stats.consentResponsesSent = *rtcStats.responses_sent;
+}
+
+static inline void fillRTCCertificateStats(RTCStatsReport::CertificateStats& stats, const webrtc::RTCCertificateStats& rtcStats)
+{
+ fillRTCStats(stats, rtcStats);
+
+ if (rtcStats.fingerprint.is_defined())
+ stats.fingerprint = fromStdString(*rtcStats.fingerprint);
+ if (rtcStats.fingerprint_algorithm.is_defined())
+ stats.fingerprintAlgorithm = fromStdString(*rtcStats.fingerprint_algorithm);
+ if (rtcStats.base64_certificate.is_defined())
+ stats.base64Certificate = fromStdString(*rtcStats.base64_certificate);
+ if (rtcStats.issuer_certificate_id.is_defined())
+ stats.issuerCertificateId = fromStdString(*rtcStats.issuer_certificate_id);
+}
+void LibWebRTCStatsCollector::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& rtcReport)
+{
+ callOnMainThread([protectedThis = rtc::scoped_refptr<LibWebRTCStatsCollector>(this), rtcReport] {
+ auto report = RTCStatsReport::create();
+ if (!protectedThis->m_callback(report.copyRef()))
+ return;
+
+ ASSERT(report->backingMap());
+
+ for (const auto& rtcStats : *rtcReport) {
+ if (rtcStats.type() == webrtc::RTCInboundRTPStreamStats::kType) {
+ RTCStatsReport::InboundRTPStreamStats stats;
+ fillInboundRTPStreamStats(stats, static_cast<const webrtc::RTCInboundRTPStreamStats&>(rtcStats));
+ report->addStats<IDLDictionary<RTCStatsReport::InboundRTPStreamStats>>(WTFMove(stats));
+ } else if (rtcStats.type() == webrtc::RTCOutboundRTPStreamStats::kType) {
+ RTCStatsReport::OutboundRTPStreamStats stats;
+ fillOutboundRTPStreamStats(stats, static_cast<const webrtc::RTCOutboundRTPStreamStats&>(rtcStats));
+ report->addStats<IDLDictionary<RTCStatsReport::OutboundRTPStreamStats>>(WTFMove(stats));
+ } else if (rtcStats.type() == webrtc::RTCMediaStreamTrackStats::kType) {
+ RTCStatsReport::MediaStreamTrackStats stats;
+ fillRTCMediaStreamTrackStats(stats, static_cast<const webrtc::RTCMediaStreamTrackStats&>(rtcStats));
+ report->addStats<IDLDictionary<RTCStatsReport::MediaStreamTrackStats>>(WTFMove(stats));
+ } else if (rtcStats.type() == webrtc::RTCDataChannelStats::kType) {
+ RTCStatsReport::DataChannelStats stats;
+ fillRTCDataChannelStats(stats, static_cast<const webrtc::RTCDataChannelStats&>(rtcStats));
+ report->addStats<IDLDictionary<RTCStatsReport::DataChannelStats>>(WTFMove(stats));
+ } else if (rtcStats.type() == webrtc::RTCIceCandidatePairStats::kType) {
+ RTCStatsReport::IceCandidatePairStats stats;
+ fillRTCIceCandidatePairStats(stats, static_cast<const webrtc::RTCIceCandidatePairStats&>(rtcStats));
+ report->addStats<IDLDictionary<RTCStatsReport::IceCandidatePairStats>>(WTFMove(stats));
+ } else if (rtcStats.type() == webrtc::RTCCertificateStats::kType) {
+ RTCStatsReport::CertificateStats stats;
+ fillRTCCertificateStats(stats, static_cast<const webrtc::RTCCertificateStats&>(rtcStats));
+ report->addStats<IDLDictionary<RTCStatsReport::CertificateStats>>(WTFMove(stats));
+ }
+ }
+ });
+}
+
+}; // namespace WTF
+
+
+#endif // USE(LIBWEBRTC)
Added: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h (0 => 235576)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h 2018-08-31 23:27:20 UTC (rev 235576)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(LIBWEBRTC)
+
+#include "LibWebRTCMacros.h"
+#include <wtf/CompletionHandler.h>
+#include <wtf/RefPtr.h>
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+
+#include <webrtc/pc/rtcstatscollector.h>
+
+#pragma GCC diagnostic pop
+
+namespace WebCore {
+
+class RTCStatsReport;
+
+class LibWebRTCStatsCollector : public webrtc::RTCStatsCollectorCallback {
+public:
+ using CollectorCallback = WTF::CompletionHandler<bool(RefPtr<RTCStatsReport>&&)>;
+ static rtc::scoped_refptr<LibWebRTCStatsCollector> create(CollectorCallback&& callback) { return new rtc::RefCountedObject<LibWebRTCStatsCollector>(WTFMove(callback)); }
+
+ explicit LibWebRTCStatsCollector(CollectorCallback&&);
+ ~LibWebRTCStatsCollector();
+
+private:
+ void OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>&) final;
+
+ CollectorCallback m_callback;
+};
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (235575 => 235576)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-08-31 23:22:47 UTC (rev 235575)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-08-31 23:27:20 UTC (rev 235576)
@@ -1125,6 +1125,7 @@
41D129D31F3D0F1600D15E47 /* CacheStorageConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */; settings = {ATTRIBUTES = (Private, ); }; };
41D129D51F3D0F6900D15E47 /* CacheStorageProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D129D41F3D0F6600D15E47 /* CacheStorageProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F54F831C50C4F600338488 /* FetchHeaders.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 41D28D0D2139E05800F4206F /* LibWebRTCStatsCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D28D0B2139E01D00F4206F /* LibWebRTCStatsCollector.cpp */; };
41DEFCB61E56C1BD000D9E5F /* JSDOMMapLike.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DEFCB41E56C1B9000D9E5F /* JSDOMMapLike.h */; };
41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E1B1CB0FF5986900576B3B /* AbstractWorker.h */; };
41F062140F5F192600A07EAC /* InspectorDatabaseResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */; };
@@ -7334,6 +7335,8 @@
41D129CA1F3D0EE300D15E47 /* CacheStorageRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageRecord.h; sourceTree = "<group>"; };
41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageConnection.h; sourceTree = "<group>"; };
41D129D41F3D0F6600D15E47 /* CacheStorageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageProvider.h; sourceTree = "<group>"; };
+ 41D28D0B2139E01D00F4206F /* LibWebRTCStatsCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCStatsCollector.cpp; path = libwebrtc/LibWebRTCStatsCollector.cpp; sourceTree = "<group>"; };
+ 41D28D0C2139E01E00F4206F /* LibWebRTCStatsCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCStatsCollector.h; path = libwebrtc/LibWebRTCStatsCollector.h; sourceTree = "<group>"; };
41D51BB21E4E2E8100131A5B /* LibWebRTCAudioFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCAudioFormat.h; path = libwebrtc/LibWebRTCAudioFormat.h; sourceTree = "<group>"; };
41DEFCB21E56C1B9000D9E5F /* JSDOMBindingInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = JSDOMBindingInternals.js; sourceTree = "<group>"; };
41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMMapLike.cpp; sourceTree = "<group>"; };
@@ -16827,6 +16830,8 @@
415A3B732138E264001B4BAA /* LibWebRTCObservers.h */,
417612AD1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.cpp */,
417612AE1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.h */,
+ 41D28D0B2139E01D00F4206F /* LibWebRTCStatsCollector.cpp */,
+ 41D28D0C2139E01E00F4206F /* LibWebRTCStatsCollector.h */,
);
name = libwebrtc;
sourceTree = "<group>";
@@ -31774,6 +31779,7 @@
DECA7E651F9EBD8300E3B661 /* UnifiedSource234.cpp in Sources */,
DECA7E661F9EBD8300E3B661 /* UnifiedSource235.cpp in Sources */,
DECA7E671F9EBD8300E3B661 /* UnifiedSource236.cpp in Sources */,
+ 41D28D0D2139E05800F4206F /* LibWebRTCStatsCollector.cpp in Sources */,
DECA7E681F9EBD8300E3B661 /* UnifiedSource237.cpp in Sources */,
DECA7E691F9EBD8300E3B661 /* UnifiedSource238.cpp in Sources */,
DECA7E6A1F9EBD8300E3B661 /* UnifiedSource239.cpp in Sources */,