static void fileplay_soundwrite(const char *filename) {
	MSConnectionHelper h;
	bool_t need_resampler = FALSE;
	unsigned int filter_mask = FILTER_MASK_FILEPLAY | FILTER_MASK_SOUNDWRITE;
	int sample_rate = 8000;
	int nchannels = 1;
	int done = FALSE;

	ms_filter_reset_statistics();
	ms_tester_create_ticker();
	ms_tester_create_filters(filter_mask);
	ms_filter_set_notify_callback(ms_tester_fileplay, fileplay_eof, &done);
	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
	ms_filter_call_method(ms_tester_fileplay, MS_FILE_PLAYER_OPEN, (void *)filename);
	ms_filter_call_method(ms_tester_fileplay, MS_FILTER_GET_SAMPLE_RATE, &sample_rate);
	ms_filter_call_method(ms_tester_fileplay, MS_FILTER_GET_NCHANNELS, &nchannels);
	if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_BITRATE, &sample_rate) != 0) {
		int soundwrite_sample_rate = 48000;
		ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_GET_BITRATE, &soundwrite_sample_rate);
		if (sample_rate != soundwrite_sample_rate) need_resampler = TRUE;
	}
	if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_NCHANNELS, &nchannels) != 0) {
		int soundwrite_nchannels = 1;
		ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_GET_NCHANNELS, &soundwrite_nchannels);
		if (nchannels != soundwrite_nchannels) need_resampler = TRUE;
	}
	if (need_resampler == TRUE) {
		ms_tester_create_filters(FILTER_MASK_RESAMPLER);
		configure_resampler(ms_tester_resampler, ms_tester_fileplay, ms_tester_soundwrite);
	}
	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_START);
	ms_connection_helper_start(&h);
	ms_connection_helper_link(&h, ms_tester_fileplay, -1, 0);
	if (need_resampler == TRUE) {
		ms_connection_helper_link(&h, ms_tester_resampler, 0, 0);
	}
	ms_connection_helper_link(&h, ms_tester_soundwrite, 0, -1);
	ms_ticker_attach(ms_tester_ticker, ms_tester_fileplay);

	while (done != TRUE) {
		ms_usleep(10000);
	}

	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
	ms_ticker_detach(ms_tester_ticker, ms_tester_fileplay);
	ms_connection_helper_start(&h);
	ms_connection_helper_unlink(&h, ms_tester_fileplay, -1, 0);
	if (need_resampler == TRUE) {
		ms_connection_helper_unlink(&h, ms_tester_resampler, 0, 0);
	}
	ms_connection_helper_unlink(&h, ms_tester_soundwrite, 0, -1);
	if (need_resampler == TRUE) {
		ms_tester_destroy_filters(FILTER_MASK_RESAMPLER);
	}
	ms_filter_log_statistics();
	ms_tester_destroy_filters(filter_mask);
	ms_tester_destroy_ticker();
}
예제 #2
0
void audio_stream_record_stop(AudioStream *st)
{
	if (st->filewriter != NULL &&  ms_filter_get_id(st->filewriter)==MS_FILE_REC_ID){
		ms_filter_call_method_noarg(st->filewriter,MS_FILE_REC_STOP);
		ms_filter_call_method_noarg(st->filewriter,MS_FILE_REC_CLOSE);
	}else{
		ms_error("Cannot stop record !");
	}
}
예제 #3
0
void audio_stream_record_start(AudioStream *st, const char *filename){
	if (st->filewriter != NULL && ms_filter_get_id(st->filewriter)==MS_FILE_REC_ID){
		ms_filter_call_method_noarg(st->filewriter,MS_FILE_REC_CLOSE);
		ms_filter_call_method(st->filewriter,MS_FILE_REC_OPEN,(void*)filename);
		ms_filter_call_method_noarg(st->filewriter,MS_FILE_REC_START);
	}else{
		ms_error("Cannot record file: no st->filewriter Filter !");
	}
}
int audio_stream_mixed_record_stop(AudioStream *st){
	if (st->recorder && st->recorder_file){
		int pin=1;
		ms_filter_call_method_noarg(st->recorder,MS_RECORDER_PAUSE);
		ms_filter_call_method(st->recv_tee,MS_TEE_MUTE,&pin);
		ms_filter_call_method(st->send_tee,MS_TEE_MUTE,&pin);
		ms_filter_call_method_noarg(st->recorder,MS_RECORDER_CLOSE);
	}
	return 0;
}
예제 #5
0
void audio_stream_play(AudioStream *st, const char *name){
	if (ms_filter_get_id(st->soundread)==MS_FILE_PLAYER_ID){
		ms_filter_call_method_noarg(st->soundread,MS_FILE_PLAYER_CLOSE);
		ms_filter_call_method(st->soundread,MS_FILE_PLAYER_OPEN,(void*)name);
		ms_filter_call_method_noarg(st->soundread,MS_FILE_PLAYER_START);
	}else{
		ms_error("Cannot play file: the stream hasn't been started with"
		" audio_stream_start_with_files");
	}
}
예제 #6
0
void video_stream_play_file_stop(VideoStream *st)
{
	if (ms_filter_get_id(st->source)==MS_VIDEO_FILE_PLAYER_ID){
		ms_filter_call_method_noarg(st->source,MS_VIDEO_FILE_PLAYER_STOP);
		ms_filter_call_method_noarg(st->source,MS_VIDEO_FILE_PLAYER_CLOSE);
	}else{
		ms_error("Cannot play file: the stream hasn't been started with"
			" video_stream_play");
	}
}
void audio_stream_record(AudioStream *st, const char *name){
	if (ms_filter_get_id(st->soundwrite)==MS_FILE_REC_ID){
		ms_filter_call_method_noarg(st->soundwrite,MS_FILE_REC_CLOSE);
		ms_filter_call_method(st->soundwrite,MS_FILE_REC_OPEN,(void*)name);
		ms_filter_call_method_noarg(st->soundwrite,MS_FILE_REC_START);
	}else{
		ms_error("Cannot record file: the stream hasn't been started with"
		" audio_stream_start_with_files");
	}
}
예제 #8
0
void video_stream_play_file(VideoStream *st, const char *name)
{
	if (ms_filter_get_id(st->source)==MS_VIDEO_FILE_PLAYER_ID){
		ms_filter_call_method_noarg(st->source,MS_VIDEO_FILE_PLAYER_CLOSE);
		ms_filter_call_method(st->source,MS_VIDEO_FILE_PLAYER_OPEN,(void*)name);
		ms_filter_call_method_noarg(st->source,MS_VIDEO_FILE_PLAYER_START);
	}else{
		ms_error("Cannot play file: the stream hasn't been started with"
			" video_stream_play");
	}
}
예제 #9
0
void linphone_conference_play_audio_stop(struct _LinphoneCore *lc, LinphoneConference *conf){
	LinphoneConferenceStream *conf_stream = conf->conf_stream;

	if(conf==NULL && conf_stream==NULL) return;

	if (conf_stream->audio_fileplayer != NULL && ms_filter_get_id(conf_stream->audio_fileplayer)==MS_FILE_PLAYER_ID){
		ms_filter_call_method_noarg(conf_stream->audio_fileplayer,MS_FILE_PLAYER_STOP);
		ms_filter_call_method_noarg(conf_stream->audio_fileplayer,MS_FILE_PLAYER_CLOSE);
	}else{
		ms_error("Cannot record file: not inited conf->audio_fileplayer Filter !");
	}
}
예제 #10
0
void linphone_conference_record_audio_stop(struct _LinphoneCore *lc, LinphoneConference *conf){
	LinphoneConferenceStream *conf_stream = conf->conf_stream;

	if(conf==NULL && conf_stream==NULL) return;

	if (conf_stream->audio_filerecorder != NULL && ms_filter_get_id(conf_stream->audio_filerecorder)==MS_FILE_REC_ID){
		ms_filter_call_method_noarg(conf_stream->audio_filerecorder,MS_FILE_REC_STOP);
		ms_filter_call_method_noarg(conf_stream->audio_filerecorder,MS_FILE_REC_CLOSE);
	}else{
		ms_error("Cannot stop conference record !");
	}
}
예제 #11
0
//录制当前会议
void linphone_conference_record_audio(struct _LinphoneCore *lc, LinphoneConference *conf, const char *filename){
	LinphoneConferenceStream *conf_stream = conf->conf_stream;

	if(conf==NULL && conf_stream==NULL) return;

	if (conf_stream->audio_filerecorder != NULL && ms_filter_get_id(conf_stream->audio_filerecorder)==MS_FILE_REC_ID){
		ms_filter_call_method_noarg(conf_stream->audio_filerecorder,MS_FILE_REC_CLOSE);
		ms_filter_call_method(conf_stream->audio_filerecorder,MS_FILE_REC_OPEN,(void*)filename);
		ms_filter_call_method_noarg(conf_stream->audio_filerecorder,MS_FILE_REC_START);
	}else{
		ms_error("Cannot record file: not conf->audio_filerecorder st->filewrite Filter !");
	}
}
예제 #12
0
int ms_audio_recorder_endpoint_start(MSAudioEndpoint *ep, const char *path){
	int err;
	MSRecorderState state;
	if (!ep->recorder){
		ms_error("This endpoint isn't a recorder endpoint.");
		return -1;
	}
	ms_filter_call_method(ep->recorder,MS_RECORDER_GET_STATE,&state);
	if (state!=MSRecorderClosed)
		ms_filter_call_method_noarg(ep->recorder,MS_RECORDER_CLOSE);
	err=ms_filter_call_method(ep->recorder,MS_RECORDER_OPEN,(void*)path);
	if (err==-1) return -1;
	return ms_filter_call_method_noarg(ep->recorder,MS_RECORDER_START);
}
예제 #13
0
RingStream * ring_start_with_cb(const char *file,int interval,MSSndCard *sndcard, MSFilterNotifyFunc func,void * user_data)
{
	RingStream *stream;
	int tmp;
	stream=(RingStream *)ms_new0(RingStream,1);
	stream->source=ms_filter_new(MS_FILE_PLAYER_ID);
	if (ms_filter_call_method(stream->source,MS_FILE_PLAYER_OPEN,(void*)file)<0){
		ms_filter_destroy(stream->source);
		ms_free(stream);
		return NULL;
	}
	ms_filter_call_method(stream->source,MS_FILE_PLAYER_LOOP,&interval);
	ms_filter_call_method_noarg(stream->source,MS_FILE_PLAYER_START);
	if (func!=NULL)
		ms_filter_set_notify_callback(stream->source,func,user_data);
	stream->sndwrite=ms_snd_card_create_writer(sndcard);
	ms_filter_call_method(stream->source,MS_FILTER_GET_SAMPLE_RATE,&tmp);
	ms_filter_call_method(stream->sndwrite,MS_FILTER_SET_SAMPLE_RATE,&tmp);
	ms_filter_call_method(stream->source,MS_FILTER_GET_NCHANNELS,&tmp);
	ms_filter_call_method(stream->sndwrite,MS_FILTER_SET_NCHANNELS,&tmp);
	stream->ticker=ms_ticker_new();
	ms_ticker_set_name(stream->ticker,"Audio (ring) MSTicker");
	ms_filter_link(stream->source,0,stream->sndwrite,0);
	ms_ticker_attach(stream->ticker,stream->source);
	return stream;
}
예제 #14
0
void linphone_conference_enable_auto_layout(LinphoneConference *conf,bool_t enabled){
	LinphoneConferenceStream *stream = conf->conf_stream;

	if(!conf || !conf->conf_stream) return;

	stream->auto_layout = enabled;
	MSList *list = stream->video_ports;
	int port_index =0;

	for(;list!=NULL;list=list->next){
		ConfVideoPort* port = (ConfVideoPort*) list->data;
	
		if(stream->auto_layout){
			/*自动布局模式下,关闭所有视频端口的 no signal 图片输出,0 号通道除外*/
			if((port->sink_connected==FALSE && port->source_connected==FALSE) && port_index !=0 )
				ms_filter_call_method(stream->video_static_image_tee,MS_TEE_MUTE,&port_index);
			}else{
			/*如视频端口为连接call或camera,输出静态图片 0号通道除外*/
			if((port->sink_connected==FALSE && port->source_connected==FALSE) && port_index !=0 )
				ms_filter_call_method(stream->video_static_image_tee,MS_TEE_UNMUTE,&port_index);			
		}

		port_index++;
	}
	/*请求视频Mixer刷新布局*/
	ms_filter_call_method_noarg(stream->video_mixer,MS_FILTER_REQ_VFU);

	linphone_conference_send_vfu(conf);
}
예제 #15
0
void ms_media_player_stop(MSMediaPlayer *obj) {
	int seek_pos = 0;
	if(obj->is_open) {
		ms_filter_call_method_noarg(obj->player, MS_PLAYER_PAUSE);
		ms_filter_call_method(obj->player, MS_PLAYER_SEEK_MS, &seek_pos);
	}
}
예제 #16
0
int linphone_conference_remove_local_webcam(LinphoneConference *conf, ConfWebCam *localcam)
{
	if(conf==NULL || localcam==NULL) return -1;

	ConfVideoPort *video_port = find_video_slot_at_index(conf->conf_stream,localcam->video_port_index);

	if(localcam->ticker && video_port)
	{

		ms_message("Remove Local Camera: conf_stream [%d] <----> local_webcam !!",video_port->index);

		ms_filter_call_method(video_port->video_itc_source,MS_CONF_ITC_SOURCE_CONNECT,NULL);
		ms_filter_call_method(localcam->itc_sink,MS_CONF_ITC_SINK_CONNECT,NULL);
		video_port->sink_connected = FALSE;
		video_port->source_connected = FALSE;
		localcam->video_port_index = -1;

		int tmp =  video_port->index;

		if(conf->conf_stream->auto_layout)//自动布局模式下只开启 0 号端口的静态图片 
		{
			if(tmp==0) ms_filter_call_method(conf->conf_stream->video_static_image_tee,MS_TEE_UNMUTE,&tmp);

		}else{
			ms_filter_call_method(conf->conf_stream->video_static_image_tee,MS_TEE_UNMUTE,&tmp);
		}

		ms_filter_call_method_noarg(conf->conf_stream->video_mixer,MS_FILTER_REQ_VFU);
	}
}
예제 #17
0
int lsd_player_play(LsdPlayer *b, const char *filename ){
	int state;
	
	ms_filter_call_method(b->player,MS_PLAYER_GET_STATE,&state);
	if (state!=MSPlayerClosed){
		ms_filter_call_method_noarg(b->player,MS_PLAYER_CLOSE);
	}
	
	if (ms_filter_call_method(b->player,MS_PLAYER_OPEN,(void*)filename)!=0){
		ms_warning("Could not play %s",filename);
		return -1;
	}
	ms_filter_set_notify_callback (b->player,lsd_player_on_eop,b);
	lsd_player_configure(b);
	ms_filter_call_method_noarg (b->player,MS_PLAYER_START);
	return 0;
}
예제 #18
0
RingStream * ring_start_with_cb(const char *file,int interval,MSSndCard *sndcard, MSFilterNotifyFunc func,void * user_data)
{
	RingStream *stream;
	int srcchannels, dstchannels;
	int srcrate,dstrate;
	MSConnectionHelper h;
	MSTickerParams params={0};

	stream=(RingStream *)ms_new0(RingStream,1);
	stream->source=ms_filter_new(MS_FILE_PLAYER_ID);
	if (file)
		ms_filter_call_method(stream->source,MS_FILE_PLAYER_OPEN,(void*)file);

	ms_filter_call_method(stream->source,MS_FILE_PLAYER_LOOP,&interval);
	ms_filter_call_method_noarg(stream->source,MS_FILE_PLAYER_START);
	if (func!=NULL)
		ms_filter_set_notify_callback(stream->source,func,user_data);
	stream->gendtmf=ms_filter_new(MS_DTMF_GEN_ID);

	stream->sndwrite=ms_snd_card_create_writer(sndcard);
	ms_filter_call_method(stream->source,MS_FILTER_GET_SAMPLE_RATE,&srcrate);
	ms_filter_call_method(stream->gendtmf,MS_FILTER_SET_SAMPLE_RATE,&srcrate);
	ms_filter_call_method(stream->sndwrite,MS_FILTER_SET_SAMPLE_RATE,&srcrate);
	ms_filter_call_method(stream->sndwrite,MS_FILTER_GET_SAMPLE_RATE,&dstrate);
	if (srcrate!=dstrate){
		stream->write_resampler=ms_filter_new(MS_RESAMPLE_ID);
		ms_filter_call_method(stream->write_resampler,MS_FILTER_SET_SAMPLE_RATE,&srcrate);
		ms_filter_call_method(stream->write_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&dstrate);
		ms_message("configuring resampler from rate [%i] to rate [%i]", srcrate,dstrate);
	}
	ms_filter_call_method(stream->source,MS_FILTER_GET_NCHANNELS,&srcchannels);
	ms_filter_call_method(stream->gendtmf,MS_FILTER_SET_NCHANNELS,&srcchannels);
	ms_filter_call_method(stream->sndwrite,MS_FILTER_SET_NCHANNELS,&srcchannels);
	ms_filter_call_method(stream->sndwrite,MS_FILTER_GET_NCHANNELS,&dstchannels);
	if (srcchannels != dstchannels) {
		if (!stream->write_resampler) {
			stream->write_resampler=ms_filter_new(MS_RESAMPLE_ID);
		}
		ms_filter_call_method(stream->write_resampler,MS_FILTER_SET_NCHANNELS,&srcchannels);
		ms_filter_call_method(stream->write_resampler,MS_FILTER_SET_OUTPUT_NCHANNELS,&dstchannels);
		ms_message("configuring resampler from channels [%i] to channels [%i]", srcchannels, dstchannels);
	}
	

	params.name="Ring MSTicker";
	params.prio=MS_TICKER_PRIO_HIGH;
	stream->ticker=ms_ticker_new_with_params(&params);

	ms_connection_helper_start(&h);
	ms_connection_helper_link(&h,stream->source,-1,0);
	ms_connection_helper_link(&h,stream->gendtmf,0,0);
	if (stream->write_resampler)
		ms_connection_helper_link(&h,stream->write_resampler,0,0);
	ms_connection_helper_link(&h,stream->sndwrite,0,-1);
	ms_ticker_attach(stream->ticker,stream->source);

	return stream;
}
예제 #19
0
void ms_media_player_close(MSMediaPlayer *obj) {
	if(obj->is_open) {
		ms_ticker_detach(obj->ticker, obj->player);
		ms_filter_call_method_noarg(obj->player, MS_PLAYER_CLOSE);
		_unlink_all(obj);
		_destroy_graph(obj);
		obj->is_open = FALSE;
		ms_free(obj->filename); obj->filename = NULL;
	}
}
예제 #20
0
// Pass NULL to stop playing
void audio_stream_play(AudioStream *st, const char *name){
	if (st->soundread == NULL) {
		ms_warning("Cannot play file: the stream hasn't been started");
		return;
	}
	if (ms_filter_get_id(st->soundread)==MS_FILE_PLAYER_ID){
		ms_filter_call_method_noarg(st->soundread,MS_FILE_PLAYER_CLOSE);
		if (name != NULL) {
			ms_filter_call_method(st->soundread,MS_FILE_PLAYER_OPEN,(void*)name);
			if (st->read_resampler){
				audio_stream_configure_resampler(st->read_resampler,st->soundread,st->ms.rtpsend);
			}
			ms_filter_call_method_noarg(st->soundread,MS_FILE_PLAYER_START);
		}
	}else{
		ms_error("Cannot play file: the stream hasn't been started with"
		" audio_stream_start_with_files");
	}
}
예제 #21
0
bool_t ms_media_player_start(MSMediaPlayer *obj) {
	if(!obj->is_open) {
		ms_error("Cannot start playing. No file has been opened");
		return FALSE;
	}
	if(ms_filter_call_method_noarg(obj->player, MS_PLAYER_START) == -1) {
		ms_error("Could not play %s. Playing filter failed to start", obj->filename);
		return FALSE;
	}
	return TRUE;
}
예제 #22
0
void video_stream_iterate(VideoStream *stream){
	if (stream->output!=NULL)
		ms_filter_call_method_noarg(stream->output,
			MS_VIDEO_OUT_HANDLE_RESIZING);
	if (stream->evq){
		OrtpEvent *ev=ortp_ev_queue_get(stream->evq);
		if (ev!=NULL){
			if (ortp_event_get_type(ev)==ORTP_EVENT_RTCP_PACKET_RECEIVED){
				OrtpEventData *evd=ortp_event_get_data(ev);
				video_steam_process_rtcp(stream,evd->packet);
			}
			ortp_event_destroy(ev);
		}
	}
}
예제 #23
0
int audio_stream_mixed_record_start(AudioStream *st){
	if (st->recorder && st->recorder_file){
		int pin=1;
		MSRecorderState state;
		ms_filter_call_method(st->recorder,MS_RECORDER_GET_STATE,&state);
		if (state==MSRecorderClosed){
			if (ms_filter_call_method(st->recorder,MS_RECORDER_OPEN,st->recorder_file)==-1)
				return -1;
		}
		ms_filter_call_method_noarg(st->recorder,MS_RECORDER_START);
		ms_filter_call_method(st->recv_tee,MS_TEE_UNMUTE,&pin);
		ms_filter_call_method(st->send_tee,MS_TEE_UNMUTE,&pin);
		return 0;
	}
	return -1;
}
static void dtmfgen_filerec_fileplay_tonedet(void) {
	MSConnectionHelper h;
	unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_FILEREC
		| FILTER_MASK_FILEPLAY | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
	bool_t send_silence = TRUE;
	char* recorded_file = bc_tester_file(DTMFGEN_FILE_NAME);

	
	ms_factory_reset_statistics(factory);
	ms_tester_create_ticker();
	ms_tester_create_filters(filter_mask, factory);
	ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);

	// Generate tones and save them to a file
	ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_CLOSE);
	ms_filter_call_method(ms_tester_filerec, MS_FILE_REC_OPEN, recorded_file);
	ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_START);
	ms_filter_call_method(ms_tester_voidsource, MS_VOID_SOURCE_SEND_SILENCE, &send_silence);
	ms_connection_helper_start(&h);
	ms_connection_helper_link(&h, ms_tester_voidsource, -1, 0);
	ms_connection_helper_link(&h, ms_tester_dtmfgen, 0, 0);
	ms_connection_helper_link(&h, ms_tester_filerec, 0, -1);
	ms_ticker_attach(ms_tester_ticker, ms_tester_voidsource);
	ms_tester_tone_generation_loop();
	ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_CLOSE);
	ms_ticker_detach(ms_tester_ticker, ms_tester_voidsource);
	ms_connection_helper_start(&h);
	ms_connection_helper_unlink(&h, ms_tester_voidsource, -1, 0);
	ms_connection_helper_unlink(&h, ms_tester_dtmfgen, 0, 0);
	ms_connection_helper_unlink(&h, ms_tester_filerec, 0, -1);

	// Read the previous file and detect the tones
	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
	ms_filter_call_method(ms_tester_fileplay, MS_FILE_PLAYER_OPEN, recorded_file);
	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_START);
	ms_connection_helper_start(&h);
	ms_connection_helper_link(&h, ms_tester_fileplay, -1, 0);
	ms_connection_helper_link(&h, ms_tester_tonedet, 0, 0);
	ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1);
	ms_ticker_attach(ms_tester_ticker, ms_tester_fileplay);
	ms_tester_tone_detection_loop();
	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
	ms_ticker_detach(ms_tester_ticker, ms_tester_fileplay);
	ms_connection_helper_start(&h);
	ms_connection_helper_unlink(&h, ms_tester_fileplay, -1, 0);
	ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0);
	ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1);
	ms_factory_log_statistics(factory);
