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 cut_audio_stream_graph(MSAudioEndpoint *ep, bool_t is_remote){ AudioStream *st=ep->st; /*stop the audio graph*/ ms_ticker_detach(st->ms.ticker,st->soundread); if (!st->ec) ms_ticker_detach(st->ms.ticker,st->soundwrite); ep->in_cut_point_prev.pin=0; if (is_remote){ /*we would like to keep the volrecv (MSVolume filter) in the graph to measure the output level*/ ep->in_cut_point_prev.filter=st->volrecv; }else{ ep->in_cut_point_prev.filter=st->ms.decoder; } ep->in_cut_point=just_after(ep->in_cut_point_prev.filter); ms_filter_unlink(ep->in_cut_point_prev.filter,ep->in_cut_point_prev.pin,ep->in_cut_point.filter, ep->in_cut_point.pin); ep->out_cut_point=just_before(st->ms.encoder); ms_filter_unlink(ep->out_cut_point.filter,ep->out_cut_point.pin,st->ms.encoder,0); ms_filter_call_method(st->ms.rtpsend,MS_FILTER_GET_SAMPLE_RATE,&ep->samplerate); if (is_remote){ ep->mixer_in.filter=ep->in_cut_point_prev.filter; ep->mixer_in.pin=ep->in_cut_point_prev.pin; ep->mixer_out.filter=st->ms.encoder; ep->mixer_out.pin=0; }else{ ep->mixer_in=ep->out_cut_point; ep->mixer_out=ep->in_cut_point; } }
void video_stream_change_camera(VideoStream *stream, MSWebCam *cam){ if (stream->ticker && stream->source){ #ifdef ENABLE_UDT if (stream->udt) ms_ticker_detach (stream->ticker, stream->udt); #endif // ENABLE_UDT ms_ticker_detach(stream->ticker,stream->source); /*unlink source filters and subsequent post processin filters */ 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); /*destroy the filters */ ms_filter_destroy(stream->source); ms_filter_destroy(stream->pixconv); ms_filter_destroy(stream->sizeconv); /*re create new ones and configure them*/ stream->source = ms_web_cam_create_reader(cam); configure_video_source(stream); ms_filter_link (stream->source, 0, stream->pixconv, 0); ms_filter_link (stream->pixconv, 0, stream->sizeconv, 0); ms_filter_link (stream->sizeconv, 0, stream->tee, 0); ms_ticker_attach(stream->ticker,stream->source); } }
static void ecc_deinit_filters(EcCalibrator *ecc) { if (ecc->audio_uninit_cb != NULL) { (*ecc->audio_uninit_cb)(ecc->cb_data); } ms_ticker_detach(ecc->ticker,ecc->sndread); ms_ticker_detach(ecc->ticker,ecc->play); ms_filter_unlink(ecc->play,0,ecc->gen,0); ms_filter_unlink(ecc->gen,0,ecc->write_resampler,0); ms_filter_unlink(ecc->write_resampler,0,ecc->sndwrite,0); ms_filter_unlink(ecc->sndread,0,ecc->read_resampler,0); ms_filter_unlink(ecc->read_resampler,0,ecc->det,0); ms_filter_unlink(ecc->det,0,ecc->rec,0); ms_filter_destroy(ecc->sndread); ms_filter_destroy(ecc->det); ms_filter_destroy(ecc->rec); ms_filter_destroy(ecc->play); ms_filter_destroy(ecc->gen); ms_filter_destroy(ecc->read_resampler); ms_filter_destroy(ecc->write_resampler); ms_filter_destroy(ecc->sndwrite); ms_ticker_destroy(ecc->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); }
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 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 local_sound_card_stop(ConfSoundCard *sndcard) { if (sndcard->ticker){ ms_ticker_detach(sndcard->ticker,sndcard->capture_card); ms_ticker_detach(sndcard->ticker,sndcard->itc_source); ms_filter_unlink(sndcard->capture_card,0,sndcard->itc_sink,0); ms_filter_unlink(sndcard->itc_source,0,sndcard->playback_card,0); } snd_card_free(sndcard); }
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->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); }
void VodWnd::stop_vod() { if (ticker_) { char opt[128]; snprintf(opt, sizeof(opt), "sinkid=%d", sinkid_); zk_xmpp_uac_send_cmd(uac_, mcu_jid_.c_str(), "test.fc.del_sink", opt, 0, 0); ms_ticker_detach(ticker_, filter_rtp_); ms_filter_destroy(filter_rtp_); filter_rtp_ = 0; ms_filter_destroy(filter_decoder_); filter_decoder_ = 0; ms_filter_destroy(filter_sink_); filter_sink_ = 0; rtp_session_destroy(rtp_); rtp_ = 0; ortp_ev_queue_destroy(evq_); evq_ = 0; ms_ticker_destroy(ticker_); ticker_ = 0; if (render_) { rv_close(render_); render_ = 0; } } }
static void stop_preload_graph(TextStream *stream){ ms_ticker_detach(stream->ms.sessions.ticker, stream->ms.rtprecv); ms_filter_unlink(stream->ms.rtprecv, 0, stream->ms.voidsink, 0); ms_filter_destroy(stream->ms.voidsink); ms_filter_destroy(stream->ms.rtprecv); stream->ms.voidsink = stream->ms.rtprecv = NULL; }
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(); }
static void stop_preload_graph(VideoStream *stream){ ms_ticker_detach(stream->ticker,stream->rtprecv); ms_filter_unlink(stream->rtprecv,0,stream->voidsink,0); ms_filter_destroy(stream->voidsink); ms_filter_destroy(stream->rtprecv); stream->voidsink=stream->rtprecv=NULL; }
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 multicast_video_stream(void) { video_stream_tester_t* marielle=video_stream_tester_new(); video_stream_tester_t* margaux=video_stream_tester_new(); bool_t supported = ms_filter_codec_supported("vp8"); video_stream_tester_set_local_ip(marielle,"224.1.2.3"); marielle->local_rtcp=0; /*no rtcp*/ video_stream_tester_set_local_ip(margaux,"0.0.0.0"); if (supported) { int dummy=0; init_video_streams(marielle, margaux, FALSE, TRUE, NULL,VP8_PAYLOAD_TYPE); CU_ASSERT_TRUE(wait_for_until_with_parse_events(&marielle->vs->ms, &margaux->vs->ms, &margaux->stats.number_of_SR, 2, 15000, event_queue_cb, &marielle->stats, event_queue_cb, &margaux->stats)); ms_ticker_detach(margaux->vs->ms.sessions.ticker,margaux->vs->source); /*to stop sending*/ /*make sure packets can cross from sender to receiver*/ wait_for_until(&marielle->vs->ms,&margaux->vs->ms,&dummy,1,500); video_stream_get_local_rtp_stats(marielle->vs, &marielle->stats.rtp); video_stream_get_local_rtp_stats(margaux->vs, &marielle->stats.rtp); CU_ASSERT_EQUAL(margaux->stats.rtp.sent,marielle->stats.rtp.recv); uninit_video_streams(marielle, margaux); } else { ms_error("VP8 codec is not supported!"); } video_stream_tester_destroy(marielle); video_stream_tester_destroy(margaux); }
int main(int argc, char *argv[]){ MSFilter *f1,*f2; MSSndCard *card; MSTicker *ticker; char *card_id=NULL; ms_init(); signal(SIGINT,stop); if (argc>1) card_id=argv[1]; if (card_id!=NULL) card=ms_snd_card_manager_get_card(ms_snd_card_manager_get(),card_id); else card=ms_snd_card_manager_get_default_card(ms_snd_card_manager_get()); if (card==NULL){ ms_error("No card."); return -1; } f1=ms_snd_card_create_reader(card); f2=ms_snd_card_create_writer(card); ticker=ms_ticker_new(); ms_filter_link(f1,0,f2,0); ms_ticker_attach(ticker,f1); while(run) sleep(1); ms_ticker_detach(ticker,f1); ms_ticker_destroy(ticker); ms_filter_unlink(f1,0,f2,0); ms_filter_destroy(f1); ms_filter_destroy(f2); return 0; }
void ms_audio_conference_remove_member(MSAudioConference *obj, MSAudioEndpoint *ep){ ms_ticker_detach(obj->ticker,obj->mixer); unplumb_from_conf(ep); ep->conference=NULL; obj->nmembers--; if (obj->nmembers>0) ms_ticker_attach(obj->ticker,obj->mixer); }
void video_preview_stop(VideoStream *stream){ ms_ticker_detach(stream->ticker, stream->source); ms_filter_unlink(stream->source,0,stream->pixconv,0); ms_filter_unlink(stream->pixconv,0,stream->output,0); video_stream_free(stream); }
static void stop_preload_graph(VideoStream *stream){ ms_ticker_detach(stream->ms.ticker,stream->ms.rtprecv); ms_filter_unlink(stream->ms.rtprecv,0,stream->ms.voidsink,0); ms_filter_destroy(stream->ms.voidsink); ms_filter_destroy(stream->ms.rtprecv); stream->ms.voidsink=stream->ms.rtprecv=NULL; stream->prepare_ongoing = FALSE; }
void ms_audio_conference_add_member(MSAudioConference *obj, MSAudioEndpoint *ep){ /* now connect to the mixer */ ep->conference=obj; if (obj->nmembers>0) ms_ticker_detach(obj->ticker,obj->mixer); plumb_to_conf(ep); ms_ticker_attach(obj->ticker,obj->mixer); obj->nmembers++; }
void ring_stop(RingStream *stream){ ms_ticker_detach(stream->ticker,stream->source); ms_filter_unlink(stream->source,0,stream->sndwrite,0); ms_ticker_destroy(stream->ticker); ms_filter_destroy(stream->source); ms_filter_destroy(stream->sndwrite); ms_free(stream); }
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(); }
void video_stream_recv_only_stop (VideoStream * stream){ if (stream->ticker!=NULL){ ms_ticker_detach(stream->ticker, stream->rtprecv); rtp_stats_display(rtp_session_get_stats(stream->session),"Video session's RTP statistics"); ms_filter_unlink(stream->rtprecv, 0, stream->decoder, 0); ms_filter_unlink(stream->decoder,0,stream->output,0); } 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 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; } }
void video_stream_send_only_stop(VideoStream *stream){ if (stream->ticker){ ms_ticker_detach (stream->ticker, 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->encoder, 0); ms_filter_unlink(stream->encoder,0,stream->rtpsend,0); } video_stream_free(stream); }
void ring_stop(RingStream *stream){ ms_ticker_detach(stream->ticker,stream->source); ms_filter_unlink(stream->source,0,stream->sndwrite,0); ms_ticker_destroy(stream->ticker); ms_filter_destroy(stream->source); 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 }
static void ecc_deinit_filters(EcCalibrator *ecc){ ms_ticker_detach(ecc->ticker,ecc->play); ms_ticker_detach(ecc->ticker,ecc->sndread); ms_filter_unlink(ecc->play,0,ecc->gen,0); ms_filter_unlink(ecc->gen,0,ecc->resampler,0); ms_filter_unlink(ecc->resampler,0,ecc->sndwrite,0); ms_filter_unlink(ecc->sndread,0,ecc->det,0); ms_filter_unlink(ecc->det,0,ecc->rec,0); ms_filter_destroy(ecc->sndread); ms_filter_destroy(ecc->det); ms_filter_destroy(ecc->rec); ms_filter_destroy(ecc->play); ms_filter_destroy(ecc->gen); ms_filter_destroy(ecc->resampler); ms_filter_destroy(ecc->sndwrite); ms_ticker_destroy(ecc->ticker); }
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); }