Skip to content

Commit 64fbd17

Browse files
authored
feat: v137 upgrade (#20)
1 parent 772fc76 commit 64fbd17

File tree

8 files changed

+75
-13
lines changed

8 files changed

+75
-13
lines changed

android/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ android {
7070
targetSdkVersion safeExtGet('targetSdkVersion', 24)
7171
versionCode 1
7272
versionName "1.0"
73+
consumerProguardFiles 'consumer-rules.pro'
7374
}
7475

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

8788
dependencies {
88-
api 'io.getstream:stream-webrtc-android:1.3.10'
89-
implementation 'com.facebook.react:react-native:+'
89+
api 'io.getstream:stream-video-webrtc-android:137.0.1'
90+
implementation "com.facebook.react:react-android:+"
9091
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
9192
implementation "androidx.core:core:1.7.0"
9293
}

android/consumer-rules.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# WebRTC
2+
-keep class org.webrtc.** { *; }
3+
-keep class org.jni_zero.** { *; }

android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ private AudioTrack createAudioTrack(ReadableMap constraints) {
111111
PeerConnectionFactory pcFactory = webRTCModule.mFactory;
112112
MediaConstraints peerConstraints = webRTCModule.constraintsForOptions(audioConstraintsMap);
113113

114+
// Convert given constraints into the internal webrtc media constraints.
115+
peerConstraints.optional.add(new MediaConstraints.KeyValuePair("googAutoGainControl",
116+
audioConstraintsMap.hasKey("autoGainControl")
117+
? ReactBridgeUtil.getMapStrValue(audioConstraintsMap, "autoGainControl")
118+
: "true"));
119+
peerConstraints.optional.add(new MediaConstraints.KeyValuePair("googNoiseSuppression",
120+
audioConstraintsMap.hasKey("noiseSuppression")
121+
? ReactBridgeUtil.getMapStrValue(audioConstraintsMap, "noiseSuppression")
122+
: "true"));
123+
peerConstraints.optional.add(new MediaConstraints.KeyValuePair("googEchoCancellation",
124+
audioConstraintsMap.hasKey("echoCancellation")
125+
? ReactBridgeUtil.getMapStrValue(audioConstraintsMap, "echoCancellation")
126+
: "true"));
127+
peerConstraints.optional.add(new MediaConstraints.KeyValuePair("googHighpassFilter",
128+
audioConstraintsMap.hasKey("highpassFilter")
129+
? ReactBridgeUtil.getMapStrValue(audioConstraintsMap, "highpassFilter")
130+
: "true"));
131+
114132
// PeerConnectionFactory.createAudioSource will throw an error when mandatory constraints contain nulls.
115133
// so, let's check for nulls
116134
checkMandatoryConstraints(peerConstraints);

ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ - (void)setVideoEffectProcessor:(VideoEffectProcessor *)videoEffectProcessor
3232

3333
#pragma mark - getUserMedia
3434

35+
- (NSString *)convertBoolToString:(id)value {
36+
return value ? @"true" : @"false";
37+
}
38+
3539
/**
3640
* Initializes a new {@link RTCAudioTrack} which satisfies the given constraints.
3741
*
@@ -40,7 +44,26 @@ - (void)setVideoEffectProcessor:(VideoEffectProcessor *)videoEffectProcessor
4044
*/
4145
- (RTCAudioTrack *)createAudioTrack:(NSDictionary *)constraints {
4246
NSString *trackId = [[NSUUID UUID] UUIDString];
43-
RTCAudioTrack *audioTrack = [self.peerConnectionFactory audioTrackWithTrackId:trackId];
47+
NSDictionary *audioConstraints = constraints[@"audio"];
48+
NSMutableDictionary *optionalConstraints = [NSMutableDictionary dictionary];
49+
optionalConstraints[@"googAutoGainControl"] = audioConstraints[@"autoGainControl"] != nil
50+
? [self convertBoolToString:audioConstraints[@"autoGainControl"]]
51+
: @"true";
52+
optionalConstraints[@"googNoiseSuppression"] =
53+
audioConstraints[@"noiseSuppression"] != nil ? [self convertBoolToString:audioConstraints[@"noiseSuppression"]]
54+
: @"true";
55+
optionalConstraints[@"googEchoCancellation"] =
56+
audioConstraints[@"echoCancellation"] != nil ? [self convertBoolToString:audioConstraints[@"echoCancellation"]]
57+
: @"true";
58+
optionalConstraints[@"googHighpassFilter"] = audioConstraints[@"highpassFilter"] != nil
59+
? [self convertBoolToString:audioConstraints[@"highpassFilter"]]
60+
: @"true";
61+
62+
RTCMediaConstraints *mediaConstraints =
63+
[[RTCMediaConstraints alloc] initWithMandatoryConstraints:nil optionalConstraints:optionalConstraints];
64+
65+
RTCAudioSource *audioSource = [self.peerConnectionFactory audioSourceWithConstraints:mediaConstraints];
66+
RTCAudioTrack *audioTrack = [self.peerConnectionFactory audioTrackWithSource:audioSource trackId:trackId];
4467
return audioTrack;
4568
}
4669
/**

ios/RCTWebRTC/WebRTCModule.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,24 @@ - (instancetype)init {
7777
NSLog(@"Both audioProcessingModule and audioDevice are provided, but only one can be used. Ignoring audioDevice.");
7878
}
7979
RCTLogInfo(@"Using audio processing module: %@", NSStringFromClass([audioProcessingModule class]));
80-
_peerConnectionFactory = [[RTCPeerConnectionFactory alloc] initWithBypassVoiceProcessing:NO
81-
encoderFactory:encoderFactory
82-
decoderFactory:decoderFactory
83-
audioProcessingModule:audioProcessingModule];
84-
} else {
85-
RCTLogInfo(@"Using audio device: %@", NSStringFromClass([audioDevice class]));
80+
_peerConnectionFactory =
81+
[[RTCPeerConnectionFactory alloc] initWithAudioDeviceModuleType:RTCAudioDeviceModuleTypePlatformDefault
82+
bypassVoiceProcessing:NO
83+
encoderFactory:encoderFactory
84+
decoderFactory:decoderFactory
85+
audioProcessingModule:audioProcessingModule];
86+
} else if (audioDevice != nil) {
87+
RCTLogInfo(@"Using custom audio device: %@", NSStringFromClass([audioDevice class]));
8688
_peerConnectionFactory = [[RTCPeerConnectionFactory alloc] initWithEncoderFactory:encoderFactory
8789
decoderFactory:decoderFactory
8890
audioDevice:audioDevice];
91+
} else {
92+
_peerConnectionFactory =
93+
[[RTCPeerConnectionFactory alloc] initWithAudioDeviceModuleType:RTCAudioDeviceModuleTypePlatformDefault
94+
bypassVoiceProcessing:NO
95+
encoderFactory:encoderFactory
96+
decoderFactory:decoderFactory
97+
audioProcessingModule:nil];
8998
}
9099

91100
_peerConnections = [NSMutableDictionary new];

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stream-io/react-native-webrtc",
3-
"version": "125.4.5",
3+
"version": "137.0.0-alpha.6",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/GetStream/react-native-webrtc.git"

stream-react-native-webrtc.podspec

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ require 'json'
22

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

5+
# WebRTC version from stream-video-swift-webrtc releases
6+
webrtc_version = '137.0.42'
7+
58
Pod::Spec.new do |s|
69
s.name = 'stream-react-native-webrtc'
710
s.version = package['version']
@@ -19,7 +22,12 @@ Pod::Spec.new do |s|
1922
s.libraries = 'c', 'sqlite3', 'stdc++'
2023
s.framework = 'AudioToolbox','AVFoundation', 'CoreAudio', 'CoreGraphics', 'CoreVideo', 'GLKit', 'VideoToolbox'
2124
s.dependency 'React-Core'
22-
s.dependency 'StreamWebRTC', '~>125.6422.070'
25+
26+
s.prepare_command = <<-CMD
27+
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
28+
CMD
29+
30+
s.vendored_frameworks = 'WebRTC.xcframework'
2331
# Swift/Objective-C compatibility #https://blog.cocoapods.org/CocoaPods-1.5.0/
2432
s.pod_target_xcconfig = {
2533
'DEFINES_MODULE' => 'YES'

0 commit comments

Comments
 (0)