- Revision
- 217888
- Author
- [email protected]
- Date
- 2017-06-07 09:55:09 -0700 (Wed, 07 Jun 2017)
Log Message
Add WebRTC stats logging
https://bugs.webkit.org/show_bug.cgi?id=173045
Patch by Youenn Fablet <[email protected]> on 2017-06-07
Reviewed by Eric Carlson.
Source/ThirdParty/libwebrtc:
* Source/webrtc/api/stats/rtcstats.h: Exporting RTCStats ToString.
Source/WebCore:
No change of behavior.
Do release logging of WebRTC stats once remote description is set.
Do logging every second for the first 30 seconds.
After 30 seconds, do release logging of these stats every 5 seconds.
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
(WebCore::LibWebRTCMediaEndpoint::stop):
(WebCore::LibWebRTCMediaEndpoint::gatherStatsForLogging):
(WebCore::LibWebRTCMediaEndpoint::OnStatsDelivered):
(WebCore::LibWebRTCMediaEndpoint::startLoggingStats):
(WebCore::LibWebRTCMediaEndpoint::stopLoggingStats):
(WebCore::LibWebRTCPeerConnectionBackend::doSetRemoteDescription):
Modified Paths
Diff
Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (217887 => 217888)
--- trunk/Source/ThirdParty/libwebrtc/ChangeLog 2017-06-07 16:54:05 UTC (rev 217887)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog 2017-06-07 16:55:09 UTC (rev 217888)
@@ -1,3 +1,12 @@
+2017-06-07 Youenn Fablet <[email protected]>
+
+ Add WebRTC stats logging
+ https://bugs.webkit.org/show_bug.cgi?id=173045
+
+ Reviewed by Eric Carlson.
+
+ * Source/webrtc/api/stats/rtcstats.h: Exporting RTCStats ToString.
+
2017-05-28 Dan Bernstein <[email protected]>
[Xcode] ALWAYS_SEARCH_USER_PATHS is set to YES
Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/api/stats/rtcstats.h (217887 => 217888)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/api/stats/rtcstats.h 2017-06-07 16:54:05 UTC (rev 217887)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/api/stats/rtcstats.h 2017-06-07 16:55:09 UTC (rev 217888)
@@ -75,7 +75,7 @@
// Creates a human readable string representation of the stats object, listing
// all of its members (names and values).
- std::string ToString() const;
+ WEBRTC_DYLIB_EXPORT std::string ToString() const;
// Downcasts the stats object to an |RTCStats| subclass |T|. DCHECKs that the
// object is of type |T|.
Modified: trunk/Source/WebCore/ChangeLog (217887 => 217888)
--- trunk/Source/WebCore/ChangeLog 2017-06-07 16:54:05 UTC (rev 217887)
+++ trunk/Source/WebCore/ChangeLog 2017-06-07 16:55:09 UTC (rev 217888)
@@ -1,3 +1,25 @@
+2017-06-07 Youenn Fablet <[email protected]>
+
+ Add WebRTC stats logging
+ https://bugs.webkit.org/show_bug.cgi?id=173045
+
+ Reviewed by Eric Carlson.
+
+ No change of behavior.
+
+ Do release logging of WebRTC stats once remote description is set.
+ Do logging every second for the first 30 seconds.
+ After 30 seconds, do release logging of these stats every 5 seconds.
+
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+ (WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
+ (WebCore::LibWebRTCMediaEndpoint::stop):
+ (WebCore::LibWebRTCMediaEndpoint::gatherStatsForLogging):
+ (WebCore::LibWebRTCMediaEndpoint::OnStatsDelivered):
+ (WebCore::LibWebRTCMediaEndpoint::startLoggingStats):
+ (WebCore::LibWebRTCMediaEndpoint::stopLoggingStats):
+ (WebCore::LibWebRTCPeerConnectionBackend::doSetRemoteDescription):
+
2017-06-07 Per Arne Vollan <[email protected]>
Support removal of authentication data through the Website data store API.
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (217887 => 217888)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2017-06-07 16:54:05 UTC (rev 217887)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2017-06-07 16:55:09 UTC (rev 217888)
@@ -33,6 +33,7 @@
#include "LibWebRTCDataChannelHandler.h"
#include "LibWebRTCPeerConnectionBackend.h"
#include "LibWebRTCProvider.h"
+#include "Logging.h"
#include "MediaStreamEvent.h"
#include "NotImplemented.h"
#include "PlatformStrategies.h"
@@ -63,6 +64,7 @@
, m_createSessionDescriptionObserver(*this)
, m_setLocalSessionDescriptionObserver(*this)
, m_setRemoteSessionDescriptionObserver(*this)
+ , m_statsLogTimer(*this, &LibWebRTCMediaEndpoint::gatherStatsForLogging)
{
ASSERT(m_backend);
ASSERT(client.factory());
@@ -161,6 +163,8 @@
return;
}
m_backend->SetRemoteDescription(&m_setRemoteSessionDescriptionObserver, sessionDescription.release());
+
+ startLoggingStats();
}
void LibWebRTCMediaEndpoint::addTrack(RTCRtpSender& sender, MediaStreamTrack& track, const Vector<String>& mediaStreamIds)
@@ -722,6 +726,8 @@
void LibWebRTCMediaEndpoint::stop()
{
+ stopLoggingStats();
+
ASSERT(m_backend);
m_backend->Close();
m_backend = nullptr;
@@ -983,6 +989,47 @@
return fillRtpParameters(rtcSender->GetParameters());
}
+void LibWebRTCMediaEndpoint::gatherStatsForLogging()
+{
+ m_backend->GetStats(this);
+}
+
+void LibWebRTCMediaEndpoint::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report)
+{
+ if (!m_statsTimestamp)
+ m_statsTimestamp = report->timestamp_us();
+ else if (m_statsLogTimer.repeatInterval() == 1_s && (report->timestamp_us() - m_statsTimestamp) > 30000000) {
+ callOnMainThread([protectedThis = makeRef(*this)] {
+ protectedThis->m_statsLogTimer.augmentRepeatInterval(4_s);
+ });
+ }
+
+#if !RELEASE_LOG_DISABLED
+ // Log stats once every second for the 30 seconds, then drop to once every 5 seconds.
+ for (auto iterator = report->begin(); iterator != report->end(); ++iterator) {
+ if (iterator->type() == webrtc::RTCCodecStats::kType)
+ continue;
+ RELEASE_LOG(WebRTC, "WebRTC stats for %p: %s", this, iterator->ToString().c_str());
+ }
+#else
+ UNUSED_PARAM(report);
+#endif
+}
+
+void LibWebRTCMediaEndpoint::startLoggingStats()
+{
+#if !RELEASE_LOG_DISABLED
+ if (m_statsLogTimer.isActive())
+ m_statsLogTimer.stop();
+ m_statsLogTimer.startRepeating(1_s);
+#endif
+}
+
+void LibWebRTCMediaEndpoint::stopLoggingStats()
+{
+ m_statsLogTimer.stop();
+}
+
} // namespace WebCore
#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (217887 => 217888)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h 2017-06-07 16:54:05 UTC (rev 217887)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h 2017-06-07 16:55:09 UTC (rev 217888)
@@ -31,6 +31,7 @@
#include "RTCRtpReceiver.h"
#include "RealtimeOutgoingAudioSource.h"
#include "RealtimeOutgoingVideoSource.h"
+#include <Timer.h>
#include <webrtc/api/jsep.h>
#include <webrtc/api/peerconnectioninterface.h>
@@ -56,7 +57,7 @@
class MediaStreamTrack;
class RTCSessionDescription;
-class LibWebRTCMediaEndpoint : public ThreadSafeRefCounted<LibWebRTCMediaEndpoint>, private webrtc::PeerConnectionObserver {
+class LibWebRTCMediaEndpoint : public ThreadSafeRefCounted<LibWebRTCMediaEndpoint>, private webrtc::PeerConnectionObserver, private webrtc::RTCStatsCollectorCallback {
public:
static Ref<LibWebRTCMediaEndpoint> create(LibWebRTCPeerConnectionBackend& peerConnection, LibWebRTCProvider& client) { return adoptRef(*new LibWebRTCMediaEndpoint(peerConnection, client)); }
virtual ~LibWebRTCMediaEndpoint() { }
@@ -110,6 +111,11 @@
void removeRemoteStream(webrtc::MediaStreamInterface&);
void addDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface>&&);
+ void OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>&) final;
+ void gatherStatsForLogging();
+ void startLoggingStats();
+ void stopLoggingStats();
+
MediaStream& mediaStreamFromRTCStream(webrtc::MediaStreamInterface&);
int AddRef() const { ref(); return static_cast<int>(refCount()); }
@@ -182,6 +188,8 @@
HashMap<RTCRtpSender*, rtc::scoped_refptr<webrtc::RtpSenderInterface>> m_senders;
bool m_isInitiator { false };
+ Timer m_statsLogTimer;
+ int64_t m_statsTimestamp { 0 };
};
} // namespace WebCore