]> sjero.net Git - linphone/commitdiff
add get_remote_contact() api and clean java API.
authorSimon Morlat <simon.morlat@linphone.org>
Wed, 30 Jan 2013 11:05:09 +0000 (12:05 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Wed, 30 Jan 2013 11:05:09 +0000 (12:05 +0100)
coreapi/linphonecall.c
coreapi/linphonecore.h
coreapi/linphonecore_jni.cc
coreapi/sal.c
coreapi/sal.h
coreapi/sal_eXosip2.c
java/common/org/linphone/core/LinphoneCall.java
java/impl/org/linphone/core/LinphoneCallImpl.java

index 11be247c237bd5a5bf7f8576e8f6b1616e80d239..3bfa7d9d450ebb117da451be6a0689bb53cd826e 100644 (file)
@@ -898,6 +898,16 @@ const char *linphone_call_get_remote_user_agent(LinphoneCall *call){
        return NULL;
 }
 
+/**
+ * Returns the far end's sip contact as a string, if available.
+**/
+const char *linphone_call_get_remote_contact(LinphoneCall *call){
+       if (call->op){
+               return sal_op_get_remote_contact(call->op);
+       }
+       return NULL;
+}
+
 /**
  * Returns true if this calls has received a transfer that has not been
  * executed yet.
index 1f49cce46909fd8a5ea2eb37910f47dbc3a14f77..6eb401638b2849787bb987ea5e525e99a7697f93 100644 (file)
@@ -396,6 +396,7 @@ bool_t linphone_call_camera_enabled(const LinphoneCall *lc);
 int linphone_call_take_video_snapshot(LinphoneCall *call, const char *file);
 LinphoneReason linphone_call_get_reason(const LinphoneCall *call);
 const char *linphone_call_get_remote_user_agent(LinphoneCall *call);
+const char *linphone_call_get_remote_contact(LinphoneCall *call);
 float linphone_call_get_play_volume(LinphoneCall *call);
 float linphone_call_get_record_volume(LinphoneCall *call);
 float linphone_call_get_current_quality(LinphoneCall *call);
index 4144c1441f54d07da534f7995313002d7f0f6c64..6c2135203648a8349879f9fbf1b8931c6ba2175a 100644 (file)
@@ -1508,7 +1508,17 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress(       JNIEn
 
 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteUserAgent(JNIEnv *env, jobject thiz, jlong ptr) {
        LinphoneCall *call = (LinphoneCall *)ptr;
-       jstring jvalue = env->NewStringUTF(linphone_call_get_remote_user_agent(call));
+       const char *value=linphone_call_get_remote_user_agent(call);
+       jstring jvalue=NULL;
+       if (value) jvalue=env->NewStringUTF();
+       return jvalue;
+}
+
+extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteContact(JNIEnv *env, jobject thiz, jlong ptr) {
+       LinphoneCall *call = (LinphoneCall *)ptr;
+       const char *value=linphone_call_get_remote_contact(call);
+       jstring jvalue = NULL;
+       if (value) jvalue=env->NewStringUTF(value);
        return jvalue;
 }
 
index 05d03499d85e327a6dc813bca746757815c193b5..d91be1cb6a891ce1049ecd6768520cd316838672 100644 (file)
@@ -273,6 +273,10 @@ const char *sal_op_get_contact(const SalOp *op){
        return ((SalOpBase*)op)->contact;
 }
 
+const char *sal_op_get_remote_contact(const SalOp *op){
+       return ((SalOpBase*)op)->remote_contact;
+}
+
 const char *sal_op_get_route(const SalOp *op){
        return ((SalOpBase*)op)->route;
 }
@@ -304,6 +308,9 @@ void __sal_op_set_network_origin(SalOp *op, const char *origin){
        assign_string(&((SalOpBase*)op)->origin,origin);
 }
 
+void __sal_op_set_remote_contact(SalOp *op, const char *ct){
+       assign_string(&((SalOpBase*)op)->remote_contact,ct);
+}
 
 void __sal_op_free(SalOp *op){
        SalOpBase *b=(SalOpBase *)op;
@@ -331,12 +338,16 @@ void __sal_op_free(SalOp *op){
                ms_free(b->remote_ua);
                b->remote_ua=NULL;
        }
+       if (b->remote_contact){
+               ms_free(b->remote_contact);
+               b->remote_contact=NULL;
+       }
        if (b->local_media)
                sal_media_description_unref(b->local_media);
        if (b->remote_media)
                sal_media_description_unref(b->remote_media);
        if (b->call_id)
-               ms_free((void*)b->call_id);
+               ms_free(b->call_id);
        ms_free(op);
 }
 
index 6baae97ae8b20fb6941e3245077232fb5bc2b46b..b751dfc0d43cf0616e277c547f9f4f973eb5e71c 100644 (file)
@@ -221,7 +221,8 @@ typedef struct SalOpBase{
        SalMediaDescription *local_media;
        SalMediaDescription *remote_media;
        void *user_pointer;
-       const char* call_id;
+       char* call_id;
+       char *remote_contact;
 } SalOpBase;
 
 
@@ -385,6 +386,7 @@ const char *sal_op_get_to(const SalOp *op);
 const char *sal_op_get_contact(const SalOp *op);
 const char *sal_op_get_route(const SalOp *op);
 const char *sal_op_get_proxy(const SalOp *op);
+const char *sal_op_get_remote_contact(const SalOp *op);
 /*for incoming requests, returns the origin of the packet as a sip uri*/
 const char *sal_op_get_network_origin(const SalOp *op);
 /*returns far-end "User-Agent" string */
@@ -442,7 +444,7 @@ int sal_ping(SalOp *op, const char *from, const char *to);
 
 
 
-#define payload_type_set_number(pt,n)  (pt)->user_data=(void*)((long)n);
+#define payload_type_set_number(pt,n)          (pt)->user_data=(void*)((long)n);
 #define payload_type_get_number(pt)            ((int)(long)(pt)->user_data)
 
 /*misc*/
@@ -452,6 +454,7 @@ void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t ipl
 /*internal API */
 void __sal_op_init(SalOp *b, Sal *sal);
 void __sal_op_set_network_origin(SalOp *op, const char *origin /*a sip uri*/);
+void __sal_op_set_remote_contact(SalOp *op, const char *ct);
 void __sal_op_free(SalOp *b);
 
 #endif
index 1cbecb638c8452677d82e88c39509b072c398401..076f3d934405384b86739d54fa204c7fad9b1325 100644 (file)
@@ -671,8 +671,11 @@ int sal_call(SalOp *h, const char *from, const char *to){
                ms_error("Fail to send invite ! Error code %d", err);
                return -1;
        }else{
+               char *tmp=NULL;
                callid=osip_message_get_call_id(invite);
-               osip_call_id_to_str(callid,(char **)(&h->base.call_id));
+               osip_call_id_to_str(callid,&tmp);
+               h->base.call_id=ms_strdup(tmp);
+               osip_free(tmp);
                sal_add_call(h->base.root,h);
        }
        return 0;
@@ -1014,6 +1017,19 @@ static void set_remote_ua(SalOp* op, osip_message_t *req){
        }
 }
 
