OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 574 |
575 stats_proxy_->SetAdaptationStats(GetActiveCounts(kCpu), | 575 stats_proxy_->SetAdaptationStats(GetActiveCounts(kCpu), |
576 GetActiveCounts(kQuality)); | 576 GetActiveCounts(kQuality)); |
577 } | 577 } |
578 | 578 |
579 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { | 579 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { |
580 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); | 580 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); |
581 VideoFrame incoming_frame = video_frame; | 581 VideoFrame incoming_frame = video_frame; |
582 | 582 |
583 // Local time in webrtc time base. | 583 // Local time in webrtc time base. |
584 int64_t current_time_ms = clock_->TimeInMilliseconds(); | 584 int64_t current_time_us = clock_->TimeInMicroseconds(); |
| 585 int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec; |
| 586 // If the frame is not from the capturer but from decoder, render time may |
| 587 // be set to the future. To avoid irregularities in statistics, where frame |
| 588 // is captured after being encoded, we should reset capture time here. |
| 589 if (incoming_frame.timestamp_us() > current_time_us) |
| 590 incoming_frame.set_timestamp_us(current_time_us); |
585 | 591 |
586 // Capture time may come from clock with an offset and drift from clock_. | 592 // Capture time may come from clock with an offset and drift from clock_. |
587 int64_t capture_ntp_time_ms; | 593 int64_t capture_ntp_time_ms; |
588 if (video_frame.ntp_time_ms() > 0) { | 594 if (video_frame.ntp_time_ms() > 0) { |
589 capture_ntp_time_ms = video_frame.ntp_time_ms(); | 595 capture_ntp_time_ms = video_frame.ntp_time_ms(); |
590 } else if (video_frame.render_time_ms() != 0) { | 596 } else if (video_frame.render_time_ms() != 0) { |
591 capture_ntp_time_ms = video_frame.render_time_ms() + delta_ntp_internal_ms_; | 597 capture_ntp_time_ms = video_frame.render_time_ms() + delta_ntp_internal_ms_; |
592 } else { | 598 } else { |
593 capture_ntp_time_ms = current_time_ms + delta_ntp_internal_ms_; | 599 capture_ntp_time_ms = current_time_ms + delta_ntp_internal_ms_; |
594 } | 600 } |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 std::string ViEEncoder::AdaptCounter::ToString( | 1057 std::string ViEEncoder::AdaptCounter::ToString( |
1052 const std::vector<int>& counters) const { | 1058 const std::vector<int>& counters) const { |
1053 std::stringstream ss; | 1059 std::stringstream ss; |
1054 for (size_t reason = 0; reason < kScaleReasonSize; ++reason) { | 1060 for (size_t reason = 0; reason < kScaleReasonSize; ++reason) { |
1055 ss << (reason ? " cpu" : "quality") << ":" << counters[reason]; | 1061 ss << (reason ? " cpu" : "quality") << ":" << counters[reason]; |
1056 } | 1062 } |
1057 return ss.str(); | 1063 return ss.str(); |
1058 } | 1064 } |
1059 | 1065 |
1060 } // namespace webrtc | 1066 } // namespace webrtc |
OLD | NEW |