Stratus service for developing end2end applications using RTMFP in Flash Play 10

2010-10-08  来源:本站原创  分类:Flash  人气:266 

Personal learning purposes only

Site reference:
YOU CAN GETTING START FROM THE LINKS ON THE BOTTOM "Getting Started", LIKE "Review the RTMFP groups overview"

Adobe Flash Player 10 and Adobe AIR 1.5 introduce a new communications protocol, Real-Time Media Flow Protocol (RTMFP), whose low latency, end-to-end peering capability, security, and scalability make it especially well suited for developing real-time collaboration applications by not only providing superior user experience but also reducing operators' costs.

Earlier versions of Flash Player use Real-Time Messaging Protocol (RTMP) and require Adobe Flash Media Server (FMS) for Interactive Collaboration applications (such as Adobe Acrobat Connect Pro) or Audio / Video Streaming. While RTMP is an excellent Choice for Streaming Media , shared objects, or remoting, it has limited ability of meeting real-time requirements of interactive audio and video communications.

In order to use RTMFP, Flash Player endpoints must Connect to an RTMFP-Capable Server, such as the Stratus beta Adobe Flash Media Server service or upcoming 4. Stratus is a hosted service that AIDS establishing Rendezvous Communications between endpoints Flash Player. Unlike FMS, Stratus does not support media relay, shared objects, scripting, etc. So by using Stratus, you can develop applications only where Flash Player endpoints are directly communicating with one another.

Flash Player is already the market leader in online video distribution over the web. With the introduction of RTMFP and advanced media compression technologies, Flash Player 10 is well positioned as the leader in real-time communications as well.

In this article, I first highlight the benefits of using RTMFP in real-time communications applications. Second, I describe the new ActionScript 3 API for managing direct end-to-end RTMFP connections. Finally, I present our VideoPhone sample application.

Benefits of 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).

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).

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

  • 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.
  • 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.
  • 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.

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.

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 ):


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.

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 proxy to Aid TURN Firewall traversal.

Stratus service

Flash Player instances must Connect to the Adobe Stratus service (using rtmfp:// in order to communicate with one another. Stratus Rendezvous is a hosted service that helps Flash Player instances Contact one another even if they are located behind NATs. Although service is Connecting to Stratus very similar to connecting to Flash Media Server, Stratus does not provide any of the typical Flash Media Server features (media relay, shared objects, remoting, etc.). Flash Player endpoints must stay connected to Adobe Stratus during the entire time of communication. In order to access Stratus, you will need a developer key that is generated when you create your Adobe Developer ID.

RTMFP support will be available in Flash Media Server 4. With Flash Media Server, it will be possible to enable communications between Flash Player 9 or earlier clients (using RTMP) and Flash Player 10 clients (using RTMFP).


RTMFP provides Secure Communications between endpoints. It uses a 128-bit AES with the Key negotiated using the Diffie-Hellmann Key Exchange method. However, IT does not provide strong authentication such as SSL or Endpoint RTMPS. To Aid Endpoint authentication, RTMFP and ActionScript Expose Secure nonces to Application Developers. These nonces are available at both communicating endpoints and Flash Player are Guaranteed to Match. By Verifying these nonces, End users can ensure that there is no Man-in-the-Middle Attack. These nonces can also be used to develop key continuity mechanism.

It is important to note that Flash Player only enables sending media from your microphone and webcam devices to other Flash Player endpoints that subscribe to your media streams.

ActionScript 3 API supporting RTMFP

There is a new ActionScript 3 API in Flash Player 10 to support RTMFP. Connecting to the Stratus service and creating end-to-end media streams are analogous to working with Flash Media Server. Please note that you must use ActionScript 3 with either Flash Professional (CS4 or later) or Flash Builder 4 targeting Flash Player 10 or AIR 1.5.

As I mentioned before, first you must connect to the Adobe Stratus service:

private const StratusAddress:String = "rtmfp://"; private const DeveloperKey:String = "your-developer-key"; private var netConnection:NetConnection; netConnection = new NetConnection(); netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnectionHandler); netConnection.connect(StratusAddress + "/" + DeveloperKey);

The Developer Key is issued when you Sign up for an account and Adobe Developer Connection is available on the Adobe Stratus beta service site.

Upon successful connection to Stratus, you get a NetConnection.Connect.Success event. There could be several reason for connection failure. If you provide an invalid developer key or incorrectly specify Stratus address, you'll receive NetConnection.Connect.Failed. If your firewall blocks outgoing UDP traffic, you ' ll receive the NetConnection.Connect.Failed event after a 90-second timeout.

After successfully establishing a connection to the Stratus service, you are assigned a unique 256-bit peer ID (NetConnection.nearID). Other Flash Player endpoints must know this peer ID in order to receive your published audio / video streams. It is out of the scope of Flash Player or the Stratus service How these IDs are exchanged among peer endpoints Flash Player. For exchanging peer IDs, you may use an XMPP service or a Simple Web service, as the Video Phone Sample Application does.

Direct communications between Flash Player instances is conducted using unidirectional NetStream channels. That is, if you want two-way voice conversation, each Flash Player endpoint must create a sending NetStream and a receiving NetStream.

