Skip to content

Commit 889c68e

Browse files
authored
Merge pull request #774 from opentok/develop
Merge v2.28.1 into main
2 parents 4008047 + debd5b2 commit 889c68e

File tree

12 files changed

+108
-9
lines changed

12 files changed

+108
-9
lines changed

@types/index.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ declare module "opentok-react-native" {
224224
credential?: string;
225225
}[];
226226
};
227+
228+
/**
229+
* Enable single peer connection for the client.
230+
*/
231+
enableSinglePeerConnection?: boolean;
227232
}
228233

229234
interface OTSessionEventHandlers {
@@ -509,6 +514,17 @@ declare module "opentok-react-native" {
509514
*/
510515
getRtcStatsReport: () => void;
511516

517+
/**
518+
* Sets audio transformers for the publisher (or clears them if passed an empty array).
519+
* To use this method, add `pod 'VonageClientSDKVideoTransformers'` to your
520+
* Podfile and add `implementation "com.vonage:client-sdk-video-transformers:2.28.0"`
521+
* to your your app/build.gradle file.
522+
*/
523+
setAudioTransformers: (transformers: Array<{
524+
name: string,
525+
properties?: string,
526+
}>) => void;
527+
512528
/**
513529
* Sets video transformers for the publisher (or clears them if passed an empty array).
514530
* To use this method, add `pod 'VonageClientSDKVideoTransformers'` to your

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# 2.28.1 (September 2024)
2+
3+
- [Update]: The new `OTPublisher.setAudioTransformers()` method lets you set (and clear) audio transformers. One transformer, the noise suppression filter, is supported. To use this, call the `setAudioTransformers()` method of the OTPublisher ref, and pass in an array with one object that has a `name` property set to `'NoiseSuppression'` and a `properties` property set to an empty string:
4+
5+
```js
6+
publisherRef.setAudioTransformers([{
7+
name: 'NoiseSuppression',
8+
properties: '',
9+
}]);
10+
```
11+
12+
*Important:* To use this method, you must add the Vonage Media Transformer library to your project, separately from the OpenTok React Native SDK. See [Vonage Media Library integration](https://tokbox.com/developer/guides/vonage-media-processor/react-native/#vonage-media-library-integration).
13+
14+
- [Update]: This version adds support for enabling single peer connection for the client, by setting the `enableSinglePeerConnection` property of the `options` prop of the OTSession component to `true`. For more information see [this documentation](https://tokbox.com/developer/guides/create-session/#single-peer-connection).
15+
116
# 2.28.0 (July 2024)
217

318
- [Update]: This version updates the Vonage Video Android SDK and iOS SDK to version 2.28.0.
@@ -6,6 +21,8 @@
621

722
**Important:** In order to use the `OTPublisher.setVideoTransformers()` method (which uses the Vonage Media Library), you must add the Vonage Media Library separately from the Vonage Video React Native SDK. For details, see [Vonage Media Library integration](https://tokbox.com/developer/guides/vonage-media-processor/react-native/#vonage-media-library-integration).
823

24+
- [Update]: For Android, this version of the library requires a minimum Android API level of 24.
25+
926
- [Update]: This version adds support for reading the Certificate Authority certificates in the trust store of the host so that it can use them as valid root certificates when connecting to OpenTok services.
1027

1128
- [Update]: This version adds support for Apple's requirement of the [signature for the SDK](https://developer.apple.com/support/third-party-SDK-requirements).

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ See the system requirements for the [OpenTok Android SDK](https://tokbox.com/dev
6363
6464
When you create an archive of your app, the [privacy manifest settings required by Apple's App store](https://developer.apple.com/support/third-party-SDK-requirements) are added automatically with this version of the OpenTok React Native SDK.
6565
66-
3. If your app will use the `OTPublisher.setVideoTransformers()` method, you need to include the following in your Podfile:
66+
3. If your app will use the `OTPublisher.setVideoTransformers()` or `OTPublisher.setAudioTransformers()` method, you need to include the following in your Podfile:
6767
6868
```
6969
pod 'VonageClientSDKVideoTransformers'
@@ -127,7 +127,7 @@ If you try to archive the app and it fails, please do the following:
127127
<uses-permission android:name="android.permission.CAMERA" tools:node="remove"/>
128128
```
129129
130-
3. If your app will use the `OTPublisher.setVideoTransformers()` method, you need to include the following in your app/build.gradle file:
130+
3. If your app will use the `OTPublisher.setVideoTransformers()` or `OTPublisher.setAudioTransformers()` method, you need to include the following in your app/build.gradle file:
131131
132132
```
133133
implementation "com.vonage:client-sdk-video-transformers:2.28.0"

android/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ apply plugin: 'com.android.library'
22

33
def _ext = rootProject.ext
44
def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'
5-
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 23
6-
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '23.0.1'
7-
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16
8-
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 23
5+
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 24
6+
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '24.0.3'
7+
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 24
8+
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 24
99

1010
android {
1111
compileSdkVersion _compileSdkVersion

android/src/main/java/com/opentokreactnative/OTSessionManager.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.opentok.android.MuteForcedInfo;
3232
import com.opentok.android.Publisher;
3333
import com.opentok.android.PublisherKit;
34+
import com.opentok.android.PublisherKit.AudioTransformer;
3435
import com.opentok.android.PublisherKit.VideoTransformer;
3536
import com.opentok.android.Stream;
3637
import com.opentok.android.OpentokError;
@@ -107,6 +108,7 @@ public void initSession(String apiKey, String sessionId, ReadableMap sessionOpti
107108
ConcurrentHashMap<String, Session> mSessions = sharedState.getSessions();
108109
ConcurrentHashMap<String, String> mAndroidOnTopMap = sharedState.getAndroidOnTopMap();
109110
ConcurrentHashMap<String, String> mAndroidZOrderMap = sharedState.getAndroidZOrderMap();
111+
final boolean singlePeerConnection = sessionOptions.getBoolean("enableSinglePeerConnection");
110112

111113

112114
Session mSession = new Session.Builder(this.getReactApplicationContext(), apiKey, sessionId)
@@ -121,6 +123,7 @@ public boolean useTextureViews() {
121123
.setIceRouting(transportPolicy)
122124
.setIpWhitelist(ipWhitelist)
123125
.setProxyUrl(proxyUrl)
126+
.setSinglePeerConnection(singlePeerConnection)
124127
.build();
125128
mSession.setSessionListener(this);
126129
mSession.setSignalListener(this);
@@ -421,6 +424,16 @@ public void setVideoTransformers(String publisherId, ReadableArray videoTransfor
421424
}
422425
}
423426

427+
@ReactMethod
428+
public void setAudioTransformers(String publisherId, ReadableArray audioTransformers) {
429+
ConcurrentHashMap<String, Publisher> mPublishers = sharedState.getPublishers();
430+
Publisher mPublisher = mPublishers.get(publisherId);
431+
if (mPublisher != null) {
432+
ArrayList<AudioTransformer> nativeAudioTransformers = Utils.sanitizeAudioTransformerList(mPublisher, audioTransformers);
433+
mPublisher.setAudioTransformers(nativeAudioTransformers);
434+
}
435+
}
436+
424437
@ReactMethod
425438
public void subscribeToAudio(String streamId, Boolean subscribeToAudio) {
426439

android/src/main/java/com/opentokreactnative/utils/Utils.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.opentok.android.OpentokError;
44
import com.opentok.android.Publisher;
55
import com.opentok.android.PublisherKit;
6+
import com.opentok.android.PublisherKit.AudioTransformer;
67
import com.opentok.android.PublisherKit.VideoTransformer;
78
import com.opentok.android.Subscriber;
89
import com.opentok.android.SubscriberKit;
@@ -101,6 +102,21 @@ public static List<IceServer> sanitizeIceServer(ReadableArray serverList) {
101102
return iceServers;
102103
}
103104

105+
public static ArrayList<AudioTransformer> sanitizeAudioTransformerList(PublisherKit publisher, ReadableArray transformerList) {
106+
ArrayList<AudioTransformer> nativeAudioTransformers = new ArrayList<>();
107+
if (transformerList != null) {
108+
for (int i = 0; i < transformerList.size(); i++) {
109+
String transformerName = transformerList.getMap(i).getString("name");
110+
AudioTransformer transformer = publisher.new AudioTransformer(
111+
transformerName,
112+
transformerList.getMap(i).getString("properties")
113+
);
114+
nativeAudioTransformers.add(transformer);
115+
}
116+
}
117+
return nativeAudioTransformers;
118+
}
119+
104120
public static ArrayList<VideoTransformer> sanitizeVideoTransformerList(PublisherKit publisher, ReadableArray transformerList) {
105121
ArrayList<VideoTransformer> nativeVideoTransformers = new ArrayList<>();
106122
if (transformerList != null) {

ios/OpenTokReactNative/OTSessionManager.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ @interface RCT_EXTERN_MODULE(OTSessionManager, RCTEventEmitter)
9797
RCT_EXTERN_METHOD(setVideoTransformers:
9898
(NSString*)publisherId
9999
videoTransformers:(NSArray*)videoTransformers)
100+
RCT_EXTERN_METHOD(setAudioTransformers:
101+
(NSString*)publisherId
102+
audioTransformers:(NSArray*)audioTransformers)
100103
RCT_EXTERN_METHOD(removeJSComponentEvents:
101104
(NSArray*)events)
102105
RCT_EXTERN_METHOD(getSessionInfo:

ios/OpenTokReactNative/OTSessionManager.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class OTSessionManager: RCTEventEmitter {
5252
settings.proxyURL = Utils.sanitizeStringProperty(sessionOptions["proxyUrl"] as Any);
5353
settings.ipWhitelist = Utils.sanitizeBooleanProperty(sessionOptions["ipWhitelist"] as Any);
5454
settings.iceConfig = Utils.sanitizeIceServer(sessionOptions["customServers"] as Any, sessionOptions["transportPolicy"] as Any, sessionOptions["includeServers"] as Any);
55+
settings.singlePeerConnection = Utils.sanitizeBooleanProperty(sessionOptions["enableSinglePeerConnection"] as Any);
5556
OTRN.sharedState.sessions.updateValue(OTSession(apiKey: apiKey, sessionId: sessionId, delegate: self, settings: settings)!, forKey: sessionId);
5657
}
5758

@@ -358,6 +359,30 @@ class OTSessionManager: RCTEventEmitter {
358359
}
359360
}
360361

362+
@objc func setAudioTransformers(_ publisherId: String, audioTransformers: Array<Any>) -> Void {
363+
guard let publisher = OTRN.sharedState.publishers[publisherId] else {
364+
return // To do -- handle error
365+
}
366+
var nativeTransformers: [OTAudioTransformer] = [];
367+
368+
for transformer in audioTransformers {
369+
guard let transformerDictionary = transformer as? [String: String] else {
370+
return // To do -- handle error
371+
}
372+
guard let transformerName = transformerDictionary["name"], let transformerProperties = transformerDictionary["properties"] else {
373+
return // To do -- handle error
374+
}
375+
guard let nativeTransformer = OTAudioTransformer(
376+
name: transformerName,
377+
properties: transformerProperties
378+
) else {
379+
return // To do -- handle error
380+
}
381+
nativeTransformers.append(nativeTransformer)
382+
}
383+
publisher.audioTransformers = nativeTransformers
384+
}
385+
361386
@objc func setVideoTransformers(_ publisherId: String, videoTransformers: Array<Any>) -> Void {
362387
guard let publisher = OTRN.sharedState.publishers[publisherId] else {
363388
return // To do -- handle error

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": "opentok-react-native",
3-
"version": "2.28.0",
3+
"version": "2.28.1",
44
"description": "React Native components for OpenTok iOS and Android SDKs",
55
"main": "src/index.js",
66
"homepage": "https://www.tokbox.com",

0 commit comments

Comments
 (0)