| OLD | NEW |
| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 << "@" << bestFrameRate | 266 << "@" << bestFrameRate |
| 267 << "fps, color format: " << bestRawType; | 267 << "fps, color format: " << bestRawType; |
| 268 | 268 |
| 269 // Copy the capability | 269 // Copy the capability |
| 270 if (bestformatIndex < 0) | 270 if (bestformatIndex < 0) |
| 271 return -1; | 271 return -1; |
| 272 resulting = _captureCapabilities[bestformatIndex]; | 272 resulting = _captureCapabilities[bestformatIndex]; |
| 273 return bestformatIndex; | 273 return bestformatIndex; |
| 274 } | 274 } |
| 275 | 275 |
| 276 /* Returns the expected Capture delay*/ | |
| 277 int32_t DeviceInfoImpl::GetExpectedCaptureDelay( | |
| 278 const DelayValues delayValues[], | |
| 279 const uint32_t sizeOfDelayValues, | |
| 280 const char* productId, | |
| 281 const uint32_t width, | |
| 282 const uint32_t height) | |
| 283 { | |
| 284 int32_t bestDelay = kDefaultCaptureDelay; | |
| 285 | |
| 286 for (uint32_t device = 0; device < sizeOfDelayValues; ++device) | |
| 287 { | |
| 288 if (delayValues[device].productId && strncmp((char*) productId, | |
| 289 (char*) delayValues[device]
.productId, | |
| 290 kVideoCaptureProductIdLengt
h) == 0) | |
| 291 { | |
| 292 // We have found the camera | |
| 293 | |
| 294 int32_t bestWidth = 0; | |
| 295 int32_t bestHeight = 0; | |
| 296 | |
| 297 //Loop through all tested sizes and find one that seems fitting | |
| 298 for (uint32_t delayIndex = 0; delayIndex < NoOfDelayValues; ++delayI
ndex) | |
| 299 { | |
| 300 const DelayValue& currentValue = delayValues[device].delayValues
[delayIndex]; | |
| 301 | |
| 302 const int32_t diffWidth = currentValue.width - width; | |
| 303 const int32_t diffHeight = currentValue.height - height; | |
| 304 | |
| 305 const int32_t currentbestDiffWith = bestWidth - width; | |
| 306 const int32_t currentbestDiffHeight = bestHeight - height; | |
| 307 | |
| 308 if ((diffHeight >= 0 && diffHeight <= abs(currentbestDiffHeight)
) // Height better or equal than previous. | |
| 309 || (currentbestDiffHeight < 0 && diffHeight >= currentbestDi
ffHeight)) | |
| 310 { | |
| 311 | |
| 312 if (diffHeight == currentbestDiffHeight) // Found best heigh
t. Care about the width) | |
| 313 { | |
| 314 if ((diffWidth >= 0 && diffWidth <= abs(currentbestDiffW
ith)) // Width better or equal | |
| 315 || (currentbestDiffWith < 0 && diffWidth >= currentb
estDiffWith)) | |
| 316 { | |
| 317 if (diffWidth == currentbestDiffWith && diffHeight | |
| 318 == currentbestDiffHeight) // Same size as previo
us | |
| 319 { | |
| 320 } | |
| 321 else // Better width than previously | |
| 322 { | |
| 323 bestWidth = currentValue.width; | |
| 324 bestHeight = currentValue.height; | |
| 325 bestDelay = currentValue.delay; | |
| 326 } | |
| 327 }// else width no good | |
| 328 } | |
| 329 else // Better height | |
| 330 { | |
| 331 bestWidth = currentValue.width; | |
| 332 bestHeight = currentValue.height; | |
| 333 bestDelay = currentValue.delay; | |
| 334 } | |
| 335 }// else height not good | |
| 336 }//end for | |
| 337 break; | |
| 338 } | |
| 339 } | |
| 340 if (bestDelay > kMaxCaptureDelay) | |
| 341 { | |
| 342 LOG(LS_WARNING) << "Expected capture delay (" << bestDelay | |
| 343 << " ms) too high, using " << kMaxCaptureDelay | |
| 344 << " ms."; | |
| 345 bestDelay = kMaxCaptureDelay; | |
| 346 } | |
| 347 | |
| 348 return bestDelay; | |
| 349 | |
| 350 } | |
| 351 | |
| 352 //Default implementation. This should be overridden by Mobile implementations. | 276 //Default implementation. This should be overridden by Mobile implementations. |
| 353 int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, | 277 int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, |
| 354 VideoRotation& orientation) { | 278 VideoRotation& orientation) { |
| 355 orientation = kVideoRotation_0; | 279 orientation = kVideoRotation_0; |
| 356 return -1; | 280 return -1; |
| 357 } | 281 } |
| 358 } // namespace videocapturemodule | 282 } // namespace videocapturemodule |
| 359 } // namespace webrtc | 283 } // namespace webrtc |
| OLD | NEW |