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

Side by Side Diff: webrtc/pc/rtcstatscollector.cc

Issue 3000943002: Reland of Trace the stats report as JSON instead of each stat separately. (Closed)
Patch Set: This should work. Created 3 years, 3 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/pc/rtcstats_integrationtest.cc ('k') | no next file » | 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
(...skipping 14 matching lines...) Expand all
25 #include "webrtc/pc/webrtcsession.h" 25 #include "webrtc/pc/webrtcsession.h"
26 #include "webrtc/rtc_base/checks.h" 26 #include "webrtc/rtc_base/checks.h"
27 #include "webrtc/rtc_base/stringutils.h" 27 #include "webrtc/rtc_base/stringutils.h"
28 #include "webrtc/rtc_base/timeutils.h" 28 #include "webrtc/rtc_base/timeutils.h"
29 #include "webrtc/rtc_base/trace_event.h" 29 #include "webrtc/rtc_base/trace_event.h"
30 30
31 namespace webrtc { 31 namespace webrtc {
32 32
33 namespace { 33 namespace {
34 34
35 const int kStatTypeMemberNameAndIdMaxLen = 1024;
36
37 std::string GetStatTypeMemberNameAndId(const RTCStats& stats,
38 const RTCStatsMemberInterface* member) {
39 RTC_DCHECK(strlen(stats.type()) + strlen(member->name())
40 + stats.id().size() + 3 < kStatTypeMemberNameAndIdMaxLen);
41 char buffer[kStatTypeMemberNameAndIdMaxLen];
42 rtc::sprintfn(&buffer[0], sizeof(buffer), "%s.%s.%s", stats.type(),
43 member->name(), stats.id().c_str());
44 return buffer;
45 }
46
47 std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) { 35 std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) {
48 return "RTCCertificate_" + fingerprint; 36 return "RTCCertificate_" + fingerprint;
49 } 37 }
50 38
51 std::string RTCCodecStatsIDFromDirectionMediaAndPayload( 39 std::string RTCCodecStatsIDFromDirectionMediaAndPayload(
52 bool inbound, bool audio, uint32_t payload_type) { 40 bool inbound, bool audio, uint32_t payload_type) {
53 // TODO(hbos): The present codec ID assignment is not sufficient to support 41 // TODO(hbos): The present codec ID assignment is not sufficient to support
54 // Unified Plan or unbundled connections in all cases. When we are able to 42 // Unified Plan or unbundled connections in all cases. When we are able to
55 // handle multiple m= lines of the same media type (and multiple BaseChannels 43 // handle multiple m= lines of the same media type (and multiple BaseChannels
56 // for the same type is possible?) this needs to be updated to differentiate 44 // for the same type is possible?) this needs to be updated to differentiate
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 if (!num_pending_partial_reports_) { 759 if (!num_pending_partial_reports_) {
772 cache_timestamp_us_ = partial_report_timestamp_us_; 760 cache_timestamp_us_ = partial_report_timestamp_us_;
773 cached_report_ = partial_report_; 761 cached_report_ = partial_report_;
774 partial_report_ = nullptr; 762 partial_report_ = nullptr;
775 channel_name_pairs_.reset(); 763 channel_name_pairs_.reset();
776 track_media_info_map_.reset(); 764 track_media_info_map_.reset();
777 track_to_id_.clear(); 765 track_to_id_.clear();
778 // Trace WebRTC Stats when getStats is called on Javascript. 766 // Trace WebRTC Stats when getStats is called on Javascript.
779 // This allows access to WebRTC stats from trace logs. To enable them, 767 // This allows access to WebRTC stats from trace logs. To enable them,
780 // select the "webrtc_stats" category when recording traces. 768 // select the "webrtc_stats" category when recording traces.
781 for (const RTCStats& stats : *cached_report_) { 769 TRACE_EVENT_INSTANT1("webrtc_stats", "webrtc_stats", "report",
782 for (const RTCStatsMemberInterface* member : stats.Members()) { 770 cached_report_->ToJson());
783 if (member->is_defined()) {
784 TRACE_EVENT_INSTANT2("webrtc_stats", "webrtc_stats",
785 "value", member->ValueToString(),
786 "type.name.id", GetStatTypeMemberNameAndId(
787 stats, member));
788 }
789 }
790 }
791 DeliverCachedReport(); 771 DeliverCachedReport();
792 } 772 }
793 } 773 }
794 774
795 void RTCStatsCollector::DeliverCachedReport() { 775 void RTCStatsCollector::DeliverCachedReport() {
796 RTC_DCHECK(signaling_thread_->IsCurrent()); 776 RTC_DCHECK(signaling_thread_->IsCurrent());
797 RTC_DCHECK(!callbacks_.empty()); 777 RTC_DCHECK(!callbacks_.empty());
798 RTC_DCHECK(cached_report_); 778 RTC_DCHECK(cached_report_);
799 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : 779 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback :
800 callbacks_) { 780 callbacks_) {
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 const std::string& type) { 1258 const std::string& type) {
1279 return CandidateTypeToRTCIceCandidateType(type); 1259 return CandidateTypeToRTCIceCandidateType(type);
1280 } 1260 }
1281 1261
1282 const char* DataStateToRTCDataChannelStateForTesting( 1262 const char* DataStateToRTCDataChannelStateForTesting(
1283 DataChannelInterface::DataState state) { 1263 DataChannelInterface::DataState state) {
1284 return DataStateToRTCDataChannelState(state); 1264 return DataStateToRTCDataChannelState(state);
1285 } 1265 }
1286 1266
1287 } // namespace webrtc 1267 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/rtcstats_integrationtest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698