Skip to content

Commit

Permalink
Merge pull request #774 from opentok/develop
Browse files Browse the repository at this point in the history
Merge v2.28.1 into main
  • Loading branch information
jeffswartz authored Sep 5, 2024
2 parents 4008047 + debd5b2 commit 889c68e
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 9 deletions.
16 changes: 16 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ declare module "opentok-react-native" {
credential?: string;
}[];
};

/**
* Enable single peer connection for the client.
*/
enableSinglePeerConnection?: boolean;
}

interface OTSessionEventHandlers {
Expand Down Expand Up @@ -509,6 +514,17 @@ declare module "opentok-react-native" {
*/
getRtcStatsReport: () => void;

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

/**
* Sets video transformers for the publisher (or clears them if passed an empty array).
* To use this method, add `pod 'VonageClientSDKVideoTransformers'` to your
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# 2.28.1 (September 2024)

- [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:

```js
publisherRef.setAudioTransformers([{
name: 'NoiseSuppression',
properties: '',
}]);
```

*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).

- [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).

# 2.28.0 (July 2024)

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

**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).

- [Update]: For Android, this version of the library requires a minimum Android API level of 24.

- [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.

- [Update]: This version adds support for Apple's requirement of the [signature for the SDK](https://developer.apple.com/support/third-party-SDK-requirements).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ See the system requirements for the [OpenTok Android SDK](https://tokbox.com/dev
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.
3. If your app will use the `OTPublisher.setVideoTransformers()` method, you need to include the following in your Podfile:
3. If your app will use the `OTPublisher.setVideoTransformers()` or `OTPublisher.setAudioTransformers()` method, you need to include the following in your Podfile:
```
pod 'VonageClientSDKVideoTransformers'
Expand Down Expand Up @@ -127,7 +127,7 @@ If you try to archive the app and it fails, please do the following:
<uses-permission android:name="android.permission.CAMERA" tools:node="remove"/>
```
3. If your app will use the `OTPublisher.setVideoTransformers()` method, you need to include the following in your app/build.gradle file:
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:
```
implementation "com.vonage:client-sdk-video-transformers:2.28.0"
Expand Down
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ apply plugin: 'com.android.library'

def _ext = rootProject.ext
def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 23
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '23.0.1'
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 23
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 24
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '24.0.3'
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 24
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 24

android {
compileSdkVersion _compileSdkVersion
Expand Down
13 changes: 13 additions & 0 deletions android/src/main/java/com/opentokreactnative/OTSessionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.opentok.android.MuteForcedInfo;
import com.opentok.android.Publisher;
import com.opentok.android.PublisherKit;
import com.opentok.android.PublisherKit.AudioTransformer;
import com.opentok.android.PublisherKit.VideoTransformer;
import com.opentok.android.Stream;
import com.opentok.android.OpentokError;
Expand Down Expand Up @@ -107,6 +108,7 @@ public void initSession(String apiKey, String sessionId, ReadableMap sessionOpti
ConcurrentHashMap<String, Session> mSessions = sharedState.getSessions();
ConcurrentHashMap<String, String> mAndroidOnTopMap = sharedState.getAndroidOnTopMap();
ConcurrentHashMap<String, String> mAndroidZOrderMap = sharedState.getAndroidZOrderMap();
final boolean singlePeerConnection = sessionOptions.getBoolean("enableSinglePeerConnection");


Session mSession = new Session.Builder(this.getReactApplicationContext(), apiKey, sessionId)
Expand All @@ -121,6 +123,7 @@ public boolean useTextureViews() {
.setIceRouting(transportPolicy)
.setIpWhitelist(ipWhitelist)
.setProxyUrl(proxyUrl)
.setSinglePeerConnection(singlePeerConnection)
.build();
mSession.setSessionListener(this);
mSession.setSignalListener(this);
Expand Down Expand Up @@ -421,6 +424,16 @@ public void setVideoTransformers(String publisherId, ReadableArray videoTransfor
}
}

@ReactMethod
public void setAudioTransformers(String publisherId, ReadableArray audioTransformers) {
ConcurrentHashMap<String, Publisher> mPublishers = sharedState.getPublishers();
Publisher mPublisher = mPublishers.get(publisherId);
if (mPublisher != null) {
ArrayList<AudioTransformer> nativeAudioTransformers = Utils.sanitizeAudioTransformerList(mPublisher, audioTransformers);
mPublisher.setAudioTransformers(nativeAudioTransformers);
}
}

@ReactMethod
public void subscribeToAudio(String streamId, Boolean subscribeToAudio) {

Expand Down
16 changes: 16 additions & 0 deletions android/src/main/java/com/opentokreactnative/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.opentok.android.OpentokError;
import com.opentok.android.Publisher;
import com.opentok.android.PublisherKit;
import com.opentok.android.PublisherKit.AudioTransformer;
import com.opentok.android.PublisherKit.VideoTransformer;
import com.opentok.android.Subscriber;
import com.opentok.android.SubscriberKit;
Expand Down Expand Up @@ -101,6 +102,21 @@ public static List<IceServer> sanitizeIceServer(ReadableArray serverList) {
return iceServers;
}

public static ArrayList<AudioTransformer> sanitizeAudioTransformerList(PublisherKit publisher, ReadableArray transformerList) {
ArrayList<AudioTransformer> nativeAudioTransformers = new ArrayList<>();
if (transformerList != null) {
for (int i = 0; i < transformerList.size(); i++) {
String transformerName = transformerList.getMap(i).getString("name");
AudioTransformer transformer = publisher.new AudioTransformer(
transformerName,
transformerList.getMap(i).getString("properties")
);
nativeAudioTransformers.add(transformer);
}
}
return nativeAudioTransformers;
}

public static ArrayList<VideoTransformer> sanitizeVideoTransformerList(PublisherKit publisher, ReadableArray transformerList) {
ArrayList<VideoTransformer> nativeVideoTransformers = new ArrayList<>();
if (transformerList != null) {
Expand Down
3 changes: 3 additions & 0 deletions ios/OpenTokReactNative/OTSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ @interface RCT_EXTERN_MODULE(OTSessionManager, RCTEventEmitter)
RCT_EXTERN_METHOD(setVideoTransformers:
(NSString*)publisherId
videoTransformers:(NSArray*)videoTransformers)
RCT_EXTERN_METHOD(setAudioTransformers:
(NSString*)publisherId
audioTransformers:(NSArray*)audioTransformers)
RCT_EXTERN_METHOD(removeJSComponentEvents:
(NSArray*)events)
RCT_EXTERN_METHOD(getSessionInfo:
Expand Down
25 changes: 25 additions & 0 deletions ios/OpenTokReactNative/OTSessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class OTSessionManager: RCTEventEmitter {
settings.proxyURL = Utils.sanitizeStringProperty(sessionOptions["proxyUrl"] as Any);
settings.ipWhitelist = Utils.sanitizeBooleanProperty(sessionOptions["ipWhitelist"] as Any);
settings.iceConfig = Utils.sanitizeIceServer(sessionOptions["customServers"] as Any, sessionOptions["transportPolicy"] as Any, sessionOptions["includeServers"] as Any);
settings.singlePeerConnection = Utils.sanitizeBooleanProperty(sessionOptions["enableSinglePeerConnection"] as Any);
OTRN.sharedState.sessions.updateValue(OTSession(apiKey: apiKey, sessionId: sessionId, delegate: self, settings: settings)!, forKey: sessionId);
}

Expand Down Expand Up @@ -358,6 +359,30 @@ class OTSessionManager: RCTEventEmitter {
}
}

@objc func setAudioTransformers(_ publisherId: String, audioTransformers: Array<Any>) -> Void {
guard let publisher = OTRN.sharedState.publishers[publisherId] else {
return // To do -- handle error
}
var nativeTransformers: [OTAudioTransformer] = [];

for transformer in audioTransformers {
guard let transformerDictionary = transformer as? [String: String] else {
return // To do -- handle error
}
guard let transformerName = transformerDictionary["name"], let transformerProperties = transformerDictionary["properties"] else {
return // To do -- handle error
}
guard let nativeTransformer = OTAudioTransformer(
name: transformerName,
properties: transformerProperties
) else {
return // To do -- handle error
}
nativeTransformers.append(nativeTransformer)
}
publisher.audioTransformers = nativeTransformers
}

@objc func setVideoTransformers(_ publisherId: String, videoTransformers: Array<Any>) -> Void {
guard let publisher = OTRN.sharedState.publishers[publisherId] else {
return // To do -- handle error
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": "opentok-react-native",
"version": "2.28.0",
"version": "2.28.1",
"description": "React Native components for OpenTok iOS and Android SDKs",
"main": "src/index.js",
"homepage": "https://www.tokbox.com",
Expand Down
5 changes: 5 additions & 0 deletions src/OTPublisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ class OTPublisher extends Component {
}
}

setAudioTransformers(audioTransformers) {
OT.setAudioTransformers(this.state.publisherId, audioTransformers);
}

setVideoTransformers(videoTransformers) {
OT.setVideoTransformers(this.state.publisherId, videoTransformers);
}
Expand All @@ -214,6 +218,7 @@ OTPublisher.propTypes = {
properties: PropTypes.object, // eslint-disable-line react/forbid-prop-types
eventHandlers: PropTypes.object, // eslint-disable-line react/forbid-prop-types
getRtcStatsReport: PropTypes.object, // eslint-disable-line react/forbid-prop-types
setAudioTransformers: PropTypes.func, // eslint-disable-line react/forbid-prop-types
setVideoTransformers: PropTypes.func, // eslint-disable-line react/forbid-prop-types
};
OTPublisher.defaultProps = {
Expand Down
4 changes: 4 additions & 0 deletions src/helpers/OTSessionHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const sanitizeSessionOptions = (options) => {
enableStereoOutput: false,
androidOnTop: '', // 'publisher' || 'subscriber'
androidZOrder: '', // 'mediaOverlay' || 'onTop'
enableSinglePeerConnection: false,
};
} else {
sessionOptions = {
Expand All @@ -114,6 +115,7 @@ const sanitizeSessionOptions = (options) => {
iceConfig: {},
proxyUrl: '',
enableStereoOutput: false,
enableSinglePeerConnection: false,
};
}

Expand All @@ -128,6 +130,7 @@ const sanitizeSessionOptions = (options) => {
iceConfig: 'object',
proxyUrl: 'string',
enableStereoOutput: 'boolean',
enableSinglePeerConnection: 'boolean',
},
android: {
connectionEventsSuppressed: 'boolean',
Expand All @@ -138,6 +141,7 @@ const sanitizeSessionOptions = (options) => {
iceConfig: 'object',
proxyUrl: 'string',
enableStereoOutput: 'boolean',
enableSinglePeerConnection: 'boolean',
},
};

Expand Down

0 comments on commit 889c68e

Please sign in to comment.