Merge branch 'video' of git.linphone.org:linphone-android-private into video

Conflicts:
	src/org/linphone/core/LinphoneCoreImpl.java
This commit is contained in:
Guillaume Beraudo 2010-11-26 15:11:17 +01:00
commit cb9ac80f39
12 changed files with 90 additions and 24 deletions

View file

@ -113,6 +113,7 @@
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-permission android:name="android.permission.BOOT_COMPLETED"></uses-permission> <uses-permission android:name="android.permission.BOOT_COMPLETED"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera" />

Binary file not shown.

Binary file not shown.

View file

@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package org.linphone; package org.linphone;
import java.io.IOException;
import org.linphone.component.ToggleImageButton; import org.linphone.component.ToggleImageButton;
import org.linphone.component.ToggleImageButton.OnCheckedChangeListener; import org.linphone.component.ToggleImageButton.OnCheckedChangeListener;
import org.linphone.core.AndroidCameraRecord; import org.linphone.core.AndroidCameraRecord;
@ -39,10 +41,15 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.Html; import android.text.Html;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -101,6 +108,11 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
private static String CURRENT_ADDRESS = "org.linphone.current-address"; private static String CURRENT_ADDRESS = "org.linphone.current-address";
private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname"; private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
static int VIDEO_VIEW_ACTIVITY = 100; static int VIDEO_VIEW_ACTIVITY = 100;
Settings.System mSystemSettings = new Settings.System();
MediaPlayer mRingerPlayer;
LinphoneCall.State mCurrentCallState;
Vibrator mVibrator;
/** /**
* *
* @return null if not ready yet * @return null if not ready yet
@ -122,6 +134,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
setContentView(R.layout.dialer); setContentView(R.layout.dialer);
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE)); mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone"); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone");
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
@ -227,6 +240,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
if (LinphoneService.isready()) { if (LinphoneService.isready()) {
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
if (lLinphoneCore.isIncall()) { if (lLinphoneCore.isIncall()) {
mCurrentCallState = lLinphoneCore.getCurrentCall().getState();
if(lLinphoneCore.isInComingInvitePending()) { if(lLinphoneCore.isInComingInvitePending()) {
callPending(); callPending();
} else { } else {
@ -352,6 +366,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onDestroy(); super.onDestroy();
if (mWakeLock.isHeld()) mWakeLock.release(); if (mWakeLock.isHeld()) mWakeLock.release();
theDialer=null;
} }
@Override @Override
protected void onResume() { protected void onResume() {
@ -428,6 +443,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final LinphoneCore.RegistrationState state,final String smessage) {/*nop*/}; public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final LinphoneCore.RegistrationState state,final String smessage) {/*nop*/};
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) { public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
if (mCurrentCallState == LinphoneCall.State.IncomingReceived) {
//previous state was ringing, so stop ringing
stoptRinging();
}
if (state == LinphoneCall.State.OutgoingInit) { if (state == LinphoneCall.State.OutgoingInit) {
mWakeLock.acquire(); mWakeLock.acquire();
enterIncalMode(lc); enterIncalMode(lc);
@ -455,6 +474,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
finishActivity(VIDEO_VIEW_ACTIVITY); finishActivity(VIDEO_VIEW_ACTIVITY);
} }
} }
mCurrentCallState = state;
} }
public void show(LinphoneCore lc) { public void show(LinphoneCore lc) {
@ -530,6 +550,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
boolean prefVideoEnable = mPref.getBoolean(getString(R.string.pref_video_enable_key), false); boolean prefVideoEnable = mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
boolean prefAutomaticallyShareMyCamera = mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false); boolean prefAutomaticallyShareMyCamera = mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false);
AndroidCameraRecord.setMuteCamera(!(prefVideoEnable && prefAutomaticallyShareMyCamera)); AndroidCameraRecord.setMuteCamera(!(prefVideoEnable && prefAutomaticallyShareMyCamera));
startRinging();
} }
public void newOutgoingCall(String aTo) { public void newOutgoingCall(String aTo) {
newOutgoingCall(aTo,null); newOutgoingCall(aTo,null);
@ -645,5 +666,39 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
private synchronized void startRinging() {
try {
if (mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER) && mVibrator !=null) {
long[] patern = {0,1000,1000};
mVibrator.vibrate(patern, 1);
}
if (mRingerPlayer == null) {
//mRingerPlayer = MediaPlayer.create(getApplicationContext(), RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
mRingerPlayer = new MediaPlayer();
mRingerPlayer.setAudioStreamType(AudioManager.STREAM_RING);
mRingerPlayer.setDataSource(getApplicationContext(), RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
mRingerPlayer.prepare();
//mRingerPlayer.setVolume(mAudioManager.getStreamVolume(AudioManager.STREAM_RING),mAudioManager.getStreamVolume(AudioManager.STREAM_RING));
mRingerPlayer.setLooping(true);
mRingerPlayer.start();
} else {
Log.w(LinphoneService.TAG,"already ringing");
}
} catch (Exception e) {
Log.e(LinphoneService.TAG, "cannot handle incoming call",e);
}
}
private synchronized void stoptRinging() {
if (mRingerPlayer !=null) {
mRingerPlayer.stop();
mRingerPlayer.release();
mRingerPlayer=null;
}
if (mVibrator!=null) {
mVibrator.cancel();
}
}
} }

