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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 | 557 |
558 stats_proxy_->SetAdaptationStats(GetActiveCounts(kCpu), | 558 stats_proxy_->SetAdaptationStats(GetActiveCounts(kCpu), |
559 GetActiveCounts(kQuality)); | 559 GetActiveCounts(kQuality)); |
560 } | 560 } |
561 | 561 |
562 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { | 562 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { |
563 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); | 563 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); |
564 VideoFrame incoming_frame = video_frame; | 564 VideoFrame incoming_frame = video_frame; |
565 | 565 |
566 // Local time in webrtc time base. | 566 // Local time in webrtc time base. |
567 int64_t current_time_ms = clock_->TimeInMilliseconds(); | 567 int64_t current_time_us = clock_->TimeInMicroseconds(); |
568 int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec; | |
569 // If the frame is not from the capturer but from decoder, render time may | |
570 // be set to the future. To avoid irregularities in statistics, where frame | |
571 // is captured after being encoded, we should reset capture time here. | |
572 if (incoming_frame.timestamp_us() > current_time_us) | |
nisse-webrtc
2017/06/02 12:04:55
I don't quite understand the problem here, and I'd
ilnik
2017/06/02 13:02:21
Problem is that timestamps are sent over network a
nisse-webrtc
2017/06/08 06:58:36
I think I'm missing some context here, can you hel
ilnik
2017/06/08 07:26:00
It happens in PeerConnectionIntegrationTest.CanSen
nisse-webrtc
2017/06/08 07:38:36
Ok, I see. Could you clarify the comment a bit? I
ilnik
2017/06/08 08:01:43
I clarified the comment.
About the broad refacto
| |
573 incoming_frame.set_timestamp_us(current_time_us); | |
568 | 574 |
569 // Capture time may come from clock with an offset and drift from clock_. | 575 // Capture time may come from clock with an offset and drift from clock_. |
570 int64_t capture_ntp_time_ms; | 576 int64_t capture_ntp_time_ms; |
571 if (video_frame.ntp_time_ms() > 0) { | 577 if (video_frame.ntp_time_ms() > 0) { |
572 capture_ntp_time_ms = video_frame.ntp_time_ms(); | 578 capture_ntp_time_ms = video_frame.ntp_time_ms(); |
573 } else if (video_frame.render_time_ms() != 0) { | 579 } else if (video_frame.render_time_ms() != 0) { |
574 capture_ntp_time_ms = video_frame.render_time_ms() + delta_ntp_internal_ms_; | 580 capture_ntp_time_ms = video_frame.render_time_ms() + delta_ntp_internal_ms_; |
nisse-webrtc
2017/06/02 12:04:56
BTW, this delta_ntp_internal_ms may be the caching
ilnik
2017/06/02 13:02:21
Acknowledged.
| |
575 } else { | 581 } else { |
576 capture_ntp_time_ms = current_time_ms + delta_ntp_internal_ms_; | 582 capture_ntp_time_ms = current_time_ms + delta_ntp_internal_ms_; |
577 } | 583 } |
578 incoming_frame.set_ntp_time_ms(capture_ntp_time_ms); | 584 incoming_frame.set_ntp_time_ms(capture_ntp_time_ms); |
579 | 585 |
580 // Convert NTP time, in ms, to RTP timestamp. | 586 // Convert NTP time, in ms, to RTP timestamp. |
581 const int kMsToRtpTimestamp = 90; | 587 const int kMsToRtpTimestamp = 90; |
582 incoming_frame.set_timestamp( | 588 incoming_frame.set_timestamp( |
583 kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms())); | 589 kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms())); |
584 | 590 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1032 std::string ViEEncoder::AdaptCounter::ToString( | 1038 std::string ViEEncoder::AdaptCounter::ToString( |
1033 const std::vector<int>& counters) const { | 1039 const std::vector<int>& counters) const { |
1034 std::stringstream ss; | 1040 std::stringstream ss; |
1035 for (size_t reason = 0; reason < kScaleReasonSize; ++reason) { | 1041 for (size_t reason = 0; reason < kScaleReasonSize; ++reason) { |
1036 ss << (reason ? " cpu" : "quality") << ":" << counters[reason]; | 1042 ss << (reason ? " cpu" : "quality") << ":" << counters[reason]; |
1037 } | 1043 } |
1038 return ss.str(); | 1044 return ss.str(); |
1039 } | 1045 } |
1040 | 1046 |
1041 } // namespace webrtc | 1047 } // namespace webrtc |
OLD | NEW |