]> sjero.net Git - linphone/commitdiff
Merge commit 'aab6c70'
authorJehan Monnier <jehan.monnier@linphone.org>
Tue, 3 Apr 2012 08:50:48 +0000 (10:50 +0200)
committerJehan Monnier <jehan.monnier@linphone.org>
Tue, 3 Apr 2012 08:50:48 +0000 (10:50 +0200)
1  2 
coreapi/callbacks.c
coreapi/linphonecall.c
coreapi/sal.h

diff --combined coreapi/callbacks.c
index 8d41da1018c9ac72a732040e2ac8a0bc2542daaa,a4181cfa0a02f8227bf2608260c1e7184ec9e166..34fd552af15461809a7592d674f863890df94ce1
@@@ -276,6 -276,7 +276,7 @@@ static void call_ringing(SalOp *h)
                if (lc->ringstream!=NULL) return;       /*already ringing !*/
                if (lc->sound_conf.play_sndcard!=NULL){
                        MSSndCard *ringcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
+                       if (call->localdesc->streams[0].max_rate>0) ms_snd_card_set_preferred_sample_rate(ringcard, call->localdesc->streams[0].max_rate);
                        lc->ringstream=ring_start(lc->sound_conf.remote_ring,2000,ringcard);
                }
                ms_message("Remote ringing...");
@@@ -323,7 -324,6 +324,7 @@@ static void call_accepted(SalOp *op)
            call->state==LinphoneCallOutgoingRinging ||
            call->state==LinphoneCallOutgoingEarlyMedia){
                linphone_call_set_state(call,LinphoneCallConnected,"Connected");
 +              if (call->referer) linphone_core_notify_refer_state(lc,call->referer,call);
        }
        if (md && !sal_media_description_empty(md)){
                if (sal_media_description_has_dir(md,SalStreamSendOnly) ||
                                }
                        }
                        linphone_core_update_streams (lc,call,md);
 -                      linphone_call_set_state(call, LinphoneCallStreamsRunning, "Streams running");
                        if (!call->current_params.in_conference)
                                lc->current_call=call;
 +                      linphone_call_set_state(call, LinphoneCallStreamsRunning, "Streams running");
                }
        }else{
                /*send a bye*/
@@@ -592,10 -592,6 +593,10 @@@ static void call_failure(SalOp *op, Sal
        } else {
                linphone_call_set_state(call,LinphoneCallError,msg);
        }
 +      if (call->referer && linphone_call_get_state(call->referer)==LinphoneCallPaused && call->referer->was_automatically_paused){
 +              /*resume to the call that send us the refer automatically*/
 +              linphone_core_resume_call(lc,call->referer);
 +      }
  }
  
  static void call_released(SalOp *op){
@@@ -749,11 -745,12 +750,11 @@@ static void refer_received(Sal *sal, Sa
                if (call->state!=LinphoneCallPaused){
                        ms_message("Automatically pausing current call to accept transfer.");
                        linphone_core_pause_call(lc,call);
 +                      call->was_automatically_paused=TRUE;
                }
                linphone_core_start_refered_call(lc,call);
 -              sal_call_accept_refer(op);
        }else if (lc->vtable.refer_received){
                lc->vtable.refer_received(lc,referto);
 -              sal_call_accept_refer(op);
        }
  }
  