View file

@ -49,11 +49,13 @@ import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log; import android.util.Log;
public class LinphoneService extends Service implements LinphoneCoreListener { public class LinphoneService extends Service implements LinphoneCoreListener {
@ -80,6 +82,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
final int IC_LEVEL_GREEN=1; final int IC_LEVEL_GREEN=1;
final int IC_LEVEL_RED=2; final int IC_LEVEL_RED=2;
private Handler mHandler = new Handler() ; private Handler mHandler = new Handler() ;
static boolean isready() { static boolean isready() {
return (theLinphone!=null); return (theLinphone!=null);
@ -117,6 +120,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
, null); , null);
mLinphoneCore.setPlaybackGain(3); mLinphoneCore.setPlaybackGain(3);
mLinphoneCore.setRing(null);
try { try {
initFromConf(); initFromConf();
@ -237,22 +241,19 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
, mNofificationContentIntent); , mNofificationContentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mNotification); mNotificationManager.notify(NOTIFICATION_ID, mNotification);
} }
if (DialerActivity.getDialer()!=null) { mHandler.post(new Runnable() {
mHandler.post(new Runnable() { public void run() {
public void run() { if (DialerActivity.getDialer()!=null) DialerActivity.getDialer().registrationState(lc,cfg,state,smessage);
DialerActivity.getDialer().registrationState(lc,cfg,state,smessage); }
} });
});
}
} }
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) { public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
if (DialerActivity.getDialer()!=null) { Log.i(TAG, "new state ["+state+"]");
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
DialerActivity.getDialer().callState(lc,call,state,message); if (DialerActivity.getDialer()!=null) DialerActivity.getDialer().callState(lc,call,state,message);
} }
}); });
}
if (state == LinphoneCall.State.IncomingReceived) { if (state == LinphoneCall.State.IncomingReceived) {
//wakeup linphone //wakeup linphone
Intent lIntent = new Intent(); Intent lIntent = new Intent();
@ -347,6 +348,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
//proxy //proxy
mLinphoneCore.clearProxyConfigs();
String lProxy = mPref.getString(getString(R.string.pref_proxy_key),null); String lProxy = mPref.getString(getString(R.string.pref_proxy_key),null);
if (lProxy == null || lProxy.length() == 0) { if (lProxy == null || lProxy.length() == 0) {
lProxy = "sip:"+lDomain; lProxy = "sip:"+lDomain;
@ -432,5 +434,6 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
} }
} }

View file

