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

Side by Side Diff: webrtc/modules/video_capture/video_capture_impl.cc

Issue 2765243002: Delete RawVideoType enum, use the VideoType enum instead. (Closed)
Patch Set: Define constant webrtc::kI420, for backwards compatibility. Created 3 years, 7 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 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 _requestedCapability(), 82 _requestedCapability(),
83 _lastProcessTimeNanos(rtc::TimeNanos()), 83 _lastProcessTimeNanos(rtc::TimeNanos()),
84 _lastFrameRateCallbackTimeNanos(rtc::TimeNanos()), 84 _lastFrameRateCallbackTimeNanos(rtc::TimeNanos()),
85 _dataCallBack(NULL), 85 _dataCallBack(NULL),
86 _lastProcessFrameTimeNanos(rtc::TimeNanos()), 86 _lastProcessFrameTimeNanos(rtc::TimeNanos()),
87 _rotateFrame(kVideoRotation_0), 87 _rotateFrame(kVideoRotation_0),
88 apply_rotation_(false) { 88 apply_rotation_(false) {
89 _requestedCapability.width = kDefaultWidth; 89 _requestedCapability.width = kDefaultWidth;
90 _requestedCapability.height = kDefaultHeight; 90 _requestedCapability.height = kDefaultHeight;
91 _requestedCapability.maxFPS = 30; 91 _requestedCapability.maxFPS = 30;
92 _requestedCapability.rawType = kVideoI420; 92 _requestedCapability.videoType = VideoType::kI420;
93 memset(_incomingFrameTimesNanos, 0, sizeof(_incomingFrameTimesNanos)); 93 memset(_incomingFrameTimesNanos, 0, sizeof(_incomingFrameTimesNanos));
94 } 94 }
95 95
96 VideoCaptureImpl::~VideoCaptureImpl() 96 VideoCaptureImpl::~VideoCaptureImpl()
97 { 97 {
98 DeRegisterCaptureDataCallback(); 98 DeRegisterCaptureDataCallback();
99 if (_deviceUniqueId) 99 if (_deviceUniqueId)
100 delete[] _deviceUniqueId; 100 delete[] _deviceUniqueId;
101 } 101 }
102 102
(...skipping 24 matching lines...) Expand all
127 int64_t captureTime/*=0*/) 127 int64_t captureTime/*=0*/)
128 { 128 {
129 rtc::CritScope cs(&_apiCs); 129 rtc::CritScope cs(&_apiCs);
130 130
131 const int32_t width = frameInfo.width; 131 const int32_t width = frameInfo.width;
132 const int32_t height = frameInfo.height; 132 const int32_t height = frameInfo.height;
133 133
134 TRACE_EVENT1("webrtc", "VC::IncomingFrame", "capture_time", captureTime); 134 TRACE_EVENT1("webrtc", "VC::IncomingFrame", "capture_time", captureTime);
135 135
136 // Not encoded, convert to I420. 136 // Not encoded, convert to I420.
137 const VideoType commonVideoType = 137 if (frameInfo.videoType != VideoType::kMJPEG &&
138 RawVideoTypeToCommonVideoVideoType(frameInfo.rawType); 138 CalcBufferSize(frameInfo.videoType, width, abs(height)) !=
139
140 if (frameInfo.rawType != kVideoMJPEG &&
141 CalcBufferSize(commonVideoType, width, abs(height)) !=
142 videoFrameLength) { 139 videoFrameLength) {
143 LOG(LS_ERROR) << "Wrong incoming frame length."; 140 LOG(LS_ERROR) << "Wrong incoming frame length.";
144 return -1; 141 return -1;
145 } 142 }
146 143
147 int stride_y = width; 144 int stride_y = width;
148 int stride_uv = (width + 1) / 2; 145 int stride_uv = (width + 1) / 2;
149 int target_width = width; 146 int target_width = width;
150 int target_height = height; 147 int target_height = height;
151 148
(...skipping 10 matching lines...) Expand all
162 } 159 }
163 160
164 // Setting absolute height (in case it was negative). 161 // Setting absolute height (in case it was negative).
165 // In Windows, the image starts bottom left, instead of top left. 162 // In Windows, the image starts bottom left, instead of top left.
166 // Setting a negative source height, inverts the image (within LibYuv). 163 // Setting a negative source height, inverts the image (within LibYuv).
167 164
168 // TODO(nisse): Use a pool? 165 // TODO(nisse): Use a pool?
169 rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create( 166 rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(
170 target_width, abs(target_height), stride_y, stride_uv, stride_uv); 167 target_width, abs(target_height), stride_y, stride_uv, stride_uv);
171 const int conversionResult = ConvertToI420( 168 const int conversionResult = ConvertToI420(
172 commonVideoType, videoFrame, 0, 0, // No cropping 169 frameInfo.videoType, videoFrame, 0, 0, // No cropping
173 width, height, videoFrameLength, 170 width, height, videoFrameLength,
174 apply_rotation ? _rotateFrame : kVideoRotation_0, buffer.get()); 171 apply_rotation ? _rotateFrame : kVideoRotation_0, buffer.get());
175 if (conversionResult < 0) { 172 if (conversionResult < 0) {
176 LOG(LS_ERROR) << "Failed to convert capture frame from type " 173 LOG(LS_ERROR) << "Failed to convert capture frame from type "
177 << frameInfo.rawType << "to I420."; 174 << static_cast<int>(frameInfo.videoType) << "to I420.";
178 return -1; 175 return -1;
179 } 176 }
180 177
181 VideoFrame captureFrame(buffer, 0, rtc::TimeMillis(), 178 VideoFrame captureFrame(buffer, 0, rtc::TimeMillis(),
182 !apply_rotation ? _rotateFrame : kVideoRotation_0); 179 !apply_rotation ? _rotateFrame : kVideoRotation_0);
183 captureFrame.set_ntp_time_ms(captureTime); 180 captureFrame.set_ntp_time_ms(captureTime);
184 181
185 DeliverCapturedFrame(captureFrame); 182 DeliverCapturedFrame(captureFrame);
186 183
187 return 0; 184 return 0;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 rtc::kNumNanosecsPerMillisec; 228 rtc::kNumNanosecsPerMillisec;
232 if (diff > 0) { 229 if (diff > 0) {
233 return uint32_t((nrOfFrames * 1000.0f / diff) + 0.5f); 230 return uint32_t((nrOfFrames * 1000.0f / diff) + 0.5f);
234 } 231 }
235 } 232 }
236 233
237 return nrOfFrames; 234 return nrOfFrames;
238 } 235 }
239 } // namespace videocapturemodule 236 } // namespace videocapturemodule
240 } // namespace webrtc 237 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_capture/video_capture_defines.h ('k') | webrtc/modules/video_capture/windows/device_info_ds.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698