·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[FMS]运用as3开发RTMFP协议的P2P程序(基础篇)(2)

时间:2014-01-02 17:05未知
在这篇文章中,我首先强调在即时通讯领域使用RTMFP的优势。其次,我将要介绍直接管理点对点RTMFP管理所对应的新的ActionScript 3.0 API。最后,我介绍我们的VideoPhone应用实例。 Requirements 要求 In order to ma

在这篇文章中,我首先强调在即时通讯领域使用RTMFP的优势。其次,我将要介绍直接管理点对点RTMFP管理所对应的新的ActionScript 3.0 API。最后,我介绍我们的VideoPhone应用实例。

Requirements 要求

In order to make the most of this article, you need the following software and files:

为了使用文中的文件,你需要以下软件和文件:

Flex Builder 3

Try 
Buy
Note: Please follow the instructions in Introducing Flex SDK 3.2 and Flex Builder 3.0.2 to install Flex Builder 3.0.2. This also includes Flex SDK 3.2, which is required to build applications targeting Flash Player 10. Although you may also use Adobe Flash Professional CS4 for development, this article instructs how to build a sample application using Flex Builder 3.

注意:请按照Introducing Flex SDK 3.2 and Flex Builder 3.0.2指南中的方法去安装Flex Builder 3.0.2.这里面包括Flex SDK 3.2, 这是为了建立 Flash Player 10应用。尽管你也可以使用Adobe Flash Professional CS4 作为开发工具,但这篇文件指导你如果使用Flex Builder 3建立一个简单的应用.

Flash Player 10

Download
Sample files:

stratus_article_assets.zip (ZIP, 13K)
Prerequisite knowledge

预备知识

Familiarity with ActionScript 3.0 and Flex Builder is required.

熟悉ActionScript 3.0 和 Flex Builder 是必要的。

Benefits of RTMFP  RTMFP的好处

Real-Time Media Flow Protocol (RTMFP) is a new communications protocol introduced in Flash Player 10 and also available in AIR 1.5. One of its major differentiators from Real-Time Messaging Protocol (RTMP), which is based on the Transmission Control Protocol (TCP) and exclusively used in previous versions of Flash Player, is that RTMFP is built on User Datagram Protocol (UDP).


Real-Time Media Flow Protocol (RTMFP)是一个引入到Flash Player 10 和 in AIR 1.5新的通讯协议。同Real-Time Messaging Protocol (RTMP)的主要不同点之一是,RTMP基于传输控制协议 (TCP) 和 先前版本的Flash Player,RTMFP建立在 User Datagram Protocol (UDP)协议.

