Commit dd9241f2 authored by Simon Morlat's avatar Simon Morlat
Browse files

add new JNI and java methods.

parent f36aac6d
......@@ -154,13 +154,13 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa
@Override
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr,
LinphoneChatMessage message) {
write("Message [" + message.getMessage() + "] received from [" + message.getFrom().asString() + "]");
write("Message [" + message.getText() + "] received from [" + message.getFrom().asString() + "]");
}
@Override
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg,
org.linphone.core.LinphoneChatMessage.State state) {
write("Sent message [" + msg.getMessage() + "] new state is " + state.toString());
write("Sent message [" + msg.getText() + "] new state is " + state.toString());
}
......
......@@ -1367,7 +1367,7 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRa
}
extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
const LinphoneCall *call = (LinphoneCall *)call_ptr;
LinphoneCall *call = (LinphoneCall *)call_ptr;
const LinphoneCallParams *params;
const PayloadType *pt;
const report_block_t *srb = NULL;
......@@ -1396,7 +1396,7 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarr
}
extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
const LinphoneCall *call = (LinphoneCall *)call_ptr;
LinphoneCall *call = (LinphoneCall *)call_ptr;
const LinphoneCallParams *params;
const PayloadType *pt;
const report_block_t *rrb = NULL;
......@@ -1671,12 +1671,32 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEn
jobject ud = env->NewGlobalRef(thiz);
linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
}
extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv* env
,jobject thiz
,jlong ptr) {
jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
jstring jvalue =env->NewStringUTF(linphone_chat_message_get_text((LinphoneChatMessage*)ptr));
return jvalue;
}
extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getCustomHeader(JNIEnv* env
,jobject thiz
,jlong ptr, jstring jheader_name) {
const char *name=env->GetStringUTFChars(jheader_name,NULL);
const char *value=linphone_chat_message_get_custom_header((LinphoneChatMessage*)ptr,name);
env->ReleaseStringUTFChars(jheader_name, name);
return value ? env->NewStringUTF(value) : NULL;
}
extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_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_chat_message_add_custom_header((LinphoneChatMessage*)ptr,name,value);
env->ReleaseStringUTFChars(jheader_name, name);
env->ReleaseStringUTFChars(jheader_name, name);
}
extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
,jobject thiz
,jlong ptr) {
......@@ -1696,11 +1716,13 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv*
,jlong ptr) {
return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
}
extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
,jobject thiz
,jlong ptr) {
return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
}
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
,jobject thiz
,jlong ptr
......@@ -1847,6 +1869,29 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenc
return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
}
extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name){
const char* header_name=env->GetStringUTFChars(jheader_name, NULL);
const char *header_value=linphone_call_params_get_custom_header((LinphoneCallParams*)lcp,header_name);
env->ReleaseStringUTFChars(jheader_name, header_name);
return header_value ? env->NewStringUTF(header_value) : NULL;
}
extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name, jstring jheader_value){
const char* header_name=env->GetStringUTFChars(jheader_name, NULL);
const char* header_value=env->GetStringUTFChars(jheader_value, NULL);
linphone_call_params_add_custom_header((LinphoneCallParams*)lcp,header_name,header_value);
env->ReleaseStringUTFChars(jheader_name, header_name);
env->ReleaseStringUTFChars(jheader_value, header_value);
}
extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setRecordFile(JNIEnv *env, jobject thiz, jlong lcp, jstring jrecord_file){
if (jrecord_file){
const char* record_file=env->GetStringUTFChars(jrecord_file, NULL);
linphone_call_params_set_record_file((LinphoneCallParams*)lcp,record_file);
env->ReleaseStringUTFChars(jrecord_file, record_file);
}else linphone_call_params_set_record_file((LinphoneCallParams*)lcp,NULL);
}
extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
return linphone_call_params_destroy((LinphoneCallParams*)lc);
}
......@@ -1873,6 +1918,14 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv
return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc);
}
extern "C" void Java_org_linphone_core_LinphoneCallImpl_startRecording(JNIEnv *env, jobject thiz, jlong lc){
linphone_call_start_recording((LinphoneCall *)lc);
}
extern "C" void Java_org_linphone_core_LinphoneCallImpl_stopRecording(JNIEnv *env, jobject thiz, jlong lc){
linphone_call_stop_recording((LinphoneCall *)lc);
}
extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
......
......@@ -281,4 +281,15 @@ public interface LinphoneCall {
* Scale the video by factor, and center it using cx,cy point
*/
void zoomVideo(float factor, float cx, float cy);
/**
* Start call recording.
* A file path must be provided with LinphoneCallParams.setRecordFile() at call establishement for this method to work.
*/
void startRecording();
/**
* Stop call recording.
*/
void stopRecording();
}
......@@ -72,4 +72,25 @@ public interface LinphoneCallParams {
* @return true if low bandwidth has been configured/detected
*/
boolean isLowBandwidthEnabled();
/**
* Set a path to file where the call will be recorded.
* Actual start of the recording is controlled by LinphoneCall.startRecording().
**/
void setRecordFile(String path);
/**
* Add a custom header to be used for the call for which these call params are used.
* @param name header name
* @param value header value
*/
void addCustomHeader(String name, String value);
/**
* Returns the value of a custom header given its name.
* If no header with that name exists, then null is returned.
* @param name
* @return value for the header, or null if it doesn't exist.
*/
String getCustomHeader(String name);
}
......@@ -63,7 +63,7 @@ public interface LinphoneChatMessage {
*
* @return text sent along with the message
*/
String getMessage();
String getText();
/**
* get peer address associated to this LinphoneChatMessage
......@@ -92,4 +92,18 @@ public interface LinphoneChatMessage {
* @param url ex: access-type=URL; URL="http://www.foo.com/file"
*/
void setExternalBodyUrl(String url);
/**
* Add a custom header into the message.
* @param name
* @param value
*/
void addCustomHeader(String name, String value);
/**
* Obtain a header value.
* @param name
* @return the value of the header, or null if not found.
*/
String getCustomHeader(String name);
}
......@@ -194,4 +194,15 @@ class LinphoneCallImpl implements LinphoneCall {
public void zoomVideo(float factor, float cx, float cy) {
zoomVideo(nativePtr, factor, cx, cy);
}
private native void startRecording(long nativePtr);
@Override
public void startRecording() {
startRecording(nativePtr);
}
private native void stopRecording(long nativePtr);
@Override
public void stopRecording() {
stopRecording(nativePtr);
}
}
......@@ -88,4 +88,23 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams {
public boolean isLowBandwidthEnabled() {
return isLowBandwidthEnabled(nativePtr);
}
private native void setRecordFile(long nativePtr, String path);
@Override
public void setRecordFile(String path) {
setRecordFile(nativePtr,path);
}
private native void addCustomHeader(long nativePtr, String name, String value);
@Override
public void addCustomHeader(String name, String value) {
addCustomHeader(nativePtr,name,value);
}
private native String getCustomHeader(long nativePtr, String name);
@Override
public String getCustomHeader(String name) {
return getCustomHeader(nativePtr,name);
}
}
......@@ -3,7 +3,7 @@ package org.linphone.core;
public class LinphoneChatMessageImpl implements LinphoneChatMessage {
protected final long nativePtr;
private native void setUserData(long ptr);
private native String getMessage(long ptr);
private native String getText(long ptr);
private native long getPeerAddress(long ptr);
private native String getExternalBodyUrl(long ptr);
private native void setExternalBodyUrl(long ptr, String url);
......@@ -30,8 +30,8 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
}
@Override
public String getMessage() {
return getMessage(nativePtr);
public String getText() {
return getText(nativePtr);
}
@Override
......@@ -53,4 +53,15 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
public LinphoneAddress getFrom() {
return new LinphoneAddressImpl(getFrom(nativePtr));
}
private native void addCustomHeader(long nativePtr, String name, String value);
@Override
public void addCustomHeader(String name, String value) {
addCustomHeader(nativePtr, name, value);
}
private native String getCustomHeader(long nativePtr, String name);
@Override
public String getCustomHeader(String name) {
return getCustomHeader(nativePtr,name);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment