-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from opentok/0.9.0
v0.9.0
- Loading branch information
Showing
16 changed files
with
1,231 additions
and
794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
521 changes: 240 additions & 281 deletions
521
android/src/main/java/com/opentokreactnative/OTSessionManager.java
Large diffs are not rendered by default.
Oops, something went wrong.
106 changes: 106 additions & 0 deletions
106
android/src/main/java/com/opentokreactnative/utils/EventUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
62
android/src/main/java/com/opentokreactnative/utils/Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '', | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.