mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-21 04:38:29 +00:00
Merge branch 'master' of git.linphone.org:linphone-private
This commit is contained in:
commit
f2acf7a8e8
4 changed files with 37 additions and 73 deletions
|
|
@ -65,11 +65,12 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCa
|
||||||
LinphoneAddress *addr=linphone_address_new(me);
|
LinphoneAddress *addr=linphone_address_new(me);
|
||||||
const char *username=linphone_address_get_username (addr);
|
const char *username=linphone_address_get_username (addr);
|
||||||
SalMediaDescription *md=sal_media_description_new();
|
SalMediaDescription *md=sal_media_description_new();
|
||||||
|
|
||||||
md->nstreams=1;
|
md->nstreams=1;
|
||||||
strncpy(md->addr,call->localip,sizeof(md->addr));
|
strncpy(md->addr,call->localip,sizeof(md->addr));
|
||||||
strncpy(md->username,username,sizeof(md->username));
|
strncpy(md->username,username,sizeof(md->username));
|
||||||
md->bandwidth=linphone_core_get_download_bandwidth(lc);
|
md->bandwidth=linphone_core_get_download_bandwidth(lc);
|
||||||
|
|
||||||
/*set audio capabilities */
|
/*set audio capabilities */
|
||||||
strncpy(md->streams[0].addr,call->localip,sizeof(md->streams[0].addr));
|
strncpy(md->streams[0].addr,call->localip,sizeof(md->streams[0].addr));
|
||||||
md->streams[0].port=call->audio_port;
|
md->streams[0].port=call->audio_port;
|
||||||
|
|
@ -81,8 +82,6 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCa
|
||||||
l=ms_list_append(l,pt);
|
l=ms_list_append(l,pt);
|
||||||
md->streams[0].payloads=l;
|
md->streams[0].payloads=l;
|
||||||
|
|
||||||
if (lc->dw_audio_bw>0)
|
|
||||||
md->streams[0].bandwidth=lc->dw_audio_bw;
|
|
||||||
|
|
||||||
if (call->params.has_video){
|
if (call->params.has_video){
|
||||||
md->nstreams++;
|
md->nstreams++;
|
||||||
|
|
@ -91,8 +90,6 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCa
|
||||||
md->streams[1].type=SalVideo;
|
md->streams[1].type=SalVideo;
|
||||||
l=make_codec_list(lc,lc->codecs_conf.video_codecs,0);
|
l=make_codec_list(lc,lc->codecs_conf.video_codecs,0);
|
||||||
md->streams[1].payloads=l;
|
md->streams[1].payloads=l;
|
||||||
if (lc->dw_video_bw)
|
|
||||||
md->streams[1].bandwidth=lc->dw_video_bw;
|
|
||||||
}
|
}
|
||||||
linphone_address_destroy(addr);
|
linphone_address_destroy(addr);
|
||||||
return md;
|
return md;
|
||||||
|
|
@ -716,12 +713,13 @@ static void post_configure_audio_streams(LinphoneCall*call){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static RtpProfile *make_profile(LinphoneCore *lc, const SalMediaDescription *md, const SalStreamDescription *desc, int *used_pt){
|
static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *md, const SalStreamDescription *desc, int *used_pt){
|
||||||
int bw;
|
int bw;
|
||||||
const MSList *elem;
|
const MSList *elem;
|
||||||
RtpProfile *prof=rtp_profile_new("Call profile");
|
RtpProfile *prof=rtp_profile_new("Call profile");
|
||||||
bool_t first=TRUE;
|
bool_t first=TRUE;
|
||||||
int remote_bw=0;
|
int remote_bw=0;
|
||||||
|
LinphoneCore *lc=call->core;
|
||||||
*used_pt=-1;
|
*used_pt=-1;
|
||||||
|
|
||||||
for(elem=desc->payloads;elem!=NULL;elem=elem->next){
|
for(elem=desc->payloads;elem!=NULL;elem=elem->next){
|
||||||
|
|
@ -730,7 +728,7 @@ static RtpProfile *make_profile(LinphoneCore *lc, const SalMediaDescription *md,
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
if (desc->type==SalAudio){
|
if (desc->type==SalAudio){
|
||||||
linphone_core_update_allocated_audio_bandwidth_in_call(lc,pt);
|
linphone_core_update_allocated_audio_bandwidth_in_call(call,pt);
|
||||||
}
|
}
|
||||||
*used_pt=payload_type_get_number(pt);
|
*used_pt=payload_type_get_number(pt);
|
||||||
first=FALSE;
|
first=FALSE;
|
||||||
|
|
@ -740,13 +738,13 @@ static RtpProfile *make_profile(LinphoneCore *lc, const SalMediaDescription *md,
|
||||||
/*case where b=AS is given globally, not per stream*/
|
/*case where b=AS is given globally, not per stream*/
|
||||||
remote_bw=md->bandwidth;
|
remote_bw=md->bandwidth;
|
||||||
if (desc->type==SalVideo){
|
if (desc->type==SalVideo){
|
||||||
remote_bw-=lc->audio_bw;
|
remote_bw-=call->audio_bw-10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc->type==SalAudio){
|
if (desc->type==SalAudio){
|
||||||
bw=get_min_bandwidth(lc->up_audio_bw,remote_bw);
|
bw=get_min_bandwidth(call->audio_bw,remote_bw);
|
||||||
}else bw=get_min_bandwidth(lc->up_video_bw,remote_bw);
|
}else bw=get_min_bandwidth(linphone_core_get_upload_bandwidth (lc)-call->audio_bw,remote_bw);
|
||||||
if (bw>0) pt->normal_bitrate=bw*1000;
|
if (bw>0) pt->normal_bitrate=bw*1000;
|
||||||
else if (desc->type==SalAudio){
|
else if (desc->type==SalAudio){
|
||||||
pt->normal_bitrate=-1;
|
pt->normal_bitrate=-1;
|
||||||
|
|
@ -801,7 +799,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
|
||||||
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
|
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
|
||||||
const char *playfile=lc->play_file;
|
const char *playfile=lc->play_file;
|
||||||
const char *recfile=lc->rec_file;
|
const char *recfile=lc->rec_file;
|
||||||
call->audio_profile=make_profile(lc,call->resultdesc,stream,&used_pt);
|
call->audio_profile=make_profile(call,call->resultdesc,stream,&used_pt);
|
||||||
if (used_pt!=-1){
|
if (used_pt!=-1){
|
||||||
if (playcard==NULL) {
|
if (playcard==NULL) {
|
||||||
ms_warning("No card defined for playback !");
|
ms_warning("No card defined for playback !");
|
||||||
|
|
@ -866,7 +864,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
|
||||||
call->current_params.has_video=FALSE;
|
call->current_params.has_video=FALSE;
|
||||||
if (stream && stream->dir!=SalStreamInactive) {
|
if (stream && stream->dir!=SalStreamInactive) {
|
||||||
const char *addr=stream->addr[0]!='\0' ? stream->addr : call->resultdesc->addr;
|
const char *addr=stream->addr[0]!='\0' ? stream->addr : call->resultdesc->addr;
|
||||||
call->video_profile=make_profile(lc,call->resultdesc,stream,&used_pt);
|
call->video_profile=make_profile(call,call->resultdesc,stream,&used_pt);
|
||||||
if (used_pt!=-1){
|
if (used_pt!=-1){
|
||||||
VideoStreamDir dir=VideoStreamSendRecv;
|
VideoStreamDir dir=VideoStreamSendRecv;
|
||||||
MSWebCam *cam=lc->video_conf.device;
|
MSWebCam *cam=lc->video_conf.device;
|
||||||
|
|
|
||||||
|
|
@ -816,13 +816,6 @@ static void autoreplier_config_init(LinphoneCore *lc)
|
||||||
*/
|
*/
|
||||||
void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw){
|
void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw){
|
||||||
lc->net_conf.download_bw=bw;
|
lc->net_conf.download_bw=bw;
|
||||||
if (bw==0){ /*infinite*/
|
|
||||||
lc->dw_audio_bw=-1;
|
|
||||||
lc->dw_video_bw=-1;
|
|
||||||
}else {
|
|
||||||
lc->dw_audio_bw=MIN(lc->audio_bw,bw);
|
|
||||||
lc->dw_video_bw=MAX(bw-lc->dw_audio_bw-10,0);/*-10: security margin*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -840,13 +833,6 @@ void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw){
|
||||||
*/
|
*/
|
||||||
void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw){
|
void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw){
|
||||||
lc->net_conf.upload_bw=bw;
|
lc->net_conf.upload_bw=bw;
|
||||||
if (bw==0){ /*infinite*/
|
|
||||||
lc->up_audio_bw=-1;
|
|
||||||
lc->up_video_bw=-1;
|
|
||||||
}else{
|
|
||||||
lc->up_audio_bw=MIN(lc->audio_bw,bw);
|
|
||||||
lc->up_video_bw=MAX(bw-lc->up_audio_bw-10,0);/*-10: security margin*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2212,7 +2198,7 @@ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const Linpho
|
||||||
**/
|
**/
|
||||||
int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call)
|
int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call)
|
||||||
{
|
{
|
||||||
LinphoneProxyConfig *cfg=NULL;
|
LinphoneProxyConfig *cfg=NULL,*dest_proxy=NULL;
|
||||||
const char *contact=NULL;
|
const char *contact=NULL;
|
||||||
SalOp *replaced;
|
SalOp *replaced;
|
||||||
SalMediaDescription *new_md;
|
SalMediaDescription *new_md;
|
||||||
|
|
@ -2267,8 +2253,15 @@ int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call)
|
||||||
}
|
}
|
||||||
|
|
||||||
linphone_core_get_default_proxy(lc,&cfg);
|
linphone_core_get_default_proxy(lc,&cfg);
|
||||||
|
dest_proxy=cfg;
|
||||||
|
dest_proxy=linphone_core_lookup_known_proxy(lc,call->log->to);
|
||||||
|
|
||||||
|
if (cfg!=dest_proxy && dest_proxy!=NULL) {
|
||||||
|
ms_message("Overriding default proxy setting for this call:");
|
||||||
|
ms_message("The used identity will be %s",linphone_proxy_config_get_identity(dest_proxy));
|
||||||
|
}
|
||||||
/*try to be best-effort in giving real local or routable contact address*/
|
/*try to be best-effort in giving real local or routable contact address*/
|
||||||
contact=get_fixed_contact(lc,call,cfg);
|
contact=get_fixed_contact(lc,call,dest_proxy);
|
||||||
if (contact)
|
if (contact)
|
||||||
sal_op_set_contact(call->op,contact);
|
sal_op_set_contact(call->op,contact);
|
||||||
|
|
||||||
|
|
@ -3964,14 +3957,6 @@ static PayloadType* find_payload_type_from_list(const char* type, int rate,const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printCodecs(const MSList* from) {
|
|
||||||
const MSList *elem;
|
|
||||||
for(elem=from;elem!=NULL;elem=elem->next){
|
|
||||||
PayloadType *pt=(PayloadType*)elem->data;
|
|
||||||
ms_message(payload_type_get_mime(pt));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get payload type from mime type and clock rate
|
* Get payload type from mime type and clock rate
|
||||||
* @ingroup media_parameters
|
* @ingroup media_parameters
|
||||||
|
|
|
||||||
|
|
@ -233,11 +233,8 @@ static double get_audio_payload_bandwidth(LinphoneCore *lc, const PayloadType *p
|
||||||
return packet_size*8.0*npacket;
|
return packet_size*8.0*npacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCore *lc, const PayloadType *pt){
|
void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt){
|
||||||
lc->audio_bw=(int)(get_audio_payload_bandwidth(lc,pt)/1000.0);
|
call->audio_bw=(int)(get_audio_payload_bandwidth(call->core,pt)/1000.0);
|
||||||
/*update*/
|
|
||||||
linphone_core_set_download_bandwidth(lc,lc->net_conf.download_bw);
|
|
||||||
linphone_core_set_upload_bandwidth(lc,lc->net_conf.upload_bw);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){
|
void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){
|
||||||
|
|
@ -254,7 +251,7 @@ void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max) {
|
if (max) {
|
||||||
linphone_core_update_allocated_audio_bandwidth_in_call(lc,max);
|
lc->audio_bw=(int)(get_audio_payload_bandwidth(lc,max)/1000.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,11 +275,6 @@ bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, Payl
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_VIDEO:
|
case PAYLOAD_VIDEO:
|
||||||
if (bandwidth_limit!=0) {/* infinite (-1) or strictly positive*/
|
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;
|
ret=TRUE;
|
||||||
}
|
}
|
||||||
else ret=FALSE;
|
else ret=FALSE;
|
||||||
|
|
@ -295,27 +287,25 @@ bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, Payl
|
||||||
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt)
|
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt)
|
||||||
{
|
{
|
||||||
double codec_band;
|
double codec_band;
|
||||||
int min_audio_bw;
|
int allowed_bw,video_bw;
|
||||||
int min_video_bw;
|
|
||||||
bool_t ret=FALSE;
|
bool_t ret=FALSE;
|
||||||
/*
|
|
||||||
update allocated audio bandwidth to allocate the remaining to video.
|
linphone_core_update_allocated_audio_bandwidth(lc);
|
||||||
This must be done outside calls, because after sdp negociation
|
allowed_bw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc),
|
||||||
the audio bandwidth is refined to the selected codec
|
|
||||||
*/
|
|
||||||
if (!linphone_core_in_call(lc)) linphone_core_update_allocated_audio_bandwidth(lc);
|
|
||||||
min_audio_bw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc),
|
|
||||||
linphone_core_get_upload_bandwidth(lc));
|
linphone_core_get_upload_bandwidth(lc));
|
||||||
if (min_audio_bw==0) min_audio_bw=-1;
|
if (allowed_bw==0) {
|
||||||
min_video_bw=get_min_bandwidth(lc->dw_video_bw,lc->up_video_bw);
|
allowed_bw=-1;
|
||||||
|
video_bw=1500; /*around 1.5 Mbit/s*/
|
||||||
|
}else
|
||||||
|
video_bw=allowed_bw-lc->audio_bw-10;
|
||||||
|
|
||||||
switch (pt->type){
|
switch (pt->type){
|
||||||
case PAYLOAD_AUDIO_CONTINUOUS:
|
case PAYLOAD_AUDIO_CONTINUOUS:
|
||||||
case PAYLOAD_AUDIO_PACKETIZED:
|
case PAYLOAD_AUDIO_PACKETIZED:
|
||||||
codec_band=get_audio_payload_bandwidth(lc,pt);
|
codec_band=get_audio_payload_bandwidth(lc,pt);
|
||||||
ret=bandwidth_is_greater(min_audio_bw*1000,codec_band);
|
ret=bandwidth_is_greater(allowed_bw*1000,codec_band);
|
||||||
/*hack to avoid using uwb codecs when having low bitrate and video*/
|
/*hack to avoid using uwb codecs when having low bitrate and video*/
|
||||||
if (bandwidth_is_greater(199,min_audio_bw)){
|
if (bandwidth_is_greater(199,allowed_bw)){
|
||||||
if (linphone_core_video_enabled(lc) && pt->clock_rate>16000){
|
if (linphone_core_video_enabled(lc) && pt->clock_rate>16000){
|
||||||
ret=FALSE;
|
ret=FALSE;
|
||||||
}
|
}
|
||||||
|
|
@ -323,19 +313,13 @@ bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType
|
||||||
//ms_message("Payload %s: %g",pt->mime_type,codec_band);
|
//ms_message("Payload %s: %g",pt->mime_type,codec_band);
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_VIDEO:
|
case PAYLOAD_VIDEO:
|
||||||
if (min_video_bw!=0) {/* infinite (-1) or strictly positive*/
|
if (video_bw>0){
|
||||||
/*let the video use all the bandwidth minus the maximum bandwidth used by audio */
|
pt->normal_bitrate=video_bw*1000;
|
||||||
if (min_video_bw>0)
|
|
||||||
pt->normal_bitrate=min_video_bw*1000;
|
|
||||||
else
|
|
||||||
pt->normal_bitrate=1500000; /*around 1.5 Mbit/s*/
|
|
||||||
ret=TRUE;
|
ret=TRUE;
|
||||||
}
|
}
|
||||||
else ret=FALSE;
|
else ret=FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*if (!ret) ms_warning("Payload %s is not usable with your internet connection.",pt->mime_type);*/
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ struct _LinphoneCall
|
||||||
LinphoneCallParams params;
|
LinphoneCallParams params;
|
||||||
LinphoneCallParams current_params;
|
LinphoneCallParams current_params;
|
||||||
int up_bw; /*upload bandwidth setting at the time the call is started. Used to detect if it changes during a call */
|
int up_bw; /*upload bandwidth setting at the time the call is started. Used to detect if it changes during a call */
|
||||||
|
int audio_bw; /*upload bandwidth used by audio */
|
||||||
bool_t refer_pending;
|
bool_t refer_pending;
|
||||||
bool_t media_pending;
|
bool_t media_pending;
|
||||||
bool_t audio_muted;
|
bool_t audio_muted;
|
||||||
|
|
@ -171,7 +172,7 @@ void linphone_subscription_closed(LinphoneCore *lc, SalOp *op);
|
||||||
MSList *linphone_find_friend(MSList *fl, const LinphoneAddress *fri, LinphoneFriend **lf);
|
MSList *linphone_find_friend(MSList *fl, const LinphoneAddress *fri, LinphoneFriend **lf);
|
||||||
|
|
||||||
void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc);
|
void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc);
|
||||||
void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCore *lc, const PayloadType *pt);
|
void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt);
|
||||||
void linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call);
|
void linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call);
|
||||||
|
|
||||||
void linphone_core_send_initial_subscribes(LinphoneCore *lc);
|
void linphone_core_send_initial_subscribes(LinphoneCore *lc);
|
||||||
|
|
@ -412,10 +413,6 @@ struct _LinphoneCore
|
||||||
char *play_file;
|
char *play_file;
|
||||||
char *rec_file;
|
char *rec_file;
|
||||||
time_t prevtime;
|
time_t prevtime;
|
||||||
int dw_audio_bw;
|
|
||||||
int up_audio_bw;
|
|
||||||
int dw_video_bw;
|
|
||||||
int up_video_bw;
|
|
||||||
int audio_bw;
|
int audio_bw;
|
||||||
LinphoneWaitingCallback wait_cb;
|
LinphoneWaitingCallback wait_cb;
|
||||||
void *wait_ctx;
|
void *wait_ctx;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue