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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 | 467 |
| 468 void SendStatisticsProxy::OnSetEncoderTargetRate(uint32_t bitrate_bps) { | 468 void SendStatisticsProxy::OnSetEncoderTargetRate(uint32_t bitrate_bps) { |
| 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 bool report_quality_scales = true; | |
| 477 | 478 |
| 478 rtc::CritScope lock(&crit_); | 479 rtc::CritScope lock(&crit_); |
| 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/14 09:25:13
Scaling could be disabled for simulcast_idx == 0?
kthelgason
2016/12/15 10:33:54
Done.
| |
| 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 stats_.bw_limited_resolution || quality_downscales_ > 0; |
|
åsapersson
2016/12/14 09:25:13
Why remove encoded_image.adapt_reason_.bw_resoluti
kthelgason
2016/12/15 10:33:54
Sorry, that should not have been removed. Fixed!
| |
| 510 encoded_image.adapt_reason_.bw_resolutions_disabled > 0; | |
| 511 | 512 |
| 512 if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { | 513 if (report_quality_scales) { |
| 513 bool downscaled = | 514 if (quality_downscales_ >= 0) { |
|
åsapersson
2016/12/14 09:25:13
always >= 0?
kthelgason
2016/12/15 10:33:54
Acknowledged.
| |
| 514 encoded_image.adapt_reason_.quality_resolution_downscales > 0; | 515 uma_container_->quality_limited_frame_counter_.Add(quality_downscales_ > |
| 515 uma_container_->quality_limited_frame_counter_.Add(downscaled); | 516 0); |
| 516 if (downscaled) { | 517 if (quality_downscales_ > 0) |
| 517 uma_container_->quality_downscales_counter_.Add( | 518 uma_container_->quality_downscales_counter_.Add(quality_downscales_); |
| 518 encoded_image.adapt_reason_.quality_resolution_downscales); | |
| 519 } | 519 } |
| 520 } | 520 } |
| 521 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { | 521 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { |
| 522 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; | 522 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; |
| 523 uma_container_->bw_limited_frame_counter_.Add(bw_limited); | 523 uma_container_->bw_limited_frame_counter_.Add(bw_limited); |
| 524 if (bw_limited) { | 524 if (bw_limited) { |
| 525 uma_container_->bw_resolutions_disabled_counter_.Add( | 525 uma_container_->bw_resolutions_disabled_counter_.Add( |
| 526 encoded_image.adapt_reason_.bw_resolutions_disabled); | 526 encoded_image.adapt_reason_.bw_resolutions_disabled); |
| 527 } | 527 } |
| 528 } | 528 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 } | 595 } |
| 596 | 596 |
| 597 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( | 597 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( |
| 598 bool cpu_restricted_resolution) { | 598 bool cpu_restricted_resolution) { |
| 599 rtc::CritScope lock(&crit_); | 599 rtc::CritScope lock(&crit_); |
| 600 stats_.cpu_limited_resolution = cpu_restricted_resolution; | 600 stats_.cpu_limited_resolution = cpu_restricted_resolution; |
| 601 ++stats_.number_of_cpu_adapt_changes; | 601 ++stats_.number_of_cpu_adapt_changes; |
| 602 } | 602 } |
| 603 | 603 |
| 604 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( | 604 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( |
| 605 bool restricted) { | 605 int nr_of_downscales) { |
| 606 rtc::CritScope lock(&crit_); | 606 rtc::CritScope lock(&crit_); |
| 607 uma_container_->quality_downscales_counter_.Add(restricted); | 607 quality_downscales_ = nr_of_downscales; |
| 608 stats_.bw_limited_resolution = restricted; | 608 stats_.bw_limited_resolution = nr_of_downscales > 0; |
| 609 } | 609 } |
| 610 | 610 |
| 611 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 611 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
| 612 uint32_t ssrc, | 612 uint32_t ssrc, |
| 613 const RtcpPacketTypeCounter& packet_counter) { | 613 const RtcpPacketTypeCounter& packet_counter) { |
| 614 rtc::CritScope lock(&crit_); | 614 rtc::CritScope lock(&crit_); |
| 615 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 615 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
| 616 if (!stats) | 616 if (!stats) |
| 617 return; | 617 return; |
| 618 | 618 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 return Fraction(min_required_samples, 1000.0f); | 716 return Fraction(min_required_samples, 1000.0f); |
| 717 } | 717 } |
| 718 | 718 |
| 719 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 719 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 720 int min_required_samples, float multiplier) const { | 720 int min_required_samples, float multiplier) const { |
| 721 if (num_samples < min_required_samples || num_samples == 0) | 721 if (num_samples < min_required_samples || num_samples == 0) |
| 722 return -1; | 722 return -1; |
| 723 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 723 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 724 } | 724 } |
| 725 } // namespace webrtc | 725 } // namespace webrtc |
| OLD | NEW |