Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: media/video/capture/fake_video_capture_device.cc

Issue 22876027: Consolidate duplicated frame / capability structures in video_capture_types.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 EventHandler* observer) { 71 EventHandler* observer) {
72 capture_format_.frame_size_type = capture_format.frame_size_type; 72 capture_format_.frame_size_type = capture_format.frame_size_type;
73 if (capture_format.frame_size_type == VariableResolutionVideoCaptureDevice) 73 if (capture_format.frame_size_type == VariableResolutionVideoCaptureDevice)
74 PopulateCapabilitiesRoster(); 74 PopulateCapabilitiesRoster();
75 75
76 if (state_ != kIdle) { 76 if (state_ != kIdle) {
77 return; // Wrong state. 77 return; // Wrong state.
78 } 78 }
79 79
80 observer_ = observer; 80 observer_ = observer;
81 capture_format_.color = VideoCaptureCapability::kI420; 81 capture_format_.color = kI420;
82 capture_format_.expected_capture_delay = 0; 82 capture_format_.expected_capture_delay = 0;
83 capture_format_.interlaced = false; 83 capture_format_.interlaced = false;
84 if (capture_format.width > 320) { // VGA 84 if (capture_format.width > 320) { // VGA
85 capture_format_.width = 640; 85 capture_format_.width = 640;
86 capture_format_.height = 480; 86 capture_format_.height = 480;
87 capture_format_.frame_rate = 30; 87 capture_format_.frame_rate = 30;
88 } else { // QVGA 88 } else { // QVGA
89 capture_format_.width = 320; 89 capture_format_.width = 320;
90 capture_format_.height = 240; 90 capture_format_.height = 240;
91 capture_format_.frame_rate = 30; 91 capture_format_.frame_rate = 30;
92 } 92 }
93 93
94 size_t fake_frame_size = 94 size_t fake_frame_size =
95 capture_format_.width * capture_format_.height * 3 / 2; 95 capture_format_.width * capture_format_.height * 3 / 2;
96 fake_frame_.reset(new uint8[fake_frame_size]); 96 fake_frame_.reset(new uint8[fake_frame_size]);
97 97
98 state_ = kAllocated; 98 state_ = kAllocated;
99 observer_->OnFrameInfo(capture_format_); 99 observer_->OnFrameInfo(capture_format_);
100 } 100 }
101 101
102 void FakeVideoCaptureDevice::Reallocate() { 102 void FakeVideoCaptureDevice::Reallocate() {
103 DCHECK_EQ(state_, kCapturing); 103 DCHECK_EQ(state_, kCapturing);
104 capture_format_ = capabilities_roster_.at(++capabilities_roster_index_ % 104 capture_format_ = capabilities_roster_.at(++capabilities_roster_index_ %
105 capabilities_roster_.size()); 105 capabilities_roster_.size());
106 DCHECK_EQ(capture_format_.color, VideoCaptureCapability::kI420); 106 DCHECK_EQ(capture_format_.color, kI420);
107 DVLOG(3) << "Reallocating FakeVideoCaptureDevice, new capture resolution (" 107 DVLOG(3) << "Reallocating FakeVideoCaptureDevice, new capture resolution ("
108 << capture_format_.width << "x" << capture_format_.height << ")"; 108 << capture_format_.width << "x" << capture_format_.height << ")";
109 109
110 size_t fake_frame_size = 110 size_t fake_frame_size =
111 capture_format_.width * capture_format_.height * 3 / 2; 111 capture_format_.width * capture_format_.height * 3 / 2;
112 fake_frame_.reset(new uint8[fake_frame_size]); 112 fake_frame_.reset(new uint8[fake_frame_size]);
113 113
114 observer_->OnFrameInfoChanged(capture_format_); 114 observer_->OnFrameInfoChanged(capture_format_);
115 } 115 }
116 116
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 base::Bind(&FakeVideoCaptureDevice::OnCaptureTask, 218 base::Bind(&FakeVideoCaptureDevice::OnCaptureTask,
219 base::Unretained(this)), 219 base::Unretained(this)),
220 base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs)); 220 base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs));
221 } 221 }
222 222
223 void FakeVideoCaptureDevice::PopulateCapabilitiesRoster() { 223 void FakeVideoCaptureDevice::PopulateCapabilitiesRoster() {
224 capabilities_roster_.push_back( 224 capabilities_roster_.push_back(
225 media::VideoCaptureCapability(320, 225 media::VideoCaptureCapability(320,
226 240, 226 240,
227 30, 227 30,
228 VideoCaptureCapability::kI420, 228 kI420,
229 0, 229 0,
230 false, 230 false,
231 VariableResolutionVideoCaptureDevice)); 231 VariableResolutionVideoCaptureDevice));
232 capabilities_roster_.push_back( 232 capabilities_roster_.push_back(
233 media::VideoCaptureCapability(640, 233 media::VideoCaptureCapability(640,
234 480, 234 480,
235 30, 235 30,
236 VideoCaptureCapability::kI420, 236 kI420,
237 0, 237 0,
238 false, 238 false,
239 VariableResolutionVideoCaptureDevice)); 239 VariableResolutionVideoCaptureDevice));
240 capabilities_roster_.push_back( 240 capabilities_roster_.push_back(
241 media::VideoCaptureCapability(800, 241 media::VideoCaptureCapability(800,
242 600, 242 600,
243 30, 243 30,
244 VideoCaptureCapability::kI420, 244 kI420,
245 0, 245 0,
246 false, 246 false,
247 VariableResolutionVideoCaptureDevice)); 247 VariableResolutionVideoCaptureDevice));
248 248
249 capabilities_roster_index_ = 0; 249 capabilities_roster_index_ = 0;
250 } 250 }
251 251
252 } // namespace media 252 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698