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 "content/browser/media/capture/content_video_capture_device_core.h" | 5 #include "content/browser/media/capture/content_video_capture_device_core.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 VideoCaptureOracle::Event event, | 68 VideoCaptureOracle::Event event, |
69 const gfx::Rect& damage_rect, | 69 const gfx::Rect& damage_rect, |
70 base::TimeTicks event_time, | 70 base::TimeTicks event_time, |
71 scoped_refptr<media::VideoFrame>* storage, | 71 scoped_refptr<media::VideoFrame>* storage, |
72 CaptureFrameCallback* callback) { | 72 CaptureFrameCallback* callback) { |
73 base::AutoLock guard(lock_); | 73 base::AutoLock guard(lock_); |
74 | 74 |
75 if (!client_) | 75 if (!client_) |
76 return false; // Capture is stopped. | 76 return false; // Capture is stopped. |
77 | 77 |
78 // Always round up the coded size to multiples of 16 pixels. | |
79 // See http://crbug.com/402151. | |
80 const gfx::Size visible_size = params_.requested_format.frame_size; | |
81 const gfx::Size coded_size((visible_size.width() + 15) & ~15, | |
82 (visible_size.height() + 15) & ~15); | |
83 | |
84 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> output_buffer = | 78 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> output_buffer = |
85 client_->ReserveOutputBuffer(video_frame_format_, coded_size); | 79 client_->ReserveOutputBuffer(video_frame_format_, |
| 80 params_.requested_format.frame_size); |
86 const bool should_capture = | 81 const bool should_capture = |
87 oracle_->ObserveEventAndDecideCapture(event, damage_rect, event_time); | 82 oracle_->ObserveEventAndDecideCapture(event, damage_rect, event_time); |
88 const bool content_is_dirty = | 83 const bool content_is_dirty = |
89 (event == VideoCaptureOracle::kCompositorUpdate || | 84 (event == VideoCaptureOracle::kCompositorUpdate || |
90 event == VideoCaptureOracle::kSoftwarePaint); | 85 event == VideoCaptureOracle::kSoftwarePaint); |
91 const char* event_name = | 86 const char* event_name = |
92 (event == VideoCaptureOracle::kTimerPoll ? "poll" : | 87 (event == VideoCaptureOracle::kTimerPoll ? "poll" : |
93 (event == VideoCaptureOracle::kCompositorUpdate ? "gpu" : | 88 (event == VideoCaptureOracle::kCompositorUpdate ? "gpu" : |
94 "paint")); | 89 "paint")); |
95 | 90 |
(...skipping 25 matching lines...) Expand all Loading... |
121 } | 116 } |
122 int frame_number = oracle_->RecordCapture(); | 117 int frame_number = oracle_->RecordCapture(); |
123 TRACE_EVENT_ASYNC_BEGIN2("mirroring", "Capture", output_buffer.get(), | 118 TRACE_EVENT_ASYNC_BEGIN2("mirroring", "Capture", output_buffer.get(), |
124 "frame_number", frame_number, | 119 "frame_number", frame_number, |
125 "trigger", event_name); | 120 "trigger", event_name); |
126 // NATIVE_TEXTURE frames wrap a texture mailbox, which we don't have at the | 121 // NATIVE_TEXTURE frames wrap a texture mailbox, which we don't have at the |
127 // moment. We do not construct those frames. | 122 // moment. We do not construct those frames. |
128 if (video_frame_format_ != media::VideoFrame::NATIVE_TEXTURE) { | 123 if (video_frame_format_ != media::VideoFrame::NATIVE_TEXTURE) { |
129 *storage = media::VideoFrame::WrapExternalPackedMemory( | 124 *storage = media::VideoFrame::WrapExternalPackedMemory( |
130 video_frame_format_, | 125 video_frame_format_, |
131 coded_size, | 126 params_.requested_format.frame_size, |
132 gfx::Rect(visible_size), | 127 gfx::Rect(params_.requested_format.frame_size), |
133 visible_size, | 128 params_.requested_format.frame_size, |
134 static_cast<uint8*>(output_buffer->data()), | 129 static_cast<uint8*>(output_buffer->data()), |
135 output_buffer->size(), | 130 output_buffer->size(), |
136 base::SharedMemory::NULLHandle(), | 131 base::SharedMemory::NULLHandle(), |
137 base::TimeDelta(), | 132 base::TimeDelta(), |
138 base::Closure()); | 133 base::Closure()); |
139 } | 134 } |
140 *callback = base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, | 135 *callback = base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, |
141 this, | 136 this, |
142 frame_number, | 137 frame_number, |
143 output_buffer); | 138 output_buffer); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 return; | 335 return; |
341 | 336 |
342 if (oracle_proxy_) | 337 if (oracle_proxy_) |
343 oracle_proxy_->ReportError(reason); | 338 oracle_proxy_->ReportError(reason); |
344 | 339 |
345 StopAndDeAllocate(); | 340 StopAndDeAllocate(); |
346 TransitionStateTo(kError); | 341 TransitionStateTo(kError); |
347 } | 342 } |
348 | 343 |
349 } // namespace content | 344 } // namespace content |
OLD | NEW |