//	ms_filter_log_statistics();
	ms_tester_destroy_filters(filter_mask);
	ms_tester_destroy_ticker();
	unlink(recorded_file);
    free(recorded_file);
}
예제 #25
0
파일: bench.c 프로젝트: biddyweb/azfone-ios
static int uninit_bench(struct bench_config *bench)
{
	MSList *it;
	for(it=bench->tsessions;it!=NULL;it=bench->tsessions){
		struct test_session *ts = (struct test_session *)it->data;
		bench->tsessions = ms_list_remove_link(bench->tsessions, it);

		ms_ticker_detach(bench->ticker,ts->fplayer);
		ms_ticker_detach(bench->ticker,ts->rtprecv);

		ms_filter_call_method_noarg(ts->frecorder,MS_FILE_REC_CLOSE);

		if (strstr(bench->wavfile, ".au")==NULL)
			{
				ms_filter_unlink(ts->fplayer,0,ts->encoder,0);
				ms_filter_unlink(ts->encoder,0,ts->rtpsend,0);
			}
		else
			{
				ms_filter_unlink(ts->fplayer,0,ts->rtpsend,0);
			}

		ms_filter_unlink(ts->rtprecv,0,ts->decoder,0);
		ms_filter_unlink(ts->decoder,0,ts->frecorder,0);

		if (ts->fplayer) ms_filter_destroy(ts->fplayer);
		if (ts->encoder) ms_filter_destroy(ts->encoder);
		if (ts->rtpsend) ms_filter_destroy(ts->rtpsend);

		if (ts->rtprecv) ms_filter_destroy(ts->rtprecv);
		if (ts->decoder) ms_filter_destroy(ts->decoder);
		if (ts->frecorder) ms_filter_destroy(ts->frecorder);

		ortp_free(ts);
	}

	ms_ticker_destroy(bench->ticker);
	return 0;
}
예제 #26
0
파일: player.c 프로젝트: CTA/linphone
static int call_player_pause(LinphonePlayer *player){
	LinphoneCall *call=(LinphoneCall*)player->impl;
	if (!call_player_check_state(player,TRUE)) return -1;
	return ms_filter_call_method_noarg(call->audiostream->av_player.player,MS_PLAYER_PAUSE);
}
예제 #27
0
int main(int argc, char *argv[]){
	MSFilter *src, *gen, *det, *rec;
	MSTicker *ticker;

	ms_base_init();
	ortp_set_log_level_mask (ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);

	src=ms_filter_new(MS_FILE_PLAYER_ID);
	rec=ms_filter_new(MS_FILE_REC_ID);
	gen=ms_filter_new(MS_DTMF_GEN_ID);
	det=ms_filter_new(MS_TONE_DETECTOR_ID);
	
	ms_filter_link(src,0,gen,0);
	ms_filter_link(gen,0,det,0);
	//ms_filter_link(gen,0,rec,0);
	ms_filter_link(det,0,rec,0);

	ticker=ms_ticker_new();

	ms_ticker_attach(ticker,src);

	ms_filter_call_method(rec,MS_FILE_REC_OPEN,"/tmp/output.wav");
	ms_filter_call_method_noarg(rec,MS_FILE_REC_START);
	{
		/*generate and detect the tones*/
		MSDtmfGenCustomTone tone;
		MSToneDetectorDef expected_tone;
		char dtmf='*';
			
		tone.frequency=2000;
		tone.duration=400;
		tone.amplitude=0.6;

		expected_tone.frequency=2000;
		expected_tone.min_duration=200;
		expected_tone.min_amplitude=0.5;
		ms_filter_set_notify_callback(det,(MSFilterNotifyFunc)tone_detected_cb,NULL);
		ms_filter_set_notify_callback(gen,(MSFilterNotifyFunc)tone_sent_cb,NULL);
		
		ms_filter_call_method(det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);

		ms_filter_call_method(gen,MS_DTMF_GEN_PLAY,&dtmf);
		ms_sleep(1);
		
		ms_filter_call_method(gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
		ms_sleep(1);
		ms_filter_call_method(gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
		ms_sleep(1);
		ms_filter_call_method(gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
		ms_sleep(1);
		tone.frequency=1500;
		tone.amplitude=1.0;
		ms_filter_call_method(gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
		ms_sleep(1);
	}

	ms_filter_call_method_noarg(rec,MS_FILE_REC_CLOSE);
	ms_ticker_detach(ticker,src);

	ms_filter_unlink(src,0,gen,0);
	ms_filter_unlink(gen,0,det,0);
	//ms_filter_unlink(gen,0,rec,0);
	ms_filter_unlink(det,0,rec,0);

	ms_ticker_destroy(ticker);

	ms_filter_destroy(src);
	ms_filter_destroy(gen);
	ms_filter_destroy(det);
	ms_filter_destroy(rec);

	ms_base_exit();
	return 0;
}
예제 #28
0
void video_stream_send_vfu(VideoStream *stream){
	if (stream->ms.encoder)
		ms_filter_call_method_noarg(stream->ms.encoder, MS_VIDEO_ENCODER_REQ_VFU);
}
예제 #29
0
int ms_audio_recorder_endpoint_stop(MSAudioEndpoint *ep){
	if (!ep->recorder){
		return -1;
	}
	return ms_filter_call_method_noarg(ep->recorder,MS_RECORDER_CLOSE);
}
static void soundread_filerec_fileplay_soundwrite(void) {
	MSConnectionHelper h;
	unsigned int filter_mask = FILTER_MASK_SOUNDREAD | FILTER_MASK_FILEREC | FILTER_MASK_FILEPLAY | FILTER_MASK_SOUNDWRITE;
	int capture_sample_rate = 8000;
	int playback_sample_rate = 8000;
	int capture_nchannels = 1;
	int playback_nchannels = 1;
	char *writable_filename = bc_tester_file(SOUNDREAD_FILE_NAME);

	ms_filter_reset_statistics();
	ms_tester_create_ticker();
	ms_tester_create_filters(filter_mask);

	// Write audio capture to a file
	ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_SAMPLE_RATE, &capture_sample_rate);
	ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_NCHANNELS, &capture_nchannels);
	ms_filter_call_method(ms_tester_filerec, MS_FILTER_SET_SAMPLE_RATE, &capture_sample_rate);
	ms_filter_call_method(ms_tester_filerec, MS_FILTER_SET_NCHANNELS, &capture_nchannels);
	ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_CLOSE);
	ms_filter_call_method(ms_tester_filerec, MS_FILE_REC_OPEN, writable_filename);
	ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_START);
	ms_connection_helper_start(&h);
	ms_connection_helper_link(&h, ms_tester_soundread, -1, 0);
	ms_connection_helper_link(&h, ms_tester_filerec, 0, -1);
	ms_ticker_attach(ms_tester_ticker, ms_tester_soundread);

	ms_sleep(4);

	ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_CLOSE);
	ms_ticker_detach(ms_tester_ticker, ms_tester_soundread);
	ms_connection_helper_start(&h);
	ms_connection_helper_unlink(&h, ms_tester_soundread, -1, 0);
	ms_connection_helper_unlink(&h, ms_tester_filerec, 0, -1);

	// Read the previous file and play it
	ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_GET_SAMPLE_RATE, &playback_sample_rate);
	ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_GET_NCHANNELS, &playback_nchannels);
	if ((capture_sample_rate != playback_sample_rate) || (capture_nchannels != playback_nchannels)) {
		ms_tester_create_filter(&ms_tester_resampler, MS_RESAMPLE_ID);
	}
	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
	ms_filter_call_method(ms_tester_fileplay, MS_FILE_PLAYER_OPEN, writable_filename);
	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_START);
	ms_connection_helper_start(&h);
	ms_connection_helper_link(&h, ms_tester_fileplay, -1, 0);
	if (ms_tester_resampler != NULL) {
		ms_connection_helper_link(&h, ms_tester_resampler, 0, 0);
		ms_filter_call_method(ms_tester_resampler, MS_FILTER_SET_SAMPLE_RATE, &capture_sample_rate);
		ms_filter_call_method(ms_tester_resampler, MS_FILTER_SET_OUTPUT_SAMPLE_RATE, &playback_sample_rate);
		ms_filter_call_method(ms_tester_resampler, MS_FILTER_SET_NCHANNELS, &capture_nchannels);
		ms_filter_call_method(ms_tester_resampler, MS_FILTER_SET_OUTPUT_NCHANNELS, &capture_nchannels);
	}
	ms_connection_helper_link(&h, ms_tester_soundwrite, 0, -1);
	ms_ticker_attach(ms_tester_ticker, ms_tester_fileplay);

	ms_sleep(4);

	ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
	ms_ticker_detach(ms_tester_ticker, ms_tester_fileplay);
	ms_connection_helper_start(&h);
	ms_connection_helper_unlink(&h, ms_tester_fileplay, -1, 0);
	if (ms_tester_resampler != NULL) {
		ms_connection_helper_unlink(&h, ms_tester_resampler, 0, 0);
	}
	ms_connection_helper_unlink(&h, ms_tester_soundwrite, 0, -1);
	ms_filter_log_statistics();
	ms_tester_destroy_filters(filter_mask);
	ms_tester_destroy_ticker();

	unlink(writable_filename);
    free(writable_filename);
}