| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 EventHandler* observer) { | 72 EventHandler* observer) { |
| 73 capture_format_.frame_size_type = capture_format.frame_size_type; | 73 capture_format_.frame_size_type = capture_format.frame_size_type; |
| 74 if (capture_format.frame_size_type == VariableResolutionVideoCaptureDevice) | 74 if (capture_format.frame_size_type == VariableResolutionVideoCaptureDevice) |
| 75 PopulateCapabilitiesRoster(); | 75 PopulateCapabilitiesRoster(); |
| 76 | 76 |
| 77 if (state_ != kIdle) { | 77 if (state_ != kIdle) { |
| 78 return; // Wrong state. | 78 return; // Wrong state. |
| 79 } | 79 } |
| 80 | 80 |
| 81 observer_ = observer; | 81 observer_ = observer; |
| 82 capture_format_.color = VideoCaptureCapability::kI420; | 82 capture_format_.color = PIXEL_FORMAT_I420; |
| 83 capture_format_.expected_capture_delay = 0; | 83 capture_format_.expected_capture_delay = 0; |
| 84 capture_format_.interlaced = false; | 84 capture_format_.interlaced = false; |
| 85 if (capture_format.width > 320) { // VGA | 85 if (capture_format.width > 320) { // VGA |
| 86 capture_format_.width = 640; | 86 capture_format_.width = 640; |
| 87 capture_format_.height = 480; | 87 capture_format_.height = 480; |
| 88 capture_format_.frame_rate = 30; | 88 capture_format_.frame_rate = 30; |
| 89 } else { // QVGA | 89 } else { // QVGA |
| 90 capture_format_.width = 320; | 90 capture_format_.width = 320; |
| 91 capture_format_.height = 240; | 91 capture_format_.height = 240; |
| 92 capture_format_.frame_rate = 30; | 92 capture_format_.frame_rate = 30; |
| 93 } | 93 } |
| 94 | 94 |
| 95 const size_t fake_frame_size = VideoFrame::AllocationSize( | 95 const size_t fake_frame_size = VideoFrame::AllocationSize( |
| 96 VideoFrame::I420, | 96 VideoFrame::I420, |
| 97 gfx::Size(capture_format_.width, capture_format_.height)); | 97 gfx::Size(capture_format_.width, capture_format_.height)); |
| 98 fake_frame_.reset(new uint8[fake_frame_size]); | 98 fake_frame_.reset(new uint8[fake_frame_size]); |
| 99 | 99 |
| 100 state_ = kAllocated; | 100 state_ = kAllocated; |
| 101 observer_->OnFrameInfo(capture_format_); | 101 observer_->OnFrameInfo(capture_format_); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void FakeVideoCaptureDevice::Reallocate() { | 104 void FakeVideoCaptureDevice::Reallocate() { |
| 105 DCHECK_EQ(state_, kCapturing); | 105 DCHECK_EQ(state_, kCapturing); |
| 106 capture_format_ = capabilities_roster_.at(++capabilities_roster_index_ % | 106 capture_format_ = capabilities_roster_.at(++capabilities_roster_index_ % |
| 107 capabilities_roster_.size()); | 107 capabilities_roster_.size()); |
| 108 DCHECK_EQ(capture_format_.color, VideoCaptureCapability::kI420); | 108 DCHECK_EQ(capture_format_.color, PIXEL_FORMAT_I420); |
| 109 DVLOG(3) << "Reallocating FakeVideoCaptureDevice, new capture resolution (" | 109 DVLOG(3) << "Reallocating FakeVideoCaptureDevice, new capture resolution (" |
| 110 << capture_format_.width << "x" << capture_format_.height << ")"; | 110 << capture_format_.width << "x" << capture_format_.height << ")"; |
| 111 | 111 |
| 112 const size_t fake_frame_size = VideoFrame::AllocationSize( | 112 const size_t fake_frame_size = VideoFrame::AllocationSize( |
| 113 VideoFrame::I420, | 113 VideoFrame::I420, |
| 114 gfx::Size(capture_format_.width, capture_format_.height)); | 114 gfx::Size(capture_format_.width, capture_format_.height)); |
| 115 fake_frame_.reset(new uint8[fake_frame_size]); | 115 fake_frame_.reset(new uint8[fake_frame_size]); |
| 116 | 116 |
| 117 observer_->OnFrameInfoChanged(capture_format_); | 117 observer_->OnFrameInfoChanged(capture_format_); |
| 118 } | 118 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 base::Bind(&FakeVideoCaptureDevice::OnCaptureTask, | 223 base::Bind(&FakeVideoCaptureDevice::OnCaptureTask, |
| 224 base::Unretained(this)), | 224 base::Unretained(this)), |
| 225 base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs)); | 225 base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void FakeVideoCaptureDevice::PopulateCapabilitiesRoster() { | 228 void FakeVideoCaptureDevice::PopulateCapabilitiesRoster() { |
| 229 capabilities_roster_.push_back( | 229 capabilities_roster_.push_back( |
| 230 media::VideoCaptureCapability(320, | 230 media::VideoCaptureCapability(320, |
| 231 240, | 231 240, |
| 232 30, | 232 30, |
| 233 VideoCaptureCapability::kI420, | 233 PIXEL_FORMAT_I420, |
| 234 0, | 234 0, |
| 235 false, | 235 false, |
| 236 VariableResolutionVideoCaptureDevice)); | 236 VariableResolutionVideoCaptureDevice)); |
| 237 capabilities_roster_.push_back( | 237 capabilities_roster_.push_back( |
| 238 media::VideoCaptureCapability(640, | 238 media::VideoCaptureCapability(640, |
| 239 480, | 239 480, |
| 240 30, | 240 30, |
| 241 VideoCaptureCapability::kI420, | 241 PIXEL_FORMAT_I420, |
| 242 0, | 242 0, |
| 243 false, | 243 false, |
| 244 VariableResolutionVideoCaptureDevice)); | 244 VariableResolutionVideoCaptureDevice)); |
| 245 capabilities_roster_.push_back( | 245 capabilities_roster_.push_back( |
| 246 media::VideoCaptureCapability(800, | 246 media::VideoCaptureCapability(800, |
| 247 600, | 247 600, |
| 248 30, | 248 30, |
| 249 VideoCaptureCapability::kI420, | 249 PIXEL_FORMAT_I420, |
| 250 0, | 250 0, |
| 251 false, | 251 false, |
| 252 VariableResolutionVideoCaptureDevice)); | 252 VariableResolutionVideoCaptureDevice)); |
| 253 | 253 |
| 254 capabilities_roster_index_ = 0; | 254 capabilities_roster_index_ = 0; |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace media | 257 } // namespace media |
| OLD | NEW |