@@@ -770,7 -767,7 +771,7 @@@ static void notify(SalOp *op, const cha
                lc->vtable.notify_recv(lc,call,from,msg);
  }
  
 -static void notify_presence(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg){
 +static void notify_presence(SalOp *op, SalSubscribeStatus ss, SalPresenceStatus status, const char *msg){
        LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
        linphone_notify_recv(lc,op,ss,status);
  }
@@@ -799,35 -796,6 +800,35 @@@ static void ping_reply(SalOp *op)
        }
  }
  
 +static void notify_refer(SalOp *op, SalReferStatus status){
 +      LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
 +      LinphoneCall *call=(LinphoneCall*) sal_op_get_user_pointer(op);
 +      LinphoneCallState cstate;
 +      if (call==NULL) {
 +              ms_warning("Receiving notify_refer for unknown call.");
 +              return ;
 +      }
 +      switch(status){
 +              case SalReferTrying:
 +                      cstate=LinphoneCallOutgoingProgress;
 +              break;
 +              case SalReferSuccess:
 +                      cstate=LinphoneCallConnected;
 +              break;
 +              case SalReferFailed:
 +                      cstate=LinphoneCallError;
 +              break;
 +              default:
 +                      cstate=LinphoneCallError;
 +      }
 +      if (lc->vtable.transfer_state_changed)
 +              lc->vtable.transfer_state_changed(lc,call,cstate);
 +      if (cstate==LinphoneCallConnected){
 +              /*automatically terminate the call as the transfer is complete.*/
 +              linphone_core_terminate_call(lc,call);
 +      }
 +}
 +
  SalCallbacks linphone_sal_callbacks={
        call_received,
        call_ringing,
        text_received,
        notify,
        notify_presence,
 +      notify_refer,
        subscribe_received,
        subscribe_closed,
        ping_reply
diff --combined coreapi/linphonecall.c
index 35e84090218399c3ace50ff8e247d55ecb195067,6ec119105824ee9b1b7b3ebe521a32cc2364544c..9c3ecfd11a18976aab1d1c6883913c0bdad682bb
@@@ -35,6 -35,7 +35,7 @@@ Foundation, Inc., 59 Temple Place - Sui
  #include "mediastreamer2/msfileplayer.h"
  #include "mediastreamer2/msjpegwriter.h"
  #include "mediastreamer2/mseventqueue.h"
+ #include "mediastreamer2/mssndcard.h"
  
  #ifdef VIDEO_ENABLED
  static MSWebCam *get_nowebcam_device(){
@@@ -172,9 -173,10 +173,10 @@@ void linphone_call_set_authentication_t
        propagate_encryption_changed(call);
  }
  
- static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, int bandwidth_limit){
+ static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, int bandwidth_limit,int* max_sample_rate){
        MSList *l=NULL;
        const MSList *it;
+       if (max_sample_rate) *max_sample_rate=0;
        for(it=codecs;it!=NULL;it=it->next){
                PayloadType *pt=(PayloadType*)it->data;
                if (pt->flags & PAYLOAD_TYPE_ENABLED){
                        }
                        if (linphone_core_check_payload_type_usability(lc,pt)){
                                l=ms_list_append(l,payload_type_clone(pt));
+                               if (max_sample_rate && payload_type_get_rate(pt)>*max_sample_rate) *max_sample_rate=payload_type_get_rate(pt);
                        }
                }
        }
@@@ -199,6 -202,7 +202,7 @@@ static SalMediaDescription *_create_loc
        const char *username=linphone_address_get_username (addr);
        SalMediaDescription *md=sal_media_description_new();
  
        md->session_id=session_id;
        md->session_ver=session_ver;
        md->nstreams=1;
                SalProtoRtpSavp : 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,call->params.audio_bw);
+       l=make_codec_list(lc,lc->codecs_conf.audio_codecs,call->params.audio_bw,&md->streams[0].max_rate);
        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;
+       
  
  
        if (call->params.has_video){
                md->streams[1].port=call->video_port;
                md->streams[1].proto=md->streams[0].proto;
                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,NULL);
                md->streams[1].payloads=l;
        }
        
@@@ -332,7 -337,6 +337,7 @@@ LinphoneCall * linphone_call_new_outgoi
        discover_mtu(lc,linphone_address_get_domain (to));
        if (params->referer){
                sal_call_set_referer(call->op,params->referer->op);
 +              call->referer=linphone_call_ref(params->referer);
        }
        return call;
  }
