From 6f05c2a6cebd75bddfbd9af182a485f9d6512cbd Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 30 Aug 2016 11:44:04 +0200 Subject: [PATCH 1/7] Added username/password settings for STUN/TURN server --- res/values/non_localizable_strings.xml | 2 + res/values/strings.xml | 4 +- res/xml/preferences.xml | 12 +++ src/org/linphone/LinphonePreferences.java | 109 ++++++++++++++-------- src/org/linphone/SettingsFragment.java | 32 +++++++ submodules/linphone | 2 +- 6 files changed, 119 insertions(+), 42 deletions(-) diff --git a/res/values/non_localizable_strings.xml b/res/values/non_localizable_strings.xml index c114a813e..dcbc04bec 100644 --- a/res/values/non_localizable_strings.xml +++ b/res/values/non_localizable_strings.xml @@ -206,4 +206,6 @@ pref_device_ringtone_key pref_auto_answer_key pref_android_app_settings_key + pref_turn_username_key + pref_turn_passwd_key diff --git a/res/values/strings.xml b/res/values/strings.xml index 901b491e3..7807e83fb 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -290,9 +290,11 @@ Network Use WiFi only - Stun server + STUN server Enable ICE Enable TURN + STUN / TURN username (optional) + STUN / TURN password (optional) Enable UPNP Use random ports SIP port to use diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index c225348a7..d0f262a83 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -268,6 +268,18 @@ android:title="@string/pref_turn_enable" android:key="@string/pref_turn_enable_key" android:persistent="false"/> + + + + Date: Tue, 30 Aug 2016 14:37:30 +0200 Subject: [PATCH 2/7] Updated linphone --- submodules/linphone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/linphone b/submodules/linphone index 9c3540b80..01df9f935 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 9c3540b804f90d5f1a149eb62bd5fa1df04fca58 +Subproject commit 01df9f93533bb1526a673ae7c557ae2508747a49 From 983956947e340bd2a6c83762c5060071f73543ed Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 30 Aug 2016 16:07:05 +0200 Subject: [PATCH 3/7] Fixed some issues when edition TURN/STUN credentials --- src/org/linphone/LinphonePreferences.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/org/linphone/LinphonePreferences.java b/src/org/linphone/LinphonePreferences.java index d93202d2c..d4897e5b5 100644 --- a/src/org/linphone/LinphonePreferences.java +++ b/src/org/linphone/LinphonePreferences.java @@ -1011,20 +1011,30 @@ public class LinphonePreferences { public void setTurnUsername(String username) { LinphoneNatPolicy nat = getOrCreateNatPolicy(); LinphoneAuthInfo authInfo = getLc().findAuthInfo(nat.getStunServerUsername(), null, null); + if (authInfo != null) { - authInfo.setUsername(username); + LinphoneAuthInfo cloneAuthInfo = authInfo.clone(); + getLc().removeAuthInfo(authInfo); + cloneAuthInfo.setUsername(username); + cloneAuthInfo.setUserId(username); + getLc().addAuthInfo(cloneAuthInfo); } else { authInfo = LinphoneCoreFactory.instance().createAuthInfo(username, username, null, null, null, null); getLc().addAuthInfo(authInfo); } nat.setStunServerUsername(username); + getLc().setNatPolicy(nat); } public void setTurnPassword(String password) { LinphoneNatPolicy nat = getOrCreateNatPolicy(); LinphoneAuthInfo authInfo = getLc().findAuthInfo(nat.getStunServerUsername(), null, null); + if (authInfo != null) { - authInfo.setPassword(password); + LinphoneAuthInfo cloneAuthInfo = authInfo.clone(); + getLc().removeAuthInfo(authInfo); + cloneAuthInfo.setPassword(password); + getLc().addAuthInfo(cloneAuthInfo); } else { authInfo = LinphoneCoreFactory.instance().createAuthInfo(nat.getStunServerUsername(), nat.getStunServerUsername(), password, null, null, null); getLc().addAuthInfo(authInfo); From 2171962b78ac01e12f01be37cf3c789f0af70303 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 31 Aug 2016 14:02:29 +0200 Subject: [PATCH 4/7] Updated cmake builder --- submodules/cmake-builder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/cmake-builder b/submodules/cmake-builder index f4eac4803..a6d9ea7b2 160000 --- a/submodules/cmake-builder +++ b/submodules/cmake-builder @@ -1 +1 @@ -Subproject commit f4eac4803eee43de3efa96ecca9450ba4f2bc7dc +Subproject commit a6d9ea7b211c53b1d4800497644a56f4674e5924 From 8036675e28643a2d1b060814048942f016bf326a Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 31 Aug 2016 16:27:39 +0200 Subject: [PATCH 5/7] Adding type of stream to RequestAudioFocus --- src/org/linphone/LinphoneManager.java | 36 +++++++++++++-------------- submodules/linphone | 2 +- submodules/msopenh264 | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index e025c5505..4b7d463be 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -66,6 +66,7 @@ import org.linphone.core.PublishState; import org.linphone.core.SubscriptionState; import org.linphone.core.TunnelConfig; import org.linphone.mediastream.Log; +import org.linphone.mediastream.MediastreamerAndroidContext; import org.linphone.mediastream.Version; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera; @@ -139,6 +140,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag private static List mPendingChatFileMessage; private static LinphoneChatMessage mUploadPendingFileMessage; + public String wizardLoginViewDomain = null; private static List simpleListeners = new ArrayList(); @@ -1069,6 +1071,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag else if (state == State.IncomingReceived || (state == State.CallIncomingEarlyMedia && mR.getBoolean(R.bool.allow_ringing_while_early_media))) { // Brighten screen for at least 10 seconds if (mLc.getCallsNb() == 1) { + requestAudioFocus(STREAM_RING); BluetoothManager.getInstance().disableBluetoothSCO(); // Just in case ringingCall = call; @@ -1082,8 +1085,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag if (state == State.Connected) { if (mLc.getCallsNb() == 1) { - requestAudioFocus(); - setAudioManagerInCallMode(); + mAudioManager.abandonAudioFocus(null); + requestAudioFocus(STREAM_VOICE_CALL); } if (Hacks.needSoftvolume()) { @@ -1096,15 +1099,14 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag setAudioManagerInCallMode(); } - if (state == State.CallReleased || state == State.Error) { + if (state == State.CallEnd || state == State.Error) { if (mLc.getCallsNb() == 0) { + Context activity = getContext(); if (mAudioFocused){ int res = mAudioManager.abandonAudioFocus(null); Log.d("Audio focus released a bit later: " + (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED ? "Granted" : "Denied")); mAudioFocused = false; } - - Context activity = getContext(); if (activity != null) { TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE); if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) { @@ -1116,17 +1118,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } } } - - if (state == State.CallEnd) { - if (mLc.getCallsNb() == 0) { - if (mIncallWakeLock != null && mIncallWakeLock.isHeld()) { - mIncallWakeLock.release(); - Log.i("Last call ended: releasing incall (CPU only) wake lock"); - } else { - Log.i("Last call ended: no incall (CPU only) wake lock were held"); - } - } - } if (state == State.CallUpdatedByRemote) { // If the correspondent proposes video while audio call boolean remoteVideo = call.getRemoteParams().getVideoEnabled(); @@ -1140,6 +1131,10 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } } } + if (state == State.OutgoingInit) { + setAudioManagerInCallMode(); + requestAudioFocus(STREAM_VOICE_CALL); + } if (state == State.StreamsRunning) { if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { @@ -1175,6 +1170,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag routeAudioToSpeaker(); setAudioManagerInCallMode(); Log.i("Set audio mode on 'Voice Communication'"); + requestAudioFocus(STREAM_VOICE_CALL); int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL); int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL); mAudioManager.setStreamVolume(STREAM_VOICE_CALL, maxVolume, 0); @@ -1186,6 +1182,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag routeAudioToSpeaker(); setAudioManagerInCallMode(); Log.i("Set audio mode on 'Voice Communication'"); + requestAudioFocus(STREAM_VOICE_CALL); int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL); int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL); int sampleRate = 44100; @@ -1222,9 +1219,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag private boolean isRinging; - private void requestAudioFocus(){ + private void requestAudioFocus(int stream){ if (!mAudioFocused){ - int res = mAudioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT ); + int res = mAudioManager.requestAudioFocus(null, stream, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT ); Log.d("Audio focus requested: " + (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED ? "Granted" : "Denied")); if (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) mAudioFocused=true; } @@ -1259,7 +1256,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag mVibrator.vibrate(patern, 1); } if (mRingerPlayer == null) { - requestAudioFocus(); + requestAudioFocus(STREAM_RING); mRingerPlayer = new MediaPlayer(); mRingerPlayer.setAudioStreamType(STREAM_RING); @@ -1528,6 +1525,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status, int delay_ms, Object data) { ((AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL); + mAudioManager.abandonAudioFocus(null); Log.i("Set audio mode on 'Normal'"); } diff --git a/submodules/linphone b/submodules/linphone index 01df9f935..6bc186fb2 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 01df9f93533bb1526a673ae7c557ae2508747a49 +Subproject commit 6bc186fb256f7a1ff0755d42773e55f91ca4a9b3 diff --git a/submodules/msopenh264 b/submodules/msopenh264 index 7744dc572..3fe5d85ee 160000 --- a/submodules/msopenh264 +++ b/submodules/msopenh264 @@ -1 +1 @@ -Subproject commit 7744dc572470de6caf11b7e4ce7e79ba0c5efd55 +Subproject commit 3fe5d85ee4dbed91920f3a43f129d28b3dece138 From 6ac636b5b3166b11f8611d2f9203b5ec5bf44651 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Thu, 1 Sep 2016 09:14:00 +0200 Subject: [PATCH 6/7] Update linphone --- submodules/linphone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/linphone b/submodules/linphone index 6bc186fb2..56b08128b 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 6bc186fb256f7a1ff0755d42773e55f91ca4a9b3 +Subproject commit 56b08128b41a64ae95b708ce61f1a9328016d3a4 From e39cc0112d5cbd239259923cf637123b2ffdcb35 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 1 Sep 2016 11:53:30 +0200 Subject: [PATCH 7/7] Fixed audio routes no being set correctly all the time --- src/org/linphone/CallActivity.java | 1 - src/org/linphone/CallIncomingActivity.java | 8 ++------ src/org/linphone/CallOutgoingActivity.java | 7 +------ src/org/linphone/LinphoneActivity.java | 22 ++-------------------- 4 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/org/linphone/CallActivity.java b/src/org/linphone/CallActivity.java index da94060e8..f83ec9abb 100644 --- a/src/org/linphone/CallActivity.java +++ b/src/org/linphone/CallActivity.java @@ -300,7 +300,6 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve callFragment.setArguments(getIntent().getExtras()); getFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss(); - } } diff --git a/src/org/linphone/CallIncomingActivity.java b/src/org/linphone/CallIncomingActivity.java index 74edc5de3..5e068be82 100644 --- a/src/org/linphone/CallIncomingActivity.java +++ b/src/org/linphone/CallIncomingActivity.java @@ -305,12 +305,8 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig if (!LinphoneActivity.isInstanciated()) { return; } - final LinphoneCallParams remoteParams = mCall.getRemoteParams(); - if (remoteParams != null && remoteParams.getVideoEnabled() && LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests()) { - LinphoneActivity.instance().startVideoActivity(mCall); - } else { - LinphoneActivity.instance().startIncallActivity(mCall); - } + LinphoneManager.getInstance().routeAudioToReceiver(); + LinphoneActivity.instance().startIncallActivity(mCall); } } diff --git a/src/org/linphone/CallOutgoingActivity.java b/src/org/linphone/CallOutgoingActivity.java index bec0d7a9a..2b9d1715f 100644 --- a/src/org/linphone/CallOutgoingActivity.java +++ b/src/org/linphone/CallOutgoingActivity.java @@ -101,12 +101,7 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{ if (!LinphoneActivity.isInstanciated()) { return; } - final LinphoneCallParams remoteParams = mCall.getRemoteParams(); - if (remoteParams != null && remoteParams.getVideoEnabled() && LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests()) { - LinphoneActivity.instance().startVideoActivity(mCall); - } else { - LinphoneActivity.instance().startIncallActivity(mCall); - } + LinphoneActivity.instance().startIncallActivity(mCall); finish(); return; } else if (state == State.Error) { diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index f183e3de8..0da686b64 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -943,16 +943,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta LinphoneManager.getInstance().newOutgoingCall(address); } - public void startVideoActivity(LinphoneCall currentCall) { - Intent intent = new Intent(this, CallActivity.class); - intent.putExtra("VideoEnabled", true); - startOrientationSensor(); - startActivityForResult(intent, CALL_ACTIVITY); - } - public void startIncallActivity(LinphoneCall currentCall) { Intent intent = new Intent(this, CallActivity.class); - intent.putExtra("VideoEnabled", false); startOrientationSensor(); startActivityForResult(intent, CALL_ACTIVITY); } @@ -1024,8 +1016,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; if (call.getState() == LinphoneCall.State.IncomingReceived) { startActivity(new Intent(LinphoneActivity.this, CallIncomingActivity.class)); - } else if (call.getCurrentParamsCopy().getVideoEnabled()) { - startVideoActivity(call); } else { startIncallActivity(call); } @@ -1333,11 +1323,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta } else if (callState == State.OutgoingInit || callState == State.OutgoingProgress || callState == State.OutgoingRinging) { startActivity(new Intent(this, CallOutgoingActivity.class)); } else { - if (call.getCurrentParamsCopy().getVideoEnabled()) { - startVideoActivity(call); - } else { - startIncallActivity(call); - } + startIncallActivity(call); } } } @@ -1383,11 +1369,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta } else if (extras != null && extras.getBoolean("Notification", false)) { if (LinphoneManager.getLc().getCallsNb() > 0) { LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; - if (call.getCurrentParamsCopy().getVideoEnabled()) { - startVideoActivity(call); - } else { - startIncallActivity(call); - } + startIncallActivity(call); } } else { DialerFragment dialerFragment = DialerFragment.instance();