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;
|
||||||
CIFilter *filter = [CIFilter filterWithName:filterName];
|
} else if (!_playerItem.videoComposition && (filterName == nil || [filterName isEqualToString:@""])) {
|
||||||
|
return; // Setting up an empty filter has a cost so avoid whenever possible
|
||||||
_playerItem.videoComposition = [AVVideoComposition
|
|
||||||
videoCompositionWithAsset:asset
|
|
||||||
applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *_Nonnull request) {
|
|
||||||
|
|
||||||
if (filter == nil) {
|
|
||||||
|
|
||||||
[request finishWithImage:request.sourceImage context:nil];
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
CIImage *image = request.sourceImage.imageByClampingToExtent;
|
|
||||||
|
|
||||||
[filter setValue:image forKey:kCIInputImageKey];
|
|
||||||
|
|
||||||
CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];
|
|
||||||
|
|
||||||
[request finishWithImage:output context:nil];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// TODO: filters don't work for HLS, check & return
|
||||||
|
|
||||||
|
CIFilter *filter = [CIFilter filterWithName:filterName];
|
||||||
|
_playerItem.videoComposition = [AVVideoComposition
|
||||||
|
videoCompositionWithAsset:asset
|
||||||
|
applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *_Nonnull request) {
|
||||||
|
if (filter == nil) {
|
||||||
|
[request finishWithImage:request.sourceImage context:nil];
|
||||||
|
} else {
|
||||||
|
CIImage *image = request.sourceImage.imageByClampingToExtent;
|
||||||
|
[filter setValue:image forKey:kCIInputImageKey];
|
||||||
|
CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];
|
||||||
|
[request finishWithImage:output context:nil];
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - React View Management
|
#pragma mark - React View Management
|
||||||
@ -1463,4 +1453,4 @@ static int const RCTVideoUnset = -1;
|
|||||||
return array[0];
|
return array[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user