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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(), | 115 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(), |
116 "frame_number", frame_number, "trigger", event_name); | 116 "frame_number", frame_number, "trigger", event_name); |
117 | 117 |
118 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage); | 118 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage); |
119 *storage = VideoFrame::WrapExternalSharedMemory( | 119 *storage = VideoFrame::WrapExternalSharedMemory( |
120 params_.requested_format.pixel_format, coded_size, | 120 params_.requested_format.pixel_format, coded_size, |
121 gfx::Rect(visible_size), visible_size, | 121 gfx::Rect(visible_size), visible_size, |
122 static_cast<uint8_t*>(output_buffer->data()), | 122 static_cast<uint8_t*>(output_buffer->data()), |
123 output_buffer->mapped_size(), base::SharedMemory::NULLHandle(), 0u, | 123 output_buffer->mapped_size(), base::SharedMemory::NULLHandle(), 0u, |
124 base::TimeDelta()); | 124 base::TimeDelta()); |
125 DCHECK(*storage); | 125 if (!(*storage)) |
| 126 return false; |
126 *callback = | 127 *callback = |
127 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number, | 128 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number, |
128 base::Passed(&output_buffer), capture_begin_time, | 129 base::Passed(&output_buffer), capture_begin_time, |
129 oracle_.estimated_frame_duration()); | 130 oracle_.estimated_frame_duration()); |
130 return true; | 131 return true; |
131 } | 132 } |
132 | 133 |
133 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const { | 134 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const { |
134 base::AutoLock guard(lock_); | 135 base::AutoLock guard(lock_); |
135 return oracle_.capture_size(); | 136 return oracle_.capture_size(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // destructor. |metadata| is still valid for read-access at this point. | 198 // destructor. |metadata| is still valid for read-access at this point. |
198 double utilization = -1.0; | 199 double utilization = -1.0; |
199 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 200 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
200 &utilization)) { | 201 &utilization)) { |
201 base::AutoLock guard(lock_); | 202 base::AutoLock guard(lock_); |
202 oracle_.RecordConsumerFeedback(frame_number, utilization); | 203 oracle_.RecordConsumerFeedback(frame_number, utilization); |
203 } | 204 } |
204 } | 205 } |
205 | 206 |
206 } // namespace media | 207 } // namespace media |
OLD | NEW |