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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 VideoCaptureInput::~VideoCaptureInput() { | 61 VideoCaptureInput::~VideoCaptureInput() { |
62 module_process_thread_->DeRegisterModule(overuse_detector_.get()); | 62 module_process_thread_->DeRegisterModule(overuse_detector_.get()); |
63 | 63 |
64 // Stop the thread. | 64 // Stop the thread. |
65 rtc::AtomicOps::ReleaseStore(&stop_, 1); | 65 rtc::AtomicOps::ReleaseStore(&stop_, 1); |
66 capture_event_.Set(); | 66 capture_event_.Set(); |
67 encoder_thread_.Stop(); | 67 encoder_thread_.Stop(); |
68 } | 68 } |
69 | 69 |
70 void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) { | 70 void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) { |
71 // TODO(pbos): Remove local rendering, it should be handled by the client code | |
72 // if required. | |
73 if (local_renderer_) | |
74 local_renderer_->RenderFrame(video_frame, 0); | |
75 | |
76 stats_proxy_->OnIncomingFrame(video_frame.width(), video_frame.height()); | 71 stats_proxy_->OnIncomingFrame(video_frame.width(), video_frame.height()); |
77 | 72 |
78 VideoFrame incoming_frame = video_frame; | 73 VideoFrame incoming_frame = video_frame; |
79 | 74 |
80 if (incoming_frame.ntp_time_ms() != 0) { | 75 if (incoming_frame.ntp_time_ms() != 0) { |
81 // If a NTP time stamp is set, this is the time stamp we will use. | 76 // If a NTP time stamp is set, this is the time stamp we will use. |
82 incoming_frame.set_render_time_ms(incoming_frame.ntp_time_ms() - | 77 incoming_frame.set_render_time_ms(incoming_frame.ntp_time_ms() - |
83 delta_ntp_internal_ms_); | 78 delta_ntp_internal_ms_); |
84 } else { // NTP time stamp not set. | 79 } else { // NTP time stamp not set. |
85 int64_t render_time = incoming_frame.render_time_ms() != 0 | 80 int64_t render_time = incoming_frame.render_time_ms() != 0 |
86 ? incoming_frame.render_time_ms() | 81 ? incoming_frame.render_time_ms() |
87 : TickTime::MillisecondTimestamp(); | 82 : TickTime::MillisecondTimestamp(); |
88 | 83 |
89 incoming_frame.set_render_time_ms(render_time); | 84 incoming_frame.set_render_time_ms(render_time); |
90 incoming_frame.set_ntp_time_ms(render_time + delta_ntp_internal_ms_); | 85 incoming_frame.set_ntp_time_ms(render_time + delta_ntp_internal_ms_); |
91 } | 86 } |
92 | 87 |
93 // Convert NTP time, in ms, to RTP timestamp. | 88 // Convert NTP time, in ms, to RTP timestamp. |
94 const int kMsToRtpTimestamp = 90; | 89 const int kMsToRtpTimestamp = 90; |
95 incoming_frame.set_timestamp( | 90 incoming_frame.set_timestamp( |
96 kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms())); | 91 kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms())); |
97 | 92 |
| 93 // TODO(pbos): Remove local rendering, it should be handled by the client code |
| 94 // if required. |
| 95 if (local_renderer_) |
| 96 local_renderer_->RenderFrame(incoming_frame, 0); |
| 97 |
98 CriticalSectionScoped cs(capture_cs_.get()); | 98 CriticalSectionScoped cs(capture_cs_.get()); |
99 if (incoming_frame.ntp_time_ms() <= last_captured_timestamp_) { | 99 if (incoming_frame.ntp_time_ms() <= last_captured_timestamp_) { |
100 // We don't allow the same capture time for two frames, drop this one. | 100 // We don't allow the same capture time for two frames, drop this one. |
101 LOG(LS_WARNING) << "Same/old NTP timestamp (" | 101 LOG(LS_WARNING) << "Same/old NTP timestamp (" |
102 << incoming_frame.ntp_time_ms() | 102 << incoming_frame.ntp_time_ms() |
103 << " <= " << last_captured_timestamp_ | 103 << " <= " << last_captured_timestamp_ |
104 << ") for incoming frame. Dropping."; | 104 << ") for incoming frame. Dropping."; |
105 return; | 105 return; |
106 } | 106 } |
107 | 107 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 // We're done! | 158 // We're done! |
159 if (capture_time != -1) { | 159 if (capture_time != -1) { |
160 overuse_detector_->FrameSent(capture_time); | 160 overuse_detector_->FrameSent(capture_time); |
161 } | 161 } |
162 return true; | 162 return true; |
163 } | 163 } |
164 | 164 |
165 } // namespace internal | 165 } // namespace internal |
166 } // namespace webrtc | 166 } // namespace webrtc |
OLD | NEW |