While TCP provides reliable data delivery (well applicable for file transfer, e-mail, etc.), it does not provide any end-to-end delay guarantees. Reliable data transmission in TCP is achieved by re-transmission of lost data, which introduces latency. Because minimizing end-to-end delay is one of the most important goals in real-time communications (a few hundred milliseconds' delay may render a conversation unusable), TCP is not well suited for this purpose. Transmission error resilience and recovery form an integral part of most advanced audio and video compression techniques—such as Speex audio and H.264 video codec, both available in Flash Player 10. Reliable delivery provided by TCP is therefore not needed. As a result, UDP, which provides an efficient and rapid data delivery, is popularly used in real-time collaboration applications where minimizing end-to-end delay is of paramount importance. Another advantage of UDP over TCP that it enables end-to-end peering—that is, direct data transmission between two clients located behind network address translators (NATs).

TCP提供了可靠的数据传输(也适用于文件传输,电子邮件等) ,它没有提供任何端到端延迟保证。可靠的数据传输的TCP实现了重新传输丢失的数据,其中包括了延迟。由于尽量减少端到端延迟是实时通信 (几百毫秒的延迟可能使一个会话不可用)中最重要的一个目标,TCP是不适合用于这一目的。传输错误复原和恢复不可分割的组成部分,最先进的音频和视频压 缩技术,如Speex音频和H.264视频编解码器,可同时在Flash Player 10 。因此,可靠的交付所提供的TCP没有必要的。因此, UDP连接,它提供了一个高效,快速的数据传输,是普遍使用的实时协作应用,尽量减少端到端延迟是至关重要的。另一个优势在于 UDP连接,它使端到端的对等,也就是说,数据直接的传输客户之间后面网络地址转换( NAT ) 。

When compared to RTMP, RTMFP provides the following advantages for real-time communications:

当同RTMP做对比,RTMFP提供下列高级的即时通讯:

Low latency: Since RTMFP is built on top of UDP, it provides minimal latency for real-time communications. It is important to note that RTMFP provides both reliable and unreliable service. When sending data between two Flash Player instances (for example, using the NetStream.send() method), reliable data transmission is used. When sending Speex audio between two Flash Player instances, unreliable delivery is used, providing the smallest possible latency.
低延迟:一但RTMFP建立起了UDP,它将给即时通讯提供最小的延迟。重要的是要注意RTMFP提供了可靠和不可靠的服务。当在两个Flash Player 实例之间发送数据的时候(例如,使用NetStream.send()方法),可靠的数据传输被使用。当在两个Flash Player 实例之间发送Speex 音频的时候,不可靠的交互方式被使用,以提供最小的延迟。
End-to-end media delivery: Media is sent directly between two Flash Player instances without routing through a central relay server. When compared to RTMP, where all data is sent through Flash Media Server, RTMFP not only further reduces end-to-end delay, but also eliminates costs associated with a central data relay, thus lending itself to extremely scalable deployments.
点对点媒体传输:媒体直接发送给两个Flash Player的情况下,不通过路由,而是通过一个中央中继服务器。当同RTMP相比发现,在所有通过Flash Media Server传送的数据, RTMFP不仅进一步降低了端到端的延迟,而且也消除了中央数据中继的相关开销,因此,有助于自身的可扩展性部署。
Data prioritization: Audio is transmitted with higher priority than video and non-time critical data (such as instant message, etc.). This can significantly enhance user experience over a bandwidth constrained communications channel.

数据的优先次序:音频传输具有较高优先于视频和非时间关键数据(如即时信息等) 。这可以通过带宽通信通道的限制大大提高在用户体验。
All of these features represent tremendous benefits for real-time communications, providing a significantly greater user experience than is achievable with earlier versions of Flash Player.

所有这些功能代表了应用于实时通信的巨大优势,提供了一个极大的用户体验,其成就比早期版本的Flash播放器的效应更为巨大。

Firewall traversal  穿越防火墙

RTMFP is built on top of UDP, which enables direct connection between clients even if they are located behind NATs or firewalls. In order for RTMFP to work, your firewall must be configured to allow outgoing UDP traffic. While this is the case with most consumer or small office/home office (SOHO) firewalls, many corporate firewalls block UDP traffic altogether.

RTMFP是建立在UDP连接的基础上,使客户端直接的通信,即使它们位于NATs(译者注:是一个网络协议允许客户端后面的NAT (网络地址转换) ,以找出其公共地址,类型的NAT是延迟和互联网方面的端口相关的网络地址转换,尤其本地端口。此信息是用来建立UDP连接(用户数据报协议)之间的沟通 两个主机都是延迟的NAT路由器。该议定书是指在RFC 3489)或防火墙。为了RTMFP工作,您的防火墙必须配置为允许即将发出的UDP通信。大多数的消费者或小型办公室/家庭办公室( SOHO )的防火墙是这种情况,许多企业防火墙完全阻止UDP通信。

One solution is to configure Flash Player to use a TURN proxy (Traversal Using Relays around NAT). Flash Player supports IETF Internet Draft draft-ietf-behave-turn-08 without authentication. If the network administrator configures a TURN proxy that allows outgoing UDP, Flash Player can be configured by adding the following line in mms.cfg (for more information on Flash Player configuration and the location of mms.cfg, please read the Adobe Flash Player Administration Guide for Flash Player 10):

一种解决办法是配置的Flash Player使用转向代理 (遍历周围可用的NAT ) 。 Flash Player的支持IETF的因特网草案draft-ietf-behave-turn-08。如果网络管理员配置转向代理,允许即将发送的UDP连接, Flash播放器可以增加在mms.cfg的配置(更多的信息Flash Player的配置和位置mms.cfg ,请阅读Adobe Flash Player的管理指南的Flash Player 10 ) :

RTMFPTURNProxy=ip_address_or_hostname_of_TURN_proxy

Direct UDP traffic is always attempted and the TURN proxy is only used as a backup: it is used for UDP traffic that cannot flow between Flash Player and Stratus (in case of UDP blocking firewall) or between Flash Player endpoints.

直接UDP通信总是被尝试,转向代理只是用来作为备份:它是用于UDP通信,不能在Flash Player和Stratus (如UDP协议封锁防火墙)之间或Flash Player的端点之间流动。

Even if your firewall enables outgoing UDP traffic, it is possible that end-to-end peering cannot be established due to a combination of firewalls. When one endpoint is located behind a so-called "symmetric firewall," end-to-end communications may not be possible. (For a classification of firewalls, please see the Network address translation entry on Wikipedia.) In this situation, you may use a TURN proxy to aid firewall traversal.

即使你的防火墙使即将发送的UDP通信的用,可能和你对应端的防火墙不能够允许通过。当一个端点设在一个所谓的“对称的防火墙, ” 的后面,端到端的通信可能是不可以实现。 (对于多种防火墙,请进入维基百科参阅 网络地址转换。 )在这种情况下,你可以使用转代理援助你防火墙穿越。

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器