Skip to content

Commit

Permalink
Merge pull request #423 from opentok/0.14.0
Browse files Browse the repository at this point in the history
Update Native SDK to 2.17.x (#421)
  • Loading branch information
ggoldens authored Jun 26, 2020
2 parents ed9feb6 + f0d8e2f commit 1baf989
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 67 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.14.0 (May 22, 2020)

- **[Feature]**: Update of iOS SDK to `2.17.0` and Android SDK to `2.17.1`
- OTSessionManager.java#248 mSubscriber.destroy() removed as from 2.17.x, resources will be automatically released by the garbage collector.

# 0.13.0 (Mar 23, 2020)

- **[Feature]**: Add Session Options support, both [iOS](https://tokbox.com/developer/sdks/ios/reference/Classes/OTSessionSettings.html) and [Android](https://tokbox.com/developer/sdks/android/reference/). Note: iceConfig option is not currently supported
Expand Down Expand Up @@ -28,6 +33,6 @@

- **[Feature]**: Enable `OTSubscriber` children custom render (merged from [PR306](https://github.com/opentok/opentok-react-native/pull/306)). Adheres to: [#289](https://github.com/opentok/opentok-react-native/issues/289), [#174](https://github.com/opentok/opentok-react-native/issues/174)
- iOS SDK updated to `2.16.1`
- Android SDK updated to `2.16.1`
- Android SDK updated to `2.16.1`

# 0.x.x (todo)
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@

React Native library for OpenTok iOS and Android SDKs

- [Pre-Requisites](#pre-requisites)
- [Installation](#installation)
- [iOS Installation](#ios-installation)
- [Android Installation](#android-installation)
- API Reference
- [OTSession Component](https://github.com/opentok/opentok-react-native/tree/master/docs/OTSession.md)
- [OTPublisher Component](https://github.com/opentok/opentok-react-native/tree/master/docs/OTPublisher.md)
- [OTSubscriber Component](https://github.com/opentok/opentok-react-native/tree/master/docs/OTSubscriber.md)
- [Event Data](https://github.com/opentok/opentok-react-native/tree/master/docs/EventData.md)
- [Samples](#samples)
- [Contributing](#contributing)
- [opentok-react-native](#opentok-react-native)
- [In this repo, you'll find the OpenTok React Native library:](#in-this-repo-youll-find-the-opentok-react-native-library)
- [Pre-Requisites:](#pre-requisites)
- [Installation:](#installation)
- [iOS Installation](#ios-installation)
- [Android Installation](#android-installation)
- [Samples](#samples)
- [Development and Contributing](#development-and-contributing)
- [Getting Help](#getting-help)

### In this repo, you'll find the OpenTok React Native library:

Expand Down Expand Up @@ -54,7 +52,7 @@ If you've installed this package before, you may need to edit your `Podfile` and
target '<YourProjectName>' do
# Pods for <YourProject>
pod 'OpenTok', '2.16.3'
pod 'OpenTok', '2.17.0'
end
```
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:${_reactNativeVersion}" // From node_modules
implementation 'com.opentok.android:opentok-android-sdk:2.16.5'
implementation 'com.opentok.android:opentok-android-sdk:2.17.1'
}
52 changes: 24 additions & 28 deletions android/src/main/java/com/opentokreactnative/OTSessionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ public void publish(String sessionId, String publisherId, Callback callback) {
}

@ReactMethod
public void subscribeToStream(String streamId, ReadableMap properties, Callback callback) {
public void subscribeToStream(String streamId, String sessionId, ReadableMap properties, Callback callback) {

ConcurrentHashMap<String, Stream> mSubscriberStreams = sharedState.getSubscriberStreams();
ConcurrentHashMap<String, Subscriber> mSubscribers = sharedState.getSubscribers();
ConcurrentHashMap<String, Session> mSessions = sharedState.getSessions();
Stream stream = mSubscriberStreams.get(streamId);
Session mSession = mSessions.get(stream.getSession().getSessionId());
Session mSession = mSessions.get(sessionId);
Subscriber mSubscriber = new Subscriber.Builder(getReactApplicationContext(), stream).build();
mSubscriber.setSubscriberListener(this);
mSubscriber.setAudioLevelListener(this);
Expand Down Expand Up @@ -246,9 +246,6 @@ public void run() {
mSubscriberViewContainer.removeAllViews();
}
mSubscriberViewContainers.remove(mStreamId);
if (mSubscriber != null) {
mSubscriber.destroy();
}
mSubscribers.remove(mStreamId);
mSubscriberStreams.remove(mStreamId);
mCallback.invoke();
Expand Down Expand Up @@ -388,7 +385,7 @@ public void run() {
Publisher mPublisher = mPublishers.get(publisherId);
Session mSession = null;
mPublisherDestroyedCallbacks.put(publisherId, callback);
if (mPublisher != null && mPublisher.getSession() != null) {
if (mPublisher != null && mPublisher.getSession() != null && mPublisher.getSession().getSessionId() != null) {
mSession = mSessions.get(mPublisher.getSession().getSessionId());
}

Expand All @@ -400,10 +397,9 @@ public void run() {
mSession.unpublish(mPublisher);
}
if (mPublisher != null) {
mPublisher.destroy();
mPublisher.getCapturer().stopCapture();
}
mPublishers.remove(publisherId);
callback.invoke();
}
});
}
Expand Down Expand Up @@ -507,7 +503,7 @@ public void onStreamReceived(Session session, Stream stream) {

ConcurrentHashMap<String, Stream> mSubscriberStreams = sharedState.getSubscriberStreams();
mSubscriberStreams.put(stream.getStreamId(), stream);
WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream);
WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream, session);
sendEventMap(this.getReactApplicationContext(), session.getSessionId() + ":" + sessionPreface + "onStreamReceived", streamInfo);
printLogs("onStreamReceived: New Stream Received " + stream.getStreamId() + " in session: " + session.getSessionId());

Expand Down Expand Up @@ -587,7 +583,7 @@ public void onConnectionDestroyed(Session session, Connection connection) {
@Override
public void onStreamDropped(Session session, Stream stream) {

WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream);
WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream, session);
sendEventMap(this.getReactApplicationContext(), session.getSessionId() + ":" + sessionPreface + "onStreamDropped", streamInfo);
printLogs("onStreamDropped: Stream Dropped: "+stream.getStreamId() +" in session: "+session.getSessionId());
}
Expand All @@ -600,7 +596,7 @@ public void onStreamCreated(PublisherKit publisherKit, Stream stream) {
mSubscriberStreams.put(stream.getStreamId(), stream);
if (publisherId.length() > 0) {
String event = publisherId + ":" + publisherPreface + "onStreamCreated";;
WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream);
WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream, publisherKit.getSession());
sendEventMap(this.getReactApplicationContext(), event, streamInfo);
}
printLogs("onStreamCreated: Publisher Stream Created. Own stream "+stream.getStreamId());
Expand All @@ -616,7 +612,7 @@ public void onStreamDestroyed(PublisherKit publisherKit, Stream stream) {
String mStreamId = stream.getStreamId();
mSubscriberStreams.remove(mStreamId);
if (publisherId.length() > 0) {
WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream);
WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream, publisherKit.getSession());
sendEventMap(this.getReactApplicationContext(), event, streamInfo);
}
Callback mCallback = sharedState.getPublisherDestroyedCallbacks().get(publisherId);
Expand Down Expand Up @@ -659,7 +655,7 @@ public void onConnected(SubscriberKit subscriberKit) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriberKit.getSession()));
}
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onConnected", subscriberInfo);
}
Expand All @@ -675,7 +671,7 @@ public void onDisconnected(SubscriberKit subscriberKit) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriberKit.getSession()));
}
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onDisconnected", subscriberInfo);
}
Expand All @@ -691,7 +687,7 @@ public void onReconnected(SubscriberKit subscriberKit) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriberKit.getSession()));
}
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onReconnected", subscriberInfo);
}
Expand All @@ -707,7 +703,7 @@ public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriberKit.getSession()));
}
subscriberInfo.putMap("error", EventUtils.prepareJSErrorMap(opentokError));
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onError", subscriberInfo);
Expand Down Expand Up @@ -740,7 +736,7 @@ public void onAudioStats(SubscriberKit subscriber, SubscriberKit.SubscriberAudio
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
}
subscriberInfo.putMap("audioStats", EventUtils.prepareAudioNetworkStats(stats));
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onAudioStats", subscriberInfo);
Expand All @@ -756,7 +752,7 @@ public void onVideoStats(SubscriberKit subscriber, SubscriberKit.SubscriberVideo
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
}
subscriberInfo.putMap("videoStats", EventUtils.prepareVideoNetworkStats(stats));
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onVideoStats", subscriberInfo);
Expand All @@ -772,7 +768,7 @@ public void onAudioLevelUpdated(SubscriberKit subscriber, float audioLevel) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
}
subscriberInfo.putString("audioLevel", String.valueOf(audioLevel));
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onAudioLevelUpdated", subscriberInfo);
Expand All @@ -788,7 +784,7 @@ public void onVideoDisabled(SubscriberKit subscriber, String reason) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
}
subscriberInfo.putString("reason", reason);
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onVideoDisabled", subscriberInfo);
Expand All @@ -805,7 +801,7 @@ public void onVideoEnabled(SubscriberKit subscriber, String reason) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
}
subscriberInfo.putString("reason", reason);
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onVideoEnabled", subscriberInfo);
Expand All @@ -822,7 +818,7 @@ public void onVideoDisableWarning(SubscriberKit subscriber) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
}
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onVideoDisableWarning", subscriberInfo);
}
Expand All @@ -838,7 +834,7 @@ public void onVideoDisableWarningLifted(SubscriberKit subscriber) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
}
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onVideoDisableWarningLifted", subscriberInfo);
}
Expand All @@ -854,7 +850,7 @@ public void onVideoDataReceived(SubscriberKit subscriber) {
Stream mStream = streams.get(streamId);
WritableMap subscriberInfo = Arguments.createMap();
if (mStream != null) {
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream));
subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
}
sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onVideoDataReceived", subscriberInfo);
}
Expand All @@ -863,14 +859,14 @@ public void onVideoDataReceived(SubscriberKit subscriber) {
@Override
public void onStreamHasAudioChanged(Session session, Stream stream, boolean Audio) {

WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("hasAudio", !Audio, Audio, stream);
WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("hasAudio", !Audio, Audio, stream, session);
sendEventMap(this.getReactApplicationContext(), session.getSessionId() + ":" + sessionPreface + "onStreamPropertyChanged", eventData);
printLogs("onStreamHasAudioChanged");
}
@Override
public void onStreamHasVideoChanged(Session session, Stream stream, boolean Video) {

WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("hasVideo", !Video, Video, stream);
WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("hasVideo", !Video, Video, stream, session);
sendEventMap(this.getReactApplicationContext(), session.getSessionId() + ":" + sessionPreface + "onStreamPropertyChanged", eventData);
printLogs("onStreamHasVideoChanged");
}
Expand All @@ -887,7 +883,7 @@ public void onStreamVideoDimensionsChanged(Session session, Stream stream, int w
WritableMap newVideoDimensions = Arguments.createMap();
newVideoDimensions.putInt("height", height);
newVideoDimensions.putInt("width", width);
WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("videoDimensions", oldVideoDimensions, newVideoDimensions, stream);
WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("videoDimensions", oldVideoDimensions, newVideoDimensions, stream, session);
sendEventMap(this.getReactApplicationContext(), session.getSessionId() + ":" + sessionPreface + "onStreamPropertyChanged", eventData);
printLogs("onStreamVideoDimensionsChanged");

Expand All @@ -898,7 +894,7 @@ public void onStreamVideoTypeChanged(Session session, Stream stream, Stream.Stre

ConcurrentHashMap<String, Stream> mSubscriberStreams = sharedState.getSubscriberStreams();
String oldVideoType = stream.getStreamVideoType().toString();
WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("videoType", oldVideoType, videoType.toString(), stream);
WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("videoType", oldVideoType, videoType.toString(), stream, session);
sendEventMap(this.getReactApplicationContext(), session.getSessionId() + ":" + sessionPreface + "onStreamPropertyChanged", eventData);
printLogs("onStreamVideoTypeChanged");
}
Expand Down
Loading

0 comments on commit 1baf989

Please sign in to comment.