]> sjero.net Git - linphone/blobdiff - coreapi/offeranswer.c
update ms2 and cleanup dead function
[linphone] / coreapi / offeranswer.c
index 1d4ce1b9fcee0f7c2ff53398ae44c5a609ecfa17..9823c24a69f12f6b448d4b687d85436249c9fdb7 100644 (file)
@@ -19,11 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "sal.h"
 #include "offeranswer.h"
+#include "private.h"
 
 static bool_t only_telephone_event(const MSList *l){
-       PayloadType *p=(PayloadType*)l->data;
-       if (strcasecmp(p->mime_type,"telephone-event")!=0){
-               return FALSE;
+       for(;l!=NULL;l=l->next){
+               PayloadType *p=(PayloadType*)l->data;
+               if (strcasecmp(p->mime_type,"telephone-event")!=0){
+                       return FALSE;
+               }
        }
        return TRUE;
 }
@@ -238,7 +241,6 @@ static void initiate_incoming(const SalStreamDescription *local_cap,
        if (result->payloads && !only_telephone_event(result->payloads) && (remote_offer->rtp_port!=0 || remote_offer->rtp_port==SalStreamSendOnly)){
                strcpy(result->rtp_addr,local_cap->rtp_addr);
                strcpy(result->rtcp_addr,local_cap->rtcp_addr);
-               memcpy(result->candidates,local_cap->candidates,sizeof(result->candidates));
                result->rtp_port=local_cap->rtp_port;
                result->rtcp_port=local_cap->rtcp_port;
                result->bandwidth=local_cap->bandwidth;
@@ -256,6 +258,7 @@ static void initiate_incoming(const SalStreamDescription *local_cap,
        strcpy(result->ice_pwd, local_cap->ice_pwd);
        strcpy(result->ice_ufrag, local_cap->ice_ufrag);
        result->ice_mismatch = local_cap->ice_mismatch;
+       result->ice_completed = local_cap->ice_completed;
        memcpy(result->ice_candidates, local_cap->ice_candidates, sizeof(result->ice_candidates));
        memcpy(result->ice_remote_candidates, local_cap->ice_remote_candidates, sizeof(result->ice_remote_candidates));
 }
@@ -265,22 +268,23 @@ static void initiate_incoming(const SalStreamDescription *local_cap,
  * and the returned response (remote).
 **/
 int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
-                                                                       const SalMediaDescription *remote_answer,
-                                                       SalMediaDescription *result){
-       int i,j;
-    
+                                       const SalMediaDescription *remote_answer,
+                                       SalMediaDescription *result){
+       int i,j;
+
        const SalStreamDescription *ls,*rs;
-       for(i=0,j=0;i<local_offer->nstreams;++i){
+       for(i=0,j=0;i<local_offer->n_total_streams;++i){
                ms_message("Processing for stream %i",i);
                ls=&local_offer->streams[i];
                rs=sal_media_description_find_stream((SalMediaDescription*)remote_answer,ls->proto,ls->type);
-       if (rs) {
+               if (rs) {
                        initiate_outgoing(ls,rs,&result->streams[j]);
                        ++j;
                }
                else ms_warning("No matching stream for %i",i);
        }
-       result->nstreams=j;
+       result->n_active_streams=j;
+       result->n_total_streams=local_offer->n_total_streams;
        result->bandwidth=remote_answer->bandwidth;
        strcpy(result->addr,remote_answer->addr);
        return 0;
@@ -292,12 +296,13 @@ int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
  * The returned media description is an answer and should be sent to the offerer.
 **/
 int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities,
-                                               const SalMediaDescription *remote_offer,
-                                       SalMediaDescription *result, bool_t one_matching_codec){
+                                       const SalMediaDescription *remote_offer,
+                                       SalMediaDescription *result, bool_t one_matching_codec){
        int i;
        const SalStreamDescription *ls=NULL,*rs;
-                                                       
-       for(i=0;i<remote_offer->nstreams;++i){
+
+       result->n_active_streams=0;
+       for(i=0;i<remote_offer->n_total_streams;++i){
                rs=&remote_offer->streams[i];
                if (rs->proto!=SalProtoUnknown){
                        ls=sal_media_description_find_stream((SalMediaDescription*)local_capabilities,rs->proto,rs->type);
@@ -308,9 +313,9 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities
                }else ms_warning("Unknown protocol for mline %i, declining",i);
                if (ls){
                        initiate_incoming(ls,rs,&result->streams[i],one_matching_codec);
-               }
-               else {
-                       /* create an inactive stream for the answer, as there where no matching stream a local capability */
+                       if (result->streams[i].rtp_port!=0) result->n_active_streams++;
+               }else {
+                       /* create an inactive stream for the answer, as there where no matching stream in local capabilities */
                        result->streams[i].dir=SalStreamInactive;
                        result->streams[i].rtp_port=0;
                        result->streams[i].type=rs->type;
@@ -320,7 +325,7 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities
                        }
                }
        }
-       result->nstreams=i;
+       result->n_total_streams=i;
        strcpy(result->username, local_capabilities->username);
        strcpy(result->addr,local_capabilities->addr);
        result->bandwidth=local_capabilities->bandwidth;
@@ -329,6 +334,6 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities
        strcpy(result->ice_pwd, local_capabilities->ice_pwd);
        strcpy(result->ice_ufrag, local_capabilities->ice_ufrag);
        result->ice_lite = local_capabilities->ice_lite;
-       result->ice_completed = local_capabilities->ice_lite;
+       result->ice_completed = local_capabilities->ice_completed;
        return 0;
 }