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 10 matching lines...) Expand all Loading... |
21 enum { kNumberOfFakeDevices = 2 }; | 21 enum { kNumberOfFakeDevices = 2 }; |
22 | 22 |
23 bool FakeVideoCaptureDevice::fail_next_create_ = false; | 23 bool FakeVideoCaptureDevice::fail_next_create_ = false; |
24 | 24 |
25 void FakeVideoCaptureDevice::GetDeviceNames(Names* const device_names) { | 25 void FakeVideoCaptureDevice::GetDeviceNames(Names* const device_names) { |
26 // Empty the name list. | 26 // Empty the name list. |
27 device_names->erase(device_names->begin(), device_names->end()); | 27 device_names->erase(device_names->begin(), device_names->end()); |
28 | 28 |
29 for (int n = 0; n < kNumberOfFakeDevices; n++) { | 29 for (int n = 0; n < kNumberOfFakeDevices; n++) { |
30 Name name; | 30 Name name; |
31 name.unique_id = StringPrintf("/dev/video%d", n); | 31 name.unique_id = base::StringPrintf("/dev/video%d", n); |
32 name.device_name = StringPrintf("fake_device_%d", n); | 32 name.device_name = base::StringPrintf("fake_device_%d", n); |
33 device_names->push_back(name); | 33 device_names->push_back(name); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) { | 37 VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) { |
38 if (fail_next_create_) { | 38 if (fail_next_create_) { |
39 fail_next_create_ = false; | 39 fail_next_create_ = false; |
40 return NULL; | 40 return NULL; |
41 } | 41 } |
42 for (int n = 0; n < kNumberOfFakeDevices; ++n) { | 42 for (int n = 0; n < kNumberOfFakeDevices; ++n) { |
43 std::string possible_id = StringPrintf("/dev/video%d", n); | 43 std::string possible_id = base::StringPrintf("/dev/video%d", n); |
44 if (device_name.unique_id.compare(possible_id) == 0) { | 44 if (device_name.unique_id.compare(possible_id) == 0) { |
45 return new FakeVideoCaptureDevice(device_name); | 45 return new FakeVideoCaptureDevice(device_name); |
46 } | 46 } |
47 } | 47 } |
48 return NULL; | 48 return NULL; |
49 } | 49 } |
50 | 50 |
51 void FakeVideoCaptureDevice::SetFailNextCreate() { | 51 void FakeVideoCaptureDevice::SetFailNextCreate() { |
52 fail_next_create_ = true; | 52 fail_next_create_ = true; |
53 } | 53 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 fake_frame_.get(), frame_size_, base::Time::Now(), 0, false, false); | 196 fake_frame_.get(), frame_size_, base::Time::Now(), 0, false, false); |
197 // Reschedule next CaptureTask. | 197 // Reschedule next CaptureTask. |
198 capture_thread_.message_loop()->PostDelayedTask( | 198 capture_thread_.message_loop()->PostDelayedTask( |
199 FROM_HERE, | 199 FROM_HERE, |
200 base::Bind(&FakeVideoCaptureDevice::OnCaptureTask, | 200 base::Bind(&FakeVideoCaptureDevice::OnCaptureTask, |
201 base::Unretained(this)), | 201 base::Unretained(this)), |
202 base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs)); | 202 base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs)); |
203 } | 203 } |
204 | 204 |
205 } // namespace media | 205 } // namespace media |
OLD | NEW |