only set filter if given

This commit is contained in:
Nicolas Gonzalez 2018-12-04 20:49:11 -06:00
parent 97ac68745b
commit c807053b52

View File

@ -1266,33 +1266,38 @@ static int const RCTVideoUnset = -1;
- (void)setFilter:(NSString *)filterName {
_filterName = filterName;
_filterName = filterName;
AVAsset *asset = _playerItem.asset;
AVAsset *asset = _playerItem.asset;
if (asset != nil) {
if (asset != nil && filterName != nil) {
CIFilter *filter = [CIFilter filterWithName:filterName];
CIFilter *filter = [CIFilter filterWithName:filterName];
if (filter != nil) {
_playerItem.videoComposition = [AVVideoComposition
videoCompositionWithAsset:asset
applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *_Nonnull request) {
_playerItem.videoComposition = [AVVideoComposition
videoCompositionWithAsset:asset
applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *_Nonnull request) {
if (filter == nil) {
CIImage *image = request.sourceImage.imageByClampingToExtent;
[request finishWithImage:request.sourceImage context:nil];
[filter setValue:image forKey:kCIInputImageKey];
} else {
CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];
CIImage *image = request.sourceImage.imageByClampingToExtent;
[request finishWithImage:output context:nil];
[filter setValue:image forKey:kCIInputImageKey];
CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];
[request finishWithImage:output context:nil];
}
}];
}
}];
}
}
}
@ -1456,4 +1461,4 @@ static int const RCTVideoUnset = -1;
return array[0];
}
@end
@end