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

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

Issue 2613793007: Revert of [Mojo Video Capture] Simplify media::VideoCaptureDevice::Client:Buffer to a struct (Closed)
Patch Set: Created 3 years, 11 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 expected_execution_time, 313 expected_execution_time,
314 base::Bind(&FakeVideoCaptureDevice::CaptureUsingOwnBuffers, 314 base::Bind(&FakeVideoCaptureDevice::CaptureUsingOwnBuffers,
315 weak_factory_.GetWeakPtr())); 315 weak_factory_.GetWeakPtr()));
316 } 316 }
317 317
318 void FakeVideoCaptureDevice::CaptureUsingClientBuffers( 318 void FakeVideoCaptureDevice::CaptureUsingClientBuffers(
319 base::TimeTicks expected_execution_time) { 319 base::TimeTicks expected_execution_time) {
320 DCHECK(thread_checker_.CalledOnValidThread()); 320 DCHECK(thread_checker_.CalledOnValidThread());
321 321
322 const int arbitrary_frame_feedback_id = 0; 322 const int arbitrary_frame_feedback_id = 0;
323 VideoCaptureDevice::Client::Buffer capture_buffer = 323 std::unique_ptr<VideoCaptureDevice::Client::Buffer> capture_buffer(
324 client_->ReserveOutputBuffer( 324 client_->ReserveOutputBuffer(
325 capture_format_.frame_size, capture_format_.pixel_format, 325 capture_format_.frame_size, capture_format_.pixel_format,
326 capture_format_.pixel_storage, arbitrary_frame_feedback_id); 326 capture_format_.pixel_storage, arbitrary_frame_feedback_id));
327 DLOG_IF(ERROR, !capture_buffer.is_valid()) 327 DLOG_IF(ERROR, !capture_buffer) << "Couldn't allocate Capture Buffer";
328 << "Couldn't allocate Capture Buffer"; 328 DCHECK(capture_buffer->data()) << "Buffer has NO backing memory";
329 auto buffer_access =
330 capture_buffer.handle_provider()->GetHandleForInProcessAccess();
331 DCHECK(buffer_access->data()) << "Buffer has NO backing memory";
332 329
333 DCHECK_EQ(PIXEL_STORAGE_CPU, capture_format_.pixel_storage); 330 DCHECK_EQ(PIXEL_STORAGE_CPU, capture_format_.pixel_storage);
334 uint8_t* data_ptr = buffer_access->data(); 331 uint8_t* data_ptr = static_cast<uint8_t*>(capture_buffer->data());
335 memset(data_ptr, 0, buffer_access->mapped_size()); 332 memset(data_ptr, 0, capture_buffer->mapped_size());
336 DrawPacman(capture_format_.pixel_format, data_ptr, elapsed_time_, 333 DrawPacman(capture_format_.pixel_format, data_ptr, elapsed_time_,
337 fake_capture_rate_, capture_format_.frame_size, current_zoom_); 334 fake_capture_rate_, capture_format_.frame_size, current_zoom_);
338 335
339 // Give the captured frame to the client. 336 // Give the captured frame to the client.
340 base::TimeTicks now = base::TimeTicks::Now(); 337 base::TimeTicks now = base::TimeTicks::Now();
341 if (first_ref_time_.is_null()) 338 if (first_ref_time_.is_null())
342 first_ref_time_ = now; 339 first_ref_time_ = now;
343 client_->OnIncomingCapturedBuffer(std::move(capture_buffer), capture_format_, 340 client_->OnIncomingCapturedBuffer(std::move(capture_buffer), capture_format_,
344 now, now - first_ref_time_); 341 now, now - first_ref_time_);
345 342
(...skipping 24 matching lines...) Expand all
370 // Don't accumulate any debt if we are lagging behind - just post the next 367 // Don't accumulate any debt if we are lagging behind - just post the next
371 // frame immediately and continue as normal. 368 // frame immediately and continue as normal.
372 const base::TimeTicks next_execution_time = 369 const base::TimeTicks next_execution_time =
373 std::max(current_time, expected_execution_time + frame_interval); 370 std::max(current_time, expected_execution_time + frame_interval);
374 const base::TimeDelta delay = next_execution_time - current_time; 371 const base::TimeDelta delay = next_execution_time - current_time;
375 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 372 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
376 FROM_HERE, base::Bind(next_capture, next_execution_time), delay); 373 FROM_HERE, base::Bind(next_capture, next_execution_time), delay);
377 } 374 }
378 375
379 } // namespace media 376 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/content/thread_safe_capture_oracle.cc ('k') | media/capture/video/fake_video_capture_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698