Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/RestComm/android-QoS
Browse files Browse the repository at this point in the history
  • Loading branch information
bscheurman committed Sep 20, 2016
2 parents 8cfefec + 4699d0c commit 2056f06
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 32 deletions.
11 changes: 0 additions & 11 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/Restcomm_demo/app/build.gradle
Expand Up @@ -48,7 +48,7 @@ dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'

// TODO: To set up the project to use actual Restcomm SDK, please edit settings.gradle to set actual path to sdk
compile project(':restcomm.android.client.sdk')
compile project(':restcomm.android.sdk')
// TODO: Otherwise for now, I shipped .aar file with the modified SDK
//compile(name:'restcomm.android.client.sdk-debug', ext:'aar')

Expand Down
Expand Up @@ -36,18 +36,25 @@
import java.util.Timer;


import org.mobicents.restcomm.android.client.sdk.RCClient;
import org.mobicents.restcomm.android.client.sdk.RCConnection;
import org.mobicents.restcomm.android.client.sdk.RCConnectionListener;
import org.mobicents.restcomm.android.client.sdk.RCDevice;
import org.mobicents.restcomm.android.client.sdk.RCDeviceListener;
import org.mobicents.restcomm.android.client.sdk.RCPresenceEvent;
import org.restcomm.android.sdk.RCClient;
import org.restcomm.android.sdk.RCConnection;
import org.restcomm.android.sdk.RCConnectionListener;
import org.restcomm.android.sdk.RCDevice;
import org.restcomm.android.sdk.RCDeviceListener;
import org.restcomm.android.sdk.RCPresenceEvent;
import org.webrtc.VideoTrack;

import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.IBinder;

public class MainActivity extends FragmentActivity implements RCDeviceListener, RCConnectionListener, OnClickListener {
public class MainActivity extends FragmentActivity implements RCDeviceListener, RCConnectionListener, OnClickListener,
ServiceConnection {

private RCDevice device;
boolean serviceBound = false;

private RCConnection connection, pendingConnection;
private HashMap<String, Object> params;
private static final String TAG = "MainActivity";
Expand Down Expand Up @@ -134,6 +141,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (prefDial != null)
editDial.setText(prefDial);

/*
RCClient.setLogLevel(Log.VERBOSE);
RCClient.initialize(getApplicationContext(), new RCClient.RCInitListener() {
public void onInitialized() {
Expand Down Expand Up @@ -196,15 +204,120 @@ public void run() {
}
}
});
*/
}

@Override
protected void onStart()
{
super.onStart();
// The activity is about to become visible.
Log.i(TAG, "%% onStart");

bindService(new Intent(this, RCDevice.class), this, Context.BIND_AUTO_CREATE);
}

@Override
protected void onStop()
{
super.onStop();
// The activity is no longer visible (it is now "stopped")
Log.i(TAG, "%% onStop");

// Unbind from the service
if (serviceBound) {
//device.detach();
unbindService(this);
serviceBound = false;
}
}

@Override
protected void onDestroy() {
super.onDestroy();
// The activity is about to be destroyed.
Log.i(TAG, "%% onDestroy");
device.release();
/*
RCClient.shutdown();
device = null;
*/
}

// Callbacks for service binding, passed to bindService()
@Override
public void onServiceConnected(ComponentName className, IBinder service)
{
Log.i(TAG, "%% onServiceConnected");
// We've bound to LocalService, cast the IBinder and get LocalService instance
RCDevice.RCDeviceBinder binder = (RCDevice.RCDeviceBinder) service;
device = binder.getService();

Intent intent = new Intent(getApplicationContext(), MainActivity.class);

HashMap<String, Object> params = new HashMap<String, Object>();
// we don't have a separate activity for the calls and messages, so let's use the same intent both for calls and messages
params.put(RCDevice.ParameterKeys.INTENT_INCOMING_CALL, intent);
params.put(RCDevice.ParameterKeys.INTENT_INCOMING_MESSAGE, intent);

params.put(RCDevice.ParameterKeys.SIGNALING_DOMAIN, "sip:" + editServer.getText().toString() + ":5060"); // :5080
params.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, editUser.getText().toString());
params.put(RCDevice.ParameterKeys.SIGNALING_PASSWORD, editPwd.getText().toString());
params.put(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED, true);
params.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "https://service.xirsys.com/ice");
params.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "atsakiridis");
params.put(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, "4e89a09e-bf6f-11e5-a15c-69ffdcc2b8a7");

