RTMFP UDP

Peer-to-peer (P2P) communication is the real-time transfer of data and media between clients.

Real Time Media Flow Protocol (RTMFP) is an Adobe proprietary protocol. It enables peer-to-peer communication between applications running in Flash Player or the AIR runtime. It is meant to provide a low-latency, secure, peering network experience.

Real Time Messaging Protocol (RTMP) uses Transmission Control Protocol (TCP). RTMFP uses User Datagram Protocol (UDP), which provides better latency, higher security (128-bit AES encryption), and scalability. RTMP is faster than RTMFP, but does not guarantee perfect message ordering and delivery.

RTMP was designed to connect via an RTMFP-capable server, such as the Cirrus service (RTMP uses the Flash Media Server), but it can also be used over a local network using WiFi without the need for a server. Note that Flash Media Server 4.0 speaks RTMFP as well.

 

HTTP Dynamic Streaming, Peer-to-Peer Communication, Controls, YouTube

HTTP Dynamic Streaming

Adobe’s adaptive streaming delivery method, called HTTP Dynamic Streaming, is another option for live or on-demand video playback. This method is similar to Apple’s Adaptive Streaming and Microsoft’s Smooth Streaming.

Because HTTP Dynamic Streaming plays back video files in chunks, additional complex logic needs to be built in to put the segments together in the right order and play them back. Therefore, it is recommended that an Open Source Media Frameworkbased player be used for HTTP Dynamic Streaming.

You can build one from scratch using OSMF, or use a prebuilt solution such as Flash Media Playback or Strobe Media Playback. Video content needs to be prepared for HTTP Dynamic Streaming in a simple post-processing step that creates the segments along with a manifest file that describes the video and its segments. Adobe provides free command-line tools for preparing both on-demand and live streams.

More information on HTTP Dynamic Streaming is available online at http://www.adobe.com/products/httpdynamicstreaming/ and http://www.flashstreamworks.com/archive.php?post_id=1278132166.

 Peer-to-Peer Communication

Real Time Media Flow Protocol (RTMFP) is an Adobe proprietary protocol that enables peer-to-peer communication in Flash Player and the AIR runtime. It opens up possibilities for your applications using video.

Controls

The methods for controlling the stream are play, pause, resume, seek, and close. You cannot stop the stream because it is still downloading. You need to close it completely.

You can check the progress of the stream by checking its time property. Use that value and increment it to seek ahead in the video. You can also seek to a specific time, of course. With progressive download, you can only seek ahead to points in the video file that have been downloaded. With embedded video and RTMP, you can seek anywhere within the video file at any time.

To monitor these events, register for NetStatusEvent and its info.code object:

[code]function onNetEvent(event:NetStatusEvent):void {
switch (event.info.code) {
case “NetStream.Play.Start” :
break;
case “NetStream.Play.Stop”:
break;
case ” NetStream.Pause.Notify” :
break;
case ” NetStream.Unpause.Notify”:
break;
case “NetStream.Buffer.Full”:
break;
case “NetStream.Seek.Notify”:
break;
}
}
}[/code]

You cannot use the Sound object to control the audio part on the video. Use the Sound Transform property instead. Here we are setting the volume to silent:

[code]var transform:SoundTransform = new SoundTransform();
stream.soundTransform = new SoundTransform(0);[/code]

YouTube

It is almost impossible to talk about videos without mentioning YouTube. As you most certainly know, YouTube is a file-sharing video site that has changed the propagation of information via video, whether is it pop culture or current events.

YouTube videos can be played on Android devices if they are encoded with the H.264 video codec.

In both cases, you use a URLRequest:

[code]<uses-permission android:name=”android.permission.INTERNET” />
import flash.net.navigateToURL;
import flash.net.URLRequest;
var youTubePath:String = “http://www.youtube.com/watch?v=”;
var videoID:String = someID;
navigateToURL(new URLRequest(youTubePath + videoID);[/code]

To display the video at full screen, use a different path:

[code]var youTubePath:String = “http://www.youtube.com/watch/v/”;[/code]

 

 

RTMP Streaming

Real Time Messaging Protocol (RTMP) is a protocol using a streaming server such as Flash Media Server or a streaming service such as Influxis or Flash Media Server for Amazon Web Services.

Streaming uses a lot of data. Inform your users to use WiFi so that it is not too costly and guarantees the best possible quality experience.

RTMP server

Let’s use our RTMP server to stream an on-demand video. As in progressive downloading, streaming uses a Video, a NetConnection, and a NetStream object.

NetConnection connects to the streaming server. The protocol used is rtmp. Note the streamClient variable. You need it for callbacks; otherwise, you will get a runtime error:

[code]static const SERVER:String = “rtmp://SERVER_URI/vod/;
static const VIDEO_PATH:String = “/myVideo”;
video = new Video();
video.width = 480;
video.height = 320;
connection.addEventListener(NetStatusEvent.NET_STATUS, onNetEvent);
connection.connect(SERVER);
function netConnectionEvent(event:NetStatusEvent):void {
if (event.info.code == “NetConnection.Connect.Success”) {
var stream:NetStream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, onStreamEvent);
var streamClient:Object = new Object();
streamClient.onMetaData = onMetaData;
stream.client = streamClient;
video.attachNetStream(stream);
stream.play(VIDEO_PATH);
addChild(video);
break;
}
}
function onStreamEvent(event:NetStatusEvent):void {}
function onMetaData(info:Object):void {}
function onBWDone():void {}[/code]

It is a good idea to add listeners for connection errors while debugging and to inform your audience in case of an issue:

[code]connection.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
connection.addEventListener
(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
function onIOError(event:IOErrorEvent):void {}
function onSecurityError(event:SecurityErrorEvent):void {}
function onASyncError(event:AsyncErrorEvent):void {}[/code]

Local Flash Media Server

You can install a local Flash Media Server to run and test your applications. Change the path to your local server. To ensure the video plays, turn off .swf verifications on the server:

[code]static const SERVER:String = “rtmp://localhost/vod/”;[/code]

Flash Media Server offers features to examine and monitor your video streams. The Quality of Service API, for instance, returns the user’s current bandwidth. You can extend the functionality of your video management by writing additional server code.