diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 0c0b640fe..92b5c4e0e 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -21,40 +21,39 @@ #include "tester_utils.h" #include "quality_reporting.h" -/*avoid crash if x is NULL on libc versions <4.5.26 */ +/* 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, SalStreamType stream_type, const LinphoneContent *content){ +static void on_report_send_mandatory (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { const char *body = linphone_content_get_string_buffer(content); - char * remote_metrics_start = __strstr(body, "RemoteMetrics:"); - BC_ASSERT_TRUE( - __strstr(body, "VQIntervalReport\r\n") == body || - __strstr(body, "VQSessionReport\r\n") == body || - __strstr(body, "VQSessionReport: CallTerm\r\n") == body + char *remote_metrics_start = __strstr(body, "RemoteMetrics:"); + BC_ASSERT_TRUE((__strstr(body, "VQIntervalReport\r\n") == body) + || (__strstr(body, "VQSessionReport\r\n") == body) + || (__strstr(body, "VQSessionReport: CallTerm\r\n") == body) ); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "CallID:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalID:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "RemoteID:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "OrigID:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalGroup:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "RemoteGroup:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalAddr:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "IP=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PORT=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SSRC=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "RemoteAddr:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "IP=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PORT=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SSRC=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalMetrics:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "Timestamps:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "START=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "STOP=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "CallID:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalID:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "RemoteID:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "OrigID:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalGroup:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "RemoteGroup:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalAddr:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "IP=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PORT=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SSRC=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "RemoteAddr:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "IP=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PORT=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SSRC=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalMetrics:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "Timestamps:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "START=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "STOP=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SessionDesc:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PT=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PD=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SR=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SessionDesc:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PT=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PD=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SR=")); /* We should have not reached RemoteMetrics section yet */ BC_ASSERT_TRUE(!remote_metrics_start || body < remote_metrics_start); @@ -62,23 +61,21 @@ void on_report_send_mandatory(const LinphoneCall *call, SalStreamType stream_typ BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "DialogID:")); } -const char *on_report_send_verify_metrics (const reporting_content_metrics_t *metrics, const char *body) { +static const char *on_report_send_verify_metrics (const reporting_content_metrics_t *metrics, const char *body) { if (metrics->rtcp_xr_count) { BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SessionDesc:")); BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "JitterBuffer:")); BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PacketLoss:")); } - if (metrics->rtcp_sr_count + metrics->rtcp_xr_count > 0) { + if (metrics->rtcp_sr_count + metrics->rtcp_xr_count > 0) BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "Delay:")); - } - if (metrics->rtcp_xr_count){ + if (metrics->rtcp_xr_count) BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "QualityEst:")); - } return body; } -void on_report_send_with_rtcp_xr_local (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { +static void on_report_send_with_rtcp_xr_local (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { char *remote_metrics_start = __strstr(linphone_content_get_string_buffer(content), "RemoteMetrics:"); reporting_session_report_t *report = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; on_report_send_mandatory(call, stream_type, content); @@ -88,33 +85,32 @@ void on_report_send_with_rtcp_xr_local (const LinphoneCall *call, SalStreamType 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, SalStreamType stream_type, const LinphoneContent *content){ - char * body = (char*)linphone_content_get_buffer(content); - reporting_session_report_t * report = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; +static 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 = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; - on_report_send_mandatory(call,stream_type,content); - if (report->remote_metrics.rtcp_sr_count+report->remote_metrics.rtcp_xr_count>0){ - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "RemoteMetrics:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "Timestamps:")); - on_report_send_verify_metrics(&report->remote_metrics,body); + on_report_send_mandatory(call, stream_type, content); + if ((report->remote_metrics.rtcp_sr_count + report->remote_metrics.rtcp_xr_count) > 0) { + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "RemoteMetrics:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "Timestamps:")); + on_report_send_verify_metrics(&report->remote_metrics, body); } } -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); + +static 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); } -bool_t create_call_for_quality_reporting_tests( - LinphoneCoreManager* marie, - LinphoneCoreManager* pauline, - LinphoneCall** call_marie, - LinphoneCall** call_pauline, - LinphoneCallParams * params_marie, - LinphoneCallParams * params_pauline - ) { - - - bool_t call_succeeded = call_with_params(marie,pauline,params_marie,params_pauline); +static bool_t create_call_for_quality_reporting_tests ( + LinphoneCoreManager *marie, + LinphoneCoreManager *pauline, + LinphoneCall **call_marie, + LinphoneCall **call_pauline, + LinphoneCallParams *params_marie, + LinphoneCallParams *params_pauline +) { + bool_t call_succeeded = call_with_params(marie, pauline, params_marie, params_pauline); BC_ASSERT_TRUE(call_succeeded); if (call_succeeded) { if (call_marie) { @@ -129,24 +125,23 @@ bool_t create_call_for_quality_reporting_tests( return call_succeeded; } -static void quality_reporting_not_used_without_config(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; +static void quality_reporting_not_used_without_config (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; reporting_session_report_t **quality_reports = NULL; - - if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { - // marie has stats collection enabled but pauline has not + if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { + // Marie has stats collection enabled but Pauline has not BC_ASSERT_TRUE(linphone_proxy_config_quality_reporting_enabled(linphone_call_get_dest_proxy(call_marie))); BC_ASSERT_FALSE(linphone_proxy_config_quality_reporting_enabled(linphone_call_get_dest_proxy(call_pauline))); - // this field should be already filled + // This field should be already filled quality_reports = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call_marie))); BC_ASSERT_PTR_NOT_NULL(quality_reports[0]->info.local_addr.ip); - // but not this one since it is updated at the end of call + // But not this one since it is updated at the end of call BC_ASSERT_PTR_NULL(quality_reports[0]->dialog_id); end_call(marie, pauline); } @@ -155,89 +150,92 @@ static void quality_reporting_not_used_without_config(void) { linphone_core_manager_destroy(pauline); } -static void quality_reporting_not_sent_if_call_not_started(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCallLog* out_call_log; - LinphoneCall* out_call; +static void quality_reporting_not_sent_if_call_not_started (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCallLog *out_call_log; + LinphoneCall *out_call; - linphone_core_set_max_calls(pauline->lc,0); - out_call = linphone_core_invite(marie->lc,"pauline"); + linphone_core_set_max_calls(pauline->lc, 0); + out_call = linphone_core_invite(marie->lc, "pauline"); BC_ASSERT_PTR_NOT_NULL(out_call); - if(out_call == NULL) goto end; + if (!out_call) + goto end; linphone_call_ref(out_call); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallError,1, 10000)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1, int, "%d"); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallError, 1, 10000)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError, 1, int, "%d"); - if (bctbx_list_size(linphone_core_get_call_logs(marie->lc))>0) { - out_call_log=(LinphoneCallLog*)(linphone_core_get_call_logs(marie->lc)->data); + if (bctbx_list_size(linphone_core_get_call_logs(marie->lc)) > 0) { + out_call_log = (LinphoneCallLog *)(linphone_core_get_call_logs(marie->lc)->data); BC_ASSERT_PTR_NOT_NULL(out_call_log); - BC_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log),LinphoneCallAborted, int, "%d"); + BC_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log), LinphoneCallAborted, int, "%d"); } linphone_call_unref(out_call); - // wait a few time... - wait_for_until(marie->lc,NULL,NULL,0,1000); + // Wait a few time... + wait_for_until(marie->lc, NULL, NULL, 0, 1000); + + // Since the callee was busy, there should be no publish to do + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); - // since the callee was busy, there should be no publish to do - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0, int, "%d"); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void quality_reporting_not_sent_if_low_bandwidth(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCallParams* marie_params; - - marie_params=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_low_bandwidth(marie_params,TRUE); +static void quality_reporting_not_sent_if_low_bandwidth (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_low_bandwidth(marie_params, TRUE); if (create_call_for_quality_reporting_tests(marie, pauline, NULL, NULL, marie_params, NULL)) { end_call(marie, pauline); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0, int, "%d"); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); } linphone_call_params_unref(marie_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -void on_report_send_remove_fields(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ - char *body = (char *)linphone_content_get_string_buffer(content); - /*corrupt start of the report*/ +static void on_report_send_remove_fields (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { + char *body = bctbx_strdup(linphone_content_get_string_buffer(content)); + /* Corrupt start of the report */ strncpy(body, "corrupted report is corrupted", strlen("corrupted report is corrupted")); + linphone_content_set_string_buffer((LinphoneContent *)content, body); + bctbx_free(body); } -static void quality_reporting_invalid_report(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; +static void quality_reporting_invalid_report (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_remove_fields); end_call(marie, pauline); - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1)); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishError,1,3000)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishError,1, int, "%d"); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishProgress, 1)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishError, 1, 3000)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishError, 1, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void quality_reporting_at_call_termination(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; +static void quality_reporting_at_call_termination (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc_rtcp_xr"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; reporting_session_report_t **quality_reports = NULL; if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { @@ -245,32 +243,33 @@ static void quality_reporting_at_call_termination(void) { linphone_core_terminate_all_calls(marie->lc); - // now dialog id should be filled + // Now dialog id should be filled quality_reports = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call_marie))); BC_ASSERT_PTR_NOT_NULL(quality_reports[0]->dialog_id); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallReleased,1, 10000)); - BC_ASSERT_TRUE(wait_for_until(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallReleased,1, 10000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1, 10000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneCallReleased, 1, 10000)); BC_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc)); BC_ASSERT_PTR_NULL(linphone_core_get_current_call(pauline->lc)); // PUBLISH submission to the collector should be ok - BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,1, int, "%d"); - BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishOk,1)); + BC_ASSERT_TRUE(wait_for(marie->lc, NULL, &marie->stat.number_of_LinphonePublishProgress, 1)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 1, int, "%d"); + BC_ASSERT_TRUE(wait_for(marie->lc, NULL, &marie->stat.number_of_LinphonePublishOk, 1)); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void quality_reporting_interval_report(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; +static void quality_reporting_interval_report (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc_rtcp_xr"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc_rtcp_xr"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; - if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { + if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_mandatory); linphone_proxy_config_set_quality_reporting_interval(linphone_call_get_dest_proxy(call_marie), 1); @@ -278,67 +277,67 @@ static void quality_reporting_interval_report(void) { BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); // PUBLISH submission to the collector should be ok - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,60000)); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,60000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishProgress, 1, 60000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishOk, 1, 60000)); end_call(marie, pauline); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } #ifdef VIDEO_ENABLED -static void quality_reporting_session_report_if_video_stopped(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCall* call_pauline = NULL; - LinphoneCall* call_marie = NULL; - LinphoneCallParams* pauline_params; - LinphoneCallParams* marie_params; +static void quality_reporting_session_report_if_video_stopped (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc_rtcp_xr"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCall *call_pauline = NULL; + LinphoneCall *call_marie = NULL; + LinphoneCallParams *pauline_params; + LinphoneCallParams *marie_params; linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, FALSE); linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, FALSE); - marie_params=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_video(marie_params,TRUE); - pauline_params=linphone_core_create_call_params(pauline->lc, NULL); - linphone_call_params_enable_video(pauline_params,TRUE); + marie_params = linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_video(marie_params, TRUE); + pauline_params = linphone_core_create_call_params(pauline->lc, NULL); + linphone_call_params_enable_video(pauline_params, TRUE); if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_with_rtcp_xr_local); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0, int, "%d"); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,NULL,0,3000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, NULL, 0, 3000)); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); - /*remove video*/ + /* Remove video */ linphone_call_params_unref(pauline_params); - pauline_params=linphone_core_create_call_params(pauline->lc, call_pauline); - linphone_call_params_enable_video(pauline_params,FALSE); - linphone_call_update(call_pauline,pauline_params); + pauline_params = linphone_core_create_call_params(pauline->lc, call_pauline); + linphone_call_params_enable_video(pauline_params, FALSE); + linphone_call_update(call_pauline, pauline_params); linphone_call_params_unref(pauline_params); - 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_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))); end_call(marie, pauline); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,2,5000)); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,2,5000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishProgress, 2, 5000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishOk, 2, 5000)); } linphone_call_params_unref(marie_params); - linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } #endif -void publish_report_with_route_state_changed(LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state){ +static void publish_report_with_route_state_changed (LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state) { if (state == LinphonePublishProgress) { char *uri = linphone_address_as_string(linphone_event_get_resource(ev)); BC_ASSERT_STRING_EQUAL(uri, linphone_proxy_config_get_quality_reporting_collector(linphone_core_get_default_proxy_config(lc))); @@ -347,58 +346,59 @@ void publish_report_with_route_state_changed(LinphoneCore *lc, LinphoneEvent *ev } static void quality_reporting_sent_using_custom_route(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get()); linphone_core_cbs_set_publish_state_changed(cbs, publish_report_with_route_state_changed); linphone_core_add_callbacks(marie->lc, cbs); linphone_core_cbs_unref(cbs); - //INVALID collector: sip.linphone.org do not collect reports, so it will throw a 404 Not Found error + // INVALID collector: sip.linphone.org do not collect reports, so it will throw a 404 Not Found error linphone_proxy_config_set_quality_reporting_collector(linphone_core_get_default_proxy_config(marie->lc), "sip:sip.linphone.org"); if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { end_call(marie, pauline); // PUBLISH submission to the collector should be ERROR since route is not valid - BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,1, int, "%d"); - BC_ASSERT_TRUE(wait_for_until(marie->lc,NULL,&marie->stat.number_of_LinphonePublishError,1,10000)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0,int, "%d"); + BC_ASSERT_TRUE(wait_for(marie->lc, NULL, &marie->stat.number_of_LinphonePublishProgress, 1)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 1, int, "%d"); + BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphonePublishError, 1, 10000)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } #ifdef VIDEO_ENABLED -static void quality_reporting_interval_report_video_and_rtt(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; - LinphoneCallParams* pauline_params; - LinphoneCallParams* marie_params; +static void quality_reporting_interval_report_video_and_rtt (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc_rtcp_xr"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc_rtcp_xr"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; + LinphoneCallParams *pauline_params; + LinphoneCallParams *marie_params; LinphoneChatRoom *pauline_chat_room; linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, FALSE); linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, FALSE); - marie_params=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_video(marie_params,TRUE); - linphone_call_params_enable_realtime_text(marie_params,TRUE); - pauline_params=linphone_core_create_call_params(pauline->lc, NULL); - linphone_call_params_enable_video(pauline_params,TRUE); - linphone_call_params_enable_realtime_text(pauline_params,TRUE); + marie_params = linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_video(marie_params, TRUE); + linphone_call_params_enable_realtime_text(marie_params, TRUE); + pauline_params = linphone_core_create_call_params(pauline->lc, NULL); + linphone_call_params_enable_video(pauline_params, TRUE); + linphone_call_params_enable_realtime_text(pauline_params, TRUE); - if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) { + if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_mandatory); linphone_proxy_config_set_quality_reporting_interval(linphone_call_get_dest_proxy(call_marie), 3); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,NULL,0,3000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, NULL, 0, 3000)); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(call_pauline))); @@ -406,29 +406,29 @@ static void quality_reporting_interval_report_video_and_rtt(void) { BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); // PUBLISH submission to the collector should be ok - 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,10000)); + 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, 10000)); pauline_chat_room = linphone_call_get_chat_room(call_pauline); BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); LinphoneChatMessage *rtt_message = NULL; if (pauline_chat_room) { - const char* message = "Lorem Ipsum Belledonnum Communicatum"; + const char *message = "Lorem Ipsum Belledonnum Communicatum"; size_t i; - rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); + rtt_message = linphone_chat_room_create_message(pauline_chat_room, NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(call_marie); for (i = 0; i < strlen(message); i++) { linphone_chat_message_put_char(rtt_message, message[i]); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)(i + 1), 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c"); } - linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); + linphone_chat_message_send(rtt_message); } end_call(marie, pauline); - /*wait that all publish complete*/ - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,marie->stat.number_of_LinphonePublishProgress,60000)); + /* Wait that all publish complete */ + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishOk, marie->stat.number_of_LinphonePublishProgress, 60000)); if (rtt_message) linphone_chat_message_unref(rtt_message); @@ -442,10 +442,10 @@ static void quality_reporting_interval_report_video_and_rtt(void) { } #endif -static void video_bandwidth_estimation(void){ +static void video_bandwidth_estimation (void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); - LinphoneVideoPolicy pol = {0}; + LinphoneVideoPolicy pol = { 0 }; OrtpNetworkSimulatorParams simparams = { 0 }; linphone_core_set_video_device(marie->lc, "Mire: Mire (synthetic moving picture)"); @@ -465,14 +465,15 @@ static void video_bandwidth_estimation(void){ simparams.max_bandwidth = 300000; linphone_core_set_network_simulator_params(marie->lc, &simparams); - if (BC_ASSERT_TRUE(call(marie, pauline))){ - /*wait for the first TMMBR*/ + if (BC_ASSERT_TRUE(call(marie, pauline))) { + /* Wait for the first TMMBR */ BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_tmmbr_received, 1, 50000)); BC_ASSERT_GREATER((float)marie->stat.last_tmmbr_value_received, 270000.f, float, "%f"); BC_ASSERT_LOWER((float)marie->stat.last_tmmbr_value_received, 330000.f, float, "%f"); end_call(marie, pauline); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }