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 codec backwards compat
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l authored Jun 13, 2018
1 parent 4fdd548 commit 91f5bf4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ios/RN/RNCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ - (void)record:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve r
[connection setVideoOrientation:[RNCameraUtils videoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]]];

if (options[@"codec"]) {
AVVideoCodecType videoCodecType = options[@"codec"];
if (@available(iOS 10, *)) {
AVVideoCodecType videoCodecType = options[@"codec"];
if ([self.movieFileOutput.availableVideoCodecTypes containsObject:videoCodecType]) {
[self.movieFileOutput setOutputSettings:@{AVVideoCodecKey:videoCodecType} forConnection:connection];
self.videoCodecType = videoCodecType;
Expand Down Expand Up @@ -812,12 +812,15 @@ - (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToO
}
}
if (success && self.videoRecordedResolve != nil) {
AVVideoCodecType videoCodec = self.videoCodecType;
if (videoCodec == nil) {
videoCodec = [self.movieFileOutput.availableVideoCodecTypes firstObject];
if (@available(iOS 10, *)) {
AVVideoCodecType videoCodec = self.videoCodecType;
if (videoCodec == nil) {
videoCodec = [self.movieFileOutput.availableVideoCodecTypes firstObject];
}
self.videoRecordedResolve(@{ @"uri": outputFileURL.absoluteString, @"codec":videoCodec });
} else {
self.videoRecordedResolve(@{ @"uri": outputFileURL.absoluteString });
}

self.videoRecordedResolve(@{ @"uri": outputFileURL.absoluteString, @"codec":videoCodec });
} else if (self.videoRecordedReject != nil) {
self.videoRecordedReject(@"E_RECORDING_FAILED", @"An error occurred while recording a video.", error);
}
Expand Down

0 comments on commit 91f5bf4

Please sign in to comment.