OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" | 5 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" |
6 | 6 |
7 #import <CoreVideo/CoreVideo.h> | 7 #import <CoreVideo/CoreVideo.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 // VideoCaptureDeviceMac::ReceiveFrame() is calling here, depending on the | 168 // VideoCaptureDeviceMac::ReceiveFrame() is calling here, depending on the |
169 // running state. VCDM::ReceiveFrame() calls here to change aspect ratio. | 169 // running state. VCDM::ReceiveFrame() calls here to change aspect ratio. |
170 DCHECK((![captureSession_ isRunning] && | 170 DCHECK((![captureSession_ isRunning] && |
171 main_thread_checker_.CalledOnValidThread()) || | 171 main_thread_checker_.CalledOnValidThread()) || |
172 callback_thread_checker_.CalledOnValidThread()); | 172 callback_thread_checker_.CalledOnValidThread()); |
173 | 173 |
174 frameWidth_ = width; | 174 frameWidth_ = width; |
175 frameHeight_ = height; | 175 frameHeight_ = height; |
176 frameRate_ = frameRate; | 176 frameRate_ = frameRate; |
177 | 177 |
178 // Identify the sessionPreset that corresponds to the desired resolution. | 178 // Identify the sessionPreset that corresponds to the desired resolution. |
bemasc
2014/04/28 17:17:33
This comment should probably be updated, since the
mcasas
2014/04/28 19:01:36
Seems that you're right, despite the line you copy
| |
179 NSString* sessionPreset; | 179 NSString* sessionPreset; |
180 if (width == 1280 && height == 720 && [captureSession_ canSetSessionPreset: | 180 if (width >= 1280 && height >= 720 && [captureSession_ canSetSessionPreset: |
181 AVFoundationGlue::AVCaptureSessionPreset1280x720()]) { | 181 AVFoundationGlue::AVCaptureSessionPreset1280x720()]) { |
182 sessionPreset = AVFoundationGlue::AVCaptureSessionPreset1280x720(); | 182 sessionPreset = AVFoundationGlue::AVCaptureSessionPreset1280x720(); |
183 } else if (width == 640 && height == 480 && [captureSession_ | 183 } else if (width >= 640 && height >= 480 && [captureSession_ |
184 canSetSessionPreset: | 184 canSetSessionPreset:AVFoundationGlue::AVCaptureSessionPreset640x480()]) { |
185 AVFoundationGlue::AVCaptureSessionPreset640x480()]) { | |
186 sessionPreset = AVFoundationGlue::AVCaptureSessionPreset640x480(); | 185 sessionPreset = AVFoundationGlue::AVCaptureSessionPreset640x480(); |
187 } else if (width == 320 && height == 240 && [captureSession_ | 186 } else if ([captureSession_ |
188 canSetSessionPreset: | 187 canSetSessionPreset:AVFoundationGlue::AVCaptureSessionPreset320x240()]) { |
bemasc
2014/04/28 17:17:33
Does such a preset even exist? It isn't documente
mcasas
2014/04/28 19:01:36
Not in iOS but in Mac:
https://developer.apple.co
| |
189 AVFoundationGlue::AVCaptureSessionPreset320x240()]) { | |
190 sessionPreset = AVFoundationGlue::AVCaptureSessionPreset320x240(); | 188 sessionPreset = AVFoundationGlue::AVCaptureSessionPreset320x240(); |
191 } else { | 189 } else { |
192 DLOG(ERROR) << "Unsupported resolution (" << width << "x" << height << ")"; | 190 DLOG(ERROR) << "Preset not found for requested frame size"; |
193 return NO; | 191 return NO; |
194 } | 192 } |
195 [captureSession_ setSessionPreset:sessionPreset]; | 193 [captureSession_ setSessionPreset:sessionPreset]; |
196 | 194 |
197 // Check that our capture Device can be used with the current preset. | 195 // Check that our capture Device can be used with the current preset. |
198 if (![captureDevice_ supportsAVCaptureSessionPreset: | 196 if (![captureDevice_ supportsAVCaptureSessionPreset: |
199 [captureSession_ sessionPreset]]){ | 197 [captureSession_ sessionPreset]]){ |
200 DLOG(ERROR) << "Video capture device does not support current preset"; | 198 DLOG(ERROR) << "Video capture device does not support current preset"; |
201 return NO; | 199 return NO; |
202 } | 200 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 [NSString stringWithFormat:@"%@: %@", | 299 [NSString stringWithFormat:@"%@: %@", |
302 [error localizedDescription], | 300 [error localizedDescription], |
303 [error localizedFailureReason]]; | 301 [error localizedFailureReason]]; |
304 | 302 |
305 base::AutoLock lock(lock_); | 303 base::AutoLock lock(lock_); |
306 if (frameReceiver_) | 304 if (frameReceiver_) |
307 frameReceiver_->ReceiveError([str_error UTF8String]); | 305 frameReceiver_->ReceiveError([str_error UTF8String]); |
308 } | 306 } |
309 | 307 |
310 @end | 308 @end |
OLD | NEW |