| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 VideoEncoderConfig::ContentType content_type) { | 342 VideoEncoderConfig::ContentType content_type) { |
| 343 rtc::CritScope lock(&crit_); | 343 rtc::CritScope lock(&crit_); |
| 344 if (content_type_ != content_type) { | 344 if (content_type_ != content_type) { |
| 345 uma_container_->UpdateHistograms(config_, stats_); | 345 uma_container_->UpdateHistograms(config_, stats_); |
| 346 uma_container_.reset( | 346 uma_container_.reset( |
| 347 new UmaSamplesContainer(GetUmaPrefix(content_type), stats_, clock_)); | 347 new UmaSamplesContainer(GetUmaPrefix(content_type), stats_, clock_)); |
| 348 content_type_ = content_type; | 348 content_type_ = content_type; |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 void SendStatisticsProxy::OnEncoderStatsUpdate( | 352 void SendStatisticsProxy::OnEncoderStatsUpdate(uint32_t framerate, |
| 353 uint32_t framerate, | 353 uint32_t bitrate) { |
| 354 uint32_t bitrate, | |
| 355 const std::string& encoder_name) { | |
| 356 rtc::CritScope lock(&crit_); | 354 rtc::CritScope lock(&crit_); |
| 357 stats_.encode_frame_rate = framerate; | 355 stats_.encode_frame_rate = framerate; |
| 358 stats_.media_bitrate_bps = bitrate; | 356 stats_.media_bitrate_bps = bitrate; |
| 359 stats_.encoder_implementation_name = encoder_name; | |
| 360 } | 357 } |
| 361 | 358 |
| 362 void SendStatisticsProxy::OnEncodedFrameTimeMeasured( | 359 void SendStatisticsProxy::OnEncodedFrameTimeMeasured( |
| 363 int encode_time_ms, | 360 int encode_time_ms, |
| 364 const CpuOveruseMetrics& metrics) { | 361 const CpuOveruseMetrics& metrics) { |
| 365 rtc::CritScope lock(&crit_); | 362 rtc::CritScope lock(&crit_); |
| 366 uma_container_->encode_time_counter_.Add(encode_time_ms); | 363 uma_container_->encode_time_counter_.Add(encode_time_ms); |
| 367 encode_time_.Apply(1.0f, encode_time_ms); | 364 encode_time_.Apply(1.0f, encode_time_ms); |
| 368 stats_.avg_encode_time_ms = round(encode_time_.filtered()); | 365 stats_.avg_encode_time_ms = round(encode_time_.filtered()); |
| 369 stats_.encode_usage_percent = metrics.encode_usage_percent; | 366 stats_.encode_usage_percent = metrics.encode_usage_percent; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 void SendStatisticsProxy::OnSetEncoderTargetRate(uint32_t bitrate_bps) { | 431 void SendStatisticsProxy::OnSetEncoderTargetRate(uint32_t bitrate_bps) { |
| 435 rtc::CritScope lock(&crit_); | 432 rtc::CritScope lock(&crit_); |
| 436 stats_.target_media_bitrate_bps = bitrate_bps; | 433 stats_.target_media_bitrate_bps = bitrate_bps; |
| 437 } | 434 } |
| 438 | 435 |
| 439 void SendStatisticsProxy::OnSendEncodedImage( | 436 void SendStatisticsProxy::OnSendEncodedImage( |
| 440 const EncodedImage& encoded_image, | 437 const EncodedImage& encoded_image, |
| 441 const CodecSpecificInfo* codec_info) { | 438 const CodecSpecificInfo* codec_info) { |
| 442 size_t simulcast_idx = 0; | 439 size_t simulcast_idx = 0; |
| 443 | 440 |
| 441 rtc::CritScope lock(&crit_); |
| 444 if (codec_info) { | 442 if (codec_info) { |
| 445 if (codec_info->codecType == kVideoCodecVP8) { | 443 if (codec_info->codecType == kVideoCodecVP8) { |
| 446 simulcast_idx = codec_info->codecSpecific.VP8.simulcastIdx; | 444 simulcast_idx = codec_info->codecSpecific.VP8.simulcastIdx; |
| 447 } else if (codec_info->codecType == kVideoCodecGeneric) { | 445 } else if (codec_info->codecType == kVideoCodecGeneric) { |
| 448 simulcast_idx = codec_info->codecSpecific.generic.simulcast_idx; | 446 simulcast_idx = codec_info->codecSpecific.generic.simulcast_idx; |
| 449 } | 447 } |
| 448 if (codec_info->codec_name) { |
| 449 stats_.encoder_implementation_name = codec_info->codec_name; |
| 450 } |
| 450 } | 451 } |
| 451 | 452 |
| 452 if (simulcast_idx >= config_.rtp.ssrcs.size()) { | 453 if (simulcast_idx >= config_.rtp.ssrcs.size()) { |
| 453 LOG(LS_ERROR) << "Encoded image outside simulcast range (" << simulcast_idx | 454 LOG(LS_ERROR) << "Encoded image outside simulcast range (" << simulcast_idx |
| 454 << " >= " << config_.rtp.ssrcs.size() << ")."; | 455 << " >= " << config_.rtp.ssrcs.size() << ")."; |
| 455 return; | 456 return; |
| 456 } | 457 } |
| 457 uint32_t ssrc = config_.rtp.ssrcs[simulcast_idx]; | 458 uint32_t ssrc = config_.rtp.ssrcs[simulcast_idx]; |
| 458 | 459 |
| 459 rtc::CritScope lock(&crit_); | |
| 460 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 460 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
| 461 if (!stats) | 461 if (!stats) |
| 462 return; | 462 return; |
| 463 | 463 |
| 464 stats->width = encoded_image._encodedWidth; | 464 stats->width = encoded_image._encodedWidth; |
| 465 stats->height = encoded_image._encodedHeight; | 465 stats->height = encoded_image._encodedHeight; |
| 466 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); | 466 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); |
| 467 | 467 |
| 468 uma_container_->key_frame_counter_.Add(encoded_image._frameType == | 468 uma_container_->key_frame_counter_.Add(encoded_image._frameType == |
| 469 kVideoFrameKey); | 469 kVideoFrameKey); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 return Fraction(min_required_samples, 1000.0f); | 640 return Fraction(min_required_samples, 1000.0f); |
| 641 } | 641 } |
| 642 | 642 |
| 643 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 643 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 644 int min_required_samples, float multiplier) const { | 644 int min_required_samples, float multiplier) const { |
| 645 if (num_samples < min_required_samples || num_samples == 0) | 645 if (num_samples < min_required_samples || num_samples == 0) |
| 646 return -1; | 646 return -1; |
| 647 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 647 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 648 } | 648 } |
| 649 } // namespace webrtc | 649 } // namespace webrtc |
| OLD | NEW |