First, create a sending NetStream:

private var sendStream:NetStream; sendStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS); sendStream.addEventListener(NetStatusEvent.NET_STATUS, netStreamHandler); sendStream.publish("media"); sendStream.attachAudio(Microphone.getMicrophone()); sendStream.attachCamera(Camera.getCamera());

This means that media is published as an end-to-end stream. Since Stratus cannot relay media, you can publish only end-to-end streams. This stream will include both audio and video from your local default devices chosen by the Settings Manager .

Note: Audio / video is not sent out until another Flash Player endpoint subscribes to your media stream.

Now, create the receiving NetStream:

private var recvStream:NetStream; recvStream = new NetStream(netConnection, id_of_publishing_client); recvStream.addEventListener(NetStatusEvent.NET_STATUS, netStreamHandler);"media");

At this point, you hear audio and you can create a Video object to display video. In order to create the receiving NetStream, you must know the 256-bit peer ID of the publisher (id_of_publishing_client). In order to receive audio / video, you must know the name of the stream being published.

Advanced topics

The publisher has fine control over which endpoint can receive its published stream. When a subscriber attempts to receive a published stream, the onPeerConnect() method is invoked (default implementation simply returns true) on the published NetStream. The publisher could disallow certain Flash Player endpoints to receive its media:

var o:Object = new Object(); o.onPeerConnect = function(subscriberStream:NetStream):Boolean { if (accept) { return true; } else { return false; } } sendStream.client = o;

On the publisher side, the NetStream.peerStreams property holds all the subscribing instances of the publishing NetStream. For example, using sendStream.send() will send the same data to all subscribers. You can use the following to send information to a specific subscriber:


The NetConnection.maxPeerConnections property specifiesthe number of peer streams that are allowed to connect to the publisher. Thedefault value is set to 8 but, in practice, depending on your application, youmust consider that most ISPs provide asymmetric Internet access. Figure 1illustrates the direct communication among three instances of Flash Player. Each FlashPlayer endpoint sends and receives two streams, creating a fully connected mesh.Since Internet download capacity is generally much higher than upload capacity, you must be extra careful not to overload the end-user's uplink.

Stratus service for developing end2end applications using RTMFP in Flash Play 10

Figure 1. End-to-end connections using the Stratus service

The NetConnection.unconnectedPeerStreams property is an array of NetStreams that are not associated with a publishing NetStream yet. When a publishing stream matches a subscribing stream name, the subscribing NetStream is moved from this array to the publishing NetStream.peerStreams array.

Exploring the Video Phone sample application

We have developed a Sample Video Phone Application for illustrating How to use End-to-End Capabilities of Flash Player 10. It is also available as Part of this article.

The Video Phone sample application relies on a simple HTTP service to exchange the Flash Player peer ID. The script is provided as part of the package (reg.cgi). This web service does not provide any user authentication. After Flash Player successfully connects to Stratus, it registers its peer ID with the web service. When making a call, the Video Phone caller uses this web service to look up recipient's peer ID.

Adobe runs this web service exclusively for the hosted Video Phone sample. When you build your own Video Phone sample, you must run your own web service and specify WebServiceUrl in VideoPhoneLabs.mxml. You should override the AbstractIdManager class to implement your own peer ID exchange mechanism-using, for example, XMPP, Google Apps, or the Facebook framework.

