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); } }
void myAudioStream::destroy_filters() { ms_message("Destroying filters"); if (stream->rtpsend != NULL) ms_filter_destroy(stream->rtpsend); if (stream->soundread != NULL) ms_filter_destroy(stream->soundread); if (stream->encoder != NULL) ms_filter_destroy(stream->encoder); }
static void test_filterdesc_enable_disable_base(const char* mime, const char* filtername,bool_t is_enc) { MSFilter *filter; ms_init(); if (is_enc) filter = ms_filter_create_encoder(mime); else filter = ms_filter_create_decoder(mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(ms_factory_get_fallback(),filtername,FALSE)); BC_ASSERT_FALSE(ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),filtername)); if (is_enc) filter = ms_filter_create_encoder(mime); else filter = ms_filter_create_decoder(mime); BC_ASSERT_PTR_NULL(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(ms_factory_get_fallback(),filtername,TRUE)); BC_ASSERT_TRUE(ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),filtername)); if (is_enc) filter = ms_filter_create_encoder(mime); else filter = ms_filter_create_decoder(mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); ms_exit(); }
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; }
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; } } }
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; }
static void test_filterdesc_enable_disable_base(const char* mime, const char* filtername,bool_t is_enc) { MSFilter *filter; MSFactory *factory = NULL; factory = ms_factory_new_with_voip(); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,FALSE)); BC_ASSERT_FALSE(ms_factory_filter_from_name_enabled(factory,filtername)); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NULL(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,TRUE)); BC_ASSERT_TRUE(ms_factory_filter_from_name_enabled(factory,filtername)); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); ms_factory_destroy(factory); }
void ms_audio_endpoint_destroy(MSAudioEndpoint *ep){ if (ep->in_resampler) ms_filter_destroy(ep->in_resampler); if (ep->out_resampler) ms_filter_destroy(ep->out_resampler); if (ep->recorder) ms_filter_destroy(ep->recorder); if (ep->player) ms_filter_destroy(ep->player); ms_free(ep); }
SinkBase::~SinkBase(void) { ms_ticker_destroy(ticker_); ms_filter_destroy(f_void_); ms_filter_destroy(f_recv_); rtp_session_destroy(rtp_); }
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 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 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 webcam_free(ConfWebCam *localcam){ if (localcam->ticker!=NULL) ms_ticker_destroy(localcam->ticker); if (localcam->webcam!=NULL) ms_filter_destroy(localcam->webcam); if (localcam->pixconv!=NULL) ms_filter_destroy(localcam->pixconv); if (localcam->sizeconv!=NULL) ms_filter_destroy(localcam->sizeconv); if (localcam->itc_sink!=NULL) ms_filter_destroy(localcam->itc_sink); ms_free(localcam); }
void video_slot_destory(ConfVideoPort *slot){ if(slot->video_itc_source!=NULL) ms_filter_destroy(slot->video_itc_source); if(slot->video_itc_sink!=NULL) ms_filter_destroy(slot->video_itc_sink); if(slot->video_input_join!=NULL) ms_filter_destroy(slot->video_input_join); ms_mutex_destroy(&slot->slotq_in.lock); ms_queue_flush (&slot->slotq_in.q); ms_mutex_destroy(&slot->slotq_out.lock); ms_queue_flush (&slot->slotq_out.q); ms_free(slot); }
void audio_slot_destory(ConfAudioPort *slot){ if(slot->audio_itc_source!=NULL) ms_filter_destroy(slot->audio_itc_source); if(slot->audio_itc_sink!=NULL) ms_filter_destroy(slot->audio_itc_sink); ms_mutex_destroy(&slot->slotq_in.lock); ms_queue_flush (&slot->slotq_in.q); ms_mutex_destroy(&slot->slotq_out.lock); ms_queue_flush (&slot->slotq_out.q); ms_free(slot); }
static void snd_card_free(ConfSoundCard *sndcard) { if (sndcard->ticker!=NULL) ms_ticker_destroy(sndcard->ticker); if (sndcard->capture_card!=NULL) ms_filter_destroy(sndcard->capture_card); if (sndcard->itc_source!=NULL) ms_filter_destroy(sndcard->itc_source); if (sndcard->playback_card!=NULL) ms_filter_destroy(sndcard->playback_card); if (sndcard->itc_sink!=NULL) ms_filter_destroy(sndcard->itc_sink); ms_free(sndcard); }
DirectorConference::~DirectorConference() { // 释放所有 sources, sinks, ... do { ost::MutexLock al(cs_graphics_); GRAPHICS::iterator it; for (it = graphics_.begin(); it != graphics_.end(); ++it) { delete *it; } graphics_.clear(); } while (0); do { ost::MutexLock al(cs_sinks_); SINKS::iterator it; for (it = sinks_.begin(); it != sinks_.end(); ++it) { del_sink(*it); delete *it; } sinks_.clear(); } while (0); do { ost::MutexLock al(cs_streams_); STREAMS::iterator it; for (it = streams_.begin(); it != streams_.end(); ++it) { del_stream(*it); delete *it; } streams_.clear(); } while (0); do { ost::MutexLock al(cs_sources_); SOURCES::iterator it; for (it = sources_.begin(); it != sources_.end(); ++it) { del_source(*it); delete *it; } sources_.clear(); } while (0); pause_audio(); pause_video(); ms_ticker_destroy(audio_ticker_); ms_ticker_destroy(video_ticker_); ms_filter_destroy(audio_resample_); ms_filter_destroy(audio_encoder_); ms_filter_destroy(audio_mixer_); ms_filter_destroy(video_mixer_); ms_filter_destroy(audio_publisher_); ms_filter_destroy(video_publisher_); ms_filter_destroy(video_tee_); if (filter_tee_) ms_filter_destroy(filter_tee_); if (filter_sink_) ms_filter_destroy(filter_sink_); }
void audio_stream_unprepare_sound(AudioStream *stream){ if (stream->dummy){ stop_preload_graph(stream); #ifdef __ios if (stream->soundread) ms_filter_destroy(stream->soundread); stream->soundread=NULL; if (stream->soundwrite) ms_filter_destroy(stream->soundwrite); stream->soundwrite=NULL; #endif } }
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 stop_preload_graph(AudioStream *stream){ ms_ticker_detach(stream->ms.ticker,stream->dummy); if (stream->soundwrite) { ms_filter_unlink(stream->dummy,0,stream->soundwrite,0); } if (stream->ms.voidsink) { ms_filter_unlink(stream->dummy,0,stream->ms.voidsink,0); ms_filter_destroy(stream->ms.voidsink); stream->ms.voidsink=NULL; } ms_filter_destroy(stream->dummy); stream->dummy=NULL; }
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 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 video_stream_free(VideoStream *stream) { /* Prevent filters from being destroyed two times */ if (stream->source_performs_encoding == TRUE) { stream->ms.encoder = NULL; } if (stream->output_performs_decoding == TRUE) { stream->ms.decoder = NULL; } media_stream_free(&stream->ms); if (stream->source != NULL) ms_filter_destroy (stream->source); if (stream->output != NULL) ms_filter_destroy (stream->output); if (stream->sizeconv != NULL) ms_filter_destroy (stream->sizeconv); if (stream->pixconv!=NULL) ms_filter_destroy(stream->pixconv); if (stream->tee!=NULL) ms_filter_destroy(stream->tee); if (stream->tee2!=NULL) ms_filter_destroy(stream->tee2); if (stream->jpegwriter!=NULL) ms_filter_destroy(stream->jpegwriter); if (stream->output2!=NULL) ms_filter_destroy(stream->output2); if (stream->display_name!=NULL) ms_free(stream->display_name); ms_free (stream); }
/* this code is not part of the library itself, it is part of the mediastream program */ void video_stream_free (VideoStream * stream) { if (stream->session!=NULL){ rtp_session_unregister_event_queue(stream->session,stream->evq); rtp_session_destroy(stream->session); } if (stream->rtprecv != NULL) ms_filter_destroy (stream->rtprecv); if (stream->rtpsend!=NULL) ms_filter_destroy (stream->rtpsend); if (stream->source != NULL) ms_filter_destroy (stream->source); if (stream->output != NULL) ms_filter_destroy (stream->output); if (stream->decoder != NULL) ms_filter_destroy (stream->decoder); if (stream->sizeconv != NULL) ms_filter_destroy (stream->sizeconv); if (stream->pixconv!=NULL) ms_filter_destroy(stream->pixconv); if (stream->tee!=NULL) ms_filter_destroy(stream->tee); if (stream->ticker != NULL) ms_ticker_destroy (stream->ticker); if (stream->evq!=NULL) ortp_ev_queue_destroy(stream->evq); ms_free (stream); }
void video_stream_change_camera(VideoStream *stream, MSWebCam *cam){ bool_t keep_source=(cam==stream->cam); bool_t encoder_has_builtin_converter = (!stream->pixconv && !stream->sizeconv); if (stream->ms.ticker && stream->source){ ms_ticker_detach(stream->ms.ticker,stream->source); /*unlink source filters and subsequent post processin filters */ if (encoder_has_builtin_converter || (stream->source_performs_encoding == TRUE)) { ms_filter_unlink(stream->source, 0, stream->tee, 0); } else { 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 */ if (!keep_source) ms_filter_destroy(stream->source); if (!encoder_has_builtin_converter && (stream->source_performs_encoding == FALSE)) { ms_filter_destroy(stream->pixconv); ms_filter_destroy(stream->sizeconv); } /*re create new ones and configure them*/ if (!keep_source) stream->source = ms_web_cam_create_reader(cam); stream->cam=cam; /* update orientation */ if (stream->source){ ms_filter_call_method(stream->source,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&stream->device_orientation); if (!stream->display_filter_auto_rotate_enabled) ms_filter_call_method(stream->source,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&stream->device_orientation); } if (stream->output && stream->display_filter_auto_rotate_enabled) { ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&stream->device_orientation); } configure_video_source(stream); if (encoder_has_builtin_converter || (stream->source_performs_encoding == TRUE)) { ms_filter_link (stream->source, 0, stream->tee, 0); } else { 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->ms.ticker,stream->source); } }
void linphone_sound_daemon_destroy(LinphoneSoundDaemon *obj){ int i; MSConnectionPoint mp; ms_ticker_detach(obj->ticker,obj->soundout); mp.filter=obj->mixer; for(i=0;i<MAX_BRANCHES;++i){ mp.pin=i; if (i!=0) linphone_sound_daemon_release_player(obj,&obj->branches[i]); lsd_player_uninit (&obj->branches[i],mp); } ms_filter_unlink(obj->mixer,0,obj->soundout,0); ms_ticker_destroy(obj->ticker); ms_filter_destroy(obj->soundout); ms_filter_destroy(obj->mixer); }
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; }
void ms_tester_destroy_filter(MSFilter **filter) { CU_ASSERT_PTR_NOT_NULL(filter); if (*filter != NULL) { ms_filter_destroy(*filter); *filter = NULL; } }
/*this function must be called from the MSTicker thread: it replaces one filter by another one. This is a dirty hack that works anyway. It would be interesting to have something that does the job simplier within the MSTicker api */ void video_stream_change_decoder(VideoStream *stream, int payload){ RtpSession *session=stream->session; RtpProfile *prof=rtp_session_get_profile(session); PayloadType *pt=rtp_profile_get_payload(prof,payload); if (pt!=NULL){ MSFilter *dec=ms_filter_create_decoder(pt->mime_type); if (dec!=NULL){ ms_filter_unlink(stream->rtprecv, 0, stream->decoder, 0); ms_filter_unlink(stream->decoder,0,stream->output,0); ms_filter_postprocess(stream->decoder); ms_filter_destroy(stream->decoder); stream->decoder=dec; if (pt->recv_fmtp!=NULL) ms_filter_call_method(stream->decoder,MS_FILTER_ADD_FMTP,(void*)pt->recv_fmtp); ms_filter_link (stream->rtprecv, 0, stream->decoder, 0); ms_filter_link (stream->decoder,0 , stream->output, 0); ms_filter_preprocess(stream->decoder,stream->ticker); }else{ ms_warning("No decoder found for %s",pt->mime_type); } }else{ ms_warning("No payload defined with number %i",payload); } }
void media_stream_free(MediaStream *stream) { if (stream->sessions.rtp_session != NULL){ rtp_session_unregister_event_queue(stream->sessions.rtp_session, stream->evq); } if (stream->owns_sessions){ ms_media_stream_sessions_uninit(&stream->sessions); } if (stream->evq) ortp_ev_queue_destroy(stream->evq); if (stream->rc != NULL) ms_bitrate_controller_destroy(stream->rc); if (stream->rtpsend != NULL) ms_filter_destroy(stream->rtpsend); if (stream->rtprecv != NULL) ms_filter_destroy(stream->rtprecv); if (stream->encoder != NULL) ms_filter_destroy(stream->encoder); if (stream->decoder != NULL) ms_filter_destroy(stream->decoder); if (stream->voidsink != NULL) ms_filter_destroy(stream->voidsink); if (stream->qi) ms_quality_indicator_destroy(stream->qi); }