Commit d3e68666 authored by Ghislain MARY's avatar Ghislain MARY

Add tests to check payload type changes during streaming.

parent 051147bd
......@@ -83,17 +83,15 @@ static void reset_stats(stats_t* s) {
static void notify_cb(void *user_data, MSFilter *f, unsigned int event, void *eventdata) {
stats_t* stats = (stats_t*)user_data;
switch (event) {
case MS_FILE_PLAYER_EOF: {
ms_message("EndOfFile received");
stats->number_of_EndOfFile++;
case MS_FILE_PLAYER_EOF: {
ms_message("EndOfFile received");
stats->number_of_EndOfFile++;
break;
}
break;
}
break;
}
}
static void basic_audio_stream_base( const char* marielle_local_ip
......@@ -111,9 +109,9 @@ static void basic_audio_stream_base( const char* marielle_local_ip
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);
rtp_session_set_multicast_loopback(margaux->ms.sessions.rtp_session,TRUE);
reset_stats(&marielle_stats);
reset_stats(&marielle_stats);
reset_stats(&margaux_stats);
rtp_profile_set_payload (profile,0,&payload_type_pcmu8000);
......@@ -166,7 +164,9 @@ static void basic_audio_stream_base( const char* marielle_local_ip
unlink(recorded_file);
ms_free(recorded_file);
ms_free(hello_file);
rtp_profile_destroy(profile);
}
static void basic_audio_stream() {
basic_audio_stream_base(MARIELLE_IP,MARIELLE_RTP_PORT,MARIELLE_RTCP_PORT
,MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT);
......@@ -308,27 +308,90 @@ static void encrypted_audio_stream_base( bool_t change_ssrc,
audio_stream_stop(marielle);
audio_stream_stop(margaux);
rtp_profile_destroy(profile);
}
static void encrypted_audio_stream(void) {
encrypted_audio_stream_base(FALSE, FALSE, FALSE, TRUE);
}
static void encrypted_audio_stream() {
encrypted_audio_stream_base(FALSE,FALSE,FALSE,TRUE);
static void encrypted_audio_stream_with_2_srtp_stream(void) {
encrypted_audio_stream_base(FALSE, FALSE, TRUE, TRUE);
}
static void encrypted_audio_stream_with_2_srtp_stream() {
encrypted_audio_stream_base(FALSE,FALSE,TRUE,TRUE);
static void encrypted_audio_stream_with_2_srtp_stream_recv_first(void) {
encrypted_audio_stream_base(FALSE, FALSE, TRUE, FALSE);
}
static void encrypted_audio_stream_with_2_srtp_stream_recv_first() {
encrypted_audio_stream_base(FALSE,FALSE,TRUE,FALSE);
static void encrypted_audio_stream_with_key_change(void) {
encrypted_audio_stream_base(FALSE, TRUE, FALSE, TRUE);
}
static void encrypted_audio_stream_with_key_change() {
encrypted_audio_stream_base(FALSE,TRUE,FALSE,TRUE);
static void encrypted_audio_stream_with_ssrc_change(void) {
encrypted_audio_stream_base(TRUE, FALSE, FALSE, TRUE);
}
static void encrypted_audio_stream_with_ssrc_change() {
encrypted_audio_stream_base(TRUE,FALSE,FALSE,TRUE);
static void codec_change_for_audio_stream(void) {
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT);
stats_t marielle_stats;
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_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;
reset_stats(&marielle_stats);
reset_stats(&margaux_stats);
rtp_profile_set_payload(profile, 0, &payload_type_pcmu8000);
rtp_profile_set_payload(profile, 8, &payload_type_pcma8000);
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);
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);
reset_stats(&marielle_stats);
reset_stats(&margaux_stats);
CU_ASSERT_EQUAL(audio_stream_start_full(marielle, profile, MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_IP, MARGAUX_RTCP_PORT,
8, 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);
rtp_profile_destroy(profile);
}
#if 0
static void audio_stream_dtmf(int codec_payload, int initial_bitrate,int target_bw, int max_recv_rtcp_packet) {
stream_manager_t * marielle = stream_manager_new();
......@@ -366,7 +429,6 @@ static void audio_stream_dtmf(int codec_payload, int initial_bitrate,int target_
stream_manager_delete(margaux);
}
#endif
......@@ -374,10 +436,11 @@ static test_t tests[] = {
{ "Basic audio stream", basic_audio_stream },
{ "Multicast audio stream", multicast_audio_stream },
{ "Encrypted audio stream", encrypted_audio_stream },
{ "Encrypted audio stream with 2 srtp context",encrypted_audio_stream_with_2_srtp_stream},
{ "Encrypted audio stream with 2 srtp context, recv first",encrypted_audio_stream_with_2_srtp_stream_recv_first},
{ "Encrypted audio stream with ssrc changes", encrypted_audio_stream_with_ssrc_change},
{ "Encrypted audio stream with key change",encrypted_audio_stream_with_key_change},
{ "Encrypted audio stream with 2 srtp context", encrypted_audio_stream_with_2_srtp_stream },
{ "Encrypted audio stream with 2 srtp context, recv first", encrypted_audio_stream_with_2_srtp_stream_recv_first },
{ "Encrypted audio stream with ssrc changes", encrypted_audio_stream_with_ssrc_change },
{ "Encrypted audio stream with key change", encrypted_audio_stream_with_key_change },
{ "Codec change for audio stream", codec_change_for_audio_stream }
};
test_suite_t audio_stream_test_suite = {
......
......@@ -93,6 +93,7 @@ typedef struct _video_stream_tester_t {
int local_rtp;
int local_rtcp;
MSWebCam * cam;
int payload_type;
} video_stream_tester_t;
void video_stream_tester_set_local_ip(video_stream_tester_t* obj,const char*ip) {
......@@ -200,21 +201,36 @@ static void event_queue_cb(MediaStream *ms, void *user_pointer) {
}
}
static void init_video_streams(video_stream_tester_t *marielle, video_stream_tester_t *margaux, bool_t avpf, bool_t one_way, OrtpNetworkSimulatorParams *params,int payload_type) {
static void create_video_stream(video_stream_tester_t *vst, int payload_type) {
vst->vs = video_stream_new2(vst->local_ip, vst->local_rtp, vst->local_rtcp);
vst->vs->staticimage_webcam_fps_optimization = FALSE;
vst->local_rtp = rtp_session_get_local_port(vst->vs->ms.sessions.rtp_session);
vst->local_rtcp = rtp_session_get_local_rtcp_port(vst->vs->ms.sessions.rtp_session);
reset_stats(&vst->stats);
rtp_session_set_multicast_loopback(vst->vs->ms.sessions.rtp_session, TRUE);
vst->stats.q = ortp_ev_queue_new();
rtp_session_register_event_queue(vst->vs->ms.sessions.rtp_session, vst->stats.q);
video_stream_set_event_callback(vst->vs, video_stream_event_cb, vst);
if (vst->vconf) {
PayloadType *pt = rtp_profile_get_payload(&rtp_profile, payload_type);
CU_ASSERT_PTR_NOT_NULL_FATAL(pt);
pt->normal_bitrate = vst->vconf->required_bitrate;
video_stream_set_fps(vst->vs, vst->vconf->fps);
video_stream_set_sent_video_size(vst->vs, vst->vconf->vsize);
}
vst->payload_type = payload_type;
}
static void destroy_video_stream(video_stream_tester_t *vst) {
video_stream_stop(vst->vs);
ortp_ev_queue_destroy(vst->stats.q);
}
static void init_video_streams(video_stream_tester_t *vst1, video_stream_tester_t *vst2, bool_t avpf, bool_t one_way, OrtpNetworkSimulatorParams *params, int payload_type) {
PayloadType *pt;
marielle->vs = video_stream_new2(marielle->local_ip,marielle->local_rtp, marielle->local_rtcp);
marielle->vs->staticimage_webcam_fps_optimization = FALSE;
marielle->local_rtp=rtp_session_get_local_port(marielle->vs->ms.sessions.rtp_session);
marielle->local_rtcp=rtp_session_get_local_rtcp_port(marielle->vs->ms.sessions.rtp_session);
margaux->vs = video_stream_new2(margaux->local_ip, margaux->local_rtp, margaux->local_rtcp);
margaux->vs->staticimage_webcam_fps_optimization = FALSE;
margaux->local_rtp=rtp_session_get_local_port(margaux->vs->ms.sessions.rtp_session);
margaux->local_rtcp=rtp_session_get_local_rtcp_port(margaux->vs->ms.sessions.rtp_session);
reset_stats(&marielle->stats);
reset_stats(&margaux->stats);
rtp_session_set_multicast_loopback(marielle->vs->ms.sessions.rtp_session,TRUE);
rtp_session_set_multicast_loopback(margaux->vs->ms.sessions.rtp_session,TRUE);
create_video_stream(vst1, payload_type);
create_video_stream(vst2, payload_type);
/* Enable/disable avpf. */
pt = rtp_profile_get_payload(&rtp_profile, payload_type);
......@@ -227,66 +243,47 @@ static void init_video_streams(video_stream_tester_t *marielle, video_stream_tes
/* Configure network simulator. */
if ((params != NULL) && (params->enabled == TRUE)) {
rtp_session_enable_network_simulation(marielle->vs->ms.sessions.rtp_session, params);
rtp_session_enable_network_simulation(margaux->vs->ms.sessions.rtp_session, params);
rtp_session_enable_network_simulation(vst1->vs->ms.sessions.rtp_session, params);
rtp_session_enable_network_simulation(vst2->vs->ms.sessions.rtp_session, params);
}
marielle->stats.q = ortp_ev_queue_new();
rtp_session_register_event_queue(marielle->vs->ms.sessions.rtp_session, marielle->stats.q);
video_stream_set_event_callback(marielle->vs,video_stream_event_cb, marielle);
margaux->stats.q = ortp_ev_queue_new();
rtp_session_register_event_queue(margaux->vs->ms.sessions.rtp_session, margaux->stats.q);
video_stream_set_event_callback(margaux->vs,video_stream_event_cb, margaux);
if (one_way == TRUE) {
video_stream_set_direction(marielle->vs, VideoStreamRecvOnly);
}
if (marielle->vconf) {
PayloadType *pt = rtp_profile_get_payload(&rtp_profile, payload_type);
pt->normal_bitrate=marielle->vconf->required_bitrate;
video_stream_set_fps(marielle->vs,marielle->vconf->fps);
video_stream_set_sent_video_size(marielle->vs,marielle->vconf->vsize);
video_stream_set_direction(vst1->vs, VideoStreamRecvOnly);
}
CU_ASSERT_EQUAL(
video_stream_start(marielle->vs, &rtp_profile, margaux->local_ip, margaux->local_rtp, margaux->local_ip, margaux->local_rtcp, payload_type, 50, marielle->cam),
0);
if (margaux->vconf) {
PayloadType *pt = rtp_profile_get_payload(&rtp_profile, payload_type);
pt->normal_bitrate=margaux->vconf->required_bitrate;
video_stream_set_fps(margaux->vs,margaux->vconf->fps);
video_stream_set_sent_video_size(margaux->vs,margaux->vconf->vsize);
}
CU_ASSERT_EQUAL(
video_stream_start(margaux->vs, &rtp_profile, marielle->local_ip, marielle->local_rtp, marielle->local_ip, marielle->local_rtcp, payload_type, 50, margaux->cam),
0);
CU_ASSERT_EQUAL(video_stream_start(vst1->vs, &rtp_profile, vst2->local_ip, vst2->local_rtp, vst2->local_ip, vst2->local_rtcp, payload_type, 50, vst1->cam), 0);
CU_ASSERT_EQUAL(video_stream_start(vst2->vs, &rtp_profile, vst1->local_ip, vst1->local_rtp, vst1->local_ip, vst1->local_rtcp, payload_type, 50, vst2->cam), 0);
}
static void uninit_video_streams(video_stream_tester_t *marielle, video_stream_tester_t *margaux) {
static void uninit_video_streams(video_stream_tester_t *vst1, video_stream_tester_t *vst2) {
float rtcp_send_bandwidth;
PayloadType *pt;
pt = rtp_profile_get_payload(&rtp_profile, VP8_PAYLOAD_TYPE);
CU_ASSERT_PTR_NOT_NULL_FATAL(pt);
PayloadType *vst1_pt;
PayloadType *vst2_pt;
vst1_pt = rtp_profile_get_payload(&rtp_profile, vst1->payload_type);
CU_ASSERT_PTR_NOT_NULL_FATAL(vst1_pt);
vst2_pt = rtp_profile_get_payload(&rtp_profile, vst2->payload_type);
CU_ASSERT_PTR_NOT_NULL_FATAL(vst2_pt);
rtp_session_compute_send_bandwidth(vst1->vs->ms.sessions.rtp_session);
rtp_session_compute_send_bandwidth(vst2->vs->ms.sessions.rtp_session);
rtcp_send_bandwidth = rtp_session_get_rtcp_send_bandwidth(vst1->vs->ms.sessions.rtp_session);
CU_ASSERT_TRUE(rtcp_send_bandwidth <= (0.06 * payload_type_get_bitrate(vst1_pt)));
rtcp_send_bandwidth = rtp_session_get_rtcp_send_bandwidth(vst2->vs->ms.sessions.rtp_session);
CU_ASSERT_TRUE(rtcp_send_bandwidth <= (0.06 * payload_type_get_bitrate(vst2_pt)));
destroy_video_stream(vst1);
destroy_video_stream(vst2);
}
rtp_session_compute_send_bandwidth(marielle->vs->ms.sessions.rtp_session);
rtp_session_compute_send_bandwidth(margaux->vs->ms.sessions.rtp_session);
rtcp_send_bandwidth = rtp_session_get_rtcp_send_bandwidth(marielle->vs->ms.sessions.rtp_session);
CU_ASSERT_TRUE(rtcp_send_bandwidth <= (0.06 * payload_type_get_bitrate(pt)));
rtcp_send_bandwidth = rtp_session_get_rtcp_send_bandwidth(margaux->vs->ms.sessions.rtp_session);
CU_ASSERT_TRUE(rtcp_send_bandwidth <= (0.06 * payload_type_get_bitrate(pt)));
static void change_codec(video_stream_tester_t *vst1, video_stream_tester_t *vst2, int payload_type) {
MSWebCam *no_webcam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "StaticImage: Static picture");
video_stream_stop(marielle->vs);
video_stream_stop(margaux->vs);
if (vst1->payload_type == payload_type) return;
ortp_ev_queue_destroy(marielle->stats.q);
ortp_ev_queue_destroy(margaux->stats.q);
destroy_video_stream(vst1);
create_video_stream(vst1, payload_type);
CU_ASSERT_EQUAL(video_stream_start(vst1->vs, &rtp_profile, vst2->local_ip, vst2->local_rtp, vst2->local_ip, vst2->local_rtcp, payload_type, 50, no_webcam), 0);
}
static void basic_video_stream(void) {
......@@ -327,6 +324,33 @@ static void basic_one_way_video_stream(void) {
video_stream_tester_destroy(margaux);
}
static void codec_change_for_video_stream(void) {
video_stream_tester_t *marielle = video_stream_tester_new();
video_stream_tester_t *margaux = video_stream_tester_new();
bool_t vp8_supported = ms_filter_codec_supported("vp8");
bool_t h264_supported = ms_filter_codec_supported("h264");
if (vp8_supported) {
init_video_streams(marielle, margaux, FALSE, FALSE, NULL, VP8_PAYLOAD_TYPE);
CU_ASSERT_TRUE(wait_for_until(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_decoder_first_image_decoded, 1, 2000));
CU_ASSERT_TRUE(wait_for_until(&marielle->vs->ms, &margaux->vs->ms, &margaux->stats.number_of_decoder_first_image_decoded, 1, 2000));
CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_SR, 2, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
if (h264_supported) {
change_codec(marielle, margaux, H264_PAYLOAD_TYPE);
CU_ASSERT_TRUE(wait_for_until(&marielle->vs->ms, &margaux->vs->ms, &margaux->stats.number_of_decoder_first_image_decoded, 2, 2000));
CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_SR, 2, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
} else {
ms_error("H264 codec is not supported!");
}
uninit_video_streams(marielle, margaux);
} else {
ms_error("VP8 codec is not supported!");
}
video_stream_tester_destroy(marielle);
video_stream_tester_destroy(margaux);
}
static void multicast_video_stream(void) {
video_stream_tester_t* marielle=video_stream_tester_new();
video_stream_tester_t* margaux=video_stream_tester_new();
......@@ -565,14 +589,15 @@ static void video_configuration_stream(void) {
static test_t tests[] = {
{ "Basic video stream", basic_video_stream },
{ "Multicast video stream",multicast_video_stream},
{ "Multicast video stream",multicast_video_stream },
{ "Basic one-way video stream", basic_one_way_video_stream },
{ "Codec change for video stream", codec_change_for_video_stream },
{ "AVPF video stream", avpf_video_stream },
{ "AVPF high-loss video stream", avpf_high_loss_video_stream },
{ "AVPF very high-loss video stream", avpf_very_high_loss_video_stream },
{ "AVPF PLI on first iframe lost",avpf_video_stream_first_iframe_lost_vp8},
{ "AVP PLI on first iframe lost",video_stream_first_iframe_lost_vp8},
{ "Video configuration",video_configuration_stream},
{ "AVPF PLI on first iframe lost", avpf_video_stream_first_iframe_lost_vp8 },
{ "AVP PLI on first iframe lost", video_stream_first_iframe_lost_vp8 },
{ "Video configuration", video_configuration_stream },
{ "AVPF RPSI count", avpf_rpsi_count}
};
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment