OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (width > 320) { // VGA | 63 if (width > 320) { // VGA |
64 current_settings.width = 640; | 64 current_settings.width = 640; |
65 current_settings.height = 480; | 65 current_settings.height = 480; |
66 current_settings.frame_rate = 30; | 66 current_settings.frame_rate = 30; |
67 } else { // QVGA | 67 } else { // QVGA |
68 current_settings.width = 320; | 68 current_settings.width = 320; |
69 current_settings.height = 240; | 69 current_settings.height = 240; |
70 current_settings.frame_rate = 30; | 70 current_settings.frame_rate = 30; |
71 } | 71 } |
72 | 72 |
73 fake_frame_.reset(new uint8[current_settings.width * | 73 size_t fake_frame_size = |
74 current_settings.height * 3 / 2]); | 74 current_settings.width * current_settings.height * 3 / 2; |
75 memset(fake_frame_.get(), 0, sizeof(fake_frame_.get())); | 75 fake_frame_.reset(new uint8[fake_frame_size]); |
| 76 memset(fake_frame_.get(), 0, fake_frame_size); |
76 | 77 |
77 state_ = kAllocated; | 78 state_ = kAllocated; |
78 observer_->OnFrameInfo(current_settings); | 79 observer_->OnFrameInfo(current_settings); |
79 } | 80 } |
80 | 81 |
81 void FakeVideoCaptureDevice::Start() { | 82 void FakeVideoCaptureDevice::Start() { |
82 if (state_ != kAllocated) { | 83 if (state_ != kAllocated) { |
83 return; // Wrong state. | 84 return; // Wrong state. |
84 } | 85 } |
85 state_ = kCapturing; | 86 state_ = kCapturing; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 sizeof(fake_frame_.get()), | 119 sizeof(fake_frame_.get()), |
119 base::Time::Now()); | 120 base::Time::Now()); |
120 // Reschedule next CaptureTask. | 121 // Reschedule next CaptureTask. |
121 capture_thread_.message_loop()->PostDelayedTask( | 122 capture_thread_.message_loop()->PostDelayedTask( |
122 FROM_HERE, | 123 FROM_HERE, |
123 NewRunnableMethod(this, &FakeVideoCaptureDevice::OnCaptureTask), | 124 NewRunnableMethod(this, &FakeVideoCaptureDevice::OnCaptureTask), |
124 kFakeCaptureTimeoutMs); | 125 kFakeCaptureTimeoutMs); |
125 } | 126 } |
126 | 127 |
127 } // namespace media | 128 } // namespace media |
OLD | NEW |