From b862148419eb175c986154bbbcdb7b75cf1f1edf Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 25 Nov 2010 17:40:13 +0100 Subject: [PATCH 01/14] restore App name and icon on preview video window --- gtk/main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gtk/main.c b/gtk/main.c index 584db85e7..f88f9cfcd 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -512,6 +512,7 @@ static gboolean linphone_gtk_iterate(LinphoneCore *lc){ static gboolean first_time=TRUE; unsigned long id; static unsigned long previd=0; + static unsigned long preview_previd=0; static gboolean in_iterate=FALSE; /*avoid reentrancy*/ @@ -534,6 +535,25 @@ static gboolean linphone_gtk_iterate(LinphoneCore *lc){ w=gdk_window_foreign_new(id); #else w=gdk_window_foreign_new((HANDLE)id); +#endif + if (w) { + set_video_window_decorations(w); + g_object_unref(G_OBJECT(w)); + } + else ms_error("gdk_window_foreign_new() failed"); + if (video_needs_update) video_needs_update=FALSE; + } + } + id=linphone_core_get_native_preview_window_id (lc); + if (id!=preview_previd ){ + GdkWindow *w; + preview_previd=id; + if (id!=0){ + ms_message("Updating window decorations for preview"); +#ifndef WIN32 + w=gdk_window_foreign_new(id); +#else + w=gdk_window_foreign_new((HANDLE)id); #endif if (w) { set_video_window_decorations(w); From f9cff9304f2e249243706d0ce946765fc8989a82 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 26 Nov 2010 11:13:59 +0100 Subject: [PATCH 02/14] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index b1a4c2b64..28a6e7f22 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit b1a4c2b6470a6de62a8e58d4f2874eda091a8db3 +Subproject commit 28a6e7f22fbdd93a01676fc9cc47a2605c846d75 From fb250ab7240252a9b90f01277a2a992f60e9cae6 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 26 Nov 2010 14:41:28 +0100 Subject: [PATCH 03/14] Added bindings to linphoneCore: video size, bandwidth... Declared Java counterpart for VideoSize object. --- coreapi/linphonecore_jni.cc | 27 +++++- .../org/linphone/core/LinphoneCall.java | 18 ++++ .../org/linphone/core/LinphoneCallParams.java | 2 +- .../org/linphone/core/LinphoneCore.java | 7 ++ java/common/org/linphone/core/VideoSize.java | 86 +++++++++++++++++++ 5 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 java/common/org/linphone/core/VideoSize.java diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 3ed73fd4c..eed1b2692 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1001,4 +1001,29 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams( extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){ return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params); -} \ No newline at end of file +} + + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){ + MSVideoSize vsize; + vsize.width = (int)width; + vsize.height = (int)height; + linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize); +} + +extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){ + MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc); + jintArray arr = env->NewIntArray(2); + int tVsize [2]= {vsize.width,vsize.height}; + env->SetIntArrayRegion(arr, 0, 2, tVsize); + return arr; +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){ + linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){ + linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw); +} + diff --git a/java/common/org/linphone/core/LinphoneCall.java b/java/common/org/linphone/core/LinphoneCall.java index 840a5fa99..9a1fe963d 100644 --- a/java/common/org/linphone/core/LinphoneCall.java +++ b/java/common/org/linphone/core/LinphoneCall.java @@ -89,10 +89,28 @@ public interface LinphoneCall { * Call end */ public final static State CallEnd = new State(13,"CallEnd"); + /** * Paused by remote */ public final static State PausedByRemote = new State(14,"PausedByRemote"); + + /** + * The call's parameters are updated, used for example when video is asked by remote + */ + public static final State CallUpdatedByRemote = new State(15, "CallUpdatedByRemote"); + + /** + * We are proposing early media to an incoming call + */ + public static final State CallIncomingEarlyMedia = new State(16,"CallIncomingEarlyMedia"); + + /** + * The remote accepted the call update initiated by us + */ + public static final State CallUpdated = new State(17, "CallUpdated"); + + private State(int value,String stringValue) { mValue = value; values.addElement(this); diff --git a/java/common/org/linphone/core/LinphoneCallParams.java b/java/common/org/linphone/core/LinphoneCallParams.java index 2b903b9ec..30362a73b 100644 --- a/java/common/org/linphone/core/LinphoneCallParams.java +++ b/java/common/org/linphone/core/LinphoneCallParams.java @@ -26,7 +26,7 @@ package org.linphone.core; * */ public interface LinphoneCallParams { - void setVideoEnalbled(boolean b); + void setVideoEnabled(boolean b); boolean getVideoEnabled(); LinphoneCallParams copy(); } diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 94705b49d..327f6e5aa 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -461,4 +461,11 @@ public interface LinphoneCore { public LinphoneCallParams createDefaultCallParameters(); + public void setUploadBandwidth(int bw); + + public void setDownloadBandwidth(int bw); + + public void setPreferredVideoSize(VideoSize vSize); + + public VideoSize getPreferredVideoSize(); } diff --git a/java/common/org/linphone/core/VideoSize.java b/java/common/org/linphone/core/VideoSize.java new file mode 100644 index 000000000..5dab887be --- /dev/null +++ b/java/common/org/linphone/core/VideoSize.java @@ -0,0 +1,86 @@ +/* +VideoSize.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +package org.linphone.core; + +/** + * @author Guillaume Beraudo + */ +public final class VideoSize { + public static final int QCIF = 0; + public static final int CIF = 1; + public static final int HVGA = 2; + + private int width; + public int getWidth() {return width;} + public void setWidth(int width) {this.width = width;} + + private int height; + public int getHeight() {return height;} + public void setHeight(int height) {this.height = height;} + + public VideoSize() {} + private VideoSize(int width, int height) { + this.width = width; + this.height = height; + } + + public static final VideoSize createStandard(int code) { + switch (code) { + case QCIF: + return new VideoSize(176, 144); + case CIF: + return new VideoSize(352, 288); + case HVGA: + return new VideoSize(320, 480); + default: + return new VideoSize(); // Invalid one + } + } + + public boolean isValid() { + return width > 0 && height > 0; + } + + // Generated + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + height; + result = prime * result + width; + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VideoSize other = (VideoSize) obj; + if (height != other.height) + return false; + if (width != other.width) + return false; + return true; + } + + +} From 361c33536e1b239bf0ebeed1e4e4a43ef7e2c747 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 26 Nov 2010 17:57:28 +0100 Subject: [PATCH 04/14] cleanups and fix broken resume --- configure.ac | 2 +- coreapi/callbacks.c | 6 +++++- coreapi/linphonecall.c | 18 ++++++++---------- coreapi/linphonecore.c | 12 +++--------- coreapi/misc.c | 35 +++++++++++++++++++++++++++++++++++ coreapi/offeranswer.c | 37 ++++++++++++++++++++++++------------- coreapi/offeranswer.h | 2 +- coreapi/private.h | 6 +++--- coreapi/sal.h | 1 + coreapi/sal_eXosip2.c | 8 ++++++-- coreapi/sal_eXosip2.h | 1 + 11 files changed, 88 insertions(+), 40 deletions(-) diff --git a/configure.ac b/configure.ac index 93f4f1b00..3d67cbabc 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 393a05d04..5fda3e638 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.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..."); diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 6fce61605..15ffa24d1 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -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: diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index d2583a2b8..16a624c6a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -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...")); diff --git a/coreapi/misc.c b/coreapi/misc.c index 0ea84ca1d..00b4d2895 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -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) { diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index baf84287a..0db6b08a4 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -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; } } diff --git a/coreapi/offeranswer.h b/coreapi/offeranswer.h index 079f41c96..5aa658ae6 100644 --- a/coreapi/offeranswer.h +++ b/coreapi/offeranswer.h @@ -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 diff --git a/coreapi/private.h b/coreapi/private.h index 235d4e984..6ee0071a2 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -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(); diff --git a/coreapi/sal.h b/coreapi/sal.h index e848f71fc..d98d5eb5c 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -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); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 59467f379..fb0eb49ea 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -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"); diff --git a/coreapi/sal_eXosip2.h b/coreapi/sal_eXosip2.h index 10c8b46b7..ad6eeb7f4 100644 --- a/coreapi/sal_eXosip2.h +++ b/coreapi/sal_eXosip2.h @@ -40,6 +40,7 @@ struct Sal{ int session_expires; int keepalive_period; void *up; + bool_t one_matching_codec; }; struct SalOp{ From 7d90f44faebe2552a838e61f2973318175b4e586 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 26 Nov 2010 18:20:52 +0100 Subject: [PATCH 05/14] implement linphone_call_params_set_audio_bandwidth_limit() --- coreapi/linphonecall.c | 24 +++++++++++++++++++----- coreapi/linphonecore.h | 1 + coreapi/misc.c | 4 +--- coreapi/private.h | 4 ++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 15ffa24d1..11b46c89e 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -40,13 +40,19 @@ static MSWebCam *get_nowebcam_device(){ #endif -static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs){ +static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, int bandwidth_limit){ 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 (pt->flags & PAYLOAD_TYPE_ENABLED){ + if (bandwidth_limit>0 && !linphone_core_is_payload_type_usable_for_bandwidth(lc,pt,bandwidth_limit)){ + ms_message("Codec %s/%i eliminated because of audio bandwidth constraint.",pt->mime_type,pt->clock_rate); + continue; + } + if (linphone_core_check_payload_type_usability(lc,pt)){ + l=ms_list_append(l,payload_type_clone(pt)); + } } } return l; @@ -70,7 +76,7 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCa 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); + l=make_codec_list(lc,lc->codecs_conf.audio_codecs,call->params.audio_bw); 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; @@ -83,7 +89,7 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCa 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); + l=make_codec_list(lc,lc->codecs_conf.video_codecs,0); md->streams[1].payloads=l; if (lc->dw_video_bw) md->streams[1].bandwidth=lc->dw_video_bw; @@ -533,6 +539,14 @@ bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams return cp->real_early_media; } +/** + * Refine bandwidth settings for this call by setting a bandwidth limit for audio streams. + * As a consequence, codecs whose bitrates are not compatible with this limit won't be used. +**/ +void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bandwidth){ + cp->audio_bw=bandwidth; +} + /** * **/ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index a6ab6a12f..219b13a7e 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -180,6 +180,7 @@ void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp); +void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bw); void linphone_call_params_destroy(LinphoneCallParams *cp); /** diff --git a/coreapi/misc.c b/coreapi/misc.c index 00b4d2895..a83cd8394 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -258,7 +258,7 @@ void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){ } } -bool_t linphone_core_is_payload_type_usable(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit) +bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit) { double codec_band; bool_t ret=FALSE; @@ -288,8 +288,6 @@ bool_t linphone_core_is_payload_type_usable(LinphoneCore *lc, PayloadType *pt, else ret=FALSE; break; } - /*if (!ret) ms_warning("Payload %s is not usable with your internet connection.",pt->mime_type);*/ - return ret; } diff --git a/coreapi/private.h b/coreapi/private.h index 6ee0071a2..1203fe0fa 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -58,6 +58,7 @@ struct _LinphoneCallParams{ LinphoneCall *referer; /*in case this call creation is consecutive to an incoming transfer, this points to the original call */ + int audio_bw; /* bandwidth limit for audio stream */ bool_t has_video; bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/ bool_t pad[2]; @@ -441,6 +442,9 @@ void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCall *call); void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md); + +bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit); + #define linphone_core_ready(lc) ((lc)->state!=LinphoneGlobalStartup) void _linphone_core_configure_resolver(); From a9817ef514c46a3ae1ee59b1528e26ab214f6ae3 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 26 Nov 2010 20:01:33 +0100 Subject: [PATCH 06/14] add isNetworkStateReachable to java api --- java/common/org/linphone/core/LinphoneCore.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 422c0e5a0..22a660302 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -164,6 +164,11 @@ public interface LinphoneCore { * */ public void setNetworkStateReachable(boolean isReachable); + /** + * + * @return if false, there is no network connection. + */ + public boolean setNetworkStateReachable(); /** * destroy linphone core and free all underlying resources */ From f8db2b8f80ca5b365b783566204bc59e7953bb68 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 26 Nov 2010 20:03:52 +0100 Subject: [PATCH 07/14] remove java 1.3 compilation issue --- java/common/org/linphone/core/VideoSize.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/java/common/org/linphone/core/VideoSize.java b/java/common/org/linphone/core/VideoSize.java index 5dab887be..1d931624b 100644 --- a/java/common/org/linphone/core/VideoSize.java +++ b/java/common/org/linphone/core/VideoSize.java @@ -58,7 +58,6 @@ public final class VideoSize { } // Generated - @Override public int hashCode() { final int prime = 31; int result = 1; @@ -66,7 +65,6 @@ public final class VideoSize { result = prime * result + width; return result; } - @Override public boolean equals(Object obj) { if (this == obj) return true; From aae2584a1722f6c5de219070a6cbd4d70aafddb9 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 26 Nov 2010 20:08:11 +0100 Subject: [PATCH 08/14] fix typo in LinphoneCore --- java/common/org/linphone/core/LinphoneCore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index a11c84f27..1e8416756 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -303,7 +303,7 @@ public interface LinphoneCore { * * @return if false, there is no network connection. */ - public boolean setNetworkStateReachable(); + public boolean getNetworkStateReachable(); /** * destroy linphone core and free all underlying resources */ From a5d821c32ea57fa44d8cec86ca0d9b805a3b3f4a Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 29 Nov 2010 10:52:44 +0100 Subject: [PATCH 09/14] rename bad named methods --- java/common/org/linphone/core/LinphoneCore.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 1e8416756..cbf3bdd34 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -298,12 +298,12 @@ public interface LinphoneCore { * @param network state * */ - public void setNetworkStateReachable(boolean isReachable); + public void setNetworkReachable(boolean isReachable); /** * * @return if false, there is no network connection. */ - public boolean getNetworkStateReachable(); + public boolean isNetworkReachable(); /** * destroy linphone core and free all underlying resources */ From e720d553fda7bdc7b64335fd6a7e83904dbb9a9f Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 29 Nov 2010 12:38:31 +0100 Subject: [PATCH 10/14] fix doxygen for building out of the source tree --- coreapi/help/Doxyfile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/help/Doxyfile.in b/coreapi/help/Doxyfile.in index b1ef17a4e..03dbf91a0 100644 --- a/coreapi/help/Doxyfile.in +++ b/coreapi/help/Doxyfile.in @@ -80,7 +80,7 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = . ../ +INPUT = @top_srcdir@/coreapi @top_srcdir@/coreapi/help FILE_PATTERNS = *.h \ *.c \ @@ -89,7 +89,7 @@ RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = -EXAMPLE_PATH = ../../ . +EXAMPLE_PATH = @top_srcdir@ @top_srcdir@/coreapi/help EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = From 8483823b51e72a3098e24301d18d83f7c61464c3 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 29 Nov 2010 15:40:19 +0100 Subject: [PATCH 11/14] add portrait image sizes --- coreapi/linphonecore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 16a624c6a..8d40ac629 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3368,7 +3368,9 @@ static MSVideoSizeDef supported_resolutions[]={ { {MS_VIDEO_SIZE_VGA_W,MS_VIDEO_SIZE_VGA_H} , "vga" }, { {MS_VIDEO_SIZE_CIF_W,MS_VIDEO_SIZE_CIF_H} , "cif" }, { {MS_VIDEO_SIZE_QVGA_W,MS_VIDEO_SIZE_QVGA_H} , "qvga" }, + { {MS_VIDEO_SIZE_QVGA_H,MS_VIDEO_SIZE_QVGA_W} , "qvga-portrait" }, { {MS_VIDEO_SIZE_QCIF_W,MS_VIDEO_SIZE_QCIF_H} , "qcif" }, + { {MS_VIDEO_SIZE_QCIF_H,MS_VIDEO_SIZE_QCIF_W} , "qcif-portrait" }, { {0,0} , NULL } }; From 7107aa1d1d7a5eaa3fbee6a7bae5766a5bc7bda6 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 29 Nov 2010 21:27:44 +0100 Subject: [PATCH 12/14] add x264 --- build/android/Android.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/android/Android.mk b/build/android/Android.mk index 6b9dc85c1..78355ddd3 100755 --- a/build/android/Android.mk +++ b/build/android/Android.mk @@ -85,7 +85,8 @@ LOCAL_STATIC_LIBRARIES += \ libavcodec \ libswscale \ libavcore \ - libavutil + libavutil \ + libx264 endif ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) From 5cdf291009aa0481259b99ff15c62d0c178d5e36 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 29 Nov 2010 22:10:19 +0100 Subject: [PATCH 13/14] add msx264 compilation --- build/android/Android.mk | 2 ++ coreapi/linphonecore_jni.cc | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build/android/Android.mk b/build/android/Android.mk index 78355ddd3..126e24168 100755 --- a/build/android/Android.mk +++ b/build/android/Android.mk @@ -86,7 +86,9 @@ LOCAL_STATIC_LIBRARIES += \ libswscale \ libavcore \ libavutil \ + libmsx264 \ libx264 + endif ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 000fbbbd3..d52ce4396 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef ANDROID #include extern "C" void libmsilbc_init(); +extern "C" void libmsx264_init(); #endif /*ANDROID*/ extern "C" void ms_andsnd_set_jvm(JavaVM *jvm) ; @@ -48,7 +49,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) #ifdef ANDROID ms_andsnd_set_jvm(ajvm); #ifdef VIDEO_ENABLED - ms_andvid_set_jvm(ajvm); + ms_andvid_set_jvm(ajvm); #endif /*VIDEO_ENABLED*/ #endif /*ANDROID*/ jvm=ajvm; @@ -312,6 +313,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* #ifdef HAVE_ILBC libmsilbc_init(); // requires an fpu +#endif +#ifdef VIDEO_ENABLED + libmsx264_init(); #endif jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable ,userConfig From 1b8402a57a3f28cc57e5c663e660f8d802fc1fba Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 30 Nov 2010 16:05:18 +0100 Subject: [PATCH 14/14] add tutorials c code to make install --- coreapi/help/Makefile.am | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/coreapi/help/Makefile.am b/coreapi/help/Makefile.am index 7fa592da2..74767bea3 100644 --- a/coreapi/help/Makefile.am +++ b/coreapi/help/Makefile.am @@ -32,23 +32,29 @@ endif clean-local: rm -rf doc +#tutorials + noinst_PROGRAMS=helloworld registration buddy_status chatroom helloworld_SOURCES=helloworld.c +LINPHONE_TUTOS=$(helloworld_SOURCES) helloworld_LDADD=$(top_builddir)/coreapi/liblinphone.la \ $(MEDIASTREAMER_LIBS) \ $(ORTP_LIBS) registration_SOURCES=registration.c +LINPHONE_TUTOS+=$(registration_SOURCES) registration_LDADD=$(helloworld_LDADD) buddy_status_SOURCES=buddy_status.c +LINPHONE_TUTOS+=$(buddy_status_SOURCES) buddy_status_LDADD=$(helloworld_LDADD) chatroom_SOURCES=chatroom.c +LINPHONE_TUTOS+=$(chatroom_SOURCES) chatroom_LDADD=$(helloworld_LDADD) @@ -68,3 +74,7 @@ AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE \ -DORTP_INET6 \ $(VIDEO_CFLAGS) + +tutodir=$(datadir)/tutorials/linphone + +tuto_DATA=$(LINPHONE_TUTOS)