Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: webrtc/video/video_capture_input.cc

Issue 1534233002: Incorrect timestamps used by video analyzer with real camera Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updated to use current interfaces Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/video/video_quality_test.cc » ('j') | webrtc/video/video_quality_test.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 clock_(Clock::GetRealTimeClock()), 37 clock_(Clock::GetRealTimeClock()),
38 last_captured_timestamp_(0), 38 last_captured_timestamp_(0),
39 delta_ntp_internal_ms_(clock_->CurrentNtpInMilliseconds() - 39 delta_ntp_internal_ms_(clock_->CurrentNtpInMilliseconds() -
40 clock_->TimeInMilliseconds()), 40 clock_->TimeInMilliseconds()),
41 overuse_detector_(overuse_detector) {} 41 overuse_detector_(overuse_detector) {}
42 42
43 VideoCaptureInput::~VideoCaptureInput() { 43 VideoCaptureInput::~VideoCaptureInput() {
44 } 44 }
45 45
46 void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) { 46 void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) {
47 // TODO(pbos): Remove local rendering, it should be handled by the client code
48 // if required.
49 if (local_renderer_)
50 local_renderer_->OnFrame(video_frame);
51
52 stats_proxy_->OnIncomingFrame(video_frame.width(), video_frame.height()); 47 stats_proxy_->OnIncomingFrame(video_frame.width(), video_frame.height());
53 48
54 VideoFrame incoming_frame = video_frame; 49 VideoFrame incoming_frame = video_frame;
55 50
56 // Local time in webrtc time base. 51 // Local time in webrtc time base.
57 int64_t current_time = clock_->TimeInMilliseconds(); 52 int64_t current_time = clock_->TimeInMilliseconds();
58 incoming_frame.set_render_time_ms(current_time); 53 incoming_frame.set_render_time_ms(current_time);
59 54
60 // Capture time may come from clock with an offset and drift from clock_. 55 // Capture time may come from clock with an offset and drift from clock_.
61 int64_t capture_ntp_time_ms; 56 int64_t capture_ntp_time_ms;
62 if (video_frame.ntp_time_ms() != 0) { 57 if (video_frame.ntp_time_ms() != 0) {
63 capture_ntp_time_ms = video_frame.ntp_time_ms(); 58 capture_ntp_time_ms = video_frame.ntp_time_ms();
64 } else if (video_frame.render_time_ms() != 0) { 59 } else if (video_frame.render_time_ms() != 0) {
65 capture_ntp_time_ms = video_frame.render_time_ms() + delta_ntp_internal_ms_; 60 capture_ntp_time_ms = video_frame.render_time_ms() + delta_ntp_internal_ms_;
66 } else { 61 } else {
67 capture_ntp_time_ms = current_time + delta_ntp_internal_ms_; 62 capture_ntp_time_ms = current_time + delta_ntp_internal_ms_;
68 } 63 }
69 incoming_frame.set_ntp_time_ms(capture_ntp_time_ms); 64 incoming_frame.set_ntp_time_ms(capture_ntp_time_ms);
70 65
71 // Convert NTP time, in ms, to RTP timestamp. 66 // Convert NTP time, in ms, to RTP timestamp.
72 const int kMsToRtpTimestamp = 90; 67 const int kMsToRtpTimestamp = 90;
73 incoming_frame.set_timestamp( 68 incoming_frame.set_timestamp(
74 kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms())); 69 kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms()));
75 70
71 // TODO(pbos): Remove local rendering, it should be handled by the client code
72 // if required.
73 if (local_renderer_)
74 local_renderer_->OnFrame(incoming_frame);
75
76 rtc::CritScope lock(&crit_); 76 rtc::CritScope lock(&crit_);
77 if (incoming_frame.ntp_time_ms() <= last_captured_timestamp_) { 77 if (incoming_frame.ntp_time_ms() <= last_captured_timestamp_) {
78 // We don't allow the same capture time for two frames, drop this one. 78 // We don't allow the same capture time for two frames, drop this one.
79 LOG(LS_WARNING) << "Same/old NTP timestamp (" 79 LOG(LS_WARNING) << "Same/old NTP timestamp ("
80 << incoming_frame.ntp_time_ms() 80 << incoming_frame.ntp_time_ms()
81 << " <= " << last_captured_timestamp_ 81 << " <= " << last_captured_timestamp_
82 << ") for incoming frame. Dropping."; 82 << ") for incoming frame. Dropping.";
83 return; 83 return;
84 } 84 }
85 85
(...skipping 14 matching lines...) Expand all
100 if (!captured_frame_) 100 if (!captured_frame_)
101 return false; 101 return false;
102 102
103 *video_frame = *captured_frame_; 103 *video_frame = *captured_frame_;
104 captured_frame_.reset(); 104 captured_frame_.reset();
105 return true; 105 return true;
106 } 106 }
107 107
108 } // namespace internal 108 } // namespace internal
109 } // namespace webrtc 109 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/video/video_quality_test.cc » ('j') | webrtc/video/video_quality_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698