| OLD | NEW |
| 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/video/capture/fake_video_capture_device.h" | 5 #include "media/video/capture/fake_video_capture_device.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 base::TimeTicks::Now()); | 149 base::TimeTicks::Now()); |
| 150 BeepAndScheduleNextCapture( | 150 BeepAndScheduleNextCapture( |
| 151 base::Bind(&FakeVideoCaptureDevice::CaptureUsingOwnBuffers, | 151 base::Bind(&FakeVideoCaptureDevice::CaptureUsingOwnBuffers, |
| 152 weak_factory_.GetWeakPtr())); | 152 weak_factory_.GetWeakPtr())); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void FakeVideoCaptureDevice::CaptureUsingClientBuffers() { | 155 void FakeVideoCaptureDevice::CaptureUsingClientBuffers() { |
| 156 DCHECK(thread_checker_.CalledOnValidThread()); | 156 DCHECK(thread_checker_.CalledOnValidThread()); |
| 157 | 157 |
| 158 const scoped_refptr<VideoCaptureDevice::Client::Buffer> capture_buffer = | 158 const scoped_refptr<VideoCaptureDevice::Client::Buffer> capture_buffer = |
| 159 client_->ReserveOutputBuffer(VideoFrame::I420, | 159 client_->ReserveOutputBuffer(capture_format_); |
| 160 capture_format_.frame_size); | |
| 161 DLOG_IF(ERROR, !capture_buffer) << "Couldn't allocate Capture Buffer"; | 160 DLOG_IF(ERROR, !capture_buffer) << "Couldn't allocate Capture Buffer"; |
| 162 if (!capture_buffer) | 161 if (!capture_buffer) |
| 163 return; | 162 return; |
| 164 | 163 |
| 165 uint8_t* const data_ptr = static_cast<uint8_t*>(capture_buffer->data()); | 164 uint8_t* const data_ptr = static_cast<uint8_t*>(capture_buffer->data()); |
| 166 memset(data_ptr, 0, capture_buffer->size()); | 165 memset(data_ptr, 0, capture_buffer->size()); |
| 167 DCHECK(data_ptr) << "Buffer has NO backing memory"; | 166 DCHECK(data_ptr) << "Buffer has NO backing memory"; |
| 168 | 167 |
| 169 DrawPacman(false /* use_argb */, | 168 DrawPacman(false /* use_argb */, |
| 170 data_ptr, | 169 data_ptr, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // Generate a synchronized beep sound every so many frames. | 204 // Generate a synchronized beep sound every so many frames. |
| 206 if (frame_count_++ % kFakeCaptureBeepCycle == 0) | 205 if (frame_count_++ % kFakeCaptureBeepCycle == 0) |
| 207 FakeAudioInputStream::BeepOnce(); | 206 FakeAudioInputStream::BeepOnce(); |
| 208 | 207 |
| 209 // Reschedule next CaptureTask. | 208 // Reschedule next CaptureTask. |
| 210 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, next_capture, | 209 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, next_capture, |
| 211 base::TimeDelta::FromMilliseconds(kFakeCapturePeriodMs)); | 210 base::TimeDelta::FromMilliseconds(kFakeCapturePeriodMs)); |
| 212 } | 211 } |
| 213 | 212 |
| 214 } // namespace media | 213 } // namespace media |
| OLD | NEW |