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

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

Issue 2668693008: Delete VideoCaptureCapability::codecType and related logic. (Closed)
Patch Set: Attempt to fix DeviceInfoImpl::GetBestMatchedCapability. Created 3 years, 10 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 _apiLock.ReleaseLockExclusive(); 148 _apiLock.ReleaseLockExclusive();
149 _apiLock.AcquireLockShared(); 149 _apiLock.AcquireLockShared();
150 } 150 }
151 151
152 int32_t bestformatIndex = -1; 152 int32_t bestformatIndex = -1;
153 int32_t bestWidth = 0; 153 int32_t bestWidth = 0;
154 int32_t bestHeight = 0; 154 int32_t bestHeight = 0;
155 int32_t bestFrameRate = 0; 155 int32_t bestFrameRate = 0;
156 RawVideoType bestRawType = kVideoUnknown; 156 RawVideoType bestRawType = kVideoUnknown;
157 webrtc::VideoCodecType bestCodecType = webrtc::kVideoCodecUnknown;
158 157
159 const int32_t numberOfCapabilies = 158 const int32_t numberOfCapabilies =
160 static_cast<int32_t>(_captureCapabilities.size()); 159 static_cast<int32_t>(_captureCapabilities.size());
161 160
162 for (int32_t tmp = 0; tmp < numberOfCapabilies; ++tmp) // Loop through all c apabilities 161 for (int32_t tmp = 0; tmp < numberOfCapabilies; ++tmp) // Loop through all c apabilities
163 { 162 {
164 VideoCaptureCapability& capability = _captureCapabilities[tmp]; 163 VideoCaptureCapability& capability = _captureCapabilities[tmp];
165 164
166 const int32_t diffWidth = capability.width - requested.width; 165 const int32_t diffWidth = capability.width - requested.width;
167 const int32_t diffHeight = capability.height - requested.height; 166 const int32_t diffHeight = capability.height - requested.height;
(...skipping 26 matching lines...) Expand all
194 if ((currentbestDiffFrameRate == diffFrameRate) // S ame frame rate as previous or frame rate allready good enough 193 if ((currentbestDiffFrameRate == diffFrameRate) // S ame frame rate as previous or frame rate allready good enough
195 || (currentbestDiffFrameRate >= 0)) 194 || (currentbestDiffFrameRate >= 0))
196 { 195 {
197 if (bestRawType != requested.rawType 196 if (bestRawType != requested.rawType
198 && requested.rawType != kVideoUnknown 197 && requested.rawType != kVideoUnknown
199 && (capability.rawType == requested.rawType 198 && (capability.rawType == requested.rawType
200 || capability.rawType == kVideoI420 199 || capability.rawType == kVideoI420
201 || capability.rawType == kVideoYUY2 200 || capability.rawType == kVideoYUY2
202 || capability.rawType == kVideoYV12)) 201 || capability.rawType == kVideoYV12))
203 { 202 {
204 bestCodecType = capability.codecType;
205 bestRawType = capability.rawType; 203 bestRawType = capability.rawType;
206 bestformatIndex = tmp; 204 bestformatIndex = tmp;
207 } 205 }
208 // If width height and frame rate is full filled we can use the camera for encoding if it is supported. 206 // If width height and frame rate is full filled we can use the camera for encoding if it is supported.
209 if (capability.height == requested.height 207 if (capability.height == requested.height
210 && capability.width == requested.width 208 && capability.width == requested.width
211 && capability.maxFPS >= requested.maxFPS) 209 && capability.maxFPS >= requested.maxFPS)
212 { 210 {
213 if (capability.codecType == requested.codecT ype 211 bestformatIndex = tmp;
214 && bestCodecType != requested.codecType)
215 {
216 bestCodecType = capability.codecType;
217 bestformatIndex = tmp;
218 }
219 } 212 }
220 } 213 }
221 else // Better frame rate 214 else // Better frame rate
222 { 215 {
223 if (requested.codecType == capability.codecType) 216 bestWidth = capability.width;
224 { 217 bestHeight = capability.height;
225 218 bestFrameRate = capability.maxFPS;
226 bestWidth = capability.width; 219 bestRawType = capability.rawType;
227 bestHeight = capability.height; 220 bestformatIndex = tmp;
228 bestFrameRate = capability.maxFPS;
229 bestCodecType = capability.codecType;
230 bestRawType = capability.rawType;
231 bestformatIndex = tmp;
232 }
233 } 221 }
234 } 222 }
235 } 223 }
236 else // Better width than previously 224 else // Better width than previously
237 { 225 {
238 if (requested.codecType == capability.codecType) 226 bestWidth = capability.width;
239 { 227 bestHeight = capability.height;
240 bestWidth = capability.width; 228 bestFrameRate = capability.maxFPS;
241 bestHeight = capability.height; 229 bestRawType = capability.rawType;
242 bestFrameRate = capability.maxFPS; 230 bestformatIndex = tmp;
243 bestCodecType = capability.codecType;
244 bestRawType = capability.rawType;
245 bestformatIndex = tmp;
246 }
247 } 231 }
248 }// else width no good 232 }// else width no good
249 } 233 }
250 else // Better height 234 else // Better height
251 { 235 {
252 if (requested.codecType == capability.codecType) 236 bestWidth = capability.width;
253 { 237 bestHeight = capability.height;
254 bestWidth = capability.width; 238 bestFrameRate = capability.maxFPS;
255 bestHeight = capability.height; 239 bestRawType = capability.rawType;
256 bestFrameRate = capability.maxFPS; 240 bestformatIndex = tmp;
257 bestCodecType = capability.codecType;
258 bestRawType = capability.rawType;
259 bestformatIndex = tmp;
260 }
261 } 241 }
262 }// else height not good 242 }// else height not good
263 }//end for 243 }//end for
264 244
265 LOG(LS_VERBOSE) << "Best camera format: " << bestWidth << "x" << bestHeight 245 LOG(LS_VERBOSE) << "Best camera format: " << bestWidth << "x" << bestHeight
266 << "@" << bestFrameRate 246 << "@" << bestFrameRate
267 << "fps, color format: " << bestRawType; 247 << "fps, color format: " << bestRawType;
268 248
269 // Copy the capability 249 // Copy the capability
270 if (bestformatIndex < 0) 250 if (bestformatIndex < 0)
271 return -1; 251 return -1;
272 resulting = _captureCapabilities[bestformatIndex]; 252 resulting = _captureCapabilities[bestformatIndex];
273 return bestformatIndex; 253 return bestformatIndex;
274 } 254 }
275 255
276 //Default implementation. This should be overridden by Mobile implementations. 256 //Default implementation. This should be overridden by Mobile implementations.
277 int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, 257 int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8,
278 VideoRotation& orientation) { 258 VideoRotation& orientation) {
279 orientation = kVideoRotation_0; 259 orientation = kVideoRotation_0;
280 return -1; 260 return -1;
281 } 261 }
282 } // namespace videocapturemodule 262 } // namespace videocapturemodule
283 } // namespace webrtc 263 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideocapturer.cc ('k') | webrtc/modules/video_capture/objc/device_info_objc.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698