Merge pull request #1360 from nickgzzjr/master
Only apply filter if filter is set
This commit is contained in:
commit
e5bada9fc6
@ -1268,39 +1268,29 @@ static int const RCTVideoUnset = -1;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFilter:(NSString *)filterName {
|
- (void)setFilter:(NSString *)filterName {
|
||||||
|
|
||||||
_filterName = filterName;
|
_filterName = filterName;
|
||||||
|
|
||||||
AVAsset *asset = _playerItem.asset;
|
AVAsset *asset = _playerItem.asset;
|
||||||
|
|
||||||
if (asset != nil) {
|
if (!asset) {
|
||||||
|
return;
|
||||||
|
} else if (!_playerItem.videoComposition && (filterName == nil || [filterName isEqualToString:@""])) {
|
||||||
|
return; // Setting up an empty filter has a cost so avoid whenever possible
|
||||||
|
}
|
||||||
|
// TODO: filters don't work for HLS, check & return
|
||||||
|
|
||||||
CIFilter *filter = [CIFilter filterWithName:filterName];
|
CIFilter *filter = [CIFilter filterWithName:filterName];
|
||||||
|
|
||||||
_playerItem.videoComposition = [AVVideoComposition
|
_playerItem.videoComposition = [AVVideoComposition
|
||||||
videoCompositionWithAsset:asset
|
videoCompositionWithAsset:asset
|
||||||
applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *_Nonnull request) {
|
applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *_Nonnull request) {
|
||||||
|
|
||||||
if (filter == nil) {
|
if (filter == nil) {
|
||||||
|
|
||||||
[request finishWithImage:request.sourceImage context:nil];
|
[request finishWithImage:request.sourceImage context:nil];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
CIImage *image = request.sourceImage.imageByClampingToExtent;
|
CIImage *image = request.sourceImage.imageByClampingToExtent;
|
||||||
|
|
||||||
[filter setValue:image forKey:kCIInputImageKey];
|
[filter setValue:image forKey:kCIInputImageKey];
|
||||||
|
|
||||||
CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];
|
CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];
|
||||||
|
|
||||||
[request finishWithImage:output context:nil];
|
[request finishWithImage:output context:nil];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - React View Management
|
#pragma mark - React View Management
|
||||||
|
Loading…
Reference in New Issue
Block a user