@@@ -402,10 -406,6 +407,10 @@@ static void linphone_call_set_terminate
                linphone_core_stop_dtmf(lc);
                call->ringing_beep=FALSE;
        }
 +      if (call->referer){
 +              linphone_call_unref(call->referer);
 +              call->referer=NULL;
 +      }
  }
  
  void linphone_call_fix_call_parameters(LinphoneCall *call){
@@@ -847,18 -847,12 +852,18 @@@ static void rendercb(void *data, const 
  
  #ifdef VIDEO_ENABLED
  static void video_stream_event_cb(void *user_pointer, const MSFilter *f, const unsigned int event_id, const void *args){
 +    LinphoneCall* call = (LinphoneCall*) user_pointer;
        ms_warning("In linphonecall.c: video_stream_event_cb");
        switch (event_id) {
                case MS_VIDEO_DECODER_DECODING_ERRORS:
                        ms_warning("Case is MS_VIDEO_DECODER_DECODING_ERRORS");
 -                      linphone_call_send_vfu_request((LinphoneCall*) user_pointer);
 +                      linphone_call_send_vfu_request(call);
                        break;
 +        case MS_VIDEO_DECODER_FIRST_IMAGE_DECODED:
 +            ms_message("First video frame decoded successfully");
 +            if (call->nextVideoFrameDecoded._func != NULL)
 +                call->nextVideoFrameDecoded._func(call, call->nextVideoFrameDecoded._user_data);
 +            break;
                default:
                        ms_warning("Unhandled event %i", event_id);
                        break;
  }
  #endif
  
 +void linphone_call_set_next_video_frame_decoded_callback(LinphoneCall *call, LinphoneCallCbFunc cb, void* user_data) {
 +    call->nextVideoFrameDecoded._func = cb;
 +    call->nextVideoFrameDecoded._user_data = user_data;
 +#ifdef VIDEO_ENABLED
 +    ms_filter_call_method_noarg(call->videostream->decoder, MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION);
 +#endif
 +}
 +
  void linphone_call_init_media_streams(LinphoneCall *call){
        LinphoneCore *lc=call->core;
        SalMediaDescription *md=call->localdesc;
  #ifdef VIDEO_ENABLED
  
        if ((lc->video_conf.display || lc->video_conf.capture) && md->streams[1].port>0){
 +              int video_recv_buf_size=lp_config_get_int(lc->config,"video","recv_buf_size",0);
                call->videostream=video_stream_new(md->streams[1].port,linphone_core_ipv6_enabled(lc));
 -        video_stream_enable_display_filter_auto_rotate(call->videostream, lp_config_get_int(lc->config,"video","display_filter_auto_rotate",0));
 -      if( lc->video_conf.displaytype != NULL)
 -              video_stream_set_display_filter_name(call->videostream,lc->video_conf.displaytype);
 -      video_stream_set_event_callback(call->videostream,video_stream_event_cb, call);
 -      if (lc->rtptf){
 -              RtpTransport *vrtp=lc->rtptf->video_rtp_func(lc->rtptf->video_rtp_func_data, call->video_port);
 -              RtpTransport *vrtcp=lc->rtptf->video_rtcp_func(lc->rtptf->video_rtcp_func_data, call->video_port+1);
 -              rtp_session_set_transports(call->videostream->session,vrtp,vrtcp);
 -      }
 -      call->videostream_app_evq = ortp_ev_queue_new();
 -      rtp_session_register_event_queue(call->videostream->session,call->videostream_app_evq);
 +              video_stream_enable_display_filter_auto_rotate(call->videostream, lp_config_get_int(lc->config,"video","display_filter_auto_rotate",0));
 +              if (video_recv_buf_size>0) rtp_session_set_recv_buf_size(call->videostream->session,video_recv_buf_size);
 +          
 +              if( lc->video_conf.displaytype != NULL)
 +                      video_stream_set_display_filter_name(call->videostream,lc->video_conf.displaytype);
 +              video_stream_set_event_callback(call->videostream,video_stream_event_cb, call);
 +              if (lc->rtptf){
 +                      RtpTransport *vrtp=lc->rtptf->video_rtp_func(lc->rtptf->video_rtp_func_data, call->video_port);
 +                      RtpTransport *vrtcp=lc->rtptf->video_rtcp_func(lc->rtptf->video_rtcp_func_data, call->video_port+1);
 +                      rtp_session_set_transports(call->videostream->session,vrtp,vrtcp);
 +              }
 +              call->videostream_app_evq = ortp_ev_queue_new();
 +              rtp_session_register_event_queue(call->videostream->session,call->videostream_app_evq);
  #ifdef TEST_EXT_RENDERER
                video_stream_set_render_callback(call->videostream,rendercb,NULL);
  #endif
@@@ -1176,7 -1159,8 +1181,8 @@@ static void linphone_call_start_audio_s
                                captcard=playcard=NULL;
                        }
                        use_ec=captcard==NULL ? FALSE : linphone_core_echo_cancellation_enabled(lc);
+                       if (playcard &&  stream->max_rate>0) ms_snd_card_set_preferred_sample_rate(playcard, stream->max_rate);
+                       if (captcard &&  stream->max_rate>0) ms_snd_card_set_preferred_sample_rate(captcard, stream->max_rate);
                        audio_stream_enable_adaptive_bitrate_control(call->audiostream,use_arc);
                        audio_stream_start_full(
                                call->audiostream,
@@@ -1292,7 -1276,6 +1298,7 @@@ static void linphone_call_start_video_s
                                cam=get_nowebcam_device();
                        }
                        if (!is_inactive){
 +                call->log->video_enabled = TRUE;
                                video_stream_set_direction (call->videostream, dir);
                                ms_message("%s lc rotation:%d\n", __FUNCTION__, lc->device_rotation);
                                video_stream_set_device_rotation(call->videostream, lc->device_rotation);
diff --combined coreapi/sal.h
index c4fabc6baff35c99ee9bd05a12cc2ca93a8c5051,e74e80c68ade8b88ad8b07c210b87b5e2968bab7..bbe4dafff035afb35ed82abe53c3700b2a032c90
@@@ -134,6 -134,7 +134,7 @@@ typedef struct SalStreamDescription
        SalStreamDir dir;
        SalSrtpCryptoAlgo crypto[SAL_CRYPTO_ALGO_MAX];
        unsigned int crypto_local_tag;
+       int max_rate;
  } SalStreamDescription;
  
  #define SAL_MEDIA_DESCRIPTION_MAX_STREAMS 4
@@@ -206,16 -207,10 +207,16 @@@ typedef enum SalPresenceStatus
        SalPresenceAltService,
  }SalPresenceStatus;
  
 -typedef enum SalSubscribeState{
 +typedef enum SalReferStatus{
 +      SalReferTrying,
 +      SalReferSuccess,
 +      SalReferFailed
 +}SalReferStatus;
 +
 +typedef enum SalSubscribeStatus{
        SalSubscribeActive,
        SalSubscribeTerminated
 -}SalSubscribeState;
 +}SalSubscribeStatus;
  
  typedef void (*SalOnCallReceived)(SalOp *op);
  typedef void (*SalOnCallRinging)(SalOp *op);
@@@ -233,9 -228,8 +234,9 @@@ typedef void (*SalOnVfuRequest)(SalOp *
  typedef void (*SalOnDtmfReceived)(SalOp *op, char dtmf);
  typedef void (*SalOnRefer)(Sal *sal, SalOp *op, const char *referto);
  typedef void (*SalOnTextReceived)(Sal *sal, const char *from, const char *msg);
 -typedef void (*SalOnNotify)(SalOp *op, const char *from, const char *value);
 -typedef void (*SalOnNotifyPresence)(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg);
 +typedef void (*SalOnNotify)(SalOp *op, const char *from, const char *event);
 +typedef void (*SalOnNotifyRefer)(SalOp *op, SalReferStatus state);
 +typedef void (*SalOnNotifyPresence)(SalOp *op, SalSubscribeStatus ss, SalPresenceStatus status, const char *msg);
  typedef void (*SalOnSubscribeReceived)(SalOp *salop, const char *from);
  typedef void (*SalOnSubscribeClosed)(SalOp *salop, const char *from);
  typedef void (*SalOnPingReply)(SalOp *salop);
@@@ -259,7 -253,6 +260,7 @@@ typedef struct SalCallbacks
        SalOnTextReceived text_received;
        SalOnNotify notify;
        SalOnNotifyPresence notify_presence;
 +      SalOnNotifyRefer notify_refer;
        SalOnSubscribeReceived subscribe_received;
        SalOnSubscribeClosed subscribe_closed;
        SalOnPingReply ping_reply;
@@@ -347,7 -340,6 +348,7 @@@ 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);
 +int sal_call_notify_refer_state(SalOp *h, SalOp *newcall);
  
  /*Registration*/
  int sal_register(SalOp *op, const char *proxy, const char *from, int expires);