int main(int argc, char *argv[]) { RingStream *r; 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); factory = ms_factory_new_with_voip(); if (argc>1) { file=argv[1]; } else file="/usr/share/sounds/linphone/rings/oldphone.wav"; if (argc>2) { card_id=argv[2]; } sc=ms_snd_card_manager_get_card(ms_factory_get_snd_card_manager(factory),card_id); #ifdef __linux if (sc==NULL) sc = ms_alsa_card_new_custom(card_id, card_id); #endif r=ring_start(factory, file,2000,sc); ms_sleep(10); ring_stop(r); ms_factory_destroy(factory); return 0; }
static void test_filterdesc_enable_disable_base(const char* mime, const char* filtername,bool_t is_enc) { MSFilter *filter; MSFactory *factory = NULL; factory = ms_factory_new_with_voip(); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,FALSE)); BC_ASSERT_FALSE(ms_factory_filter_from_name_enabled(factory,filtername)); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NULL(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,TRUE)); BC_ASSERT_TRUE(ms_factory_filter_from_name_enabled(factory,filtername)); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); ms_factory_destroy(factory); }
static int basic_audio_tester_before_all(void) { factory = ms_factory_new_with_voip(); ms_factory_enable_statistics(factory, TRUE); ortp_init(); return 0; }
static int tester_init(void) { _factory = ms_factory_new_with_voip(); ortp_init(); rtp_profile_set_payload(&rtp_profile, T140_PAYLOAD_TYPE, &payload_type_t140); rtp_profile_set_payload(&rtp_profile, T140_RED_PAYLOAD_TYPE, &payload_type_t140_red); return 0; }
static void filter_register_tester(void) { MSFilter* filter; MSFactory* factory = NULL; factory = ms_factory_new_with_voip(); BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory, "MSVoidSource")); BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory, "MSVoidSource")); filter= ms_factory_create_decoder(factory, "pcma"); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory,"MSVoidSource")); filter= ms_factory_create_decoder(factory, "pcma"); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); ms_factory_destroy(factory); }
int main(int argc, char *argv[]){ MSFilter *f1,*f2; MSSndCard *card_capture; MSSndCard *card_playback; MSTicker *ticker; MSFactory *factory; char *capt_card=NULL,*play_card=NULL; int rate = 8000; int i; #ifdef __linux const char *alsadev=NULL; #endif ortp_init(); ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); factory = ms_factory_new_with_voip(); #ifndef _WIN32_WCE signal(SIGINT,stop); #endif #ifdef __linux alsadev=getenv("MS2_ALSADEV"); if (alsadev!=NULL){ ms_snd_card_manager_add_card( ms_factory_get_snd_card_manager(factory), ms_alsa_card_new_custom (alsadev,alsadev)); } #endif for(i=1;i<argc;++i){ if (strcmp(argv[i],"--help")==0){ print_usage(); }else if (strcmp(argv[i],"--card")==0){ i++; capt_card=play_card=argv[i]; }else if (strcmp(argv[i],"--capt-card")==0){ i++; capt_card=argv[i]; }else if (strcmp(argv[i],"--play-card")==0){ i++; play_card=argv[i]; } } if (capt_card) card_capture = ms_snd_card_manager_get_card(ms_factory_get_snd_card_manager(factory),capt_card); else card_capture = ms_snd_card_manager_get_default_capture_card(ms_factory_get_snd_card_manager(factory)); if (play_card) card_playback = ms_snd_card_manager_get_card(ms_factory_get_snd_card_manager(factory),play_card); else card_playback = ms_snd_card_manager_get_default_playback_card(ms_factory_get_snd_card_manager(factory)); if (card_playback==NULL || card_capture==NULL){ ms_error("No card."); return -1; } f1=ms_snd_card_create_reader(card_capture); f2=ms_snd_card_create_writer(card_playback); ms_filter_call_method (f1, MS_FILTER_SET_SAMPLE_RATE, &rate); ms_filter_call_method (f2, MS_FILTER_SET_SAMPLE_RATE, &rate); ticker=ms_ticker_new(); ms_filter_link(f1,0,f2,0); ms_ticker_attach(ticker,f1); #ifndef _WIN32_WCE while(run) ms_sleep(1); #else ms_sleep(5); #endif ms_ticker_detach(ticker,f1); ms_ticker_destroy(ticker); ms_filter_unlink(f1,0,f2,0); ms_filter_destroy(f1); ms_filter_destroy(f2); ms_factory_destroy(factory); return 0; }
static int tester_before_all(void) { _factory = ms_factory_new_with_voip(); return 0; }
/* * This small program starts a video stream to either * - read an H264 video track from mkv file and stream it out with RTP to specified destination * - receive H264 RTP packets on a local port and record them into an mkv file */ int main(int argc, char *argv[]){ const char *command; const char *file; const char *ip; int port; VideoStream *stream; RtpProfile *profile; PayloadType *pt; Mode mode = INVALID_MODE; int local_port = 7778; MSFactory *factory ; MSMediaStreamIO io = MS_MEDIA_STREAM_IO_INITIALIZER; int err; /*parse command line arguments*/ if (argc<4) usage(argv[0]); command = argv[1]; if (strcasecmp(command,"play")==0) mode = PLAY_MODE; else if (strcasecmp(command, "record")==0) mode = RECORD_MODE; else usage(argv[0]); file = argv[2]; if (mode == PLAY_MODE){ ip = argv[3]; if (argc<5) usage(argv[0]); port = atoi(argv[4]); }else{ local_port = atoi(argv[3]); ip = "127.0.0.1"; port = 9990; /*dummy destination address, we won't send anything here anyway*/ } /*set a signal handler to interrupt the program cleanly*/ signal(SIGINT,stop_handler); /*initialize mediastreamer2*/ factory = ms_factory_new_with_voip(); /*create the video stream */ stream = video_stream_new(factory, local_port, local_port+1, FALSE); /*define its local input and outputs with the MSMediaStreamIO structure*/ if (mode == PLAY_MODE){ io.input.type = MSResourceFile; io.input.file = file; /*the file we want to stream out via rtp*/ io.output.type = MSResourceFile; io.output.file = NULL; /*we don't set a record file in PLAY_MODE, we just want the received video stream to be ignored, if something is received*/ }else{ io.input.type = MSResourceFile; io.input.file = NULL; /*We don't want to send anything via RTP in RECORD_MODE*/ io.output.type = MSResourceFile; io.output.file = file; /*The file to which we want to record the received video stream*/ } /*define the RTP profile to use: in this case we just want to use H264 codec*/ profile = rtp_profile_new("My RTP profile"); pt = payload_type_clone(&payload_type_h264); rtp_profile_set_payload(profile, payload_type_number, pt); /*we assign H264 to payload type number payload_type_number*/ media_stream_set_target_network_bitrate(&stream->ms, 500000); /*set a target IP bitrate in bits/second */ /*By default, the VideoStream will show up a display window where the received video is played, with a local preview as well. * If you don't need this, assign (void*)-1 as window id, which explicitely disable the display feature.*/ /*video_stream_set_native_window_id(stream, (void*)-1);*/ /*start the video stream, given the RtpProfile and "io" definition */ err = video_stream_start_from_io(stream, profile, ip, port, ip, port+1, payload_type_number, &io); if (err !=0 ){ fprintf(stderr,"Could not start video stream."); goto end; } /*Register an event handler on the player to be notified of end of file*/ ms_filter_add_notify_callback(stream->source, on_end_of_play, NULL, FALSE); /*program's main loop*/ while (active){ /*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(factory)); ms_usleep(50000); /*pause 50ms to avoid busy loop*/ } end: /*stop and destroy the video stream object*/ if (stream) video_stream_stop(stream); /*free the RTP profile and payload type inside*/ if (profile) rtp_profile_destroy(profile); ms_factory_destroy(factory); return err; }