Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion LFLiveKit/LFLiveSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#import "LFLiveVideoConfiguration.h"
#import "LFLiveDebug.h"


@class GPUImageFilterGroup;

typedef NS_ENUM(NSInteger,LFLiveCaptureType) {
LFLiveCaptureAudio, //< capture only audio
Expand Down Expand Up @@ -127,6 +127,7 @@ typedef NS_ENUM(NSInteger,LFLiveCaptureTypeMask) {
/* The saveLocalVideoPath is save the local video path */
@property (nonatomic, strong, nullable) NSURL *saveLocalVideoPath;

@property (nonatomic, nullable) GPUImageFilterGroup *customFilterGroup;
#pragma mark - Initializer
///=============================================================================
/// @name Initializer
Expand Down
9 changes: 9 additions & 0 deletions LFLiveKit/LFLiveSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ - (void)setSaveLocalVideoPath:(NSURL*)saveLocalVideoPath{
[self.videoCaptureSource setSaveLocalVideoPath:saveLocalVideoPath];
}

- (GPUImageFilterGroup * _Nullable)customFilterGroup {
return self.videoCaptureSource.customFilterGroup;
}

- (void)setCustomFilterGroup:(GPUImageFilterGroup * _Nullable)customFilterGroup {
[self.videoCaptureSource setCustomFilterGroup:customFilterGroup];
}


- (BOOL)beautyFace {
return self.videoCaptureSource.beautyFace;
}
Expand Down
4 changes: 4 additions & 0 deletions LFLiveKit/capture/LFVideoCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#import <AVFoundation/AVFoundation.h>
#import "LFLiveVideoConfiguration.h"


@class LFVideoCapture;
@class GPUImageFilterGroup;
/** LFVideoCapture callback videoData */
@protocol LFVideoCaptureDelegate <NSObject>
- (void)captureOutput:(nullable LFVideoCapture *)capture pixelBuffer:(nullable CVPixelBufferRef)pixelBuffer;
Expand Down Expand Up @@ -68,6 +70,8 @@
/* The saveLocalVideoPath is save the local video path */
@property (nonatomic, strong, nullable) NSURL *saveLocalVideoPath;

@property (nonatomic, nullable) GPUImageFilterGroup *customFilterGroup;

#pragma mark - Initializer
///=============================================================================
/// @name Initializer
Expand Down
22 changes: 18 additions & 4 deletions LFLiveKit/capture/LFVideoCapture.m
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ - (GPUImageMovieWriter*)movieWriter{
return _movieWriter;
}

- (void)setCustomFilterGroup:(GPUImageFilterGroup * _Nullable)customFilterGroup {
[_customFilterGroup removeAllTargets];
_customFilterGroup = customFilterGroup;
[self reloadFilter];
}

#pragma mark -- Custom Method
- (void)processVideo:(GPUImageOutput *)output {
__weak typeof(self) _self = self;
Expand All @@ -287,6 +293,7 @@ - (void)reloadFilter{
[self.output removeAllTargets];
[self.cropfilter removeAllTargets];

[self.customFilterGroup removeAllTargets];
if (self.beautyFace) {
self.output = [[LFGPUImageEmptyFilter alloc] init];
self.filter = [[LFGPUImageBeautyFilter alloc] init];
Expand All @@ -309,21 +316,28 @@ - (void)reloadFilter{
}else{
[self.videoCamera addTarget:self.filter];
}


GPUImageOutput<GPUImageInput> * lastFilter = self.filter;
if (self.customFilterGroup) {
[self.filter addTarget:self.customFilterGroup];
lastFilter = self.customFilterGroup;
}

//< 添加水印
if(self.warterMarkView){
[self.filter addTarget:self.blendFilter];
[lastFilter addTarget:self.blendFilter];
[self.uiElementInput addTarget:self.blendFilter];
[self.blendFilter addTarget:self.gpuImageView];
if(self.saveLocalVideo) [self.blendFilter addTarget:self.movieWriter];
[self.filter addTarget:self.output];
[lastFilter addTarget:self.output];
[self.uiElementInput update];
}else{
[self.filter addTarget:self.output];
[lastFilter addTarget:self.output];
[self.output addTarget:self.gpuImageView];
if(self.saveLocalVideo) [self.output addTarget:self.movieWriter];
}

[self.customFilterGroup forceProcessingAtSize:self.configuration.videoSize];
[self.filter forceProcessingAtSize:self.configuration.videoSize];
[self.output forceProcessingAtSize:self.configuration.videoSize];
[self.blendFilter forceProcessingAtSize:self.configuration.videoSize];
Expand Down