+static void set_remote_contact(SalOp* op, osip_message_t *req){
+       if (op->base.remote_contact==NULL){
+               osip_contact_t *h=NULL;
+               osip_message_get_contact(req,0,&h);
+               if (h){
+                       char *tmp=NULL;
+                       osip_contact_to_str(h,&tmp);
+                       __sal_op_set_remote_contact(op,tmp);
+                       osip_free(tmp);
+               }
+       }
+}
+
 static void set_replaces(SalOp *op, osip_message_t *req){
        osip_header_t *h=NULL;
 
@@ -1051,12 +1067,17 @@ static void inc_new_call(Sal *sal, eXosip_event_t *ev){
        SalOp *op=sal_op_new(sal);
        osip_from_t *from,*to;
        osip_call_info_t *call_info;
-       char *tmp;
+       char *tmp=NULL;
        sdp_message_t *sdp=eXosip_get_sdp_info(ev->request);
+       
        osip_call_id_t *callid=osip_message_get_call_id(ev->request);
-       osip_call_id_to_str(callid,(char**)(&op->base.call_id));
-
+       
+       osip_call_id_to_str(callid,&tmp);
+       op->base.call_id=ms_strdup(tmp);
+       osip_free(tmp);
+       
        set_network_origin(op,ev->request);
+       set_remote_contact(op,ev->request);
        set_remote_ua(op,ev->request);
        set_replaces(op,ev->request);
        
@@ -1234,6 +1255,7 @@ static void call_accepted(Sal *sal, eXosip_event_t *ev){
 
        op->did=ev->did;
        set_remote_ua(op,ev->response);
+       set_remote_contact(op,ev->response);
 
        sdp=eXosip_get_sdp_info(ev->response);
        if (sdp){
index ac7b14d8de497885bfe3e8ad11e1ba2cdcbe994d..79f38633bd0e91fa913e79652ff54e4e4ac56e47 100644 (file)
@@ -102,22 +102,22 @@ public interface LinphoneCall {
                /**
                 * The call's parameters are updated, used for example when video is asked by remote
                 */
-               public static final State CallUpdatedByRemote = new State(15, "CallUpdatedByRemote");
+               public static final State CallUpdatedByRemote = new State(15, "UpdatedByRemote");
 
                /**
                 * We are proposing early media to an incoming call
                 */
-               public static final State CallIncomingEarlyMedia = new State(16,"CallIncomingEarlyMedia");
+               public static final State CallIncomingEarlyMedia = new State(16,"IncomingEarlyMedia");
 
                /**
-                * The remote accepted the call update initiated by us
+                * We have initiated a call update. When the remote accepts the call update, state will move to StreamsRunning.
                 */
-               public static final State CallUpdated = new State(17, "CallUpdated");
+               public static final State CallUpdating = new State(17, "Updating");
                
                /**
                 * The call object is now released.
                 */
-               public static final State CallReleased = new State(18,"CallReleased");
+               public static final State CallReleased = new State(18,"Released");
 
                
                private State(int value,String stringValue) {
@@ -160,17 +160,6 @@ public interface LinphoneCall {
        **/
        LinphoneCallLog getCallLog();
 
-       /**
-        * Set the audio statistics associated with this call.
-        * @return LinphoneCallStats
-        */
-       void setAudioStats(LinphoneCallStats stats);
-
-       /**
-        * Set the video statistics associated with this call.
-        * @return LinphoneCallStats
-        */
-       void setVideoStats(LinphoneCallStats stats);
 
        /**
         * Get the audio statistics associated with this call.
@@ -184,6 +173,10 @@ public interface LinphoneCall {
         */
        LinphoneCallStats getVideoStats();
        
+       /**
+        * Get call's remote parameters, as proposed by far end.
+        * This is useful for example to know if far end supports video or encryption.
+       **/
        LinphoneCallParams getRemoteParams();
 
        LinphoneCallParams getCurrentParamsCopy();
@@ -273,6 +266,11 @@ public interface LinphoneCall {
         * Obtain the remote user agent string. 
         */
        String getRemoteUserAgent();
+
+       /**
+        * Obtain the remote sip contact string.
+       **/
+       String getRemoteContact();
        
        /**
         * Take a photo of currently received video and write it into a jpeg file.
index 6a91438acf4ea8aaf80f3a4849fabae80bc8126d..45c905dbb5b7d3f253c17c9cb17080cf7c43a5f7 100644 (file)
@@ -179,6 +179,11 @@ class LinphoneCallImpl implements LinphoneCall {
        public String getRemoteUserAgent() {
                return getRemoteUserAgent(nativePtr);
        }
+
+       private native String getRemoteContact(long nativePtr);
+       public String getRemoteContact() {
+               return getRemoteContact(nativePtr);
+       }
        
        private native void takeSnapshot(long nativePtr, String path);
        public void takeSnapshot(String path) {