static void dtmfgen_tonedet(void) { MSConnectionHelper h; unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK; bool_t send_silence = TRUE; ms_filter_reset_statistics(); ms_tester_create_ticker(); ms_tester_create_filters(filter_mask); ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE); 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_tonedet, 0, 0); ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1); ms_ticker_attach(ms_tester_ticker, ms_tester_voidsource); ms_tester_tone_generation_and_detection_loop(); /*try unrecognized DTMF*/ BC_ASSERT_NOT_EQUAL(ms_filter_call_method(ms_tester_dtmfgen, MS_DTMF_GEN_PLAY, "F"),0,int,"%d"); 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_tonedet, 0, 0); ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1); ms_filter_log_statistics(); ms_tester_destroy_filters(filter_mask); ms_tester_destroy_ticker(); }
static void dtmfgen_tonedet(void) { MSConnectionHelper h; unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK; ms_filter_reset_statistics(); ms_tester_create_ticker(); ms_tester_create_filters(filter_mask); ms_filter_set_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL); 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_tonedet, 0, 0); ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1); ms_ticker_attach(ms_tester_ticker, ms_tester_voidsource); ms_tester_tone_generation_and_detection_loop(); 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_tonedet, 0, 0); ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1); ms_filter_log_statistics(); ms_tester_destroy_filters(filter_mask); ms_tester_destroy_ticker(); }
void text_stream_stop(TextStream *stream) { if (stream->ms.sessions.ticker) { if (stream->ms.state == MSStreamPreparing) { text_stream_unprepare_text(stream); } else if (stream->ms.state == MSStreamStarted) { MSConnectionHelper h; stream->ms.state = MSStreamStopped; ms_ticker_detach(stream->ms.sessions.ticker, stream->rttsource); ms_ticker_detach(stream->ms.sessions.ticker, stream->ms.rtprecv); if (stream->ms.ice_check_list != NULL) { ice_check_list_print_route(stream->ms.ice_check_list, "Text session's route"); stream->ms.ice_check_list = NULL; } rtp_stats_display(rtp_session_get_stats(stream->ms.sessions.rtp_session), " TEXT SESSION'S RTP STATISTICS "); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h, stream->rttsource, -1, 0); ms_connection_helper_unlink(&h, stream->ms.rtpsend, 0, -1); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h, stream->ms.rtprecv, -1, 0); ms_connection_helper_unlink(&h, stream->rttsink, 0, -1); } } text_stream_free(stream); ms_filter_log_statistics(); }
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(); }
static void dtmfgen_soundwrite(void) { MSConnectionHelper h; bool_t need_resampler = FALSE; unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_SOUNDWRITE; int sample_rate = 8000; int nchannels = 1; bool_t send_silence = TRUE; ms_filter_reset_statistics(); ms_tester_create_ticker(); ms_tester_create_filters(filter_mask); ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_voidsource, MS_VOID_SOURCE_SEND_SILENCE, &send_silence); ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_NCHANNELS, &nchannels); if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_SAMPLE_RATE, &sample_rate) != 0) { need_resampler = TRUE; } if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_NCHANNELS, &nchannels) != 0) { need_resampler = TRUE; } if (need_resampler == TRUE) { ms_tester_create_filters(FILTER_MASK_RESAMPLER); configure_resampler(ms_tester_resampler, ms_tester_dtmfgen, ms_tester_soundwrite); } 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); 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_voidsource); ms_tester_tone_generation_loop(); 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); 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(); }
static void lsd_player_uninit(LsdPlayer *p, MSConnectionPoint mixer){ MSConnectionHelper h; ms_connection_helper_start(&h); ms_connection_helper_unlink (&h,p->player,-1,0); ms_connection_helper_unlink(&h,p->rateconv,0,0); ms_connection_helper_unlink(&h,p->chanadapter,0,0); ms_connection_helper_unlink(&h,mixer.filter,mixer.pin,-1); ms_filter_destroy(p->player); ms_filter_destroy(p->rateconv); ms_filter_destroy(p->chanadapter); }
static void soundread_soundwrite(void) { MSConnectionHelper h; bool_t need_resampler = FALSE; unsigned int filter_mask = FILTER_MASK_SOUNDREAD | FILTER_MASK_SOUNDWRITE; int sample_rate = 8000; int nchannels = 1; ms_filter_reset_statistics(); ms_tester_create_ticker(); ms_tester_create_filters(filter_mask); ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_soundread, 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_soundread, ms_tester_soundwrite); } ms_connection_helper_start(&h); ms_connection_helper_link(&h, ms_tester_soundread, -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_soundread); ms_sleep(3); ms_ticker_detach(ms_tester_ticker, ms_tester_soundread); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h, ms_tester_soundread, -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(); }
void video_stream_stop (VideoStream * stream) { stream->eventcb = NULL; stream->event_pointer = NULL; if (stream->ticker){ if (stream->voidsink) { stop_preload_graph(stream); } else { if (stream->source) ms_ticker_detach(stream->ticker,stream->source); if (stream->rtprecv) ms_ticker_detach(stream->ticker,stream->rtprecv); if (stream->ice_check_list != NULL) { ice_check_list_print_route(stream->ice_check_list, "Video session's route"); stream->ice_check_list = NULL; } rtp_stats_display(rtp_session_get_stats(stream->session),"Video session's RTP statistics"); if (stream->source){ ms_filter_unlink(stream->source,0,stream->pixconv,0); ms_filter_unlink (stream->pixconv, 0, stream->sizeconv, 0); ms_filter_unlink (stream->sizeconv, 0, stream->tee, 0); ms_filter_unlink(stream->tee,0,stream->encoder,0); ms_filter_unlink(stream->encoder, 0, stream->rtpsend,0); if (stream->output2){ ms_filter_unlink(stream->tee,1,stream->output2,0); } } if (stream->rtprecv){ MSConnectionHelper h; ms_connection_helper_start (&h); ms_connection_helper_unlink (&h,stream->rtprecv,-1,0); ms_connection_helper_unlink (&h,stream->decoder,0,0); if (stream->tee2){ ms_connection_helper_unlink (&h,stream->tee2,0,0); ms_filter_unlink(stream->tee2,1,stream->jpegwriter,0); } if(stream->output) ms_connection_helper_unlink (&h,stream->output,0,-1); if (stream->tee && stream->output && stream->output2==NULL) ms_filter_unlink(stream->tee,1,stream->output,1); } } } video_stream_free (stream); }
static void clear_mediastreams(MediastreamDatas *args) { MSConnectionHelper h; ms_message("stopping all...\n"); if (args->read) { ms_ticker_detach(args->ticker, args->read); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h, args->read, -1, 0); ms_connection_helper_unlink(&h, args->decoder, 0, 0); ms_connection_helper_unlink(&h, args->write, 0, -1); } rtp_profile_destroy(args->profile); ms_exit(); }
static void dtmfgen_enc_rtp_dec_tonedet(void) { MSConnectionHelper h; RtpSession *rtps; unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER | FILTER_MASK_RTPSEND | FILTER_MASK_RTPRECV | FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK; bool_t send_silence = TRUE; MSSndCardManager *scm = ms_factory_get_snd_card_manager(factory); ms_factory_reset_statistics(factory); //ms_filter_reset_statistics(); ms_tester_create_ticker(); ms_tester_codec_mime = "pcmu"; ms_tester_create_filters(filter_mask, factory); ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE); rtps = ms_create_duplex_rtp_session("0.0.0.0", 50060, 0, ms_factory_get_mtu(factory)); rtp_session_set_remote_addr_full(rtps, "127.0.0.1", 50060, "127.0.0.1", 50061); rtp_session_set_payload_type(rtps, 8); rtp_session_enable_rtcp(rtps,FALSE); ms_filter_call_method(ms_tester_rtprecv, MS_RTP_RECV_SET_SESSION, rtps); ms_filter_call_method(ms_tester_rtpsend, MS_RTP_SEND_SET_SESSION, rtps); 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_encoder, 0, 0); ms_connection_helper_link(&h, ms_tester_rtpsend, 0, -1); ms_connection_helper_start(&h); ms_connection_helper_link(&h, ms_tester_rtprecv, -1, 0); ms_connection_helper_link(&h, ms_tester_decoder, 0, 0); ms_connection_helper_link(&h, ms_tester_tonedet, 0, 0); ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1); ms_ticker_attach_multiple(ms_tester_ticker, ms_tester_voidsource, ms_tester_rtprecv, NULL); ms_tester_tone_generation_and_detection_loop(); ms_ticker_detach(ms_tester_ticker, ms_tester_voidsource); ms_ticker_detach(ms_tester_ticker, ms_tester_rtprecv); 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_encoder, 0, 0); ms_connection_helper_unlink(&h, ms_tester_rtpsend, 0, -1); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h, ms_tester_rtprecv, -1, 0); ms_connection_helper_unlink(&h, ms_tester_decoder, 0, 0); ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0); ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1); // ms_filter_log_statistics(); ms_factory_log_statistics(scm->factory); ms_tester_destroy_filters(filter_mask); ms_tester_destroy_ticker(); rtp_session_destroy(rtps); }
void ring_stop(RingStream *stream){ MSConnectionHelper h; ms_ticker_detach(stream->ticker,stream->source); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->source,-1,0); ms_connection_helper_unlink(&h,stream->gendtmf,0,0); if (stream->write_resampler) ms_connection_helper_unlink(&h,stream->write_resampler,0,0); ms_connection_helper_unlink(&h,stream->sndwrite,0,-1); ms_ticker_destroy(stream->ticker); ms_filter_destroy(stream->source); ms_filter_destroy(stream->gendtmf); ms_filter_destroy(stream->sndwrite); if (stream->write_resampler) ms_filter_destroy(stream->write_resampler); ms_free(stream); }
void ring_stop(RingStream *stream){ MSConnectionHelper h; ms_ticker_detach(stream->ticker,stream->source); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->source,-1,0); ms_connection_helper_unlink(&h,stream->gendtmf,0,0); if (stream->write_resampler) ms_connection_helper_unlink(&h,stream->write_resampler,0,0); ms_connection_helper_unlink(&h,stream->sndwrite,0,-1); ms_ticker_destroy(stream->ticker); ms_filter_destroy(stream->source); ms_filter_destroy(stream->gendtmf); ms_filter_destroy(stream->sndwrite); ms_free(stream); #ifdef _WIN32_WCE ms_warning("Sleeping a bit after closing the audio device..."); ms_sleep(1); #endif }
void video_stream_stop (VideoStream * stream) { if (stream->ticker){ if (stream->source) ms_ticker_detach(stream->ticker,stream->source); if (stream->rtprecv) ms_ticker_detach(stream->ticker,stream->rtprecv); rtp_stats_display(rtp_session_get_stats(stream->session),"Video session's RTP statistics"); if (stream->source){ ms_filter_unlink(stream->source,0,stream->pixconv,0); ms_filter_unlink (stream->pixconv, 0, stream->sizeconv, 0); ms_filter_unlink (stream->sizeconv, 0, stream->tee, 0); ms_filter_unlink(stream->tee,0,stream->encoder,0); ms_filter_unlink(stream->encoder, 0, stream->rtpsend,0); if (stream->output2){ ms_filter_unlink(stream->tee,1,stream->output2,0); } } if (stream->rtprecv){ MSConnectionHelper h; ms_connection_helper_start (&h); ms_connection_helper_unlink (&h,stream->rtprecv,-1,0); ms_connection_helper_unlink (&h,stream->decoder,0,0); if (stream->tee2){ ms_connection_helper_unlink (&h,stream->tee2,0,0); ms_filter_unlink(stream->tee2,1,stream->jpegwriter,0); if(stream->video_record) ms_filter_unlink(stream->tee2,2,stream->video_record,0); } ms_connection_helper_unlink (&h,stream->output,0,-1); if (stream->tee && stream->output2==NULL && ms_filter_get_id(stream->output)!=MS_CONF_ITC_SINK_ID) ms_filter_unlink(stream->tee,1,stream->output,1); } } video_stream_free (stream); }
static void dtmfgen_enc_dec_tonedet(char *mime, int sample_rate, int nchannels) { MSConnectionHelper h; unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER | FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK; bool_t send_silence = TRUE; MSSndCardManager *scm = ms_factory_get_snd_card_manager(factory); ms_factory_reset_statistics(scm->factory); //ms_filter_reset_statistics(); ms_tester_create_ticker(); ms_tester_codec_mime = mime; ms_tester_create_filters(filter_mask, scm->factory); /* set sample rate and channel number to all filters (might need to check the return value to insert a resampler if needed?) */ ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_voidsource, MS_VOID_SOURCE_SEND_SILENCE, &send_silence); ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_encoder, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_encoder, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_tonedet, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_tonedet, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE); 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_encoder, 0, 0); ms_connection_helper_link(&h, ms_tester_decoder, 0, 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_voidsource); ms_tester_tone_generation_and_detection_loop(); 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_encoder, 0, 0); ms_connection_helper_unlink(&h, ms_tester_decoder, 0, 0); ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0); ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1); // ms_filter_log_statistics(); ms_factory_log_statistics(scm->factory); ms_tester_destroy_filters(filter_mask); ms_tester_destroy_ticker(); }
void video_mail_record_stop(VideoMailRecord *vp) { MSConnectionHelper h; VideoRecoder *os= vp->os; if(vp->ticker) { if(vp->snd_read!=NULL && vp->snd_sink!=NULL){ ms_ticker_detach(vp->ticker,vp->snd_read); ms_filter_unlink(vp->snd_read,0,vp->snd_sink,0); } if(vp->video_source!=NULL && vp->video_output!=NULL){ ms_ticker_detach(vp->ticker,vp->video_source); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,vp->video_source,-1,0); ms_connection_helper_unlink(&h,vp->pixconv,0,0); ms_connection_helper_unlink(&h,vp->sizeconv,0,0); ms_connection_helper_unlink(&h,vp->video_tee,0,0); ms_filter_unlink(vp->video_tee,1,vp->video_output,0); ms_connection_helper_unlink(&h,vp->video_sink,0,-1); } } if(vp->os) { video_recoder_stop(os); video_recoder_destory(os); } video_mail_record_free(vp); }
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); }
static void _unlink_all(MSMediaPlayer *obj) { MSConnectionHelper helper; if(obj->audio_pin_fmt.fmt && obj->audio_sink) { ms_connection_helper_start(&helper); ms_connection_helper_unlink(&helper, obj->player, -1, obj->audio_pin_fmt.pin); if(obj->audio_decoder) ms_connection_helper_unlink(&helper, obj->audio_decoder, 0, 0); if(obj->resampler) ms_connection_helper_unlink(&helper, obj->resampler, 0, 0); ms_connection_helper_unlink(&helper, obj->audio_sink, 0, -1); } if(obj->video_pin_fmt.fmt && obj->video_sink) { ms_connection_helper_start(&helper); ms_connection_helper_unlink(&helper, obj->player, -1, obj->video_pin_fmt.pin); if(obj->video_decoder) ms_connection_helper_unlink(&helper, obj->video_decoder, 0 , 0); ms_connection_helper_unlink(&helper, obj->video_sink, 0, -1); } }
void audio_stream_stop(AudioStream * stream) { if (stream->ms.ticker){ MSConnectionHelper h; if (stream->dummy){ stop_preload_graph(stream); }else if (stream->ms.start_time!=0){ ms_ticker_detach(stream->ms.ticker,stream->soundread); ms_ticker_detach(stream->ms.ticker,stream->ms.rtprecv); if (stream->ms.ice_check_list != NULL) { ice_check_list_print_route(stream->ms.ice_check_list, "Audio session's route"); stream->ms.ice_check_list = NULL; } rtp_stats_display(rtp_session_get_stats(stream->ms.session), " AUDIO SESSION'S RTP STATISTICS "); /*dismantle the outgoing graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->soundread,-1,0); if (stream->read_resampler!=NULL) ms_connection_helper_unlink(&h,stream->read_resampler,0,0); if (stream->ec!=NULL) ms_connection_helper_unlink(&h,stream->ec,1,1); if (stream->volsend!=NULL) ms_connection_helper_unlink(&h,stream->volsend,0,0); if (stream->dtmfgen_rtp) ms_connection_helper_unlink(&h,stream->dtmfgen_rtp,0,0); if (stream->send_tee) ms_connection_helper_unlink(&h,stream->send_tee,0,0); ms_connection_helper_unlink(&h,stream->ms.encoder,0,0); ms_connection_helper_unlink(&h,stream->ms.rtpsend,0,-1); /*dismantle the receiving graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->ms.rtprecv,-1,0); ms_connection_helper_unlink(&h,stream->ms.decoder,0,0); if (stream->plc!=NULL) ms_connection_helper_unlink(&h,stream->plc,0,0); if (stream->dtmfgen!=NULL) ms_connection_helper_unlink(&h,stream->dtmfgen,0,0); if (stream->volrecv!=NULL) ms_connection_helper_unlink(&h,stream->volrecv,0,0); if (stream->recv_tee) ms_connection_helper_unlink(&h,stream->recv_tee,0,0); if (stream->equalizer!=NULL) ms_connection_helper_unlink(&h,stream->equalizer,0,0); if (stream->ec!=NULL) ms_connection_helper_unlink(&h,stream->ec,0,0); if (stream->write_resampler!=NULL) ms_connection_helper_unlink(&h,stream->write_resampler,0,0); ms_connection_helper_unlink(&h,stream->soundwrite,0,-1); /*dismantle the call recording */ if (stream->recorder){ ms_filter_unlink(stream->send_tee,1,stream->recorder_mixer,0); ms_filter_unlink(stream->recv_tee,1,stream->recorder_mixer,1); ms_filter_unlink(stream->recorder_mixer,0,stream->recorder,0); } } } audio_stream_free(stream); ms_filter_log_statistics(); }
void audio_stream_stop(AudioStream * stream) { if (stream->ticker){ MSConnectionHelper h; if(stream->record_enabled) audio_stream_record_stop(stream); ms_ticker_detach(stream->ticker,stream->soundread); ms_ticker_detach(stream->ticker,stream->rtprecv); rtp_stats_display(rtp_session_get_stats(stream->session),"Audio session's RTP statistics"); /*dismantle the outgoing graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->soundread,-1,0); if (stream->read_resampler!=NULL) ms_connection_helper_unlink(&h,stream->read_resampler,0,0); if (stream->ec!=NULL) ms_connection_helper_unlink(&h,stream->ec,1,1); if (stream->volsend!=NULL) ms_connection_helper_unlink(&h,stream->volsend,0,0); if(stream->mic_tee && stream->recordmixer) ms_filter_unlink(stream->mic_tee,1,stream->recordmixer,0); if(stream->mic_tee) ms_connection_helper_unlink(&h,stream->mic_tee,0,0); ms_connection_helper_unlink(&h,stream->encoder,0,0); ms_connection_helper_unlink(&h,stream->rtpsend,0,-1); /*dismantle the receiving graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->rtprecv,-1,0); ms_connection_helper_unlink(&h,stream->decoder,0,0); ms_connection_helper_unlink(&h,stream->dtmfgen,0,0); if (stream->equalizer) ms_connection_helper_unlink(&h,stream->equalizer,0,0); if (stream->volrecv!=NULL) ms_connection_helper_unlink(&h,stream->volrecv,0,0); if (stream->ec!=NULL) ms_connection_helper_unlink(&h,stream->ec,0,0); if (stream->write_resampler!=NULL) ms_connection_helper_unlink(&h,stream->write_resampler,0,0); if(stream->mic_tee && stream->recordmixer) ms_filter_unlink(stream->spk_tee,1,stream->recordmixer,1); if(stream->spk_tee) ms_connection_helper_unlink(&h,stream->spk_tee,0,0); ms_connection_helper_unlink(&h,stream->soundwrite,0,-1); } audio_stream_free(stream); }
void video_stream_stop (VideoStream * stream) { stream->eventcb = NULL; stream->event_pointer = NULL; if (stream->ms.ticker){ if (stream->prepare_ongoing == TRUE) { stop_preload_graph(stream); } else { if (stream->source) ms_ticker_detach(stream->ms.ticker,stream->source); if (stream->ms.rtprecv) ms_ticker_detach(stream->ms.ticker,stream->ms.rtprecv); if (stream->ms.ice_check_list != NULL) { ice_check_list_print_route(stream->ms.ice_check_list, "Video session's route"); stream->ms.ice_check_list = NULL; } rtp_stats_display(rtp_session_get_stats(stream->ms.session), " VIDEO SESSION'S RTP STATISTICS "); if (stream->source){ MSConnectionHelper ch; ms_connection_helper_start(&ch); ms_connection_helper_unlink(&ch, stream->source, -1, 0); if (stream->pixconv) { ms_connection_helper_unlink(&ch, stream->pixconv, 0, 0); } if (stream->sizeconv) { ms_connection_helper_unlink(&ch, stream->sizeconv, 0, 0); } ms_connection_helper_unlink(&ch, stream->tee, 0, 0); if (stream->source_performs_encoding == FALSE) { ms_connection_helper_unlink(&ch, stream->ms.encoder, 0, 0); } ms_connection_helper_unlink(&ch, stream->ms.rtpsend, 0, -1); if (stream->output2){ ms_filter_unlink(stream->tee,1,stream->output2,0); } } if (stream->ms.voidsink) { ms_filter_unlink(stream->ms.rtprecv, 0, stream->ms.voidsink, 0); } else if (stream->ms.rtprecv){ MSConnectionHelper h; ms_connection_helper_start (&h); ms_connection_helper_unlink (&h,stream->ms.rtprecv,-1,0); if (stream->output_performs_decoding == FALSE) { ms_connection_helper_unlink (&h,stream->ms.decoder,0,0); } if (stream->tee2){ ms_connection_helper_unlink (&h,stream->tee2,0,0); ms_filter_unlink(stream->tee2,1,stream->jpegwriter,0); } if(stream->output) ms_connection_helper_unlink (&h,stream->output,0,-1); if (stream->tee && stream->output && stream->output2==NULL) ms_filter_unlink(stream->tee,1,stream->output,1); } } } video_stream_free (stream); }
static void dtmfgen_enc_dec_tonedet_filerec_fileplay(char *mime, int sample_rate, int nchannels) { MSConnectionHelper h; unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER | FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK | FILTER_MASK_SOUNDREAD | FILTER_MASK_FILEREC | FILTER_MASK_FILEPLAY | FILTER_MASK_SOUNDWRITE; bool_t send_silence = TRUE; 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); MSSndCardManager *scm = ms_factory_get_snd_card_manager(factory); ms_factory_reset_statistics(scm->factory); //ms_filter_reset_statistics(); ms_tester_create_ticker(); ms_tester_codec_mime = mime; ms_tester_create_filters(filter_mask, scm->factory); // 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); /* set sample rate and channel number to all filters (might need to check the return value to insert a resampler if needed?) */ ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_voidsource, MS_VOID_SOURCE_SEND_SILENCE, &send_silence); ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_encoder, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_encoder, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_tonedet, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_tonedet, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_SAMPLE_RATE, &sample_rate); ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_NCHANNELS, &nchannels); ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE); 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_encoder, 0, 0); ms_connection_helper_link(&h, ms_tester_decoder, 0, 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_voidsource); ms_tester_tone_generation_and_detection_loop(); 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, scm->factory); } 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); 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_encoder, 0, 0); ms_connection_helper_unlink(&h, ms_tester_decoder, 0, 0); ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0); ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1); // ms_filter_log_statistics(); ms_factory_log_statistics(scm->factory); ms_tester_destroy_filters(filter_mask); ms_tester_destroy_ticker(); }
int conf_stream_connect_to_audio_stream(LinphoneConferenceStream *conf_stream, AudioStream *audio_stream){ int connect_port = -1; if(conf_stream==NULL || audio_stream == NULL) return connect_port; ConfAudioPort *audio_port = find_free_audio_slot(conf_stream); if(audio_port==NULL){ ms_message("no more audio port to conf"); return -2; } /*连接呼叫音频部分 audio_stream <---> audio_port*/ if(audio_stream->ticker!=NULL){ MSConnectionHelper h; ms_ticker_detach(audio_stream->ticker,audio_stream->soundread); ms_ticker_detach(audio_stream->ticker,audio_stream->rtprecv); ms_message("connect: conf_stream [%d] <----> audio_stream !!",audio_port->index); /*dismantle the outgoing graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,audio_stream->soundread,-1,0); if (audio_stream->read_resampler!=NULL) ms_connection_helper_unlink(&h,audio_stream->read_resampler,0,0); #ifndef ENABLED_MCU_MEDIA_SERVER if (audio_stream->volsend!=NULL) ms_connection_helper_unlink(&h,audio_stream->volsend,0,0); #endif // ENABLED_MCU_MEDIA_SERVER if (audio_stream->dtmfgen_rtp) ms_connection_helper_unlink(&h,audio_stream->dtmfgen_rtp,0,0); ms_connection_helper_unlink(&h,audio_stream->encoder,0,0); ms_connection_helper_unlink(&h,audio_stream->rtpsend,0,-1); /*dismantle the receiving graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,audio_stream->rtprecv,-1,0); ms_connection_helper_unlink(&h,audio_stream->decoder,0,0); ms_connection_helper_unlink(&h,audio_stream->dtmfgen,0,0); #ifndef ENABLED_MCU_MEDIA_SERVER if (audio_stream->equalizer) ms_connection_helper_unlink(&h,audio_stream->equalizer,0,0); if (audio_stream->volrecv) ms_connection_helper_unlink(&h,audio_stream->volrecv,0,0); if (audio_stream->ec) ms_connection_helper_unlink(&h,audio_stream->ec,0,0); #endif // ENABLED_MCU_MEDIA_SERVER if (audio_stream->write_resampler) ms_connection_helper_unlink(&h,audio_stream->write_resampler,0,0); ms_connection_helper_unlink(&h,audio_stream->soundwrite,0,-1); /*销毁原声卡filter*/ ms_filter_destroy(audio_stream->soundread); ms_filter_destroy(audio_stream->soundwrite); audio_stream->soundread = ms_filter_new(MS_CONF_ITC_SOURCE_ID); audio_stream->soundwrite = ms_filter_new(MS_CONF_ITC_SINK_ID); /*处理采样率变换*/ /*outgoing graph*/ ms_connection_helper_start(&h); ms_connection_helper_link(&h,audio_stream->soundread,-1,0); if (audio_stream->read_resampler!=NULL) ms_connection_helper_link(&h,audio_stream->read_resampler,0,0); #ifndef ENABLED_MCU_MEDIA_SERVER if (audio_stream->volsend!=NULL) ms_connection_helper_link(&h,audio_stream->volsend,0,0); #endif // ENABLED_MCU_MEDIA_SERVER if (audio_stream->dtmfgen_rtp) ms_connection_helper_link(&h,audio_stream->dtmfgen_rtp,0,0); ms_connection_helper_link(&h,audio_stream->encoder,0,0); ms_connection_helper_link(&h,audio_stream->rtpsend,0,-1); /*receiving graph*/ ms_connection_helper_start(&h); ms_connection_helper_link(&h,audio_stream->rtprecv,-1,0); ms_connection_helper_link(&h,audio_stream->decoder,0,0); ms_connection_helper_link(&h,audio_stream->dtmfgen,0,0); #ifndef ENABLED_MCU_MEDIA_SERVER if (audio_stream->equalizer) ms_connection_helper_link(&h,audio_stream->equalizer,0,0); if (audio_stream->volrecv) ms_connection_helper_link(&h,audio_stream->volrecv,0,0); if (audio_stream->ec) ms_connection_helper_link(&h,audio_stream->ec,0,0); #endif // ENABLED_MCU_MEDIA_SERVER if (audio_stream->write_resampler) ms_connection_helper_link(&h,audio_stream->write_resampler,0,0); ms_connection_helper_link(&h,audio_stream->soundwrite,0,-1); ms_ticker_attach(audio_stream->ticker,audio_stream->soundread); ms_ticker_attach(audio_stream->ticker,audio_stream->rtprecv); /*连接Call声卡I/O至conf_stream*/ audio_port->source_connected = TRUE; ms_filter_call_method(audio_port->audio_itc_source,MS_CONF_ITC_SOURCE_CONNECT,&audio_port->slotq_in); ms_filter_call_method(audio_stream->soundwrite,MS_CONF_ITC_SINK_CONNECT,&audio_port->slotq_in); audio_port->sink_connected = TRUE; ms_filter_call_method(audio_stream->soundread,MS_CONF_ITC_SOURCE_CONNECT,&audio_port->slotq_out); ms_filter_call_method(audio_port->audio_itc_sink,MS_CONF_ITC_SINK_CONNECT,&audio_port->slotq_out); if(audio_port->muted) ms_filter_call_method(audio_port->audio_itc_sink,MS_CONF_ITC_SINK_MUTE,NULL); else ms_filter_call_method(audio_port->audio_itc_sink,MS_CONF_ITC_SINK_UNMUTE,NULL); connect_port = audio_port->index; } return connect_port; }
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); }
int conf_stream_connect_video_stream_port(LinphoneConferenceStream *conf_stream, VideoStream *video_stream){ int connected_port = -1; if(conf_stream==NULL || video_stream == NULL) return -1; ConfVideoPort *video_port = find_free_video_slot(conf_stream); MSPixFmt format=MS_YUV420P; if(video_port==NULL){ ms_message("no more video port to conf"); return -2; } if(video_stream->ticker!=NULL && video_stream->output!=NULL){ MSConnectionHelper ch; if (video_stream->source) ms_ticker_detach (video_stream->ticker, video_stream->source); if (video_stream->rtprecv) ms_ticker_detach (video_stream->ticker, video_stream->rtprecv); ms_message("connect: conf_stream [%d] <----> video_port !!",video_port->index); ms_filter_unlink(video_stream->source,0,video_stream->pixconv,0); if (video_stream->tee!=NULL){ //断开本地视频预览小窗口输出 ms_filter_unlink(video_stream->tee,1,video_stream->output,1); } /*断开解码器*/ /* and connect the filters */ ms_connection_helper_start (&ch); ms_connection_helper_unlink (&ch,video_stream->rtprecv,-1,0); ms_connection_helper_unlink (&ch,video_stream->decoder,0,0); if (video_stream->tee2){ ms_connection_helper_unlink (&ch,video_stream->tee2,0,0); ms_filter_unlink(video_stream->tee2,1,video_stream->jpegwriter,0); //输出视频录制帧. if(video_stream->video_record){ ms_filter_unlink(video_stream->tee2,2,video_stream->video_record,0); } } ms_connection_helper_unlink (&ch,video_stream->output,0,-1); //销毁旧的I/O ms_filter_destroy(video_stream->source); ms_filter_destroy(video_stream->output); //创建会议槽I/O video_stream->source = ms_filter_new(MS_CONF_ITC_SOURCE_ID); //output = 1 video_stream->output = ms_filter_new(MS_CONF_ITC_SINK_ID); //input = 1 //会议参数设置 int tmp = video_port->index; if(conf_stream->auto_layout)//自动布局模式下只开启 0 号端口的静态图片 { if(tmp==0) ms_filter_call_method(conf_stream->video_static_image_tee,MS_TEE_MUTE,&tmp); }else{ ms_filter_call_method(conf_stream->video_static_image_tee,MS_TEE_MUTE,&tmp); } MSVideoSize sent_size; ms_filter_call_method(video_stream->encoder,MS_FILTER_GET_VIDEO_SIZE,&sent_size); ms_filter_call_method(video_stream->pixconv,MS_FILTER_SET_PIX_FMT,&format); ms_filter_call_method(video_stream->sizeconv,MS_FILTER_SET_VIDEO_SIZE,&sent_size); ms_filter_link(video_stream->source,0,video_stream->pixconv,0); {//重连解码器 /* and connect the filters */ ms_connection_helper_start (&ch); ms_connection_helper_link (&ch,video_stream->rtprecv,-1,0); ms_connection_helper_link (&ch,video_stream->decoder,0,0); if (video_stream->tee2){ ms_connection_helper_link (&ch,video_stream->tee2,0,0); ms_filter_link(video_stream->tee2,1,video_stream->jpegwriter,0); //输出视频录制帧. if(video_stream->video_record) ms_filter_link(video_stream->tee2,2,video_stream->video_record,0); } ms_connection_helper_link (&ch,video_stream->output,0,-1); } if (video_stream->source) ms_ticker_attach(video_stream->ticker, video_stream->source); if (video_stream->rtprecv) ms_ticker_attach (video_stream->ticker, video_stream->rtprecv); video_port->source_connected = TRUE; ms_filter_call_method(video_port->video_itc_source,MS_CONF_ITC_SOURCE_CONNECT,&video_port->slotq_in); ms_filter_call_method(video_stream->output,MS_CONF_ITC_SINK_CONNECT,&video_port->slotq_in); video_port->sink_connected = TRUE; ms_filter_call_method(video_stream->source,MS_CONF_ITC_SOURCE_CONNECT,&video_port->slotq_out); ms_filter_call_method(video_port->video_itc_sink,MS_CONF_ITC_SINK_CONNECT,&video_port->slotq_out); if(video_port->muted) ms_filter_call_method(video_port->video_itc_sink,MS_CONF_ITC_SINK_MUTE,NULL); else ms_filter_call_method(video_port->video_itc_sink,MS_CONF_ITC_SINK_UNMUTE,NULL); connected_port = video_port->index; } return connected_port; }
static void soundread_speexenc_speexdec_soundwrite(void) { MSConnectionHelper h; MSFilter *read_resampler = NULL, *write_resampler = NULL; bool_t need_read_resampler = FALSE, need_write_resampler = FALSE; unsigned int filter_mask = FILTER_MASK_SOUNDREAD | FILTER_MASK_ENCODER | FILTER_MASK_DECODER | FILTER_MASK_SOUNDWRITE; int sample_rate = 8000; int nchannels = 1; ms_filter_reset_statistics(); ms_tester_create_ticker(); ms_tester_codec_mime = "speex"; ms_tester_create_filters(filter_mask); ms_filter_call_method(ms_tester_encoder, MS_FILTER_GET_BITRATE, &sample_rate); ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_BITRATE, &sample_rate); if (ms_filter_call_method(ms_tester_soundread, MS_FILTER_SET_BITRATE, &sample_rate) != 0) { int soundread_sample_rate = 48000; ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_BITRATE, &soundread_sample_rate); if (sample_rate != soundread_sample_rate) need_read_resampler = TRUE; } if (ms_filter_call_method(ms_tester_soundread, MS_FILTER_SET_NCHANNELS, &nchannels) != 0) { int soundread_nchannels = 1; ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_NCHANNELS, &soundread_nchannels); if (nchannels != soundread_nchannels) need_read_resampler = TRUE; } if (need_read_resampler == TRUE) { ms_tester_create_filter(&read_resampler, MS_RESAMPLE_ID); configure_resampler(read_resampler, ms_tester_soundread, ms_tester_encoder); } 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_write_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_write_resampler = TRUE; } if (need_write_resampler == TRUE) { ms_tester_create_filter(&write_resampler, MS_RESAMPLE_ID); configure_resampler(write_resampler, ms_tester_decoder, ms_tester_soundwrite); } ms_connection_helper_start(&h); ms_connection_helper_link(&h, ms_tester_soundread, -1, 0); if (need_read_resampler == TRUE) { ms_connection_helper_link(&h, read_resampler, 0, 0); } ms_connection_helper_link(&h, ms_tester_encoder, 0, 0); ms_connection_helper_link(&h, ms_tester_decoder, 0, 0); if (need_write_resampler == TRUE) { ms_connection_helper_link(&h, write_resampler, 0, 0); } ms_connection_helper_link(&h, ms_tester_soundwrite, 0, -1); ms_ticker_attach(ms_tester_ticker, ms_tester_soundread); ms_sleep(5); ms_ticker_detach(ms_tester_ticker, ms_tester_soundread); ms_connection_helper_start(&h); ms_connection_helper_unlink(&h, ms_tester_soundread, -1, 0); if (need_read_resampler == TRUE) { ms_connection_helper_unlink(&h, read_resampler, 0, 0); } ms_connection_helper_unlink(&h, ms_tester_encoder, 0, 0); ms_connection_helper_unlink(&h, ms_tester_decoder, 0, 0); if (need_write_resampler == TRUE) { ms_connection_helper_unlink(&h, write_resampler, 0, 0); } ms_connection_helper_unlink(&h, ms_tester_soundwrite, 0, -1); if (need_read_resampler == TRUE) { ms_tester_destroy_filter(&read_resampler); } if (need_write_resampler == TRUE) { ms_tester_destroy_filter(&write_resampler); } ms_filter_log_statistics(); ms_tester_destroy_filters(filter_mask); ms_tester_destroy_ticker(); }
void audio_stream_stop(AudioStream * stream) { if (stream->ticker){ MSConnectionHelper h; #ifdef ENABLE_UDT if (stream->udt) ms_ticker_detach (stream->ticker, stream->udt); #endif // ENABLE_UDT ms_ticker_detach(stream->ticker,stream->soundread); ms_ticker_detach(stream->ticker,stream->rtprecv); rtp_stats_display(rtp_session_get_stats(stream->session),"Audio session's RTP statistics"); /*dismantle the outgoing graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->soundread,-1,0); if (stream->read_resampler!=NULL) ms_connection_helper_unlink(&h,stream->read_resampler,0,0); #ifndef ENABLED_MCU_MEDIA_SERVER if (stream->ec!=NULL) ms_connection_helper_unlink(&h,stream->ec,1,1); if (stream->volsend!=NULL) ms_connection_helper_unlink(&h,stream->volsend,0,0); #endif // ENABLED_MCU_MEDIA_SERVER if (stream->dtmfgen_rtp) ms_connection_helper_unlink(&h,stream->dtmfgen_rtp,0,0); ms_connection_helper_unlink(&h,stream->encoder,0,0); ms_connection_helper_unlink(&h,stream->rtpsend,0,-1); /*dismantle the receiving graph*/ ms_connection_helper_start(&h); ms_connection_helper_unlink(&h,stream->rtprecv,-1,0); ms_connection_helper_unlink(&h,stream->decoder,0,0); ms_connection_helper_unlink(&h,stream->dtmfgen,0,0); #ifndef ENABLED_MCU_MEDIA_SERVER if (stream->equalizer) ms_connection_helper_unlink(&h,stream->equalizer,0,0); if (stream->volrecv!=NULL) ms_connection_helper_unlink(&h,stream->volrecv,0,0); if (stream->ec!=NULL) ms_connection_helper_unlink(&h,stream->ec,0,0); #endif // ENABLED_MCU_MEDIA_SERVER if (stream->write_resampler!=NULL) ms_connection_helper_unlink(&h,stream->write_resampler,0,0); if(stream->mic_tee && stream->recordmixer) ms_filter_unlink(stream->spk_tee,1,stream->recordmixer,1); if(stream->spk_tee) ms_connection_helper_unlink(&h,stream->spk_tee,0,0); if (stream->tee2){ ms_connection_helper_unlink(&h,stream->tee2,0,0); if(stream->audio_record) ms_filter_unlink(stream->tee2,1,stream->audio_record,0); } ms_connection_helper_unlink(&h,stream->soundwrite,0,-1); } audio_stream_free(stream); }