From 01d5a0b48d04f1d6cd8aee40d6e064a3d479f991 Mon Sep 17 00:00:00 2001 From: nisse Date: Wed, 31 May 2017 06:33:21 -0700 Subject: [PATCH] Propagate input capture time in ViEEncoder::OnFrame. BUG=webrtc:6977 Review-Url: https://codereview.webrtc.org/2763023002 Cr-Commit-Position: refs/heads/master@{#18351} --- webrtc/modules/video_coding/generic_encoder.cc | 6 +++++- webrtc/test/frame_generator_capturer.cc | 1 + webrtc/video/vie_encoder.cc | 6 +----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/webrtc/modules/video_coding/generic_encoder.cc b/webrtc/modules/video_coding/generic_encoder.cc index bfa534f8fb..50731c050a 100644 --- a/webrtc/modules/video_coding/generic_encoder.cc +++ b/webrtc/modules/video_coding/generic_encoder.cc @@ -126,7 +126,11 @@ int32_t VCMGenericEncoder::RequestFrame( // TODO(nisse): Used only with internal source. Delete as soon as // that feature is removed. The only implementation I've been able - // to find ignores what's in the frame. + // to find ignores what's in the frame. With one exception: It seems + // a few test cases, e.g., + // VideoSendStreamTest.VideoSendStreamStopSetEncoderRateToZero, set + // internal_source to true and use FakeEncoder. And the latter will + // happily encode this 1x1 frame and pass it on down the pipeline. return encoder_->Encode(VideoFrame(I420Buffer::Create(1, 1), kVideoRotation_0, 0), NULL, &frame_types); diff --git a/webrtc/test/frame_generator_capturer.cc b/webrtc/test/frame_generator_capturer.cc index 641000dc6e..bd3f8ca2a0 100644 --- a/webrtc/test/frame_generator_capturer.cc +++ b/webrtc/test/frame_generator_capturer.cc @@ -160,6 +160,7 @@ void FrameGeneratorCapturer::InsertFrame() { rtc::CritScope cs(&lock_); if (sending_) { VideoFrame* frame = frame_generator_->NextFrame(); + frame->set_timestamp_us(rtc::TimeMicros()); frame->set_ntp_time_ms(clock_->CurrentNtpInMilliseconds()); frame->set_rotation(fake_rotation_); if (first_frame_capture_time_ == -1) { diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc index a3b071ac00..76969b0371 100644 --- a/webrtc/video/vie_encoder.cc +++ b/webrtc/video/vie_encoder.cc @@ -587,11 +587,7 @@ void ViEEncoder::OnFrame(const VideoFrame& video_frame) { VideoFrame incoming_frame = video_frame; // Local time in webrtc time base. - int64_t current_time_us = clock_->TimeInMicroseconds(); - int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec; - // TODO(nisse): This always overrides the incoming timestamp. Don't - // do that, trust the frame source. - incoming_frame.set_timestamp_us(current_time_us); + int64_t current_time_ms = clock_->TimeInMilliseconds(); // Capture time may come from clock with an offset and drift from clock_. int64_t capture_ntp_time_ms;