@ -86,6 +86,9 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void setPreferredVideoSize(long nativePtr, int width, int heigth); private native void setPreferredVideoSize(long nativePtr, int width, int heigth);
private native int[] getPreferredVideoSize(long nativePtr); private native int[] getPreferredVideoSize(long nativePtr);
private native void setRing(long nativePtr, String path);
private native String getRing(long nativePtr);
private static String TAG = "LinphoneCore"; private static String TAG = "LinphoneCore";
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
@ -382,6 +385,7 @@ class LinphoneCoreImpl implements LinphoneCore {
return updateCall(nativePtr, ptrCall, ptrParams); return updateCall(nativePtr, ptrCall, ptrParams);
} }
<<<<<<< HEAD
public void setUploadBandwidth(int bw) { public void setUploadBandwidth(int bw) {
@ -404,5 +408,12 @@ class LinphoneCoreImpl implements LinphoneCore {
vSize.setHeight(nativeSize[1]); vSize.setHeight(nativeSize[1]);
return vSize; return vSize;
=======
public void setRing(String path) {
setRing(nativePtr, path);
}
public String getRing() {
return getRing(nativePtr);
>>>>>>> c95431295dc09c5558d38c6de49fa071c957d926
} }
} }

View file

@ -18,9 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package org.linphone.core; package org.linphone.core;
import org.linphone.LinphoneService;
import android.util.Log;
@ -35,7 +32,6 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
setProxy(proxy); setProxy(proxy);
enableRegister(enableRegister); enableRegister(enableRegister);
ownPtr=true; ownPtr=true;
Log.w(LinphoneService.TAG, "route ["+route+"] not used yet");
} }
protected LinphoneProxyConfigImpl(long aNativePtr) { protected LinphoneProxyConfigImpl(long aNativePtr) {
nativePtr = aNativePtr; nativePtr = aNativePtr;

View file

@ -36,7 +36,7 @@ import android.widget.TextView;
*/ */
public class TutorialBuddyStatusActivity extends Activity { public class TutorialBuddyStatusActivity extends Activity {
private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; private static final String defaultSipAddress = "sip:";
private TextView sipAddressWidget; private TextView sipAddressWidget;
private TutorialBuddyStatus tutorial; private TutorialBuddyStatus tutorial;
private Handler mHandler = new Handler() ; private Handler mHandler = new Handler() ;

View file

@ -36,7 +36,7 @@ import android.widget.TextView;
*/ */
public class TutorialChatRoomActivity extends Activity { public class TutorialChatRoomActivity extends Activity {
private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; private static final String defaultSipAddress = "sip:";
private TextView sipAddressWidget; private TextView sipAddressWidget;
private TutorialChatRoom tutorial; private TutorialChatRoom tutorial;
private Handler mHandler = new Handler() ; private Handler mHandler = new Handler() ;

View file

@ -36,7 +36,7 @@ import android.widget.TextView;
*/ */
public class TutorialHelloWorldActivity extends Activity { public class TutorialHelloWorldActivity extends Activity {
private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; private static final String defaultSipAddress = "sip:";
private TextView sipAddressWidget; private TextView sipAddressWidget;
private TutorialHelloWorld tutorial; private TutorialHelloWorld tutorial;
private Handler mHandler = new Handler() ; private Handler mHandler = new Handler() ;

View file

@ -35,8 +35,8 @@ import android.widget.TextView;
*/ */
public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { public class TutorialRegistrationActivity extends TutorialHelloWorldActivity {
private static final String defaultSipAddress = "sip:8182449901ip@mty11.axtel.net"; private static final String defaultSipAddress = "sip:";
private static final String defaultSipPassword = "49901"; private static final String defaultSipPassword = "";
private TextView sipAddressWidget; private TextView sipAddressWidget;
private TextView sipPasswordWidget; private TextView sipPasswordWidget;
private TutorialRegistration tutorial; private TutorialRegistration tutorial;

@ -1 +1 @@
Subproject commit 801508597b36e02e6d726851332a202529dc9025 Subproject commit a9db49b15aee38098d23086fd574adb99a1afda3