Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #126 from opentok/3.4.0
Browse files Browse the repository at this point in the history
v3.4.0
  • Loading branch information
Manik Sachdeva authored Sep 6, 2018
2 parents d572008 + da177c9 commit b5dbd80
Show file tree
Hide file tree
Showing 12 changed files with 639 additions and 21 deletions.
2 changes: 1 addition & 1 deletion 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": "cordova-plugin-opentok",
"version": "3.3.0",
"version": "3.4.0",
"description": "Add live video streaming to your Cordova Application",
"cordova": {
"id": "cordova-plugin-opentok",
Expand Down
6 changes: 4 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-opentok"
version="3.3.0">
version="3.4.0">

<name>OpenTokCordovaPlugin</name>
<description>Add live video streaming to your Cordova Application</description>
Expand All @@ -16,7 +16,7 @@
<framework src="com.android.volley:volley:1.1.0" />
<asset src="www/opentok.js" target="opentok.js" />
<source-file src="src/android/OpenTokAndroidPlugin.java" target-dir="src/com/tokbox/cordova/" />

<source-file src="src/android/OpenTokCustomVideoRenderer.java" target-dir="src/com/tokbox/cordova/" />
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -43,6 +43,8 @@
<hook type="before_plugin_install" src="scripts/downloadiOSSDK.js" />
<asset src="www/opentok.js" target="opentok.js" />

<header-file src="src/ios/UIView+Category.h" />
<source-file src="src/ios/UIView+Category.m" />
<header-file src="src/ios/OpenTokPlugin.h" />
<source-file src="src/ios/OpenTokPlugin.m" />

Expand Down
41 changes: 36 additions & 5 deletions src/android/OpenTokAndroidPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.opentok.android.Subscriber;
import com.opentok.android.SubscriberKit;
import com.opentok.android.BaseVideoRenderer;
import com.tokbox.cordova.OpenTokCustomVideoRenderer;

public class OpenTokAndroidPlugin extends CordovaPlugin
implements Session.SessionListener,
Expand Down Expand Up @@ -190,7 +191,7 @@ public RunnablePublisher(JSONArray args) {
boolean publishVideo = true;
int audioBitrate = 40000;
String publisherName = "Android-Cordova-Publisher";
String frameRate = "FPS_30";
String frameRate = "FPS_15";
String resolution = "MEDIUM";
String cameraName = "front";
try {
Expand All @@ -206,7 +207,7 @@ public RunnablePublisher(JSONArray args) {
if (compareStrings(this.mProperty.getString(16), "1280x720")) {
resolution = "HIGH";
}
if (compareStrings(this.mProperty.getString(16), "352x288")) {
if (compareStrings(this.mProperty.getString(16), "320x240") || compareStrings(this.mProperty.getString(16), "352x288")) {
resolution = "LOW";
}
Log.i(TAG, "publisher properties sanitized");
Expand All @@ -220,6 +221,7 @@ public RunnablePublisher(JSONArray args) {
.audioBitrate(audioBitrate)
.frameRate(Publisher.CameraCaptureFrameRate.valueOf(frameRate))
.resolution(Publisher.CameraCaptureResolution.valueOf(resolution))
.renderer(new OpenTokCustomVideoRenderer(cordova.getActivity().getApplicationContext()))
.build();
mPublisher.setCameraListener(this);
mPublisher.setPublisherListener(this);
Expand Down Expand Up @@ -264,6 +266,10 @@ public void destroyPublisher() {
}
}

public void getImgData(CallbackContext callbackContext) {
((OpenTokCustomVideoRenderer) mPublisher.getRenderer()).getSnapshot(callbackContext);
}

public void run() {
if(this.mView == null) {
this.mView = mPublisher.getView();
Expand Down Expand Up @@ -349,12 +355,13 @@ public RunnableSubscriber(JSONArray args, Stream stream) {
mStream = stream;

logMessage("NEW SUBSCRIBER BEING CREATED");
mSubscriber = new Subscriber(cordova.getActivity(), mStream);
mSubscriber = new Subscriber.Builder(cordova.getActivity().getApplicationContext(), mStream)
.renderer(new OpenTokCustomVideoRenderer(cordova.getActivity().getApplicationContext()))
.build();
mSubscriber.setVideoListener(this);
mSubscriber.setSubscriberListener(this);
mSubscriber.setAudioLevelListener(this);
mSubscriber.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);

mSession.subscribe(mSubscriber);
cordova.getActivity().runOnUiThread(this);
}
Expand Down Expand Up @@ -391,6 +398,10 @@ public void run() {
super.run();
}

public void getImgData(CallbackContext callbackContext) {
((OpenTokCustomVideoRenderer) mSubscriber.getRenderer()).getSnapshot(callbackContext);
}

@Override
public void onConnected(SubscriberKit arg0) {
// TODO Auto-generated method stub
Expand Down Expand Up @@ -655,6 +666,26 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
cordova.getActivity().runOnUiThread(runsub);
}
}
} else if (action.equals("getImgData")) {
if (args.getString(0).equals("TBPublisher") && myPublisher != null && sessionConnected) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
myPublisher.getImgData(callbackContext);
}
});
return true;
} else {
RunnableSubscriber runsub = subscriberCollection.get(args.getString(0));
if (runsub != null) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
runsub.getImgData(callbackContext);
}
});
runsub.getImgData(callbackContext);
return true;
}
}
} else if (action.equals("exceptionHandler")) {

}
Expand Down Expand Up @@ -948,7 +979,7 @@ protected Map<String, String> getParams()
JSONObject payload = new JSONObject();
try {
payload.put("platform", "Android");
payload.put("cp_version", "3.3.0");
payload.put("cp_version", "3.4.0");
} catch (JSONException e) {
Log.i(TAG, "Error creating payload json object");
}
Expand Down
Loading

0 comments on commit b5dbd80

Please sign in to comment.