Commit 3caf5664 authored by Sandrine Avakian's avatar Sandrine Avakian

Added new structure to count RTCP feedback packets received for video stream :...

Added new structure to count RTCP feedback packets received for video stream : PLI, SLI, FIR and RPSI.
Modified test avpf_video_stream to use counters.
parent b032b1eb
......@@ -753,8 +753,15 @@ static MS2_INLINE RtpSession * audio_stream_get_rtp_session(const AudioStream *s
typedef void (*VideoStreamRenderCallback)(void *user_pointer, const MSPicture *local_view, const MSPicture *remote_view);
typedef void (*VideoStreamEventCallback)(void *user_pointer, const MSFilter *f, const unsigned int event_id, const void *args);
struct _MediastreamVideoStat
{
int counter_rcvd_pli; /*Picture Loss Indication counter */
int counter_rcvd_sli;/* Slice Loss Indication counter */
int counter_rcvd_rpsi; /*Reference Picture Selection Indication */
int counter_rcvd_fir; /* Full INTRA-frame Request */
};
typedef struct _MediastreamVideoStat MediaStreamVideoStat;
struct _VideoStream
{
......@@ -797,11 +804,14 @@ struct _VideoStream
bool_t output_performs_decoding;
bool_t player_active;
bool_t staticimage_webcam_fps_optimization; /* if TRUE, the StaticImage webcam will ignore the fps target in order to save CPU time. Default is TRUE */
MediaStreamVideoStat ms_video_stat;
};
typedef struct _VideoStream VideoStream;
MS2_PUBLIC VideoStream *video_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t use_ipv6);
/**
* Creates a VideoStream object listening on a RTP port for a dedicated address.
......
......@@ -138,15 +138,23 @@ static void video_stream_process_rtcp(MediaStream *media_stream, mblk_t *m){
if (rtcp_fb_fir_fci_get_ssrc(fci) == rtp_session_get_recv_ssrc(stream->ms.sessions.rtp_session)) {
uint8_t seq_nr = rtcp_fb_fir_fci_get_seq_nr(fci);
ms_filter_call_method(stream->ms.encoder, MS_VIDEO_ENCODER_NOTIFY_FIR, &seq_nr);
stream->ms_video_stat.counter_rcvd_fir++;
ms_message("video_stream_process_rtcp stream [%p] FIR count %d", stream, stream->ms_video_stat.counter_rcvd_fir);
break;
}
}
break;
case RTCP_PSFB_PLI:
stream->ms_video_stat.counter_rcvd_pli++;
ms_filter_call_method_noarg(stream->ms.encoder, MS_VIDEO_ENCODER_NOTIFY_PLI);
ms_message("video_stream_process_rtcp stream [%p] PLI count %d", stream, stream->ms_video_stat.counter_rcvd_pli);
break;
case RTCP_PSFB_SLI:
for (i = 0; ; i++) {
rtcp_fb_sli_fci_t *fci = rtcp_PSFB_sli_get_fci(m, i);
MSVideoCodecSLI sli;
if (fci == NULL) break;
......@@ -154,6 +162,9 @@ static void video_stream_process_rtcp(MediaStream *media_stream, mblk_t *m){
sli.number = rtcp_fb_sli_fci_get_number(fci);
sli.picture_id = rtcp_fb_sli_fci_get_picture_id(fci);
ms_filter_call_method(stream->ms.encoder, MS_VIDEO_ENCODER_NOTIFY_SLI, &sli);
stream->ms_video_stat.counter_rcvd_sli++;
ms_message("video_stream_process_rtcp stream [%p] SLI count %d", stream, stream->ms_video_stat.counter_rcvd_sli);
}
break;
case RTCP_PSFB_RPSI:
......@@ -163,6 +174,8 @@ static void video_stream_process_rtcp(MediaStream *media_stream, mblk_t *m){
rpsi.bit_string = rtcp_fb_rpsi_fci_get_bit_string(fci);
rpsi.bit_string_len = rtcp_PSFB_rpsi_get_fci_bit_string_len(m);
ms_filter_call_method(stream->ms.encoder, MS_VIDEO_ENCODER_NOTIFY_RPSI, &rpsi);
stream->ms_video_stat.counter_rcvd_rpsi++;
ms_message("video_stream_process_rtcp stream [%p] RPSI count %d", stream, stream->ms_video_stat.counter_rcvd_rpsi);
}
break;
default:
......@@ -265,9 +278,10 @@ VideoStream *video_stream_new2(const char* ip, int loc_rtp_port, int loc_rtcp_po
sessions.rtp_session=ms_create_duplex_rtp_session(ip,loc_rtp_port,loc_rtcp_port);
obj=video_stream_new_with_sessions(&sessions);
obj->ms.owns_sessions=TRUE;
return obj;
return obj;
}
VideoStream *video_stream_new_with_sessions(const MSMediaStreamSessions *sessions){
VideoStream *stream = (VideoStream *)ms_new0 (VideoStream, 1);
const OrtpRtcpXrMediaCallbacks rtcp_xr_media_cbs = {
......
......@@ -73,15 +73,15 @@ typedef struct _video_stream_tester_stats_t {
int number_of_SR;
int number_of_RR;
int number_of_SDES;
int number_of_PLI;
int number_of_SLI;
int number_of_RPSI;
int number_of_sent_PLI;
int number_of_sent_SLI;
int number_of_sent_RPSI;
int number_of_decoder_decoding_error;
int number_of_decoder_first_image_decoded;
int number_of_decoder_send_pli;
int number_of_decoder_send_sli;
int number_of_decoder_send_rpsi;
int number_of_decoder_send_request_pli;
int number_of_decoder_send_request_sli;
int number_of_decoder_send_request_rpsi;
} video_stream_tester_stats_t;
typedef struct _video_stream_tester_t {
......@@ -142,14 +142,14 @@ static void video_stream_event_cb(void *user_pointer, const MSFilter *f, const u
break;
case MS_VIDEO_DECODER_SEND_PLI:
event_name="MS_VIDEO_DECODER_SEND_PLI";
vs_tester->stats.number_of_decoder_send_pli++;
vs_tester->stats.number_of_decoder_send_request_pli++;
break;
case MS_VIDEO_DECODER_SEND_SLI:
event_name="MS_VIDEO_DECODER_SEND_SLI";
vs_tester->stats.number_of_decoder_send_sli++;
vs_tester->stats.number_of_decoder_send_request_sli++;
break;
case MS_VIDEO_DECODER_SEND_RPSI:
vs_tester->stats.number_of_decoder_send_rpsi++;
vs_tester->stats.number_of_decoder_send_request_rpsi++;
event_name="MS_VIDEO_DECODER_SEND_RPSI";
/* Handled internally by mediastreamer2. */
break;
......@@ -181,13 +181,17 @@ static void event_queue_cb(MediaStream *ms, void *user_pointer) {
} else if (rtcp_is_PSFB(d->packet)) {
switch (rtcp_PSFB_get_type(d->packet)) {
case RTCP_PSFB_PLI:
st->number_of_PLI++;
st->number_of_sent_PLI++;
ms_message("event_queue_cb: [%p] sending PLI %d",st, st->number_of_sent_PLI);
break;
case RTCP_PSFB_SLI:
st->number_of_SLI++;
st->number_of_sent_SLI++;
ms_message("event_queue_cb: [%p] sending SLI %d",st, st->number_of_sent_SLI);
break;
case RTCP_PSFB_RPSI:
st->number_of_RPSI++;
st->number_of_sent_RPSI++;
ms_message("event_queue_cb: [%p] sending RPSI %d",st, st->number_of_sent_RPSI);
break;
default:
break;
......@@ -396,20 +400,50 @@ static void avpf_video_stream(void) {
video_stream_tester_t* margaux=video_stream_tester_new();
OrtpNetworkSimulatorParams params = { 0 };
bool_t supported = ms_filter_codec_supported("vp8");
int dummy = 0;
if (supported) {
params.enabled = TRUE;
params.loss_rate = 5.;
params.RTP_only = TRUE;
init_video_streams(marielle, margaux, TRUE, FALSE, &params,VP8_PAYLOAD_TYPE);
BC_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));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_SLI, 1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_RPSI, 1, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
uninit_video_streams(marielle, margaux);
BC_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));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_sent_SLI, 1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_sent_RPSI, 1, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
//disable network simulator
params.enabled = FALSE;
rtp_session_enable_network_simulation(marielle->vs->ms.sessions.rtp_session, &params);
rtp_session_enable_network_simulation(margaux->vs->ms.sessions.rtp_session, &params);
wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &dummy, 1, 1000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats);
// wait for all packets reception before closing streams
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->vs->ms_video_stat.counter_rcvd_rpsi , marielle->stats.number_of_sent_RPSI, 10000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->vs->ms_video_stat.counter_rcvd_rpsi , margaux->stats.number_of_sent_RPSI, 10000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->vs->ms_video_stat.counter_rcvd_pli, marielle->stats.number_of_sent_PLI, 10000,event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->vs->ms_video_stat.counter_rcvd_pli , margaux->stats.number_of_sent_PLI,10000,event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->vs->ms_video_stat.counter_rcvd_sli , marielle->stats.number_of_sent_SLI,10000,event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->vs->ms_video_stat.counter_rcvd_sli , margaux->stats.number_of_sent_SLI,10000,event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_EQUAL(margaux->vs->ms_video_stat.counter_rcvd_sli , marielle->stats.number_of_sent_SLI, int, "%d");
BC_ASSERT_EQUAL(margaux->vs->ms_video_stat.counter_rcvd_rpsi , marielle->stats.number_of_sent_RPSI, int, "%d");
BC_ASSERT_EQUAL(margaux->vs->ms_video_stat.counter_rcvd_pli , marielle->stats.number_of_sent_PLI, int, "%d");
BC_ASSERT_EQUAL(marielle->vs->ms_video_stat.counter_rcvd_sli , margaux->stats.number_of_sent_SLI, int, "%d");
BC_ASSERT_EQUAL(marielle->vs->ms_video_stat.counter_rcvd_rpsi , margaux->stats.number_of_sent_RPSI, int, "%d");
BC_ASSERT_EQUAL(marielle->vs->ms_video_stat.counter_rcvd_pli , margaux->stats.number_of_sent_PLI, int, "%d");
uninit_video_streams(marielle, margaux);
} else {
ms_error("VP8 codec is not supported!");
}
video_stream_tester_destroy(marielle);
video_stream_tester_destroy(margaux);
}
......@@ -443,8 +477,8 @@ static void avpf_rpsi_count(void) {
/*wait for 4 rpsi*/
wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &dummy, 1, delay, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats);
BC_ASSERT_EQUAL(marielle->stats.number_of_RPSI,4,int,"%d");
BC_ASSERT_EQUAL(margaux->stats.number_of_RPSI,4,int,"%d");
BC_ASSERT_EQUAL(marielle->stats.number_of_sent_RPSI,4,int,"%d");
BC_ASSERT_EQUAL(margaux->stats.number_of_sent_RPSI,4,int,"%d");
BC_ASSERT_LOWER(fabs(video_stream_get_received_framerate(marielle->vs)-margaux->vconf->fps), 2.f, float, "%f");
BC_ASSERT_LOWER(fabs(video_stream_get_received_framerate(margaux->vs)-marielle->vconf->fps), 2.f, float, "%f");
uninit_video_streams(marielle, margaux);
......@@ -534,9 +568,9 @@ static void avpf_video_stream_first_iframe_lost_base(int payload_type) {
rtp_session_enable_network_simulation(margaux->vs->ms.sessions.rtp_session, &params);
wait_for_until(&marielle->vs->ms, &margaux->vs->ms,&dummy,1,2000);
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_PLI,
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_sent_PLI,
1, 1000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->stats.number_of_PLI,
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->stats.number_of_sent_PLI,
1, 1000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_decoder_first_image_decoded,
1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
......@@ -585,15 +619,15 @@ static void avpf_high_loss_video_stream_base(float rate, int payload_type) {
switch (payload_type) {
case VP8_PAYLOAD_TYPE:
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms,
&marielle->stats.number_of_SLI, 1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
&marielle->stats.number_of_sent_SLI, 1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
if (rate <= 10) {
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms,
&marielle->stats.number_of_RPSI, 1, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
&marielle->stats.number_of_sent_RPSI, 1, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
}
break;
case H264_PAYLOAD_TYPE:
BC_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms,
&marielle->stats.number_of_PLI, 1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
&marielle->stats.number_of_sent_PLI, 1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
break;
default:
break;
......
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