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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "media/audio/fake_audio_input_stream.h" | 12 #include "media/audio/fake_audio_input_stream.h" |
| 13 #include "media/base/video_frame.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
15 #include "third_party/skia/include/core/SkPaint.h" | 16 #include "third_party/skia/include/core/SkPaint.h" |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 | 19 |
19 static const int kFakeCaptureTimeoutMs = 50; | 20 static const int kFakeCaptureTimeoutMs = 50; |
20 static const int kFakeCaptureBeepCycle = 20; // Visual beep every 1s. | 21 static const int kFakeCaptureBeepCycle = 20; // Visual beep every 1s. |
21 static const int kFakeCaptureCapabilityChangePeriod = 30; | 22 static const int kFakeCaptureCapabilityChangePeriod = 30; |
22 enum { kNumberOfFakeDevices = 2 }; | 23 enum { kNumberOfFakeDevices = 2 }; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 208 |
208 if (frame_count_ % kFakeCaptureBeepCycle == 0) { | 209 if (frame_count_ % kFakeCaptureBeepCycle == 0) { |
209 // Generate a synchronized beep sound if there is one audio input | 210 // Generate a synchronized beep sound if there is one audio input |
210 // stream created. | 211 // stream created. |
211 FakeAudioInputStream::BeepOnce(); | 212 FakeAudioInputStream::BeepOnce(); |
212 } | 213 } |
213 | 214 |
214 frame_count_++; | 215 frame_count_++; |
215 | 216 |
216 // Give the captured frame to the client. | 217 // Give the captured frame to the client. |
217 client_->OnIncomingCapturedFrame(fake_frame_.get(), | 218 client_->OnIncomingCapturedData(fake_frame_.get(), |
218 frame_size, | 219 frame_size, |
219 base::TimeTicks::Now(), | 220 capture_format_, |
220 0, | 221 0, |
221 capture_format_); | 222 base::TimeTicks::Now()); |
222 if (!(frame_count_ % kFakeCaptureCapabilityChangePeriod) && | 223 if (!(frame_count_ % kFakeCaptureCapabilityChangePeriod) && |
223 format_roster_.size() > 0U) { | 224 format_roster_.size() > 0U) { |
224 Reallocate(); | 225 Reallocate(); |
225 } | 226 } |
226 // Reschedule next CaptureTask. | 227 // Reschedule next CaptureTask. |
227 capture_thread_.message_loop()->PostDelayedTask( | 228 capture_thread_.message_loop()->PostDelayedTask( |
228 FROM_HERE, | 229 FROM_HERE, |
229 base::Bind(&FakeVideoCaptureDevice::OnCaptureTask, | 230 base::Bind(&FakeVideoCaptureDevice::OnCaptureTask, |
230 base::Unretained(this)), | 231 base::Unretained(this)), |
231 base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs)); | 232 base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs)); |
(...skipping 18 matching lines...) Expand all Loading... |
250 media::VideoCaptureFormat(gfx::Size(320, 240), 30, PIXEL_FORMAT_I420)); | 251 media::VideoCaptureFormat(gfx::Size(320, 240), 30, PIXEL_FORMAT_I420)); |
251 format_roster_.push_back( | 252 format_roster_.push_back( |
252 media::VideoCaptureFormat(gfx::Size(640, 480), 30, PIXEL_FORMAT_I420)); | 253 media::VideoCaptureFormat(gfx::Size(640, 480), 30, PIXEL_FORMAT_I420)); |
253 format_roster_.push_back( | 254 format_roster_.push_back( |
254 media::VideoCaptureFormat(gfx::Size(800, 600), 30, PIXEL_FORMAT_I420)); | 255 media::VideoCaptureFormat(gfx::Size(800, 600), 30, PIXEL_FORMAT_I420)); |
255 | 256 |
256 format_roster_index_ = 0; | 257 format_roster_index_ = 0; |
257 } | 258 } |
258 | 259 |
259 } // namespace media | 260 } // namespace media |
OLD | NEW |