static void basic_audio_stream() { AudioStream * marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE); stats_t marielle_stats; AudioStream * margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE); stats_t margaux_stats; RtpProfile* profile = rtp_profile_new("default profile"); reset_stats(&marielle_stats); reset_stats(&margaux_stats); rtp_profile_set_payload (profile,0,&payload_type_pcmu8000); CU_ASSERT_EQUAL(audio_stream_start_full(margaux , profile , MARIELLE_IP , MARIELLE_RTP_PORT , MARIELLE_IP , MARIELLE_RTCP_PORT , 0 , 50 , NULL , RECORDED_8K_1S_FILE , NULL , NULL , 0),0); CU_ASSERT_EQUAL(audio_stream_start_full(marielle , profile , MARGAUX_IP , MARGAUX_RTP_PORT , MARGAUX_IP , MARGAUX_RTCP_PORT , 0 , 50 , HELLO_8K_1S_FILE , NULL , NULL , NULL , 0),0); ms_filter_add_notify_callback(marielle->soundread, notify_cb, &marielle_stats,TRUE); CU_ASSERT_TRUE(wait_for_until(&marielle->ms,&margaux->ms,&marielle_stats.number_of_EndOfFile,1,12000)); audio_stream_get_local_rtp_stats(marielle,&marielle_stats.rtp); audio_stream_get_local_rtp_stats(margaux,&margaux_stats.rtp); /* No packet loss is assumed */ CU_ASSERT_EQUAL(marielle_stats.rtp.sent,margaux_stats.rtp.recv); audio_stream_stop(marielle); audio_stream_stop(margaux); unlink(RECORDED_8K_1S_FILE); }
static void basic_audio_stream_base( const char* marielle_local_ip , int marielle_local_rtp_port , int marielle_local_rtcp_port , const char* margaux_local_ip , int margaux_local_rtp_port , int margaux_local_rtcp_port) { AudioStream * marielle = audio_stream_new2 (marielle_local_ip, marielle_local_rtp_port, marielle_local_rtcp_port); stats_t marielle_stats; AudioStream * margaux = audio_stream_new2 (margaux_local_ip, margaux_local_rtp_port,margaux_local_rtcp_port); stats_t margaux_stats; RtpProfile* profile = rtp_profile_new("default profile"); char* hello_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_file_root(), HELLO_8K_1S_FILE); char* recorded_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_writable_dir(), RECORDED_8K_1S_FILE); int dummy=0; rtp_session_set_multicast_loopback(marielle->ms.sessions.rtp_session,TRUE); rtp_session_set_multicast_loopback(margaux->ms.sessions.rtp_session,TRUE); reset_stats(&marielle_stats); reset_stats(&margaux_stats); rtp_profile_set_payload (profile,0,&payload_type_pcmu8000); CU_ASSERT_EQUAL(audio_stream_start_full(margaux , profile , ms_is_multicast(margaux_local_ip)?margaux_local_ip:marielle_local_ip , ms_is_multicast(margaux_local_ip)?margaux_local_rtp_port:marielle_local_rtp_port , marielle_local_ip , marielle_local_rtcp_port , 0 , 50 , NULL , recorded_file , NULL , NULL , 0),0); CU_ASSERT_EQUAL(audio_stream_start_full(marielle , profile , margaux_local_ip , margaux_local_rtp_port , margaux_local_ip , margaux_local_rtcp_port , 0 , 50 , hello_file , NULL , NULL , NULL , 0),0); ms_filter_add_notify_callback(marielle->soundread, notify_cb, &marielle_stats,TRUE); CU_ASSERT_TRUE(wait_for_until(&marielle->ms,&margaux->ms,&marielle_stats.number_of_EndOfFile,1,12000)); /*make sure packets can cross from sender to receiver*/ wait_for_until(&marielle->ms,&margaux->ms,&dummy,1,500); audio_stream_get_local_rtp_stats(marielle,&marielle_stats.rtp); audio_stream_get_local_rtp_stats(margaux,&margaux_stats.rtp); /* No packet loss is assumed */ CU_ASSERT_EQUAL(marielle_stats.rtp.sent,margaux_stats.rtp.recv); audio_stream_stop(marielle); audio_stream_stop(margaux); unlink(recorded_file); ms_free(recorded_file); ms_free(hello_file); }
static void encrypted_audio_stream_base( bool_t change_ssrc, bool_t change_send_key_in_the_middle ,bool_t set_both_send_recv_key ,bool_t send_key_first) { AudioStream * marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE); AudioStream * margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE); RtpProfile* profile = rtp_profile_new("default profile"); char* hello_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_file_root(), HELLO_8K_1S_FILE); char* recorded_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_writable_dir(), RECORDED_8K_1S_FILE); stats_t marielle_stats; stats_t margaux_stats; int dummy=0; if (ms_srtp_supported()) { reset_stats(&marielle_stats); reset_stats(&margaux_stats); rtp_profile_set_payload (profile,0,&payload_type_pcmu8000); CU_ASSERT_EQUAL(audio_stream_start_full(margaux , profile , MARIELLE_IP , MARIELLE_RTP_PORT , MARIELLE_IP , MARIELLE_RTCP_PORT , 0 , 50 , NULL , recorded_file , NULL , NULL , 0),0); CU_ASSERT_EQUAL(audio_stream_start_full(marielle , profile , MARGAUX_IP , MARGAUX_RTP_PORT , MARGAUX_IP , MARGAUX_RTCP_PORT , 0 , 50 , hello_file , NULL , NULL , NULL , 0),0); if (send_key_first) { CU_ASSERT_TRUE(media_stream_set_srtp_send_key_b64(&(marielle->ms.sessions), MS_AES_128_SHA1_32, "d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") == 0); if (set_both_send_recv_key) CU_ASSERT_TRUE(media_stream_set_srtp_send_key_b64(&(margaux->ms.sessions), MS_AES_128_SHA1_32, "6jCLmtRkVW9E/BUuJtYj/R2z6+4iEe06/DWohQ9F") == 0); CU_ASSERT_TRUE(media_stream_set_srtp_recv_key_b64(&(margaux->ms.sessions), MS_AES_128_SHA1_32, "d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") ==0); if (set_both_send_recv_key) CU_ASSERT_TRUE(media_stream_set_srtp_recv_key_b64(&(marielle->ms.sessions), MS_AES_128_SHA1_32, "6jCLmtRkVW9E/BUuJtYj/R2z6+4iEe06/DWohQ9F") ==0); } else { CU_ASSERT_TRUE(media_stream_set_srtp_recv_key_b64(&(margaux->ms.sessions), MS_AES_128_SHA1_32, "d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") ==0); if (set_both_send_recv_key) CU_ASSERT_TRUE(media_stream_set_srtp_recv_key_b64(&(marielle->ms.sessions), MS_AES_128_SHA1_32, "6jCLmtRkVW9E/BUuJtYj/R2z6+4iEe06/DWohQ9F") ==0); CU_ASSERT_TRUE(media_stream_set_srtp_send_key_b64(&(marielle->ms.sessions), MS_AES_128_SHA1_32, "d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") == 0); if (set_both_send_recv_key) CU_ASSERT_TRUE(media_stream_set_srtp_send_key_b64(&(margaux->ms.sessions), MS_AES_128_SHA1_32, "6jCLmtRkVW9E/BUuJtYj/R2z6+4iEe06/DWohQ9F") == 0); } ms_filter_add_notify_callback(marielle->soundread, notify_cb, &marielle_stats,TRUE); if (change_send_key_in_the_middle) { int dummy=0; wait_for_until(&marielle->ms,&margaux->ms,&dummy,1,2000); CU_ASSERT_TRUE(media_stream_set_srtp_send_key_b64(&(marielle->ms.sessions), MS_AES_128_SHA1_32, "eCYF4nYyCvmCpFWjUeDaxI2GWp2BzCRlIPfg52Te") == 0); CU_ASSERT_TRUE(media_stream_set_srtp_recv_key_b64(&(margaux->ms.sessions), MS_AES_128_SHA1_32, "eCYF4nYyCvmCpFWjUeDaxI2GWp2BzCRlIPfg52Te") ==0); } CU_ASSERT_TRUE(wait_for_until(&marielle->ms,&margaux->ms,&marielle_stats.number_of_EndOfFile,1,12000)); /*make sure packets can cross from sender to receiver*/ wait_for_until(&marielle->ms,&margaux->ms,&dummy,1,500); audio_stream_get_local_rtp_stats(marielle,&marielle_stats.rtp); audio_stream_get_local_rtp_stats(margaux,&margaux_stats.rtp); /* No packet loss is assumed */ if (change_send_key_in_the_middle) { /*we can accept one or 2 error in such case*/ CU_ASSERT_TRUE((marielle_stats.rtp.packet_sent-margaux_stats.rtp.packet_recv)<3); } else CU_ASSERT_EQUAL(marielle_stats.rtp.sent,margaux_stats.rtp.recv); if (change_ssrc) { audio_stream_stop(marielle); marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE); CU_ASSERT_EQUAL(audio_stream_start_full(marielle , profile , MARGAUX_IP , MARGAUX_RTP_PORT , MARGAUX_IP , MARGAUX_RTCP_PORT , 0 , 50 , hello_file , NULL , NULL , NULL , 0),0); CU_ASSERT_FATAL(media_stream_set_srtp_send_key_b64(&(marielle->ms.sessions), MS_AES_128_SHA1_32, "d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") == 0); ms_filter_add_notify_callback(marielle->soundread, notify_cb, &marielle_stats,TRUE); CU_ASSERT_TRUE(wait_for_until(&marielle->ms,&margaux->ms,&marielle_stats.number_of_EndOfFile,2,12000)); /*make sure packets can cross from sender to receiver*/ wait_for_until(&marielle->ms,&margaux->ms,&dummy,1,500); audio_stream_get_local_rtp_stats(marielle,&marielle_stats.rtp); audio_stream_get_local_rtp_stats(margaux,&margaux_stats.rtp); /* No packet loss is assumed */ CU_ASSERT_EQUAL(marielle_stats.rtp.sent*2,margaux_stats.rtp.recv); } unlink(recorded_file); ms_free(recorded_file); ms_free(hello_file); } else { ms_warning("srtp not available, skiping..."); } audio_stream_stop(marielle); audio_stream_stop(margaux); rtp_profile_destroy(profile); }
static void basic_audio_stream_base_2( const char* marielle_local_ip , const char* marielle_remote_ip , int marielle_local_rtp_port , int marielle_remote_rtp_port , int marielle_local_rtcp_port , int marielle_remote_rtcp_port , const char* margaux_local_ip , const char* margaux_remote_ip , int margaux_local_rtp_port , int margaux_remote_rtp_port , int margaux_local_rtcp_port , int margaux_remote_rtcp_port , int lost_percentage) { AudioStream * marielle = audio_stream_new2 (_factory, marielle_local_ip, marielle_local_rtp_port, marielle_local_rtcp_port); stats_t marielle_stats; AudioStream * margaux = audio_stream_new2 (_factory, margaux_local_ip, margaux_local_rtp_port,margaux_local_rtcp_port); stats_t margaux_stats; RtpProfile* profile = rtp_profile_new("default profile"); char* hello_file = bc_tester_res(HELLO_8K_1S_FILE); char* recorded_file = bc_tester_file(RECORDED_8K_1S_FILE); uint64_t marielle_rtp_sent=0; rtp_session_set_multicast_loopback(marielle->ms.sessions.rtp_session,TRUE); rtp_session_set_multicast_loopback(margaux->ms.sessions.rtp_session,TRUE); rtp_session_set_rtcp_report_interval(marielle->ms.sessions.rtp_session, 1000); rtp_session_set_rtcp_report_interval(margaux->ms.sessions.rtp_session, 1000); reset_stats(&marielle_stats); reset_stats(&margaux_stats); rtp_profile_set_payload (profile,0,&payload_type_pcmu8000); BC_ASSERT_EQUAL(audio_stream_start_full(margaux , profile , ms_is_multicast(margaux_local_ip)?margaux_local_ip:margaux_remote_ip , ms_is_multicast(margaux_local_ip)?margaux_local_rtp_port:margaux_remote_rtp_port , margaux_remote_ip , margaux_remote_rtcp_port , 0 , 50 , NULL , recorded_file , NULL , NULL , 0) ,0, int, "%d"); BC_ASSERT_EQUAL(audio_stream_start_full(marielle , profile , marielle_remote_ip , marielle_remote_rtp_port , marielle_remote_ip , marielle_remote_rtcp_port , 0 , 50 , hello_file , NULL , NULL , NULL , 0) ,0, int, "%d"); ms_filter_add_notify_callback(marielle->soundread, notify_cb, &marielle_stats,TRUE); wait_for_until(&marielle->ms,&margaux->ms,&marielle_stats.number_of_EndOfFile,1,12000); audio_stream_get_local_rtp_stats(marielle,&marielle_stats.rtp); audio_stream_get_local_rtp_stats(margaux,&margaux_stats.rtp); marielle_rtp_sent = marielle_stats.rtp.sent; if (rtp_session_rtcp_enabled(marielle->ms.sessions.rtp_session) && rtp_session_rtcp_enabled(margaux->ms.sessions.rtp_session)) { BC_ASSERT_GREATER_STRICT(rtp_session_get_round_trip_propagation(marielle->ms.sessions.rtp_session),0,float,"%f"); BC_ASSERT_GREATER_STRICT(rtp_session_get_stats(marielle->ms.sessions.rtp_session)->recv_rtcp_packets,0,unsigned long long,"%llu"); }
static void linphone_call_log_fill_stats(LinphoneCallLog *log, AudioStream *st){ audio_stream_get_local_rtp_stats (st,&log->local_stats); log->quality=audio_stream_get_average_quality_rating(st); }