Skip to content

Commit

Permalink
fix(ios): select correct capture session preset when defaultVideoQual…
Browse files Browse the repository at this point in the history
…ity is not provided (react-native-camera#1908)

Closes react-native-camera#1900
  • Loading branch information
cozmo authored and n1ru4l committed Nov 7, 2018
1 parent 4f3e4f1 commit 41079d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ios/RN/RNCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@property (nonatomic, assign) BOOL canReadText;
@property(assign, nonatomic) AVVideoCodecType videoCodecType;
@property (assign, nonatomic) AVCaptureVideoStabilizationMode videoStabilizationMode;
@property(assign, nonatomic) NSInteger defaultVideoQuality;
@property(assign, nonatomic, nullable) NSNumber *defaultVideoQuality;

- (id)initWithBridge:(RCTBridge *)bridge;
- (void)updateType;
Expand Down
4 changes: 3 additions & 1 deletion ios/RN/RNCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,9 @@ - (void)startSession
return;
}

AVCaptureSessionPreset preset = [RNCameraUtils captureSessionPresetForVideoResolution:[self defaultVideoQuality]];
// Default video quality AVCaptureSessionPresetHigh if non is provided
AVCaptureSessionPreset preset = ([self defaultVideoQuality]) ? [RNCameraUtils captureSessionPresetForVideoResolution:[[self defaultVideoQuality] integerValue]] : AVCaptureSessionPresetHigh;

self.session.sessionPreset = preset == AVCaptureSessionPresetHigh ? AVCaptureSessionPresetPhoto: preset;

AVCaptureStillImageOutput *stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
Expand Down
2 changes: 1 addition & 1 deletion ios/RN/RNCameraManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ + (NSDictionary *)faceDetectorConstants

RCT_CUSTOM_VIEW_PROPERTY(defaultVideoQuality, NSInteger, RNCamera)
{
[view setDefaultVideoQuality:(NSInteger) [RCTConvert NSInteger:json]];
[view setDefaultVideoQuality: [NSNumber numberWithInteger:[RCTConvert NSInteger:json]]];
}

RCT_REMAP_METHOD(takePicture,
Expand Down

0 comments on commit 41079d5

Please sign in to comment.