| 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 |
| 11 #include "webrtc/video/receive_statistics_proxy.h" | 11 #include "webrtc/video/receive_statistics_proxy.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <cmath> | 14 #include <cmath> |
| 15 #include <utility> | 15 #include <utility> |
| 16 | 16 |
| 17 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 17 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 18 #include "webrtc/rtc_base/checks.h" | 18 #include "webrtc/rtc_base/checks.h" |
| 19 #include "webrtc/rtc_base/logging.h" | 19 #include "webrtc/rtc_base/logging.h" |
| 20 #include "webrtc/rtc_base/trace_event.h" | |
| 21 #include "webrtc/system_wrappers/include/clock.h" | 20 #include "webrtc/system_wrappers/include/clock.h" |
| 22 #include "webrtc/system_wrappers/include/field_trial.h" | 21 #include "webrtc/system_wrappers/include/field_trial.h" |
| 23 #include "webrtc/system_wrappers/include/metrics.h" | 22 #include "webrtc/system_wrappers/include/metrics.h" |
| 24 | 23 |
| 25 namespace webrtc { | 24 namespace webrtc { |
| 26 namespace { | 25 namespace { |
| 27 // Periodic time interval for processing samples for |freq_offset_counter_|. | 26 // Periodic time interval for processing samples for |freq_offset_counter_|. |
| 28 const int64_t kFreqOffsetProcessIntervalMs = 40000; | 27 const int64_t kFreqOffsetProcessIntervalMs = 40000; |
| 29 | 28 |
| 30 // Configuration for bad call detection. | 29 // Configuration for bad call detection. |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 stats_.jitter_buffer_ms = jitter_buffer_ms; | 449 stats_.jitter_buffer_ms = jitter_buffer_ms; |
| 451 stats_.min_playout_delay_ms = min_playout_delay_ms; | 450 stats_.min_playout_delay_ms = min_playout_delay_ms; |
| 452 stats_.render_delay_ms = render_delay_ms; | 451 stats_.render_delay_ms = render_delay_ms; |
| 453 decode_time_counter_.Add(decode_ms); | 452 decode_time_counter_.Add(decode_ms); |
| 454 jitter_buffer_delay_counter_.Add(jitter_buffer_ms); | 453 jitter_buffer_delay_counter_.Add(jitter_buffer_ms); |
| 455 target_delay_counter_.Add(target_delay_ms); | 454 target_delay_counter_.Add(target_delay_ms); |
| 456 current_delay_counter_.Add(current_delay_ms); | 455 current_delay_counter_.Add(current_delay_ms); |
| 457 // Network delay (rtt/2) + target_delay_ms (jitter delay + decode time + | 456 // Network delay (rtt/2) + target_delay_ms (jitter delay + decode time + |
| 458 // render delay). | 457 // render delay). |
| 459 delay_counter_.Add(target_delay_ms + avg_rtt_ms_ / 2); | 458 delay_counter_.Add(target_delay_ms + avg_rtt_ms_ / 2); |
| 460 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.DecodeTimeInMs", | |
| 461 "decode_ms", decode_ms, "ssrc", stats_.ssrc); | |
| 462 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.MaxDecodeTimeInMs", | |
| 463 "max_decode_ms", max_decode_ms, "ssrc", stats_.ssrc); | |
| 464 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.CurrentDelayInMs", | |
| 465 "current_delay_ms", current_delay_ms, | |
| 466 "ssrc", stats_.ssrc); | |
| 467 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.TargetDelayInMs", | |
| 468 "target_delay_ms", target_delay_ms, | |
| 469 "ssrc", stats_.ssrc); | |
| 470 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.JitterBufferDelayInMs", | |
| 471 "jitter_buffer_ms", jitter_buffer_ms, | |
| 472 "ssrc", stats_.ssrc); | |
| 473 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.RenderDelayInMs", | |
| 474 "render_delay_ms", render_delay_ms, | |
| 475 "ssrc", stats_.ssrc); | |
| 476 } | 459 } |
| 477 | 460 |
| 478 void ReceiveStatisticsProxy::OnTimingFrameInfoUpdated( | 461 void ReceiveStatisticsProxy::OnTimingFrameInfoUpdated( |
| 479 const TimingFrameInfo& info) { | 462 const TimingFrameInfo& info) { |
| 480 rtc::CritScope lock(&crit_); | 463 rtc::CritScope lock(&crit_); |
| 481 // Only the frame which was processed the longest since the last | 464 // Only the frame which was processed the longest since the last |
| 482 // GetStats() call is reported. Therefore, only single 'longest' frame is | 465 // GetStats() call is reported. Therefore, only single 'longest' frame is |
| 483 // stored. | 466 // stored. |
| 484 if (!timing_frame_info_ || info.IsLongerThan(*timing_frame_info_)) { | 467 if (!timing_frame_info_ || info.IsLongerThan(*timing_frame_info_)) { |
| 485 timing_frame_info_.emplace(info); | 468 timing_frame_info_.emplace(info); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 501 rtc::CritScope lock(&crit_); | 484 rtc::CritScope lock(&crit_); |
| 502 // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we | 485 // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we |
| 503 // receive stats from one of them. | 486 // receive stats from one of them. |
| 504 if (stats_.ssrc != ssrc) | 487 if (stats_.ssrc != ssrc) |
| 505 return; | 488 return; |
| 506 stats_.rtcp_stats = statistics; | 489 stats_.rtcp_stats = statistics; |
| 507 report_block_stats_.Store(statistics, ssrc, 0); | 490 report_block_stats_.Store(statistics, ssrc, 0); |
| 508 | 491 |
| 509 if (first_report_block_time_ms_ == -1) | 492 if (first_report_block_time_ms_ == -1) |
| 510 first_report_block_time_ms_ = clock_->TimeInMilliseconds(); | 493 first_report_block_time_ms_ = clock_->TimeInMilliseconds(); |
| 511 | |
| 512 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.PacketsLost", | |
| 513 "packets_lost", statistics.cumulative_lost, | |
| 514 "ssrc", stats_.ssrc); | |
| 515 } | 494 } |
| 516 | 495 |
| 517 void ReceiveStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) { | 496 void ReceiveStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) { |
| 518 rtc::CritScope lock(&crit_); | 497 rtc::CritScope lock(&crit_); |
| 519 // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we | 498 // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we |
| 520 // receive stats from one of them. | 499 // receive stats from one of them. |
| 521 if (stats_.ssrc != ssrc) | 500 if (stats_.ssrc != ssrc) |
| 522 return; | 501 return; |
| 523 stats_.c_name = cname; | 502 stats_.c_name = cname; |
| 524 } | 503 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 if (last_content_type_ == VideoContentType::SCREENSHARE) { | 591 if (last_content_type_ == VideoContentType::SCREENSHARE) { |
| 613 e2e_delay_max_ms_screenshare_ = | 592 e2e_delay_max_ms_screenshare_ = |
| 614 std::max(delay_ms, e2e_delay_max_ms_screenshare_); | 593 std::max(delay_ms, e2e_delay_max_ms_screenshare_); |
| 615 e2e_delay_counter_screenshare_.Add(delay_ms); | 594 e2e_delay_counter_screenshare_.Add(delay_ms); |
| 616 } else { | 595 } else { |
| 617 e2e_delay_max_ms_video_ = std::max(delay_ms, e2e_delay_max_ms_video_); | 596 e2e_delay_max_ms_video_ = std::max(delay_ms, e2e_delay_max_ms_video_); |
| 618 e2e_delay_counter_video_.Add(delay_ms); | 597 e2e_delay_counter_video_.Add(delay_ms); |
| 619 } | 598 } |
| 620 } | 599 } |
| 621 } | 600 } |
| 622 | |
| 623 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.ReceivedWidthInPixels", | |
| 624 "width", width, "ssrc", stats_.ssrc); | |
| 625 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.ReceivedHeightInPixels", | |
| 626 "height", height, "ssrc", stats_.ssrc); | |
| 627 TRACE_EVENT_INSTANT1("webrtc_stats", "WebRTC.Video.OnRenderedFrame", | |
| 628 "ssrc", stats_.ssrc); | |
| 629 } | 601 } |
| 630 | 602 |
| 631 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms, | 603 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms, |
| 632 double estimated_freq_khz) { | 604 double estimated_freq_khz) { |
| 633 rtc::CritScope lock(&crit_); | 605 rtc::CritScope lock(&crit_); |
| 634 sync_offset_counter_.Add(std::abs(sync_offset_ms)); | 606 sync_offset_counter_.Add(std::abs(sync_offset_ms)); |
| 635 stats_.sync_offset_ms = sync_offset_ms; | 607 stats_.sync_offset_ms = sync_offset_ms; |
| 636 | 608 |
| 637 const double kMaxFreqKhz = 10000.0; | 609 const double kMaxFreqKhz = 10000.0; |
| 638 int offset_khz = kMaxFreqKhz; | 610 int offset_khz = kMaxFreqKhz; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 sum = 0; | 673 sum = 0; |
| 702 } | 674 } |
| 703 | 675 |
| 704 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms, | 676 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms, |
| 705 int64_t max_rtt_ms) { | 677 int64_t max_rtt_ms) { |
| 706 rtc::CritScope lock(&crit_); | 678 rtc::CritScope lock(&crit_); |
| 707 avg_rtt_ms_ = avg_rtt_ms; | 679 avg_rtt_ms_ = avg_rtt_ms; |
| 708 } | 680 } |
| 709 | 681 |
| 710 } // namespace webrtc | 682 } // namespace webrtc |
| OLD | NEW |