190 likes | 509 Views
linphone-1.5.1 - mediastreamer2. Speaker : C hungyi Wang Adviser : Quincy Wu Date : 2007/1/8. outline. 安è£éŽç¨‹ mediastreamer2 linphone – æµç¨‹ msfilter. 安è£éŽç¨‹ (1/2). perl-XML-Parser perl-XML-Parser-2.34-6.1.2.2.1.i386.rpm speex-devel speex-devel-1.2-0.1.beta1.fc6.i386.rpm libosip
E N D
linphone-1.5.1- mediastreamer2 Speaker:Chungyi WangAdviser : Quincy Wu Date : 2007/1/8
outline • 安裝過程 • mediastreamer2 • linphone – 流程 • msfilter
安裝過程(1/2) • perl-XML-Parser • perl-XML-Parser-2.34-6.1.2.2.1.i386.rpm • speex-devel • speex-devel-1.2-0.1.beta1.fc6.i386.rpm • libosip • libosip2-2.2.2.tar.gz • ./configure • make • make install
安裝過程(2/2) • linphone-1.5.1 • ./configure –disable-video • make • make install • >> linphone • http://studentweb.ncnu.edu.tw/95321518/ncnu/file/linphone_full_fc6_i386.tar.gz
mediastreamer2 • Read/Write from to an alsa device, an oss device, a windows waveapi device • Send and receive RTP packets • Encode and decode the following formats: speex, G711, GSM, H263, theora. • Read and write from/to a wav file • Dual tones generation • Echo cancelation, using the extraordinary echo canceler algorithm from the speex library from:http://www.linphone.org/index.php/v2/code_review/mediastreamer2
mediastreamer2 • Mediastreamer2 can be extended with dynamic plugins. • 這個動作主要來自於MSFilter • write/read device • encode/decode • rtp_send/rtp_recv • video_play/cam_rec
mediastreamer2 – ring.c #include "mediastreamer2/mssndcard.h“ • MSSndCard • 取得系統預設的音效卡裝置ms_snd_card_manager_get_default_card(ms_snd_card_manager_get()) • 指定音效卡裝置ms_snd_card_manager_get_card(ms_snd_card_manager_get(),card_id)
mediastreamer2 – ring.c • #include "mediastreamer2/mediastream.h“ • RingStream • sc=ms_snd_card_manager_get_default_card(ms_snd_card_manager_get()); • ring_start(…) • ring_stop(…)
mediastreamer2 – ring.c • 使用mediastreamer2可以簡單的就播放wav檔案 • demo
linphone – 流程 • 當signaling之後,兩方正式建立通話,其流程如下: • linphone_core_start_media_streams • audiostream=audio_stream_start_with_sndcardsaudiostream=audio_stream_start_with_files • audio_stream_start_full • ms_filter_call_method • 設定device,rtp,codec
linphone – 流程 • ms_filter_link • 連結資料 • send:device array -> codeccodec -> rtp_send • recv:rtp_send -> codeccodec -> device array • AudioStream->ticker=ms_ticker_new • 新執行緒,進入重複執行的迴圈
linphone – 流程 • 將ticker與MSFilter連接 • ms_ticker_attach • 當結束通話時,釋放以及停止執行緒 • ms_ticker_disattach
MSFilter • 由ticker統一執行 *_process(msfilter *f, …)動作 • 依據MSFilterId執行不同動作 • 使用結構,但是類似 ”繼承” 的動作,所以充分的使用 ”指標函式” 的功能;一旦符合函式輸入輸出即可指到相對應的函式 • 使用”指標函式”(不同MSFilter)的原因 • 不同裝置 • alsa oss winsnd • 不同codec • alaw ulaw speex theora gsm • 不同傳送方式 • rtp (目前僅有msrtp,也就是套用oRTP的函式庫)
MSFilter • write/read device • alsa.c oss.c winsnd.c • encode/decode • alaw.c ulaw.c speex.c theora.c gsm.c … • rtp_send/rtp_recv • msrtp.c
MSFilter • allfilters.h • typedef enum MSFilterId{ • MS_FILTER_NOT_SET_ID, • MS_FILTER_PLUGIN_ID, /* no type checking will be performed on plugins */ • MS_FILTER_BASE_ID, • MS_ALSA_READ_ID, • MS_ALSA_WRITE_ID, • MS_OSS_READ_ID, • MS_OSS_WRITE_ID, • MS_ULAW_ENC_ID, • MS_ULAW_DEC_ID, • MS_ALAW_ENC_ID, • MS_ALAW_DEC_ID, • MS_RTP_SEND_ID, • MS_RTP_RECV_ID, • MS_FILE_PLAYER_ID, • MS_FILE_REC_ID, • MS_DTMF_GEN_ID, • MS_SPEEX_ENC_ID, • MS_SPEEX_DEC_ID, • MS_GSM_ENC_ID, • MS_GSM_DEC_ID,
MSFilter • MS_GSM_ENC_ID, • MS_GSM_DEC_ID, • MS_V4L_ID, • MS_SDL_OUT_ID, • MS_H263_ENC_ID, • MS_H263_DEC_ID, • MS_ARTS_READ_ID, • MS_ARTS_WRITE_ID, • MS_WINSND_READ_ID, • MS_WINSND_WRITE_ID, • MS_SPEEX_EC_ID, • MS_PIX_CONV_ID, • MS_TEE_ID, • MS_SIZE_CONV_ID, • MS_CONF_ID, • MS_THEORA_ENC_ID, • MS_THEORA_DEC_ID, • MS_PASND_READ_ID, • MS_PASND_WRITE_ID, • MS_MPEG4_ENC_ID, • MS_MPEG4_DEC_ID, • MS_MJPEG_DEC_ID • } MSFilterId;
MSFilter – ulaw.c • static void ulaw_enc_process(MSFilter *obj) { //變數宣告… //參數設定,好比說buffer … • //讀取裝置內的資料,透過msfilter裡面的data (存在bz中) //該data則是由另一個msfilter處理 while(ms_bufferizer_read(bz,buffer,size_of_pcm) ==size_of_pcm) { //做encode的動作,且呼叫g711common.h的函式for( … ) … //餵資料到傳送資料的msfilter中ms_queue_put(obj->outputs[0],o); }}
MSFilter – msrtp.c • static void sender_process(MSFilter * f) { //變數宣告… //參數設定,好比說… //產生DTMF的判定if (d->dtmf != 0) { //DTFM的音訊傳送… } …
//通話傳送 else{ if (d->mute_mic==FALSE) { //傳送的標頭設定以及其他參數設定… //實際傳送的動作//這邊就是實際使用oRTP lib的部分 rtp_session_sendm_with_ts(s, header, timestamp); } … } … }