Commit 90c2aed3 authored by Sandrine Avakian's avatar Sandrine Avakian

Updating tests to use ms_factory functions.

parent 52d52f0b
......@@ -59,7 +59,8 @@ struct bench_config {
int rate;
int ptime;
char *wavfile;
MSFactory *factory;
MSTicker *ticker;
MSList *tsessions; /* list of struct test_session */
};
......@@ -101,6 +102,11 @@ static int init_bench(struct bench_config *bench)
int pos;
int val;
int count;
bench->factory = ms_factory_new();
ms_factory_init_voip(bench->factory);
ms_factory_init_plugins(bench->factory);
bench->ticker=ms_ticker_new();
count = 0;
......@@ -134,14 +140,14 @@ static int init_bench(struct bench_config *bench)
bench->ip_destination,
bench->port_destination+1+pos*2);
ts->fplayer = ms_filter_new(MS_FILE_PLAYER_ID);
ts->fplayer = ms_factory_create_filter(bench->factory, MS_FILE_PLAYER_ID);
if (strstr(bench->wavfile, ".au")==NULL)
ts->encoder = ms_filter_create_encoder(pt->mime_type);
ts->rtpsend = ms_filter_new(MS_RTP_SEND_ID);
ts->encoder = ms_factory_create_encoder(bench->factory, pt->mime_type);
ts->rtpsend = ms_factory_create_filter(bench->factory, MS_RTP_SEND_ID);
ts->rtprecv = ms_filter_new(MS_RTP_RECV_ID);
ts->decoder = ms_filter_create_decoder(pt->mime_type);
ts->frecorder = ms_filter_new(MS_FILE_REC_ID);
ts->rtprecv = ms_factory_create_filter(bench->factory, MS_RTP_RECV_ID);
ts->decoder = ms_factory_create_decoder(bench->factory, pt->mime_type);
ts->frecorder = ms_factory_create_filter(bench->factory, MS_FILE_REC_ID);
if ((ts->encoder==NULL && strstr(bench->wavfile, ".au")==NULL)
|| (ts->decoder==NULL )){
......@@ -326,6 +332,9 @@ static int uninit_bench(struct bench_config *bench)
ortp_free(ts);
}
ms_factory_uninit_voip(bench->factory);
ms_factory_uninit_plugins(bench->factory);
ms_factory_destroy(bench->factory);
ms_ticker_destroy(bench->ticker);
return 0;
}
......@@ -336,7 +345,9 @@ int main(int argc, char *argv[]){
int count;
ortp_init();
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
ms_init();
rtp_profile_set_payload(&av_profile,115,&payload_type_lpc1015);
rtp_profile_set_payload(&av_profile,110,&payload_type_speex_nb);
rtp_profile_set_payload(&av_profile,111,&payload_type_speex_wb);
......@@ -347,7 +358,7 @@ int main(int argc, char *argv[]){
count=0;
for (pos=0;cfg[pos].num_session!=0;pos++)
{
count = count + init_bench(&cfg[pos]);
count = count + init_bench( &cfg[pos]);
ms_sleep(10);
}
......@@ -360,6 +371,8 @@ int main(int argc, char *argv[]){
{
uninit_bench(&cfg[pos]);
}
return 0;
}
......
......@@ -50,6 +50,8 @@ int main(int argc, char *argv[]){
MSSndCard *card_capture;
MSSndCard *card_playback;
MSTicker *ticker;
MSFactory *factory;
char *capt_card=NULL,*play_card=NULL;
int rate = 8000;
int i;
......@@ -59,7 +61,10 @@ int main(int argc, char *argv[]){
ortp_init();
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
#ifndef _WIN32_WCE
signal(SIGINT,stop);
......@@ -121,5 +126,9 @@ int main(int argc, char *argv[]){
ms_filter_unlink(f1,0,f2,0);
ms_filter_destroy(f1);
ms_filter_destroy(f2);
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
return 0;
}
......@@ -676,6 +676,7 @@ void setup_media_streams(MediastreamDatas* args) {
#ifdef VIDEO_ENABLED
MSWebCam *cam=NULL;
#endif
MSFactory *factory;
ortp_init();
if (args->logfile)
ortp_set_log_file(args->logfile);
......@@ -686,7 +687,9 @@ void setup_media_streams(MediastreamDatas* args) {
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
}
ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
#if TARGET_OS_IPHONE || defined(ANDROID)
#if defined (HAVE_X264) && defined (VIDEO_ENABLED)
......@@ -728,9 +731,10 @@ void setup_media_streams(MediastreamDatas* args) {
args->profile=rtp_profile_clone_full(&av_profile);
args->q=ortp_ev_queue_new();
if (args->mtu) ms_set_mtu(args->mtu);
ms_filter_enable_statistics(TRUE);
ms_filter_reset_statistics();
if (args->mtu) ms_factory_set_mtu(factory, args->mtu);
ms_factory_enable_statistics(factory, TRUE);
ms_factory_reset_statistics(factory);
args->ice_session=ice_session_new();
ice_session_set_remote_credentials(args->ice_session,"1234","1234567890abcdef123456");
// ICE local credentials are assigned when creating the ICE session, but force them here to simplify testing
......@@ -789,7 +793,7 @@ void setup_media_streams(MediastreamDatas* args) {
get_sound_card(manager,args->capture_card);
MSSndCard *play= args->playback_card==NULL ? ms_snd_card_manager_get_default_capture_card(manager) :
get_sound_card(manager,args->playback_card);
args->audio=audio_stream_new(args->localport,args->localport+1,ms_is_ipv6(args->ip));
args->audio=audio_stream_new(args->localport,args->localport+1,ms_is_ipv6(args->ip),factory);
audio_stream_enable_automatic_gain_control(args->audio,args->agc);
audio_stream_enable_noise_gate(args->audio,args->use_ng);
audio_stream_set_echo_canceller_params(args->audio,args->ec_len_ms,args->ec_delay_ms,args->ec_framesize);
......@@ -897,7 +901,7 @@ void setup_media_streams(MediastreamDatas* args) {
exit(-1);
}
ms_message("Starting video stream.\n");
args->video=video_stream_new(args->localport, args->localport+1, ms_is_ipv6(args->ip));
args->video=video_stream_new(args->localport, args->localport+1, ms_is_ipv6(args->ip),factory);
if (args->video_display_filter)
video_stream_set_display_filter_name(args->video, args->video_display_filter);
......@@ -1096,7 +1100,7 @@ void clear_mediastreams(MediastreamDatas* args) {
if (args->video) {
if (args->video->ms.ice_check_list) ice_check_list_destroy(args->video->ms.ice_check_list);
video_stream_stop(args->video);
ms_filter_log_statistics();
ms_factory_log_statistics(args->video->ms.factory);
}
#endif
if (args->ice_session) ice_session_destroy(args->ice_session);
......@@ -1105,8 +1109,10 @@ void clear_mediastreams(MediastreamDatas* args) {
if (args->logfile)
fclose(args->logfile);
ms_exit();
ms_factory_uninit_voip(args->video->ms.factory);
ms_factory_uninit_plugins(args->video->ms.factory);
ms_factory_destroy(args->video->ms.factory);
}
// ANDROID JNI WRAPPER
......
......@@ -75,6 +75,8 @@ int main(int argc, char *argv[]){
PayloadType *pt;
Mode mode = INVALID_MODE;
int local_port = 7778;
MSFactory *factory ;
MSMediaStreamIO io = MS_MEDIA_STREAM_IO_INITIALIZER;
int err;
......@@ -102,10 +104,12 @@ int main(int argc, char *argv[]){
signal(SIGINT,stop_handler);
/*initialize mediastreamer2*/
ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
/*create the video stream */
stream = video_stream_new(local_port, local_port+1, FALSE);
stream = video_stream_new(local_port, local_port+1, FALSE, factory);
/*define its local input and outputs with the MSMediaStreamIO structure*/
if (mode == PLAY_MODE){
......@@ -146,7 +150,7 @@ int main(int argc, char *argv[]){
/*handle video stream background activity. This is non blocking*/
video_stream_iterate(stream);
/*process event callbacks*/
ms_event_queue_pump(ms_factory_get_event_queue(ms_factory_get_fallback()));
ms_event_queue_pump(ms_factory_get_event_queue(factory));
ms_usleep(50000); /*pause 50ms to avoid busy loop*/
}
......@@ -155,5 +159,10 @@ end:
if (stream) video_stream_stop(stream);
/*free the RTP profile and payload type inside*/
if (profile) rtp_profile_destroy(profile);
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
return err;
}
......@@ -22,16 +22,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
#include "mediastreamer2/mscommon.h"
#include "mediastreamer2/msfactory.h"
int main(int argc, char *argv[]){
ms_base_init();
MSFactory *factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
if (argc<2){
ms_error("Usage: mtudiscover [host]");
return -1;
}
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
printf("result: %i \n",ms_discover_mtu(argv[1]));
ms_base_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
return 0;
}
......@@ -25,10 +25,16 @@ int main(int argc, char *argv[]){
const char *file;
MSSndCard *sc;
const char * card_id=NULL;
MSFactory *factory;
ortp_init();
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
if (argc>1){
file=argv[1];
}else file="/usr/share/sounds/linphone/rings/oldphone.wav";
......@@ -42,8 +48,12 @@ int main(int argc, char *argv[]){
sc = ms_alsa_card_new_custom(card_id, card_id);
#endif
r=ring_start(file,2000,sc);
r=ring_start(file,2000,sc, factory);
ms_sleep(10);
ring_stop(r);
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
return 0;
}
......@@ -114,7 +114,10 @@ int main(int argc, char *argv[]){
ms_filter_destroy(det);
ms_filter_destroy(rec);
ms_base_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
//ms_base_exit();
return 0;
}
......@@ -56,7 +56,7 @@ int main(int argc, char *argv[]){
for(i=0;i<1;++i){
int n;
vs=video_preview_new();
vs->factory=factory;
vs->ms.factory=factory;
/*video_preview_set_display_filter_name(vs,"MSVideoOut");*/
video_preview_set_size(vs,vsize);
video_preview_start(vs, cam);
......
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