Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: media/capture/video/fake_video_capture_device.cc

Issue 2068763002: Re-Reland: Make media/capture gn and gyps produce components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable warning 4267 in Win capture.gyp (probs. lost in the previous relanding). Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/video/fake_video_capture_device.h" 5 #include "media/capture/video/fake_video_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const size_t frame_size = capture_format_.ImageAllocationSize(); 180 const size_t frame_size = capture_format_.ImageAllocationSize();
181 memset(fake_frame_.get(), 0, frame_size); 181 memset(fake_frame_.get(), 0, frame_size);
182 182
183 DrawPacman(false /* use_argb */, fake_frame_.get(), elapsed_time_, 183 DrawPacman(false /* use_argb */, fake_frame_.get(), elapsed_time_,
184 fake_capture_rate_, capture_format_.frame_size); 184 fake_capture_rate_, capture_format_.frame_size);
185 185
186 // Give the captured frame to the client. 186 // Give the captured frame to the client.
187 base::TimeTicks now = base::TimeTicks::Now(); 187 base::TimeTicks now = base::TimeTicks::Now();
188 if (first_ref_time_.is_null()) 188 if (first_ref_time_.is_null())
189 first_ref_time_ = now; 189 first_ref_time_ = now;
190 client_->OnIncomingCapturedData(fake_frame_.get(), frame_size, 190 client_->OnIncomingCapturedData(
191 capture_format_, 0 /* rotation */, now, 191 fake_frame_.get(), static_cast<int>(frame_size), capture_format_,
192 now - first_ref_time_); 192 0u /* rotation */, now, now - first_ref_time_);
193 BeepAndScheduleNextCapture( 193 BeepAndScheduleNextCapture(
194 expected_execution_time, 194 expected_execution_time,
195 base::Bind(&FakeVideoCaptureDevice::CaptureUsingOwnBuffers, 195 base::Bind(&FakeVideoCaptureDevice::CaptureUsingOwnBuffers,
196 weak_factory_.GetWeakPtr())); 196 weak_factory_.GetWeakPtr()));
197 } 197 }
198 198
199 void FakeVideoCaptureDevice::CaptureUsingClientBuffers( 199 void FakeVideoCaptureDevice::CaptureUsingClientBuffers(
200 base::TimeTicks expected_execution_time) { 200 base::TimeTicks expected_execution_time) {
201 DCHECK(thread_checker_.CalledOnValidThread()); 201 DCHECK(thread_checker_.CalledOnValidThread());
202 202
(...skipping 12 matching lines...) Expand all
215 DrawPacman(false /* use_argb */, fake_frame_.get(), elapsed_time_, 215 DrawPacman(false /* use_argb */, fake_frame_.get(), elapsed_time_,
216 fake_capture_rate_, capture_format_.frame_size); 216 fake_capture_rate_, capture_format_.frame_size);
217 217
218 // Copy data from |fake_frame_| into the reserved planes of GpuMemoryBuffer. 218 // Copy data from |fake_frame_| into the reserved planes of GpuMemoryBuffer.
219 size_t offset = 0; 219 size_t offset = 0;
220 for (size_t i = 0; i < VideoFrame::NumPlanes(PIXEL_FORMAT_I420); ++i) { 220 for (size_t i = 0; i < VideoFrame::NumPlanes(PIXEL_FORMAT_I420); ++i) {
221 const size_t plane_size = 221 const size_t plane_size =
222 VideoFrame::PlaneSize(PIXEL_FORMAT_I420, i, 222 VideoFrame::PlaneSize(PIXEL_FORMAT_I420, i,
223 capture_format_.frame_size) 223 capture_format_.frame_size)
224 .GetArea(); 224 .GetArea();
225 memcpy(capture_buffer->data(i), fake_frame_.get() + offset, plane_size); 225 memcpy(capture_buffer->data(i), fake_frame_.get() + offset,
226 static_cast<int>(plane_size));
226 offset += plane_size; 227 offset += plane_size;
227 } 228 }
228 } else { 229 } else {
229 DCHECK_EQ(capture_format_.pixel_storage, PIXEL_STORAGE_CPU); 230 DCHECK_EQ(capture_format_.pixel_storage, PIXEL_STORAGE_CPU);
230 DCHECK_EQ(capture_format_.pixel_format, PIXEL_FORMAT_ARGB); 231 DCHECK_EQ(capture_format_.pixel_format, PIXEL_FORMAT_ARGB);
231 uint8_t* data_ptr = static_cast<uint8_t*>(capture_buffer->data()); 232 uint8_t* data_ptr = static_cast<uint8_t*>(capture_buffer->data());
232 memset(data_ptr, 0, capture_buffer->mapped_size()); 233 memset(data_ptr, 0, capture_buffer->mapped_size());
233 DrawPacman(true /* use_argb */, data_ptr, elapsed_time_, fake_capture_rate_, 234 DrawPacman(true /* use_argb */, data_ptr, elapsed_time_, fake_capture_rate_,
234 capture_format_.frame_size); 235 capture_format_.frame_size);
235 } 236 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // Don't accumulate any debt if we are lagging behind - just post the next 269 // Don't accumulate any debt if we are lagging behind - just post the next
269 // frame immediately and continue as normal. 270 // frame immediately and continue as normal.
270 const base::TimeTicks next_execution_time = 271 const base::TimeTicks next_execution_time =
271 std::max(current_time, expected_execution_time + frame_interval); 272 std::max(current_time, expected_execution_time + frame_interval);
272 const base::TimeDelta delay = next_execution_time - current_time; 273 const base::TimeDelta delay = next_execution_time - current_time;
273 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 274 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
274 FROM_HERE, base::Bind(next_capture, next_execution_time), delay); 275 FROM_HERE, base::Bind(next_capture, next_execution_time), delay);
275 } 276 }
276 277
277 } // namespace media 278 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698