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

Side by Side Diff: webrtc/video/send_statistics_proxy.cc

Issue 2972393002: Remove traces from {send,receive}_statistics_proxy.cc (Closed)
Patch Set: Remove trace_event.h instead of logging.h Created 3 years, 4 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/video/receive_statistics_proxy.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 (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include "webrtc/video/send_statistics_proxy.h" 11 #include "webrtc/video/send_statistics_proxy.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <cmath> 14 #include <cmath>
15 #include <map> 15 #include <map>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/common_types.h" 18 #include "webrtc/common_types.h"
19 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 19 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
20 #include "webrtc/rtc_base/checks.h" 20 #include "webrtc/rtc_base/checks.h"
21 #include "webrtc/rtc_base/logging.h" 21 #include "webrtc/rtc_base/logging.h"
22 #include "webrtc/rtc_base/trace_event.h"
23 #include "webrtc/system_wrappers/include/metrics.h" 22 #include "webrtc/system_wrappers/include/metrics.h"
24 23
25 namespace webrtc { 24 namespace webrtc {
26 namespace { 25 namespace {
27 const float kEncodeTimeWeigthFactor = 0.5f; 26 const float kEncodeTimeWeigthFactor = 0.5f;
28 27
29 // Used by histograms. Values of entries should not be changed. 28 // Used by histograms. Values of entries should not be changed.
30 enum HistogramCodecType { 29 enum HistogramCodecType {
31 kVideoUnknown = 0, 30 kVideoUnknown = 0,
32 kVideoVp8 = 1, 31 kVideoVp8 = 1,
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 GetUmaPrefix(config.content_type), stats_, clock_)); 464 GetUmaPrefix(config.content_type), stats_, clock_));
466 content_type_ = config.content_type; 465 content_type_ = config.content_type;
467 } 466 }
468 } 467 }
469 468
470 void SendStatisticsProxy::OnEncoderStatsUpdate(uint32_t framerate, 469 void SendStatisticsProxy::OnEncoderStatsUpdate(uint32_t framerate,
471 uint32_t bitrate) { 470 uint32_t bitrate) {
472 rtc::CritScope lock(&crit_); 471 rtc::CritScope lock(&crit_);
473 stats_.encode_frame_rate = framerate; 472 stats_.encode_frame_rate = framerate;
474 stats_.media_bitrate_bps = bitrate; 473 stats_.media_bitrate_bps = bitrate;
475 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.FrameRateSent",
476 "frame_rate", framerate, "ssrc", rtp_config_.ssrcs[0]);
477 } 474 }
478 475
479 void SendStatisticsProxy::OnEncodedFrameTimeMeasured( 476 void SendStatisticsProxy::OnEncodedFrameTimeMeasured(
480 int encode_time_ms, 477 int encode_time_ms,
481 const CpuOveruseMetrics& metrics) { 478 const CpuOveruseMetrics& metrics) {
482 rtc::CritScope lock(&crit_); 479 rtc::CritScope lock(&crit_);
483 uma_container_->encode_time_counter_.Add(encode_time_ms); 480 uma_container_->encode_time_counter_.Add(encode_time_ms);
484 encode_time_.Apply(1.0f, encode_time_ms); 481 encode_time_.Apply(1.0f, encode_time_ms);
485 stats_.avg_encode_time_ms = round(encode_time_.filtered()); 482 stats_.avg_encode_time_ms = round(encode_time_.filtered());
486 stats_.encode_usage_percent = metrics.encode_usage_percent; 483 stats_.encode_usage_percent = metrics.encode_usage_percent;
487 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.EncodeTimeInMs",
488 "encode_time_ms", stats_.avg_encode_time_ms,
489 "ssrc", rtp_config_.ssrcs[0]);
490 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.EncodeUsagePercent",
491 "encode_usage_percent", stats_.encode_usage_percent,
492 "ssrc", rtp_config_.ssrcs[0]);
493 } 484 }
494 485
495 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) { 486 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) {
496 int64_t now_ms = clock_->TimeInMilliseconds(); 487 int64_t now_ms = clock_->TimeInMilliseconds();
497 rtc::CritScope lock(&crit_); 488 rtc::CritScope lock(&crit_);
498 stats_.suspended = is_suspended; 489 stats_.suspended = is_suspended;
499 if (is_suspended) { 490 if (is_suspended) {
500 // Pause framerate (add min pause time since there may be frames/packets 491 // Pause framerate (add min pause time since there may be frames/packets
501 // that are not yet sent). 492 // that are not yet sent).
502 const int64_t kMinMs = 500; 493 const int64_t kMinMs = 500;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 uma_container_->max_sent_width_per_timestamp_ = 0; 690 uma_container_->max_sent_width_per_timestamp_ = 0;
700 uma_container_->max_sent_height_per_timestamp_ = 0; 691 uma_container_->max_sent_height_per_timestamp_ = 0;
701 } 692 }
702 last_sent_frame_timestamp_ = encoded_image._timeStamp; 693 last_sent_frame_timestamp_ = encoded_image._timeStamp;
703 uma_container_->max_sent_width_per_timestamp_ = 694 uma_container_->max_sent_width_per_timestamp_ =
704 std::max(uma_container_->max_sent_width_per_timestamp_, 695 std::max(uma_container_->max_sent_width_per_timestamp_,
705 static_cast<int>(encoded_image._encodedWidth)); 696 static_cast<int>(encoded_image._encodedWidth));
706 uma_container_->max_sent_height_per_timestamp_ = 697 uma_container_->max_sent_height_per_timestamp_ =
707 std::max(uma_container_->max_sent_height_per_timestamp_, 698 std::max(uma_container_->max_sent_height_per_timestamp_,
708 static_cast<int>(encoded_image._encodedHeight)); 699 static_cast<int>(encoded_image._encodedHeight));
709
710 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.SentWidthInPixels",
711 "frame_width", encoded_image._encodedWidth, "ssrc", ssrc);
712 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.SentHeightInPixels",
713 "frame_height", encoded_image._encodedHeight, "ssrc", ssrc);
714 } 700 }
715 701
716 int SendStatisticsProxy::GetSendFrameRate() const { 702 int SendStatisticsProxy::GetSendFrameRate() const {
717 rtc::CritScope lock(&crit_); 703 rtc::CritScope lock(&crit_);
718 return stats_.encode_frame_rate; 704 return stats_.encode_frame_rate;
719 } 705 }
720 706
721 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { 707 void SendStatisticsProxy::OnIncomingFrame(int width, int height) {
722 rtc::CritScope lock(&crit_); 708 rtc::CritScope lock(&crit_);
723 uma_container_->input_frame_rate_tracker_.AddSamples(1); 709 uma_container_->input_frame_rate_tracker_.AddSamples(1);
724 uma_container_->input_fps_counter_.Add(1); 710 uma_container_->input_fps_counter_.Add(1);
725 uma_container_->input_width_counter_.Add(width); 711 uma_container_->input_width_counter_.Add(width);
726 uma_container_->input_height_counter_.Add(height); 712 uma_container_->input_height_counter_.Add(height);
727 if (cpu_downscales_ >= 0) { 713 if (cpu_downscales_ >= 0) {
728 uma_container_->cpu_limited_frame_counter_.Add( 714 uma_container_->cpu_limited_frame_counter_.Add(
729 stats_.cpu_limited_resolution); 715 stats_.cpu_limited_resolution);
730 } 716 }
731 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate",
732 "frame_rate", round(
733 uma_container_->input_frame_rate_tracker_.ComputeRate()),
734 "ssrc", rtp_config_.ssrcs[0]);
735 } 717 }
736 718
737 void SendStatisticsProxy::SetAdaptationStats( 719 void SendStatisticsProxy::SetAdaptationStats(
738 const ViEEncoder::AdaptCounts& cpu_counts, 720 const ViEEncoder::AdaptCounts& cpu_counts,
739 const ViEEncoder::AdaptCounts& quality_counts) { 721 const ViEEncoder::AdaptCounts& quality_counts) {
740 rtc::CritScope lock(&crit_); 722 rtc::CritScope lock(&crit_);
741 SetAdaptTimer(cpu_counts, &uma_container_->cpu_adapt_timer_); 723 SetAdaptTimer(cpu_counts, &uma_container_->cpu_adapt_timer_);
742 SetAdaptTimer(quality_counts, &uma_container_->quality_adapt_timer_); 724 SetAdaptTimer(quality_counts, &uma_container_->quality_adapt_timer_);
743 UpdateAdaptationStats(cpu_counts, quality_counts); 725 UpdateAdaptationStats(cpu_counts, quality_counts);
744 } 726 }
745 727
746 void SendStatisticsProxy::OnCpuAdaptationChanged( 728 void SendStatisticsProxy::OnCpuAdaptationChanged(
747 const ViEEncoder::AdaptCounts& cpu_counts, 729 const ViEEncoder::AdaptCounts& cpu_counts,
748 const ViEEncoder::AdaptCounts& quality_counts) { 730 const ViEEncoder::AdaptCounts& quality_counts) {
749 rtc::CritScope lock(&crit_); 731 rtc::CritScope lock(&crit_);
750 ++stats_.number_of_cpu_adapt_changes; 732 ++stats_.number_of_cpu_adapt_changes;
751 UpdateAdaptationStats(cpu_counts, quality_counts); 733 UpdateAdaptationStats(cpu_counts, quality_counts);
752 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.CpuAdaptationChanges");
753 } 734 }
754 735
755 void SendStatisticsProxy::OnQualityAdaptationChanged( 736 void SendStatisticsProxy::OnQualityAdaptationChanged(
756 const ViEEncoder::AdaptCounts& cpu_counts, 737 const ViEEncoder::AdaptCounts& cpu_counts,
757 const ViEEncoder::AdaptCounts& quality_counts) { 738 const ViEEncoder::AdaptCounts& quality_counts) {
758 rtc::CritScope lock(&crit_); 739 rtc::CritScope lock(&crit_);
759 ++stats_.number_of_quality_adapt_changes; 740 ++stats_.number_of_quality_adapt_changes;
760 UpdateAdaptationStats(cpu_counts, quality_counts); 741 UpdateAdaptationStats(cpu_counts, quality_counts);
761 } 742 }
762 743
(...skipping 24 matching lines...) Expand all
787 uint32_t ssrc, 768 uint32_t ssrc,
788 const RtcpPacketTypeCounter& packet_counter) { 769 const RtcpPacketTypeCounter& packet_counter) {
789 rtc::CritScope lock(&crit_); 770 rtc::CritScope lock(&crit_);
790 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 771 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
791 if (!stats) 772 if (!stats)
792 return; 773 return;
793 774
794 stats->rtcp_packet_type_counts = packet_counter; 775 stats->rtcp_packet_type_counts = packet_counter;
795 if (uma_container_->first_rtcp_stats_time_ms_ == -1) 776 if (uma_container_->first_rtcp_stats_time_ms_ == -1)
796 uma_container_->first_rtcp_stats_time_ms_ = clock_->TimeInMilliseconds(); 777 uma_container_->first_rtcp_stats_time_ms_ = clock_->TimeInMilliseconds();
797
798 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.FirPacketsReceived",
799 "fir_packets_received", packet_counter.fir_packets, "ssrc", ssrc);
800 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.NackPacketsReceived",
801 "nack_packets_received", packet_counter.nack_packets, "ssrc", ssrc);
802 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.PliPacketsReceived",
803 "pli_packets_received", packet_counter.pli_packets, "ssrc", ssrc);
804 } 778 }
805 779
806 void SendStatisticsProxy::StatisticsUpdated(const RtcpStatistics& statistics, 780 void SendStatisticsProxy::StatisticsUpdated(const RtcpStatistics& statistics,
807 uint32_t ssrc) { 781 uint32_t ssrc) {
808 rtc::CritScope lock(&crit_); 782 rtc::CritScope lock(&crit_);
809 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 783 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
810 if (!stats) 784 if (!stats)
811 return; 785 return;
812 786
813 stats->rtcp_stats = statistics; 787 stats->rtcp_stats = statistics;
814 uma_container_->report_block_stats_.Store(statistics, 0, ssrc); 788 uma_container_->report_block_stats_.Store(statistics, 0, ssrc);
815
816 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.SentPacketsLost",
817 "packets_lost", statistics.cumulative_lost, "ssrc", ssrc);
818 } 789 }
819 790
820 void SendStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) {} 791 void SendStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) {}
821 792
822 void SendStatisticsProxy::DataCountersUpdated( 793 void SendStatisticsProxy::DataCountersUpdated(
823 const StreamDataCounters& counters, 794 const StreamDataCounters& counters,
824 uint32_t ssrc) { 795 uint32_t ssrc) {
825 rtc::CritScope lock(&crit_); 796 rtc::CritScope lock(&crit_);
826 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 797 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
827 RTC_DCHECK(stats) << "DataCountersUpdated reported for unknown ssrc " << ssrc; 798 RTC_DCHECK(stats) << "DataCountersUpdated reported for unknown ssrc " << ssrc;
(...skipping 18 matching lines...) Expand all
846 ssrc); 817 ssrc);
847 uma_container_->retransmit_byte_counter_.Set( 818 uma_container_->retransmit_byte_counter_.Set(
848 counters.retransmitted.TotalBytes(), ssrc); 819 counters.retransmitted.TotalBytes(), ssrc);
849 uma_container_->fec_byte_counter_.Set(counters.fec.TotalBytes(), ssrc); 820 uma_container_->fec_byte_counter_.Set(counters.fec.TotalBytes(), ssrc);
850 if (stats->is_rtx) { 821 if (stats->is_rtx) {
851 uma_container_->rtx_byte_counter_.Set(counters.transmitted.TotalBytes(), 822 uma_container_->rtx_byte_counter_.Set(counters.transmitted.TotalBytes(),
852 ssrc); 823 ssrc);
853 } else { 824 } else {
854 uma_container_->media_byte_counter_.Set(counters.MediaPayloadBytes(), ssrc); 825 uma_container_->media_byte_counter_.Set(counters.MediaPayloadBytes(), ssrc);
855 } 826 }
856
857 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.SentPackets",
858 "packets_sent", counters.transmitted.packets, "ssrc", ssrc);
859 } 827 }
860 828
861 void SendStatisticsProxy::Notify(uint32_t total_bitrate_bps, 829 void SendStatisticsProxy::Notify(uint32_t total_bitrate_bps,
862 uint32_t retransmit_bitrate_bps, 830 uint32_t retransmit_bitrate_bps,
863 uint32_t ssrc) { 831 uint32_t ssrc) {
864 rtc::CritScope lock(&crit_); 832 rtc::CritScope lock(&crit_);
865 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 833 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
866 if (!stats) 834 if (!stats)
867 return; 835 return;
868 836
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 } 914 }
947 915
948 int SendStatisticsProxy::BoolSampleCounter::Fraction( 916 int SendStatisticsProxy::BoolSampleCounter::Fraction(
949 int64_t min_required_samples, 917 int64_t min_required_samples,
950 float multiplier) const { 918 float multiplier) const {
951 if (num_samples < min_required_samples || num_samples == 0) 919 if (num_samples < min_required_samples || num_samples == 0)
952 return -1; 920 return -1;
953 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); 921 return static_cast<int>((sum * multiplier / num_samples) + 0.5f);
954 } 922 }
955 } // namespace webrtc 923 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/receive_statistics_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698