Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: webrtc/stats/rtcstatscollector.h

Issue 2242043002: RTCStatsCollector and RTCPeerConnectionStats added (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Making sure the RTCPeerConnectionStats has the correct timestamp Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/stats/rtcstatscollector.h
diff --git a/webrtc/stats/rtcstatscollector.h b/webrtc/stats/rtcstatscollector.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed3bb1c10085c912154a3f28d4eb49311e2861e8
--- /dev/null
+++ b/webrtc/stats/rtcstatscollector.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_STATS_RTCSTATSCOLLECTOR_H_
+#define WEBRTC_STATS_RTCSTATSCOLLECTOR_H_
+
+#include <memory>
+
+#include "webrtc/api/peerconnection.h"
magjed_webrtc 2016/08/25 09:07:52 If this is only used for PeerConnection*, forward
hbos 2016/08/29 13:10:58 Done.
+#include "webrtc/api/rtcstats_objects.h"
+#include "webrtc/api/rtcstatsreport.h"
+#include "webrtc/base/refcount.h"
magjed_webrtc 2016/08/25 09:07:52 refcount is not needed?
hbos 2016/08/29 13:10:59 Done.
+#include "webrtc/base/scoped_ref_ptr.h"
+#include "webrtc/base/timing.h"
+
+namespace webrtc {
+
+// All calls to the collector and gathering of stats is performed on the
+// signaling thread. A stats report is cached for |cache_lifetime_| ms.
+class RTCStatsCollector {
+ public:
+ RTCStatsCollector(
magjed_webrtc 2016/08/25 09:07:52 You have only one mandatory argument, so I think y
hbos 2016/08/29 13:10:58 Done.
+ PeerConnection* pc,
+ double cache_lifetime = 0.05,
+ std::unique_ptr<rtc::Timing> timing = std::unique_ptr<rtc::Timing>(
+ new rtc::Timing()));
+
+ // Gets a recent stats report. If there is a report cached that is still fresh
+ // it is returned, otherwise new stats are gathered and returned. A report is
+ // considered fresh for |cache_lifetime_| ms. const RTCStatsReports are safe
+ // to use across multiple threads and may be destructed on any thread.
+ rtc::scoped_refptr<const RTCStatsReport> GetStatsReport();
+ // Clears the cache's reference to the most recent stats report. Subsequently
+ // calling |GetStatsReport| guarantees fresh stats.
+ void ClearCachedStatsReport();
+
+ private:
+ bool IsSignalingThread() const;
hta-webrtc 2016/08/26 09:28:57 Naming nit: This isn't a thread, so "IsSignalingTh
hbos 2016/08/29 13:10:58 Done.
+
+ std::unique_ptr<RTCPeerConnectionStats> ProducePeerConnectionStats() const;
+
+ PeerConnection* const pc_;
+ mutable std::unique_ptr<rtc::Timing> timing_;
+ // Time relative to the UNIX epoch (Jan 1, 1970, UTC), in seconds.
+ double cache_timestamp_;
+ double cache_lifetime_; // In seconds.
+ rtc::scoped_refptr<const RTCStatsReport> cached_report_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_STATS_RTCSTATSCOLLECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698