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

Side by Side Diff: webrtc/api/rtcstatscollector.h

Issue 2610843003: RTC[In/Out]boundRTPStreamStats.mediaTrackId collected. (Closed)
Patch Set: Rebase with master Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « webrtc/api/rtcstats_integrationtest.cc ('k') | webrtc/api/rtcstatscollector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 14 #include <map>
15 #include <memory> 15 #include <memory>
16 #include <set> 16 #include <set>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/api/datachannel.h" 19 #include "webrtc/api/datachannel.h"
20 #include "webrtc/api/datachannelinterface.h" 20 #include "webrtc/api/datachannelinterface.h"
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/api/trackmediainfomap.h"
23 #include "webrtc/base/asyncinvoker.h" 24 #include "webrtc/base/asyncinvoker.h"
24 #include "webrtc/base/optional.h" 25 #include "webrtc/base/optional.h"
25 #include "webrtc/base/refcount.h" 26 #include "webrtc/base/refcount.h"
26 #include "webrtc/base/scoped_ref_ptr.h" 27 #include "webrtc/base/scoped_ref_ptr.h"
27 #include "webrtc/base/sigslot.h" 28 #include "webrtc/base/sigslot.h"
28 #include "webrtc/base/sslidentity.h" 29 #include "webrtc/base/sslidentity.h"
29 #include "webrtc/base/timeutils.h" 30 #include "webrtc/base/timeutils.h"
30 #include "webrtc/media/base/mediachannel.h" 31 #include "webrtc/media/base/mediachannel.h"
31 32
32 namespace cricket { 33 namespace cricket {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 // Can be called on any thread. 88 // Can be called on any thread.
88 void AddPartialResults( 89 void AddPartialResults(
89 const rtc::scoped_refptr<RTCStatsReport>& partial_report); 90 const rtc::scoped_refptr<RTCStatsReport>& partial_report);
90 91
91 private: 92 private:
92 struct CertificateStatsPair { 93 struct CertificateStatsPair {
93 std::unique_ptr<rtc::SSLCertificateStats> local; 94 std::unique_ptr<rtc::SSLCertificateStats> local;
94 std::unique_ptr<rtc::SSLCertificateStats> remote; 95 std::unique_ptr<rtc::SSLCertificateStats> remote;
95 }; 96 };
96 struct MediaInfo {
97 rtc::Optional<cricket::VoiceMediaInfo> voice;
98 rtc::Optional<cricket::VideoMediaInfo> video;
99 };
100 97
101 void AddPartialResults_s(rtc::scoped_refptr<RTCStatsReport> partial_report); 98 void AddPartialResults_s(rtc::scoped_refptr<RTCStatsReport> partial_report);
102 void DeliverCachedReport(); 99 void DeliverCachedReport();
103 100
104 // Produces |RTCCertificateStats|. 101 // Produces |RTCCertificateStats|.
105 void ProduceCertificateStats_n( 102 void ProduceCertificateStats_n(
106 int64_t timestamp_us, 103 int64_t timestamp_us,
107 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, 104 const std::map<std::string, CertificateStatsPair>& transport_cert_stats,
108 RTCStatsReport* report) const; 105 RTCStatsReport* report) const;
109 // Produces |RTCCodecStats|. 106 // Produces |RTCCodecStats|.
110 void ProduceCodecStats_n( 107 void ProduceCodecStats_n(
111 int64_t timestamp_us, const MediaInfo& media_info, 108 int64_t timestamp_us, const TrackMediaInfoMap& track_media_info_map,
112 RTCStatsReport* report) const; 109 RTCStatsReport* report) const;
113 // Produces |RTCDataChannelStats|. 110 // Produces |RTCDataChannelStats|.
114 void ProduceDataChannelStats_s( 111 void ProduceDataChannelStats_s(
115 int64_t timestamp_us, RTCStatsReport* report) const; 112 int64_t timestamp_us, RTCStatsReport* report) const;
116 // Produces |RTCIceCandidatePairStats| and |RTCIceCandidateStats|. 113 // Produces |RTCIceCandidatePairStats| and |RTCIceCandidateStats|.
117 void ProduceIceCandidateAndPairStats_n( 114 void ProduceIceCandidateAndPairStats_n(
118 int64_t timestamp_us, const SessionStats& session_stats, 115 int64_t timestamp_us, const SessionStats& session_stats,
119 RTCStatsReport* report) const; 116 RTCStatsReport* report) const;
120 // Produces |RTCMediaStreamStats| and |RTCMediaStreamTrackStats|. 117 // Produces |RTCMediaStreamStats| and |RTCMediaStreamTrackStats|.
121 void ProduceMediaStreamAndTrackStats_s( 118 void ProduceMediaStreamAndTrackStats_s(
122 int64_t timestamp_us, RTCStatsReport* report) const; 119 int64_t timestamp_us, RTCStatsReport* report) const;
123 // Produces |RTCPeerConnectionStats|. 120 // Produces |RTCPeerConnectionStats|.
124 void ProducePeerConnectionStats_s( 121 void ProducePeerConnectionStats_s(
125 int64_t timestamp_us, RTCStatsReport* report) const; 122 int64_t timestamp_us, RTCStatsReport* report) const;
126 // Produces |RTCInboundRTPStreamStats| and |RTCOutboundRTPStreamStats|. 123 // Produces |RTCInboundRTPStreamStats| and |RTCOutboundRTPStreamStats|.
127 void ProduceRTPStreamStats_n( 124 void ProduceRTPStreamStats_n(
128 int64_t timestamp_us, const SessionStats& session_stats, 125 int64_t timestamp_us, const SessionStats& session_stats,
129 const MediaInfo& media_info, RTCStatsReport* report) const; 126 const TrackMediaInfoMap& track_media_info_map,
127 RTCStatsReport* report) const;
130 // Produces |RTCTransportStats|. 128 // Produces |RTCTransportStats|.
131 void ProduceTransportStats_n( 129 void ProduceTransportStats_n(
132 int64_t timestamp_us, const SessionStats& session_stats, 130 int64_t timestamp_us, const SessionStats& session_stats,
133 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, 131 const std::map<std::string, CertificateStatsPair>& transport_cert_stats,
134 RTCStatsReport* report) const; 132 RTCStatsReport* report) const;
135 133
136 // Helper function to stats-producing functions. 134 // Helper function to stats-producing functions.
137 std::map<std::string, CertificateStatsPair> 135 std::map<std::string, CertificateStatsPair>
138 PrepareTransportCertificateStats_n(const SessionStats& session_stats) const; 136 PrepareTransportCertificateStats_n(const SessionStats& session_stats) const;
139 std::unique_ptr<MediaInfo> PrepareMediaInfo_s() const; 137 std::unique_ptr<TrackMediaInfoMap> PrepareTrackMediaInfoMap_s() const;
138 std::map<MediaStreamTrackInterface*, std::string> PrepareTrackToID_s() const;
140 139
141 // Slots for signals (sigslot) that are wired up to |pc_|. 140 // Slots for signals (sigslot) that are wired up to |pc_|.
142 void OnDataChannelCreated(DataChannel* channel); 141 void OnDataChannelCreated(DataChannel* channel);
143 // Slots for signals (sigslot) that are wired up to |channel|. 142 // Slots for signals (sigslot) that are wired up to |channel|.
144 void OnDataChannelOpened(DataChannel* channel); 143 void OnDataChannelOpened(DataChannel* channel);
145 void OnDataChannelClosed(DataChannel* channel); 144 void OnDataChannelClosed(DataChannel* channel);
146 145
147 PeerConnection* const pc_; 146 PeerConnection* const pc_;
148 rtc::Thread* const signaling_thread_; 147 rtc::Thread* const signaling_thread_;
149 rtc::Thread* const worker_thread_; 148 rtc::Thread* const worker_thread_;
150 rtc::Thread* const network_thread_; 149 rtc::Thread* const network_thread_;
151 rtc::AsyncInvoker invoker_; 150 rtc::AsyncInvoker invoker_;
152 151
153 int num_pending_partial_reports_; 152 int num_pending_partial_reports_;
154 int64_t partial_report_timestamp_us_; 153 int64_t partial_report_timestamp_us_;
155 rtc::scoped_refptr<RTCStatsReport> partial_report_; 154 rtc::scoped_refptr<RTCStatsReport> partial_report_;
156 std::vector<rtc::scoped_refptr<RTCStatsCollectorCallback>> callbacks_; 155 std::vector<rtc::scoped_refptr<RTCStatsCollectorCallback>> callbacks_;
157 156
158 // Set in |GetStatsReport|, used in |ProducePartialResultsOnNetworkThread| 157 // Set in |GetStatsReport|, read in |ProducePartialResultsOnNetworkThread| and
159 // (not passed as arguments to avoid copies). This is thread safe - it is set 158 // |ProducePartialResultsOnSignalingThread|, reset after work is complete. Not
160 // at the start of |GetStatsReport| after making sure there are no pending 159 // passed as arguments to avoid copies. This is thread safe - when we
161 // stats requests in progress. 160 // set/reset we know there are no pending stats requests in progress.
162 std::unique_ptr<ChannelNamePairs> channel_name_pairs_; 161 std::unique_ptr<ChannelNamePairs> channel_name_pairs_;
163 std::unique_ptr<MediaInfo> media_info_; 162 std::unique_ptr<TrackMediaInfoMap> track_media_info_map_;
163 std::map<MediaStreamTrackInterface*, std::string> track_to_id_;
164 164
165 // A timestamp, in microseconds, that is based on a timer that is 165 // A timestamp, in microseconds, that is based on a timer that is
166 // monotonically increasing. That is, even if the system clock is modified the 166 // monotonically increasing. That is, even if the system clock is modified the
167 // difference between the timer and this timestamp is how fresh the cached 167 // difference between the timer and this timestamp is how fresh the cached
168 // report is. 168 // report is.
169 int64_t cache_timestamp_us_; 169 int64_t cache_timestamp_us_;
170 int64_t cache_lifetime_us_; 170 int64_t cache_lifetime_us_;
171 rtc::scoped_refptr<const RTCStatsReport> cached_report_; 171 rtc::scoped_refptr<const RTCStatsReport> cached_report_;
172 172
173 // Data recorded and maintained by the stats collector during its lifetime. 173 // Data recorded and maintained by the stats collector during its lifetime.
(...skipping 17 matching lines...) Expand all
191 }; 191 };
192 192
193 const char* CandidateTypeToRTCIceCandidateTypeForTesting( 193 const char* CandidateTypeToRTCIceCandidateTypeForTesting(
194 const std::string& type); 194 const std::string& type);
195 const char* DataStateToRTCDataChannelStateForTesting( 195 const char* DataStateToRTCDataChannelStateForTesting(
196 DataChannelInterface::DataState state); 196 DataChannelInterface::DataState state);
197 197
198 } // namespace webrtc 198 } // namespace webrtc
199 199
200 #endif // WEBRTC_API_RTCSTATSCOLLECTOR_H_ 200 #endif // WEBRTC_API_RTCSTATSCOLLECTOR_H_
OLDNEW
« no previous file with comments | « webrtc/api/rtcstats_integrationtest.cc ('k') | webrtc/api/rtcstatscollector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698