diff options
Diffstat (limited to 'pjsip-apps/src/pjsua/android/app/src/main')
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/AndroidManifest.xml | 47 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/java/org/pjsip/pjsua/MainActivity.java | 277 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/drawable-hdpi/main_image.png | bin | 0 -> 8269 bytes | |||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/drawable-ldpi/main_image.png | bin | 0 -> 3863 bytes | |||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/drawable-mdpi/main_image.png | bin | 0 -> 5059 bytes | |||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/drawable-xhdpi/main_image.png | bin | 0 -> 12058 bytes | |||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/layout/activity_main.xml | 46 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/values-v11/styles.xml | 5 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/values-v14/styles.xml | 5 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/values/strings.xml | 6 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/android/app/src/main/res/values/styles.xml | 5 |
11 files changed, 391 insertions, 0 deletions
diff --git a/pjsip-apps/src/pjsua/android/app/src/main/AndroidManifest.xml b/pjsip-apps/src/pjsua/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..97da16d3 --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,47 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.pjsip.pjsua" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk + android:minSdkVersion="15" + android:targetSdkVersion="15" /> + + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.RECORD_AUDIO" /> + <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> + <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> + <uses-permission android:name="android.permission.WRITE_SETTINGS" /> + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.WAKE_LOCK" /> + <uses-permission android:name="android.permission.VIBRATE" /> + <uses-permission android:name="android.permission.READ_LOGS" /> + <uses-permission android:name="android.permission.USE_SIP" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.CAMERA" /> + + <uses-feature android:glEsVersion="0x00020000" android:required="false" /> + + <uses-feature + android:name="android.hardware.microphone" + android:required="true" /> + + <application + android:icon="@drawable/main_image" + android:label="@string/app_name" + android:theme="@android:style/Theme.DeviceDefault.NoActionBar" > + <activity + android:name=".MainActivity" + android:windowSoftInputMode="stateHidden" + android:label="@string/app_name" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest>
\ No newline at end of file diff --git a/pjsip-apps/src/pjsua/android/app/src/main/java/org/pjsip/pjsua/MainActivity.java b/pjsip-apps/src/pjsua/android/app/src/main/java/org/pjsip/pjsua/MainActivity.java new file mode 100644 index 00000000..927a70b6 --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/java/org/pjsip/pjsua/MainActivity.java @@ -0,0 +1,277 @@ +/* $Id: MainActivity.java $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package org.pjsip.pjsua; + +import java.lang.ref.WeakReference; + +import android.app.Activity; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; +import android.util.Log; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.os.Handler; +import android.os.Message; +import android.widget.TextView; + +class CONST { + public static final String LIB_FILENAME = "pjsua"; + public static final String TAG = "pjsua"; + public static final Boolean AUTOKILL_ON_FINISH = true; + public enum MSG_TYPE { + STR_DEBUG, + STR_INFO, + STR_ERROR, + CLI_STOP, + CLI_RESTART, + QUIT + }; +} + +class LOG { + public static void DEBUG(Handler h, String str) { + Message msg = Message.obtain(h, CONST.MSG_TYPE.STR_DEBUG.ordinal(), + str); + msg.sendToTarget(); + } + public static void INFO(Handler h, String str) { + Message msg = Message.obtain(h, CONST.MSG_TYPE.STR_INFO.ordinal(), + str); + msg.sendToTarget(); + } + public static void ERROR(Handler h, String str) { + Message msg = Message.obtain(h, CONST.MSG_TYPE.STR_ERROR.ordinal(), + str); + msg.sendToTarget(); + } +} + +public class MainActivity extends Activity implements SurfaceHolder.Callback { + private MyHandler ui_handler = new MyHandler(this); + private static MyCallback callback; + + private static class MyHandler extends Handler { + private final WeakReference<MainActivity> mTarget; + + public MyHandler(MainActivity target) { + mTarget = new WeakReference<MainActivity>(target); + } + + @Override + public void handleMessage(Message m) { + MainActivity target = mTarget.get(); + if (target == null) + return; + + if (m.what == CONST.MSG_TYPE.STR_DEBUG.ordinal()) { + Log.d(CONST.TAG, (String)m.obj); + } else if (m.what == CONST.MSG_TYPE.STR_INFO.ordinal()) { + target.updateStatus((String)m.obj); + Log.i(CONST.TAG, (String)m.obj); + } else if (m.what == CONST.MSG_TYPE.STR_ERROR.ordinal()) { + target.updateStatus((String)m.obj); + Log.e(CONST.TAG, (String)m.obj); + } else if (m.what == CONST.MSG_TYPE.CLI_STOP.ordinal()) { + pjsua.pjsuaDestroy(); + LOG.INFO(this, "Telnet Unavailable"); + } else if (m.what == CONST.MSG_TYPE.CLI_RESTART.ordinal()) { + int status = pjsua.pjsuaRestart(); + if (status != 0) { + LOG.INFO(this, "Failed restarting telnet"); + } + } else if (m.what == CONST.MSG_TYPE.QUIT.ordinal()) { + target.finish(); + System.gc(); + android.os.Process.killProcess(android.os.Process.myPid()); + } + } + } + + /** Callback object **/ + private static class MyCallback extends PjsuaAppCallback { + private WeakReference<Handler> ui_handler; + + public MyCallback(Handler in_ui_handler) { + set_ui_handler(in_ui_handler); + } + + public void set_ui_handler(Handler in_ui_handler) { + ui_handler = new WeakReference<Handler>(in_ui_handler); + } + + @Override + public void onStarted(String msg) { + Handler ui = ui_handler.get(); + LOG.INFO(ui, msg); + } + + @Override + public void onStopped(int restart) { + Handler ui = ui_handler.get(); + /** Use timer to stopped/restart **/ + if (restart != 0) { + LOG.INFO(ui, "Telnet Restarting"); + Message msg = Message.obtain(ui, + CONST.MSG_TYPE.CLI_RESTART.ordinal()); + ui.sendMessageDelayed(msg, 100); + } else { + LOG.INFO(ui, "Telnet Stopping"); + Message msg = Message.obtain(ui, + CONST.MSG_TYPE.CLI_STOP.ordinal()); + ui.sendMessageDelayed(msg, 100); + } + } + } + + private void updateStatus(String output) { + TextView tStatus = (TextView) findViewById(R.id.textStatus); + tStatus.setText(output); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + LOG.DEBUG(ui_handler, "=== Activity::onCreate() ==="); + super.onCreate(savedInstanceState); + + init_view(); + + init_lib(); + } + + @Override + protected void onStart() { + LOG.DEBUG(ui_handler, "=== Activity::onStart() ==="); + super.onStart(); + } + + @Override + protected void onRestart() { + LOG.DEBUG(ui_handler, "=== Activity::onRestart() ==="); + super.onRestart(); + } + + @Override + protected void onResume() { + LOG.DEBUG(ui_handler, "=== Activity::onResume() ==="); + super.onResume(); + } + + @Override + protected void onPause() { + LOG.DEBUG(ui_handler, "=== Activity::onPause() ==="); + super.onPause(); + } + + @Override + protected void onStop() { + LOG.DEBUG(ui_handler, "=== Activity::onStop() ==="); + super.onStop(); + } + + @Override + protected void onDestroy() { + LOG.DEBUG(ui_handler, "=== Activity::onDestroy() ==="); + super.onDestroy(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + } + + private void init_view() { + setContentView(R.layout.activity_main); + } + + private int init_lib() { + LOG.INFO(ui_handler, "Loading module..."); + + // Try loading video dependency libs + try { + System.loadLibrary("openh264"); + System.loadLibrary("yuv"); + } catch (UnsatisfiedLinkError e) { + LOG.ERROR(ui_handler, "UnsatisfiedLinkError: " + e.getMessage()); + LOG.ERROR(ui_handler, "This could be safely ignored if you "+ + "don't need video."); + } + + // Load pjsua + try { + System.loadLibrary(CONST.LIB_FILENAME); + } catch (UnsatisfiedLinkError e) { + LOG.ERROR(ui_handler, "UnsatisfiedLinkError: " + e.getMessage()); + return -1; + } + + // Wait for GDB to init, for native debugging only + if (false && (getApplicationInfo().flags & + ApplicationInfo.FLAG_DEBUGGABLE) != 0) + { + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + LOG.ERROR(ui_handler, "InterruptedException: " + + e.getMessage()); + } + } + + // Set callback object + if (callback == null) + callback = new MyCallback(ui_handler); + + pjsua.setCallbackObject(callback); + + SurfaceView surfaceView = (SurfaceView) + findViewById(R.id.surfaceViewIncomingCall); + surfaceView.getHolder().addCallback(this); + + LOG.INFO(ui_handler, "Starting module.."); + + int rc = pjsua.pjsuaStart(); + + if (rc != 0) { + LOG.INFO(ui_handler, "Failed starting telnet"); + } + + return 0; + } + + public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) + { + pjsua.setIncomingVideoRenderer(holder.getSurface()); + } + + public void surfaceCreated(SurfaceHolder holder) + { + pjsua.setIncomingVideoRenderer(holder.getSurface()); + } + + public void surfaceDestroyed(SurfaceHolder holder) + { + pjsua.setIncomingVideoRenderer(null); + } + +} diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-hdpi/main_image.png b/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-hdpi/main_image.png Binary files differnew file mode 100644 index 00000000..a9c5328c --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-hdpi/main_image.png diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-ldpi/main_image.png b/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-ldpi/main_image.png Binary files differnew file mode 100644 index 00000000..969971f8 --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-ldpi/main_image.png diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-mdpi/main_image.png b/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-mdpi/main_image.png Binary files differnew file mode 100644 index 00000000..8312fcf2 --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-mdpi/main_image.png diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-xhdpi/main_image.png b/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-xhdpi/main_image.png Binary files differnew file mode 100644 index 00000000..9978b0af --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/drawable-xhdpi/main_image.png diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/layout/activity_main.xml b/pjsip-apps/src/pjsua/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..24a13372 --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/textStatus" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentTop="false" + android:layout_centerHorizontal="true" + android:textIsSelectable="false" /> + + <SurfaceView + android:id="@+id/surfaceViewIncomingCall" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_above="@+id/imageApp" + android:layout_alignParentLeft="true" + android:layout_alignParentRight="true" + android:layout_alignParentTop="true" + android:layout_marginBottom="50dp" /> + + <TextView + android:id="@+id/textApp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_above="@+id/textStatus" + android:layout_centerHorizontal="true" + android:layout_marginBottom="126dp" + android:text="@string/app_name" + android:textSize="40sp" + android:typeface="serif" /> + + <ImageView + android:id="@+id/imageApp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_above="@+id/textApp" + android:layout_centerHorizontal="true" + android:contentDescription="@string/app_name" + android:src="@drawable/main_image" /> + +</RelativeLayout>
\ No newline at end of file diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/values-v11/styles.xml b/pjsip-apps/src/pjsua/android/app/src/main/res/values-v11/styles.xml new file mode 100644 index 00000000..d408cbc3 --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/values-v11/styles.xml @@ -0,0 +1,5 @@ +<resources> + + <style name="AppTheme" parent="android:Theme.Holo.Light" /> + +</resources>
\ No newline at end of file diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/values-v14/styles.xml b/pjsip-apps/src/pjsua/android/app/src/main/res/values-v14/styles.xml new file mode 100644 index 00000000..1c089a78 --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/values-v14/styles.xml @@ -0,0 +1,5 @@ +<resources> + + <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" /> + +</resources>
\ No newline at end of file diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/values/strings.xml b/pjsip-apps/src/pjsua/android/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..dd5ee690 --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/values/strings.xml @@ -0,0 +1,6 @@ +<resources> + + <string name="app_name">pjsua</string> + <string name="title_activity_main">MainActivity</string> + +</resources>
\ No newline at end of file diff --git a/pjsip-apps/src/pjsua/android/app/src/main/res/values/styles.xml b/pjsip-apps/src/pjsua/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..4dba0d0a --- /dev/null +++ b/pjsip-apps/src/pjsua/android/app/src/main/res/values/styles.xml @@ -0,0 +1,5 @@ +<resources> + + <style name="AppTheme" parent="android:Theme.Light" /> + +</resources>
\ No newline at end of file |