Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
fix(rn-camera): fix types, conversions and casts
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Jun 6, 2018
1 parent a090faa commit 83d0618
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ios/RN/RNCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ - (void)record:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve r
[self updateSessionAudioIsMuted:!!options[@"mute"]];

AVCaptureConnection *connection = [self.movieFileOutput connectionWithMediaType:AVMediaTypeVideo];
if (self.videoStabilizationMode != nil) {
if (self.videoStabilizationMode != 0) {
if (connection.isVideoStabilizationSupported == NO) {
RCTLogWarn(@"%s: Video Stabilization is not supported on this device.", __func__);
} else {
Expand Down
8 changes: 4 additions & 4 deletions ios/RN/RNCameraManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ + (NSDictionary *)validCodecTypes
+ (NSDictionary *)validVideoStabilizationModes
{
return @{
@"off": AVCaptureVideoStabilizationModeOff,
@"standard": AVCaptureVideoStabilizationModeStandard,
@"cinematic": AVCaptureVideoStabilizationModeCinematic,
@"auto": AVCaptureVideoStabilizationModeAuto
@"off": @(AVCaptureVideoStabilizationModeOff),
@"standard": @(AVCaptureVideoStabilizationModeStandard),
@"cinematic": @(AVCaptureVideoStabilizationModeCinematic),
@"auto": @(AVCaptureVideoStabilizationModeAuto)
};
}

Expand Down
8 changes: 5 additions & 3 deletions src/RNCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type PropsType = typeof View.props & {
captureAudio?: boolean,
useCamera2Api?: boolean,
playSoundOnCapture?: boolean,
videoStabilizationMode?: string,
videoStabilizationMode?: number | string,
pictureSize?: string,
};

Expand Down Expand Up @@ -157,7 +157,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
GoogleVisionBarcodeDetection: CameraManager.GoogleVisionBarcodeDetection,
FaceDetection: CameraManager.FaceDetection,
CameraStatus,
VideoStabilization: CameraManager.VideoStabilization || {},
VideoStabilization: CameraManager.VideoStabilization,
};

// Values under keys from this object will be transformed to native options
Expand All @@ -170,6 +170,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
faceDetectionLandmarks: (CameraManager.FaceDetection || {}).Landmarks,
faceDetectionClassifications: (CameraManager.FaceDetection || {}).Classifications,
googleVisionBarcodeType: (CameraManager.GoogleVisionBarcodeDetection || {}).BarcodeType,
videoStabilizationMode: CameraManager.VideoStabilization || {},
};

static propTypes = {
Expand Down Expand Up @@ -200,7 +201,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
captureAudio: PropTypes.bool,
useCamera2Api: PropTypes.bool,
playSoundOnCapture: PropTypes.bool,
videoStabilizationMode: PropTypes.string,
videoStabilizationMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
pictureSize: PropTypes.string,
};

Expand Down Expand Up @@ -234,6 +235,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
useCamera2Api: false,
playSoundOnCapture: false,
pictureSize: '1920x1080',
videoStabilizationMode: 0,
};

_cameraRef: ?Object;
Expand Down

0 comments on commit 83d0618

Please sign in to comment.