Skip to content

Commit

Permalink
Merge pull request #189 from opentok/0.9.0
Browse files Browse the repository at this point in the history
v0.9.0
  • Loading branch information
Manik Sachdeva authored Nov 4, 2018
2 parents 85c83a6 + b7fa27e commit fc70693
Show file tree
Hide file tree
Showing 16 changed files with 1,231 additions and 794 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ React Native library for OpenTok iOS and Android SDKs
- [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)

Expand Down Expand Up @@ -48,7 +49,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.14.0'
pod 'OpenTok', '2.15.0'
end
```
Expand All @@ -59,7 +60,7 @@ If you've installed this package before, you may need to edit your `Podfile` and

6. Now run, `react-native link opentok-react-native`.

7. Open `<YourProjectName>.xcworkspace` file in XCode. This file can be found in the `ios` folder of your React Native project.
7. Open `<YourProjectName>.xcworkspace` contents in XCode. This file can be found in the `ios` folder of your React Native project.

7. Click `File` and `New File`

Expand Down Expand Up @@ -97,12 +98,10 @@ If you try to archive the app and it fails, please do the following:
url "http://tokbox.bintray.com/maven"
}
```
* It should look something like this:
* ![](https://dha4w82d62smt.cloudfront.net/items/1W1p0Z27471J210d3M2r/Image%202018-03-08%20at%202.12.38%20PM.png?X-CloudApp-Visitor-Id=2816462&v=8ce583bb)

5. Sync Gradle

6. Make sure the following in your app's gradle `compileSdkVersion`, `buildToolsVersion`, `minSdkVersion`, and `targetSdkVersion` are the same in the OpenTok React Native library.
6. Make sure the following in your app's gradle `compileSdkVersion`, `buildToolsVersion`, `minSdkVersion`, and `targetSdkVersion` are greater than or equal to versions specified in the OpenTok React Native library.

7. As for the older Android devices, ensure you add camera and audio permissions to your `AndroidManifest.xml` file:

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 {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.facebook.react:react-native:${_reactNativeVersion}" // From node_modules
compile 'com.opentok.android:opentok-android-sdk:2.14.0'
compile 'com.opentok.android:opentok-android-sdk:2.15.0'
}
521 changes: 240 additions & 281 deletions android/src/main/java/com/opentokreactnative/OTSessionManager.java

Large diffs are not rendered by default.

106 changes: 106 additions & 0 deletions android/src/main/java/com/opentokreactnative/utils/EventUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.opentokreactnative.utils;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.opentok.android.Connection;
import com.opentok.android.OpentokError;
import com.opentok.android.Session;
import com.opentok.android.Stream;
import com.opentok.android.SubscriberKit;

public final class EventUtils {

public static WritableMap prepareJSConnectionMap(Connection connection) {

WritableMap connectionInfo = Arguments.createMap();
if (connection != null) {
connectionInfo.putString("connectionId", connection.getConnectionId());
connectionInfo.putString("creationTime", connection.getCreationTime().toString());
connectionInfo.putString("data", connection.getData());
}
return connectionInfo;
}

public static WritableMap prepareJSStreamMap(Stream stream) {

WritableMap streamInfo = Arguments.createMap();
if (stream != null) {
streamInfo.putString("streamId", stream.getStreamId());
streamInfo.putInt("height", stream.getVideoHeight());
streamInfo.putInt("width", stream.getVideoWidth());
streamInfo.putString("creationTime", stream.getCreationTime().toString());
streamInfo.putString("connectionId", stream.getConnection().getConnectionId());
streamInfo.putString("name", stream.getName());
streamInfo.putBoolean("hasAudio", stream.hasAudio());
streamInfo.putBoolean("hasVideo", stream.hasVideo());
}
return streamInfo;
}

public static WritableMap prepareJSErrorMap(OpentokError error) {

WritableMap errorInfo = Arguments.createMap();
errorInfo.putString("message", error.getMessage());
errorInfo.putString("code", error.getErrorCode().toString());
return errorInfo;
}

public static WritableMap prepareJSSessionMap(Session session) {

WritableMap sessionInfo = Arguments.createMap();
sessionInfo.putString("sessionId", session.getSessionId());
if (session.getConnection() != null) {
WritableMap connectionInfo = prepareJSConnectionMap(session.getConnection());
sessionInfo.putMap("connection", connectionInfo);
}
return sessionInfo;
}

public static WritableMap prepareStreamPropertyChangedEventData(String changedProperty, String oldValue, String newValue, Stream stream) {

WritableMap streamPropertyEventData = Arguments.createMap();
streamPropertyEventData.putString("changedProperty", changedProperty);
streamPropertyEventData.putString("oldValue", oldValue);
streamPropertyEventData.putString("newValue", newValue);
streamPropertyEventData.putMap("stream", prepareJSStreamMap(stream));
return streamPropertyEventData;
}

public static WritableMap prepareStreamPropertyChangedEventData(String changedProperty, WritableMap oldValue, WritableMap newValue, Stream stream) {

WritableMap streamPropertyEventData = Arguments.createMap();
streamPropertyEventData.putString("changedProperty", changedProperty);
streamPropertyEventData.putMap("oldValue", oldValue);
streamPropertyEventData.putMap("newValue", newValue);
streamPropertyEventData.putMap("stream", prepareJSStreamMap(stream));
return streamPropertyEventData;
}

public static WritableMap prepareStreamPropertyChangedEventData(String changedProperty, Boolean oldValue, Boolean newValue, Stream stream) {

WritableMap streamPropertyEventData = Arguments.createMap();
streamPropertyEventData.putString("changedProperty", changedProperty);
streamPropertyEventData.putBoolean("oldValue", oldValue);
streamPropertyEventData.putBoolean("newValue", newValue);
streamPropertyEventData.putMap("stream", prepareJSStreamMap(stream));
return streamPropertyEventData;
}

public static WritableMap prepareAudioNetworkStats(SubscriberKit.SubscriberAudioStats stats) {

WritableMap audioStats = Arguments.createMap();
audioStats.putInt("audioPacketsLost", stats.audioPacketsLost);
audioStats.putInt("audioBytesReceived", stats.audioBytesReceived);
audioStats.putInt("audioPacketsReceived", stats.audioPacketsReceived);
return audioStats;
}

public static WritableMap prepareVideoNetworkStats(SubscriberKit.SubscriberVideoStats stats) {

WritableMap videoStats = Arguments.createMap();
videoStats.putInt("videoPacketsLost", stats.videoPacketsLost);
videoStats.putInt("videoBytesReceived", stats.videoBytesReceived);
videoStats.putInt("videoPacketsReceived", stats.videoPacketsReceived);
return videoStats;
}
}
62 changes: 62 additions & 0 deletions android/src/main/java/com/opentokreactnative/utils/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.opentokreactnative.utils;

import com.opentok.android.OpentokError;
import com.opentok.android.Publisher;
import com.opentok.android.PublisherKit;
import com.opentok.android.Subscriber;
import com.opentok.android.SubscriberKit;
import com.opentokreactnative.OTRN;

import java.util.ArrayList;
import java.util.Map;

public final class Utils {

public static boolean didConnectionFail(OpentokError errorCode) {

switch (errorCode.getErrorCode()) {
case ConnectionFailed:
return true;
case ConnectionRefused:
return true;
case ConnectionTimedOut:
return true;
default:
return false;
}
}

public static boolean contains(ArrayList array, String value) {

for (int i = 0; i < array.size(); i++) {
if (array.get(i).equals(value)) {
return true;
}
}
return false;
}

public static String getPublisherId(PublisherKit publisherKit) {

Map<String, Publisher> publishers = OTRN.sharedState.getPublishers();
for (Map.Entry<String, Publisher> entry: publishers.entrySet()) {
Publisher mPublisher = entry.getValue();
if (mPublisher.equals(publisherKit)) {
return entry.getKey();
}
}
return "";
}

public static String getStreamIdBySubscriber(SubscriberKit subscriberKit) {

Map<String, Subscriber> subscribers = OTRN.sharedState.getSubscribers();
for (Map.Entry<String, Subscriber> entry: subscribers.entrySet()) {
Subscriber mSubcriber = entry.getValue();
if (mSubcriber.equals(subscriberKit)) {
return entry.getKey();
}
}
return "";
}
}
75 changes: 75 additions & 0 deletions docs/EventData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## Event Data

Below, you will find the strucutre of the event objects broken down by event type.

### Archive Event

You can find the structure of the object below:

```javascript
archive = {
archiveId: '',
name: '',
};
```

### Audio Network Stats

You can find the structure of the object below:

```javascript
audioNetworkStats = {
audioPacketsLost: '',
audioBytesReceived: '',
audioPacketsReceived: '',
};
```

### Connection Event

You can find the structure of the object below:

```javascript
connection = {
connectionId: '',
creationTime: '',
};
```

### Error Event
You can find the structure of the object below:

```javascript
error = {
code: '',
message: '',
};
```

### Stream Event

You can find the structure of the object below:

```javascript
stream = {
streamId: '',
name: '',
connectionId: '',
hasAudio: '',
hasVideo: '',
creationTime: '',
height: '',
width: '',
};
```

### Video Network Stats
You can find the structure of the object below:

```javascript
videoNetworkStats = {
videoPacketsLost: '',
videoBytesReceived: '',
videoPacketsReceived: '',
};
```
16 changes: 16 additions & 0 deletions docs/OT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### OT

This library uses React Native bridging to expose native (iOS & Android) methods via a native module. We've create a custom native module, `OT`, for this library.

Below, you will find a list of methods that you can access at any time to configure logs, etc:

### To enable logs:
By default, the native logs are disabled. Please using the following method to enable native logs.
```javascript
OT.enableLogs(true);
```

### To disable logs:
```javascript
OT.enableLogs(false);
```
20 changes: 18 additions & 2 deletions ios/OpenTokReactNative.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
9C6F95D420ACE90E00FEAD68 /* OTScreenCapturer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C6F95C920ACE90E00FEAD68 /* OTScreenCapturer.swift */; };
9C6F95D520ACE90E00FEAD68 /* OTRN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C6F95CB20ACE90E00FEAD68 /* OTRN.swift */; };
9C6F95D620ACE90E00FEAD68 /* OTPublisher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C6F95CC20ACE90E00FEAD68 /* OTPublisher.m */; };
9C86849D218E2B5A004679BA /* EventUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C86849C218E2B5A004679BA /* EventUtils.swift */; };
9C86850F218E3433004679BA /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C86850E218E3433004679BA /* Utils.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -51,6 +53,8 @@
9C6F95CA20ACE90E00FEAD68 /* OTPublisher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTPublisher.h; sourceTree = "<group>"; };
9C6F95CB20ACE90E00FEAD68 /* OTRN.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTRN.swift; sourceTree = "<group>"; };
9C6F95CC20ACE90E00FEAD68 /* OTPublisher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTPublisher.m; sourceTree = "<group>"; };
9C86849C218E2B5A004679BA /* EventUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventUtils.swift; sourceTree = "<group>"; };
9C86850E218E3433004679BA /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -83,6 +87,7 @@
9C6F95B620ACE8BE00FEAD68 /* OpenTokReactNative */ = {
isa = PBXGroup;
children = (
9C86849B218E2B31004679BA /* Utils */,
9C6F95CA20ACE90E00FEAD68 /* OTPublisher.h */,
9C6F95CC20ACE90E00FEAD68 /* OTPublisher.m */,
9C6F95C520ACE90E00FEAD68 /* OTPublisherManager.swift */,
Expand All @@ -102,6 +107,15 @@
path = OpenTokReactNative;
sourceTree = "<group>";
};
9C86849B218E2B31004679BA /* Utils */ = {
isa = PBXGroup;
children = (
9C86849C218E2B5A004679BA /* EventUtils.swift */,
9C86850E218E3433004679BA /* Utils.swift */,
);
path = Utils;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -162,8 +176,10 @@
files = (
9C6F95D020ACE90E00FEAD68 /* OTSubscriber.m in Sources */,
9C6F95D120ACE90E00FEAD68 /* OTPublisherManager.swift in Sources */,
9C86849D218E2B5A004679BA /* EventUtils.swift in Sources */,
9C6F95D220ACE90E00FEAD68 /* OTSessionManager.swift in Sources */,
9C6F95D320ACE90E00FEAD68 /* OTSubscriberView.swift in Sources */,
9C86850F218E3433004679BA /* Utils.swift in Sources */,
9C6F95CF20ACE90E00FEAD68 /* OTPublisherView.swift in Sources */,
9C6F95CE20ACE90E00FEAD68 /* OTSubscriberManager.swift in Sources */,
9C6F95B920ACE8BE00FEAD68 /* OpenTokReactNative.m in Sources */,
Expand Down Expand Up @@ -225,7 +241,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -274,7 +290,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
2 changes: 2 additions & 0 deletions ios/OpenTokReactNative/OTSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ @interface RCT_EXTERN_MODULE(OTSessionManager, RCTEventEmitter)
(NSArray*)events)
RCT_EXTERN_METHOD(getSessionInfo:
(RCTResponseSenderBlock*)callback)
RCT_EXTERN_METHOD(enableLogs:
(BOOL)logLevel)
@end
Loading

0 comments on commit fc70693

Please sign in to comment.