Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 rtc::CritScope lock(&crit_); | 469 rtc::CritScope lock(&crit_); |
| 470 stats_.target_media_bitrate_bps = bitrate_bps; | 470 stats_.target_media_bitrate_bps = bitrate_bps; |
| 471 } | 471 } |
| 472 | 472 |
| 473 void SendStatisticsProxy::OnSendEncodedImage( | 473 void SendStatisticsProxy::OnSendEncodedImage( |
| 474 const EncodedImage& encoded_image, | 474 const EncodedImage& encoded_image, |
| 475 const CodecSpecificInfo* codec_info) { | 475 const CodecSpecificInfo* codec_info) { |
| 476 size_t simulcast_idx = 0; | 476 size_t simulcast_idx = 0; |
| 477 | 477 |
| 478 rtc::CritScope lock(&crit_); | 478 rtc::CritScope lock(&crit_); |
| 479 bool report_quality_scales = quality_downscales_ >= 0; | |
| 479 ++stats_.frames_encoded; | 480 ++stats_.frames_encoded; |
| 480 if (codec_info) { | 481 if (codec_info) { |
| 481 if (codec_info->codecType == kVideoCodecVP8) { | 482 if (codec_info->codecType == kVideoCodecVP8) { |
| 482 simulcast_idx = codec_info->codecSpecific.VP8.simulcastIdx; | 483 simulcast_idx = codec_info->codecSpecific.VP8.simulcastIdx; |
| 484 report_quality_scales &= simulcast_idx == 0; | |
|
åsapersson
2016/12/16 14:45:14
Shouldn't this be decided from the ScalingSettings
kthelgason
2016/12/19 10:25:27
Yes, you're absolutely right, quality scaling is t
| |
| 483 } else if (codec_info->codecType == kVideoCodecGeneric) { | 485 } else if (codec_info->codecType == kVideoCodecGeneric) { |
| 484 simulcast_idx = codec_info->codecSpecific.generic.simulcast_idx; | 486 simulcast_idx = codec_info->codecSpecific.generic.simulcast_idx; |
| 485 } | 487 } |
| 486 if (codec_info->codec_name) { | 488 if (codec_info->codec_name) { |
| 487 stats_.encoder_implementation_name = codec_info->codec_name; | 489 stats_.encoder_implementation_name = codec_info->codec_name; |
| 488 } | 490 } |
| 489 } | 491 } |
| 490 | 492 |
| 491 if (simulcast_idx >= rtp_config_.ssrcs.size()) { | 493 if (simulcast_idx >= rtp_config_.ssrcs.size()) { |
| 492 LOG(LS_ERROR) << "Encoded image outside simulcast range (" << simulcast_idx | 494 LOG(LS_ERROR) << "Encoded image outside simulcast range (" << simulcast_idx |
| 493 << " >= " << rtp_config_.ssrcs.size() << ")."; | 495 << " >= " << rtp_config_.ssrcs.size() << ")."; |
| 494 return; | 496 return; |
| 495 } | 497 } |
| 496 uint32_t ssrc = rtp_config_.ssrcs[simulcast_idx]; | 498 uint32_t ssrc = rtp_config_.ssrcs[simulcast_idx]; |
| 497 | 499 |
| 498 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 500 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
| 499 if (!stats) | 501 if (!stats) |
| 500 return; | 502 return; |
| 501 | 503 |
| 502 stats->width = encoded_image._encodedWidth; | 504 stats->width = encoded_image._encodedWidth; |
| 503 stats->height = encoded_image._encodedHeight; | 505 stats->height = encoded_image._encodedHeight; |
| 504 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); | 506 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); |
| 505 | 507 |
| 506 uma_container_->key_frame_counter_.Add(encoded_image._frameType == | 508 uma_container_->key_frame_counter_.Add(encoded_image._frameType == |
| 507 kVideoFrameKey); | 509 kVideoFrameKey); |
| 508 stats_.bw_limited_resolution = | 510 stats_.bw_limited_resolution = |
| 509 stats_.bw_limited_resolution || | 511 encoded_image.adapt_reason_.bw_resolutions_disabled > 0 || |
| 510 encoded_image.adapt_reason_.bw_resolutions_disabled > 0; | 512 quality_downscales_ > 0; |
| 511 | 513 |
| 512 if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { | 514 if (report_quality_scales) { |
| 513 bool downscaled = | 515 uma_container_->quality_limited_frame_counter_.Add(quality_downscales_ > 0); |
| 514 encoded_image.adapt_reason_.quality_resolution_downscales > 0; | 516 if (quality_downscales_ > 0) |
| 515 uma_container_->quality_limited_frame_counter_.Add(downscaled); | 517 uma_container_->quality_downscales_counter_.Add(quality_downscales_); |
| 516 if (downscaled) { | |
| 517 uma_container_->quality_downscales_counter_.Add( | |
| 518 encoded_image.adapt_reason_.quality_resolution_downscales); | |
| 519 } | |
| 520 } | 518 } |
| 521 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { | 519 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { |
| 522 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; | 520 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; |
| 523 uma_container_->bw_limited_frame_counter_.Add(bw_limited); | 521 uma_container_->bw_limited_frame_counter_.Add(bw_limited); |
| 524 if (bw_limited) { | 522 if (bw_limited) { |
| 525 uma_container_->bw_resolutions_disabled_counter_.Add( | 523 uma_container_->bw_resolutions_disabled_counter_.Add( |
| 526 encoded_image.adapt_reason_.bw_resolutions_disabled); | 524 encoded_image.adapt_reason_.bw_resolutions_disabled); |
| 527 } | 525 } |
| 528 } | 526 } |
| 529 | 527 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 | 578 |
| 581 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { | 579 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { |
| 582 rtc::CritScope lock(&crit_); | 580 rtc::CritScope lock(&crit_); |
| 583 uma_container_->input_frame_rate_tracker_.AddSamples(1); | 581 uma_container_->input_frame_rate_tracker_.AddSamples(1); |
| 584 uma_container_->input_fps_counter_.Add(1); | 582 uma_container_->input_fps_counter_.Add(1); |
| 585 uma_container_->input_width_counter_.Add(width); | 583 uma_container_->input_width_counter_.Add(width); |
| 586 uma_container_->input_height_counter_.Add(height); | 584 uma_container_->input_height_counter_.Add(height); |
| 587 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); | 585 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); |
| 588 } | 586 } |
| 589 | 587 |
| 590 void SendStatisticsProxy::SetResolutionRestrictionStats(bool bandwidth, | 588 void SendStatisticsProxy::SetResolutionRestrictionStats( |
| 591 bool cpu) { | 589 bool scaling_enabled, |
| 590 bool cpu_restricted, | |
| 591 int nr_of_quality_downscales) { | |
| 592 rtc::CritScope lock(&crit_); | 592 rtc::CritScope lock(&crit_); |
| 593 stats_.bw_limited_resolution = bandwidth; | 593 if (!scaling_enabled) { |
| 594 stats_.cpu_limited_resolution = cpu; | 594 stats_.bw_limited_resolution = false; |
| 595 stats_.cpu_limited_resolution = false; | |
| 596 quality_downscales_ = -1; | |
| 597 } else { | |
| 598 quality_downscales_ = nr_of_quality_downscales; | |
| 599 stats_.bw_limited_resolution = quality_downscales_ > 0; | |
| 600 stats_.cpu_limited_resolution = cpu_restricted; | |
| 601 } | |
| 595 } | 602 } |
| 596 | 603 |
| 597 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( | 604 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( |
| 598 bool cpu_restricted_resolution) { | 605 bool cpu_restricted_resolution) { |
| 599 rtc::CritScope lock(&crit_); | 606 rtc::CritScope lock(&crit_); |
| 600 stats_.cpu_limited_resolution = cpu_restricted_resolution; | 607 stats_.cpu_limited_resolution = cpu_restricted_resolution; |
| 601 ++stats_.number_of_cpu_adapt_changes; | 608 ++stats_.number_of_cpu_adapt_changes; |
| 602 } | 609 } |
| 603 | 610 |
| 604 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( | 611 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( |
| 605 bool restricted) { | 612 int nr_of_downscales) { |
| 606 rtc::CritScope lock(&crit_); | 613 rtc::CritScope lock(&crit_); |
| 607 uma_container_->quality_downscales_counter_.Add(restricted); | 614 quality_downscales_ = nr_of_downscales; |
| 608 stats_.bw_limited_resolution = restricted; | 615 stats_.bw_limited_resolution = quality_downscales_ > 0; |
| 609 } | 616 } |
| 610 | 617 |
| 611 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 618 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
| 612 uint32_t ssrc, | 619 uint32_t ssrc, |
| 613 const RtcpPacketTypeCounter& packet_counter) { | 620 const RtcpPacketTypeCounter& packet_counter) { |
| 614 rtc::CritScope lock(&crit_); | 621 rtc::CritScope lock(&crit_); |
| 615 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 622 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
| 616 if (!stats) | 623 if (!stats) |
| 617 return; | 624 return; |
| 618 | 625 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 return Fraction(min_required_samples, 1000.0f); | 723 return Fraction(min_required_samples, 1000.0f); |
| 717 } | 724 } |
| 718 | 725 |
| 719 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 726 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 720 int min_required_samples, float multiplier) const { | 727 int min_required_samples, float multiplier) const { |
| 721 if (num_samples < min_required_samples || num_samples == 0) | 728 if (num_samples < min_required_samples || num_samples == 0) |
| 722 return -1; | 729 return -1; |
| 723 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 730 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 724 } | 731 } |
| 725 } // namespace webrtc | 732 } // namespace webrtc |
| OLD | NEW |