]> sjero.net Git - linphone/commitdiff
add new JNI and java methods.
authorSimon Morlat <simon.morlat@linphone.org>
Thu, 7 Feb 2013 14:34:19 +0000 (15:34 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Thu, 7 Feb 2013 14:34:53 +0000 (15:34 +0100)
coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java
coreapi/linphonecore_jni.cc
java/common/org/linphone/core/LinphoneCall.java
java/common/org/linphone/core/LinphoneCallParams.java
java/common/org/linphone/core/LinphoneChatMessage.java
java/impl/org/linphone/core/LinphoneCallImpl.java
java/impl/org/linphone/core/LinphoneCallParamsImpl.java
java/impl/org/linphone/core/LinphoneChatMessageImpl.java

index a9134dc88acf7cb105b61a10e0e4e5ae6faf4fe5..0249274688c555f4887a5dfa67edf630f2ad54d1 100644 (file)
@@ -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());
        }
 
 
index 9629688c7f9f1140902d2805bb60c932246353e3..3cbcf8f79b3c949a31d4317640a094b09eb56a30 100644 (file)
@@ -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));
index 79f38633bd0e91fa913e79652ff54e4e4ac56e47..893572e2eeaf64e6c68d22d12cf650dd2b8ff16b 100644 (file)
@@ -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();
 }
index f8c7c097f36cdf5566487d08834ab636bd1e73a8..b6d5ef33dfc9a2406989363aeb57fc709d16e6b4 100644 (file)
@@ -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);
 }
index d403d94bdb0ddfb5b349bd376c8a616232a71b36..3a2a4571813edd40c1564708a78e7717853be018 100644 (file)
@@ -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);
 }
index 45c905dbb5b7d3f253c17c9cb17080cf7c43a5f7..30bcd528fce17e94ec46bd94c393513cc7962d50 100644 (file)
@@ -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);
+       }
 }
index ca41f6ecbbea4155080c6a5d4fc72d39fea3d0e2..83cc95f54f0e000869fd3f3c949c2124148f3518 100644 (file)
@@ -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);
+       }
+       
 }
index 62fac1dc37f1401e399c1749fd171bfb83e9ef13..1373708ca07508a846dc290e1dbe7d71bdeb8260 100644 (file)
@@ -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);
+       }
 }