Commit 64892163 authored by jehan's avatar jehan

add ms2 tester for rpsi

parent 680421e3
......@@ -372,9 +372,8 @@ if BUILD_WIN32_WCE
libmediastreamer_base_la_LIBADD+= -lmmtimer
endif
#put ORTP_CFLAGS first so that inner oRTP submodules is taken in priority rather than installed one
#put ORTP_CFLAGS in AM_CPPFLAGS so that inner oRTP submodules is taken in priority rather than installed one, but after MS2 include path to avoid same issue for MS2
AM_CPPFLAGS=\
$(ORTP_CFLAGS) \
-I$(top_srcdir)/include/ \
-I$(top_srcdir)/src/base \
-I$(top_srcdir)/src/utils \
......@@ -382,6 +381,7 @@ AM_CPPFLAGS=\
-I$(top_srcdir)/src/audiofilters \
-I$(top_srcdir)/src/otherfilters \
-I$(top_srcdir)/src/videofilters
$(ORTP_CFLAGS)
AM_CFLAGS=\
$(STRICT_OPTIONS) \
......
......@@ -52,14 +52,14 @@ void mire_uninit(MSFilter *f){
ms_free(f->data);
}
void mire_preprocess(MSFilter *f){
static void mire_preprocess(MSFilter *f){
MireData *d=(MireData*)f->data;
d->pic=ms_yuv_buf_alloc(&d->pict,d->vsize.width,d->vsize.height);
memset(d->pic->b_rptr,0,d->pic->b_wptr-d->pic->b_rptr);
d->starttime=f->ticker->time;
}
void plane_draw(uint8_t *p, int w, int h, int lsz, int index){
static void plane_draw(uint8_t *p, int w, int h, int lsz, int index){
int i,j;
for(i=0;i<h;++i){
for(j=0;j<w;++j){
......@@ -69,13 +69,13 @@ void plane_draw(uint8_t *p, int w, int h, int lsz, int index){
}
}
void mire_draw(MireData *d){
static void mire_draw(MireData *d){
plane_draw(d->pict.planes[0],d->pict.w,d->pict.h,d->pict.strides[0],d->index*2);
plane_draw(d->pict.planes[1],d->pict.w/2,d->pict.h/2,d->pict.strides[1],d->index);
plane_draw(d->pict.planes[2],d->pict.w/2,d->pict.h/2,d->pict.strides[2],d->index);
}
void mire_process(MSFilter *f){
static void mire_process(MSFilter *f){
MireData *d=(MireData*)f->data;
float elapsed=(float)(f->ticker->time-d->starttime);
if ((elapsed*d->fps/1000.0)>d->index){
......@@ -93,27 +93,34 @@ void mire_postprocess(MSFilter *f){
}
}
int mire_set_vsize(MSFilter *f, void* data){
static int mire_set_vsize(MSFilter *f, void* data){
MireData *d=(MireData*)f->data;
d->vsize=*(MSVideoSize*)data;
return 0;
}
int mire_set_fps(MSFilter *f, void* data){
static int mire_set_fps(MSFilter *f, void* data){
MireData *d=(MireData*)f->data;
d->fps=*(float*)data;
return 0;
}
int mire_get_fmt(MSFilter *f, void* data){
static int mire_get_fmt(MSFilter *f, void* data){
*(MSPixFmt*)data=MS_YUV420P;
return 0;
}
static int mire_get_vsize(MSFilter *f, void* data){
MireData *d=(MireData*)f->data;
*(MSVideoSize*)data=d->vsize;
return 0;
}
MSFilterMethod mire_methods[]={
{ MS_FILTER_SET_VIDEO_SIZE, mire_set_vsize },
{ MS_FILTER_SET_FPS , mire_set_fps },
{ MS_FILTER_SET_FPS , mire_set_fps },
{ MS_FILTER_GET_PIX_FMT , mire_get_fmt },
{ MS_FILTER_GET_VIDEO_SIZE, mire_get_vsize },
{ 0,0 }
};
......
......@@ -78,7 +78,6 @@ typedef struct EncFramesState {
EncFrameState golden;
EncFrameState altref;
EncFrameState reconstruct;
int ref_frames_interval;
vpx_codec_pts_t last_independent_frame;
} EncFramesState;
......@@ -134,12 +133,14 @@ static void enc_uninit(MSFilter *f) {
ms_free(s);
}
static int enc_get_ref_frames_interval(EncState *s) {
return (uint16_t)(s->vconf.fps * 3); /*s->vconf.fps is dynamic*/
}
static void enc_reset_frames_state(EncState *s){
memset(&s->frames_state, 0, sizeof(s->frames_state));
s->frames_state.altref.type=VP8_ALTR_FRAME;
s->frames_state.golden.type=VP8_GOLD_FRAME;
s->frames_state.reconstruct.type=VP8_LAST_FRAME;
s->frames_state.ref_frames_interval = (uint16_t)(s->vconf.fps * 3); /* 1 reference frame each 3s. */
}
static void enc_preprocess(MSFilter *f) {
......@@ -224,7 +225,7 @@ static vpx_codec_pts_t enc_last_reference_frame_count(EncState *s) {
}
static bool_t enc_should_generate_reference_frame(EncState *s) {
return ((s->frame_count - enc_last_reference_frame_count(s)) == s->frames_state.ref_frames_interval) ? TRUE : FALSE;
return ((s->frame_count - enc_last_reference_frame_count(s)) ==enc_get_ref_frames_interval(s)) ? TRUE : FALSE;
}
static uint8_t enc_get_type_of_reference_frame_to_generate(EncState *s) {
......@@ -304,7 +305,7 @@ static bool_t is_reference_sane(EncState *s, EncFrameState *fs){
int diff=fs->picture_id-s->last_sli_id;
bool_t ret;
if (!fs->is_independant && diff<s->frames_state.ref_frames_interval){
if (!fs->is_independant && diff<enc_get_ref_frames_interval(s)){
ret=FALSE;
}else ret=TRUE;
return ret;
......@@ -382,7 +383,7 @@ static void enc_fill_encoder_flags(EncState *s, unsigned int *flags) {
*flags |= (VP8_EFLAG_FORCE_GF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF);
} else if (frame_type & VP8_ALTR_FRAME) {
*flags |= (VP8_EFLAG_FORCE_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_REF_ARF);
if (s->frame_count > s->frames_state.last_independent_frame + 5*s->frames_state.ref_frames_interval){
if (s->frame_count > s->frames_state.last_independent_frame + 5*enc_get_ref_frames_interval(s)){
/*force an independant alt ref frame to force picture to be refreshed completely, otherwise
* pixel color saturation appears due to accumulation of small predictive errors*/
*flags |= VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF;
......
......@@ -33,15 +33,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static RtpProfile rtp_profile;
extern MSWebCamDesc mire_desc;
#define VP8_PAYLOAD_TYPE 103
#define H264_PAYLOAD_TYPE 104
static int tester_init(void) {
MSWebCam *cam;
ms_init();
ms_filter_enable_statistics(TRUE);
ortp_init();
rtp_profile_set_payload(&rtp_profile, VP8_PAYLOAD_TYPE, &payload_type_vp8);
rtp_profile_set_payload(&rtp_profile, H264_PAYLOAD_TYPE, &payload_type_h264);
cam=ms_web_cam_new(&mire_desc);
ms_web_cam_manager_add_cam(ms_web_cam_manager_get(),cam);
return 0;
}
......@@ -85,6 +92,7 @@ typedef struct _video_stream_tester_t {
char* local_ip;
int local_rtp;
int local_rtcp;
MSWebCam * cam;
} video_stream_tester_t;
void video_stream_tester_set_local_ip(video_stream_tester_t* obj,const char*ip) {
......@@ -96,6 +104,7 @@ void video_stream_tester_set_local_ip(video_stream_tester_t* obj,const char*ip)
video_stream_tester_t* video_stream_tester_new() {
video_stream_tester_t* vst = ms_new0(video_stream_tester_t,1);
video_stream_tester_set_local_ip(vst,"127.0.0.1");
vst->cam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "StaticImage: Static picture");
vst->local_rtp=-1; /*random*/
vst->local_rtcp=-1; /*random*/
return vst;
......@@ -193,9 +202,6 @@ 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) {
PayloadType *pt;
MSWebCam *no_webcam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "StaticImage: Static picture");
MSWebCam *default_webcam = no_webcam ;//ms_web_cam_manager_get_default_cam(ms_web_cam_manager_get());
/* MSWebCam *default_webcam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "QT Capture: Logitech Camera #2");*/
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);
......@@ -247,7 +253,7 @@ static void init_video_streams(video_stream_tester_t *marielle, video_stream_tes
}
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, no_webcam),
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) {
......@@ -258,7 +264,7 @@ static void init_video_streams(video_stream_tester_t *marielle, video_stream_tes
}
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, default_webcam),
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);
}
......@@ -375,6 +381,47 @@ static void avpf_video_stream(void) {
video_stream_tester_destroy(margaux);
}
static void avpf_rpsi_count(void) {
video_stream_tester_t* marielle=video_stream_tester_new();
video_stream_tester_t* margaux=video_stream_tester_new();
OrtpNetworkSimulatorParams params = { 0 };
bool_t supported = ms_filter_codec_supported("vp8");
int dummy=0;
int delay = 11000;
marielle->vconf=ms_new0(MSVideoConfiguration,1);
marielle->vconf->bitrate_limit=256000;
marielle->vconf->fps=15;
marielle->vconf->vsize.height=MS_VIDEO_SIZE_CIF_H;
marielle->vconf->vsize.width=MS_VIDEO_SIZE_CIF_W;
marielle->cam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "Mire: Mire (synthetic moving picture)");
margaux->vconf=ms_new0(MSVideoConfiguration,1);
margaux->vconf->bitrate_limit=256000;
margaux->vconf->fps=5; /*to save cpu resource*/
margaux->vconf->vsize.height=MS_VIDEO_SIZE_CIF_H;
margaux->vconf->vsize.width=MS_VIDEO_SIZE_CIF_W;
margaux->cam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "Mire: Mire (synthetic moving picture)");
if (supported) {
init_video_streams(marielle, margaux, TRUE, FALSE, &params,VP8_PAYLOAD_TYPE);
CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_decoder_first_image_decoded, 1, 10000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->stats.number_of_decoder_first_image_decoded, 1, 10000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats));
/*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);
CU_ASSERT_EQUAL(marielle->stats.number_of_RPSI,4);
CU_ASSERT_EQUAL(margaux->stats.number_of_RPSI,4);
CU_ASSERT_TRUE(fabs(video_stream_get_received_framerate(marielle->vs)-margaux->vconf->fps) <2);
CU_ASSERT_TRUE(fabs(video_stream_get_received_framerate(margaux->vs)-marielle->vconf->fps) <2);
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 video_stream_first_iframe_lost_vp8_base(bool_t use_avpf) {
video_stream_tester_t* marielle=video_stream_tester_new();
video_stream_tester_t* margaux=video_stream_tester_new();
......@@ -525,7 +572,8 @@ static test_t tests[] = {
{ "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}
{ "Video configuration",video_configuration_stream},
{ "AVPF RPSI count", avpf_rpsi_count}
};
#else
static test_t tests[] = {};
......
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