diff --git a/linphone/coreapi/exevents.c b/linphone/coreapi/exevents.c index 7fce6f7e8..a6fe9e876 100644 --- a/linphone/coreapi/exevents.c +++ b/linphone/coreapi/exevents.c @@ -595,8 +595,6 @@ SupportLevel linphone_payload_is_supported(LinphoneCore *lc, sdp_payload_t *payl /*limit to upload bandwidth if exist, else no limit*/ rtppayload->normal_bitrate=(ubw>0)? 1000*ubw : -1; } - /* but anyway give our download bandwidth constraint*/ - payload->b_as_bandwidth=(dbw>0) ? dbw : 0; if (payload->a_fmtp!=NULL){ payload_type_set_send_fmtp(rtppayload,payload->a_fmtp); } @@ -657,7 +655,9 @@ int linphone_accept_audio_offer(sdp_context_t *ctx,sdp_payload_t *payload) } params->initialized=1; /* we can now update the allocated bandwidth for audio, and then video*/ - linphone_core_update_allocated_audio_bandwidth(lc,lpt); + linphone_core_update_allocated_audio_bandwidth_in_call(lc,lpt); + /* give our download bandwidth constraint*/ + payload->b_as_bandwidth=(lc->dw_audio_bw>0) ? lc->dw_audio_bw : 0; }else{ /* refuse all other audio lines*/ if(params->line!=payload->line) return -1; @@ -710,6 +710,7 @@ int linphone_accept_video_offer(sdp_context_t *ctx,sdp_payload_t *payload) params->remotertcpport=params->remoteport+1; } params->initialized=1; + payload->b_as_bandwidth=(lc->dw_video_bw>0) ? lc->dw_video_bw : 0; }else{ /* refuse all other video lines*/ if(params->line!=payload->line) return -1; @@ -752,7 +753,7 @@ int linphone_read_audio_answer(sdp_context_t *ctx,sdp_payload_t *payload) } params->initialized=1; /* we can now update the allocated bandwidth for audio, and then video*/ - linphone_core_update_allocated_audio_bandwidth(lc,lpt); + linphone_core_update_allocated_audio_bandwidth_in_call(lc,lpt); } } return 0; diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c index 8115dd31a..9a4f42a9b 100644 --- a/linphone/coreapi/linphonecore.c +++ b/linphone/coreapi/linphonecore.c @@ -153,6 +153,7 @@ void linphone_call_destroy(LinphoneCall *obj) { linphone_core_notify_all_friends(obj->core,obj->core->prev_mode); linphone_call_log_completed(obj->log,obj); + linphone_core_update_allocated_audio_bandwidth(obj->core); if (obj->profile!=NULL && obj->profile!=obj->core->local_profile) rtp_profile_destroy(obj->profile); if (obj->sdpctx!=NULL) sdp_context_free(obj->sdpctx); ms_free(obj); @@ -595,17 +596,8 @@ void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw){ lc->dw_audio_bw=-1; lc->dw_video_bw=-1; }else { - if (bw>=256){ - lc->dw_audio_bw=80; - }else if (bw>=128){ - if (linphone_core_video_enabled(lc)) - lc->dw_audio_bw=30; - else - lc->dw_audio_bw=bw; - }else{ - lc->dw_audio_bw=bw; - } - lc->dw_video_bw=bw-lc->dw_audio_bw; + lc->dw_audio_bw=MIN(lc->audio_bw,bw); + lc->dw_video_bw=MAX(bw-lc->dw_audio_bw-10,0);/*-10: security margin*/ } } @@ -614,16 +606,10 @@ void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw){ if (bw==0){ /*infinite*/ lc->up_audio_bw=-1; lc->up_video_bw=-1; - return; - }else if (bw>=128){ - if (linphone_core_video_enabled(lc)) - lc->up_audio_bw=lc->audio_bw; - else - lc->up_audio_bw=bw; }else{ - lc->up_audio_bw=bw; + lc->up_audio_bw=MIN(lc->audio_bw,bw); + lc->up_video_bw=MAX(bw-lc->up_audio_bw-10,0);/*-10: security margin*/ } - lc->up_video_bw=bw-lc->up_audio_bw-10;/*-10: security margin*/ } int linphone_core_get_download_bandwidth(const LinphoneCore *lc){ @@ -2006,9 +1992,11 @@ const char *linphone_core_get_video_device(const LinphoneCore *lc){ } static MSVideoSizeDef supported_resolutions[]={ + { MS_VIDEO_SIZE_SVGA , "svga" }, { MS_VIDEO_SIZE_4CIF , "4cif" }, { MS_VIDEO_SIZE_VGA , "vga" }, { MS_VIDEO_SIZE_CIF , "cif" }, + { MS_VIDEO_SIZE_QVGA , "qvga" }, { MS_VIDEO_SIZE_QCIF , "qcif" }, { {0,0} , NULL } }; diff --git a/linphone/coreapi/misc.c b/linphone/coreapi/misc.c index e61332b23..00cf70d8b 100644 --- a/linphone/coreapi/misc.c +++ b/linphone/coreapi/misc.c @@ -195,13 +195,14 @@ static double get_audio_payload_bandwidth(const PayloadType *pt){ return packet_size*8.0*npacket; } -void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc, const PayloadType *pt){ +void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCore *lc, const PayloadType *pt){ lc->audio_bw=(int)(get_audio_payload_bandwidth(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); } -static void update_allocated_audio_bandwidth(LinphoneCore *lc){ +void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){ const MSList *elem; PayloadType *max=NULL; for(elem=linphone_core_get_audio_codecs(lc);elem!=NULL;elem=elem->next){ @@ -214,7 +215,7 @@ static void update_allocated_audio_bandwidth(LinphoneCore *lc){ } } if (max) { - linphone_core_update_allocated_audio_bandwidth(lc,max); + linphone_core_update_allocated_audio_bandwidth_in_call(lc,max); } } @@ -230,7 +231,7 @@ bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType This must be done outside calls, because after sdp negociation the audio bandwidth is refined to the selected codec */ - if (!linphone_core_in_call(lc)) update_allocated_audio_bandwidth(lc); + 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)); if (min_audio_bw==0) min_audio_bw=-1; @@ -249,7 +250,7 @@ bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType if (min_video_bw>0) pt->normal_bitrate=min_video_bw*1000; else - pt->normal_bitrate=512000; + pt->normal_bitrate=1500000; /*around 1.5 Mbit/s*/ ret=TRUE; } else ret=FALSE; @@ -389,6 +390,7 @@ void linphone_core_setup_local_rtp_profile(LinphoneCore *lc) /* set the fixed lists instead:*/ lc->codecs_conf.audio_codecs=audiopt; lc->codecs_conf.video_codecs=videopt; + linphone_core_update_allocated_audio_bandwidth(lc); } int from_2char_without_params(osip_from_t *from,char **str) diff --git a/linphone/coreapi/private.h b/linphone/coreapi/private.h index 45c79d600..049ac38b3 100644 --- a/linphone/coreapi/private.h +++ b/linphone/coreapi/private.h @@ -118,7 +118,8 @@ MSList *find_friend(MSList *fl, const osip_from_t *friend, LinphoneFriend **lf); LinphoneFriend *linphone_find_friend_by_nid(MSList *l, int nid); LinphoneFriend *linphone_find_friend_by_sid(MSList *l, int sid); -void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc, const PayloadType *pt); +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_run_stun_tests(LinphoneCore *lc, LinphoneCall *call); #endif /* _PRIVATE_H */ diff --git a/linphone/coreapi/sdphandler.c b/linphone/coreapi/sdphandler.c index e83af1a17..abded94c8 100644 --- a/linphone/coreapi/sdphandler.c +++ b/linphone/coreapi/sdphandler.c @@ -310,6 +310,7 @@ sdp_context_get_answer ( sdp_context_t *ctx,sdp_message_t *remote) int i, j, ncodec, m_lines_accepted = 0; int err; sdp_payload_t payload; + sdp_payload_t init_payload; sdp_handler_t *sdph=ctx->handler; sdp_bandwidth_t *sbw=NULL; char *relay; @@ -327,29 +328,28 @@ sdp_context_get_answer ( sdp_context_t *ctx,sdp_message_t *remote) answer = sdp_context_generate_template (ctx); /* for each m= line */ - for (i = 0; !sdp_message_endof_media (remote, i); i++) - { - sdp_payload_init(&payload); + for (i = 0; !sdp_message_endof_media (remote, i); i++){ + sdp_payload_init(&init_payload); mtype = sdp_message_m_media_get (remote, i); proto = sdp_message_m_proto_get (remote, i); port = sdp_message_m_port_get (remote, i); - payload.remoteport = osip_atoi (port); - payload.proto = proto; - payload.line = i; - payload.c_addr = sdp_message_c_addr_get (remote, i, 0); - if (payload.c_addr == NULL) - payload.c_addr = sdp_message_c_addr_get (remote, -1, 0); + init_payload.remoteport = osip_atoi (port); + init_payload.proto = proto; + init_payload.line = i; + init_payload.c_addr = sdp_message_c_addr_get (remote, i, 0); + if (init_payload.c_addr == NULL) + init_payload.c_addr = sdp_message_c_addr_get (remote, -1, 0); /*parse relay address if given*/ relay=sdp_message_a_attr_value_get(remote,i,"relay-addr"); if (relay){ - payload.relay_host=parse_relay_addr(relay,&payload.relay_port); + init_payload.relay_host=parse_relay_addr(relay,&init_payload.relay_port); } - payload.relay_session_id=sdp_message_a_attr_value_get(remote,i,"relay-session-id"); + init_payload.relay_session_id=sdp_message_a_attr_value_get(remote,i,"relay-session-id"); /* get application specific bandwidth, if any */ for(j=0;(sbw=sdp_message_bandwidth_get(remote,i,j))!=NULL;j++){ - if (strcasecmp(sbw->b_bwtype,"AS")==0) payload.b_as_bandwidth=atoi(sbw->b_bandwidth); + if (strcasecmp(sbw->b_bwtype,"AS")==0) init_payload.b_as_bandwidth=atoi(sbw->b_bandwidth); } - payload.a_ptime=_sdp_message_get_a_ptime(remote,i); + init_payload.a_ptime=_sdp_message_get_a_ptime(remote,i); if (keywordcmp ("audio", mtype) == 0) { if (sdph->accept_audio_codecs != NULL) @@ -361,6 +361,7 @@ sdp_context_get_answer ( sdp_context_t *ctx,sdp_message_t *remote) sdp_message_m_payload_get (remote, i, j)) != NULL); j++) { + memcpy(&payload,&init_payload,sizeof(payload)); payload.pt = osip_atoi (pt); /* get the rtpmap associated to this codec, if any */ payload.a_rtpmap = @@ -469,6 +470,7 @@ sdp_context_get_answer ( sdp_context_t *ctx,sdp_message_t *remote) sdp_message_m_payload_get (remote, i, j)) != NULL); j++) { + memcpy(&payload,&init_payload,sizeof(payload)); payload.pt = osip_atoi (pt); /* get the rtpmap associated to this codec, if any */ payload.a_rtpmap = diff --git a/linphone/mediastreamer2/include/mediastreamer2/msvideo.h b/linphone/mediastreamer2/include/mediastreamer2/msvideo.h index db9dc4faa..acc889966 100644 --- a/linphone/mediastreamer2/include/mediastreamer2/msvideo.h +++ b/linphone/mediastreamer2/include/mediastreamer2/msvideo.h @@ -45,15 +45,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MS_VIDEO_SIZE_NS1_W 324 #define MS_VIDEO_SIZE_NS1_H 248 -#define MS_VIDEO_SIZE_1024_W 1024 -#define MS_VIDEO_SIZE_1024_H 768 +#define MS_VIDEO_SIZE_SVGA_W 800 +#define MS_VIDEO_SIZE_SVGA_H 600 -#define MS_VIDEO_SIZE_800X600_W 800 -#define MS_VIDEO_SIZE_800X600_H 600 +#define MS_VIDEO_SIZE_XGA_W 1024 +#define MS_VIDEO_SIZE_XGA_H 768 #define MS_VIDEO_SIZE_MAX_W MS_VIDEO_SIZE_1024_W #define MS_VIDEO_SIZE_MAX_H MS_VIDEO_SIZE_1024_H + /* those structs are part of the ABI: don't change their size otherwise binary plugins will be broken*/ typedef struct MSVideoSize{ @@ -76,10 +77,18 @@ typedef struct MSRect{ #define MS_VIDEO_SIZE_NS1 (MSVideoSize){MS_VIDEO_SIZE_NS1_W,MS_VIDEO_SIZE_NS1_H} -#define MS_VIDEO_SIZE_1024 (MSVideoSize){MS_VIDEO_SIZE_1024_W, MS_VIDEO_SIZE_1024_H} +#define MS_VIDEO_SIZE_XGA (MSVideoSize){MS_VIDEO_SIZE_XGA_W, MS_VIDEO_SIZE_XGA_H} -#define MS_VIDEO_SIZE_800X600 (MSVideoSize){MS_VIDEO_SIZE_800X600_W, MS_VIDEO_SIZE_800X600_H} +#define MS_VIDEO_SIZE_SVGA (MSVideoSize){MS_VIDEO_SIZE_SVGA_W, MS_VIDEO_SIZE_SVGA_H} +/*deprecated: use MS_VIDEO_SIZE_SVGA*/ +#define MS_VIDEO_SIZE_800X600_W MS_VIDEO_SIZE_SVGA_W +#define MS_VIDEO_SIZE_800X600_H MS_VIDEO_SIZE_SVGA_H +#define MS_VIDEO_SIZE_800X600 MS_VIDEO_SIZE_SVGA +/*deprecated use MS_VIDEO_SIZE_XGA*/ +#define MS_VIDEO_SIZE_1024_W 1024 +#define MS_VIDEO_SIZE_1024_H 768 +#define MS_VIDEO_SIZE_1024 MS_VIDEO_SIZE_XGA typedef enum{ MS_YUV420P, diff --git a/linphone/mediastreamer2/src/audiostream.c b/linphone/mediastreamer2/src/audiostream.c index 6d690776a..543eb39d2 100644 --- a/linphone/mediastreamer2/src/audiostream.c +++ b/linphone/mediastreamer2/src/audiostream.c @@ -251,6 +251,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char /* give the encoder/decoder some parameters*/ ms_filter_call_method(stream->encoder,MS_FILTER_SET_SAMPLE_RATE,&pt->clock_rate); + ms_message("Payload's bitrate is %i",pt->normal_bitrate); if (pt->normal_bitrate>0){ ms_message("Setting audio encoder network bitrate to %i",pt->normal_bitrate); ms_filter_call_method(stream->encoder,MS_FILTER_SET_BITRATE,&pt->normal_bitrate); diff --git a/linphone/mediastreamer2/src/msv4l2.c b/linphone/mediastreamer2/src/msv4l2.c index e23eedb5f..f136391af 100644 --- a/linphone/mediastreamer2/src/msv4l2.c +++ b/linphone/mediastreamer2/src/msv4l2.c @@ -88,6 +88,7 @@ static bool_t v4lv2_try_format(V4l2State *s, int fmtid){ fmt.fmt.pix.field = V4L2_FIELD_ANY; if (ioctl (s->fd, VIDIOC_S_FMT, &fmt)<0){ + ms_message("VIDIOC_S_FMT: %s",strerror(errno)); return FALSE; } return TRUE;