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

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

Issue 22875047: EVEA cleanup: use video utility functions in media::* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: Created 7 years, 4 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
« media/base/video_frame.cc ('K') | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const size_t fake_frame_size = VideoFrame::AllocationSize(
95 capture_format_.width * capture_format_.height * 3 / 2; 95 VideoFrame::I420,
96 gfx::Size(capture_format_.width, capture_format_.height));
96 fake_frame_.reset(new uint8[fake_frame_size]); 97 fake_frame_.reset(new uint8[fake_frame_size]);
97 98
98 state_ = kAllocated; 99 state_ = kAllocated;
99 observer_->OnFrameInfo(capture_format_); 100 observer_->OnFrameInfo(capture_format_);
100 } 101 }
101 102
102 void FakeVideoCaptureDevice::Reallocate() { 103 void FakeVideoCaptureDevice::Reallocate() {
103 DCHECK_EQ(state_, kCapturing); 104 DCHECK_EQ(state_, kCapturing);
104 capture_format_ = capabilities_roster_.at(++capabilities_roster_index_ % 105 capture_format_ = capabilities_roster_.at(++capabilities_roster_index_ %
105 capabilities_roster_.size()); 106 capabilities_roster_.size());
106 DCHECK_EQ(capture_format_.color, VideoCaptureCapability::kI420); 107 DCHECK_EQ(capture_format_.color, VideoCaptureCapability::kI420);
107 DVLOG(3) << "Reallocating FakeVideoCaptureDevice, new capture resolution (" 108 DVLOG(3) << "Reallocating FakeVideoCaptureDevice, new capture resolution ("
108 << capture_format_.width << "x" << capture_format_.height << ")"; 109 << capture_format_.width << "x" << capture_format_.height << ")";
109 110
110 size_t fake_frame_size = 111 const size_t fake_frame_size = VideoFrame::AllocationSize(
111 capture_format_.width * capture_format_.height * 3 / 2; 112 VideoFrame::I420,
113 gfx::Size(capture_format_.width, capture_format_.height));
112 fake_frame_.reset(new uint8[fake_frame_size]); 114 fake_frame_.reset(new uint8[fake_frame_size]);
113 115
114 observer_->OnFrameInfoChanged(capture_format_); 116 observer_->OnFrameInfoChanged(capture_format_);
115 } 117 }
116 118
117 void FakeVideoCaptureDevice::Start() { 119 void FakeVideoCaptureDevice::Start() {
118 if (state_ != kAllocated) { 120 if (state_ != kAllocated) {
119 return; // Wrong state. 121 return; // Wrong state.
120 } 122 }
121 state_ = kCapturing; 123 state_ = kCapturing;
(...skipping 22 matching lines...) Expand all
144 146
145 const VideoCaptureDevice::Name& FakeVideoCaptureDevice::device_name() { 147 const VideoCaptureDevice::Name& FakeVideoCaptureDevice::device_name() {
146 return device_name_; 148 return device_name_;
147 } 149 }
148 150
149 void FakeVideoCaptureDevice::OnCaptureTask() { 151 void FakeVideoCaptureDevice::OnCaptureTask() {
150 if (state_ != kCapturing) { 152 if (state_ != kCapturing) {
151 return; 153 return;
152 } 154 }
153 155
154 int frame_size = capture_format_.width * capture_format_.height * 3 / 2; 156 const size_t frame_size = VideoFrame::AllocationSize(
157 VideoFrame::I420,
158 gfx::Size(capture_format_.width, capture_format_.height));
155 memset(fake_frame_.get(), 0, frame_size); 159 memset(fake_frame_.get(), 0, frame_size);
156 160
157 SkBitmap bitmap; 161 SkBitmap bitmap;
158 bitmap.setConfig(SkBitmap::kA8_Config, 162 bitmap.setConfig(SkBitmap::kA8_Config,
159 capture_format_.width, 163 capture_format_.width,
160 capture_format_.height, 164 capture_format_.height,
161 capture_format_.width); 165 capture_format_.width);
162 bitmap.setPixels(fake_frame_.get()); 166 bitmap.setPixels(fake_frame_.get());
163 167
164 SkCanvas canvas(bitmap); 168 SkCanvas canvas(bitmap);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 30, 247 30,
244 VideoCaptureCapability::kI420, 248 VideoCaptureCapability::kI420,
245 0, 249 0,
246 false, 250 false,
247 VariableResolutionVideoCaptureDevice)); 251 VariableResolutionVideoCaptureDevice));
248 252
249 capabilities_roster_index_ = 0; 253 capabilities_roster_index_ = 0;
250 } 254 }
251 255
252 } // namespace media 256 } // namespace media
OLDNEW
« media/base/video_frame.cc ('K') | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698