diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index fa2ec5bbc073d12c1ee55faab60f5bab901fc35d..51346f696994aea0f39972d11872c69de0a60ca2 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1348,6 +1348,16 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env return NULL; } } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setTone(JNIEnv* env + ,jobject thiz + ,jlong lc + ,jint toneid + ,jstring jpath) { + const char* path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + linphone_core_set_tone((LinphoneCore *)lc, (LinphoneToneID)toneid, path); + if (path) env->ReleaseStringUTFChars(jpath, path); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCallErrorTone(JNIEnv* env ,jobject thiz ,jlong lc diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 46f639238db0063329785d7c1e7f0fcbea69e22a..5a211736ca19bdc357dcede83558330e813c9196 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -1533,6 +1533,14 @@ public interface LinphoneCore { */ public void setCallErrorTone(Reason reason, String path); + /** + * Assign an audio file to be played locally in replacement of common telephony tone. + * This is typically used to internationalize tones. + * @param id a tone id + * @param wav a path to a 16 bit PCM linear wav file. + */ + public void setTone(ToneID id, String wavfile); + /** * Inform the core about the maximum transmission unit of the network. * This is used for fragmenting video RTP packets to a size compatible with the network. diff --git a/java/common/org/linphone/core/ToneID.java b/java/common/org/linphone/core/ToneID.java new file mode 100644 index 0000000000000000000000000000000000000000..6ef8be1abd2cef52d13d7e8ff6dd552c15601759 --- /dev/null +++ b/java/common/org/linphone/core/ToneID.java @@ -0,0 +1,24 @@ +package org.linphone.core; + +public enum ToneID { + Undefined(0), + Busy(1), + CallWaiting(2), + CallOnHold(3), + CallLost(4); + protected final int mValue; + private ToneID(int value){ + mValue=value; + } + static protected ToneID fromInt(int value) throws LinphoneCoreException{ + switch(value){ + case 0: return Undefined; + case 1: return Busy; + case 2: return CallWaiting; + case 3: return CallOnHold; + case 4: return CallLost; + default: + throw new LinphoneCoreException("Unhandled enum value "+value+" for LinphoneToneID"); + } + } +} diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index e5edfae742b8cb7e8099a372c561573ce4a0c40b..5eeb0ac376c8c50fcea9a96c24f8357611065cad 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -1160,5 +1160,10 @@ class LinphoneCoreImpl implements LinphoneCore { public boolean isSdp200AckEnabled() { return isSdp200AckEnabled(nativePtr); } + private native void setTone(long nativePtr, int id, String wavfile); + @Override + public void setTone(ToneID id, String wavfile) { + setTone(nativePtr, id.mValue, wavfile); + } }