1、WebRTC目的
2、WebRTC架构图
面向第三方开发者的WebRTC标准API(Javascript),使开发者能够容易地开发出类似于网络视频聊天的web应用,最新的标准化进程可以查看 这里 。
(3) WebRTC Native C++ API
本地C++ API层,使浏览器厂商容易实现WebRTC标准的Web API,抽象地对数字信号过程进行处理。
a. RTP Stack协议栈
Real Time Protocol
b. STUN/ICE
可以通过STUN和ICE组件来建立不同类型网络间的呼叫连接。
c. Session Management
一个抽象的会话层,提供会话建立和管理功能。该层协议留给应用开发者自定义实现。
音频引擎是包含一系列音频多媒体处理的框架,包括从视频采集卡到网络传输端等整个解决方案。
PS:VoiceEngine是WebRTC极具价值的技术之一,是Google收购GIPS公司后开源的。在VoIP上,技术业界领先,后面的文章会详细了解
采样频率:16khz,24khz,32khz;(默认为16khz)
自适应速率为10kbit/s ~ 52kbit/;
自适应包大小:30~60ms;
算法延时:frame + 3ms
Internet Low Bitrate Codec
VoIP音频流的窄带语音编解码器
采样频率:8khz;
20ms帧比特率为15.2kbps
30ms帧比特率为13.33kbps
标准由IETF RFC3951和RFC3952定义
c. NetEQ for Voice
回声消除器是一个基于软件的信号处理元件,能实时的去除mic采集到的回声。
噪声抑制也是一个基于软件的信号处理元件,用于消除与相关VoIP的某些类型的背景噪声(嘶嘶声,风扇噪音等等… …)
WebRTC视频处理引擎
VideoEngine是包含一系列视频处理的整体框架,从摄像头采集视频到视频信息网络传输再到视频显示整个完整过程的解决方案。
视频图像编解码器,是WebRTC视频引擎的默认的编解码器
VP8适合实时通信应用场景,因为它主要是针对低延时而设计的编解码器。
PS:VPx编解码器是Google收购ON2公司后开源的,VPx现在是WebM项目的一部分,而WebM项目是Google致力于推动的HTML5标准之一
视频抖动缓冲器,可以降低由于视频抖动和视频信息包丢失带来的不良影响。
图像质量增强模块
对网络摄像头采集到的图像进行处理,包括明暗度检测、颜色增强、降噪处理等功能,用来提升视频质量。
4、WebRTC核心模块API
(1)、网络传输模块:libjingle
(2)、音频、视频图像处理的主要数据结构
类、结构体、枚举常量 | 头文件 | 说明 |
Structures | common_types.h | Lists the structures common to the VoiceEngine & VideoEngine |
Enumerators | common_types.h | List the enumerators common to the VoiceEngine & VideoEngine |
Classes | common_types.h | List the classes common to VoiceEngine & VideoEngine |
class VoiceEngine | voe_base.h | How to allocate and release resources for the VoiceEngine using factory methods in the VoiceEngine class. It also lists the APIs which are required to enable file tracing and/or traces as callback messages |
class VideoEngine | vie_base.h | How to allocate and release resources for the VideoEngine using factory methods in the VideoEngine class. It also lists the APIs which are required to enable file tracing and/or traces as callback messages |
(3)、音频引擎(VoiceEngine)模块 APIs
sub-API | 头文件 | 说明 |
VoEAudioProcessing | voe_audio_processing.h | Adds support for Noise Suppression (NS), Automatic Gain Control (AGC) and Echo Control (EC). Receiving side VAD is also included. |
VoEBase | voe_base.h | Enables full duplex VoIP using G.711. |
VoECallReport | voe_call_report.h | Adds support for call reports which contains number of dead-or-alive detections, RTT measurements, and Echo metrics. |
VoECodec | voe_codec.h | Adds non-default codecs (e.g. iLBC, iSAC, G.722 etc.), Voice Activity Detection (VAD) support. |
VoEDTMF | voe_dtmf.h | Adds telephone event transmission, DTMF tone generation and telephone event detection. (Telephone events include DTMF.) |
VoEEncryption | voe_encryption.h | Adds external encryption/decryption support. |
VoEErrors | voe_errors.h | Error Codes for the VoiceEngine |
VoEExternalMedia | voe_external_media.h | Adds support for external media processing and enables utilization of an external audio resource. |
VoEFile | voe_file.h | Adds file playback, file recording and file conversion functions. |
VoEHardware | voe_hardware.h | Adds sound device handling, CPU load monitoring and device information functions. |
VoENetEqStats | voe_neteq_stats.h | Adds buffer statistics functions. |
VoENetwork | voe_network.h | Adds external transport, port and address filtering, Windows QoS support and packet timeout notifications. |
VoERTP_RTCP | voe_rtp_rtcp.h | Adds support for RTCP sender reports, SSRC handling, RTP/RTCP statistics, Forward Error Correction (FEC), RTCP APP, RTP capturing and RTP keepalive. |
VoEVideoSync | voe_video_sync.h | Adds RTP header modification support, playout-delay tuning and monitoring. |
VoEVolumeControl | voe_volume_control.h | Adds speaker volume controls, microphone volume controls, mute support, and additional stereo scaling methods. |
(4)、视频引擎(VideoEngine)模块 APIs
sub-API | 头文件 | 说明 |
ViEBase | vie_base.h | Basic functionality for creating a VideoEngine instance, channels and VoiceEngine interaction. NOTE: This API must always be created. |
ViECapture | vie_capture.h | Adds support for capture device allocation as well as capture device capabilities. |
ViECodec | vie_codec.h | Adds non-default codecs, codec settings and packet loss functionality. |
ViEEncryption | vie_encryption.h | Adds external encryption/decryption support. |
ViEErrors | vie_errors.h | Error codes for the VideoEngine |
ViEExternalCodec | vie_external_codec.h | Adds support for using external codecs. |
ViEFile | vie_file.h | Adds support for file recording, file playout, background images and snapshot. |
ViEImageProcess | vie_image_process.h | Adds effect filters, deflickering, denoising and color enhancement. |
ViENetwork | vie_network.h | Adds send and receive functionality, external transport, port and address filtering, Windows QoS support, packet timeout notification and changes to network settings. |
ViERender | vie_render.h | Adds rendering functionality. |
ViERTP_RTCP | vie_rtp_rtcp.h | Adds support for RTCP reports, SSRS handling RTP/RTCP statistics, NACK/FEC, keep-alive functionality and key frame request methods. |
Google WebRTC for Windows 32bit 编译
WebRTC 是个很大的项目,其中还包括 libjingle(传输)、chrome(上层 web)。由于它是 Google 近期力推的,我相信应该很快会成熟起来,并成为一定范围内(相信有些 Web Browser 会拒绝它的,因为利益)的标准,相当有前景。
WebRTC 提供的官方文档不是很多,也不够详尽。但是我们还是希望跟寻《 Getting Started》来尝试编译它,这里的环境是 Windows 7 U 32bit。
首先我们要下载、安装一些工具:
- GIT 工具,用于获得 WebM 等。
- Google Depot Tools,这是 Google 在 Chromium 中就开始使用的分发工具。直接下载depot_tools.zip 并解压即可。注意加入系统环境变量 PATH(gclient 所在路径)。
- Windows 下我们还要下载、安装 Visual Studio 2005(用 VS2010 也是 OK 的)、Microsoft SDK 7.1(GRMSDK_EN_DVD.iso) (注意要确认安装 Sample)和 Microsoft DirectX SDK(DXSDK_Jun10.exe)。
gclient config https://webrtc.googlecode.com/svn/trunk其中“sync”命令还能创建开发环境(Linux:make, OSX: XCode, Windows: Visual Studio),如我们这里最关心的是 MS Visual Studio 的解决方案(trunk/webrtc.sln)。我们也可以手工通过下面的命令手工生成开发环境:
gclient sync --force
gclient runhooks --force如果需要指定 MS Visual Studio 的版本,请在“gclient”前先如下调用:
set GYP_MSVS_VERSION=2005源码拿到了,MS Visual Studio 的解决方案也有了,直接用 Visual Studio 打开即可,编译的时候可能会有些小问题,应该都是目录相关的,按照自己的环境重新设定一下即可。如我这里按照下面所指改动有问题的工程即可,工具 - 选项 - 项目和解决方案 - VC++ 目录:
set GYP_MSVS_VERSION=2008
可执行文件:生成文件位于“\trunk\Debug”下,如“peerconnection_server.exe 和 peerconnection_client.exe”,运行效果如下截图:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin
包含文件:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include
C:\Program Files\Microsoft DirectX SDK (August 2009)\Include
库文件:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib
C:\Program Files\Microsoft DirectX SDK (August 2009)\Lib\x86
...
google开源了WebRTC项目,网址是:http://code.google.com/p/webrtc/。
WebRTC实现了基于网页的视频会议,标准是WHATWG 协议,目的是通过浏览器提供简单的javascript就可以达到实时通讯(Real-Time Communications (RTC))能力。
通过对源码的粗略分析,WebRTC提供了视频会议的核心技术,包括音视频的采集、编解码、网络传输、显示等功能,并且还支持跨平台: windows,Linux,mac,Android。