Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only apply filter if filter is set #1360

Merged
merged 2 commits into from
Dec 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions ios/Video/RCTVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -1274,27 +1274,23 @@ - (void)setFilter:(NSString *)filterName {

CIFilter *filter = [CIFilter filterWithName:filterName];

_playerItem.videoComposition = [AVVideoComposition
videoCompositionWithAsset:asset
applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *_Nonnull request) {
if (filter != nil) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, need to test for an empty filter name too. Having set no filter, I get "" here, not nil


if (filter == nil) {
_playerItem.videoComposition = [AVVideoComposition
videoCompositionWithAsset:asset
applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *_Nonnull request) {

[request finishWithImage:request.sourceImage context:nil];
CIImage *image = request.sourceImage.imageByClampingToExtent;

} else {
[filter setValue:image forKey:kCIInputImageKey];

CIImage *image = request.sourceImage.imageByClampingToExtent;
CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];

[filter setValue:image forKey:kCIInputImageKey];
[request finishWithImage:output context:nil];

CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];

[request finishWithImage:output context:nil];

}

}];
}];
}

}

Expand Down