mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
quality_reporting.c: remove debug log and refactorize a bit
This commit is contained in:
parent
38ed600456
commit
2b016a4318
3 changed files with 36 additions and 44 deletions
|
|
@ -554,7 +554,7 @@ static float reporting_rand(float t){
|
|||
return t * (.2f * (rand() / (RAND_MAX * 1.0f)) + 0.9f);
|
||||
}
|
||||
|
||||
void linphone_reporting_on_rtcp_update(LinphoneCall *call, int stats_type) {
|
||||
void linphone_reporting_on_rtcp_update(LinphoneCall *call, SalStreamType stats_type) {
|
||||
reporting_session_report_t * report = call->log->reporting.reports[stats_type];
|
||||
reporting_content_metrics_t * metrics = NULL;
|
||||
LinphoneCallStats stats = call->stats[stats_type];
|
||||
|
|
@ -645,54 +645,45 @@ int linphone_reporting_publish_interval_report(LinphoneCall* call) {
|
|||
return publish_report(call, "VQIntervalReport");
|
||||
}
|
||||
|
||||
static bool_t set_on_action_suggested_cb(MediaStream *stream,void (*on_action_suggested)(void*,int,const char**),void* u) {
|
||||
if (stream&&stream->rc){
|
||||
MSQosAnalyzer *analyzer=ms_bitrate_controller_get_qos_analyzer(stream->rc);
|
||||
if (analyzer){
|
||||
ms_qos_analyzer_set_on_action_suggested(analyzer,
|
||||
on_action_suggested,
|
||||
u);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void linphone_reporting_call_state_updated(LinphoneCall *call){
|
||||
LinphoneCallState state=linphone_call_get_state(call);
|
||||
MSQosAnalyzer *analyzer;
|
||||
int i;
|
||||
|
||||
if (state == LinphoneCallReleased||!quality_reporting_enabled(call)){
|
||||
return;
|
||||
}
|
||||
switch (state){
|
||||
case LinphoneCallStreamsRunning:{
|
||||
bool_t video_enabled=media_report_enabled(call, LINPHONE_CALL_STATS_VIDEO);
|
||||
int i = 0;
|
||||
MediaStream *streams[2] = {(MediaStream*) call->audiostream, (MediaStream *) call->videostream};
|
||||
for (i=0;i<2;i++){
|
||||
|
||||
if (streams[i]==NULL||streams[i]->rc==NULL){
|
||||
ms_message("QualityReporting[%p] Cannot set on_action_suggested"
|
||||
" callback for %s stream because something is null", call, i?"video":"audio");
|
||||
continue;
|
||||
}
|
||||
|
||||
analyzer=ms_bitrate_controller_get_qos_analyzer(streams[i]->rc);
|
||||
if (analyzer){
|
||||
for (i=0;i<2;i++) {
|
||||
bool_t enabled=media_report_enabled(call, i);
|
||||
if (enabled && set_on_action_suggested_cb(streams[i], qos_analyzer_on_action_suggested, call->log->reporting.reports[i])) {
|
||||
call->log->reporting.reports[i]->call=call;
|
||||
STR_REASSIGN(call->log->reporting.reports[i]->qos_analyzer.name, ms_strdup(ms_qos_analyzer_get_name(analyzer)));
|
||||
|
||||
ms_qos_analyzer_set_on_action_suggested(analyzer,
|
||||
qos_analyzer_on_action_suggested,
|
||||
call->log->reporting.reports[i]);
|
||||
STR_REASSIGN(call->log->reporting.reports[i]->qos_analyzer.name, ms_strdup(ms_qos_analyzer_get_name(ms_bitrate_controller_get_qos_analyzer(streams[i]->rc))));
|
||||
}
|
||||
}
|
||||
linphone_reporting_update_ip(call);
|
||||
if (!video_enabled && call->log->reporting.was_video_running){
|
||||
if (!media_report_enabled(call, LINPHONE_CALL_STATS_VIDEO) && call->log->reporting.was_video_running){
|
||||
send_report(call, call->log->reporting.reports[LINPHONE_CALL_STATS_VIDEO], "VQSessionReport");
|
||||
}
|
||||
call->log->reporting.was_video_running=video_enabled;
|
||||
call->log->reporting.was_video_running=media_report_enabled(call, LINPHONE_CALL_STATS_VIDEO);
|
||||
break;
|
||||
}
|
||||
case LinphoneCallEnd:{
|
||||
MediaStream *streams[2] = {(MediaStream*) call->audiostream, (MediaStream *) call->videostream};
|
||||
for (i=0;i<2;i++){
|
||||
if (streams[i]==NULL||streams[i]->rc==NULL){
|
||||
continue;
|
||||
}
|
||||
analyzer=ms_bitrate_controller_get_qos_analyzer(streams[i]->rc);
|
||||
if (analyzer){
|
||||
ms_qos_analyzer_set_on_action_suggested(analyzer, NULL, NULL);
|
||||
}
|
||||
}
|
||||
set_on_action_suggested_cb(&call->audiostream->ms, NULL, NULL);
|
||||
set_on_action_suggested_cb(&call->videostream->ms, NULL, NULL);
|
||||
if (call->log->status==LinphoneCallSuccess || call->log->status==LinphoneCallAborted){
|
||||
linphone_reporting_publish_session_report(call, TRUE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define quality_reporting_h
|
||||
|
||||
#include "linphonecore.h"
|
||||
#include "sal/sal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
|
@ -141,7 +142,7 @@ typedef struct reporting_session_report {
|
|||
} reporting_session_report_t;
|
||||
|
||||
|
||||
typedef void (*LinphoneQualityReportingReportSendCb)(const LinphoneCall *call, int stream_type, const LinphoneContent *content);
|
||||
typedef void (*LinphoneQualityReportingReportSendCb)(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content);
|
||||
|
||||
reporting_session_report_t * linphone_reporting_new();
|
||||
void linphone_reporting_destroy(reporting_session_report_t * report);
|
||||
|
|
@ -186,10 +187,10 @@ int linphone_reporting_publish_interval_report(LinphoneCall* call);
|
|||
/**
|
||||
* Update publish reports with newly sent/received RTCP-XR packets (if available).
|
||||
* @param call #LinphoneCall object to consider
|
||||
* @param stats_type the media type (LINPHONE_CALL_STATS_AUDIO or LINPHONE_CALL_STATS_VIDEO)
|
||||
* @param stats_type the media type
|
||||
*
|
||||
*/
|
||||
void linphone_reporting_on_rtcp_update(LinphoneCall *call, int stats_type);
|
||||
void linphone_reporting_on_rtcp_update(LinphoneCall *call, SalStreamType stats_type);
|
||||
|
||||
/**
|
||||
* Update publish reports on call state change.
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
/*avoid crash if x is NULL on libc versions <4.5.26 */
|
||||
#define __strstr(x, y) ((x==NULL)?NULL:strstr(x,y))
|
||||
|
||||
void on_report_send_mandatory(const LinphoneCall *call, int stream_type, const LinphoneContent *content){
|
||||
void on_report_send_mandatory(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){
|
||||
char * body = (char *)linphone_content_get_buffer(content);
|
||||
char * remote_metrics_start = __strstr(body, "RemoteMetrics:");
|
||||
reporting_session_report_t * report = call->log->reporting.reports[stream_type];
|
||||
|
|
@ -69,8 +69,8 @@ void on_report_send_mandatory(const LinphoneCall *call, int stream_type, const L
|
|||
|
||||
BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "DialogID:"));
|
||||
|
||||
if (report->remote_metrics.rtcp_sr_count&&ms!=NULL&&ms->rc!=NULL){
|
||||
/* Hack: reset rtcp_sr_count to 0 because in case of interval reports, we need one RTCP SR by interval */
|
||||
if (report->remote_metrics.rtcp_sr_count>0&&ms!=NULL&&ms->rc!=NULL){
|
||||
/* Hack: reset rtcp_sr_count to 0 because in case of interval reports, we need one RTCP SR by interval. */
|
||||
report->remote_metrics.rtcp_sr_count=0;
|
||||
BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "AdaptiveAlg:"));
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ char * on_report_send_verify_metrics(const reporting_content_metrics_t *metrics,
|
|||
return body;
|
||||
}
|
||||
|
||||
void on_report_send_with_rtcp_xr_local(const LinphoneCall *call, int stream_type, const LinphoneContent *content){
|
||||
void on_report_send_with_rtcp_xr_local(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){
|
||||
char * body = (char*)linphone_content_get_buffer(content);
|
||||
char * remote_metrics_start = __strstr(body, "RemoteMetrics:");
|
||||
reporting_session_report_t * report = call->log->reporting.reports[stream_type];
|
||||
|
|
@ -100,7 +100,7 @@ void on_report_send_with_rtcp_xr_local(const LinphoneCall *call, int stream_type
|
|||
BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalMetrics:"));
|
||||
BC_ASSERT_TRUE(!remote_metrics_start || on_report_send_verify_metrics(&report->local_metrics,body) < remote_metrics_start);
|
||||
}
|
||||
void on_report_send_with_rtcp_xr_remote(const LinphoneCall *call, int stream_type, const LinphoneContent *content){
|
||||
void on_report_send_with_rtcp_xr_remote(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){
|
||||
char * body = (char*)linphone_content_get_buffer(content);
|
||||
reporting_session_report_t * report = call->log->reporting.reports[stream_type];
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ void on_report_send_with_rtcp_xr_remote(const LinphoneCall *call, int stream_typ
|
|||
on_report_send_verify_metrics(&report->remote_metrics,body);
|
||||
}
|
||||
}
|
||||
void on_report_send_with_rtcp_xr_both(const LinphoneCall *call, int stream_type, const LinphoneContent *content){
|
||||
void on_report_send_with_rtcp_xr_both(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){
|
||||
on_report_send_with_rtcp_xr_local(call,stream_type,content);
|
||||
on_report_send_with_rtcp_xr_remote(call,stream_type,content);
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ static void quality_reporting_not_sent_if_low_bandwidth() {
|
|||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
void on_report_send_remove_fields(const LinphoneCall *call, int stream_type, const LinphoneContent *content){
|
||||
void on_report_send_remove_fields(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){
|
||||
char *body = (char*)linphone_content_get_buffer(content);
|
||||
/*corrupt start of the report*/
|
||||
strncpy(body, "corrupted report is corrupted", strlen("corrupted report is corrupted"));
|
||||
|
|
@ -319,8 +319,8 @@ static void quality_reporting_session_report_if_video_stopped() {
|
|||
linphone_call_params_enable_video(pauline_params,FALSE);
|
||||
linphone_core_update_call(pauline->lc,call_pauline,pauline_params);
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,5000));
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,5000));
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,10000));
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,10000));
|
||||
|
||||
BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline)));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue