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

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 2133073002: Add periodic logging of video stats. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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/media/engine/webrtcvideoengine2.h ('k') | webrtc/video/receive_statistics_proxy.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 (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 // duration hasn't been implemented. 335 // duration hasn't been implemented.
336 static const int kNackHistoryMs = 1000; 336 static const int kNackHistoryMs = 1000;
337 337
338 static const int kDefaultQpMax = 56; 338 static const int kDefaultQpMax = 56;
339 339
340 static const int kDefaultRtcpReceiverReportSsrc = 1; 340 static const int kDefaultRtcpReceiverReportSsrc = 1;
341 341
342 // Down grade resolution at most 2 times for CPU reasons. 342 // Down grade resolution at most 2 times for CPU reasons.
343 static const int kMaxCpuDowngrades = 2; 343 static const int kMaxCpuDowngrades = 2;
344 344
345 // Minimum time interval for logging stats.
346 static const int64_t kStatsLogIntervalMs = 10000;
347
345 // Adds |codec| to |list|, and also adds an RTX codec if |codec|'s name is 348 // Adds |codec| to |list|, and also adds an RTX codec if |codec|'s name is
346 // recognized. 349 // recognized.
347 // TODO(deadbeef): Should we add RTX codecs for external codecs whose names we 350 // TODO(deadbeef): Should we add RTX codecs for external codecs whose names we
348 // don't recognize? 351 // don't recognize?
349 void AddCodecAndMaybeRtxCodec(const VideoCodec& codec, 352 void AddCodecAndMaybeRtxCodec(const VideoCodec& codec,
350 std::vector<VideoCodec>* codecs) { 353 std::vector<VideoCodec>* codecs) {
351 codecs->push_back(codec); 354 codecs->push_back(codec);
352 int rtx_payload_type = 0; 355 int rtx_payload_type = 0;
353 if (CodecNamesEq(codec.name, kVp8CodecName)) { 356 if (CodecNamesEq(codec.name, kVp8CodecName)) {
354 rtx_payload_type = kDefaultRtxVp8PlType; 357 rtx_payload_type = kDefaultRtxVp8PlType;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 const std::vector<VideoCodec>& recv_codecs, 672 const std::vector<VideoCodec>& recv_codecs,
670 WebRtcVideoEncoderFactory* external_encoder_factory, 673 WebRtcVideoEncoderFactory* external_encoder_factory,
671 WebRtcVideoDecoderFactory* external_decoder_factory) 674 WebRtcVideoDecoderFactory* external_decoder_factory)
672 : VideoMediaChannel(config), 675 : VideoMediaChannel(config),
673 call_(call), 676 call_(call),
674 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), 677 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
675 video_config_(config.video), 678 video_config_(config.video),
676 external_encoder_factory_(external_encoder_factory), 679 external_encoder_factory_(external_encoder_factory),
677 external_decoder_factory_(external_decoder_factory), 680 external_decoder_factory_(external_decoder_factory),
678 default_send_options_(options), 681 default_send_options_(options),
679 red_disabled_by_remote_side_(false) { 682 red_disabled_by_remote_side_(false),
683 last_stats_log_ms_(-1) {
680 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 684 RTC_DCHECK(thread_checker_.CalledOnValidThread());
681 685
682 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; 686 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc;
683 sending_ = false; 687 sending_ = false;
684 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); 688 RTC_DCHECK(ValidateCodecFormats(recv_codecs));
685 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); 689 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs));
686 } 690 }
687 691
688 WebRtcVideoChannel2::~WebRtcVideoChannel2() { 692 WebRtcVideoChannel2::~WebRtcVideoChannel2() {
689 for (auto& kv : send_streams_) 693 for (auto& kv : send_streams_)
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 if (it == receive_streams_.end()) { 1341 if (it == receive_streams_.end()) {
1338 return false; 1342 return false;
1339 } 1343 }
1340 1344
1341 it->second->SetSink(sink); 1345 it->second->SetSink(sink);
1342 return true; 1346 return true;
1343 } 1347 }
1344 1348
1345 bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) { 1349 bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) {
1346 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::GetStats"); 1350 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::GetStats");
1351
1352 // Log stats periodically.
1353 bool log_stats = false;
1354 int64_t now_ms = rtc::TimeMillis();
1355 if (last_stats_log_ms_ == -1 ||
1356 now_ms - last_stats_log_ms_ > kStatsLogIntervalMs) {
1357 last_stats_log_ms_ = now_ms;
1358 log_stats = true;
1359 }
1360
1347 info->Clear(); 1361 info->Clear();
1348 FillSenderStats(info); 1362 FillSenderStats(info, log_stats);
1349 FillReceiverStats(info); 1363 FillReceiverStats(info, log_stats);
1350 webrtc::Call::Stats stats = call_->GetStats(); 1364 webrtc::Call::Stats stats = call_->GetStats();
1351 FillBandwidthEstimationStats(stats, info); 1365 FillBandwidthEstimationStats(stats, info);
1352 if (stats.rtt_ms != -1) { 1366 if (stats.rtt_ms != -1) {
1353 for (size_t i = 0; i < info->senders.size(); ++i) { 1367 for (size_t i = 0; i < info->senders.size(); ++i) {
1354 info->senders[i].rtt_ms = stats.rtt_ms; 1368 info->senders[i].rtt_ms = stats.rtt_ms;
1355 } 1369 }
1356 } 1370 }
1371
1372 if (log_stats)
1373 LOG(LS_INFO) << stats.ToString(now_ms);
1374
1357 return true; 1375 return true;
1358 } 1376 }
1359 1377
1360 void WebRtcVideoChannel2::FillSenderStats(VideoMediaInfo* video_media_info) { 1378 void WebRtcVideoChannel2::FillSenderStats(VideoMediaInfo* video_media_info,
1379 bool log_stats) {
1361 rtc::CritScope stream_lock(&stream_crit_); 1380 rtc::CritScope stream_lock(&stream_crit_);
1362 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it = 1381 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it =
1363 send_streams_.begin(); 1382 send_streams_.begin();
1364 it != send_streams_.end(); ++it) { 1383 it != send_streams_.end(); ++it) {
1365 video_media_info->senders.push_back(it->second->GetVideoSenderInfo()); 1384 video_media_info->senders.push_back(
1385 it->second->GetVideoSenderInfo(log_stats));
1366 } 1386 }
1367 } 1387 }
1368 1388
1369 void WebRtcVideoChannel2::FillReceiverStats(VideoMediaInfo* video_media_info) { 1389 void WebRtcVideoChannel2::FillReceiverStats(VideoMediaInfo* video_media_info,
1390 bool log_stats) {
1370 rtc::CritScope stream_lock(&stream_crit_); 1391 rtc::CritScope stream_lock(&stream_crit_);
1371 for (std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = 1392 for (std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it =
1372 receive_streams_.begin(); 1393 receive_streams_.begin();
1373 it != receive_streams_.end(); ++it) { 1394 it != receive_streams_.end(); ++it) {
1374 video_media_info->receivers.push_back(it->second->GetVideoReceiverInfo()); 1395 video_media_info->receivers.push_back(
1396 it->second->GetVideoReceiverInfo(log_stats));
1375 } 1397 }
1376 } 1398 }
1377 1399
1378 void WebRtcVideoChannel2::FillBandwidthEstimationStats( 1400 void WebRtcVideoChannel2::FillBandwidthEstimationStats(
1379 const webrtc::Call::Stats& stats, 1401 const webrtc::Call::Stats& stats,
1380 VideoMediaInfo* video_media_info) { 1402 VideoMediaInfo* video_media_info) {
1381 BandwidthEstimationInfo bwe_info; 1403 BandwidthEstimationInfo bwe_info;
1382 bwe_info.available_send_bandwidth = stats.send_bandwidth_bps; 1404 bwe_info.available_send_bandwidth = stats.send_bandwidth_bps;
1383 bwe_info.available_recv_bandwidth = stats.recv_bandwidth_bps; 1405 bwe_info.available_recv_bandwidth = stats.recv_bandwidth_bps;
1384 bwe_info.bucket_delay = stats.pacer_delay_ms; 1406 bwe_info.bucket_delay = stats.pacer_delay_ms;
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 } 2111 }
2090 } 2112 }
2091 sink_wants_.max_pixel_count = max_pixel_count; 2113 sink_wants_.max_pixel_count = max_pixel_count;
2092 sink_wants_.max_pixel_count_step_up = max_pixel_count_step_up; 2114 sink_wants_.max_pixel_count_step_up = max_pixel_count_step_up;
2093 } 2115 }
2094 // |source_->AddOrUpdateSink| may not be called while holding |lock_| since 2116 // |source_->AddOrUpdateSink| may not be called while holding |lock_| since
2095 // that might cause a lock order inversion. 2117 // that might cause a lock order inversion.
2096 source_->AddOrUpdateSink(this, sink_wants_); 2118 source_->AddOrUpdateSink(this, sink_wants_);
2097 } 2119 }
2098 2120
2099 VideoSenderInfo 2121 VideoSenderInfo WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo(
2100 WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { 2122 bool log_stats) {
2101 VideoSenderInfo info; 2123 VideoSenderInfo info;
2102 webrtc::VideoSendStream::Stats stats; 2124 webrtc::VideoSendStream::Stats stats;
2103 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 2125 RTC_DCHECK(thread_checker_.CalledOnValidThread());
2104 { 2126 {
2105 rtc::CritScope cs(&lock_); 2127 rtc::CritScope cs(&lock_);
2106 for (uint32_t ssrc : parameters_.config.rtp.ssrcs) 2128 for (uint32_t ssrc : parameters_.config.rtp.ssrcs)
2107 info.add_ssrc(ssrc); 2129 info.add_ssrc(ssrc);
2108 2130
2109 if (parameters_.codec_settings) 2131 if (parameters_.codec_settings)
2110 info.codec_name = parameters_.codec_settings->codec.name; 2132 info.codec_name = parameters_.codec_settings->codec.name;
2111 for (size_t i = 0; i < parameters_.encoder_config.streams.size(); ++i) { 2133 for (size_t i = 0; i < parameters_.encoder_config.streams.size(); ++i) {
2112 if (i == parameters_.encoder_config.streams.size() - 1) { 2134 if (i == parameters_.encoder_config.streams.size() - 1) {
2113 info.preferred_bitrate += 2135 info.preferred_bitrate +=
2114 parameters_.encoder_config.streams[i].max_bitrate_bps; 2136 parameters_.encoder_config.streams[i].max_bitrate_bps;
2115 } else { 2137 } else {
2116 info.preferred_bitrate += 2138 info.preferred_bitrate +=
2117 parameters_.encoder_config.streams[i].target_bitrate_bps; 2139 parameters_.encoder_config.streams[i].target_bitrate_bps;
2118 } 2140 }
2119 } 2141 }
2120 2142
2121 if (stream_ == NULL) 2143 if (stream_ == NULL)
2122 return info; 2144 return info;
2123 2145
2124 stats = stream_->GetStats(); 2146 stats = stream_->GetStats();
2125 } 2147 }
2148
2149 if (log_stats)
2150 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis());
2151
2126 info.adapt_changes = number_of_cpu_adapt_changes_; 2152 info.adapt_changes = number_of_cpu_adapt_changes_;
2127 info.adapt_reason = 2153 info.adapt_reason =
2128 cpu_restricted_counter_ <= 0 ? ADAPTREASON_NONE : ADAPTREASON_CPU; 2154 cpu_restricted_counter_ <= 0 ? ADAPTREASON_NONE : ADAPTREASON_CPU;
2129 2155
2130 // Get bandwidth limitation info from stream_->GetStats(). 2156 // Get bandwidth limitation info from stream_->GetStats().
2131 // Input resolution (output from video_adapter) can be further scaled down or 2157 // Input resolution (output from video_adapter) can be further scaled down or
2132 // higher video layer(s) can be dropped due to bitrate constraints. 2158 // higher video layer(s) can be dropped due to bitrate constraints.
2133 // Note, adapt_changes only include changes from the video_adapter. 2159 // Note, adapt_changes only include changes from the video_adapter.
2134 if (stats.bw_limited_resolution) 2160 if (stats.bw_limited_resolution)
2135 info.adapt_reason |= ADAPTREASON_BANDWIDTH; 2161 info.adapt_reason |= ADAPTREASON_BANDWIDTH;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2490 int payload_type) { 2516 int payload_type) {
2491 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { 2517 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) {
2492 if (decoder.payload_type == payload_type) { 2518 if (decoder.payload_type == payload_type) {
2493 return decoder.payload_name; 2519 return decoder.payload_name;
2494 } 2520 }
2495 } 2521 }
2496 return ""; 2522 return "";
2497 } 2523 }
2498 2524
2499 VideoReceiverInfo 2525 VideoReceiverInfo
2500 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetVideoReceiverInfo() { 2526 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetVideoReceiverInfo(
2527 bool log_stats) {
2501 VideoReceiverInfo info; 2528 VideoReceiverInfo info;
2502 info.ssrc_groups = stream_params_.ssrc_groups; 2529 info.ssrc_groups = stream_params_.ssrc_groups;
2503 info.add_ssrc(config_.rtp.remote_ssrc); 2530 info.add_ssrc(config_.rtp.remote_ssrc);
2504 webrtc::VideoReceiveStream::Stats stats = stream_->GetStats(); 2531 webrtc::VideoReceiveStream::Stats stats = stream_->GetStats();
2505 info.decoder_implementation_name = stats.decoder_implementation_name; 2532 info.decoder_implementation_name = stats.decoder_implementation_name;
2506 info.bytes_rcvd = stats.rtp_stats.transmitted.payload_bytes + 2533 info.bytes_rcvd = stats.rtp_stats.transmitted.payload_bytes +
2507 stats.rtp_stats.transmitted.header_bytes + 2534 stats.rtp_stats.transmitted.header_bytes +
2508 stats.rtp_stats.transmitted.padding_bytes; 2535 stats.rtp_stats.transmitted.padding_bytes;
2509 info.packets_rcvd = stats.rtp_stats.transmitted.packets; 2536 info.packets_rcvd = stats.rtp_stats.transmitted.packets;
2510 info.packets_lost = stats.rtcp_stats.cumulative_lost; 2537 info.packets_lost = stats.rtcp_stats.cumulative_lost;
(...skipping 18 matching lines...) Expand all
2529 info.jitter_buffer_ms = stats.jitter_buffer_ms; 2556 info.jitter_buffer_ms = stats.jitter_buffer_ms;
2530 info.min_playout_delay_ms = stats.min_playout_delay_ms; 2557 info.min_playout_delay_ms = stats.min_playout_delay_ms;
2531 info.render_delay_ms = stats.render_delay_ms; 2558 info.render_delay_ms = stats.render_delay_ms;
2532 2559
2533 info.codec_name = GetCodecNameFromPayloadType(stats.current_payload_type); 2560 info.codec_name = GetCodecNameFromPayloadType(stats.current_payload_type);
2534 2561
2535 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; 2562 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets;
2536 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; 2563 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets;
2537 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; 2564 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets;
2538 2565
2566 if (log_stats)
2567 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis());
2568
2539 return info; 2569 return info;
2540 } 2570 }
2541 2571
2542 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFecDisabledRemotely( 2572 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFecDisabledRemotely(
2543 bool disable) { 2573 bool disable) {
2544 red_disabled_by_remote_side_ = disable; 2574 red_disabled_by_remote_side_ = disable;
2545 RecreateWebRtcStream(); 2575 RecreateWebRtcStream();
2546 } 2576 }
2547 2577
2548 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() 2578 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings()
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2651 rtx_mapping[video_codecs[i].codec.id] != 2681 rtx_mapping[video_codecs[i].codec.id] !=
2652 fec_settings.red_payload_type) { 2682 fec_settings.red_payload_type) {
2653 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2683 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2654 } 2684 }
2655 } 2685 }
2656 2686
2657 return video_codecs; 2687 return video_codecs;
2658 } 2688 }
2659 2689
2660 } // namespace cricket 2690 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/video/receive_statistics_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698