1. Download SDK
a. git clone 後,大多都是空的資料夾,必需再透過cmake來下載與編譯
b. 事先安裝
cmake >= 3.6
python = 2.7 (python 3.7 if C# wrapper generation is disabled)
sudo apt-get install yasm nasm doxygen
sudo apt-get install libspeex-dev libavcodec-dev libxv-dev libx11-dev libglew-dev
sudo apt-get install libgl1-mesa-glx
sudo pip2 install Pystache six
cmake version: 3.6 or website
ref: Here
2. 下載 (感謝eric提供)
#/bin/bash
if [ $# -ne 1 ]; then
echo "使用方式:$0 user_name"
exit 0
fi
root_dir=$PWD
user=$1
dir=( bcmatroska2 bctoolbox bcunit belr bzrtp ortp belle-sip lime belcard mediastreamer2 mswebrtc liblinphone )
for dir_name in "${dir[@]}"
do
echo "https://gitlab.linphone.org/BC/public/${dir_name}.git"
repository="https://gitlab.linphone.org/BC/public/${dir_name}.git"
git clone ${repository}
done
cd $PWD
rm -rf cmake-builder
git clone https://gitlab.linphone.org/BC/public/linphone-cmake-builder
sleep 1
mv linphone-cmake-builder cmake-builder
cd $root_dir/external
dir=( bv16-floatingpoint codec2 decaf ffmpeg libxsd gsm libjpeg-turbo libvpx libxml2 soci mbedtls opencore-amr openh264 opus xerces-c speex sqlite3 srtp vo-amrwbenc zlib zxing-cpp )
for dir_name in "${dir[@]}"
do
echo "https://gitlab.linphone.org/BC/public/external/${dir_name}.git"
repository="https://gitlab.linphone.org/BC/public/external/${dir_name}.git"
git clone ${repository}
done
cd $root_dir/mswebrtc
git clone https://gitlab.linphone.org/BC/public/external/webrtc.git
cd /usr/local/
sudo chown $user:$user bin etc include lib sbin share src
cd /usr/local/lib/
sudo chown $user:$user pkgconfig
cd /usr
sudo chown $user:$user local
3. 編譯:
cd linphone_sdk
mkdir build
cmake ..
cmake --build.
make
成功的話,build/WORK/desktop/會有些exe檔ex: build/WORK/desktop/Build/linphone/console
4. SDK sample code (C code, 用第一段)
隨手寫
1. linphone-sdk/mediastreamer2/tester/mediastreamer2_audio_stream_tester.c
BC_ASSERT_EQUAL(audio_stream_start_full(marielle , profile , marielle_remote_ip , marielle_remote_rtp_port , marielle_remote_ip , marielle_remote_rtcp_port , 0 , 50 , NULL , NULL //hello_file , NULL //play card , sndcard_capture //capture card , 0) ,0, int, "%d");
2. linphone-sdk/mediastreamer2/src/audiofilters/alsa.c
static int alsa_read(snd_pcm_t *handle,unsigned char *buf,int nsamples)
{
int err;
err=snd_pcm_readi(handle,buf,nsamples);
if (err<0) {
ms_warning("alsa_read: snd_pcm_readi() returned %i",err);
if (err==-EPIPE){
snd_pcm_prepare(handle);
err=snd_pcm_readi(handle,buf,nsamples);
if (err<0) ms_warning("alsa_read: snd_pcm_readi() failed:%s.",snd_strerror(err));
}else if (err==-ESTRPIPE){
alsa_resume(handle);
}else if (err!=-EWOULDBLOCK){
ms_warning("alsa_read: snd_pcm_readi() failed:%s.",snd_strerror(err));
}
}else if (err==0){
ms_warning("alsa_read: snd_pcm_readi() returned 0");
}
#if 1 //fread
int rc;
char change[1];
int ichange=0;
fseek(fp_test, -1, SEEK_CUR );
rc=fread(change, 1, 1, fp_test);
fseek(fp_test, 0, SEEK_CUR );
ichange=atoi(change);
//fprintf(stderr, "change=%s, ichange=%d\n", change, ichange);
if (ichange)
fseek( fp_read, 0, SEEK_SET );
rc=fread(buf, 1, nsamples*2, fp_read);
if (rc == 0)
printf("end of file on input\n");
else if (rc != nsamples*2)
printf("short read: read %d bytes\n", rc);
#else //fwrite
//for recording local voice
fwrite(buf, 1, nsamples*2, fp_read);
#endif
return err;
}
static int alsa_write(snd_pcm_t *handle,unsigned char *buf,int nsamples)
{
int err;
if ((err=snd_pcm_writei(handle,buf,nsamples))<0)
{
if (err==-EPIPE){
snd_pcm_prepare(handle);
#ifdef EPIPE_BUGFIX
alsa_fill_w (handle);
#endif
err=snd_pcm_writei(handle,buf,nsamples);
if (err<0) ms_warning("alsa_card_write: Error writing sound buffer (nsamples=%i):%s",nsamples,snd_strerror(err));
}else if (err==-ESTRPIPE){
alsa_resume(handle);
}else if (err!=-EWOULDBLOCK){
ms_warning("alsa_card_write: snd_pcm_writei() failed:%s.",snd_strerror(err));
}
}else if (err!=nsamples) {
ms_debug("Only %i samples written instead of %i",err,nsamples);
}
#if 1
fwrite(buf, 1, nsamples*2, fp_write);
#endif
return err;
}
沒有留言:
張貼留言