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 return; | 215 TRACE_EVENT_INSTANT0("gpu.capture", "CaptureSucceeded", |
| 216 TRACE_EVENT_SCOPE_THREAD); |
216 | 217 |
217 TRACE_EVENT_INSTANT0("gpu.capture", "CaptureSucceeded", | 218 if (!client_) |
218 TRACE_EVENT_SCOPE_THREAD); | 219 return; // Capture is stopped. |
219 | 220 |
220 if (!client_) | 221 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, |
221 return; // Capture is stopped. | 222 params_.requested_format.frame_rate); |
| 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); |
222 | 231 |
223 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, | 232 client_->OnIncomingCapturedVideoFrame(std::move(buffer), std::move(frame)); |
224 params_.requested_format.frame_rate); | 233 } |
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()); | |
241 } | 234 } |
242 | 235 |
243 void ThreadSafeCaptureOracle::OnConsumerReportingUtilization( | 236 void ThreadSafeCaptureOracle::OnConsumerReportingUtilization( |
244 int frame_number, | 237 int frame_number, |
245 double utilization) { | 238 double utilization) { |
246 base::AutoLock guard(lock_); | 239 base::AutoLock guard(lock_); |
247 oracle_.RecordConsumerFeedback(frame_number, utilization); | 240 oracle_.RecordConsumerFeedback(frame_number, utilization); |
248 } | 241 } |
249 | 242 |
250 } // namespace media | 243 } // namespace media |
OLD | NEW |