官网
源码下载
git clone https://gitlab.linphone.org/BC/public/mediastreamer2.git
特性
- 音频codec支持: opus, speex, g711, g729, gsm, iLBC, AMR, AMR-WB, g722, SILK, iSAC, BV16, Codec2
- 视频codec支持: VP8, H.264 and H.265 with resolutions up to 1080P, MPEG4
- H.264编解码支持对接Mac OSX / iOS (VideoToolbox) 和 Android (MediaCodec)
- 发送和接收 RTP/RTCP 流
- 音频会议API
- 创新的抖动缓冲算法,可以快速适应抖动较大的网络条件,并改善对音频延迟的控制
- 自适应码率控制算法:支持拥塞控制和可用带宽估计,以优化音频和视频质量
- 支持ICE(RFC 5245),STUN和TURN(RFC 5766),用于优化NAT穿越,在可能的情况下,进行p2p的音视频连接
- 支持 SRTP, zRTP 和 SRTP-DTLS 语音视频加密
- 支持 RTP/AVPF:用于视频错误恢复的RTCP控制消息:PLI、SLI、RPSI、FIR
- 支持TMMBR (Temporary Maximum Media Stream Bit Rate Request)
- 支持使用 libspeexdsp、webrtc AECm 或 AEC 的回声消除器来消除回声
- 支持从各种依赖于平台的声音架构(ALSA、PulseAudio、AudioUnit、AudioSqueue、WaveApi、WASAPI、Android AudioTrack/AudioRecord、Android OpenSLES)采集和播放声音
- 支持基于操作系统摄像头API的任何网络摄像头:QuickTime、DirectShow、Video4Linux、Android摄像头
- 支持播放和录制raw, wav, 或者 mkv (matroska) 文件
- 使用OpenGL、DrawDib、X11/Xv优化YUV图像的渲染
- Dual tone generation
- Custom tone detector
- Audio parametric equaliser(声音参数均衡器)
- 音量控制,自动增益控制
- Can use plugins to add new codecs, for new sound input/output backend etc.(使用插件添加新的编解码器)
设计原则
每个处理实例都包含在MSFilter对象中。MSFilter的输入和/或输出可用于连接其他MSFilters。
一个简单的例子可以进行说明:
- MSRtpRecv是一个MSFilter,可以从网络接收RTP数据包,将其解包并发布在其唯一的输出上。
- MSSpeexDec是一个MSFilter,它认为所有的输入都是Speex编码的数据包,它会获取其输入的所有信息,对其进行解码,并将结果放在其输出上。
- MSFileRec是一个MSFilter,它获取其输入上的所有内容并将其写入wav文件(假设输入是16位线性pcm)
MSFilters可以连接在一起形成过滤器链。如果我们连接以上三个示例,我们将获得一个接收RTP数据包的处理链,对其进行解码并将未压缩的结果写入wav文件。
MSRtpRecv-->MSSpeexDec-->MSFileRec
媒体处理的执行由MSTicker对象进行调度处理,该线程每10毫秒唤醒一次,来处理其管理的所有MSFilter链中的数据。可以同时使用多个MSTicker。例如,一个用于音频过滤器、一个用于视频过滤器,或者每个处理器上运行一个。
协议
- RTP: A Transport Protocol for Real-Time Applications, RFC 3550
- 5. RTP Data Transfer Protocol
- 6.4 Sender and Receiver Reports
- 6.5 SDES: Source Description RTCP Packet
- 6.6 BYE: Goodbye RTCP Packet
- 6.7 APP: Application-Defined RTCP Packet
- RTP Profile for Audio and Video Conference with Minimal Control, RFC 3551
- RTP Payload for Text Conversation, RFC 4103
- Real-time Transport Control Protocol (RTCP)-Based Feedback (RTP/AVPF), RFC 4585
- Temporary Maximum Media Stream Bit Rate Request and Notification, section 3.5.4. of RFC 5104
- Symmetric RTP / RTP Control Protocol (RTCP), RFC 4961
- Session Traversal Utilities for NAT (STUN), RFC 5389 (Basic procedures)
- Secure Real Time Transport Protocol (SRTP, RFC 3711)
- ZRTP, RFC 6189
- ICE, RFC 5245 & RFC 6336
- TURN, RFC 5766
- RTP Payload for Text conversation, RFC 4103
- rtcp-mux, RFC 5761
- SRTP-DTSL, RFC 5763
音频协议
- RTP Payload Format for the Opus Speech and Audio Codec, RFC 7587
- RTP Payload Format for the Speex Codec, RFC 5574
- Real-Time Transport Protocol (RTP) Payload Format and File Storage Format for the Adaptive Multi-Rate (AMR) and Adaptive Multi-Rate Wideband (AMR-WB) Audio Codecsonly RTP octet-align=1 mode, without interleaving, crc, single channel
- RTP Payload for DTMF Digits, Telephony Tones, and Telephony Signals, RFC 4733RTP Payload Format for Named Telephone Events
- RTP Payload Format and File Storage Format for SILK Speech and Audio Codec
- RTP Payload Format for BroadVoice Speech Codecs, RFC 4298
视频协议
- XML Schema for Media Control, RFC 5168Sending and processing of picture fast update command in SIP INFO
- RTP Payload Format for MPEG-4 Audio/Visual Streams, RFC 30163. RTP Packetization of MPEG-4 Visual bitstream
- RTP Payload Format for ITU-T Rec. H.263 Video, RFC 4629
- RTP Payload Format for H.264 Video, RFC 3984
- RTP Payload Format for VP8 Video
编译
./autogen.sh
报错如下:
src/Makefile.am:328: error: endif reminder (BUILD_VIDEO_TRUE) incompatible with current conditional: MS2_FILTERS_TRUE
src/Makefile.am:330: error: endif without if
修改如下:
fuqiang@ubuntu:~/workspace/mediastreamer2$ git diff
diff --git a/src/Makefile.am b/src/Makefile.am
index 45319f8c..ec923e64 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -325,9 +325,8 @@ if ORTP_ENABLED
libmediastreamer_voip_la_SOURCES+= voip/videostream.c
endif
-endif BUILD_VIDEO
+endif
-endif MS2_FILTERS
if BUILD_UPNP
可以成功,继续执行:
./configure
报错如下:
checking whether byte ordering is bigendian... no
./configure: line 17747: syntax error near unexpected token `0.40,'
./configure: line 17747: `IT_PROG_INTLTOOL(0.40, no-xml)'
修改如下:
删除 IT_PROG_INTLTOOL(0.40, no-xml)
报错如下:
configure: error: Package requirements (speex >= 1.2beta3) were not met:
No package 'speex' found
安装这个包:
sudo apt install -y libspeex-dev libspeexdsp-dev
报错如下:
configure: WARNING: Could not find libavcodec (from ffmpeg) headers and library.
checking for SWSCALE... no
configure: error: Could not find libswscale (from ffmpeg) headers and library. This is mandatory for video support
安装这个包:
sudo apt install -y libavcodec-dev libswscale-dev
报错如下:
configure: error: No X video output API found. Please install X11+Xv headers.
安装这个包:
sudo apt install -y libx11-dev libxv-dev
报错如下:
configure: error: Package requirements (glew >= 1.5) were not met:
No package 'glew' found
安装这个包:
sudo apt install -y libglew-dev
报错如下:
configure: error: Couldn't find ortp library
安装这个包:
sudo apt install -y libortp-dev
报错如下:
checking for LIBV4L2... no
No libv4l2 found.
checking for LIBV4L1... no
No libv4l1 found.
checking for LIBV4LCONVERT... no
No libv4lconvert found.
configure: error:
Missing libv4l2. It is highly recommended to build with
libv4l2 headers and library. Many camera will won't work or will crash
your application if libv4l2 is not installed.
安装这个包:
sudo apt search libv4l-dev
报错如下:
configure: error: "Could not find bctoolbox"
安装这个包:
sudo apt install libbctoolbox-dev