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

React native vb #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Everyone is welcome to our [Discourse community](https://react-native-webrtc.dis

## WebRTC Revision

* Currently used revision: [M100](https://github.com/jitsi/webrtc/releases/tag/v100.0.0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

please check latest jitsi webrtc version

* Currently used revision: [M94](https://github.com/jitsi/webrtc/releases/tag/v94.0.0)
* Supported architectures
* Android: armeabi-v7a, arm64-v8a, x86, x86_64
* iOS: arm64, x86_64 (for bitcode support, run [this script](https://github.com/react-native-webrtc/react-native-webrtc/blob/master/tools/downloadBitcode.sh))
Expand Down
20 changes: 18 additions & 2 deletions ios/RCTWebRTC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,15 @@
35A222291CB493700015FD5C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../apple/";
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../apple/",
"\"${PODS_ROOT}/MLKitSegmentationSelfie/Frameworks\"",
"\"${PODS_ROOT}/MLKitSegmentationCommon/Frameworks\"",
"\"${PODS_ROOT}/MLKitCommon/Frameworks\"",
"\"${PODS_ROOT}/MLImage/Frameworks\"",
"\"${PODS_ROOT}/MLKitVision/Frameworks\"",
"\"${PODS_ROOT}/MLKitXenoCommon/Frameworks\"",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -318,7 +326,15 @@
35A2222A1CB493700015FD5C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../apple/";
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../apple/",
"\"${PODS_ROOT}/MLKitSegmentationSelfie/Frameworks\"",
"\"${PODS_ROOT}/MLKitSegmentationCommon/Frameworks\"",
"\"${PODS_ROOT}/MLKitCommon/Frameworks\"",
"\"${PODS_ROOT}/MLImage/Frameworks\"",
"\"${PODS_ROOT}/MLKitVision/Frameworks\"",
"\"${PODS_ROOT}/MLKitXenoCommon/Frameworks\"",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
4 changes: 0 additions & 4 deletions ios/RCTWebRTC/ScreenCaptureController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ - (instancetype)initWithCapturer:(nonnull ScreenCapturer *)capturer {
return self;
}

- (void)dealloc {
[self.capturer stopCapture];
}

- (void)startCapture {
if (!self.appGroupIdentifier) {
return;
Expand Down
7 changes: 0 additions & 7 deletions ios/RCTWebRTC/ScreenCapturer.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,6 @@ - (instancetype)initWithDelegate:(__weak id<RTCVideoCapturerDelegate>)delegate {
return self;
}

- (void)setConnection:(SocketConnection *)connection {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why did you remove it

if (_connection != connection) {
[_connection close];
_connection = connection;
}
}

- (void)startCaptureWithConnection:(SocketConnection *)connection {
_startTimeStampNs = -1;

Expand Down
19 changes: 17 additions & 2 deletions ios/RCTWebRTC/VideoCaptureController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ @interface VideoCaptureController ()
@property (nonatomic, assign) int width;
@property (nonatomic, assign) int height;
@property (nonatomic, assign) int frameRate;
@property (nonatomic, assign) BOOL vb;

@end

Expand All @@ -34,6 +35,9 @@ - (instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer
self.width = [constraints[@"width"] intValue];
self.height = [constraints[@"height"] intValue];
self.frameRate = [constraints[@"frameRate"] intValue];
if(constraints[@"vb"]) {
self.vb = YES;
}

id facingMode = constraints[@"facingMode"];

Expand Down Expand Up @@ -96,6 +100,17 @@ - (void)startCapture {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

__weak VideoCaptureController *weakSelf = self;

if (self.vb) {
// Selfie Segmentator library requires kCVPixelFormatType_32BGRA format
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

please update comment with MLKit

for (AVCaptureOutput *output in _capturer.captureSession.outputs) {
RCTLog(@"Changing capturer output to %@", ((AVCaptureVideoDataOutput*)output).videoSettings);
if([output isKindOfClass:AVCaptureVideoDataOutput.class]) {
((AVCaptureVideoDataOutput*)output).videoSettings = @{(NSString *)kCVPixelBufferPixelFormatTypeKey: [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]};
}
}
}

[self.capturer startCaptureWithDevice:self.device format:format fps:self.frameRate completionHandler:^(NSError *err) {
if (err) {
RCTLogError(@"[VideoCaptureController] Error starting capture: %@", err);
Expand Down Expand Up @@ -227,8 +242,8 @@ - (void)throttleFrameRateForDevice:(AVCaptureDevice *)device {
return;
}

device.activeVideoMinFrameDuration = CMTimeMake(1, 20);
device.activeVideoMaxFrameDuration = CMTimeMake(1, 15);
device.activeVideoMinFrameDuration = CMTimeMake(1, 15);
device.activeVideoMaxFrameDuration = CMTimeMake(1, 12);

[device unlockForConfiguration];
}
Expand Down
21 changes: 21 additions & 0 deletions ios/RCTWebRTC/VideoSourceInterceptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// VideoSourceInterceptor.h
// react-native-webrtc
//
// Created by YAVUZ SELIM CAKIR on 18.06.2022.
//

#import <Foundation/Foundation.h>
#import <WebRTC/RTCVideoSource.h>

NS_ASSUME_NONNULL_BEGIN

@interface VideoSourceInterceptor : NSObject<RTCVideoCapturerDelegate>

@property(nonatomic, strong) RTCVideoSource *videoSource;

- (instancetype)initWithVideoSource: (RTCVideoSource*) videoSource;

@end

NS_ASSUME_NONNULL_END
Loading