From d06faa9190f3936793d07589de2a08340881ff67 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 24 Jun 2011 14:11:47 +0200 Subject: [PATCH] keep local payload types offered in call profile in case the remote end wants to use them despite it didn't accepted them. --- coreapi/linphonecall.c | 5 +---- coreapi/offeranswer.c | 23 ++++++++++++++++++++++- coreapi/sal.h | 4 ++++ coreapi/sal_eXosip2.c | 4 ++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 36a41186e..7e6e0380a 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -783,9 +783,6 @@ static void post_configure_audio_streams(LinphoneCall*call){ } } - - - static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *md, const SalStreamDescription *desc, int *used_pt){ int bw; const MSList *elem; @@ -800,7 +797,7 @@ static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *m PayloadType *pt=(PayloadType*)elem->data; int number; - if (first) { + if ((pt->flags & PAYLOAD_TYPE_FLAG_CAN_SEND) && first) { if (desc->type==SalAudio){ linphone_core_update_allocated_audio_bandwidth_in_call(call,pt); up_ptime=linphone_core_get_upload_ptime(lc); diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index 34d21fc0f..3e054508b 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -61,7 +61,7 @@ static PayloadType * find_payload_type_best_match(const MSList *l, const Payload } static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t reading_response, bool_t one_matching_codec){ - const MSList *e2; + const MSList *e2,*e1; MSList *res=NULL; PayloadType *matched; bool_t found_codec=FALSE; @@ -85,6 +85,7 @@ static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t newp=payload_type_clone(matched); if (p2->send_fmtp) payload_type_set_send_fmtp(newp,p2->send_fmtp); + newp->flags|=PAYLOAD_TYPE_FLAG_CAN_RECV|PAYLOAD_TYPE_FLAG_CAN_SEND; res=ms_list_append(res,newp); /* we should use the remote numbering even when parsing a response */ payload_type_set_number(newp,remote_number); @@ -104,6 +105,26 @@ static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t ms_message("No match for %s/%i",p2->mime_type,p2->clock_rate); } } + if (reading_response){ + /* add remaning local payload as CAN_RECV only so that if we are in front of a non-compliant equipment we are still able to decode the RTP stream*/ + for(e1=local;e1!=NULL;e1=e1->next){ + PayloadType *p1=(PayloadType*)e1->data; + bool_t found=FALSE; + for(e2=res;e2!=NULL;e2=e2->next){ + PayloadType *p2=(PayloadType*)e2->data; + if (payload_type_get_number(p2)==payload_type_get_number(p1)){ + found=TRUE; + break; + } + } + if (!found){ + ms_message("Adding %s/%i for compatibility, just in case.",p1->mime_type,p1->clock_rate); + p1=payload_type_clone(p1); + p1->flags|=PAYLOAD_TYPE_FLAG_CAN_RECV; + res=ms_list_append(res,p1); + } + } + } return res; } diff --git a/coreapi/sal.h b/coreapi/sal.h index af1ddc367..8ab339a6e 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -319,6 +319,7 @@ int sal_call_send_dtmf(SalOp *h, char dtmf); int sal_call_terminate(SalOp *h); bool_t sal_call_autoanswer_asked(SalOp *op); void sal_call_send_vfu_request(SalOp *h); +int sal_call_is_offerer(const SalOp *h); /*Registration*/ int sal_register(SalOp *op, const char *proxy, const char *from, int expires); @@ -343,6 +344,9 @@ int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus s /*ping: main purpose is to obtain its own contact address behind firewalls*/ int sal_ping(SalOp *op, const char *from, const char *to); +#define PAYLOAD_TYPE_FLAG_CAN_RECV PAYLOAD_TYPE_USER_FLAG_1 +#define PAYLOAD_TYPE_FLAG_CAN_SEND PAYLOAD_TYPE_USER_FLAG_2 + #define payload_type_set_number(pt,n) (pt)->user_data=(void*)((long)n); #define payload_type_get_number(pt) ((int)(long)(pt)->user_data) diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index fd184a40f..363adfdeb 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -509,6 +509,10 @@ static void sdp_process(SalOp *h){ } +int sal_call_is_offerer(const SalOp *h){ + return h->sdp_offering; +} + int sal_call_set_local_media_description(SalOp *h, SalMediaDescription *desc){ if (desc) sal_media_description_ref(desc);