diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 2519bc687..6ac45de4f 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -127,13 +127,6 @@ static void propagate_encryption_changed(LinphoneCall *call){ } } -#ifdef VIDEO_ENABLED -static void linphone_call_videostream_encryption_changed(void *data, bool_t encrypted){ - LinphoneCall *call = (LinphoneCall *)data; - propagate_encryption_changed(call); -} -#endif - static void linphone_call_audiostream_encryption_changed(void *data, bool_t encrypted) { char status[255]={0}; LinphoneCall *call; @@ -2720,8 +2713,90 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ } } +void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEvent *ev){ + OrtpEventType evt=ortp_event_get_type(ev); + OrtpEventData *evd=ortp_event_get_data(ev); + + if (evt == ORTP_EVENT_RTCP_PACKET_RECEIVED) { + stats->round_trip_delay = rtp_session_get_round_trip_propagation(ms->sessions.rtp_session); + if(stats->received_rtcp != NULL) + freemsg(stats->received_rtcp); + stats->received_rtcp = evd->packet; + evd->packet = NULL; + stats->updated = LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE; + update_local_stats(stats,ms); + } else if (evt == ORTP_EVENT_RTCP_PACKET_EMITTED) { + memcpy(&stats->jitter_stats, rtp_session_get_jitter_stats(ms->sessions.rtp_session), sizeof(jitter_stats_t)); + if (stats->sent_rtcp != NULL) + freemsg(stats->sent_rtcp); + stats->sent_rtcp = evd->packet; + evd->packet = NULL; + stats->updated = LINPHONE_CALL_STATS_SENT_RTCP_UPDATE; + update_local_stats(stats,ms); + } +} + +void linphone_call_notify_stats_updated(LinphoneCall *call, int stream_index){ + LinphoneCallStats *stats=&call->stats[stream_index]; + LinphoneCore *lc=call->core; + if (stats->updated){ + linphone_reporting_call_stats_updated(call, stream_index); + if (lc->vtable.call_stats_updated) + lc->vtable.call_stats_updated(lc, call, stats); + stats->updated = 0; + } +} + +void linphone_call_handle_stream_events(LinphoneCall *call, int stream_index){ + MediaStream *ms=stream_index==0 ? (MediaStream *)call->audiostream : (MediaStream *)call->videostream; /*assumption to remove*/ + OrtpEvQueue *evq; + OrtpEvent *ev; + + if (ms==NULL) return; + /* Ensure there is no dangling ICE check list. */ + if (call->ice_session == NULL) ms->ice_check_list = NULL; + + switch(ms->type){ + case AudioStreamType: + audio_stream_iterate((AudioStream*)ms); + break; + case VideoStreamType: +#ifdef VIDEO_ENABLED + video_stream_iterate((VideoStream*)ms); +#endif + break; + default: + ms_error("linphone_call_handle_stream_events(): unsupported stream type."); + return; + break; + } + /*yes the event queue has to be taken at each iteration, because ice events may perform operations re-creating the streams*/ + while ((evq=stream_index==0 ? call->audiostream_app_evq : call->videostream_app_evq) && (NULL != (ev=ortp_ev_queue_get(evq)))){ + OrtpEventType evt=ortp_event_get_type(ev); + OrtpEventData *evd=ortp_event_get_data(ev); + + linphone_call_stats_fill(&call->stats[stream_index],ms,ev); + linphone_call_notify_stats_updated(call,stream_index); + + if (evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED){ + if (ms->type==AudioStreamType) + linphone_call_audiostream_encryption_changed(call, evd->info.zrtp_stream_encrypted); + else if (ms->type==VideoStreamType) + propagate_encryption_changed(call); + } else if (evt == ORTP_EVENT_ZRTP_SAS_READY) { + if (ms->type==AudioStreamType) + linphone_call_audiostream_auth_token_ready(call, evd->info.zrtp_sas.sas, evd->info.zrtp_sas.verified); + } else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) + || (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) || (evt == ORTP_EVENT_ICE_RESTART_NEEDED)) { + handle_ice_events(call, ev); + } else if (evt==ORTP_EVENT_TELEPHONE_EVENT){ + linphone_core_dtmf_received(call->core,evd->info.telephone_event); + } + ortp_event_destroy(ev); + } +} + void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapsed){ - LinphoneCore* lc = call->core; int disconnect_timeout = linphone_core_get_nortp_timeout(call->core); bool_t disconnected=FALSE; @@ -2743,102 +2818,8 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse linphone_upnp_call_process(call); #endif //BUILD_UPNP -#ifdef VIDEO_ENABLED - if (call->videostream!=NULL) { - OrtpEvent *ev; - - /* Ensure there is no dangling ICE check list. */ - if (call->ice_session == NULL) call->videostream->ms.ice_check_list = NULL; - - // Beware that the application queue should not depend on treatments fron the - // mediastreamer queue. - video_stream_iterate(call->videostream); - - while (call->videostream_app_evq && (NULL != (ev=ortp_ev_queue_get(call->videostream_app_evq)))){ - OrtpEventType evt=ortp_event_get_type(ev); - OrtpEventData *evd=ortp_event_get_data(ev); - if (evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED){ - linphone_call_videostream_encryption_changed(call, evd->info.zrtp_stream_encrypted); - } else if (evt == ORTP_EVENT_RTCP_PACKET_RECEIVED) { - call->stats[LINPHONE_CALL_STATS_VIDEO].round_trip_delay = rtp_session_get_round_trip_propagation(call->videostream->ms.sessions.rtp_session); - if(call->stats[LINPHONE_CALL_STATS_VIDEO].received_rtcp != NULL) - freemsg(call->stats[LINPHONE_CALL_STATS_VIDEO].received_rtcp); - call->stats[LINPHONE_CALL_STATS_VIDEO].received_rtcp = evd->packet; - evd->packet = NULL; - call->stats[LINPHONE_CALL_STATS_VIDEO].updated = LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE; - update_local_stats(&call->stats[LINPHONE_CALL_STATS_VIDEO],(MediaStream*)call->videostream); - if (linphone_call_params_video_enabled(linphone_call_get_current_params(call))) - linphone_reporting_call_stats_updated(call, LINPHONE_CALL_STATS_VIDEO); - if (lc->vtable.call_stats_updated) - lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_VIDEO]); - } else if (evt == ORTP_EVENT_RTCP_PACKET_EMITTED) { - memcpy(&call->stats[LINPHONE_CALL_STATS_VIDEO].jitter_stats, rtp_session_get_jitter_stats(call->videostream->ms.sessions.rtp_session), sizeof(jitter_stats_t)); - if(call->stats[LINPHONE_CALL_STATS_VIDEO].sent_rtcp != NULL) - freemsg(call->stats[LINPHONE_CALL_STATS_VIDEO].sent_rtcp); - call->stats[LINPHONE_CALL_STATS_VIDEO].sent_rtcp = evd->packet; - evd->packet = NULL; - call->stats[LINPHONE_CALL_STATS_VIDEO].updated = LINPHONE_CALL_STATS_SENT_RTCP_UPDATE; - update_local_stats(&call->stats[LINPHONE_CALL_STATS_VIDEO],(MediaStream*)call->videostream); - if (linphone_call_params_video_enabled(linphone_call_get_current_params(call))) - linphone_reporting_call_stats_updated(call, LINPHONE_CALL_STATS_VIDEO); - if (lc->vtable.call_stats_updated) - lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_VIDEO]); - } else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) - || (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) || (evt == ORTP_EVENT_ICE_RESTART_NEEDED)) { - handle_ice_events(call, ev); - } - ortp_event_destroy(ev); - } - } -#endif - if (call->audiostream!=NULL) { - OrtpEvent *ev; - - /* Ensure there is no dangling ICE check list. */ - if (call->ice_session == NULL) call->audiostream->ms.ice_check_list = NULL; - - // Beware that the application queue should not depend on treatments fron the - // mediastreamer queue. - audio_stream_iterate(call->audiostream); - - while (call->audiostream_app_evq && (NULL != (ev=ortp_ev_queue_get(call->audiostream_app_evq)))){ - OrtpEventType evt=ortp_event_get_type(ev); - OrtpEventData *evd=ortp_event_get_data(ev); - if (evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED){ - linphone_call_audiostream_encryption_changed(call, evd->info.zrtp_stream_encrypted); - } else if (evt == ORTP_EVENT_ZRTP_SAS_READY) { - linphone_call_audiostream_auth_token_ready(call, evd->info.zrtp_sas.sas, evd->info.zrtp_sas.verified); - } else if (evt == ORTP_EVENT_RTCP_PACKET_RECEIVED) { - call->stats[LINPHONE_CALL_STATS_AUDIO].round_trip_delay = rtp_session_get_round_trip_propagation(call->audiostream->ms.sessions.rtp_session); - if(call->stats[LINPHONE_CALL_STATS_AUDIO].received_rtcp != NULL) - freemsg(call->stats[LINPHONE_CALL_STATS_AUDIO].received_rtcp); - call->stats[LINPHONE_CALL_STATS_AUDIO].received_rtcp = evd->packet; - evd->packet = NULL; - call->stats[LINPHONE_CALL_STATS_AUDIO].updated = LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE; - update_local_stats(&call->stats[LINPHONE_CALL_STATS_AUDIO],(MediaStream*)call->audiostream); - linphone_reporting_call_stats_updated(call, LINPHONE_CALL_STATS_AUDIO); - if (lc->vtable.call_stats_updated) - lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_AUDIO]); - } else if (evt == ORTP_EVENT_RTCP_PACKET_EMITTED) { - memcpy(&call->stats[LINPHONE_CALL_STATS_AUDIO].jitter_stats, rtp_session_get_jitter_stats(call->audiostream->ms.sessions.rtp_session), sizeof(jitter_stats_t)); - if(call->stats[LINPHONE_CALL_STATS_AUDIO].sent_rtcp != NULL) - freemsg(call->stats[LINPHONE_CALL_STATS_AUDIO].sent_rtcp); - call->stats[LINPHONE_CALL_STATS_AUDIO].sent_rtcp = evd->packet; - evd->packet = NULL; - call->stats[LINPHONE_CALL_STATS_AUDIO].updated = LINPHONE_CALL_STATS_SENT_RTCP_UPDATE; - update_local_stats(&call->stats[LINPHONE_CALL_STATS_AUDIO],(MediaStream*)call->audiostream); - linphone_reporting_call_stats_updated(call, LINPHONE_CALL_STATS_AUDIO); - if (lc->vtable.call_stats_updated) - lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_AUDIO]); - } else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) - || (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) || (evt == ORTP_EVENT_ICE_RESTART_NEEDED)) { - handle_ice_events(call, ev); - } else if (evt==ORTP_EVENT_TELEPHONE_EVENT){ - linphone_core_dtmf_received(lc,evd->info.telephone_event); - } - ortp_event_destroy(ev); - } - } + linphone_call_handle_stream_events(call,0); + linphone_call_handle_stream_events(call,1); if (call->state==LinphoneCallStreamsRunning && one_second_elapsed && call->audiostream!=NULL && disconnect_timeout>0 ) disconnected=!audio_stream_alive(call->audiostream,disconnect_timeout); if (disconnected) diff --git a/coreapi/private.h b/coreapi/private.h index 2d2d9fb21..003af30f1 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -403,7 +403,7 @@ struct _LinphoneProxyConfig char *reg_proxy; char *reg_identity; char *reg_route; - char *reg_statistics_collector; + char *statistics_collector; char *realm; char *contact_params; char *contact_uri_params; diff --git a/coreapi/proxy.c b/coreapi/proxy.c index a118ba50a..30f29f3bc 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -46,7 +46,7 @@ static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *ob const char *identity = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_identity", NULL) : NULL; const char *proxy = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_proxy", NULL) : NULL; const char *route = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_route", NULL) : NULL; - const char *statistics_collector = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_statistics_collector", NULL) : NULL; + const char *statistics_collector = lc ? lp_config_get_default_string(lc->config, "proxy", "statistics_collector", NULL) : NULL; const char *contact_params = lc ? lp_config_get_default_string(lc->config, "proxy", "contact_parameters", NULL) : NULL; const char *contact_uri_params = lc ? lp_config_get_default_string(lc->config, "proxy", "contact_uri_parameters", NULL) : NULL; @@ -60,7 +60,7 @@ static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *ob obj->reg_identity = identity ? ms_strdup(identity) : NULL; obj->reg_proxy = proxy ? ms_strdup(proxy) : NULL; obj->reg_route = route ? ms_strdup(route) : NULL; - obj->reg_statistics_collector = statistics_collector ? ms_strdup(statistics_collector) : NULL; + obj->statistics_collector = statistics_collector ? ms_strdup(statistics_collector) : NULL; obj->send_statistics = lc ? lp_config_get_default_int(lc->config, "proxy", "send_statistics", 0) : 0; obj->contact_params = contact_params ? ms_strdup(contact_params) : NULL; obj->contact_uri_params = contact_uri_params ? ms_strdup(contact_uri_params) : NULL; @@ -96,7 +96,7 @@ void linphone_proxy_config_destroy(LinphoneProxyConfig *obj){ if (obj->reg_proxy!=NULL) ms_free(obj->reg_proxy); if (obj->reg_identity!=NULL) ms_free(obj->reg_identity); if (obj->reg_route!=NULL) ms_free(obj->reg_route); - if (obj->reg_statistics_collector!=NULL) ms_free(obj->reg_statistics_collector); + if (obj->statistics_collector!=NULL) ms_free(obj->statistics_collector); if (obj->ssctx!=NULL) sip_setup_context_free(obj->ssctx); if (obj->realm!=NULL) ms_free(obj->realm); if (obj->type!=NULL) ms_free(obj->type); @@ -424,7 +424,7 @@ void linphone_proxy_config_enable_statistics(LinphoneProxyConfig *cfg, bool_t va bool_t linphone_proxy_config_send_statistics_enabled(LinphoneProxyConfig *cfg){ // ensure that collector address is set too! - return cfg->send_statistics && cfg->reg_statistics_collector != NULL; + return cfg->send_statistics && cfg->statistics_collector != NULL; } void linphone_proxy_config_set_statistics_collector(LinphoneProxyConfig *cfg, const char *collector){ @@ -435,16 +435,16 @@ void linphone_proxy_config_set_statistics_collector(LinphoneProxyConfig *cfg, co if (addr) linphone_address_destroy(addr); } else { - if (cfg->reg_statistics_collector != NULL) - ms_free(cfg->reg_statistics_collector); - cfg->reg_statistics_collector = ms_strdup(collector); + if (cfg->statistics_collector != NULL) + ms_free(cfg->statistics_collector); + cfg->statistics_collector = ms_strdup(collector); linphone_address_destroy(addr); } } } const char *linphone_proxy_config_get_statistics_collector(const LinphoneProxyConfig *cfg){ - return cfg->reg_statistics_collector; + return cfg->statistics_collector; } @@ -1094,8 +1094,8 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC if (obj->reg_route!=NULL){ lp_config_set_string(config,key,"reg_route",obj->reg_route); } - if (obj->reg_statistics_collector!=NULL){ - lp_config_set_string(config,key,"reg_statistics_collector",obj->reg_statistics_collector); + if (obj->statistics_collector!=NULL){ + lp_config_set_string(config,key,"statistics_collector",obj->statistics_collector); } if (obj->reg_identity!=NULL){ lp_config_set_string(config,key,"reg_identity",obj->reg_identity); @@ -1142,7 +1142,7 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config tmp=lp_config_get_string(config,key,"reg_route",NULL); if (tmp!=NULL) linphone_proxy_config_set_route(cfg,tmp); - tmp=lp_config_get_string(config,key,"reg_statistics_collector",NULL); + tmp=lp_config_get_string(config,key,"statistics_collector",NULL); if (tmp!=NULL) linphone_proxy_config_set_statistics_collector(cfg,tmp); linphone_proxy_config_enable_statistics(cfg,lp_config_get_int(config,key,"send_statistics",0)); diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index c5107b4e1..595db24d2 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -269,7 +269,7 @@ static void reporting_publish(const LinphoneCall* call, const reporting_session_ content.size = strlen((char*)content.data); - addr = linphone_address_new(call->dest_proxy->reg_statistics_collector); + addr = linphone_address_new(call->dest_proxy->statistics_collector); if (addr != NULL) { linphone_core_publish(call->core, addr, "vq-rtcpxr", expires, &content); linphone_address_destroy(addr); diff --git a/mediastreamer2 b/mediastreamer2 index a66959cdc..69cf3ba35 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit a66959cdc9ffa2eb2736c465dfe942ce8a74dbda +Subproject commit 69cf3ba35c3533f8092b177bdc854a6fb45ceaa3 diff --git a/tester/rcfiles/marie_rc b/tester/rcfiles/marie_rc index 60fa3d118..e5cd7a3b5 100644 --- a/tester/rcfiles/marie_rc +++ b/tester/rcfiles/marie_rc @@ -22,7 +22,7 @@ reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0 -reg_statistics_collector=sip:collector@sip.example.org +statistics_collector=sip:collector@sip.example.org send_statistics=1 [friend_0]