| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return; // Wrong state. | 142 return; // Wrong state. |
| 143 } | 143 } |
| 144 capture_thread_.Stop(); | 144 capture_thread_.Stop(); |
| 145 state_ = kIdle; | 145 state_ = kIdle; |
| 146 } | 146 } |
| 147 | 147 |
| 148 const VideoCaptureDevice::Name& FakeVideoCaptureDevice::device_name() { | 148 const VideoCaptureDevice::Name& FakeVideoCaptureDevice::device_name() { |
| 149 return device_name_; | 149 return device_name_; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void FakeVideoCaptureDevice::GetDeviceSupportedFormats( |
| 153 scoped_ptr<EventHandler> client) { |
| 154 VideoCaptureCapability capture_format; |
| 155 VideoCaptureFormats capture_formats; |
| 156 capture_format.color = media::PIXEL_FORMAT_I420; |
| 157 capture_format.width = 640; |
| 158 capture_format.height = 480; |
| 159 capture_format.frame_rate = GetFrameRate(); |
| 160 capture_formats.push_back(capture_format); |
| 161 client->OnDeviceSupportedFormatsEnumerated(capture_formats); |
| 162 } |
| 163 |
| 164 int FakeVideoCaptureDevice::GetFrameRate() const { |
| 165 return (1000 / kFakeCaptureTimeoutMs); |
| 166 } |
| 167 |
| 152 void FakeVideoCaptureDevice::OnCaptureTask() { | 168 void FakeVideoCaptureDevice::OnCaptureTask() { |
| 153 if (state_ != kCapturing) { | 169 if (state_ != kCapturing) { |
| 154 return; | 170 return; |
| 155 } | 171 } |
| 156 | 172 |
| 157 const size_t frame_size = VideoFrame::AllocationSize( | 173 const size_t frame_size = VideoFrame::AllocationSize( |
| 158 VideoFrame::I420, | 174 VideoFrame::I420, |
| 159 gfx::Size(capture_format_.width, capture_format_.height)); | 175 gfx::Size(capture_format_.width, capture_format_.height)); |
| 160 memset(fake_frame_.get(), 0, frame_size); | 176 memset(fake_frame_.get(), 0, frame_size); |
| 161 | 177 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 30, | 264 30, |
| 249 PIXEL_FORMAT_I420, | 265 PIXEL_FORMAT_I420, |
| 250 0, | 266 0, |
| 251 false, | 267 false, |
| 252 VariableResolutionVideoCaptureDevice)); | 268 VariableResolutionVideoCaptureDevice)); |
| 253 | 269 |
| 254 capabilities_roster_index_ = 0; | 270 capabilities_roster_index_ = 0; |
| 255 } | 271 } |
| 256 | 272 |
| 257 } // namespace media | 273 } // namespace media |
| OLD | NEW |