OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/capture/content/thread_safe_capture_oracle.h" | 5 #include "media/capture/content/thread_safe_capture_oracle.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 base::TimeDelta estimated_frame_duration, | 204 base::TimeDelta estimated_frame_duration, |
205 scoped_refptr<VideoFrame> frame, | 205 scoped_refptr<VideoFrame> frame, |
206 base::TimeTicks reference_time, | 206 base::TimeTicks reference_time, |
207 bool success) { | 207 bool success) { |
208 TRACE_EVENT_ASYNC_END2("gpu.capture", "Capture", buffer.get(), "success", | 208 TRACE_EVENT_ASYNC_END2("gpu.capture", "Capture", buffer.get(), "success", |
209 success, "timestamp", | 209 success, "timestamp", |
210 reference_time.ToInternalValue()); | 210 reference_time.ToInternalValue()); |
211 | 211 |
212 base::AutoLock guard(lock_); | 212 base::AutoLock guard(lock_); |
213 | 213 |
214 if (oracle_.CompleteCapture(frame_number, success, &reference_time)) { | 214 if (!oracle_.CompleteCapture(frame_number, success, &reference_time)) |
215 TRACE_EVENT_INSTANT0("gpu.capture", "CaptureSucceeded", | 215 return; |
216 TRACE_EVENT_SCOPE_THREAD); | |
217 | 216 |
218 if (!client_) | 217 TRACE_EVENT_INSTANT0("gpu.capture", "CaptureSucceeded", |
219 return; // Capture is stopped. | 218 TRACE_EVENT_SCOPE_THREAD); |
220 | 219 |
221 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, | 220 if (!client_) |
222 params_.requested_format.frame_rate); | 221 return; // Capture is stopped. |
223 frame->metadata()->SetTimeTicks(VideoFrameMetadata::CAPTURE_BEGIN_TIME, | |
224 capture_begin_time); | |
225 frame->metadata()->SetTimeTicks(VideoFrameMetadata::CAPTURE_END_TIME, | |
226 base::TimeTicks::Now()); | |
227 frame->metadata()->SetTimeDelta(VideoFrameMetadata::FRAME_DURATION, | |
228 estimated_frame_duration); | |
229 frame->metadata()->SetTimeTicks(VideoFrameMetadata::REFERENCE_TIME, | |
230 reference_time); | |
231 | 222 |
232 client_->OnIncomingCapturedVideoFrame(std::move(buffer), std::move(frame)); | 223 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, |
233 } | 224 params_.requested_format.frame_rate); |
| 225 frame->metadata()->SetTimeTicks(VideoFrameMetadata::CAPTURE_BEGIN_TIME, |
| 226 capture_begin_time); |
| 227 frame->metadata()->SetTimeTicks(VideoFrameMetadata::CAPTURE_END_TIME, |
| 228 base::TimeTicks::Now()); |
| 229 frame->metadata()->SetTimeDelta(VideoFrameMetadata::FRAME_DURATION, |
| 230 estimated_frame_duration); |
| 231 frame->metadata()->SetTimeTicks(VideoFrameMetadata::REFERENCE_TIME, |
| 232 reference_time); |
| 233 |
| 234 DCHECK(frame->IsMappable()); |
| 235 media::VideoCaptureFormat format(frame->coded_size(), |
| 236 params_.requested_format.frame_rate, |
| 237 frame->format(), media::PIXEL_STORAGE_CPU); |
| 238 client_->OnIncomingCapturedBufferExt( |
| 239 std::move(buffer), format, reference_time, frame->timestamp(), |
| 240 frame->visible_rect(), *frame->metadata()); |
234 } | 241 } |
235 | 242 |
236 void ThreadSafeCaptureOracle::OnConsumerReportingUtilization( | 243 void ThreadSafeCaptureOracle::OnConsumerReportingUtilization( |
237 int frame_number, | 244 int frame_number, |
238 double utilization) { | 245 double utilization) { |
239 base::AutoLock guard(lock_); | 246 base::AutoLock guard(lock_); |
240 oracle_.RecordConsumerFeedback(frame_number, utilization); | 247 oracle_.RecordConsumerFeedback(frame_number, utilization); |
241 } | 248 } |
242 | 249 |
243 } // namespace media | 250 } // namespace media |
OLD | NEW |