media encryption API enhancements
add preference for media encryption selection.
This commit is contained in:
parent
983e36fabc
commit
5041b71568
14 changed files with 119 additions and 42 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
#default values
|
||||
BUILD_AMR=light
|
||||
BUILD_SRTP=1
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
BUILD_X264=1
|
||||
LINPHONE_VIDEO=1
|
||||
|
@ -14,7 +16,7 @@ endif
|
|||
|
||||
##ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
ifeq ($(BUILD_GPLV3_ZRTP), 1)
|
||||
BUILD_SRTP=1
|
||||
BUILD_SRTP=1
|
||||
ZRTP_C_INCLUDE= \
|
||||
$(linphone-root-dir)/submodules/externals/libzrtpcpp/src
|
||||
endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
APP_PROJECT_PATH := $(call my-dir)/../
|
||||
APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 liblinphone
|
||||
APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 liblinphone
|
||||
APP_STL := stlport_static
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
<string name="pref_codecs_key">pref_codecs_key</string>
|
||||
<string name="pref_stun_server_key">pref_stun_server_key</string>
|
||||
<string name="pref_video_codec_vp8_key">pref_video_codec_vp8_key</string>
|
||||
|
||||
|
||||
<string name="pref_media_encryption_key">pref_media_encryption_key</string>
|
||||
<string name="pref_media_encryption_key_none">none</string>
|
||||
<string name="pref_media_encryption_key_srtp">srtp</string>
|
||||
<string name="pref_media_encryption_key_zrtp">zrtp</string>
|
||||
</resources>
|
||||
|
|
|
@ -200,4 +200,8 @@
|
|||
|
||||
<string name="pref_amr_summary">AMR codec might not be present on your phone</string>
|
||||
<string name="pref_video_codec_vp8_title">VP8</string>
|
||||
<string name="pref_media_encryption">Media encryption</string>
|
||||
<string name="media_encryption_none">None</string>
|
||||
<string name="media_encryption_srtp">SRTP</string>
|
||||
<string name="media_encryption_zrtp">ZRTP</string>
|
||||
</resources>
|
||||
|
|
|
@ -146,6 +146,9 @@
|
|||
<CheckBoxPreference android:key="@string/pref_transport_use_standard_ports_key"
|
||||
android:title="@string/pref_transport_use_standard_ports"/>
|
||||
</PreferenceScreen>
|
||||
<ListPreference android:title="@string/pref_media_encryption"
|
||||
android:key="@string/pref_media_encryption_key"
|
||||
android:defaultValue="@string/pref_media_encryption_key_none" />
|
||||
|
||||
<PreferenceScreen android:title="@string/pref_audio_hacks_title"
|
||||
android:layout="@layout/hidden">
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.linphone.core.LinphoneCore;
|
|||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.Log;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.ui.Numpad;
|
||||
|
||||
|
@ -661,17 +662,21 @@ public class IncallActivity extends ListActivity implements
|
|||
removeFromConfButton.setOnClickListener(l);
|
||||
addVideoButton.setOnClickListener(l);
|
||||
|
||||
String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
|
||||
if ("none".equals(mediaEncryption)) {
|
||||
boolean showUnencrypted = Version.hasZrtp();
|
||||
MediaEncryption supposedMediaEncryption=LinphoneManager.getLc().getMediaEncryption();
|
||||
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
|
||||
if (mediaEncryption==MediaEncryption.None) {
|
||||
setVisibility(v, R.id.callee_status_secured, false);
|
||||
setVisibility(v, R.id.callee_status_maybe_secured, false);
|
||||
setVisibility(v, R.id.callee_status_not_secured, showUnencrypted);
|
||||
} else {
|
||||
boolean reallySecured = !Version.hasZrtp() || call.isAuthenticationTokenVerified();
|
||||
setVisibility(v, R.id.callee_status_not_secured, supposedMediaEncryption!=MediaEncryption.None);
|
||||
} else if (mediaEncryption==MediaEncryption.ZRTP){
|
||||
boolean reallySecured = call.isAuthenticationTokenVerified();
|
||||
setVisibility(v, R.id.callee_status_secured, reallySecured);
|
||||
setVisibility(v, R.id.callee_status_maybe_secured, !reallySecured);
|
||||
setVisibility(v, R.id.callee_status_not_secured, false);
|
||||
}else if (mediaEncryption==MediaEncryption.SRTP){
|
||||
setVisibility(v, R.id.callee_status_secured, true);
|
||||
setVisibility(v, R.id.callee_status_maybe_secured, false);
|
||||
setVisibility(v, R.id.callee_status_not_secured, false);
|
||||
}
|
||||
|
||||
v.setOnClickListener(new OnClickListener() {
|
||||
|
@ -690,13 +695,13 @@ public class IncallActivity extends ListActivity implements
|
|||
enableView(content, R.id.resume, l, !isInConference && showResume);
|
||||
enableView(content, R.id.terminate_call, l, true);
|
||||
|
||||
String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
|
||||
if ("none".equals(mediaEncryption)) {
|
||||
boolean showUnencrypted = Version.hasZrtp();
|
||||
setVisibility(content, R.id.unencrypted, showUnencrypted);
|
||||
} else {
|
||||
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
|
||||
MediaEncryption supposedEncryption = LinphoneManager.getLc().getMediaEncryption();
|
||||
if (mediaEncryption==MediaEncryption.None) {
|
||||
setVisibility(content, R.id.unencrypted, supposedEncryption!=MediaEncryption.None);
|
||||
} else{
|
||||
TextView token = (TextView) content.findViewById(R.id.authentication_token);
|
||||
if ("zrtp".equals(mediaEncryption)) {
|
||||
if (mediaEncryption==MediaEncryption.ZRTP) {
|
||||
boolean authVerified = call.isAuthenticationTokenVerified();
|
||||
String fmt = getString(authVerified ? R.string.reset_sas_fmt : R.string.validate_sas_fmt);
|
||||
token.setText(String.format(fmt, call.getAuthenticationToken()));
|
||||
|
|
|
@ -66,6 +66,7 @@ import org.linphone.core.LinphoneCall.State;
|
|||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCore.FirewallPolicy;
|
||||
import org.linphone.core.LinphoneCore.GlobalState;
|
||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCore.Transports;
|
||||
import org.linphone.mediastream.Version;
|
||||
|
@ -468,6 +469,18 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void initMediaEncryption(){
|
||||
String pref = mPref.getString(getString(R.string.pref_media_encryption_key),
|
||||
getString(R.string.pref_media_encryption_key_none));
|
||||
MediaEncryption me=MediaEncryption.None;
|
||||
if (pref.equals(getString(R.string.pref_media_encryption_key_srtp)))
|
||||
me=MediaEncryption.SRTP;
|
||||
else if (pref.equals(getString(R.string.pref_media_encryption_key_zrtp)))
|
||||
me=MediaEncryption.ZRTP;
|
||||
Log.i("Media encryption set to "+pref);
|
||||
mLc.setMediaEncryption(me);
|
||||
}
|
||||
|
||||
public void initFromConf(Context context) throws LinphoneConfigException {
|
||||
//traces
|
||||
|
@ -478,7 +491,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
initialTransports = mLc.getSignalingTransportPorts();
|
||||
|
||||
setSignalingTransportsFromConfiguration(initialTransports);
|
||||
|
||||
initMediaEncryption();
|
||||
|
||||
try {
|
||||
// Configure audio codecs
|
||||
|
|
|
@ -29,8 +29,10 @@ import static org.linphone.R.string.pref_echo_canceller_calibration_key;
|
|||
import static org.linphone.R.string.pref_video_enable_key;
|
||||
import static org.linphone.R.string.pref_echo_limiter_key;
|
||||
import static org.linphone.R.string.pref_echo_cancellation_key;
|
||||
import static org.linphone.R.string.pref_media_encryption_key;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -39,6 +41,7 @@ import org.linphone.core.LinphoneCore;
|
|||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.Log;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
import org.linphone.mediastream.video.capture.hwconf.Hacks;
|
||||
|
@ -47,6 +50,7 @@ import android.content.SharedPreferences;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
|
@ -58,6 +62,7 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
|
|||
private CheckBoxPreference ecCalibratePref;
|
||||
private CheckBoxPreference elPref;
|
||||
private CheckBoxPreference ecPref;
|
||||
private ListPreference mencPref;
|
||||
|
||||
private SharedPreferences prefs() {
|
||||
return getPreferenceManager().getSharedPreferences();
|
||||
|
@ -98,6 +103,7 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
|
|||
});
|
||||
ecPref = (CheckBoxPreference) findPreference(pref_echo_cancellation_key);
|
||||
elPref = (CheckBoxPreference) findPreference(pref_echo_limiter_key);
|
||||
mencPref = (ListPreference) findPreference(pref_media_encryption_key);
|
||||
|
||||
boolean fastCpu = Version.isArmv7();
|
||||
if (fastCpu) {
|
||||
|
@ -109,6 +115,35 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
|
|||
findPreference(pref_echo_limiter_key).setEnabled(true);
|
||||
}
|
||||
|
||||
LinphoneCore lc=LinphoneManager.getLc();
|
||||
boolean hasZrtp=lc.mediaEncryptionSupported(MediaEncryption.ZRTP);
|
||||
boolean hasSrtp=lc.mediaEncryptionSupported(MediaEncryption.SRTP);
|
||||
if (hasSrtp==false && hasZrtp==false){
|
||||
mencPref.setEnabled(false);
|
||||
}else{
|
||||
ArrayList<CharSequence> mencEntries=new ArrayList<CharSequence>();
|
||||
ArrayList<CharSequence> mencEntryValues=new ArrayList<CharSequence>();
|
||||
mencEntries.add(getString(R.string.media_encryption_none));
|
||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_none));
|
||||
if (hasSrtp){
|
||||
mencEntries.add(getString(R.string.media_encryption_srtp));
|
||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_srtp));
|
||||
}
|
||||
if (hasZrtp){
|
||||
mencEntries.add(getString(R.string.media_encryption_zrtp));
|
||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_zrtp));
|
||||
}
|
||||
CharSequence[] contents=new CharSequence[mencEntries.size()];
|
||||
mencEntries.toArray(contents);
|
||||
mencPref.setEntries(contents);
|
||||
contents=new CharSequence[mencEntryValues.size()];
|
||||
mencEntryValues.toArray(contents);
|
||||
mencPref.setEntryValues(contents);
|
||||
mencPref.setDefaultValue(getString(R.string.media_encryption_none));
|
||||
//mencPref.setValueIndex(mencPref.findIndexOfValue(getString(R.string.media_encryption_none)));
|
||||
}
|
||||
|
||||
|
||||
detectAudioCodec(pref_codec_amr_key,"AMR",8000, false);
|
||||
//detectAudioCodec(R.string.pref_codec_silk8_key,"SILK",8000, true);
|
||||
//detectAudioCodec(R.string.pref_codec_silk12_key,"SILK",12000, true);
|
||||
|
|
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
package org.linphone.core;
|
||||
|
||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||
|
||||
public class LinphoneCallParamsImpl implements LinphoneCallParams {
|
||||
protected final long nativePtr;
|
||||
|
||||
|
@ -28,8 +30,8 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams {
|
|||
private native void enableVideo(long nativePtr, boolean b);
|
||||
private native boolean getVideoEnabled(long nativePtr);
|
||||
private native void audioBandwidth(long nativePtr, int bw);
|
||||
private native void setMediaEncryption(long nativePtr, String menc);
|
||||
private native String getMediaEncryption(long nativePtr);
|
||||
private native void setMediaEncryption(long nativePtr, int menc);
|
||||
private native int getMediaEncryption(long nativePtr);
|
||||
private native void destroy(long nativePtr);
|
||||
|
||||
|
||||
|
@ -51,12 +53,12 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams {
|
|||
audioBandwidth(nativePtr, value);
|
||||
}
|
||||
|
||||
public String getMediaEncryption() {
|
||||
return getMediaEncryption(nativePtr);
|
||||
public MediaEncryption getMediaEncryption() {
|
||||
return MediaEncryption.fromInt(getMediaEncryption(nativePtr));
|
||||
}
|
||||
|
||||
public void setMediaEnctyption(String menc) {
|
||||
setMediaEncryption(nativePtr, menc);
|
||||
public void setMediaEnctyption(MediaEncryption menc) {
|
||||
setMediaEncryption(nativePtr, menc.mValue);
|
||||
}
|
||||
|
||||
private native boolean localConferenceMode(long nativePtr);
|
||||
|
|
|
@ -105,8 +105,8 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native void enableEchoLimiter(long nativePtr2, boolean val);
|
||||
private native int setVideoDevice(long nativePtr2, int id);
|
||||
private native int getVideoDevice(long nativePtr2);
|
||||
private native String getMediaEncryption(long nativePtr);
|
||||
private native void setMediaEncryption(long nativePtr, String menc);
|
||||
private native int getMediaEncryption(long nativePtr);
|
||||
private native void setMediaEncryption(long nativePtr, int menc);
|
||||
private native boolean isMediaEncryptionMandatory(long nativePtr);
|
||||
private native void setMediaEncryptionMandatory(long nativePtr, boolean yesno);
|
||||
|
||||
|
@ -501,9 +501,9 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
leaveConference(nativePtr);
|
||||
}
|
||||
|
||||
private native void enterConference(long nativePtr);
|
||||
public synchronized void enterConference() {
|
||||
enterConference(nativePtr);
|
||||
private native boolean enterConference(long nativePtr);
|
||||
public synchronized boolean enterConference() {
|
||||
return enterConference(nativePtr);
|
||||
}
|
||||
|
||||
private native boolean isInConference(long nativePtr);
|
||||
|
@ -571,14 +571,14 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
return (LinphoneCall) findCallFromUri(nativePtr, uri);
|
||||
}
|
||||
|
||||
public String getMediaEncryption() {
|
||||
return getMediaEncryption(nativePtr);
|
||||
public MediaEncryption getMediaEncryption() {
|
||||
return MediaEncryption.fromInt(getMediaEncryption(nativePtr));
|
||||
}
|
||||
public boolean isMediaEncryptionMandatory() {
|
||||
return isMediaEncryptionMandatory(nativePtr);
|
||||
}
|
||||
public void setMediaEncryption(String menc) {
|
||||
setMediaEncryption(nativePtr, menc);
|
||||
public void setMediaEncryption(MediaEncryption menc) {
|
||||
setMediaEncryption(nativePtr, menc.mValue);
|
||||
}
|
||||
public void setMediaEncryptionMandatory(boolean yesno) {
|
||||
setMediaEncryptionMandatory(nativePtr, yesno);
|
||||
|
@ -610,4 +610,9 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public boolean isEchoLimiterEnabled() {
|
||||
return isEchoLimiterEnabled(nativePtr);
|
||||
}
|
||||
private native boolean mediaEncryptionSupported(long nativePtr, int menc);
|
||||
@Override
|
||||
public boolean mediaEncryptionSupported(MediaEncryption menc) {
|
||||
return mediaEncryptionSupported(nativePtr,menc.mValue);
|
||||
}
|
||||
}
|
||||
|
|
2
submodules/externals/exosip
vendored
2
submodules/externals/exosip
vendored
|
@ -1 +1 @@
|
|||
Subproject commit ad693d4bfa47481fa867ee0f3e7b856ac0d166f8
|
||||
Subproject commit f288044136b3e60baf6c0805e8cf87e5cdbc7890
|
2
submodules/externals/speex
vendored
2
submodules/externals/speex
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a6d05eb5ff9d5062852cdf7df574bec728921ef9
|
||||
Subproject commit 06a869e4a71941d24bacbf08289a6319c920973c
|
|
@ -1 +1 @@
|
|||
Subproject commit ce510f9d1fa8d66aabcca308f0d2a9174f68acd4
|
||||
Subproject commit 72a508632760bf20c2aeac7e253f7a481974f499
|
|
@ -223,10 +223,11 @@ public class TestConferenceActivity extends IncallActivity {
|
|||
}
|
||||
public int updateCall(LinphoneCall call, LinphoneCallParams params) {return 0;}
|
||||
private boolean partOfConf;
|
||||
public void enterConference() {
|
||||
public boolean enterConference() {
|
||||
pauseAllCalls();
|
||||
partOfConf=true;
|
||||
hackTriggerConfStateUpdate(); // FIXME hack; should have an event?
|
||||
return true;
|
||||
}
|
||||
public void leaveConference() {
|
||||
partOfConf=false;
|
||||
|
@ -338,7 +339,7 @@ public class TestConferenceActivity extends IncallActivity {
|
|||
|
||||
}
|
||||
@Override
|
||||
public String getMediaEncryption() {
|
||||
public MediaEncryption getMediaEncryption() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
@ -348,11 +349,6 @@ public class TestConferenceActivity extends IncallActivity {
|
|||
return false;
|
||||
}
|
||||
@Override
|
||||
public void setMediaEncryption(String menc) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void setMediaEncryptionMandatory(boolean yesno) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
@ -362,6 +358,16 @@ public class TestConferenceActivity extends IncallActivity {
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mediaEncryptionSupported(MediaEncryption menc) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void setMediaEncryption(MediaEncryption menc) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue