Skip to content
Merged
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
5 changes: 3 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ android {
targetSdkVersion safeExtGet('targetSdkVersion', 24)
versionCode 1
versionName "1.0"
consumerProguardFiles 'consumer-rules.pro'
}

// WebRTC requires Java 8 features
Expand All @@ -85,8 +86,8 @@ def kotlin_version = getExtOrDefault('kotlinVersion', '1.8.10')
println "Building Stream WebRTC React Native module with Kotlin version: $kotlin_version"

dependencies {
api 'io.getstream:stream-webrtc-android:1.3.10'
implementation 'com.facebook.react:react-native:+'
api 'io.getstream:stream-video-webrtc-android:137.0.1'
implementation "com.facebook.react:react-android:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "androidx.core:core:1.7.0"
}
3 changes: 3 additions & 0 deletions android/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# WebRTC
-keep class org.webrtc.** { *; }
-keep class org.jni_zero.** { *; }
18 changes: 18 additions & 0 deletions android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ private AudioTrack createAudioTrack(ReadableMap constraints) {
PeerConnectionFactory pcFactory = webRTCModule.mFactory;
MediaConstraints peerConstraints = webRTCModule.constraintsForOptions(audioConstraintsMap);

// Convert given constraints into the internal webrtc media constraints.
peerConstraints.optional.add(new MediaConstraints.KeyValuePair("googAutoGainControl",
audioConstraintsMap.hasKey("autoGainControl")
? ReactBridgeUtil.getMapStrValue(audioConstraintsMap, "autoGainControl")
: "true"));
peerConstraints.optional.add(new MediaConstraints.KeyValuePair("googNoiseSuppression",
audioConstraintsMap.hasKey("noiseSuppression")
? ReactBridgeUtil.getMapStrValue(audioConstraintsMap, "noiseSuppression")
: "true"));
peerConstraints.optional.add(new MediaConstraints.KeyValuePair("googEchoCancellation",
audioConstraintsMap.hasKey("echoCancellation")
? ReactBridgeUtil.getMapStrValue(audioConstraintsMap, "echoCancellation")
: "true"));
peerConstraints.optional.add(new MediaConstraints.KeyValuePair("googHighpassFilter",
audioConstraintsMap.hasKey("highpassFilter")
? ReactBridgeUtil.getMapStrValue(audioConstraintsMap, "highpassFilter")
: "true"));

// PeerConnectionFactory.createAudioSource will throw an error when mandatory constraints contain nulls.
// so, let's check for nulls
checkMandatoryConstraints(peerConstraints);
Expand Down
25 changes: 24 additions & 1 deletion ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ - (void)setVideoEffectProcessor:(VideoEffectProcessor *)videoEffectProcessor

#pragma mark - getUserMedia

- (NSString *)convertBoolToString:(id)value {
return value ? @"true" : @"false";
}

/**
* Initializes a new {@link RTCAudioTrack} which satisfies the given constraints.
*
Expand All @@ -40,7 +44,26 @@ - (void)setVideoEffectProcessor:(VideoEffectProcessor *)videoEffectProcessor
*/
- (RTCAudioTrack *)createAudioTrack:(NSDictionary *)constraints {
NSString *trackId = [[NSUUID UUID] UUIDString];
RTCAudioTrack *audioTrack = [self.peerConnectionFactory audioTrackWithTrackId:trackId];
NSDictionary *audioConstraints = constraints[@"audio"];
NSMutableDictionary *optionalConstraints = [NSMutableDictionary dictionary];
optionalConstraints[@"googAutoGainControl"] = audioConstraints[@"autoGainControl"] != nil
? [self convertBoolToString:audioConstraints[@"autoGainControl"]]
: @"true";
optionalConstraints[@"googNoiseSuppression"] =
audioConstraints[@"noiseSuppression"] != nil ? [self convertBoolToString:audioConstraints[@"noiseSuppression"]]
: @"true";
optionalConstraints[@"googEchoCancellation"] =
audioConstraints[@"echoCancellation"] != nil ? [self convertBoolToString:audioConstraints[@"echoCancellation"]]
: @"true";
optionalConstraints[@"googHighpassFilter"] = audioConstraints[@"highpassFilter"] != nil
? [self convertBoolToString:audioConstraints[@"highpassFilter"]]
: @"true";

RTCMediaConstraints *mediaConstraints =
[[RTCMediaConstraints alloc] initWithMandatoryConstraints:nil optionalConstraints:optionalConstraints];

RTCAudioSource *audioSource = [self.peerConnectionFactory audioSourceWithConstraints:mediaConstraints];
RTCAudioTrack *audioTrack = [self.peerConnectionFactory audioTrackWithSource:audioSource trackId:trackId];
return audioTrack;
}
/**
Expand Down
21 changes: 15 additions & 6 deletions ios/RCTWebRTC/WebRTCModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,24 @@ - (instancetype)init {
NSLog(@"Both audioProcessingModule and audioDevice are provided, but only one can be used. Ignoring audioDevice.");
}
RCTLogInfo(@"Using audio processing module: %@", NSStringFromClass([audioProcessingModule class]));
_peerConnectionFactory = [[RTCPeerConnectionFactory alloc] initWithBypassVoiceProcessing:NO
encoderFactory:encoderFactory
decoderFactory:decoderFactory
audioProcessingModule:audioProcessingModule];
} else {
RCTLogInfo(@"Using audio device: %@", NSStringFromClass([audioDevice class]));
_peerConnectionFactory =
[[RTCPeerConnectionFactory alloc] initWithAudioDeviceModuleType:RTCAudioDeviceModuleTypePlatformDefault
bypassVoiceProcessing:NO
encoderFactory:encoderFactory
decoderFactory:decoderFactory
audioProcessingModule:audioProcessingModule];
} else if (audioDevice != nil) {
RCTLogInfo(@"Using custom audio device: %@", NSStringFromClass([audioDevice class]));
_peerConnectionFactory = [[RTCPeerConnectionFactory alloc] initWithEncoderFactory:encoderFactory
decoderFactory:decoderFactory
audioDevice:audioDevice];
} else {
_peerConnectionFactory =
[[RTCPeerConnectionFactory alloc] initWithAudioDeviceModuleType:RTCAudioDeviceModuleTypePlatformDefault
bypassVoiceProcessing:NO
encoderFactory:encoderFactory
decoderFactory:decoderFactory
audioProcessingModule:nil];
}

_peerConnections = [NSMutableDictionary new];
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stream-io/react-native-webrtc",
"version": "125.4.5",
"version": "137.0.0-alpha.6",
"repository": {
"type": "git",
"url": "git+https://github.com/GetStream/react-native-webrtc.git"
Expand Down
10 changes: 9 additions & 1 deletion stream-react-native-webrtc.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

# WebRTC version from stream-video-swift-webrtc releases
webrtc_version = '137.0.42'

Pod::Spec.new do |s|
s.name = 'stream-react-native-webrtc'
s.version = package['version']
Expand All @@ -19,7 +22,12 @@ Pod::Spec.new do |s|
s.libraries = 'c', 'sqlite3', 'stdc++'
s.framework = 'AudioToolbox','AVFoundation', 'CoreAudio', 'CoreGraphics', 'CoreVideo', 'GLKit', 'VideoToolbox'
s.dependency 'React-Core'
s.dependency 'StreamWebRTC', '~>125.6422.070'

s.prepare_command = <<-CMD
curl -sL "https://github.com/GetStream/stream-video-swift-webrtc/releases/download/#{webrtc_version}/WebRTC.xcframework.zip" -o w.zip && unzip -oq w.zip && rm w.zip
CMD

s.vendored_frameworks = 'WebRTC.xcframework'
# Swift/Objective-C compatibility #https://blog.cocoapods.org/CocoaPods-1.5.0/
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES'
Expand Down