| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return -1; | 146 return -1; |
| 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 VideoType bestVideoType = VideoType::kUnknown; |
| 157 | 157 |
| 158 const int32_t numberOfCapabilies = | 158 const int32_t numberOfCapabilies = |
| 159 static_cast<int32_t>(_captureCapabilities.size()); | 159 static_cast<int32_t>(_captureCapabilities.size()); |
| 160 | 160 |
| 161 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 |
| 162 { | 162 { |
| 163 VideoCaptureCapability& capability = _captureCapabilities[tmp]; | 163 VideoCaptureCapability& capability = _captureCapabilities[tmp]; |
| 164 | 164 |
| 165 const int32_t diffWidth = capability.width - requested.width; | 165 const int32_t diffWidth = capability.width - requested.width; |
| 166 const int32_t diffHeight = capability.height - requested.height; | 166 const int32_t diffHeight = capability.height - requested.height; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 186 if (((diffFrameRate >= 0 && | 186 if (((diffFrameRate >= 0 && |
| 187 diffFrameRate <= currentbestDiffFrameRate) // Fram
e rate to high but better match than previouse and we have not selected IUV | 187 diffFrameRate <= currentbestDiffFrameRate) // Fram
e rate to high but better match than previouse and we have not selected IUV |
| 188 || | 188 || |
| 189 (currentbestDiffFrameRate < 0 && | 189 (currentbestDiffFrameRate < 0 && |
| 190 diffFrameRate >= currentbestDiffFrameRate)) // Curr
ent frame rate is lower than requested. This is better. | 190 diffFrameRate >= currentbestDiffFrameRate)) // Curr
ent frame rate is lower than requested. This is better. |
| 191 ) | 191 ) |
| 192 { | 192 { |
| 193 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 |
| 194 || (currentbestDiffFrameRate >= 0)) | 194 || (currentbestDiffFrameRate >= 0)) |
| 195 { | 195 { |
| 196 if (bestRawType != requested.rawType | 196 if (bestVideoType != requested.videoType && |
| 197 && requested.rawType != kVideoUnknown | 197 requested.videoType != VideoType::kUnknown && |
| 198 && (capability.rawType == requested.rawType | 198 (capability.videoType == |
| 199 || capability.rawType == kVideoI420 | 199 requested.videoType || |
| 200 || capability.rawType == kVideoYUY2 | 200 capability.videoType == VideoType::kI420 || |
| 201 || capability.rawType == kVideoYV12)) | 201 capability.videoType == VideoType::kYUY2 || |
| 202 { | 202 capability.videoType == VideoType::kYV12)) { |
| 203 bestRawType = capability.rawType; | 203 bestVideoType = capability.videoType; |
| 204 bestformatIndex = tmp; | 204 bestformatIndex = tmp; |
| 205 } | 205 } |
| 206 // 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. |
| 207 if (capability.height == requested.height | 207 if (capability.height == requested.height |
| 208 && capability.width == requested.width | 208 && capability.width == requested.width |
| 209 && capability.maxFPS >= requested.maxFPS) | 209 && capability.maxFPS >= requested.maxFPS) |
| 210 { | 210 { |
| 211 bestformatIndex = tmp; | 211 bestformatIndex = tmp; |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 else // Better frame rate | 214 else // Better frame rate |
| 215 { | 215 { |
| 216 bestWidth = capability.width; | 216 bestWidth = capability.width; |
| 217 bestHeight = capability.height; | 217 bestHeight = capability.height; |
| 218 bestFrameRate = capability.maxFPS; | 218 bestFrameRate = capability.maxFPS; |
| 219 bestRawType = capability.rawType; | 219 bestVideoType = capability.videoType; |
| 220 bestformatIndex = tmp; | 220 bestformatIndex = tmp; |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 else // Better width than previously | 224 else // Better width than previously |
| 225 { | 225 { |
| 226 bestWidth = capability.width; | 226 bestWidth = capability.width; |
| 227 bestHeight = capability.height; | 227 bestHeight = capability.height; |
| 228 bestFrameRate = capability.maxFPS; | 228 bestFrameRate = capability.maxFPS; |
| 229 bestRawType = capability.rawType; | 229 bestVideoType = capability.videoType; |
| 230 bestformatIndex = tmp; | 230 bestformatIndex = tmp; |
| 231 } | 231 } |
| 232 }// else width no good | 232 }// else width no good |
| 233 } | 233 } |
| 234 else // Better height | 234 else // Better height |
| 235 { | 235 { |
| 236 bestWidth = capability.width; | 236 bestWidth = capability.width; |
| 237 bestHeight = capability.height; | 237 bestHeight = capability.height; |
| 238 bestFrameRate = capability.maxFPS; | 238 bestFrameRate = capability.maxFPS; |
| 239 bestRawType = capability.rawType; | 239 bestVideoType = capability.videoType; |
| 240 bestformatIndex = tmp; | 240 bestformatIndex = tmp; |
| 241 } | 241 } |
| 242 }// else height not good | 242 }// else height not good |
| 243 }//end for | 243 }//end for |
| 244 | 244 |
| 245 LOG(LS_VERBOSE) << "Best camera format: " << bestWidth << "x" << bestHeight | 245 LOG(LS_VERBOSE) << "Best camera format: " << bestWidth << "x" << bestHeight |
| 246 << "@" << bestFrameRate | 246 << "@" << bestFrameRate |
| 247 << "fps, color format: " << bestRawType; | 247 << "fps, color format: " << static_cast<int>(bestVideoType); |
| 248 | 248 |
| 249 // Copy the capability | 249 // Copy the capability |
| 250 if (bestformatIndex < 0) | 250 if (bestformatIndex < 0) |
| 251 return -1; | 251 return -1; |
| 252 resulting = _captureCapabilities[bestformatIndex]; | 252 resulting = _captureCapabilities[bestformatIndex]; |
| 253 return bestformatIndex; | 253 return bestformatIndex; |
| 254 } | 254 } |
| 255 | 255 |
| 256 //Default implementation. This should be overridden by Mobile implementations. | 256 //Default implementation. This should be overridden by Mobile implementations. |
| 257 int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, | 257 int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, |
| 258 VideoRotation& orientation) { | 258 VideoRotation& orientation) { |
| 259 orientation = kVideoRotation_0; | 259 orientation = kVideoRotation_0; |
| 260 return -1; | 260 return -1; |
| 261 } | 261 } |
| 262 } // namespace videocapturemodule | 262 } // namespace videocapturemodule |
| 263 } // namespace webrtc | 263 } // namespace webrtc |
| OLD | NEW |