Skip to content

Commit

Permalink
Release 0.9.5
Browse files Browse the repository at this point in the history
.Updated JS SDK to 0.9.5 (plugin api is changed accordingly)
.Added support for cordova-android 4.x
.Fixed issue with voice calls to not display video feeds
  • Loading branch information
Narek committed Oct 23, 2015
1 parent 8e0837f commit 9b5eaea
Show file tree
Hide file tree
Showing 8 changed files with 1,362 additions and 430 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ b6.session.signup({identity: 'usr:john', password: 'secret'}, function(err) {
```
Send a message to another user:
```js
b6.sendMessage({other: 'usr:tom', content: 'Hello!'}, function(err) {
b6.compose('usr:tom').text('Hello!').send(function(err) {
if (err) {
console.log('error', err);
} else {
Expand Down
3 changes: 1 addition & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.bit6.sdk"
version="0.9.2">
version="0.9.5">

<name>Bit6</name>
<description>Add voice and video calling, text and media messaging to your app</description>
Expand All @@ -11,7 +11,6 @@

<engines>
<engine name="cordova-ios" version=">=3.0.0" />
<engine name="cordova-android" version="&lt;4.0.0" />
</engines>

<dependency id="com.phonegap.plugins.PushPlugin" url="https://github.com/Telerik-Verified-Plugins/PushNotification" />
Expand Down
44 changes: 39 additions & 5 deletions src/android/com/dooble/phonertc/PhoneRTCPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class PhoneRTCPlugin extends CordovaPlugin {
private WebView.LayoutParams _videoParams;
private boolean _shouldDispose = true;
private boolean _initializedAndroidGlobals = false;

private WebView _webView;

public PhoneRTCPlugin() {
_remoteVideos = new ArrayList<VideoTrackRendererPair>();
Expand Down Expand Up @@ -260,9 +262,39 @@ public PeerConnectionFactory getPeerConnectionFactory() {
public Activity getActivity() {
return cordova.getActivity();
}


//Returning used WebView instance depending on cordova-android version (webView type).
//Making the code compatible with all cordova-android versions.
public WebView getWebView() {
return this.getWebView();
if (_webView != null)
return _webView;

if (webView == null) { //should not happen
Log.e("PRTC", "Error: webView is not initialized yet in CordovaPlugin");
return null;
}

if (webView instanceof WebView ) {
_webView = (WebView) webView;
}
else { //(>=4.0.0), using getView method
java.lang.reflect.Method method = null;

try {
method = webView.getClass().getMethod("getView");

} catch (Exception e) {
Log.e("PRTC", "Failed to get method 'getView' from CordovaWebView class: " + e.getMessage());
}

try {
_webView = (WebView) (method.invoke(webView));

} catch (Exception e) {
Log.e("PRTC", "getView method invocation failed: " + e.getMessage());
}
}
return _webView;
}

public VideoConfig getVideoConfig() {
Expand Down Expand Up @@ -332,7 +364,7 @@ private void createVideoView() {
_videoView = new VideoGLView(cordova.getActivity(), size);
VideoRendererGui.setView(_videoView);

webView.addView(_videoView, _videoParams);
getWebView().addView(_videoView, _videoParams);
}

private void refreshVideoView() {
Expand All @@ -352,7 +384,7 @@ private void refreshVideoView() {
}

if (_videoView != null) {
webView.removeView(_videoView);
getWebView().removeView(_videoView);
_videoView = null;
}

Expand Down Expand Up @@ -473,7 +505,7 @@ public void run() {

if (_videoView != null) {
_videoView.setVisibility(View.GONE);
webView.removeView(_videoView);
getWebView().removeView(_videoView);
}

if (_videoSource != null) {
Expand All @@ -497,6 +529,8 @@ public void run() {

_audioTrack = null;
}

_videoConfig = null;

// if (_peerConnectionFactory != null) {
// _peerConnectionFactory.dispose();
Expand Down
8 changes: 5 additions & 3 deletions src/ios/PhoneRTCPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,16 @@ -(void) setVideoView:(CDVInvokedUrlCommand*)command

dispatch_async(dispatch_get_main_queue(), ^(void) {
// create session config from the JS params

VideoConfig *videoConfig = [[VideoConfig alloc] init: config];

self.videoConfig = videoConfig; //Init self.videoConfig to request remote video.

// make sure that it's not junk
if (videoConfig.container.width == 0 || videoConfig.container.height == 0) {
return;
}

self.videoConfig = videoConfig;

// add local video view
if (self.videoConfig.local != nil) {
if (self.localVideoTrack == nil) {
Expand Down Expand Up @@ -346,6 +347,7 @@ -(void) onSessionDisconnect:(NSString*) sessionKey

self.videoSource = nil;
self.videoCapturer = nil;
self.videoConfig = nil;
}
}

Expand All @@ -358,4 +360,4 @@ - (instancetype)init:(RTCEAGLVideoView*) videoViewP :(RTCVideoTrack*) videoTrack
self.videoTrack = videoTrack;
return self;
}
@end
@end
Loading

0 comments on commit 9b5eaea

Please sign in to comment.