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_.pixel_format, |
160 capture_format_.frame_size); | 160 capture_format_.frame_size); |
161 DLOG_IF(ERROR, !capture_buffer) << "Couldn't allocate Capture Buffer"; | 161 DLOG_IF(ERROR, !capture_buffer) << "Couldn't allocate Capture Buffer"; |
162 if (!capture_buffer) | 162 if (!capture_buffer) |
163 return; | 163 return; |
164 | 164 |
165 uint8_t* const data_ptr = static_cast<uint8_t*>(capture_buffer->data()); | 165 uint8_t* const data_ptr = static_cast<uint8_t*>(capture_buffer->data()); |
166 memset(data_ptr, 0, capture_buffer->size()); | 166 memset(data_ptr, 0, capture_buffer->size()); |
167 DCHECK(data_ptr) << "Buffer has NO backing memory"; | 167 DCHECK(data_ptr) << "Buffer has NO backing memory"; |
168 | 168 |
169 DrawPacman(false /* use_argb */, | 169 DrawPacman(false /* use_argb */, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // Generate a synchronized beep sound every so many frames. | 205 // Generate a synchronized beep sound every so many frames. |
206 if (frame_count_++ % kFakeCaptureBeepCycle == 0) | 206 if (frame_count_++ % kFakeCaptureBeepCycle == 0) |
207 FakeAudioInputStream::BeepOnce(); | 207 FakeAudioInputStream::BeepOnce(); |
208 | 208 |
209 // Reschedule next CaptureTask. | 209 // Reschedule next CaptureTask. |
210 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, next_capture, | 210 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, next_capture, |
211 base::TimeDelta::FromMilliseconds(kFakeCapturePeriodMs)); | 211 base::TimeDelta::FromMilliseconds(kFakeCapturePeriodMs)); |
212 } | 212 } |
213 | 213 |
214 } // namespace media | 214 } // namespace media |
OLD | NEW |