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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 if (rtp_config.fec.red_payload_type != -1) { | 332 if (rtp_config.fec.red_payload_type != -1) { |
333 RTC_HISTOGRAMS_COUNTS_10000(kIndex, | 333 RTC_HISTOGRAMS_COUNTS_10000(kIndex, |
334 uma_prefix_ + "FecBitrateSentInKbps", | 334 uma_prefix_ + "FecBitrateSentInKbps", |
335 static_cast<int>(rtp_rtx.fec.TotalBytes() * | 335 static_cast<int>(rtp_rtx.fec.TotalBytes() * |
336 8 / elapsed_sec / 1000)); | 336 8 / elapsed_sec / 1000)); |
337 } | 337 } |
338 } | 338 } |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 void SendStatisticsProxy::SetContentType( | 342 void SendStatisticsProxy::OnEncoderReconfigured( |
343 VideoEncoderConfig::ContentType content_type) { | 343 const VideoEncoderConfig& config, |
| 344 const std::vector<VideoStream>& streams) { |
| 345 int preferred_bitrate_bps = 0; |
| 346 for (size_t i = 0; i < streams.size(); ++i) { |
| 347 if (i == streams.size() - 1) { |
| 348 preferred_bitrate_bps += streams[i].max_bitrate_bps; |
| 349 } else { |
| 350 preferred_bitrate_bps += streams[i].target_bitrate_bps; |
| 351 } |
| 352 } |
| 353 |
344 rtc::CritScope lock(&crit_); | 354 rtc::CritScope lock(&crit_); |
345 if (content_type_ != content_type) { | 355 stats_.preferred_media_bitrate_bps = preferred_bitrate_bps; |
| 356 |
| 357 if (content_type_ != config.content_type) { |
346 uma_container_->UpdateHistograms(rtp_config_, stats_); | 358 uma_container_->UpdateHistograms(rtp_config_, stats_); |
347 uma_container_.reset( | 359 uma_container_.reset(new UmaSamplesContainer( |
348 new UmaSamplesContainer(GetUmaPrefix(content_type), stats_, clock_)); | 360 GetUmaPrefix(config.content_type), stats_, clock_)); |
349 content_type_ = content_type; | 361 content_type_ = config.content_type; |
350 } | 362 } |
351 } | 363 } |
352 | 364 |
353 void SendStatisticsProxy::OnEncoderStatsUpdate(uint32_t framerate, | 365 void SendStatisticsProxy::OnEncoderStatsUpdate(uint32_t framerate, |
354 uint32_t bitrate) { | 366 uint32_t bitrate) { |
355 rtc::CritScope lock(&crit_); | 367 rtc::CritScope lock(&crit_); |
356 stats_.encode_frame_rate = framerate; | 368 stats_.encode_frame_rate = framerate; |
357 stats_.media_bitrate_bps = bitrate; | 369 stats_.media_bitrate_bps = bitrate; |
358 } | 370 } |
359 | 371 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 return Fraction(min_required_samples, 1000.0f); | 653 return Fraction(min_required_samples, 1000.0f); |
642 } | 654 } |
643 | 655 |
644 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 656 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
645 int min_required_samples, float multiplier) const { | 657 int min_required_samples, float multiplier) const { |
646 if (num_samples < min_required_samples || num_samples == 0) | 658 if (num_samples < min_required_samples || num_samples == 0) |
647 return -1; | 659 return -1; |
648 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 660 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
649 } | 661 } |
650 } // namespace webrtc | 662 } // namespace webrtc |
OLD | NEW |