| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } // namespace cricket | 34 } // namespace cricket |
| 35 | 35 |
| 36 namespace rtc { | 36 namespace rtc { |
| 37 class SSLCertificate; | 37 class SSLCertificate; |
| 38 } // namespace rtc | 38 } // namespace rtc |
| 39 | 39 |
| 40 namespace webrtc { | 40 namespace webrtc { |
| 41 | 41 |
| 42 class PeerConnection; | 42 class PeerConnection; |
| 43 struct SessionStats; | 43 struct SessionStats; |
| 44 struct ChannelNamePairs; |
| 44 | 45 |
| 45 class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface { | 46 class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface { |
| 46 public: | 47 public: |
| 47 virtual ~RTCStatsCollectorCallback() {} | 48 virtual ~RTCStatsCollectorCallback() {} |
| 48 | 49 |
| 49 virtual void OnStatsDelivered( | 50 virtual void OnStatsDelivered( |
| 50 const rtc::scoped_refptr<const RTCStatsReport>& report) = 0; | 51 const rtc::scoped_refptr<const RTCStatsReport>& report) = 0; |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 // All public methods of the collector are to be called on the signaling thread. | 54 // All public methods of the collector are to be called on the signaling thread. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 }; | 91 }; |
| 91 struct MediaInfo { | 92 struct MediaInfo { |
| 92 rtc::Optional<cricket::VoiceMediaInfo> voice; | 93 rtc::Optional<cricket::VoiceMediaInfo> voice; |
| 93 rtc::Optional<cricket::VideoMediaInfo> video; | 94 rtc::Optional<cricket::VideoMediaInfo> video; |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 void AddPartialResults_s(rtc::scoped_refptr<RTCStatsReport> partial_report); | 97 void AddPartialResults_s(rtc::scoped_refptr<RTCStatsReport> partial_report); |
| 97 void DeliverCachedReport(); | 98 void DeliverCachedReport(); |
| 98 | 99 |
| 99 // Produces |RTCCertificateStats|. | 100 // Produces |RTCCertificateStats|. |
| 100 void ProduceCertificateStats_s( | 101 void ProduceCertificateStats_n( |
| 101 int64_t timestamp_us, | 102 int64_t timestamp_us, |
| 102 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, | 103 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, |
| 103 RTCStatsReport* report) const; | 104 RTCStatsReport* report) const; |
| 104 // Produces |RTCCodecStats|. | 105 // Produces |RTCCodecStats|. |
| 105 void ProduceCodecStats_s( | 106 void ProduceCodecStats_n( |
| 106 int64_t timestamp_us, const MediaInfo& media_info, | 107 int64_t timestamp_us, const MediaInfo& media_info, |
| 107 RTCStatsReport* report) const; | 108 RTCStatsReport* report) const; |
| 108 // Produces |RTCDataChannelStats|. | 109 // Produces |RTCDataChannelStats|. |
| 109 void ProduceDataChannelStats_s( | 110 void ProduceDataChannelStats_s( |
| 110 int64_t timestamp_us, RTCStatsReport* report) const; | 111 int64_t timestamp_us, RTCStatsReport* report) const; |
| 111 // Produces |RTCIceCandidatePairStats| and |RTCIceCandidateStats|. | 112 // Produces |RTCIceCandidatePairStats| and |RTCIceCandidateStats|. |
| 112 void ProduceIceCandidateAndPairStats_s( | 113 void ProduceIceCandidateAndPairStats_n( |
| 113 int64_t timestamp_us, const SessionStats& session_stats, | 114 int64_t timestamp_us, const SessionStats& session_stats, |
| 114 RTCStatsReport* report) const; | 115 RTCStatsReport* report) const; |
| 115 // Produces |RTCMediaStreamStats| and |RTCMediaStreamTrackStats|. | 116 // Produces |RTCMediaStreamStats| and |RTCMediaStreamTrackStats|. |
| 116 void ProduceMediaStreamAndTrackStats_s( | 117 void ProduceMediaStreamAndTrackStats_s( |
| 117 int64_t timestamp_us, RTCStatsReport* report) const; | 118 int64_t timestamp_us, RTCStatsReport* report) const; |
| 118 // Produces |RTCPeerConnectionStats|. | 119 // Produces |RTCPeerConnectionStats|. |
| 119 void ProducePeerConnectionStats_s( | 120 void ProducePeerConnectionStats_s( |
| 120 int64_t timestamp_us, RTCStatsReport* report) const; | 121 int64_t timestamp_us, RTCStatsReport* report) const; |
| 121 // Produces |RTCInboundRTPStreamStats| and |RTCOutboundRTPStreamStats|. | 122 // Produces |RTCInboundRTPStreamStats| and |RTCOutboundRTPStreamStats|. |
| 122 void ProduceRTPStreamStats_s( | 123 void ProduceRTPStreamStats_n( |
| 123 int64_t timestamp_us, const SessionStats& session_stats, | 124 int64_t timestamp_us, const SessionStats& session_stats, |
| 124 const MediaInfo& media_info, RTCStatsReport* report) const; | 125 const MediaInfo& media_info, RTCStatsReport* report) const; |
| 125 // Produces |RTCTransportStats|. | 126 // Produces |RTCTransportStats|. |
| 126 void ProduceTransportStats_s( | 127 void ProduceTransportStats_n( |
| 127 int64_t timestamp_us, const SessionStats& session_stats, | 128 int64_t timestamp_us, const SessionStats& session_stats, |
| 128 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, | 129 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, |
| 129 RTCStatsReport* report) const; | 130 RTCStatsReport* report) const; |
| 130 | 131 |
| 131 // Helper function to stats-producing functions. | 132 // Helper function to stats-producing functions. |
| 132 std::map<std::string, CertificateStatsPair> | 133 std::map<std::string, CertificateStatsPair> |
| 133 PrepareTransportCertificateStats(const SessionStats& session_stats) const; | 134 PrepareTransportCertificateStats_n(const SessionStats& session_stats) const; |
| 134 MediaInfo PrepareMediaInfo(const SessionStats& session_stats) const; | 135 std::unique_ptr<MediaInfo> PrepareMediaInfo_s() const; |
| 135 | 136 |
| 136 // Slots for signals (sigslot) that are wired up to |pc_|. | 137 // Slots for signals (sigslot) that are wired up to |pc_|. |
| 137 void OnDataChannelCreated(DataChannel* channel); | 138 void OnDataChannelCreated(DataChannel* channel); |
| 138 // Slots for signals (sigslot) that are wired up to |channel|. | 139 // Slots for signals (sigslot) that are wired up to |channel|. |
| 139 void OnDataChannelOpened(DataChannel* channel); | 140 void OnDataChannelOpened(DataChannel* channel); |
| 140 void OnDataChannelClosed(DataChannel* channel); | 141 void OnDataChannelClosed(DataChannel* channel); |
| 141 | 142 |
| 142 PeerConnection* const pc_; | 143 PeerConnection* const pc_; |
| 143 rtc::Thread* const signaling_thread_; | 144 rtc::Thread* const signaling_thread_; |
| 144 rtc::Thread* const worker_thread_; | 145 rtc::Thread* const worker_thread_; |
| 145 rtc::Thread* const network_thread_; | 146 rtc::Thread* const network_thread_; |
| 146 rtc::AsyncInvoker invoker_; | 147 rtc::AsyncInvoker invoker_; |
| 147 | 148 |
| 148 int num_pending_partial_reports_; | 149 int num_pending_partial_reports_; |
| 149 int64_t partial_report_timestamp_us_; | 150 int64_t partial_report_timestamp_us_; |
| 150 rtc::scoped_refptr<RTCStatsReport> partial_report_; | 151 rtc::scoped_refptr<RTCStatsReport> partial_report_; |
| 151 std::vector<rtc::scoped_refptr<RTCStatsCollectorCallback>> callbacks_; | 152 std::vector<rtc::scoped_refptr<RTCStatsCollectorCallback>> callbacks_; |
| 152 | 153 |
| 154 // Set in |GetStatsReport|, used in |ProducePartialResultsOnNetworkThread| |
| 155 // (not passed as arguments to avoid copies). This is thread safe - it is set |
| 156 // at the start of |GetStatsReport| after making sure there are no pending |
| 157 // stats requests in progress. |
| 158 std::unique_ptr<ChannelNamePairs> channel_name_pairs_; |
| 159 std::unique_ptr<MediaInfo> media_info_; |
| 160 |
| 153 // A timestamp, in microseconds, that is based on a timer that is | 161 // A timestamp, in microseconds, that is based on a timer that is |
| 154 // monotonically increasing. That is, even if the system clock is modified the | 162 // monotonically increasing. That is, even if the system clock is modified the |
| 155 // difference between the timer and this timestamp is how fresh the cached | 163 // difference between the timer and this timestamp is how fresh the cached |
| 156 // report is. | 164 // report is. |
| 157 int64_t cache_timestamp_us_; | 165 int64_t cache_timestamp_us_; |
| 158 int64_t cache_lifetime_us_; | 166 int64_t cache_lifetime_us_; |
| 159 rtc::scoped_refptr<const RTCStatsReport> cached_report_; | 167 rtc::scoped_refptr<const RTCStatsReport> cached_report_; |
| 160 | 168 |
| 161 // Data recorded and maintained by the stats collector during its lifetime. | 169 // Data recorded and maintained by the stats collector during its lifetime. |
| 162 // Some stats are produced from this record instead of other components. | 170 // Some stats are produced from this record instead of other components. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 179 }; | 187 }; |
| 180 | 188 |
| 181 const char* CandidateTypeToRTCIceCandidateTypeForTesting( | 189 const char* CandidateTypeToRTCIceCandidateTypeForTesting( |
| 182 const std::string& type); | 190 const std::string& type); |
| 183 const char* DataStateToRTCDataChannelStateForTesting( | 191 const char* DataStateToRTCDataChannelStateForTesting( |
| 184 DataChannelInterface::DataState state); | 192 DataChannelInterface::DataState state); |
| 185 | 193 |
| 186 } // namespace webrtc | 194 } // namespace webrtc |
| 187 | 195 |
| 188 #endif // WEBRTC_API_RTCSTATSCOLLECTOR_H_ | 196 #endif // WEBRTC_API_RTCSTATSCOLLECTOR_H_ |
| OLD | NEW |