Transport selection (UDP, TCP, TLS);standard ports.
This commit is contained in:
parent
e72411efd6
commit
fbf51bbcbc
6 changed files with 151 additions and 18 deletions
|
@ -2,6 +2,10 @@
|
|||
<resources>
|
||||
|
||||
|
||||
<string name="pref_transport_udp_key">pref_transport_udp_key</string>
|
||||
<string name="pref_transport_tcp_key">pref_transport_tcp_key</string>
|
||||
<string name="pref_transport_tls_key">pref_transport_tls_key</string>
|
||||
<string name="pref_transport_use_standard_ports_key">pref_transport_use_standard_ports_key</string>
|
||||
|
||||
<string name="pref_echo_canceller_calibration_key">pref_echo_canceller_calibration_key</string>
|
||||
<string name="pref_prefix_key">pref_prefix_key</string>
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
|
||||
|
||||
|
||||
<string name="pref_network_title">Network</string>
|
||||
<string name="pref_transport_udp">UDP</string>
|
||||
<string name="pref_transport_tcp">TCP</string>
|
||||
<string name="pref_transport_tls">TLS</string>
|
||||
<string name="pref_transport_use_standard_ports">Don\'t use random ports</string>
|
||||
<string name="at_least_a_protocol">At least one item is required</string>
|
||||
|
||||
|
||||
<string name="first_launch_ok">Registration successful</string>
|
||||
<string name="error">Error</string>
|
||||
<string name="click_to_show_first_login_view">Start</string>
|
||||
|
|
|
@ -112,6 +112,16 @@
|
|||
|
||||
<CheckBoxPreference android:key="@string/pref_debug_key"
|
||||
android:title="@string/pref_debug" android:enabled="true"></CheckBoxPreference>
|
||||
|
||||
<PreferenceScreen android:title="@string/pref_network_title">
|
||||
<CheckBoxPreference android:key="@string/pref_transport_udp_key"
|
||||
android:title="@string/pref_transport_udp" android:defaultValue="true"/>
|
||||
<CheckBoxPreference android:key="@string/pref_transport_tcp_key"
|
||||
android:title="@string/pref_transport_tcp" />
|
||||
<CheckBoxPreference android:key="@string/pref_transport_tls_key" android:title="@string/pref_transport_tls" />
|
||||
<CheckBoxPreference android:key="@string/pref_transport_use_standard_ports_key"
|
||||
android:title="@string/pref_transport_use_standard_ports"/>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
|||
import org.linphone.core.LinphoneCore.FirewallPolicy;
|
||||
import org.linphone.core.LinphoneCore.GlobalState;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCore.Transports;
|
||||
import org.linphone.core.video.AndroidCameraRecordManager;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
|
@ -92,6 +93,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
private Resources mR;
|
||||
private LinphoneCore mLc;
|
||||
private int mPhoneOrientation;
|
||||
private static Transports initialTransports;
|
||||
|
||||
|
||||
|
||||
|
@ -363,6 +365,12 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false);
|
||||
LinphoneCoreFactory.instance().setDebugMode(lIsDebug);
|
||||
|
||||
if (initialTransports == null)
|
||||
initialTransports = mLc.getSignalingTransportPorts();
|
||||
|
||||
setSignalingTransportsFromConfiguration(initialTransports);
|
||||
|
||||
|
||||
try {
|
||||
// Configure audio codecs
|
||||
enableDisableAudioCodec("speex", 32000, R.string.pref_codec_speex32_key);
|
||||
|
@ -466,6 +474,34 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean getBool(int key, boolean defValue) {
|
||||
return mPref.getBoolean(getString(key), defValue);
|
||||
}
|
||||
|
||||
private void setSignalingTransportsFromConfiguration(Transports t) {
|
||||
Transports ports = new Transports(t);
|
||||
boolean useStandardPort = getBool(R.string.pref_transport_use_standard_ports_key, false);
|
||||
|
||||
if (!getBool(R.string.pref_transport_udp_key, false)) {
|
||||
ports.udp = 0;
|
||||
} else if (useStandardPort) {
|
||||
ports.udp = 5600;
|
||||
}
|
||||
|
||||
if (!getBool(R.string.pref_transport_tcp_key, false)) {
|
||||
ports.tcp = 0;
|
||||
} else if (useStandardPort) {
|
||||
ports.tcp = 5600;
|
||||
}
|
||||
|
||||
if (!getBool(R.string.pref_transport_tls_key, false)) {
|
||||
ports.tls = 0;
|
||||
} else if (useStandardPort) {
|
||||
ports.tls = 5600;
|
||||
}
|
||||
|
||||
mLc.setSignalingTransportPorts(ports);
|
||||
}
|
||||
|
||||
private void enableDisableAudioCodec(String codec, int rate, int key) throws LinphoneCoreException {
|
||||
PayloadType pt = mLc.findPayloadType(codec, rate);
|
||||
|
|
|
@ -15,7 +15,7 @@ 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.linphone;
|
||||
|
||||
|
@ -29,6 +29,9 @@ import static org.linphone.R.string.pref_echo_cancellation_key;
|
|||
import static org.linphone.R.string.pref_echo_canceller_calibration_key;
|
||||
import static org.linphone.R.string.pref_video_enable_key;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.LinphoneManager.EcCalibrationListener;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.Version;
|
||||
|
@ -40,6 +43,8 @@ import android.os.Handler;
|
|||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
@ -53,12 +58,18 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
|
|||
return getPreferenceManager().getSharedPreferences();
|
||||
}
|
||||
|
||||
private CheckBoxPreference findCheckbox(int key) {
|
||||
return (CheckBoxPreference) findPreference(getString(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
addTransportChecboxesListener();
|
||||
|
||||
|
||||
boolean enableIlbc=false;
|
||||
if (LinphoneService.isReady()) {
|
||||
|
@ -105,6 +116,61 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private List<CheckBoxPreference> findTransportCb() {
|
||||
return Arrays.asList(
|
||||
findCheckbox(R.string.pref_transport_udp_key),
|
||||
findCheckbox(R.string.pref_transport_tcp_key),
|
||||
findCheckbox(R.string.pref_transport_tls_key));
|
||||
}
|
||||
|
||||
private void addTransportChecboxesListener() {
|
||||
|
||||
final List<CheckBoxPreference> checkboxes = findTransportCb();
|
||||
|
||||
OnPreferenceChangeListener changedListener = new OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if ((Boolean) newValue) {
|
||||
for (CheckBoxPreference p : checkboxes) {
|
||||
if (p == preference) continue;
|
||||
p.setChecked(false);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
for (CheckBoxPreference p : checkboxes) {
|
||||
if (p == preference) continue;
|
||||
if (p.isChecked()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OnPreferenceClickListener clickListener = new OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
// Forbid no protocol selection
|
||||
|
||||
if (((CheckBoxPreference) preference).isChecked()) {
|
||||
// Trying to unckeck
|
||||
for (CheckBoxPreference p : checkboxes) {
|
||||
if (p == preference) continue;
|
||||
if (p.isChecked()) return false;
|
||||
}
|
||||
/*Toast.makeText(LinphonePreferencesActivity.this,
|
||||
getString(R.string.at_least_a_protocol),
|
||||
Toast.LENGTH_SHORT).show();*/
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
for (CheckBoxPreference c : checkboxes) {
|
||||
c.setOnPreferenceChangeListener(changedListener);
|
||||
c.setOnPreferenceClickListener(clickListener);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void startEcCalibration() {
|
||||
try {
|
||||
LinphoneManager.getInstance().startEcCalibration(this);
|
||||
|
|
|
@ -91,7 +91,8 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native void enableKeepAlive(long nativePtr,boolean enable);
|
||||
private native boolean isKeepAliveEnabled(long nativePtr);
|
||||
private native int startEchoCalibration(long nativePtr,Object data);
|
||||
|
||||
private native int getSignalingTransportPort(long nativePtr, int code);
|
||||
private native void setSignalingTransportPorts(long nativePtr, int udp, int tcp, int tls);
|
||||
|
||||
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
|
||||
mListener=listener;
|
||||
|
@ -285,10 +286,6 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public void setPlayLevel(int level) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
public void setSignalingTransport(Transport aTransport) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
public void enableSpeaker(boolean value) {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -439,7 +436,19 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public void startEchoCalibration(Object data) throws LinphoneCoreException {
|
||||
startEchoCalibration(nativePtr, data);
|
||||
}
|
||||
public Transport getSignalingTransport() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
|
||||
public Transports getSignalingTransportPorts() {
|
||||
Transports transports = new Transports();
|
||||
transports.udp = getSignalingTransportPort(nativePtr, 0);
|
||||
transports.tcp = getSignalingTransportPort(nativePtr, 1);
|
||||
transports.tls = getSignalingTransportPort(nativePtr, 3);
|
||||
// See C struct LCSipTransports in linphonecore.h
|
||||
// Code is the index in the structure
|
||||
return transports;
|
||||
}
|
||||
public void setSignalingTransportPorts(Transports transports) {
|
||||
setSignalingTransportPorts(nativePtr, transports.udp, transports.tcp, transports.tls);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue