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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 stats_proxy_->SetResolutionRestrictionStats( | 452 stats_proxy_->SetResolutionRestrictionStats( |
453 false, scale_counter_[kCpu] > 0, scale_counter_[kQuality]); | 453 false, scale_counter_[kCpu] > 0, scale_counter_[kQuality]); |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { | 457 void ViEEncoder::OnFrame(const VideoFrame& video_frame) { |
458 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); | 458 RTC_DCHECK_RUNS_SERIALIZED(&incoming_frame_race_checker_); |
459 VideoFrame incoming_frame = video_frame; | 459 VideoFrame incoming_frame = video_frame; |
460 | 460 |
461 // Local time in webrtc time base. | 461 // Local time in webrtc time base. |
462 int64_t current_time = clock_->TimeInMilliseconds(); | 462 int64_t current_time_us = clock_->TimeInMicroseconds(); |
463 incoming_frame.set_render_time_ms(current_time); | 463 int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec; |
464 // TODO(nisse): This always overrides the incoming timestamp. Don't | |
465 // do that, trust the frame source. | |
466 incoming_frame.set_timestamp_us(current_time_us); | |
nisse-webrtc
2017/01/13 09:33:24
I plan to delete this in a followup. This line (bo
perkj_webrtc
2017/01/13 10:39:28
doesn't that cause a regression with for example t
| |
464 | 467 |
465 // Capture time may come from clock with an offset and drift from clock_. | 468 // Capture time may come from clock with an offset and drift from clock_. |
466 int64_t capture_ntp_time_ms; | 469 int64_t capture_ntp_time_ms; |
467 if (video_frame.ntp_time_ms() != 0) { | 470 if (video_frame.ntp_time_ms() != 0) { |
468 capture_ntp_time_ms = video_frame.ntp_time_ms(); | 471 capture_ntp_time_ms = video_frame.ntp_time_ms(); |
469 } else if (video_frame.render_time_ms() != 0) { | 472 } else if (video_frame.render_time_ms() != 0) { |
470 capture_ntp_time_ms = video_frame.render_time_ms() + delta_ntp_internal_ms_; | 473 capture_ntp_time_ms = video_frame.render_time_ms() + delta_ntp_internal_ms_; |
471 } else { | 474 } else { |
472 capture_ntp_time_ms = current_time + delta_ntp_internal_ms_; | 475 capture_ntp_time_ms = current_time_ms + delta_ntp_internal_ms_; |
473 } | 476 } |
474 incoming_frame.set_ntp_time_ms(capture_ntp_time_ms); | 477 incoming_frame.set_ntp_time_ms(capture_ntp_time_ms); |
475 | 478 |
476 // Convert NTP time, in ms, to RTP timestamp. | 479 // Convert NTP time, in ms, to RTP timestamp. |
477 const int kMsToRtpTimestamp = 90; | 480 const int kMsToRtpTimestamp = 90; |
478 incoming_frame.set_timestamp( | 481 incoming_frame.set_timestamp( |
479 kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms())); | 482 kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms())); |
480 | 483 |
481 if (incoming_frame.ntp_time_ms() <= last_captured_timestamp_) { | 484 if (incoming_frame.ntp_time_ms() <= last_captured_timestamp_) { |
482 // We don't allow the same capture time for two frames, drop this one. | 485 // We don't allow the same capture time for two frames, drop this one. |
483 LOG(LS_WARNING) << "Same/old NTP timestamp (" | 486 LOG(LS_WARNING) << "Same/old NTP timestamp (" |
484 << incoming_frame.ntp_time_ms() | 487 << incoming_frame.ntp_time_ms() |
485 << " <= " << last_captured_timestamp_ | 488 << " <= " << last_captured_timestamp_ |
486 << ") for incoming frame. Dropping."; | 489 << ") for incoming frame. Dropping."; |
487 return; | 490 return; |
488 } | 491 } |
489 | 492 |
490 bool log_stats = false; | 493 bool log_stats = false; |
491 if (current_time - last_frame_log_ms_ > kFrameLogIntervalMs) { | 494 if (current_time_ms - last_frame_log_ms_ > kFrameLogIntervalMs) { |
492 last_frame_log_ms_ = current_time; | 495 last_frame_log_ms_ = current_time_ms; |
493 log_stats = true; | 496 log_stats = true; |
494 } | 497 } |
495 | 498 |
496 last_captured_timestamp_ = incoming_frame.ntp_time_ms(); | 499 last_captured_timestamp_ = incoming_frame.ntp_time_ms(); |
497 encoder_queue_.PostTask(std::unique_ptr<rtc::QueuedTask>(new EncodeTask( | 500 encoder_queue_.PostTask(std::unique_ptr<rtc::QueuedTask>(new EncodeTask( |
498 incoming_frame, this, clock_->TimeInMilliseconds(), log_stats))); | 501 incoming_frame, this, clock_->TimeInMilliseconds(), log_stats))); |
499 } | 502 } |
500 | 503 |
501 bool ViEEncoder::EncoderPaused() const { | 504 bool ViEEncoder::EncoderPaused() const { |
502 RTC_DCHECK_RUN_ON(&encoder_queue_); | 505 RTC_DCHECK_RUN_ON(&encoder_queue_); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 --scale_counter_[reason]; | 757 --scale_counter_[reason]; |
755 source_proxy_->RequestHigherResolutionThan(current_pixel_count); | 758 source_proxy_->RequestHigherResolutionThan(current_pixel_count); |
756 LOG(LS_INFO) << "Scaling up resolution."; | 759 LOG(LS_INFO) << "Scaling up resolution."; |
757 for (size_t i = 0; i < kScaleReasonSize; ++i) { | 760 for (size_t i = 0; i < kScaleReasonSize; ++i) { |
758 LOG(LS_INFO) << "Scaled " << scale_counter_[i] | 761 LOG(LS_INFO) << "Scaled " << scale_counter_[i] |
759 << " times for reason: " << (i ? "cpu" : "quality"); | 762 << " times for reason: " << (i ? "cpu" : "quality"); |
760 } | 763 } |
761 } | 764 } |
762 | 765 |
763 } // namespace webrtc | 766 } // namespace webrtc |
OLD | NEW |