| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_API_RTCSTATSCOLLECTOR_H_ | 11 #ifndef WEBRTC_API_RTCSTATSCOLLECTOR_H_ |
| 12 #define WEBRTC_API_RTCSTATSCOLLECTOR_H_ | 12 #define WEBRTC_API_RTCSTATSCOLLECTOR_H_ |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "webrtc/api/stats/rtcstats_objects.h" | 17 #include "webrtc/api/stats/rtcstats_objects.h" |
| 18 #include "webrtc/api/stats/rtcstatsreport.h" | 18 #include "webrtc/api/stats/rtcstatsreport.h" |
| 19 #include "webrtc/base/asyncinvoker.h" | 19 #include "webrtc/base/asyncinvoker.h" |
| 20 #include "webrtc/base/refcount.h" | 20 #include "webrtc/base/refcount.h" |
| 21 #include "webrtc/base/scoped_ref_ptr.h" | 21 #include "webrtc/base/scoped_ref_ptr.h" |
| 22 #include "webrtc/base/timeutils.h" | 22 #include "webrtc/base/timeutils.h" |
| 23 | 23 |
| 24 namespace cricket { |
| 25 class Candidate; |
| 26 } // namespace cricket |
| 27 |
| 24 namespace rtc { | 28 namespace rtc { |
| 25 | |
| 26 class SSLCertificate; | 29 class SSLCertificate; |
| 27 | |
| 28 } // namespace rtc | 30 } // namespace rtc |
| 29 | 31 |
| 30 namespace webrtc { | 32 namespace webrtc { |
| 31 | 33 |
| 32 class PeerConnection; | 34 class PeerConnection; |
| 33 struct SessionStats; | 35 struct SessionStats; |
| 34 | 36 |
| 35 class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface { | 37 class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface { |
| 36 public: | 38 public: |
| 37 virtual ~RTCStatsCollectorCallback() {} | 39 virtual ~RTCStatsCollectorCallback() {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 virtual void ProducePartialResultsOnNetworkThread(int64_t timestamp_us); | 71 virtual void ProducePartialResultsOnNetworkThread(int64_t timestamp_us); |
| 70 | 72 |
| 71 // Can be called on any thread. | 73 // Can be called on any thread. |
| 72 void AddPartialResults( | 74 void AddPartialResults( |
| 73 const rtc::scoped_refptr<RTCStatsReport>& partial_report); | 75 const rtc::scoped_refptr<RTCStatsReport>& partial_report); |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 void AddPartialResults_s(rtc::scoped_refptr<RTCStatsReport> partial_report); | 78 void AddPartialResults_s(rtc::scoped_refptr<RTCStatsReport> partial_report); |
| 77 void DeliverCachedReport(); | 79 void DeliverCachedReport(); |
| 78 | 80 |
| 81 // Produces |RTCCertificateStats|. |
| 79 void ProduceCertificateStats_s( | 82 void ProduceCertificateStats_s( |
| 80 int64_t timestamp_us, const SessionStats& session_stats, | 83 int64_t timestamp_us, const SessionStats& session_stats, |
| 81 RTCStatsReport* report) const; | 84 RTCStatsReport* report) const; |
| 82 void ProduceCertificateStatsFromSSLCertificateAndChain_s( | 85 void ProduceCertificateStatsFromSSLCertificateAndChain_s( |
| 83 int64_t timestamp_us, const rtc::SSLCertificate& certificate, | 86 int64_t timestamp_us, const rtc::SSLCertificate& certificate, |
| 84 RTCStatsReport* report) const; | 87 RTCStatsReport* report) const; |
| 88 // Produces |RTCIceCandidateStats|. TODO(hbos): Should also produce |
| 89 // |RTCIceCandidatePairStats|. crbug.com/633550 |
| 90 void ProduceIceCandidateAndPairStats_s( |
| 91 int64_t timestamp_us, const SessionStats& session_stats, |
| 92 RTCStatsReport* report) const; |
| 93 const std::string& ProduceIceCandidateStats_s( |
| 94 int64_t timestamp_us, const cricket::Candidate& candidate, bool is_local, |
| 95 RTCStatsReport* report) const; |
| 96 // Produces |RTCPeerConnectionStats|. |
| 85 void ProducePeerConnectionStats_s( | 97 void ProducePeerConnectionStats_s( |
| 86 int64_t timestamp_us, RTCStatsReport* report) const; | 98 int64_t timestamp_us, RTCStatsReport* report) const; |
| 87 | 99 |
| 88 PeerConnection* const pc_; | 100 PeerConnection* const pc_; |
| 89 rtc::Thread* const signaling_thread_; | 101 rtc::Thread* const signaling_thread_; |
| 90 rtc::Thread* const worker_thread_; | 102 rtc::Thread* const worker_thread_; |
| 91 rtc::Thread* const network_thread_; | 103 rtc::Thread* const network_thread_; |
| 92 rtc::AsyncInvoker invoker_; | 104 rtc::AsyncInvoker invoker_; |
| 93 | 105 |
| 94 int num_pending_partial_reports_; | 106 int num_pending_partial_reports_; |
| 95 int64_t partial_report_timestamp_us_; | 107 int64_t partial_report_timestamp_us_; |
| 96 rtc::scoped_refptr<RTCStatsReport> partial_report_; | 108 rtc::scoped_refptr<RTCStatsReport> partial_report_; |
| 97 std::vector<rtc::scoped_refptr<RTCStatsCollectorCallback>> callbacks_; | 109 std::vector<rtc::scoped_refptr<RTCStatsCollectorCallback>> callbacks_; |
| 98 | 110 |
| 99 // A timestamp, in microseconds, that is based on a timer that is | 111 // A timestamp, in microseconds, that is based on a timer that is |
| 100 // monotonically increasing. That is, even if the system clock is modified the | 112 // monotonically increasing. That is, even if the system clock is modified the |
| 101 // difference between the timer and this timestamp is how fresh the cached | 113 // difference between the timer and this timestamp is how fresh the cached |
| 102 // report is. | 114 // report is. |
| 103 int64_t cache_timestamp_us_; | 115 int64_t cache_timestamp_us_; |
| 104 int64_t cache_lifetime_us_; | 116 int64_t cache_lifetime_us_; |
| 105 rtc::scoped_refptr<const RTCStatsReport> cached_report_; | 117 rtc::scoped_refptr<const RTCStatsReport> cached_report_; |
| 106 }; | 118 }; |
| 107 | 119 |
| 120 // Helper function, exposed for unittests. |
| 121 const char* CandidateTypeToRTCIceCandidateType(const std::string& type); |
| 122 |
| 108 } // namespace webrtc | 123 } // namespace webrtc |
| 109 | 124 |
| 110 #endif // WEBRTC_API_RTCSTATSCOLLECTOR_H_ | 125 #endif // WEBRTC_API_RTCSTATSCOLLECTOR_H_ |
| OLD | NEW |