The following steps are necessary to build a Video Phone sample application (for more details, please see ReadMe.txt included in the package):

  1. Host a web service for the peer ID exchange using the provided reg.cgi Python script.
  2. Create a new Flex project in Flash Builder 4.
  3. Add the source files from the package (VideoPhoneLabs.mxml,,,, and to the project src folder.
  4. Specify your Stratus developer key in DeveloperKey in VideoPhoneLabs.mxml.
  5. Specify the URL for the web service in WebServiceUrl in VideoPhoneLabs.mxml.

The Video Phone sample application uses the phone model. The call establishment procedure is implemented using end-to-end NetStream.send() messages. Since you can use the NetStream.send() method only on an established NetStream, Video Phone publishes a so-called "listener stream" ( with a fixed name) to which other Flash Player endpoints can connect. When client A (the caller) wishes to communicate with client B (A calls B), he or she subscribes to client B's listener stream. At this point, client B is notified of the peer ID of the caller (using the onPeerConnect() method) and subscribes to client A's media stream. Through this media stream, client A notifies client B about his or her user-friendly name (using the NetStream.send() method), which is presented to the user to either accept or reject the call. If the call is accepted, client B publishes the media stream and two-way communications is established.

Where to go from here

In this article, I presented some of the most exciting features of the new RTMFP protocol along with an overview of the new ActionScript 3 API. After reading this article, you should have a good understanding of how to use this revolutionary protocol. I hope you will be developing blockbuster applications using the end-to-end and advanced media capabilities of Flash Player 10 and AIR 1.5.

  • Stratus service for developing end2end applications using RTMFP in Flash Play 10 2010-10-08

    Personal learning purposes only Site reference: YOU CAN GETTING START FROM THE LINKS ON THE BOTTOM "Getting Started", LIKE "R

  • Web Service (Axis) for advanced applications - Handler, Chain 2010-10-19

    Web Service (Axis) for advanced applications - Handler, Chain [4] The basic concept Handler Handler in the J2EE Web services technical features very much like the Servlet technology in the Filter. We know that in Servlet, when a HTTP reach the server

  • svn service configuration, and basic applications 2011-06-27

    svn service configuration, and basic applications [Introduction] svn (subversion) version of the rise in recent years, management tools, is the successor to cvs. Currently, the vast majority of open source software code using svn as version control s

  • MyEclipse5.5 developing JSP applications - EL expression analysis is not available 2010-03-29

    Jsp development to solve the problem today does not support EL encountered a baffling problem is the use of MyEclipse5.5 or less than 6.0, the analytic encounter EL expression issues. After several hours of pondering finally found, and for everyone t

  • MacOS on the VNC service settings and use VNC to connect MacOS flash across the screen solution 2010-08-24

    1.Mac OS X VNC service settings System Preferences - "Sharing -" Check "screen sharing", and then - "computer settings -" VNC display program can use the password control and gives the password screen, enter the login passwor

  • ASP.NET applications to improve performance skills of 10 small 2010-10-23

    1, the control mechanism does not participate in POSTBACK, do not use server controls, HTML markup as static 2, the compile-time configuration using RELEASE 3, was put into application, remember to set DEBUG FALSE 4, SMARTNAVIGATE remember to set TRU

  • 通过Stratus 服务器在Flash Player中使用RTMFP 开发P2P应用 2014-08-16

    通过Stratus 服务器在Flash Player中使用RTMFP 开发 点对点应用(网文转摘) 作者:Jozsef Vass 译者:巴巴鲁 (请转载时注明和改编时出处,谢谢) Adobe Flash Player 10 and Adobe AIR 1.5 introduce a new communications protocol, Real-Time Media Flow Protocol (RTMFP), whose low latency, end-to-end peering ca

  • P2P Application Development using RTMFP 2010-10-29

    flash10 peer P2P application development using RTMFP Stratus server in Flash Player through the use of point to point applications RTMFP Development Adobe Flash Player 10 and Adobe AIR 1.5 introduces a new communication protocol, Real-Time Media Flow

  • Development of applications based on the jndi 2010-03-18

    Keywords: Developing applications based on the jndi Java Naming and Directory Interface (Java Naming and Directory Interface, JNDI) is used to access the application from the Java Naming and D

  • [Change] Java Message Service 2010-04-02

    Asynchronous communication is service-oriented architecture (SOA), an important part, because many of the enterprise communication systems, especially communication with external systems inherently asynchronous. Java Message Service (JMS) is used to

  • Eclipse3.4 + Lomboz3.3 + Tomcat6.0 configuration and development of Web applications 2010-03-27

    Development of web applications using eclipse install configuration more complicated, according to their own learning experience, I will use eclipse + lomboz + tomcat specific installation and configuration process of developing web applications writ

  • ubuntu service optimization 2010-02-05

    Reprinted: 1, sysv-rc-conf Introduction sysv-rc-conf is a powerful service management procedures, opinions of the masses is the sysv-rc-conf easy to use than chkconfig. Second, background kn

  • Eclipse application software download store open nostalgic short URL service 2010-03-07

    Internet applications store now flourishing, from the very beginning Apple's AppStore, and later a lot of copycat - Android, Nokia, Ubuntu, Novell, China Mobile, China Unicom, the addition of a Eclipse, although is not unusual (Click picture below to

  • Linux Startup Service Optimization 2010-05-12

    The following are brief run and run-level sequence: A Linux system boot process can be divided into several stages. We mainly look at when the kernel is loaded for the one stage. You can run runlevel command to determine your current operating system

  • Win7 comprehensive analysis system service (change) 2010-05-28

    As for the computer "old bird" who, the system services is often optimized system parameters, and many system performance parameters and option settings, system services in a variety of optimization is to bring more direct, tangible performance

  • Four components of Android applications 2010-05-31

    In Android, an application can use components of other applications, this is Android system, a very important feature. For example, you write an application needs to display a scrollable image list, if others have developed an application with this f

  • Building Web Applications for the Spring-Seam hybrid component 2010-06-02

    Transfer from: Spring and JBoss Seam framework for enterprise web application development provides different features, respectively. Spring is a JavaEE middleware framework, it is based on the abstract as

  • Turn-linux common service names and explanations 2010-06-10

    Everyday use with linux, though often configure php environment, can be fixed for linux itself, very few common services here put it down you can turn off unused, and save resources also speed up the switch machine time. Do not close the following se

  • [Reserved] "Asynchronous Ajax for revolutionary web applications" 2010-06-18

    A very important PDF "Asynchronous Ajax for revolutionary web applications" from SUN web site. ASYNCHRONOUS AJAX FOR REVOLUTIONARY WEB APPLICATIONS Jeanfrancois Arcand Ted God

  • android Service Activity Binder interactive communication interactive examples 2010-06-25

    android Service Binder examples of interactive communication This article comes from: android SDK provides the Service, for a similar * nix daemon or windows service. Service There are