forked from mirrors/linphone-iphone
cleanups and fix broken resume
This commit is contained in:
parent
f9cff9304f
commit
361c33536e
11 changed files with 88 additions and 40 deletions
|
|
@ -1,6 +1,6 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT([linphone],[3.3.99.9],[linphone-developers@nongnu.org])
|
||||
AC_INIT([linphone],[3.3.99.10],[linphone-developers@nongnu.org])
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_CONFIG_SRCDIR([coreapi/linphonecore.c])
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details);
|
||||
|
||||
static bool_t media_parameters_changed(LinphoneCall *call, SalMediaDescription *oldmd, SalMediaDescription *newmd){
|
||||
return !sal_media_description_equals(oldmd,newmd) || call->up_bw!=linphone_core_get_upload_bandwidth(call->core);
|
||||
}
|
||||
|
||||
void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md){
|
||||
SalMediaDescription *oldmd=call->resultdesc;
|
||||
|
||||
|
|
@ -44,7 +48,7 @@ void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMedia
|
|||
if (call->audiostream && call->audiostream->ticker){
|
||||
/* we already started media: check if we really need to restart it*/
|
||||
if (oldmd){
|
||||
if (sal_media_description_equals(oldmd,new_md) && !call->playing_ringbacktone){
|
||||
if (!media_parameters_changed(call,oldmd,new_md) && !call->playing_ringbacktone){
|
||||
sal_media_description_unref(oldmd);
|
||||
if (call->all_muted){
|
||||
ms_message("Early media finished, unmuting inputs...");
|
||||
|
|
|
|||
|
|
@ -40,21 +40,19 @@ static MSWebCam *get_nowebcam_device(){
|
|||
#endif
|
||||
|
||||
|
||||
static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, bool_t only_one_codec){
|
||||
static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs){
|
||||
MSList *l=NULL;
|
||||
const MSList *it;
|
||||
for(it=codecs;it!=NULL;it=it->next){
|
||||
PayloadType *pt=(PayloadType*)it->data;
|
||||
if ((pt->flags & PAYLOAD_TYPE_ENABLED) && linphone_core_check_payload_type_usability(lc,pt)){
|
||||
l=ms_list_append(l,payload_type_clone(pt));
|
||||
if (only_one_codec) break;
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
SalMediaDescription *create_local_media_description(LinphoneCore *lc,
|
||||
LinphoneCall *call, bool_t with_video, bool_t only_one_codec){
|
||||
SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCall *call){
|
||||
MSList *l;
|
||||
PayloadType *pt;
|
||||
const char *me=linphone_core_get_identity(lc);
|
||||
|
|
@ -72,7 +70,7 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc,
|
|||
md->streams[0].proto=SalProtoRtpAvp;
|
||||
md->streams[0].type=SalAudio;
|
||||
md->streams[0].ptime=lc->net_conf.down_ptime;
|
||||
l=make_codec_list(lc,lc->codecs_conf.audio_codecs,only_one_codec);
|
||||
l=make_codec_list(lc,lc->codecs_conf.audio_codecs);
|
||||
pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event"));
|
||||
l=ms_list_append(l,pt);
|
||||
md->streams[0].payloads=l;
|
||||
|
|
@ -80,12 +78,12 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc,
|
|||
if (lc->dw_audio_bw>0)
|
||||
md->streams[0].bandwidth=lc->dw_audio_bw;
|
||||
|
||||
if (with_video){
|
||||
if (call->params.has_video){
|
||||
md->nstreams++;
|
||||
md->streams[1].port=call->video_port;
|
||||
md->streams[1].proto=SalProtoRtpAvp;
|
||||
md->streams[1].type=SalVideo;
|
||||
l=make_codec_list(lc,lc->codecs_conf.video_codecs,only_one_codec);
|
||||
l=make_codec_list(lc,lc->codecs_conf.video_codecs);
|
||||
md->streams[1].payloads=l;
|
||||
if (lc->dw_video_bw)
|
||||
md->streams[1].bandwidth=lc->dw_video_bw;
|
||||
|
|
@ -156,7 +154,7 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr
|
|||
linphone_core_get_local_ip(lc,linphone_address_get_domain(to),call->localip);
|
||||
linphone_call_init_common(call,from,to);
|
||||
call->params=*params;
|
||||
call->localdesc=create_local_media_description (lc,call,params->has_video,FALSE);
|
||||
call->localdesc=create_local_media_description (lc,call);
|
||||
call->camera_active=params->has_video;
|
||||
if (linphone_core_get_firewall_policy(call->core)==LinphonePolicyUseStun)
|
||||
linphone_core_run_stun_tests(call->core,call);
|
||||
|
|
@ -194,8 +192,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
|
|||
linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip);
|
||||
linphone_call_init_common(call, from, to);
|
||||
call->params.has_video=linphone_core_video_enabled(lc);
|
||||
call->localdesc=create_local_media_description (lc,call,
|
||||
call->params.has_video,lc->sip_conf.only_one_codec);
|
||||
call->localdesc=create_local_media_description (lc,call);
|
||||
call->camera_active=call->params.has_video;
|
||||
if (linphone_core_get_firewall_policy(call->core)==LinphonePolicyUseStun)
|
||||
linphone_core_run_stun_tests(call->core,call);
|
||||
|
|
@ -905,6 +902,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
|
|||
#endif
|
||||
call->all_muted=all_inputs_muted;
|
||||
call->playing_ringbacktone=send_ringbacktone;
|
||||
call->up_bw=linphone_core_get_upload_bandwidth(lc);
|
||||
|
||||
goto end;
|
||||
end:
|
||||
|
|
|
|||
|
|
@ -486,7 +486,6 @@ static void sip_config_read(LinphoneCore *lc)
|
|||
sal_use_session_timers(lc->sal,200);
|
||||
}
|
||||
|
||||
|
||||
tmp=lp_config_get_int(lc->config,"sip","use_rfc2833",0);
|
||||
linphone_core_set_use_rfc2833_for_dtmf(lc,tmp);
|
||||
|
||||
|
|
@ -562,21 +561,16 @@ static void sip_config_read(LinphoneCore *lc)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0);
|
||||
|
||||
/*for tuning or test*/
|
||||
lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0);
|
||||
lc->sip_conf.only_one_codec=lp_config_get_int(lc->config,"sip","only_one_codec",0);
|
||||
lc->sip_conf.register_only_when_network_is_up=
|
||||
lp_config_get_int(lc->config,"sip","register_only_when_network_is_up",1);
|
||||
lc->sip_conf.ping_with_options=lp_config_get_int(lc->config,"sip","ping_with_options",1);
|
||||
lc->sip_conf.auto_net_state_mon=lp_config_get_int(lc->config,"sip","auto_net_state_mon",1);
|
||||
lc->sip_conf.keepalive_period=lp_config_get_int(lc->config,"sip","keepalive_period",10000);
|
||||
sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period);
|
||||
sal_use_one_matching_codec_policy(lc->sal,lp_config_get_int(lc->config,"sip","only_one_codec",0));
|
||||
}
|
||||
|
||||
static void rtp_config_read(LinphoneCore *lc)
|
||||
|
|
@ -2193,8 +2187,8 @@ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, LinphoneCall
|
|||
|
||||
if (call->localdesc)
|
||||
sal_media_description_unref(call->localdesc);
|
||||
call->localdesc=create_local_media_description (lc,call,
|
||||
params->has_video,FALSE);
|
||||
call->params=*params;
|
||||
call->localdesc=create_local_media_description (lc,call);
|
||||
call->camera_active=params->has_video;
|
||||
if (lc->vtable.display_status)
|
||||
lc->vtable.display_status(lc,_("Modifying call parameters..."));
|
||||
|
|
|
|||
|
|
@ -258,6 +258,41 @@ void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){
|
|||
}
|
||||
}
|
||||
|
||||
bool_t linphone_core_is_payload_type_usable(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit)
|
||||
{
|
||||
double codec_band;
|
||||
bool_t ret=FALSE;
|
||||
|
||||
switch (pt->type){
|
||||
case PAYLOAD_AUDIO_CONTINUOUS:
|
||||
case PAYLOAD_AUDIO_PACKETIZED:
|
||||
codec_band=get_audio_payload_bandwidth(lc,pt);
|
||||
ret=bandwidth_is_greater(bandwidth_limit*1000,codec_band);
|
||||
/*hack to avoid using uwb codecs when having low bitrate and video*/
|
||||
if (bandwidth_is_greater(199,bandwidth_limit)){
|
||||
if (linphone_core_video_enabled(lc) && pt->clock_rate>16000){
|
||||
ret=FALSE;
|
||||
}
|
||||
}
|
||||
//ms_message("Payload %s: %g",pt->mime_type,codec_band);
|
||||
break;
|
||||
case PAYLOAD_VIDEO:
|
||||
if (bandwidth_limit!=0) {/* infinite (-1) or strictly positive*/
|
||||
/*let the video use all the bandwidth minus the maximum bandwidth used by audio */
|
||||
if (bandwidth_limit>0)
|
||||
pt->normal_bitrate=bandwidth_limit*1000;
|
||||
else
|
||||
pt->normal_bitrate=1500000; /*around 1.5 Mbit/s*/
|
||||
ret=TRUE;
|
||||
}
|
||||
else ret=FALSE;
|
||||
break;
|
||||
}
|
||||
/*if (!ret) ms_warning("Payload %s is not usable with your internet connection.",pt->mime_type);*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* return TRUE if codec can be used with bandwidth, FALSE else*/
|
||||
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "sal.h"
|
||||
#include "offeranswer.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;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static PayloadType * find_payload_type_best_match(const MSList *l, const PayloadType *refpt){
|
||||
PayloadType *pt;
|
||||
|
|
@ -53,10 +60,12 @@ static PayloadType * find_payload_type_best_match(const MSList *l, const Payload
|
|||
return candidate;
|
||||
}
|
||||
|
||||
static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t reading_response){
|
||||
static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t reading_response, bool_t one_matching_codec){
|
||||
const MSList *e2;
|
||||
MSList *res=NULL;
|
||||
PayloadType *matched;
|
||||
bool_t found_codec=FALSE;
|
||||
|
||||
for(e2=remote;e2!=NULL;e2=e2->next){
|
||||
PayloadType *p2=(PayloadType*)e2->data;
|
||||
matched=find_payload_type_best_match(local,p2);
|
||||
|
|
@ -64,6 +73,14 @@ static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t
|
|||
PayloadType *newp;
|
||||
int local_number=payload_type_get_number(matched);
|
||||
int remote_number=payload_type_get_number(p2);
|
||||
|
||||
if (one_matching_codec){
|
||||
if (strcasecmp(matched->mime_type,"telephone-event")!=0){
|
||||
if (found_codec){/* we have found a real codec already*/
|
||||
continue; /*this codec won't be added*/
|
||||
}else found_codec=TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
newp=payload_type_clone(matched);
|
||||
if (p2->send_fmtp)
|
||||
|
|
@ -90,13 +107,7 @@ static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t
|
|||
return res;
|
||||
}
|
||||
|
||||
static bool_t only_telephone_event(const MSList *l){
|
||||
PayloadType *p=(PayloadType*)l->data;
|
||||
if (strcasecmp(p->mime_type,"telephone-event")!=0){
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static SalStreamDir compute_dir(SalStreamDir local, SalStreamDir answered){
|
||||
SalStreamDir res=local;
|
||||
|
|
@ -117,7 +128,7 @@ static void initiate_outgoing(const SalStreamDescription *local_offer,
|
|||
const SalStreamDescription *remote_answer,
|
||||
SalStreamDescription *result){
|
||||
if (remote_answer->port!=0)
|
||||
result->payloads=match_payloads(local_offer->payloads,remote_answer->payloads,TRUE);
|
||||
result->payloads=match_payloads(local_offer->payloads,remote_answer->payloads,TRUE,FALSE);
|
||||
result->proto=local_offer->proto;
|
||||
result->type=local_offer->type;
|
||||
result->dir=compute_dir(local_offer->dir,remote_answer->dir);
|
||||
|
|
@ -135,8 +146,8 @@ static void initiate_outgoing(const SalStreamDescription *local_offer,
|
|||
|
||||
static void initiate_incoming(const SalStreamDescription *local_cap,
|
||||
const SalStreamDescription *remote_offer,
|
||||
SalStreamDescription *result){
|
||||
result->payloads=match_payloads(local_cap->payloads,remote_offer->payloads, FALSE);
|
||||
SalStreamDescription *result, bool_t one_matching_codec){
|
||||
result->payloads=match_payloads(local_cap->payloads,remote_offer->payloads, FALSE, one_matching_codec);
|
||||
result->proto=local_cap->proto;
|
||||
result->type=local_cap->type;
|
||||
if (remote_offer->dir==SalStreamSendOnly)
|
||||
|
|
@ -187,7 +198,7 @@ int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
|
|||
**/
|
||||
int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities,
|
||||
const SalMediaDescription *remote_offer,
|
||||
SalMediaDescription *result){
|
||||
SalMediaDescription *result, bool_t one_matching_codec){
|
||||
int i,j;
|
||||
const SalStreamDescription *ls,*rs;
|
||||
|
||||
|
|
@ -196,7 +207,7 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities
|
|||
ms_message("Processing for stream %i",i);
|
||||
ls=sal_media_description_find_stream((SalMediaDescription*)local_capabilities,rs->proto,rs->type);
|
||||
if (ls){
|
||||
initiate_incoming(ls,rs,&result->streams[j]);
|
||||
initiate_incoming(ls,rs,&result->streams[j],one_matching_codec);
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer,
|
|||
**/
|
||||
int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities,
|
||||
const SalMediaDescription *remote_offer,
|
||||
SalMediaDescription *result);
|
||||
SalMediaDescription *result, bool_t one_matching_codec);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ struct _LinphoneCall
|
|||
struct _VideoStream *videostream;
|
||||
char *refer_to;
|
||||
LinphoneCallParams params;
|
||||
int up_bw; /*upload bandwidth setting at the time the call is started. Used to detect if it changes during a call */
|
||||
bool_t refer_pending;
|
||||
bool_t media_pending;
|
||||
bool_t audio_muted;
|
||||
|
|
@ -280,7 +281,6 @@ typedef struct sip_config
|
|||
bool_t loopback_only;
|
||||
bool_t ipv6_enabled;
|
||||
bool_t sdp_200_ack;
|
||||
bool_t only_one_codec; /*in SDP answers*/
|
||||
bool_t register_only_when_network_is_up;
|
||||
bool_t ping_with_options;
|
||||
bool_t auto_net_state_mon;
|
||||
|
|
@ -438,8 +438,8 @@ int linphone_core_get_calls_nb(const LinphoneCore *lc);
|
|||
|
||||
void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
|
||||
|
||||
SalMediaDescription *create_local_media_description(LinphoneCore *lc,
|
||||
LinphoneCall *call, bool_t with_video, bool_t only_one_codec);
|
||||
SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCall *call);
|
||||
|
||||
void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md);
|
||||
#define linphone_core_ready(lc) ((lc)->state!=LinphoneGlobalStartup)
|
||||
void _linphone_core_configure_resolver();
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ void sal_set_user_agent(Sal *ctx, const char *user_agent);
|
|||
/*keepalive period in ms*/
|
||||
void sal_set_keepalive_period(Sal *ctx,unsigned int value);
|
||||
void sal_use_session_timers(Sal *ctx, int expires);
|
||||
void sal_use_one_matching_codec_policy(Sal *ctx, bool_t one_matching_codec);
|
||||
int sal_iterate(Sal *sal);
|
||||
MSList * sal_get_pending_auths(Sal *sal);
|
||||
|
||||
|
|
|
|||
|
|
@ -379,6 +379,10 @@ void sal_use_session_timers(Sal *ctx, int expires){
|
|||
ctx->session_expires=expires;
|
||||
}
|
||||
|
||||
void sal_use_one_matching_codec_policy(Sal *ctx, bool_t one_matching_codec){
|
||||
ctx->one_matching_codec=one_matching_codec;
|
||||
}
|
||||
|
||||
MSList *sal_get_pending_auths(Sal *sal){
|
||||
return ms_list_copy(sal->pending_auths);
|
||||
}
|
||||
|
|
@ -449,7 +453,7 @@ static void sdp_process(SalOp *h){
|
|||
offer_answer_initiate_outgoing(h->base.local_media,h->base.remote_media,h->result);
|
||||
}else{
|
||||
int i;
|
||||
offer_answer_initiate_incoming(h->base.local_media,h->base.remote_media,h->result);
|
||||
offer_answer_initiate_incoming(h->base.local_media,h->base.remote_media,h->result,h->base.root->one_matching_codec);
|
||||
h->sdp_answer=media_description_to_sdp(h->result);
|
||||
strcpy(h->result->addr,h->base.remote_media->addr);
|
||||
h->result->bandwidth=h->base.remote_media->bandwidth;
|
||||
|
|
@ -1955,7 +1959,7 @@ int sal_call_hold(SalOp *h, bool_t holdon)
|
|||
osip_message_t *reinvite=NULL;
|
||||
if(eXosip_call_build_request(h->did,"INVITE",&reinvite) != OSIP_SUCCESS || reinvite==NULL)
|
||||
return -1;
|
||||
osip_message_set_subject(reinvite,osip_strdup("Phone Call Hold"));
|
||||
osip_message_set_subject(reinvite,holdon ? "Phone call hold" : "Phone call resume" );
|
||||
osip_message_set_allow(reinvite, "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
|
||||
if (h->base.root->session_expires!=0){
|
||||
osip_message_set_header(reinvite, "Session-expires", "200");
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ struct Sal{
|
|||
int session_expires;
|
||||
int keepalive_period;
|
||||
void *up;
|
||||
bool_t one_matching_codec;
|
||||
};
|
||||
|
||||
struct SalOp{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue