diff --git a/res/values/strings.xml b/res/values/strings.xml index 8a8dc7299..2e1482b65 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,5 +1,13 @@ + H263 + pref_video_codec_h263_key + MPEG4 + pref_video_codec_mpeg4_key + H264 + pref_video_codec_h264_key + Video codecs + pref_video_codecs_key Display dialer Try High resolution Low resolution @@ -44,7 +52,7 @@ speex 16 Khz pref_codec_speex16_key pref_codec_speex32_key - Codecs + Audio Codecs pref_codecs_key Place a call Debug diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index b53581d04..74303ec0c 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -39,6 +39,11 @@ + + + + + diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index 4ba659689..86c0096b6 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -264,7 +264,34 @@ public class LinphoneService extends Service implements LinphoneCoreListener { } - + private void enableDisableAudioCodec(String codec, int rate, int key) throws LinphoneCoreException { + PayloadType pt = mLinphoneCore.findPayloadType(codec, rate); + if (pt !=null) { + boolean enable= mPref.getBoolean(getString(key),false); + mLinphoneCore.enablePayloadType(pt, enable); + } + } + + private void enableDisableVideoCodecs(PayloadType videoCodec) throws LinphoneCoreException { + String mime = videoCodec.getMime(); + int key; + + if ("MP4V-ES".equals(mime)) { + key = R.string.pref_video_codec_mpeg4_key; + } else if ("H264".equals(mime)) { + key = R.string.pref_video_codec_h264_key; + } else if ("H263-1998".equals(mime)) { + key = R.string.pref_video_codec_h263_key; + } else { + Log.e(TAG, "Unhandled video codec " + mime); + mLinphoneCore.enablePayloadType(videoCodec, false); + return; + } + + boolean enable= mPref.getBoolean(getString(key),false); + mLinphoneCore.enablePayloadType(videoCodec, enable); + } + public void initFromConf() throws LinphoneConfigException, LinphoneException { //traces boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false); @@ -272,40 +299,16 @@ public class LinphoneService extends Service implements LinphoneCoreListener { try { //codec config - PayloadType lPt = mLinphoneCore.findPayloadType("speex", 32000); - if (lPt !=null) { - boolean enable= mPref.getBoolean(getString(R.string.pref_codec_speex32_key),false); - mLinphoneCore.enablePayloadType(lPt, enable); - } - lPt = mLinphoneCore.findPayloadType("speex", 16000); - if (lPt !=null) { - boolean enable= mPref.getBoolean(getString(R.string.pref_codec_speex16_key),false); - mLinphoneCore.enablePayloadType(lPt, enable); - } - lPt = mLinphoneCore.findPayloadType("speex", 8000); - if (lPt !=null) { - boolean enable= mPref.getBoolean(getString(R.string.pref_codec_speex8_key),false); - mLinphoneCore.enablePayloadType(lPt, enable); - } - lPt = mLinphoneCore.findPayloadType("iLBC", 8000); - if (lPt !=null) { - boolean enable= mPref.getBoolean(getString(R.string.pref_codec_ilbc_key),false); - mLinphoneCore.enablePayloadType(lPt, enable); - } - lPt = mLinphoneCore.findPayloadType("GSM", 8000); - if (lPt !=null) { - boolean enable= mPref.getBoolean(getString(R.string.pref_codec_gsm_key),false); - mLinphoneCore.enablePayloadType(lPt, enable); - } - lPt = mLinphoneCore.findPayloadType("PCMU", 8000); - if (lPt !=null) { - boolean enable= mPref.getBoolean(getString(R.string.pref_codec_pcmu_key),false); - mLinphoneCore.enablePayloadType(lPt, enable); - } - lPt = mLinphoneCore.findPayloadType("PCMA", 8000); - if (lPt !=null) { - boolean enable= mPref.getBoolean(getString(R.string.pref_codec_pcma_key),false); - mLinphoneCore.enablePayloadType(lPt, enable); + enableDisableAudioCodec("speex", 32000, R.string.pref_codec_speex32_key); + enableDisableAudioCodec("speex", 16000, R.string.pref_codec_speex8_key); + enableDisableAudioCodec("speex", 8000, R.string.pref_codec_speex8_key); + enableDisableAudioCodec("iLBC", 8000, R.string.pref_codec_ilbc_key); + enableDisableAudioCodec("GSM", 8000, R.string.pref_codec_gsm_key); + enableDisableAudioCodec("PCMU", 8000, R.string.pref_codec_pcmu_key); + enableDisableAudioCodec("PCMA", 8000, R.string.pref_codec_pcma_key); + + for (PayloadType videoCodec : mLinphoneCore.listVideoCodecs()) { + enableDisableVideoCodecs(videoCodec); } @@ -398,6 +401,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener { + protected LinphoneCore getLinphoneCore() { return mLinphoneCore; } diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java index 745c8c358..62741c7ef 100644 --- a/src/org/linphone/core/LinphoneCoreImpl.java +++ b/src/org/linphone/core/LinphoneCoreImpl.java @@ -85,9 +85,10 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setDownloadBandwidth(long nativePtr, int bw); private native void setPreferredVideoSize(long nativePtr, int width, int heigth); private native int[] getPreferredVideoSize(long nativePtr); - private native void setRing(long nativePtr, String path); private native String getRing(long nativePtr); + private native long[] listVideoPayloadTypes(long nativePtr); + private static String TAG = "LinphoneCore"; @@ -415,4 +416,17 @@ class LinphoneCoreImpl implements LinphoneCore { // TODO Auto-generated method stub return false; } + + public PayloadType[] listVideoCodecs() { + long[] typesPtr = listVideoPayloadTypes(nativePtr); + if (typesPtr == null) return null; + + PayloadType[] codecs = new PayloadType[typesPtr.length]; + + for (int i=0; i < codecs.length; i++) { + codecs[i] = new PayloadTypeImpl(typesPtr[i]); + } + + return codecs; + } } diff --git a/src/org/linphone/core/PayloadTypeImpl.java b/src/org/linphone/core/PayloadTypeImpl.java index 28c206786..864b094ff 100644 --- a/src/org/linphone/core/PayloadTypeImpl.java +++ b/src/org/linphone/core/PayloadTypeImpl.java @@ -24,10 +24,21 @@ class PayloadTypeImpl implements PayloadType { protected final long nativePtr; private native String toString(long ptr); - + private native String getMime(long ptr); + private native int getRate(long ptr); + protected PayloadTypeImpl(long aNativePtr) { nativePtr = aNativePtr; } + + public int getRate() { + return getRate(nativePtr); + } + + public String getMime() { + return getMime(nativePtr); + } + public String toString() { return toString(nativePtr); } diff --git a/submodules/linphone b/submodules/linphone index 656db4fa1..8b3112cca 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 656db4fa166ceeebd3258696a9cbddfbf6a1c024 +Subproject commit 8b3112cca81a31e4b35b0c4e9e7c6217fefb5c4c