void lsd_player_enable_loop(LsdPlayer *p, bool_t loopmode){ if (ms_filter_get_id(p->player)==MS_FILE_PLAYER_ID){ int arg=loopmode ? 0 : -1; ms_filter_call_method(p->player,MS_FILE_PLAYER_LOOP,&arg); p->loop=loopmode; } }
static void configure_video_source(VideoStream *stream){ MSVideoSize vsize,cam_vsize; float fps=15; MSPixFmt format; ms_filter_call_method(stream->encoder,MS_FILTER_GET_VIDEO_SIZE,&vsize); vsize=ms_video_size_min(vsize,stream->sent_vsize); ms_filter_call_method(stream->encoder,MS_FILTER_SET_VIDEO_SIZE,&stream->sent_vsize); ms_filter_call_method(stream->encoder,MS_FILTER_GET_FPS,&fps); ms_message("Setting sent vsize=%ix%i, fps=%f",vsize.width,vsize.height,fps); /* configure the filters */ if (ms_filter_get_id(stream->source)!=MS_STATIC_IMAGE_ID) { ms_filter_call_method(stream->source,MS_FILTER_SET_FPS,&fps); } ms_filter_call_method(stream->source,MS_FILTER_SET_VIDEO_SIZE,&vsize); /* get the output format for webcam reader */ ms_filter_call_method(stream->source,MS_FILTER_GET_PIX_FMT,&format); if (format==MS_MJPEG){ stream->pixconv=ms_filter_new(MS_MJPEG_DEC_ID); }else{ stream->pixconv = ms_filter_new(MS_PIX_CONV_ID); /*set it to the pixconv */ ms_filter_call_method(stream->pixconv,MS_FILTER_SET_PIX_FMT,&format); ms_filter_call_method(stream->source,MS_FILTER_GET_VIDEO_SIZE,&cam_vsize); ms_filter_call_method(stream->pixconv,MS_FILTER_SET_VIDEO_SIZE,&cam_vsize); } stream->sizeconv=ms_filter_new(MS_SIZE_CONV_ID); ms_filter_call_method(stream->sizeconv,MS_FILTER_SET_VIDEO_SIZE,&stream->sent_vsize); }
void audio_stream_record_start(AudioStream *st, const char *filename){ if (st->filewriter != NULL && ms_filter_get_id(st->filewriter)==MS_FILE_REC_ID){ ms_filter_call_method_noarg(st->filewriter,MS_FILE_REC_CLOSE); ms_filter_call_method(st->filewriter,MS_FILE_REC_OPEN,(void*)filename); ms_filter_call_method_noarg(st->filewriter,MS_FILE_REC_START); }else{ ms_error("Cannot record file: no st->filewriter Filter !"); } }
void audio_stream_record_stop(AudioStream *st) { if (st->filewriter != NULL && ms_filter_get_id(st->filewriter)==MS_FILE_REC_ID){ ms_filter_call_method_noarg(st->filewriter,MS_FILE_REC_STOP); ms_filter_call_method_noarg(st->filewriter,MS_FILE_REC_CLOSE); }else{ ms_error("Cannot stop record !"); } }
void audio_stream_play(AudioStream *st, const char *name){ if (ms_filter_get_id(st->soundread)==MS_FILE_PLAYER_ID){ ms_filter_call_method_noarg(st->soundread,MS_FILE_PLAYER_CLOSE); ms_filter_call_method(st->soundread,MS_FILE_PLAYER_OPEN,(void*)name); ms_filter_call_method_noarg(st->soundread,MS_FILE_PLAYER_START); }else{ ms_error("Cannot play file: the stream hasn't been started with" " audio_stream_start_with_files"); } }
void video_stream_play_file_stop(VideoStream *st) { if (ms_filter_get_id(st->source)==MS_VIDEO_FILE_PLAYER_ID){ ms_filter_call_method_noarg(st->source,MS_VIDEO_FILE_PLAYER_STOP); ms_filter_call_method_noarg(st->source,MS_VIDEO_FILE_PLAYER_CLOSE); }else{ ms_error("Cannot play file: the stream hasn't been started with" " video_stream_play"); } }
void audio_stream_record(AudioStream *st, const char *name){ if (ms_filter_get_id(st->soundwrite)==MS_FILE_REC_ID){ ms_filter_call_method_noarg(st->soundwrite,MS_FILE_REC_CLOSE); ms_filter_call_method(st->soundwrite,MS_FILE_REC_OPEN,(void*)name); ms_filter_call_method_noarg(st->soundwrite,MS_FILE_REC_START); }else{ ms_error("Cannot record file: the stream hasn't been started with" " audio_stream_start_with_files"); } }
void video_stream_play_file(VideoStream *st, const char *name) { if (ms_filter_get_id(st->source)==MS_VIDEO_FILE_PLAYER_ID){ ms_filter_call_method_noarg(st->source,MS_VIDEO_FILE_PLAYER_CLOSE); ms_filter_call_method(st->source,MS_VIDEO_FILE_PLAYER_OPEN,(void*)name); ms_filter_call_method_noarg(st->source,MS_VIDEO_FILE_PLAYER_START); }else{ ms_error("Cannot play file: the stream hasn't been started with" " video_stream_play"); } }
void linphone_conference_play_audio_stop(struct _LinphoneCore *lc, LinphoneConference *conf){ LinphoneConferenceStream *conf_stream = conf->conf_stream; if(conf==NULL && conf_stream==NULL) return; if (conf_stream->audio_fileplayer != NULL && ms_filter_get_id(conf_stream->audio_fileplayer)==MS_FILE_PLAYER_ID){ ms_filter_call_method_noarg(conf_stream->audio_fileplayer,MS_FILE_PLAYER_STOP); ms_filter_call_method_noarg(conf_stream->audio_fileplayer,MS_FILE_PLAYER_CLOSE); }else{ ms_error("Cannot record file: not inited conf->audio_fileplayer Filter !"); } }
void linphone_conference_record_audio_stop(struct _LinphoneCore *lc, LinphoneConference *conf){ LinphoneConferenceStream *conf_stream = conf->conf_stream; if(conf==NULL && conf_stream==NULL) return; if (conf_stream->audio_filerecorder != NULL && ms_filter_get_id(conf_stream->audio_filerecorder)==MS_FILE_REC_ID){ ms_filter_call_method_noarg(conf_stream->audio_filerecorder,MS_FILE_REC_STOP); ms_filter_call_method_noarg(conf_stream->audio_filerecorder,MS_FILE_REC_CLOSE); }else{ ms_error("Cannot stop conference record !"); } }
//录制当前会议 void linphone_conference_record_audio(struct _LinphoneCore *lc, LinphoneConference *conf, const char *filename){ LinphoneConferenceStream *conf_stream = conf->conf_stream; if(conf==NULL && conf_stream==NULL) return; if (conf_stream->audio_filerecorder != NULL && ms_filter_get_id(conf_stream->audio_filerecorder)==MS_FILE_REC_ID){ ms_filter_call_method_noarg(conf_stream->audio_filerecorder,MS_FILE_REC_CLOSE); ms_filter_call_method(conf_stream->audio_filerecorder,MS_FILE_REC_OPEN,(void*)filename); ms_filter_call_method_noarg(conf_stream->audio_filerecorder,MS_FILE_REC_START); }else{ ms_error("Cannot record file: not conf->audio_filerecorder st->filewrite Filter !"); } }
int local_webcam_start(ConfWebCam *localcam,MSWebCam *device,MSVideoSize vsize,float fps){ MSPixFmt format=MS_YUV420P; if(!device) return -1; if(fps<=0) fps=15; if (device==NULL){ device=ms_web_cam_manager_get_default_cam ( ms_web_cam_manager_get()); } localcam->webcam = ms_web_cam_create_reader(device); ms_message("Setting sent vsize=%ix%i, fps=%f",vsize.width,vsize.height,fps); /* configure the filters */ if (ms_filter_get_id(localcam->webcam)!=MS_STATIC_IMAGE_ID) { ms_filter_call_method(localcam->webcam,MS_FILTER_SET_FPS,&fps); } ms_filter_call_method(localcam->webcam,MS_FILTER_SET_VIDEO_SIZE,&vsize); /* get the output format for webcam reader */ ms_filter_call_method(localcam->webcam,MS_FILTER_GET_PIX_FMT,&format); if (format==MS_MJPEG){ localcam->pixconv=ms_filter_new(MS_MJPEG_DEC_ID); }else{ localcam->pixconv = ms_filter_new(MS_PIX_CONV_ID); /*set it to the pixconv */ ms_filter_call_method(localcam->pixconv,MS_FILTER_SET_PIX_FMT,&format); ms_filter_call_method(localcam->webcam,MS_FILTER_GET_VIDEO_SIZE,&vsize); ms_filter_call_method(localcam->pixconv,MS_FILTER_SET_VIDEO_SIZE,&vsize); } localcam->sizeconv=ms_filter_new(MS_SIZE_CONV_ID); ms_filter_call_method(localcam->sizeconv,MS_FILTER_SET_VIDEO_SIZE,&vsize); localcam->itc_sink = ms_filter_new(MS_CONF_ITC_SINK_ID); ms_filter_link(localcam->webcam,0,localcam->pixconv,0); ms_filter_link(localcam->pixconv,0,localcam->sizeconv,0); ms_filter_link(localcam->sizeconv,0,localcam->itc_sink,0); localcam->ticker = ms_ticker_new(); ms_ticker_set_name(localcam->ticker,"Local Camera MSTicker"); ms_ticker_attach(localcam->ticker,localcam->webcam); return 0; }
void video_preview_start(VideoPreview *stream, MSWebCam *device){ MSPixFmt format; float fps=(float)29.97; int mirroring=1; int corner=-1; MSVideoSize disp_size=stream->sent_vsize; MSVideoSize vsize=disp_size; const char *displaytype=stream->display_name; stream->source = ms_web_cam_create_reader(device); /* configure the filters */ ms_filter_call_method(stream->source,MS_FILTER_SET_VIDEO_SIZE,&vsize); if (ms_filter_get_id(stream->source)!=MS_STATIC_IMAGE_ID) ms_filter_call_method(stream->source,MS_FILTER_SET_FPS,&fps); ms_filter_call_method(stream->source,MS_FILTER_GET_PIX_FMT,&format); ms_filter_call_method(stream->source,MS_FILTER_GET_VIDEO_SIZE,&vsize); if (format==MS_MJPEG){ stream->pixconv=ms_filter_new(MS_MJPEG_DEC_ID); }else{ stream->pixconv=ms_filter_new(MS_PIX_CONV_ID); ms_filter_call_method(stream->pixconv,MS_FILTER_SET_PIX_FMT,&format); ms_filter_call_method(stream->pixconv,MS_FILTER_SET_VIDEO_SIZE,&vsize); } format=MS_YUV420P; stream->output2=ms_filter_new_from_name (displaytype); ms_filter_call_method(stream->output2,MS_FILTER_SET_PIX_FMT,&format); ms_filter_call_method(stream->output2,MS_FILTER_SET_VIDEO_SIZE,&disp_size); ms_filter_call_method(stream->output2,MS_VIDEO_DISPLAY_ENABLE_MIRRORING,&mirroring); ms_filter_call_method(stream->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner); /* and then connect all */ ms_filter_link(stream->source,0, stream->pixconv,0); ms_filter_link(stream->pixconv, 0, stream->output2, 0); if (stream->preview_window_id!=0){ video_stream_set_native_preview_window_id(stream, stream->preview_window_id); } /* create the ticker */ stream->ms.ticker = ms_ticker_new(); ms_ticker_set_name(stream->ms.ticker,"Video MSTicker"); ms_ticker_attach (stream->ms.ticker, stream->source); }
// Pass NULL to stop playing void audio_stream_play(AudioStream *st, const char *name){ if (st->soundread == NULL) { ms_warning("Cannot play file: the stream hasn't been started"); return; } if (ms_filter_get_id(st->soundread)==MS_FILE_PLAYER_ID){ ms_filter_call_method_noarg(st->soundread,MS_FILE_PLAYER_CLOSE); if (name != NULL) { ms_filter_call_method(st->soundread,MS_FILE_PLAYER_OPEN,(void*)name); if (st->read_resampler){ audio_stream_configure_resampler(st->read_resampler,st->soundread,st->ms.rtpsend); } ms_filter_call_method_noarg(st->soundread,MS_FILE_PLAYER_START); } }else{ ms_error("Cannot play file: the stream hasn't been started with" " audio_stream_start_with_files"); } }
static void lsd_player_configure(LsdPlayer *b){ int rate,chans; LinphoneSoundDaemon *lsd=b->lsd; if (ms_filter_get_id(b->player)==MS_ITC_SOURCE_ID) ms_message("Configuring branch coming from audio call..."); ms_filter_call_method(b->player,MS_FILTER_GET_SAMPLE_RATE,&rate); ms_filter_call_method(b->player,MS_FILTER_GET_NCHANNELS,&chans); ms_filter_call_method(b->rateconv,MS_FILTER_SET_SAMPLE_RATE,&rate); ms_filter_call_method(b->rateconv,MS_FILTER_SET_NCHANNELS,&chans); ms_filter_call_method(b->rateconv,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&lsd->out_rate); ms_filter_call_method(b->chanadapter,MS_FILTER_SET_NCHANNELS,&chans); ms_filter_call_method(b->chanadapter,MS_CHANNEL_ADAPTER_SET_OUTPUT_NCHANNELS,&lsd->out_nchans); ms_message("player configured for rate=%i, channels=%i",rate,chans); }
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 configure_video_source(VideoStream *stream){ MSVideoSize vsize,cam_vsize; float fps=15; MSPixFmt format; bool_t encoder_has_builtin_converter = FALSE; /* transmit orientation to source filter */ ms_filter_call_method(stream->source,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&stream->device_orientation); /* transmit its preview window id if any to source filter*/ if (stream->preview_window_id!=0){ video_stream_set_native_preview_window_id(stream, stream->preview_window_id); } ms_filter_call_method(stream->ms.encoder, MS_VIDEO_ENCODER_HAS_BUILTIN_CONVERTER, &encoder_has_builtin_converter); ms_filter_call_method(stream->ms.encoder,MS_FILTER_GET_VIDEO_SIZE,&vsize); vsize=get_compatible_size(vsize,stream->sent_vsize); ms_filter_call_method(stream->source,MS_FILTER_SET_VIDEO_SIZE,&vsize); /*the camera may not support the target size and suggest a one close to the target */ ms_filter_call_method(stream->source,MS_FILTER_GET_VIDEO_SIZE,&cam_vsize); if (cam_vsize.width*cam_vsize.height<=vsize.width*vsize.height && cam_vsize.width != vsize.width){ vsize=cam_vsize; ms_message("Output video size adjusted to match camera resolution (%ix%i)\n",vsize.width,vsize.height); } else if (cam_vsize.width*cam_vsize.height>vsize.width*vsize.height){ #if TARGET_IPHONE_SIMULATOR || defined(__arm__) ms_error("Camera is proposing a size bigger than encoder's suggested size (%ix%i > %ix%i) " "Using the camera size as fallback because cropping or resizing is not implemented for arm.", cam_vsize.width,cam_vsize.height,vsize.width,vsize.height); vsize=cam_vsize; #else vsize=get_with_same_orientation(vsize,cam_vsize); ms_warning("Camera video size greater than encoder one. A scaling filter will be used!\n"); #endif } ms_filter_call_method(stream->ms.encoder,MS_FILTER_SET_VIDEO_SIZE,&vsize); ms_filter_call_method(stream->ms.encoder,MS_FILTER_GET_FPS,&fps); ms_message("Setting sent vsize=%ix%i, fps=%f",vsize.width,vsize.height,fps); /* configure the filters */ if (ms_filter_get_id(stream->source)!=MS_STATIC_IMAGE_ID) { ms_filter_call_method(stream->source,MS_FILTER_SET_FPS,&fps); } /* get the output format for webcam reader */ ms_filter_call_method(stream->source,MS_FILTER_GET_PIX_FMT,&format); if ((encoder_has_builtin_converter == TRUE) || (stream->source_performs_encoding == TRUE)) { ms_filter_call_method(stream->ms.encoder, MS_FILTER_SET_PIX_FMT, &format); } else { if (format==MS_MJPEG){ stream->pixconv=ms_filter_new(MS_MJPEG_DEC_ID); }else{ stream->pixconv = ms_filter_new(MS_PIX_CONV_ID); /*set it to the pixconv */ ms_filter_call_method(stream->pixconv,MS_FILTER_SET_PIX_FMT,&format); ms_filter_call_method(stream->pixconv,MS_FILTER_SET_VIDEO_SIZE,&cam_vsize); } stream->sizeconv=ms_filter_new(MS_SIZE_CONV_ID); ms_filter_call_method(stream->sizeconv,MS_FILTER_SET_VIDEO_SIZE,&vsize); } if (stream->ms.rc){ ms_bitrate_controller_destroy(stream->ms.rc); stream->ms.rc=NULL; } if (stream->ms.use_rc){ stream->ms.rc=ms_av_bitrate_controller_new(NULL,NULL,stream->ms.session,stream->ms.encoder); } }
int video_mail_record_start(VideoMailRecord *vp, MSSndCard *sndcard,MSWebCam *webcam,unsigned long video_window_id,const char *filename){ MSConnectionHelper h; MSPixFmt format=MS_YUV420P; { strcpy(vp->filename, filename); vp->os = video_recoder_new(); video_recoder_init(vp->os); video_recoder_set_vsize(vp->os,vp->vsize); video_recoder_set_rate(vp->os,vp->rate); video_recoder_set_audio_bit_rate(vp->os, get_bit_rate_by_samples_rate(vp->rate)); video_recoder_set_video_bit_rate(vp->os, vp->bit_rate - get_bit_rate_by_samples_rate(vp->rate)); video_recoder_set_nbchannels(vp->os,vp->nchannels); if(video_recoder_open_file(vp->os,vp->filename)<0){ video_recoder_destory(vp->os); vp->os=NULL; return -1; } video_mail_record_set_audio_sink(vp,video_recoder_create_audio_filter(vp->os)); video_mail_record_set_video_sink(vp,video_recoder_create_video_filter(vp->os)); video_recoder_start(vp->os); } { if (sndcard!=NULL) vp->snd_read=ms_snd_card_create_reader(sndcard); if(vp->snd_read){ ms_filter_call_method(vp->snd_read,MS_FILTER_SET_NCHANNELS,&vp->nchannels); ms_filter_call_method(vp->snd_read,MS_FILTER_SET_SAMPLE_RATE,&vp->rate); } } { if (webcam==NULL){ webcam=ms_web_cam_manager_get_default_cam ( ms_web_cam_manager_get()); } vp->video_source = ms_web_cam_create_reader(webcam); vp->video_tee = ms_filter_new(MS_TEE_ID); ms_message("Setting sent vsize=%ix%i, fps=%f",vp->vsize.width,vp->vsize.height,vp->fps); /* configure the filters */ if (ms_filter_get_id(vp->video_source)!=MS_STATIC_IMAGE_ID) { ms_filter_call_method(vp->video_source,MS_FILTER_SET_FPS,&vp->fps); } ms_filter_call_method(vp->video_source,MS_FILTER_SET_VIDEO_SIZE,&vp->vsize); ms_filter_call_method(vp->video_source,MS_FILTER_GET_PIX_FMT,&format); if (format==MS_MJPEG){ vp->pixconv=ms_filter_new(MS_MJPEG_DEC_ID); }else{ vp->pixconv = ms_filter_new(MS_PIX_CONV_ID); /*set it to the pixconv */ ms_filter_call_method(vp->pixconv,MS_FILTER_SET_PIX_FMT,&format); ms_filter_call_method(vp->video_source,MS_FILTER_GET_VIDEO_SIZE,&vp->vsize); ms_filter_call_method(vp->pixconv,MS_FILTER_SET_VIDEO_SIZE,&vp->vsize); } vp->sizeconv=ms_filter_new(MS_SIZE_CONV_ID); ms_filter_call_method(vp->sizeconv,MS_FILTER_SET_VIDEO_SIZE,&vp->vsize); choose_display_name(vp); vp->video_output=ms_filter_new_from_name (vp->display_name); if (video_window_id!=0) ms_filter_call_method(vp->video_output, MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID,&video_window_id); } if(vp->snd_read!=NULL && vp->snd_sink!=NULL){ ms_filter_link(vp->snd_read,0,vp->snd_sink,0); } if(vp->video_source!=NULL && vp->video_output!=NULL) { ms_connection_helper_start(&h); ms_connection_helper_link(&h,vp->video_source,-1,0); ms_connection_helper_link(&h,vp->pixconv,0,0); ms_connection_helper_link(&h,vp->sizeconv,0,0); ms_connection_helper_link(&h,vp->video_tee,0,0); ms_filter_link(vp->video_tee,1,vp->video_output,0); ms_connection_helper_link(&h,vp->video_sink,0,-1); } vp->ticker = ms_ticker_new(); ms_ticker_set_name(vp->ticker,"VideoMailRecord"); if(vp->snd_read!=NULL && vp->snd_sink!=NULL) ms_ticker_attach(vp->ticker,vp->snd_read); if(vp->video_source!=NULL && vp->video_output!=NULL) ms_ticker_attach(vp->ticker,vp->video_source); return 0; }