if (!device.isInitialized()) {
device.initialize(getApplicationContext(), params, this);
device.setLogLevel(Log.VERBOSE);
}


// Make sure Qos server is started
QosAPI.start(this, true);
// make sure user is registered with the QoS server
String login = editUser.getText().toString() + "@" + editServer.getText().toString();
QosAPI.setLogin(this, login);
// Check Firebase invites before proceeding from SplashScreen
FirebaseInvite firebaseInvite = new FirebaseInvite(this);
firebaseInvite.setOnResponseListener(new FirebaseInvite.OnResponseListener() {
@Override
public void onResponse(final FirebaseInvite invite) {
// By the time the Splash screen delay is done, we should have the invitation result
if (invite.invited) {
LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "OnResponseListener", "Firebase Invite: " + invite.url);
if (invite.url.indexOf ("simpleshare") > 0) {
Uri uri = Uri.parse (invite.url);
String evtid = uri.getQueryParameter("id");
final long iEventID = Long.parseLong(evtid);
String evttype= uri.getQueryParameter("type");
int iEventType = Integer.parseInt(evttype);

Handler invitehandler = new Handler ();
invitehandler.postDelayed(new Runnable () {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this, EventDetailWeb.class);
intent.putExtra("url", invite.deepLink);
intent.putExtra("eventId", 0);
startActivity(intent);
}
}, 2000);

}
}
}
});

serviceBound = true;
}

@Override
public void onServiceDisconnected(ComponentName arg0)
{
Log.i(TAG, "%% onServiceDisconnected");
serviceBound = false;
}

// private void videoContextReady()
Expand Down
31 changes: 20 additions & 11 deletions examples/Restcomm_demo/app/src/main/res/layout/activity_main.xml
Expand Up @@ -5,18 +5,27 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">

<org.webrtc.SurfaceViewRenderer
android:id="@+id/remote_video_view"
<org.restcomm.android.sdk.util.PercentFrameLayout
android:id="@+id/remote_video_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<org.webrtc.SurfaceViewRenderer
android:id="@+id/local_video_view"
android:layout_width="100dp"
android:layout_height="180dp"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp" />
android:layout_height="match_parent">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/remote_video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
</org.restcomm.android.sdk.util.PercentFrameLayout>

<org.restcomm.android.sdk.util.PercentFrameLayout
android:id="@+id/local_video_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/local_video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</org.restcomm.android.sdk.util.PercentFrameLayout>

<TextView android:id="@+id/textDial"
android:layout_width="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Expand Up @@ -3,6 +3,6 @@ include ':app'
project(':app').projectDir = new File('examples/Restcomm_demo/app')
// TODO: To set up the project to use actual Restcomm SDK module code, please edit actual path to sdk, and update app build.gradle dependencies
// It needs to be a modified SDK which can send Intents to the QoS library, from this Fork: https://github.com/bscheurman/restcomm-android-sdk
include ':restcomm.android.client.sdk'
project(':restcomm.android.client.sdk').projectDir = new File(settingsDir, '../restcomm-android-sdk/restcomm.android.client.sdk')
include ':restcomm.android.sdk'
project(':restcomm.android.sdk').projectDir = new File(settingsDir, '../../restcomm-android-sdk/restcomm.android.sdk')
// Only include uilib project if you want to include some MMC screens in the app. It requires Google APIs for Android.

0 comments on commit 2056f06

Please sign in to comment.