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"); bool_t mp4v_supported = ms_filter_codec_supported("mp4v-es"); 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 || mp4v_supported) { if (h264_supported) change_codec(marielle, margaux, H264_PAYLOAD_TYPE); else change_codec(marielle, margaux, MP4V_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)); if (h264_supported) { CU_ASSERT_EQUAL(strcasecmp(margaux->vs->ms.decoder->desc->enc_fmt, "h264"), 0); } else { CU_ASSERT_EQUAL(strcasecmp(margaux->vs->ms.decoder->desc->enc_fmt, "mp4v-es"), 0); } } else { ms_error("H264 codec is not supported!"); } destroy_video_stream(marielle); destroy_video_stream(margaux); } else { ms_error("VP8 codec is not supported!"); } video_stream_tester_destroy(marielle); video_stream_tester_destroy(margaux); }
MSList *fix_codec_list(RtpProfile *prof, MSList *conflist) { MSList *elem; MSList *newlist=NULL; PayloadType *payload,*confpayload; for (elem=conflist;elem!=NULL;elem=ms_list_next(elem)) { confpayload=(PayloadType*)elem->data; payload=rtp_profile_find_payload(prof,confpayload->mime_type, confpayload->clock_rate,-1); if (payload!=NULL){ if (ms_filter_codec_supported(confpayload->mime_type)){ MSFilterDesc *desc=ms_filter_get_encoder(confpayload->mime_type); if (payload_type_get_user_data(payload)==NULL){ payload_type_set_user_data(payload,(void*)desc->text); payload_type_set_enable(payload,payload_type_enabled(confpayload)); newlist=ms_list_append(newlist,payload); }/*else this is a duplicate */ } } else{ ms_warning("Cannot support %s/%i: does not exist.",confpayload->mime_type, confpayload->clock_rate); } } return newlist; }
static void loss_rate_estimation() { bool_t supported = ms_filter_codec_supported("pcma"); if( supported ) { LossRateEstimatorCtx ctx; stream_manager_t * marielle, * margaux; int loss_rate = 15; start_adaptive_stream(MSAudio, &marielle, &margaux, PCMA8_PAYLOAD_TYPE, 8000, 0, loss_rate, 0, 0); ctx.estimator=ortp_loss_rate_estimator_new(120, 2500, marielle->audio_stream->ms.sessions.rtp_session); ctx.q = ortp_ev_queue_new(); rtp_session_register_event_queue(marielle->audio_stream->ms.sessions.rtp_session, ctx.q); ctx.loss_rate = loss_rate; /*loss rate should be the initial one*/ wait_for_until_with_parse_events(&marielle->audio_stream->ms, &margaux->audio_stream->ms, &loss_rate, 100, 10000, event_queue_cb,&ctx,NULL,NULL); /*let's set some duplication. loss rate should NOT be changed */ rtp_session_set_duplication_ratio(marielle->audio_stream->ms.sessions.rtp_session, 10); wait_for_until_with_parse_events(&marielle->audio_stream->ms, &margaux->audio_stream->ms, &loss_rate, 100, 10000, event_queue_cb,&ctx,NULL,NULL); stop_adaptive_stream(marielle,margaux); ortp_loss_rate_estimator_destroy(ctx.estimator); ortp_ev_queue_destroy(ctx.q); } }
void linphone_core_setup_local_rtp_profile(LinphoneCore *lc) { int i; MSList *audiopt,*videopt; PayloadType *payload; bool_t prepend; lc->local_profile=rtp_profile_clone_full(&av_profile); /* first look at the list given by configuration file to see if it is correct */ audiopt=fix_codec_list(lc->local_profile,lc->codecs_conf.audio_codecs); videopt=fix_codec_list(lc->local_profile,lc->codecs_conf.video_codecs); /* now find and add payloads that are not listed in the configuration codec list */ for (i=0;i<127;i++) { payload=rtp_profile_get_payload(lc->local_profile,i); if (payload!=NULL){ if (payload_type_get_user_data(payload)!=NULL) continue; /* find a mediastreamer codec for this payload type */ if (ms_filter_codec_supported(payload->mime_type)){ MSFilterDesc *desc=ms_filter_get_encoder(payload->mime_type); ms_message("Adding new codec %s/%i",payload->mime_type,payload->clock_rate); payload_type_set_enable(payload,1); payload_type_set_user_data(payload,(void *)desc->text); prepend=FALSE; /* by default, put speex and theora on top of list*/ if (strcmp(payload->mime_type,"speex")==0) prepend=TRUE; if (strcmp(payload->mime_type,"theora")==0) prepend=TRUE; switch (payload->type){ case PAYLOAD_AUDIO_CONTINUOUS: case PAYLOAD_AUDIO_PACKETIZED: if (prepend) audiopt=ms_list_prepend(audiopt,(void *)payload); else audiopt=ms_list_append(audiopt,(void *)payload); break; case PAYLOAD_VIDEO: if (prepend) videopt=ms_list_prepend(videopt,(void *)payload); else videopt=ms_list_append(videopt,(void *)payload); break; default: ms_error("Unsupported rtp media type."); } } } } ms_list_for_each(lc->codecs_conf.audio_codecs,(void (*)(void*))payload_type_destroy); ms_list_for_each(lc->codecs_conf.video_codecs,(void (*)(void *))payload_type_destroy); ms_list_free(lc->codecs_conf.audio_codecs); ms_list_free(lc->codecs_conf.video_codecs); /* set the fixed lists instead:*/ lc->codecs_conf.audio_codecs=audiopt; lc->codecs_conf.video_codecs=videopt; }
static void adaptive_opus_audio_stream() { bool_t supported = ms_filter_codec_supported("opus"); if( supported ) { // at 8KHz -> 24kb/s // at 48KHz -> 48kb/s float bw_usage; stream_manager_t * marielle, * margaux; // on EDGEBW, both should be overconsumming start_adaptive_stream(AudioStreamType, &marielle, &margaux, OPUS_PAYLOAD_TYPE, 8000, EDGE_BW, 0, 0, 0); iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0); bw_usage=media_stream_get_up_bw(&marielle->audio_stream->ms)*1./EDGE_BW; CU_ASSERT_IN_RANGE(bw_usage, 2.f, 3.f); // bad! since this codec cant change its ptime and it is the lower bitrate, no improvement can occur stop_adaptive_stream(marielle,margaux); start_adaptive_stream(AudioStreamType, &marielle, &margaux, OPUS_PAYLOAD_TYPE, 48000, EDGE_BW, 0, 0, 0); iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0); bw_usage=media_stream_get_up_bw(&marielle->audio_stream->ms)*1./EDGE_BW; CU_ASSERT_IN_RANGE(bw_usage, 1.f, 1.4f); // bad! stop_adaptive_stream(marielle,margaux); // on 3G BW, both should be at max start_adaptive_stream(AudioStreamType, &marielle, &margaux, OPUS_PAYLOAD_TYPE, 8000, THIRDGENERATION_BW, 0, 0, 0); iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0); bw_usage=media_stream_get_up_bw(&marielle->audio_stream->ms)*1./THIRDGENERATION_BW; CU_ASSERT_IN_RANGE(bw_usage, .1f, .15f); stop_adaptive_stream(marielle,margaux); start_adaptive_stream(AudioStreamType, &marielle, &margaux, OPUS_PAYLOAD_TYPE, 48000, THIRDGENERATION_BW, 0, 0, 0); iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0); bw_usage=media_stream_get_up_bw(&marielle->audio_stream->ms)*1./THIRDGENERATION_BW; CU_ASSERT_IN_RANGE(bw_usage, .2f, .3f); stop_adaptive_stream(marielle,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(); bool_t supported = ms_filter_codec_supported("vp8"); video_stream_tester_set_local_ip(marielle,"224.1.2.3"); marielle->local_rtcp=0; /*no rtcp*/ video_stream_tester_set_local_ip(margaux,"0.0.0.0"); if (supported) { int dummy=0; init_video_streams(marielle, margaux, FALSE, TRUE, NULL,VP8_PAYLOAD_TYPE); CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->stats.number_of_SR, 2, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats)); ms_ticker_detach(margaux->vs->ms.sessions.ticker,margaux->vs->source); /*to stop sending*/ /*make sure packets can cross from sender to receiver*/ wait_for_until(&marielle->vs->ms,&margaux->vs->ms,&dummy,1,500); video_stream_get_local_rtp_stats(marielle->vs, &marielle->stats.rtp); video_stream_get_local_rtp_stats(margaux->vs, &marielle->stats.rtp); CU_ASSERT_EQUAL(margaux->stats.rtp.sent,marielle->stats.rtp.recv); uninit_video_streams(marielle, margaux); } else { ms_error("VP8 codec is not supported!"); } video_stream_tester_destroy(marielle); video_stream_tester_destroy(margaux); }
const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt){ if (ms_filter_codec_supported(pt->mime_type)){ MSFilterDesc *desc=ms_filter_get_encoder(pt->mime_type); #ifdef ENABLE_NLS return dgettext("mediastreamer",desc->text); #else return desc->text; #endif } return NULL; }
void adaptive_video(int max_bw, int exp_min_bw, int exp_max_bw, int loss_rate, int exp_min_loss, int exp_max_loss) { bool_t supported = ms_filter_codec_supported("VP8"); if( supported ) { stream_manager_t * marielle, * margaux; start_adaptive_stream(MSVideo, &marielle, &margaux, VP8_PAYLOAD_TYPE, 300*1000, max_bw*1000, loss_rate, 50,0); iterate_adaptive_stream(marielle, margaux, 100000, &marielle->rtcp_count, 7); BC_ASSERT_TRUE(marielle->adaptive_stats.loss_estim >= exp_min_loss); BC_ASSERT_TRUE(marielle->adaptive_stats.loss_estim <= exp_max_loss); BC_ASSERT_TRUE(marielle->adaptive_stats.congestion_bw_estim >= exp_min_bw); BC_ASSERT_TRUE(marielle->adaptive_stats.congestion_bw_estim <= exp_max_bw); stop_adaptive_stream(marielle,margaux); } }
static void adaptative_pcma_audio_stream() { bool_t supported = ms_filter_codec_supported("pcma"); if( supported ) { // at 8KHz -> 80 kb/s float bw_usage; // yet non-adaptative codecs cannot respect low throughput limitations bw_usage = adaptive_audio_stream(PCMA8_PAYLOAD_TYPE, 8000, EDGE_BW, 10); CU_ASSERT_IN_RANGE(bw_usage,6.f, 8.f); // this is bad! bw_usage = adaptive_audio_stream(PCMA8_PAYLOAD_TYPE, 8000, THIRDGENERATION_BW, 5); CU_ASSERT_IN_RANGE(bw_usage, .3f, .5f); } }
static void adaptive_speex16_audio_stream() { bool_t supported = ms_filter_codec_supported("speex"); if( supported ) { // at 16KHz -> 20 kb/s // at 32KHz -> 30 kb/s float bw_usage; stream_manager_t * marielle, * margaux; start_adaptive_stream(AudioStreamType, &marielle, &margaux, SPEEX16_PAYLOAD_TYPE, 32000, EDGE_BW / 2., 0, 0, 0); iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0); bw_usage=media_stream_get_up_bw(&marielle->audio_stream->ms)*1./(EDGE_BW / 2.); CU_ASSERT_IN_RANGE(bw_usage, 1.f, 5.f); stop_adaptive_stream(marielle,margaux); } }
static void adaptive_speek16_audio_stream() { bool_t supported = ms_filter_codec_supported("speex"); if( supported ) { // at 16KHz -> 20 kb/s // at 32KHz -> 30 kb/s float bw_usage; bw_usage = adaptive_audio_stream(SPEEX16_PAYLOAD_TYPE, 32000, EDGE_BW, 12); CU_ASSERT_IN_RANGE(bw_usage, .9f, 1.f); bw_usage = adaptive_audio_stream(SPEEX16_PAYLOAD_TYPE, 16000, EDGE_BW, 8); CU_ASSERT_IN_RANGE(bw_usage, .9f, 1.f); bw_usage = adaptive_audio_stream(SPEEX16_PAYLOAD_TYPE, 32000, THIRDGENERATION_BW, 5); CU_ASSERT_IN_RANGE(bw_usage, .1f, .2f); } }
static void play_file(const char *filename, bool_t unsupported_format, const char *audio_mime, const char *video_mime) { LinphoneCoreManager *lc_manager; LinphonePlayer *player; int res, time = 0; bool_t eof = FALSE; lc_manager = linphone_core_manager_new("marie_rc"); CU_ASSERT_PTR_NOT_NULL(lc_manager); if(lc_manager == NULL) return; player = linphone_core_create_local_player(lc_manager->lc, ms_snd_card_manager_get_default_card(ms_snd_card_manager_get()), video_stream_get_default_video_renderer(), 0); CU_ASSERT_PTR_NOT_NULL(player); if(player == NULL) goto fail; res = linphone_player_open(player, filename, eof_callback, &eof); if(unsupported_format || (audio_mime == NULL && video_mime == NULL) || (video_mime == NULL && audio_mime && !ms_filter_codec_supported(audio_mime)) || (audio_mime == NULL && video_mime && !ms_filter_codec_supported(video_mime))) { CU_ASSERT_EQUAL(res, -1); } else { CU_ASSERT_EQUAL(res, 0); } if(res == -1) goto fail; CU_ASSERT_EQUAL((res = linphone_player_start(player)), 0); if(res == -1) goto fail; CU_ASSERT_TRUE(wait_for_eof(&eof, &time, 100, 13000)); linphone_player_close(player); fail: if(player) linphone_player_destroy(player); if(lc_manager) linphone_core_manager_destroy(lc_manager); }
void upload_bitrate(const char* codec, int payload, int target_bw, int expect_bw) { bool_t supported = ms_filter_codec_supported(codec); if( supported ) { float upload_bw; stream_manager_t * marielle, * margaux; start_adaptive_stream(MSAudio, &marielle, &margaux, payload, target_bw*1000, target_bw*1000, 0, 50,0); //these tests check that encoders stick to the guidelines, so we must use NOT //the adaptive algorithm which would modify these guidelines media_stream_enable_adaptive_bitrate_control(&marielle->audio_stream->ms,FALSE); iterate_adaptive_stream(marielle, margaux, 15000, NULL, 0); upload_bw=media_stream_get_up_bw(&marielle->audio_stream->ms) / 1000; CU_ASSERT_IN_RANGE(upload_bw, expect_bw-2, expect_bw+2); stop_adaptive_stream(marielle,margaux); } }
static void video_stream_first_iframe_lost_vp8(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"); if (supported) { int dummy=0; /* Make sure first Iframe is lost. */ params.enabled = TRUE; params.loss_rate = 100.; init_video_streams(marielle, margaux, FALSE, FALSE, ¶ms, VP8_PAYLOAD_TYPE); wait_for_until(&marielle->vs->ms, &margaux->vs->ms,&dummy,1,1000); /* Use 10% packet lost to be sure to have decoding errors. */ params.enabled=TRUE; params.loss_rate = 10.; rtp_session_enable_network_simulation(marielle->vs->ms.sessions.rtp_session, ¶ms); rtp_session_enable_network_simulation(margaux->vs->ms.sessions.rtp_session, ¶ms); wait_for_until(&marielle->vs->ms, &margaux->vs->ms,&dummy,1,2000); CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_decoder_decoding_error, 1, 1000, 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_decoding_error, 1, 1000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats)); /* Remove the lost to be sure the forced iframe is going through. */ params.enabled=TRUE; params.loss_rate = 0.; rtp_session_enable_network_simulation(marielle->vs->ms.sessions.rtp_session, ¶ms); rtp_session_enable_network_simulation(margaux->vs->ms.sessions.rtp_session, ¶ms); wait_for_until(&marielle->vs->ms, &margaux->vs->ms,&dummy,1,2000); video_stream_send_vfu(marielle->vs); video_stream_send_vfu(margaux->vs); CU_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)); CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->stats.number_of_decoder_first_image_decoded, 1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats)); 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 basic_one_way_video_stream(void) { video_stream_tester_t* marielle=video_stream_tester_new(); video_stream_tester_t* margaux=video_stream_tester_new(); bool_t supported = ms_filter_codec_supported("vp8"); if (supported) { init_video_streams(marielle, margaux, FALSE, TRUE, NULL,VP8_PAYLOAD_TYPE); CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_RR, 2, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats)); video_stream_get_local_rtp_stats(marielle->vs, &marielle->stats.rtp); video_stream_get_local_rtp_stats(margaux->vs, &margaux->stats.rtp); 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 upload_bandwidth_computation() { bool_t supported = ms_filter_codec_supported("pcma"); if( supported ) { stream_manager_t * marielle, * margaux; int i; start_adaptive_stream(AudioStreamType, &marielle, &margaux, PCMA8_PAYLOAD_TYPE, 8000, 0, 0, 0, 0); media_stream_enable_adaptive_bitrate_control(&marielle->audio_stream->ms,FALSE); for (i = 0; i < 5; i++){ rtp_session_set_duplication_ratio(marielle->audio_stream->ms.sessions.rtp_session, i); iterate_adaptive_stream(marielle, margaux, 100000, &marielle->rtcp_count, 2*(i+1)); /*since PCMA uses 80kbit/s, upload bandwidth should just be 80+80*duplication_ratio kbit/s */ CU_ASSERT_TRUE(fabs(rtp_session_get_send_bandwidth(marielle->audio_stream->ms.sessions.rtp_session)/1000. - 80.*(i+1)) < 1.f); } stop_adaptive_stream(marielle,margaux); } }
void adaptive_video(int max_bw, int exp_min_bw, int exp_max_bw, int loss_rate, int exp_min_loss, int exp_max_loss) { bool_t supported = ms_filter_codec_supported("VP8"); if( supported ) { bool_t has_cam = ms_web_cam_manager_get_default_cam(ms_web_cam_manager_get()) != ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "StaticImage: Static picture"); if (has_cam) { stream_manager_t * marielle, * margaux; start_adaptive_stream(MSVideo, &marielle, &margaux, VP8_PAYLOAD_TYPE, 300*1000, max_bw*1000, loss_rate, 50,0); iterate_adaptive_stream(marielle, margaux, 100000, &marielle->rtcp_count, 7); CU_ASSERT_IN_RANGE(marielle->adaptive_stats.loss_estim, exp_min_loss, exp_max_loss); CU_ASSERT_IN_RANGE(marielle->adaptive_stats.congestion_bw_estim, exp_min_bw, exp_max_bw); stop_adaptive_stream(marielle,margaux); } else { /*ortp_loss_estimator rely on the fact that we receive some packets: however when using static picture camera, there is a traffic of around 1 packet per second which is totally unlikely leading in no QoS possibility*/ ms_warning("%s test disabled because no real camera is available", __FUNCTION__); } } }
static void adaptive_opus_audio_stream() { bool_t supported = ms_filter_codec_supported("opus"); if( supported ) { // at 8KHz -> 24kb/s // at 48KHz -> 48kb/s float bw_usage; // on EDGEBW, both should be overconsumming bw_usage = adaptive_audio_stream(OPUS_PAYLOAD_TYPE, 8000, EDGE_BW, 14); CU_ASSERT_IN_RANGE(bw_usage, 1.f, 3.f); // bad! since this codec cant change its ptime and it is the lower bitrate, no improvement can occur bw_usage = adaptive_audio_stream(OPUS_PAYLOAD_TYPE, 48000, EDGE_BW, 11); CU_ASSERT_IN_RANGE(bw_usage, 1.f, 1.2f); // bad! // on 3G BW, both should be at max bw_usage = adaptive_audio_stream(OPUS_PAYLOAD_TYPE, 8000, THIRDGENERATION_BW, 5); CU_ASSERT_IN_RANGE(bw_usage, .1f, .15f); bw_usage = adaptive_audio_stream(OPUS_PAYLOAD_TYPE, 48000, THIRDGENERATION_BW, 5); CU_ASSERT_IN_RANGE(bw_usage, .2f, .3f); } }
static void adaptive_pcma_audio_stream() { bool_t supported = ms_filter_codec_supported("pcma"); if( supported ) { // at 8KHz -> 80 kb/s float bw_usage; stream_manager_t * marielle, * margaux; // yet non-adaptative codecs cannot respect low throughput limitations start_adaptive_stream(AudioStreamType, &marielle, &margaux, PCMA8_PAYLOAD_TYPE, 8000, EDGE_BW, 0, 0, 0); iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0); bw_usage=media_stream_get_up_bw(&marielle->audio_stream->ms)*1./EDGE_BW; CU_ASSERT_IN_RANGE(bw_usage,6.f, 8.f); // this is bad! stop_adaptive_stream(marielle,margaux); start_adaptive_stream(AudioStreamType, &marielle, &margaux, PCMA8_PAYLOAD_TYPE, 8000, THIRDGENERATION_BW, 0, 0, 0); iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0); bw_usage=media_stream_get_up_bw(&marielle->audio_stream->ms)*1./THIRDGENERATION_BW; CU_ASSERT_IN_RANGE(bw_usage, .3f, .5f); stop_adaptive_stream(marielle,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=marielle->vconf->required_bitrate=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 = mediastreamer2_tester_get_mire_webcam(ms_web_cam_manager_get()); margaux->vconf=ms_new0(MSVideoConfiguration,1); margaux->vconf->bitrate_limit=margaux->vconf->required_bitrate=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 = mediastreamer2_tester_get_mire_webcam(ms_web_cam_manager_get()); if (supported) { init_video_streams(marielle, margaux, TRUE, FALSE, ¶ms,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 avpf_high_loss_video_stream_base(float rate) { 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"); if (supported) { params.enabled = TRUE; params.loss_rate = rate; init_video_streams(marielle, margaux, TRUE, FALSE, ¶ms,VP8_PAYLOAD_TYPE); CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_SR, 10, 15000, 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, &marielle->stats.number_of_SLI, 1, 5000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats)); if (rate <= 10) { CU_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); } else { ms_error("VP8 codec is not supported!"); } video_stream_tester_destroy(marielle); video_stream_tester_destroy(margaux); }
PayloadType * sipomatic_payload_is_supported(sdp_payload_t *payload,RtpProfile *local_profile,RtpProfile *dialog_profile) { int localpt; if (payload->a_rtpmap!=NULL){ localpt=rtp_profile_get_payload_number_from_rtpmap(local_profile,payload->a_rtpmap); }else{ localpt=payload->pt; ms_warning("payload has no rtpmap."); } if (localpt>=0){ /* this payload is supported in our local rtp profile, so add it to the dialog rtp profile */ PayloadType *rtppayload; rtppayload=rtp_profile_get_payload(local_profile,localpt); if (rtppayload==NULL) return NULL; /*check if we have the appropriate coder/decoder for this payload */ if (strcmp(rtppayload->mime_type,"telephone-event")!=0) { if (!ms_filter_codec_supported(rtppayload->mime_type)) { ms_message("Codec %s is not supported.", rtppayload->mime_type); return NULL; } } rtppayload=payload_type_clone(rtppayload); rtp_profile_set_payload(dialog_profile,payload->pt,rtppayload); /* add to the rtp payload type some other parameters (bandwidth) */ if (payload->b_as_bandwidth!=0) rtppayload->normal_bitrate=payload->b_as_bandwidth*1000; if (payload->a_fmtp!=NULL) payload_type_set_send_fmtp(rtppayload,payload->a_fmtp); if (strcasecmp(rtppayload->mime_type,"iLBC")==0){ /*default to 30 ms mode */ payload->a_fmtp="ptime=30"; payload_type_set_recv_fmtp(rtppayload,payload->a_fmtp); } return rtppayload; } return NULL; }
static void video_configuration_stream_base(MSVideoConfiguration* asked, MSVideoConfiguration* expected_result, int payload_type) { video_stream_tester_t* marielle=video_stream_tester_new(); video_stream_tester_t* margaux=video_stream_tester_new(); PayloadType* pt = rtp_profile_get_payload(&rtp_profile, payload_type); bool_t supported = pt?ms_filter_codec_supported(pt->mime_type):FALSE; if (supported) { margaux->vconf=ms_new0(MSVideoConfiguration,1); margaux->vconf->required_bitrate=asked->required_bitrate; margaux->vconf->bitrate_limit=asked->bitrate_limit; margaux->vconf->vsize=asked->vsize; margaux->vconf->fps=asked->fps; init_video_streams(marielle, margaux, FALSE, TRUE, NULL,payload_type); CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &marielle->stats.number_of_RR, 4, 30000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats)); video_stream_get_local_rtp_stats(marielle->vs, &marielle->stats.rtp); video_stream_get_local_rtp_stats(margaux->vs, &margaux->stats.rtp); CU_ASSERT_TRUE(ms_video_size_equal(video_stream_get_received_video_size(marielle->vs), margaux->vconf->vsize)); CU_ASSERT_TRUE(fabs(video_stream_get_received_framerate(marielle->vs)-margaux->vconf->fps) <2); if (ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "StaticImage: Static picture") != ms_web_cam_manager_get_default_cam(ms_web_cam_manager_get())) { // CU_ASSERT_TRUE(abs(media_stream_get_down_bw((MediaStream*)marielle->vs) - margaux->vconf->required_bitrate) < 0.20f * margaux->vconf->required_bitrate); } /*else this test require a real webcam*/ 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 dtmfgen_enc_dec_tonedet_isac(void) { bool_t supported = ms_filter_codec_supported("iSAC"); if( supported ) { dtmfgen_enc_dec_tonedet("iSAC", 16000, 1); } }