Skip to content
Closed
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
1 change: 1 addition & 0 deletions ios/RCTWebRTC/PIPController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ API_AVAILABLE(ios(15.0))
@property(nonatomic, assign) BOOL startAutomatically;
@property(nonatomic, assign) BOOL stopAutomatically;
@property(nonatomic, assign) CGSize preferredSize;
@property(nonatomic, assign) CGFloat blurIntensity;

- (instancetype)initWithSourceView:(UIView *)sourceView;
- (void)togglePIP;
Expand Down
5 changes: 5 additions & 0 deletions ios/RCTWebRTC/PIPController.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ - (void)setPreferredSize:(CGSize)size {
}
}

- (void)setBlurIntensity:(CGFloat)blurIntensity {
_blurIntensity = blurIntensity;
_sampleView.blurIntensity = blurIntensity;
}

- (BOOL)startAutomatically {
return _pipController.canStartPictureInPictureAutomaticallyFromInline;
}
Expand Down
6 changes: 6 additions & 0 deletions ios/RCTWebRTC/RTCVideoViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,16 @@ - (void)API_AVAILABLE(ios(15.0))setPIPOptions:(NSDictionary *)pipOptions {
_pipController.videoTrack = _videoTrack;
}

CGFloat blurIntensity = 0;
if ([pipOptions objectForKey:@"blurIntensity"]) {
blurIntensity = [pipOptions[@"blurIntensity"] doubleValue];
}

_pipController.startAutomatically = startAutomatically;
_pipController.stopAutomatically = stopAutomatically;
_pipController.objectFit = _objectFit;
_pipController.preferredSize = preferredSize;
_pipController.blurIntensity = blurIntensity;
}

- (void)API_AVAILABLE(ios(15.0))startPIP {
Expand Down
1 change: 1 addition & 0 deletions ios/RCTWebRTC/SampleBufferVideoCallView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

@property(nonnull, nonatomic, readonly) AVSampleBufferDisplayLayer *sampleBufferLayer;
@property(nonatomic, assign) BOOL shouldRender;
@property(nonatomic, assign) CGFloat blurIntensity;

- (void)requestScaleRecalculation;
@end
27 changes: 27 additions & 0 deletions ios/RCTWebRTC/SampleBufferVideoCallView.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ @interface SampleBufferVideoCallView ()
@property(nonatomic, retain) I420Converter *i420Converter;
@property(nonatomic, strong) id<SampleBufferRendering> renderer;
@property(nonatomic, assign) NSInteger currentRotation;
@property(nonatomic, strong) UIVisualEffectView *blurEffectView;

@end

Expand Down Expand Up @@ -171,6 +172,32 @@ - (CVPixelBufferRef)pixelBufferFromI420:(RTCI420Buffer *)i420Buffer {
return convertedPixelBuffer;
}

- (void)setBlurIntensity:(CGFloat)blurIntensity {
blurIntensity = MAX(0.0, MIN(1.0, blurIntensity));
if (_blurIntensity == blurIntensity) {
return;
}
_blurIntensity = blurIntensity;

dispatch_async(dispatch_get_main_queue(), ^{
if (blurIntensity > 0) {
if (!self.blurEffectView) {
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
self.blurEffectView = [[UIVisualEffectView alloc] initWithEffect:effect];
self.blurEffectView.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
self.blurEffectView.frame = self.bounds;
self.blurEffectView.alpha = blurIntensity;
if (!self.blurEffectView.superview) {
[self addSubview:self.blurEffectView];
}
} else {
[self.blurEffectView removeFromSuperview];
}
});
}

- (void)dealloc {
[_i420Converter unprepareForAccelerateConversion];
}
Expand Down