Skip to content

Commit

Permalink
Effects change possibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vasicvuk committed Mar 24, 2017
1 parent 79ff535 commit e61b0d6
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LFLiveKit/LFLiveSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#import "LFLiveDebug.h"



typedef NS_ENUM(NSInteger,LFLiveCaptureType) {
LFLiveCaptureAudio, //< capture only audio
LFLiveCaptureVideo, //< capture onlt video
Expand Down Expand Up @@ -157,6 +156,7 @@ typedef NS_ENUM(NSInteger,LFLiveCaptureTypeMask) {

/** support outer input pcm audio(set LFLiveCaptureTypeMask) .*/
- (void)pushAudio:(nullable NSData*)audioData;
-(void)loadCustomFilter:(int)input;

@end

4 changes: 4 additions & 0 deletions LFLiveKit/LFLiveSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ - (LFVideoCapture *)videoCaptureSource {
return _videoEncoder;
}

-(void)loadCustomFilter:(int)input {

[_videoCaptureSource loadCustomFilter: input];
}
- (id<LFStreamSocket>)socket {
if (!_socket) {
_socket = [[LFStreamRTMPSocket alloc] initWithStream:self.streamInfo reconnectInterval:self.reconnectInterval reconnectCount:self.reconnectCount];
Expand Down
2 changes: 1 addition & 1 deletion LFLiveKit/capture/LFVideoCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@
capture unstable.
*/
- (nullable instancetype)initWithVideoConfiguration:(nullable LFLiveVideoConfiguration *)configuration NS_DESIGNATED_INITIALIZER;

-(void)loadCustomFilter:(int)input;
@end
70 changes: 67 additions & 3 deletions LFLiveKit/capture/LFVideoCapture.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (instancetype)initWithVideoConfiguration:(LFLiveVideoConfiguration *)configura
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterForeground:) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarChanged:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];

self.beautyFace = YES;
self.beautyFace = NO;
self.beautyLevel = 0.5;
self.brightLevel = 0.5;
self.zoomScale = 1.0;
Expand Down Expand Up @@ -279,6 +279,56 @@ - (void)processVideo:(GPUImageOutput *)output {
}
}


-(GPUImage3x3ConvolutionFilter*) loadConvulationEffect{
GPUImage3x3ConvolutionFilter *filter = [[GPUImage3x3ConvolutionFilter alloc] init];
[filter setConvolutionKernel:(GPUMatrix3x3){
{ -1.0f, 0.0f, 1.0f},
{-2.0f, 0.0f, 2.0f},
{-1.0f, 0.0f, 1.0f}
}];
return filter;
}

-(void)loadCustomFilter:(int)input {
switch(input){
case 0:
self.filter = [[LFGPUImageEmptyFilter alloc] init];
break;
case 1:
self.filter = [[GPUImageSobelEdgeDetectionFilter alloc] init];
break;
case 2:
self.filter = [[GPUImageColorInvertFilter alloc] init];
break;
case 3:
self.filter = [[GPUImageSepiaFilter alloc] init];
break;
case 4:
self.filter = [[GPUImagePixellateFilter alloc] init];
break;
case 5:
self.filter = [self loadConvulationEffect];
break;
case 6:
self.filter = [[GPUImageCGAColorspaceFilter alloc] init];
break;
case 7:
self.filter = [[GPUImageCrosshatchFilter alloc] init];
break;
case 8:
self.filter = [[GPUImageGrayscaleFilter alloc] init];
break;
case 9:
self.filter = [[LFGPUImageBeautyFilter alloc] init];
break;
default:
self.filter = [[LFGPUImageEmptyFilter alloc] init];
break;
}
[self reloadEffects];
}

- (void)reloadFilter{
[self.filter removeAllTargets];
[self.blendFilter removeAllTargets];
Expand All @@ -289,14 +339,29 @@ - (void)reloadFilter{

if (self.beautyFace) {
self.output = [[LFGPUImageEmptyFilter alloc] init];
self.filter = [[LFGPUImageBeautyFilter alloc] init];
self.beautyFilter = (LFGPUImageBeautyFilter*)self.filter;
} else {
self.output = [[LFGPUImageEmptyFilter alloc] init];
self.filter = [[LFGPUImageEmptyFilter alloc] init];
self.beautyFilter = nil;

}

[self reloadSecondPart];

}

- (void) reloadEffects{
[self.filter removeAllTargets];
[self.blendFilter removeAllTargets];
[self.uiElementInput removeAllTargets];
[self.videoCamera removeAllTargets];
[self.output removeAllTargets];
[self.cropfilter removeAllTargets];
[self reloadSecondPart];
}

- (void) reloadSecondPart{
///< 调节镜像
[self reloadMirror];

Expand Down Expand Up @@ -335,7 +400,6 @@ - (void)reloadFilter{
[self.output setFrameProcessingCompletionBlock:^(GPUImageOutput *output, CMTime time) {
[_self processVideo:output];
}];

}

- (void)reloadMirror{
Expand Down

0 comments on commit e61b0d6

Please sign in to comment.