|
@@ -20,7 +20,7 @@
|
|
|
@synthesize front = _front;
|
|
|
@synthesize back = _back;
|
|
|
|
|
|
-- (void)setResolutionFor:(AVCaptureDevicePosition)position with: (NSInteger)desiredWidth model:(SDKCaptureModeIndex)model{
|
|
|
+- (void)setResolutionFor:(AVCaptureDevicePosition)position with: (NSInteger)desiredHeight model:(SDKCaptureModeIndex)model{
|
|
|
|
|
|
AVCaptureDevice* device = [self cameraWithPosition:position];
|
|
|
if(device == nil){
|
|
@@ -31,18 +31,17 @@
|
|
|
|
|
|
AVCaptureDeviceFormat *bestFormat;
|
|
|
CGFloat aspect = 1;
|
|
|
-
|
|
|
+ //分辨率
|
|
|
+ CGFloat radio = 16.0/9.0;
|
|
|
+ if(model == SDK_CAPTURE_MODE_SINGLE || model == SDK_CAPTURE_MODE_CONTINUOUS) {
|
|
|
+ radio = 4.0/3.0;
|
|
|
+ }
|
|
|
|
|
|
for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
|
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
|
CMVideoDimensions bestVideoDimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[bestFormat formatDescription]);
|
|
|
|
|
|
- //分辨率
|
|
|
- CGFloat radio = 16.0/9.0;
|
|
|
- if(model == SDK_CAPTURE_MODE_SINGLE || model == SDK_CAPTURE_MODE_CONTINUOUS) {
|
|
|
- radio = 4.0/3.0;
|
|
|
- }
|
|
|
- if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio && dimensions.width <= desiredWidth) {
|
|
|
+ if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio && dimensions.height <= desiredHeight) {
|
|
|
|
|
|
if(dimensions.width == 1080 && (model == SDK_CAPTURE_MODE_PANORAMA || model == SDK_CAPTURE_MODE_INTELLEGENCE_PANORAMA)) {
|
|
|
aspect = (CGFloat)dimensions.width / dimensions.height;
|
|
@@ -50,7 +49,7 @@
|
|
|
break;
|
|
|
} else {
|
|
|
aspect = (CGFloat)dimensions.width / dimensions.height;
|
|
|
- if (bestVideoDimensions.width <= dimensions.width) {
|
|
|
+ if (bestVideoDimensions.height <= dimensions.height) {
|
|
|
bestFormat = format;
|
|
|
}
|
|
|
}
|
|
@@ -60,6 +59,18 @@
|
|
|
[device lockForConfiguration:nil];
|
|
|
if(bestFormat) {
|
|
|
[device setActiveFormat:bestFormat];
|
|
|
+ } else {
|
|
|
+ for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
|
+ CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
|
+ CMVideoDimensions bestVideoDimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[bestFormat formatDescription]);
|
|
|
+ if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio) {
|
|
|
+ if (bestVideoDimensions.height <= dimensions.height) {
|
|
|
+ bestFormat = format;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [device setActiveFormat:bestFormat];
|
|
|
}
|
|
|
|
|
|
[device setActiveVideoMaxFrameDuration:CMTimeMake(1, 10)];
|