Yesterday I took the latest linphone
code and successfully compiled it for Android
. I am able to register successfully and i am able to make calls.
Now I am trying to use our server with some custom header
.
I was trying to find a way to add custom header in REGISTER
request. But failed.
I have done this in iPhone using "linphone_proxy_config_get_custom_header" directly.
But in Android, the method itself not available in linphonecore_jni.cc. Also "addCustomHeader" in "LinphoneProxyConfig.java" file.
But I can see other implementation like;
1. Java_org_linphone_core_LinphoneInfoMessageImpl_addHeader
2. Java_org_linphone_core_LinphoneCallParamsImpl_addCustomHeader
3. Java_org_linphone_core_LinphoneCallParamsImpl_addCustomSdpAttribute
4. Java_org_linphone_core_LinphoneCallParamsImpl_addCustomSdpMediaAttribute
5. Java_org_linphone_core_LinphoneEventImpl_addCustomHeader
6. Java_org_linphone_core_LinphoneChatMessageImpl_addCustomHeader
I don't know how to resolved this issue.
Any idea.
I have resolved this issue.
I modified 3 files to fix this issue.
1.
I added the below code in linphonecore_jni.cc
file.
extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getCustomHeader(JNIEnv* env ,jobject thiz ,jlong ptr, jstring jheader_name) { const char *name=env->GetStringUTFChars(jheader_name,NULL); const char *value=linphone_proxy_config_get_custom_header((LinphoneProxyConfig*)ptr,name); env->ReleaseStringUTFChars(jheader_name, name); return value ? env->NewStringUTF(value) : NULL; } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_addCustomHeader(JNIEnv* env ,jobject thiz ,jlong ptr, jstring jheader_name, jstring jheader_value) { const char *name=env->GetStringUTFChars(jheader_name,NULL); const char *value=env->GetStringUTFChars(jheader_value,NULL); linphone_proxy_config_set_custom_header((LinphoneProxyConfig*)ptr,name,value); env->ReleaseStringUTFChars(jheader_name, name); env->ReleaseStringUTFChars(jheader_value, value); }
2.
Then added below code in LinphoneProxyConfigImpl.java
file:
private native void addCustomHeader(long nativePtr, String key,String value); public void addCustomHeader(String key,String value) { isValid(); addCustomHeader(nativePtr, key, value); } private native String getCustomHeader(long nativePtr, String key); public String getCustomHeader(String key) { isValid(); return getCustomHeader(nativePtr, key); }
3.
Then, added below code in LinphoneProxyConfig
file.
void addCustomHeader(String key,String value); String getCustomHeader(String key);
In my code, I am adding the x-header
as below:
LinphoneProxyConfig proxyConfig = linphoneCore.createProxyConfig(----); proxyConfig.addCustomHeader("X-Test1", "testing"); proxyConfig.addCustomHeader("X-Test2", "2nd test");
There is a method called setCustomHeader
in latest linphone
source.
proxyConfig.setCustomHeader("X-Test1", "testing"); proxyConfig.setCustomHeader("X-Test2", "2nd test");