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