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
12 changes: 9 additions & 3 deletions ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ - (RTCVideoTrack *)createVideoTrack:(NSDictionary *)constraints {
return nil;
#else

RTCVideoSource *videoSource = [self.peerConnectionFactory videoSource];
self.videoSource = [self.peerConnectionFactory videoSource];

NSString *trackUUID = [[NSUUID UUID] UUIDString];
RTCVideoTrack *videoTrack = [self.peerConnectionFactory videoTrackWithSource:videoSource trackId:trackUUID];
RTCVideoTrack *videoTrack = [self.peerConnectionFactory videoTrackWithSource:self.videoSource trackId:trackUUID];

#if !TARGET_IPHONE_SIMULATOR
NSDictionary *videoContraints = constraints[@"video"];

RTCCameraVideoCapturer *videoCapturer;

RCTLog(@"Video constraint in create video track: %@", videoContraints);
self.videoSourceInterceptor = [[WebRTCVideoCaptureHandler alloc] initWithSource:videoSource backgroundImageData:nil];
self.videoSourceInterceptor = [[WebRTCVideoCaptureHandler alloc] initWithSource:self.videoSource backgroundImageData:nil];
videoCapturer = [[RTCCameraVideoCapturer alloc] initWithDelegate:self.videoSourceInterceptor];

self.videoCaptureController = [[VideoCaptureController alloc] initWithCapturer:videoCapturer
Expand Down Expand Up @@ -203,6 +203,12 @@ - (RTCVideoTrack *)createScreenCaptureVideoTrack {
: (RCTResponseSenderBlock)successCallback errorCallback
: (RCTResponseSenderBlock)errorCallback) {
// If virtual backround is enabled, use video source interceptor before video source
int width = [constraints[@"width"] intValue];
int height = [constraints[@"height"] intValue];
int frameRate = [constraints[@"frameRate"] intValue];

[self.videoSource adaptOutputFormatToWidth:width height:height fps:frameRate];

if (constraints[@"enableBlurBackgroud"]) {
[self.videoSourceInterceptor enableWithBlur:YES backgroundImageData:nil];
} else if (constraints[@"enableVirtualBackgroud"]) {
Expand Down
3 changes: 2 additions & 1 deletion ios/RCTWebRTC/WebRTCModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ static NSString *const kEventPeerConnectionOnTrack = @"peerConnectionOnTrack";
@property(nonatomic, strong) NSMutableDictionary<NSString *, RTCMediaStream *> *localStreams;
@property(nonatomic, strong) NSMutableDictionary<NSString *, RTCMediaStreamTrack *> *localTracks;
@property (nonatomic, strong) id videoSourceInterceptor;
@property (nonatomic, strong) RTCVideoSource *videoSource;
@property (nonatomic, strong) VideoCaptureController *videoCaptureController;

- (RTCMediaStream *)streamForReactTag:(NSString *)reactTag;

@end
@end