ADOBE FLASH MEDIA SERVER 4.

0 Developer’s Guide
® ®

© 2010 Adobe Systems Incorporated. All rights reserved. Prerelease.
Copyright

Adobe® Flash® Media Server 4 Developer’s Guide This guide is licensed for use under the terms of the Creative Commons Attribution Non-Commercial 3.0 License. This License allows users to copy, distribute, and transmit the user guide for noncommercial purposes only so long as (1) proper attribution to Adobe is given as the owner of the guide; and (2) any reuse or distribution of the user guide contains a notice that use of the guide is governed by these terms. The best way to provide notice is to include the following link. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/us/ Adobe, the Adobe logo, Adobe AIR, Adobe Premiere, ActionScript, Acrobat Connect, AIR, Creative Suite, Dreamweaver, Flash, Flash Builder, Flash Lite, Flex, Flex Builder, and XMP are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries. Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Macintosh and Mac OS are trademarks of Apple Inc., registered in the United States and other countries. All other trademarks are the property of their respective owners. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.

Last updated 8/30/2010

iii

Contents
Chapter 1: Getting started building applications Parts of a media application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Set up a development environment Example: Hello World application Creating an application Test an application Deploy an application .................................................................................... 1 ...................................................................................... 2

................................................................................................ 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

.................................................................................................... 8

Chapter 2: Streaming services About streaming services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Streaming live media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Streaming on-demand media Signed streaming services API Streaming media over HTTP Using the multicast service

Creating clients for signed streaming services

Chapter 3: Developing streaming media applications Connecting to the server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Managing connections Streaming media files Checking video files Handling errors Working with playlists Dynamic streaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Reconnecting streams when a connection drops Fast switching between streams Smart Seeking Detecting bandwidth

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

Detecting stream length

Chapter 4: Working with live video Capturing live video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Adding DVR features to live video Adding metadata to a live stream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

Capturing timecode sent from Flash Media Live Encoder Publishing live video in RAW file format Publishing from server to server

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Chapter 5: Building peer-assisted networking applications Real-Time Media Flow Protocol (RTMFP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 RTMFP groups Multicasting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

Post messages to a group

Last updated 8/30/2010

. . . . . . . . . . . . . . . . . . . . . 131 Authenticate clients Authenticate users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 Chapter 8: Developing Plug-ins What’s new with plug-ins in Flash Media Server 4. . . . . . . . . . . . . . . . . . . . 121 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 DEVELOPER’S GUIDE Contents iv Route messages directly to a peer Replicate an object within a group Example: P2P video and text chat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Last updated 8/30/2010 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . upgrading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 . . . . . . . . . . 122 . . . . . . . . . . . . . . . . . . . . . . . . . 126 . . . . . . . . . . 141 . . . . . . . . . . and server editions Working with plug-ins General development tasks Developing an Access plug-in Developing a File plug-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Developing an Authorization plug-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .FLASH MEDIA SERVER 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 Versioning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Additional ActionScript APIs to support peer-assisted networking Tips for developing peer-assisted networking applications Chapter 6: Developing social applications About social applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 About shared objects Remote shared objects SharedBall example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Broadcast messages to many users Chapter 7: Securing applications Allow or deny access to assets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 . . .

To test the application. You can develop clients with Adobe Flash Professional. You can also create your own client that captures live audio and video. such as Strobe Media Playback. or pause a video.asc. including Flash Video (FLV). Last updated 8/30/2010 . MPEG-4 (MP4 and F4V). you can use any text editor or IDE. Server-Side ActionScript Most applications use Server-Side ActionScript code written in a file with the suffix . To write server-side code. or the Flex SDK. livepkgr. Flash Media Server 3 and later support ActionScript 3.0. but runs on the server. You can write client-side code and server-side code on the same computer running Flash Media Server. Flash Builder. including the free developer edition. and multicast. or the Flex SDK. and so on. Flash Media Server installs with four server-side applications (also called streaming services): live. vod. copy the server-side code to Flash Media Server. Each service provides a different type of streaming. Client-side ActionScript The client contains ActionScript code that handles user interaction and connects to the server.asc. Flash Media Server supports playback of a variety of stream formats. or you can write it on a remote computer. In both cases. Adobe AIR. Adobe recommends using a player that is based on OSMF (Open Source Media Framework). The server application is written in Server-Side ActionScript (which is like ActionScript 1. called an ActionScript Communication File. Video or audio files Many media applications stream recorded audio or video from the server to clients or between clients. connect to external data sources. To write client-side code. create playlists. You can also use prebuilt clients. including Flash Professional and Flash Builder. ActionScript 2. More Help topics “Streaming services” on page 13 Set up a development environment You can use any edition of the server. and ActionScript 1.0. rather than on the client). Camera or microphone You can use Adobe Flash Media Live Encoder to stream live video or audio to the server. Adobe Flash Builder. or server to server.0. define what happens when users connect and disconnect. use Flash Professional. you need a camera and a microphone to capture the video and audio. The file is named either main. A typical Flash Media Server application has these parts: Client user interface The client displays a user interface. and RAW. such as controls to start. or myApplication. or Flash Lite 3. client to server. MPEG-3 (MP3). to develop and test applications. The user interface can run in Flash Player. You can use server-side code to control access to applications.1 Chapter 1: Getting started building applications Parts of a media application The client application is written in ActionScript™ and compiles to a SWF file. A media application usually has recorded or live audio and video that it streams from server to client.asc. stop.0.

3 Do one of the following: • Install Flash Professional from www. and sends it to Flash Media Server.com.com/go/flash. If you see an ActionScript Class Warning message about a missing definition—click OK.adobe. the client displays the string sent from the server.0 DEVELOPER’S GUIDE Getting started building applications 2 If you have an account with a Flash Media Server solution partner. b Download and install Adobe Flash Media Live Encoder from www. The sample files are in the rootinstall\documentation\samples\HelloWorld folder.0). 2 Verify that the server is installed successfully.adobe. • Install Flash Builder from www. Click User Interface and double-click Button to add it to the Stage. Last updated 8/30/2010 . The client calls a server-side function that returns a string. This sample shows simple communication from the client to the server and back again.adobe. When a user clicks a button. You can also build custom applications that capture and encode audio and video. the client connects to the server. 3 Choose Windows > Components. • Install the Flex SDK from opensource. When the server replies. do the following: a Connect a camera and a microphone to the computer. enter the instance name connectBtn. Note: Flash Media Live Encoder captures audio and video. On the Properties tab. 4 Add a Label component above the button.fla. You will add the class file in the next section. 4 To capture and encode live video. enter HelloWorld. 2 In the Document Class field.com/go/fmle. Create the user interface 1 Start Flash and select Create New > Flash File (ActionScript 3.com/go/flashbuilder. You can save the client files to any location. and give it the instance name textLbl. encodes it. Example: Hello World application Overview Note: The following sections do not apply to Flash Media Streaming Server because you cannot write server-side code for that server edition.adobe. the partner tells you how to configure your development environment to use their resources.FLASH MEDIA SERVER 4. 5 Save the file as HelloWorld. Set up a development environment: 1 Run the Flash Media Server installer to install the server.

4 Define the class constructor. connectBtn.fla file. // Close the connection.. which triggers a response that displays the returned string (“Hello. flash.as to the same folder as the HelloWorld. either connecting to or disconnecting from the server. Set the label and button display values. 2 Declare the package and import the required Flash classes: package { import import import import import public } } flash.call("serverHelloMsg". flash.0 DEVELOPER’S GUIDE Getting started building applications 3 Write the client-side script This script provides two button actions.. connectBtn.fla. flash.NetStatusEvent."). 1 Choose File > New > ActionScript File.net.. nc.connect("rtmp://localhost/HelloWorld"). } else { trace("Disconnecting.NetConnection.events.text = "". private var myResponder:Responder = new Responder(onReply).close().text = String(result). which sets the label’s display value: private function onReply(result:Object):void { trace("onReply received value: " + result). } 7 Save the file as HelloWorld. myResponder. in HelloWorld.label = "Connect".events. } } 6 Define the responder function. connectBtn. } 5 Define the event listener actions.asc. // Connect to the server.FLASH MEDIA SERVER 4. World!”). connectBtn. Last updated 8/30/2010 . declare variables for the connection and the server responder: private var nc:NetConnection. nc = new NetConnection().MouseEvent. and add an event listener to the button: public function HelloWorld() { textLbl. textLbl. textLbl.text = "". connectHandler).label = "Disconnect"."). // Call the server's client function serverHelloMsg.CLICK. nc.addEventListener(MouseEvent. When connecting.net.label == "Connect") { trace("Connecting.. flash. class HelloWorld extends MovieClip { 3 Inside the HelloWorld class declaration. "World"). nc.display. the script calls the server with a string (“World”). Check that the Target box has HelloWorld. which depend on the button’s current label: public function connectHandler(event:MouseEvent):void { if (connectBtn.Responder.MovieClip.label = "Connect".

4 Click the Connect button. “Hello. 5 Click the Disconnect button. you can easily add a pre-built media player to the application.0 DEVELOPER’S GUIDE Getting started building applications 4 Write the server-side script 1 Choose File > New > ActionScript Communications File. (Create the “HelloWorld” folder when you save the file.fla file tab. About OSMF Strobe Media Playback is based on OSMF. The player is located in the rootinstall\samples\videoPlayer\swfs\ directory. " + helloStr + "!". The output of the trace() statements is displayed in the Flash Output window. } 3 Save the file as HelloWorld. 3 Choose Control > Test Movie. You can use this player in your own applications. OSMF includes support for the following: • DVR functionality • Cue points • Seek during live streams • Buffer management • Switching management Last updated 8/30/2010 . The Adobe Flash Media Server Start Screen uses Strobe Media Playback to display videos. 2 Define the server-side function and the connection logic: application.) Compile and run the application 1 Verify that the server is running.acceptConnection( client ). which is based on OSMF (Open Source Media Framework). you must use ActionScript to create the interactivity you need.serverHelloMsg = function( helloStr ) { return "Hello. Creating an application Using a pre-built media player To build a social application.onConnect = function( client ) { client. To simply stream media. OSMF is a library of components for video players. } application. Flash Media Server includes Strobe Media Playback. or use media player components to construct your own player.asc in the rootinstall/applications/HelloWorld folder. World!” is displayed. 2 Select the HelloWorld. and the button label changes to Disconnect.FLASH MEDIA SERVER 4.

The file is located at rootinstall\samples\videoPlayer\videoplayer. For more information about OSMF. 8 Open your HTML file in a browser. and other video assets. change this: serverURL=rtmp:/vod/mp4:sample1_150kbps. or in a location recognized by your Flash Media Server web server. Supported plug-ins include: • Chrome library (for skinning) • VAST and MAST advertising libraries • Captioning • SMIL parsing (for dynamic streaming) • MRSS/ATOM syndication feed parsing • Akamai CDN connection samples You can build your own player with the OSMF library.f4v 6 Place the HTML page in the rootinstall/webroot folder. 7 Deploy your video file to the specified location. For more information. To serve a different video. you can browse to the file in your Flash Media Server installation and open it in a browser. see www.f4v To this: serverURL=rtmp:/vod/myvideos/mp4:mySampleVideo. 3 Find the section on the page labelled “Embed Code”. This updates the code that you will be copying. to point to a video called “mySampleVideo”. If you are running the Flash Media Server web server. 5 Paste this code into your HTML file. be sure to also add an appropriate SMIL file. The code begins and ends with <object> tags.org. Note that the serverURL parameter appears twice in the code block. Last updated 8/30/2010 .0 DEVELOPER’S GUIDE Getting started building applications 5 • Subclips • Pre-assigned durations • Layout APIs for media regions inside the player and in external HTML • Metadata-driven experiences and dynamic playlists (enables ads and recommendations) OSMF’s architecture also supports plug-ins.osmf. For example. It adds the URL of the video file to the code. change the value of the serverURL parameters to point to your FLV file. see Building streaming video players in Flash with the Adobe Open Source Media Framework.html. Embed Strobe Media Playback in your HTML file To embed Strobe Media Playback in your HTML file: 1 Open the Adobe Flash Media Server Sample Video Player page in a browser. you can request the Sample Video Player page with a URL similar to the following (depending on how Apache is configured): http://localhost:8134/samples/videoPlayer/videoplayer.FLASH MEDIA SERVER 4. 4 Copy the code from the TextArea at the bottom of the page.html Otherwise. 2 Select a video to play. If you are using dynamic streaming.

0. The server-side code would be in a file called main.0. For example. The server-side code goes at the top level of the application directory.asc or yourApplicationName. While these pre-built components do not include support for all OSMF features. handles events. Connect to other servers By calling a web service or creating a network socket to an application server or database. applications require server-side code written in Server-Side ActionScript if they need to do any of the following: Authenticate clients By user name and password. It is a skinnable video player that supports progressive download.0 DEVELOPER’S GUIDE Getting started building applications 6 Use OSMF-based Flex components If you use Flash Builder or the Flex framework to build your application.asc or skatingClips. • VideoDisplay — The spark. • Flash Help Resource Center at www.FLASH MEDIA SERVER 4. to create an application called skatingClips.VideoDisplay component is also based on OSMF. you can use ActionScript 3. Handle streams By allowing you to play. see “Writing server-side code” on page 6.0 or 2. you can use a pre-built media player. and does other work. create the folder rootinstall/applications/skatingClips.asc in the skatingClips folder. or by credentials stored in an application server or database.components. Writing client-side code A client has code written in ActionScript that connects to the server. For example. Implement connection logic By taking some action when a client connects or disconnects. Working in Flash Professional.components. record. and streaming video. For more information.com/devnet/flash. and manage streams sent to and from the server.VideoPlayer component is based on OSMF. see the following resources: • To simply stream media. It is useful when you do not want the user to interact with the control. • To build a social media application. see “Using a pre-built media player” on page 4. • Flex Help Resource Center at www.adobe.com/devnet/flex. Update clients By calling remote methods on clients or updating shared objects that affect all connected clients.adobe. Place the server-side code in a file named main. More Help topics “Copy client-side files to a web server” on page 11 Writing server-side code In general.asc. For information about learning ActionScript and working with video. you can use one of the following pre-built components for media playback: • VideoPlayer — The spark. Flash Builder and the Flex SDK use ActionScript 3. you can extend them as you would any other Spark component. It is a chromeless version that does not support skinning. or in its scripts subdirectory. you can use either of these locations: rootinstall/applications/appName rootinstall/applications/appName/scripts Last updated 8/30/2010 . where yourApplicationName is a folder in the rootinstall/applications folder. multi-bitrate streaming.

An application can have thousands of clients connected. edit the fms. on Windows).ini file.ini or the Vhost. Each application also has a single application object. shut down the application. Select Enable Double-Byte Online Input to enable double-byte text. obj. Use built-in JavaScript methods. such as Date.asc file that is UTF-8 encoded.xml configuration file. In the Vhost.toLocaleString(). the server creates an instance of the server-side Client class to represent the client. 2 Change the inline input setting by selecting Edit > Preferences (Windows) or Dreamweaver > Preferences (Mac OS). However. edit the following parameter: VHOST.xml file. More Help topics “Copy server-side script files to the server” on page 10 Client and application objects Server-side scripts have access to two special objects. In the fms. not the dot operator: // This is the CORRECT way to create double-byte method names obj["Any_hi_byte_name"] = function(){} // This is the INCORRECT way to create double-byte method names. edit the AppsDir element. the client object and the application object. Use a JavaScript editor. and so on. to convert the string to the locale encoding for that system. You can use it to accept clients. and then click General. Some simple text editors might not encode files to the UTF-8 standard. disconnect them. Use double-byte characters as method names ❖ Assign method names using the object array operator. In your server-side code. such as the Script window in Flash or Adobe® Dreamweaver®.Any_hi_byte_name = function() {} Last updated 8/30/2010 . then Document Encoding. the applications folder is in the root installation folder (C:\Program Files\Adobe\Flash Media Server 4\applications. you can use the client object to send and receive messages to individual clients.APPSDIR = C:\Program Files\Adobe\Flash Media Server 4\applications.FLASH MEDIA SERVER 4. which is an instance of the server-side Application class. some editors provide a Save As option to encode files in the UTF-8 standard. that encodes files to the UTF-8 standard. When a client connects to an application on Flash Media Server. The application object represents the application instance. Writing double-byte applications If you use Server-Side ActionScript to develop an application that uses double-byte text (such as an Asian language character set). place your server-side code in a main.0 DEVELOPER’S GUIDE Getting started building applications 7 By default. To configure the location of the applications folder. Set UTF-8 encoding in Dreamweaver 1 Check the document encoding setting by selecting Modify > Page Properties. Choose Unicode (UTF-8).

When a client connects to an application on the server. To load an application directly from the Administration Console. To open the Administration Console.FLASH MEDIA SERVER 4.5 > Flash Media Administration Console. Note: When you edit and save an . step into functions. shared objects. and so forth. For each application instance. if any. use trace() statements to monitor each processing point. the application is loaded and can be seen in the Administration Console. choose Start > All Programs > Adobe > Flash Media Server 3. you can observe its live log. use trace() statements to monitor each processing point. then connect to the application again. clients. select from the New Instance list of available application names. The output is shown in the Flash Output window (this example is from the “Example: Hello World application” on page 2): To debug a client-side script. You can inspect the state of the script with Windows > Debug Panels. use the Debug menu in Flash to set breakpoints.asc file. Use the Administration Console to restart the application. and performance statistics. all clients are disconnected. the changes do not take effect until the application is restarted. streams in use. Test and debug a server-side script To test a server-side script.0 DEVELOPER’S GUIDE Getting started building applications 8 Test an application Test and debug a client-side script To help test a client-side script. View the output of trace() statements in the Live Log in the Administration Console. Last updated 8/30/2010 . You can also stop an application or reload it—in either case.

00 for the most recent log file. You can view a log file with any text editor. By default. then Live Log. The availability and number of debugging sessions is set in the AllowDebugDefault and MaxPendingDebugConnections elements of the Application. Last updated 8/30/2010 . Note: Set allowDebug to false before deploying the application. While an application is running.xml file.asc file is sent to the following log file: rootinstall/logs/_defaultVHost_/yourApplicationName/yourInstanceName/application.0 DEVELOPER’S GUIDE Getting started building applications 9 The Administration Console checking the performance of an application while it is running View the output of a server-side script The output of the trace() statements in a main. 2 Choose View Applications.xx. 01 for the previous instance. if any. In the Administration Console opens. click View Applications. Debug with the Administration Console To playback streams and inspect data about shared objects.FLASH MEDIA SERVER 4.allowDebug = true. debugging is not allowed. and so on.xml configuration file.log Where yourInstanceName is _definst_ by default and xx is the instance number. you can view the Live Log in the Administration Console. 3 Select the application to debug from the list or choose New Instance and create a new instance of an application. add the following code to an application’s serverside code: application. 4 Press the Streams button to see the list of playing streams. an application must make a special debug connection to the Administration Console. To override the debug setting in the Application. To start a debugging session: 1 Open the Administration Console.

the following folder creates an instance of myApplication called “room1”: rootinstall/applications/myApplication/room1.com/myApplication/room1"). 10 Press the Close Debug button to end the debug session.xml configuration file. edit the AppsDir element. Every application must have a folder in the applications folder. This process is called registering the application with the server.ini file. on Windows).examples. edit the fms. for an application called “videoPlayer”.0 DEVELOPER’S GUIDE Getting started building applications 10 5 Click on one of the streams. For example. Last updated 8/30/2010 . To create instances of an application.asc file to rootinstall/applications/videoPlayer.ini or the Vhost. For example.APPSDIR = C:\Program Files\Adobe\Flash Media Server 4\applications. then use the Administration Console to restart the application. Deploy an application Register an application with the server To connect to an application.xml file. To register an application with the server. create subfolders. For example.FLASH MEDIA SERVER 4. By default. edit the following parameter: VHOST. create the following folder to register an application called “myApplication”: rootinstall/applications/myApplication The client-side code that connects to the application looks like the following: myNetConnection.connect("rtmp://fms. 7 A pop-up window will open and the stream will play.examples. create a folder for the application in the applications folder.xml file. you can use either of these locations: rootinstall/applications/appName rootinstall/applications/appName/scripts Note: To replace a running application. the application folder contains the server-side script and any media assets. copy the main.connect("rtmp://fms. if any. 9 Select a shared object. You can also place server-side scripts in “scripts” subfolder. It can also contain an application-specific Application. 8 Press the Shared Objects button to see the application’s shared objects. In the Vhost. 6 Press the Play Stream button. Copy server-side script files to the server Copy server-side script files for an application to the folder you registered on the server. the applications folder is in the root installation folder (C:\Program Files\Adobe\Flash Media Server 4\applications. the server must know that the application exists. Usually. The client-side code that connects to the application instance looks like the following: myNetConnection. copy the new files. To configure the location of the applications folder. but the folder can also be empty.com/myApplication"). In the fms. For example.

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Getting started building applications

11

Packaging server-side files
Flash Media Server includes a command-line archive compiler utility, far.exe, which lets you package server-side scripts into a FAR file, which is an archive file like a ZIP file, to simplify deployment. You can also use the archive compiler utility to compile server-side script files to bytecode (with the file extension .ase) to speed the time required to load an application instance. A large application can contain multiple server-side script files stored in different locations. Some files are located in the application directory and others are scattered in the script library paths that are defined in the server configuration file. To simplify deployment of your media application, you can package your server-side JS, ASC, and ASE files in a self-contained Flash Media Server archive file (a FAR file). The FAR file is a package that includes the main script file (which is either main.js, main.asc, main.ase, applicationName.js, applicationName.asc, or applicationName.ase) and any other script files that are referred to in the main script. The syntax for running the archive compiler utility to create a script package is as follows:
c:\> far -package -archive <archive> -files <file1> [<file2> ... <fileN>]

The following table describes the command-line options available for far -package.
Option -archive archive -files file1 [ file2 ... fileN ] Description Specifies the name of the archive file, which has a .far extension. Specifies the list of files to be included in the archive file. At least one file is required.

Note: If the main script refers to scripts in a subdirectory, the hierarchy must be maintained in the archive file. To maintain this hierarchy, Adobe recommends that you run the FAR utility in the same directory where the main script is located.

Copy media files to the server
Copy video and audio files to the streams/_definst_ folder in the application folder: rootinstall/applications/someapplication/streams/_definst_/ If an application connects to an instance of the application, for example,
nc.connect("rtmp://fms.example.com/someapplication/someinstance"), place the streams in the following

folder: rootinstall/applications/someapplication/streams/someinstance/ There are several ways to configure the server to look for media files stored in other locations. For example, the vod streaming service that installs with the server is configured to look for media files in the rootinstall/applications/vod/media folder.

More Help topics
“Streaming on-demand media” on page 15

Copy client-side files to a web server
You can deploy SWF files and HTML files on any web server. The SWF file contains the NetConnection.connect() call that connects to the application on Flash Media Server. The HTML file is a container for the SWF file. For more information, see the Flash documentation at www.adobe.com/support/flash.

Last updated 8/30/2010

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Getting started building applications

12

For more information about deploying AIR applications, see the Adobe AIR documentation at www.adobe.com/support/air. By default, Flash Media Server 3.5 and later install with Apache HTTP Server. If you installed and enabled the web server, you can deploy SWF files and HTML files from the same computer on which Flash Media Server is installed. You can also deploy JPG, GIF, and many other file types. For a complete list of the file types Apache serves by default, see the rootinstall/Apache2.2/conf/httpd.conf file. By default, Apache is configured with the following aliases:
Alias / /cgi-bin/ Path rootinstall/webroot rootinstall/Apache2.2/cgi-bin

To serve files over HTTP, place the files in the rootinstall/webroot folder or an appropriate subfolder. To serve CGI programs, place the files in the rootinstall/Apache2.2/cgi-bin folder. You can also add subfolders to these folders. Subfolders cannot use the following names from the fmshttpd.conf file: icons, error, SWFs, vod, or cgi-bin. In addition, subfolder names cannot use the following reserved words: open, send, idle, fcs, fms. By default, Apache is configured to serve all HTTP content from the rootinstall/webroot folder. If you want to provision the server to serve files from application-specific directories, edit the httpd.conf Apache configuration file.

Last updated 8/30/2010

13

Chapter 2: Streaming services
About streaming services
All editions of Flash Media Server version 3 and later provide two streaming services: live and vod. The live service streams live video. The vod service streams recorded video (video on demand). The live and vod services are signed by Adobe. Flash Media Streaming Server only supports signed services—it cannot run other applications. Other server editions support signed services as well as any other applications you create. Services are implemented as server-side components of Flash Media Server applications. Sample clients for both services are installed with the server. You can modify the sample clients for production use or create your own. You cannot modify the server-side code in the streaming services. However, the services have a custom client-side API that you can use to call server-side methods. Both services can be duplicated and renamed to create multiple publishing points. The server can support an unlimited number of service instances. Flash Media Server 3.5 and later optionally installs with Apache web server. If you install Apache, you can serve clients over HTTP. You can also choose to serve media over RTMP and HTTP. Flash Media Server 4 and later install with two additional services: livepkgr and multicast. These services are not signed and cannot run on Flash Media Streaming Server.

Streaming live media
About the live service
The live service is a publishing point on Flash Media Server. The following live video sources can publish video to the live service:

• Flash Media Live Encoder, version 2.0 or later
Note: Flash Media Streaming Server does not support Flash Media Live Encoder Authentication Add-in.

• Server-side scripts running on Flash Media Enterprise Server, Flash Media Interactive Server, and Flash Media
Development Server (see “Publishing from server to server” on page 109)

• A custom-built Flash Player or AIR application
The following clients play video streamed from the live service:

• OSMF Sample Player • Flash Media Server sample video player (rootinstall/samples/videoPlayer) • Flash FLVPlayback component (fl.video.FLVPlayback) • Flex VideoDisplay component (mx.controls.VideoDisplay) • Any custom-built application that runs in Flash Player, AIR, or Flash Lite 3

Last updated 8/30/2010

FLASH MEDIA SERVER 4. • If you installed Apache web server with Flash Media Server. Click Interactive to open the live video sample. 2 Do one of the following: • If you’re using the default applications/live folder. If Flash Media Live Encoder is installed on the same computer as the server. browse to http://localhost/ and click Interactive to open the live video sample. Copy the RootInstall/samples/applications/live main. Flash Media Live Encoder publishes a stream named livestream to rtmp://localhost/live. Modify the live service Note: You cannot modify the live service on Flash Media Streaming Server 1 Create a folder in the RootInstall/applications folder or use the default RootInstall/live folder. and click PLAY STREAM. Last updated 8/30/2010 .asc file to the applications/live folder. click “livestream”. 2 Do one of the following: • Choose Start > All Programs > Adobe > Flash Media Server 4 > Flash Media Server Start Screen. use these settings to connect to the live service . • Click Publish. Use a custom Flash Player application to use the live service 1 Connect a camera to the computer. live2. move the main. 2 Clients can connect to the publishing point at the URL rtmp://flashmediaserver/live2.0 DEVELOPER’S GUIDE Streaming services 14 On Flash Media Streaming Server. In this case. You can also modify the live service to allow live stream recording. do one of the following: • In the list videos. If Flash Media Live Encoder is installed on a different computer. By default. 3 Double-click the RootInstall/samples/videoPlayer/videoplayer. you can modify the live service source code to create your own applications that include DVR functionality.far file to a safe location.html file to open the sample video player in a browser. the live service cannot record streams and does not support DVR features. the new live service is located here: RootInstall/applications/live2. Use the live service Use Flash Media Live Encoder to use the live service 1 Connect a camera to the computer. Duplicate the live service 1 Duplicate the RootInstall/applications/live folder in the applications folder and give it a new name. If you're using one of these server editions. • Enter rtmp://localhost/live/livestream. check the LIVE checkbox. You can create as many instances of the live service as you need. 2 Open Flash Media Live Encoder and click Start. Other server editions support unsigned (user-created) applications. for example. 4 In the sample video player. replace localhost with the Flash Media Server IP address.

flv rtmp://serverName/live/live_recorded/fileName rtmp://serverName/live/live_recorded/fileName. copy media files to the following locations: • To stream files over RTMP only. allowedHTMLdomains.asc. copy files to RootInstall/applications/vod/media.controls.VideoDisplay) • Any custom-built application that runs in Flash Player.f4v rtmp://serverName/live/live_recorded/mp4:fileName rtmp://serverName/live/live_recorded/mp4:fileName.f4v FLV http://serverName/live_recorded/fileName. By default.txt.ini file in a text editor and edit the LIVE_DIR parameter to point to the folder you created in step 1.FLVPlayback) • Flex VideoDisplay component (mx. You can use any of the following clients to play video streamed from the vod service: • Flash Media Server sample video player (RootInstall/samples/videoPlayer) • Flash FLVPlayback component (fl.txt files from the RootInstall/samples/applications/live folder to the new folder. or Flash Lite 3 Last updated 8/30/2010 .xml.0 DEVELOPER’S GUIDE Streaming services 15 • If you created a folder in step 1. The <Streams> tag specifies a virtual directory mapping for streams. Streaming on-demand media Streaming media from the vod service The vod (video on demand) service lets you stream recorded media to clients without building an application or configuring the server.FLASH MEDIA SERVER 4. set the LIVE_DIR parameter to RootInstall\webroot\live_recorded. Disable live services ❖ Move any live services folders out of the applications folder. AIR. and allowedSWFdomains. copy files to RootInstall/webroot/vod.flv The Application. Recordings in this folder are available from the following addresses: File format F4V Address http://serverName/live_recorded/fileName. 3 Open the RootInstall/conf/fms. Simply copy recorded media files to the server and clients can stream them. install Apache. Note: To serve files over HTTP. • To stream files over RTMP and allow progressive download over HTTP.xml file in the folder you created in step 1 uses the LIVE_DIR parameter in a <Streams> tag. copy the main. To make recordings of live streams available over HTTP or RTMP. 4 Restart the server. Application.video.

the client does not connect to the vod application. Vod service configuration parameters Two parameters in the RootInstall/conf/fms. Log in to the server to see the vod service running.FLASH MEDIA SERVER 4.f4v FLV http://serverName/vod/fileName.f4v rtmp://serverName/vod/mp4:fileName rtmp://serverName/vod/mp4:fileName. If you installed Apache.xml file. you can stream media over RTMP and HTTP. The following table lists the possible addresses based on file format and protocol: File format F4V Address http://serverName/vod/fileName.xml file in the RootInstall/applications/vod folder uses these parameters in <Streams> tags to specify virtual directory mappings for streams. do one of the following: • To stream media over RTMP only. 2 Click any video in the SOURCE: /applications/vod/media list or in the SOURCE: /webroot/vod list.ini file determine the locations of the media folders for the vod application: VOD_COMMON_DIR = C:\Program Files\Adobe\Flash Media Server 4\webroot\vod VOD_DIR = C:\Program Files\Adobe\Flash Media Server 4\applications\vod\media The Application.flv rtmp://serverName/vod/fileName rtmp://serverName/vod/fileName.flv Note: To use localhost as the serverName for HTTP. Apache serves the video to the client.html file to open the sample video player in a browser. • If you installed Apache and want to serve media over RTMP or HTTP. place video files in the RootInstall/webroot/vod folder. and click PLAY STREAM. 4 Enter the address of the video in the STREAM URL text box. place media files in the folder specified in the VOD_DIR parameter. 5 Choose Start > All Programs > Adobe > Flash Media Server 4 > Flash Media Administration Console to open the Administration Console. append the port number 8134. Instead. 3 To stream your own videos to the video player. Place media files in the folder specified in the VOD_COMMON_DIR parameter.0 DEVELOPER’S GUIDE Streaming services 16 Test the vod service 1 Double-click the RootInstall/samples/videoPlayer/videoplayer. Note: When you play a video over HTTP. for example. place files in the RootInstall/applications/vod/media folder.f4v. To stream media over RTMP only. The server uses port 8134 internally for HTTP. Media files are available at the following addresses: Last updated 8/30/2010 . check VOD. http://localhost:8134/vod/video. The server looks for media in the order the <Streams> tags are listed in the Application.

ini file.flv rtmp://serverName/vod/fileName rtmp://serverName/vod/fileName. add a new VOD2_COMMON_DIR parameter: VOD2_COMMON_DIR = C:\Program Files\Adobe\Flash Media Server 4\webroot\vod2. Application. • Place files that stream over RTMP or HTTP in the C:\Program Files\Adobe\Flash Media Server 4\webroot\vod2.ini file (located in RootInstall/conf) and do the following: • Add a parameter to set the content path for the new service. • If you created a folder in step 1. = C:\Program • If you installed Apache and want the media files to be available over HTTP. • Edit the virtual directory to the following: <Streams>/.${VOD2_COMMON_DIR}</Streams>. 1 Duplicate the RootInstall/applications/vod folder in the applications folder and give it a new name. allowedHTMLdomains. the new vod service is located at RootInstall/applications/vod2. for example.xml file in the RootInstall/applications/vod2 folder and do the following: • Edit the virtual directory to the following: <Streams>/.f4v rtmp://serverName/vod/mp4:fileName rtmp://serverName/vod/mp4:fileName.${VOD2_DIR}</Streams>. Modify the vod service Note: You cannot modify the vod service on Flash Media Streaming Server 1 Create a folder in the RootInstall/applications folder or use the default RootInstall/vod folder.FLASH MEDIA SERVER 4. Note: You do not have to specify the media subdirectory in the URL. 4 Open the Application.f4v FLV http://serverName/vod/fileName. 5 Place recorded media files into the following locations: • Place files that stream only over RTMP in the C:\Program Files\Adobe\Flash Media Server 4\applications\vod\media folder.asc file to the applications/vod folder.txt. copy the main. 2 Clients can connect to the vod service at the URL rtmp://flashmediaserver/vod2. vod2. 3 Open the fms. In this case. the media directory is specified in the path you set in the fms. move the main. Copy the RootInstall/samples/applications/vod main.flv Duplicate the vod service The server supports an unlimited number of instances of the vod service.far file to a safe location.0 DEVELOPER’S GUIDE Streaming services 17 File format F4V Address http://serverName/vod/fileName.ini file in a text editor and edit the VOD_DIR parameter and the VOD_COMMON_DIR parameter to point to the correct locations. and allowedSWFdomains. Last updated 8/30/2010 .xml.txt files from the RootInstall/samples/applications/vod folder to the new folder. for example: VOD2_DIR Files\Adobe\Flash Media Server 4\applications\vod2\media. 2 Do one of the following: • If you’re using the default applications/vod folder.asc. You can create as many instances of the vod service as you need. 3 Open the RootInstall/conf/fms.

external XML file support Download the media player and its documentation from osmf. The video player lets you see video streaming from the server immediately after installation. set the isLive parameter to true. control bar position • Skinning support.0. The component supports progressive download over HTTP. a media player based on the Open Source Media Framework (OSMF). live streaming. and streaming from a Camera object. and content protection with Adobe® Flash® Access™ 2. streaming services expect the NetConnection. Creating clients for signed streaming services Using the sample video player The Flash Media Server Start Screen includes an embedded video player. auto-loop • Scaling method. Connecting to a streaming service Like all Flash Media Server applications. Use HTML embed tags to control the following: • Height and width of the video image • Play button overlay.FLASH MEDIA SERVER 4. streaming from Flash Media Server. RTMP streaming. auto-play. Do not include the /media folder in the path. set the live parameter to true. For example. Disable vod services ❖ Move any vod service folders out of the applications folder. available since Flash 8. poster frame • Auto-hide. as a client for the vod and live services. The sample video player is Strobe Media Playback. Use the code provided on the Start Screen to embed the video player in your own application.0 DEVELOPER’S GUIDE Streaming services 18 4 Restart the server.flv.org.connect() URI to be in the following format: Last updated 8/30/2010 . To connect to the live service. You can set parameters in the Component inspector or in ActionScript. To stream live video. Using the Flex VideoDisplay component You can use the Flex VideoDisplay control to play an FLV or F4V file in a Flex application. Do not include the /media folder in the path. For example. the following is the path to a sample file: rtmp://localhost/vod/sample. It comes with a predefined user interface and supports progressive download. HTTP Dynamic Streaming. Set the source parameter to the full URL of the stream. Using the Flash FLVPlayback component You can use the FLVPlayback component. Set the source parameter (or contentPath parameter in ActionScript 2. the following is the path to a sample file: rtmp://localhost/vod/sample. Set the source (or contentPath) parameter to the URL of the stream.0) to the full URL of the stream.

By default.115.asc. Access raw audio and video data Note: Flash Media Streaming Server supports this feature through the Access plug-in only. edit the allowedHTMLdomains.draw() and SoundMixer. fileOrStreamName Either a filename (for example.0.txt file. clients can connect to the live and vod services from any domain. such as room1.mp4. if the file on the server uses a filename extension (. To access the data. see ActionScript 3.f4v. ❖ Navigate to the RootInstall/applications/live or RootInstall/applications/vod folder and do one of the following: • To add a domain for SWF clients.getRemote()). specify it. you can access raw audio and video data in streams. instanceName If the client is connecting to the default instance.0 DEVELOPER’S GUIDE Streaming services 19 rtmp://hostName/serviceName/[formatType:][instanceName/]fileOrStreamName hostName The Flash Media Server domain name. mp3:. Beginning with Flash Media Server 3 and Flash Player 9. serviceName Either live or vod.com/vod/mp4:ClassicFilms/AnOldMovie. You cannot edit FAR files.examplemediaserver. More Help topics “Signed streaming services API” on page 20 Allow connections from specific domains By default.mp4).0 BitmapData.computeSpectrum() methods. formatType For mp3 files.txt file. If the client is connecting to an instance you have created. • To add a domain for HTML clients. edit the allowedSWFdomains. specify it. the services do have a custom API that lets you access information from the server. Flash Media Server prevents you from accessing streams. For MP4/F4V files.0. Unsupported features Clients for the vod and live services can use any Flash Player features except remote shared objects (SharedObject. subdir/subdir2/my_video. Last updated 8/30/2010 . The TXT files contain detailed information about adding domains. for example.far file from rootinstall/applications/live or rootinstall/applications/vod to rootinstall/samples/applications/live or rootinstall/samples/applications/vod. To allow stream access. use that name. so you must replace main.call() method from client-side code and pass it the name of the API you want to call. Not required for FLV files. For MPEG-4-based files. do the following: 1 Move the main. Use this data to create snapshots in your applications. For more information. my_video.far with main. you can either omit the instance name or use _definst_. call the ActionScript 3.mp4. You can limit the domains from which clients can connect. Call the NetConnection.0 Reference for Flash Platform. rtmp://www. . If the stream is live and the publisher specified a filename extension. and so on).FLASH MEDIA SERVER 4.mp4) or a path (for example. You cannot edit the server-side code for streaming services. mp4:. However.

html. live streaming service Last updated 8/30/2010 .com/trace.asc file from rootinstall/samples/applications/live or rootinstall/samples/applications/vod to rootinstall/applications/live or rootinstall/applications/vod. returnObj. in seconds.html) are not displayed. vod streaming service Parameters streamObj A Stream object. getPageUrl returns: http://www. Example The following client-side code gets the length of the sample_video stream and returns the value to returnObj: nc. Call this method from a client-side script and specify a response object to receive the returned value.0 DEVELOPER’S GUIDE Streaming services 20 2 Copy the main. local file address (for example. Returns A number. vod streaming service.example. //p_client.html // trace.videoSampleAccess = "/".audioSampleAccess = "/".swf The value must be an HTTP address. 5 Save the main.asc file.com/trace. getPageUrl() getPageUrl() Returns the URL of the web page in which the client SWF file is embedded.swf file is embedded in trace. The following code shows the two examples: // trace. If the SWF file isn’t embedded in a web page. 4 Uncomment the following code to allow all clients to access all streams: //p_client.example. getPageUrl returns: http://www.asc file in a text editor. Availability Flash Media Server 3. 3 Open the main. file:///C:/Flash Media Server applications/example. For security reasons.call("getStreamLength".FLASH MEDIA SERVER 4. "sample_video"). the value is the location of the SWF file.swf is not embedded in an HTML file. Availability Flash Media Server 3. Signed streaming services API getStreamLength() getStreamLength(streamObj) Returns the length of a stream.

Fash Player 10.8. The Live Packager service ingests streams. AIR 2 About the HTTP Live Packager service Important: The Live Packager service (rootinstall/applications/livepkgr) is not signed by Adobe. live streaming service Example The following code calls the getReferrer() method on the server: myNetConnection. A client cannot seek to a forward location until that location and all the data before it has downloaded. When content streams over HTTP.0 DEVELOPER’S GUIDE Streaming services 21 Example The following example calls the getPageUrl() method on the server: nc. vod streaming service. and Adobe® Flash® Access™ protection. Availability Flash Media Server 3. Last updated 8/30/2010 . clients can seek quickly to any location. Streaming media over HTTP Flash Media Server 3. returnObj).FLASH MEDIA SERVER 4. HTTP Dynamic Streaming supports multibitrate streaming. Adobe HTTP Dynamic Streaming contains several components that work together to package media and stream it over HTTP to Flash Player.1.call("getPageUrl". About HTTP Dynamic Streaming Delivering content over HTTP is usually called “progressive download”. The content must transfer from the server to the client in a progression from the beginning to the end of a file. HTTP Dynamic Streaming packages media files into fragments that Flash Player clients can access instantly without downloading the entire file. and delivers them to Flash Player over HTTP in real-time. regardless of how much data has been transferred. HTTP Dynamic Streaming combines these approaches to introduce HTTP streaming to the Flash Platform. getReferrer() getReferrer() Returns the URL of the SWF file or the server where the connection originated. The HTTP Live Packager service is a Flash Media Server application that is a component of HTTP Dynamic Streaming. The client creates a socket connection to the server (such as Flash Media Server) over which the content is sent in a continuous stream. The HTTP Live Packager service installs to rootinstall/applications/livepkgr. returnObj). The service does not run on Flash Media Streaming Server.call("getReferrer". packages them into F4F fragments. The client can seek to any point in the content instantly. Adobe® HTTP Dynamic Streaming is a solution that streams live and on-demand content over HTTP to Flash Player. DVR. Delivering content over RTMP is called “streaming”.

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Streaming services

22

HTTP Dynamic Streaming components
The Adobe HTTP Dynamic Streaming solution contains the following components:
Live Packager for HTTP Dynamic Streaming Live Packager for HTTP Dynamic Streaming is part of Adobe Flash Media Server 3.8 and later. The server ingests a live stream over RTMP and the Live Packager translates it into F4F files in real-time. The built-in Apache HTTP Server uses the HTTP Origin Module to deliver the live content over HTTP. HTTP Origin Module An Apache HTTP Server module that serves the on-demand files created by the File Packager

and the live streams created by the Live Packager. For more information, see Apache configurations for HTTP Dynamic Streaming. The HTTP Origin Module installs with Flash Media Server 3.8 and later and is available from adobe.com.
File Packager A command-line tool that translates on-demand media files into fragments and writes the fragments to F4F files. The File Packager is an offline tool. You can use the File Packager to encrypt files for use with Flash Access. For more information, see Packaging on-demand media.

The File Packager is located in the rootinstall/tools/f4fpackager folder and is available from adobe.com.
OSMF media players There are two media players built on the Open Source Media Framework (OSMF) that support

HTTP Dynamic Streaming. Download OSMF Sample Player for HTTP Dynamic Streaming and Strobe Media Playback from osmf.org.
F4F File Format Specification The F4F file format describes how to divide media content into segments and fragments. Each fragment has its own bootstrap information that provides cache management and fast seeking. For more information, see F4F File Format Specification. F4M File Format Specification The Flash Media Manifest file format contains information about a package of files that

the HTTP Origin Module can serve. Manifest information includes codecs, resolutions, and the availability of files encoded at multiple bit rates. Manifest information also includes DRM data. For more information, see F4M File Format Specification.
Flash Access Flash Access delivers protected media to Flash Player. To use HTTP Dynamic Streaming with Flash

Access, use the File Packager and Flash Media Server to both package and encrypt content. For more information, see Protecting content with Flash Access.

Use cases
The livepkgr service supports the following use cases:

• Live content • Live multi-bitrate content • Live content with DVR functionality • Live multi-bitrate content with DVR functionality
The livepkgr service also supports each of the previous use cases with Flash Access content protection.

Workflow
The following is the workflow for all HTTP live streaming use cases:
1 To configure the Live Packager to encrypt content for use with Flash Access, edit the Event.xml file. See “Event.xml

file” on page 33.
2 Create a crossdomain.xml file and copy it to the rootinstall\webroot folder.

A crossdomain.xml file allows Flash Player clients hosted on other domains to access data from this domain. For more information, see Website controls (policy files) in the ActionScript 3.0 Developer’s Guide.

Last updated 8/30/2010

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Streaming services

23

3 Publish a stream to the server.

See “Publish a stream to the Live Packager and associate the stream with a live event” on page 28.
4 Use the OSMF Sample Player or Strobe Media Playback to play the media in Flash Player 10.1.

See “Using the OSMF Player and Strobe Media Playback” on page 23

Using the OSMF Player and Strobe Media Playback
The OSMF Sample Player and Strobe Media Playback are video players built on the Open Source Media Framework (OSMF). Both players run in Flash Player 10.1 and support HTTP Dynamic Streaming. The players use the ActionScript 3.0 NetStream.appendBytes() API to deliver bytes to Flash Player. To use this API to create an HTTP Dynamic Streaming player, use the OSMF Sample Player as a reference implementation. However, OSMF is a robust framework designed to deliver high-quality video. Adobe strongly recommends using OSMF to build HTTP Dynamic Streaming players. Use Strobe Media Playback: Strobe Media Playback is built into the Flash Media Server sample video player at rootinstall/samples/videoPlayer/videoplayer.html. It’s also embedded in the Flash Media Server Start Screen at rootinstall/webroot/index.html. For more information about using Strobe Media Playback, see osmf.org. Download the OSMF Sample Player from the following locations:

• OSMF Sample Player for HTTP Dynamic Streaming • OSMF Sample Player source • Hosted OSMF Sample Player
To host OSMF Sample Player on a web server:
1 Download the OSMF Sample Player. 2 Copy the following files to a web server:

• OSMFPlayer.html • OSMFPlayer.swf • The \assets folder and the contained files. • The \images folder and the contained files. • The \scripts folder and the contained files.
To load media into the OSMF Sample Player from a URL:
❖ Click the Eject button, enter the URL, and click Enter.

The configuration of the HTTP Origin Module determines the format of the URL. For information about how to form a request URL, see “Understanding the request URL” on page 26. To test dynamic streaming in OSMF Sample Player:
1 Click “Q” to toggle between automatic and manual bitrate switching.

When the player is in manual mode, a + and - button display.
2 In manual mode, click + and - to increase and decrease the bitrate of the stream.

Last updated 8/30/2010

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Streaming services

24

More Help topics
“Example: Live HTTP Dynamic Streaming” on page 24

Protecting content with Flash Access
To deliver live content with HTTP Dynamic Streaming and protect it with Flash Access, use the following tools:

• Flash Access Server for Protected Streaming
This server is a Flash Access license server implementation optimized for use with HTTP Dynamic Streaming. See Adobe Flash Access Protecting Content. Note: The Flash Access SDK and the Flash Access license server reference implementation can also issue licenses for HTTP Dynamic Streaming.

• Live Packager for HTTP Dynamic Streaming (part of Flash Media Server)
Use this tool to packager content in real-time for live streaming. The certificates that you use with the Live Packager must match the license server. Important: Do not use the Flash Access packaging tools to encrypt content. The HTTP Dynamic Streaming packagers cannot fragment content that has already been encrypted. Use the HTTP Dynamic Streaming packagers to both encrypt and fragment content. Workflow for using Flash Access with live HTTP Dynamic Streaming
1 A camera captures a live event and sends the output to an encoder such as Flash Media Live Encoder. 2 The encoder sends a stream to the Live Packager for HTTP Dynamic Streaming which is part of Flash Media Server. 3 Configure the Live Packager to fragment and encrypt the content. The Live Packager processes the content in real

time. To configure the Live Packager to encrypt content, edit the Event.xml file. See “Event.xml file” on page 33.
4 The Live Packager outputs the fragmented and protected files needed for HTTP Dynamic Streaming. Each

fragment is persistently protected in both the CDN cache and the browser cache.
5 The OSMF Sample Player and Strobe Media Playback do the following: a Request the file fragments and play them back seamlessly. b Obtain a content license from Flash Access Server for Protected Streaming. The content license contains the key

required to play the content to legitimate clients.
c Decrypt the content in real-time.

Examples: packaging live content to deliver over HTTP
Example: Live HTTP Dynamic Streaming
Requirements To complete this tutorial, download the following software:

• Flash Media Live Encoder • OSMF Sample Player for HTTP Dynamic Streaming • Flash Player 10.1
Follow these steps to create your first end-to-end, live HTTP Dynamic Streaming application:
1 Install Flash Media Server 3.8 or later and choose to install Apache HTTP Server 2.2.

Last updated 8/30/2010

c Click the Eject button. c For Bit Rate."true" to enable this feature. enter livestream%i?adbe-live-event=liveevent&adbe-http-streaming-ver=1. enter rtmp://localhost/livepkgr.xml file. enter http://localhost/live/events/livepkgr/events/_definst_/liveevent. from the Preset pop-up menu. 4 To play the media in the OSMF Sample Player. Note: This value matches the <FragmentDuration> value in the applications/livepkgr/events/_definst_/liveevent/Event. choose 100. b Open a web browser and enter the address of the OSMF Sample Player: http://localhost/OSMFPlayer. d In the FMS URL text box. Example: Live HTTP Dynamic Streaming with DVR To add DVR capabilities to a live HTTP stream. a Close Flash Media Live Encoder.3 Streams (1500 Kbps) - H.html. Note: OSMF Sample Player requires Flash Player 10. complete the “Example: Live HTTP Dynamic Streaming” on page 24 but include two additional steps: 1 Complete Step 1 to install Flash Media Server. choose Multi Bitrate . b Open the Flash Media Live Encoder rootinstall\Conf\config. and press Enter on your keyboard. c Set the tag //flashmedialiveencoder_config/mbrconfig/streamsynchronization/enable to true: <flashmedialiveencoder_config> <mbrconfig> <streamsynchronization> <!-. For Keyframe frequency.0 DEVELOPER’S GUIDE Streaming services 25 2 Install Flash Media Live Encoder and configure it to use absolute time.264. e In the Stream text box. The <FragmentDuration> value is in milliseconds. Note: The applications/livepkgr/main. b Click the wrench next to Format to open Advanced Encoder Settings.asc file expects this value.--> <enable>true</enable> d Save the file. 3 To publish a live stream to Flash Media Server. "false" to disable. Note: This application is installed with Flash Media Server and contains a main. f Deselect Save to File. g Click Start. and \assets folders and their files). Note: These values match the <media bitrate> values in the applications/livepkgr/events/_definst_/liveevent/Manifest. \images.asc file and configuration files for live HTTP Dynamic Streaming.1.xml file.FLASH MEDIA SERVER 4. The webroot folder already contains an \images folder so copy the files from the OSMF Sample Player \images folder to the existing \images folder. start Flash Media Live Encoder and do the following: a In the Encoding Options panel. 200. Last updated 8/30/2010 .xml file in a text editor.0. select 4 seconds.f4m. do the following: a Copy the OSMF Sample Player files to the rootinstall\webroot folder (including the \scripts. and 350.

The name of the Flash Media Server application instance.FLASH MEDIA SERVER 4. <location-tag-alias> <fms-app-name> <fms-app-inst-name> <live-event-name> <live-stream-name> This tutorial uses multi-bitrate streaming. The F4M file is not written to disk. you may choose to publish a single stream instead. do the following: a Open the file rootinstall/applications/livepkgr/events/_definst_/liveevent/Manifest. This value is configured in a Location directive in the Apache /conf/httpd. Important: For live streaming. The request syntax for multi-bitrate streaming is: http://<server-name>/<location-tag-alias>/events/<fms-app-name>/events/<fms-app-instname>/<live-event-name>. 4 Complete Step 3 to stream video from Flash Media Live Encoder. OSMF Sample Player and Flash Media Server are on the same computer. The default application instance is _definst_. select DVR Auto Record.f4m The following table explains the variables in the request syntax: Variable <server-name> Description The domain name or IP address of the computer hosting Flash Media Server. The file should look like this: <manifest xmlns="http://ns.conf file.0 DEVELOPER’S GUIDE Streaming services 26 2 To configure the server to expect a DVR stream. To add DVR capabilites. The name of the Flash Media Server application to which live streams are published. The default live event is liveevent. However. The name of the live event within the Flash Media Server application. request an F4M file.0"> <dvrInfo beginOffset="0" endOffset="0"></dvrInfo> <media streamId="livestream1" bitrate="100" /> <media streamId="livestream2" bitrate="200" /> <media streamId="livestream3" bitrate="350" /> </manifest> c Save and close the file. Live streams published to this application are processed by the Live Packager.xml in a text editor.com/f4m/1.adobe. When you publish a single stream (not multiple streams encoded at different bit rates). you cannot see it on the server. The default value for live http streaming is live. The name of the stream published to the Flash Media Server application. 5 Complete Step 4 to play the video in OSMF Sample Player. The request syntax for a single stream is: Last updated 8/30/2010 . also called a manifest file. The name of the application is livepkgr. Understanding the live tutorial Understanding the request URL To play a video in OSMF Sample Player. the default live event name is the same as the stream name. 3 Complete Step 2 to configure Flash Media Live Encoder to use absolute time. b Add the <dvrInfo> tag. In this tutorial. so the value is localhost. the HTTP Origin Module generates the F4M file in real-time.

Like a Flash Media Server application. the folder name is the name of the live event. browse to the folder rootinstall/applications/livepkgr/events/_definst_/liveevent.bootstrap • livestream#.FLASH MEDIA SERVER 4. livestream1. the Live Packager creates a folder with the name of each stream. Files created by the Live Packager To play a stream in OSMF Sample Player. A live event is a configuration level within an application. This application contains an event called “liveevent”: rootinstall/applications/livepkgr/events/_definst_/liveevent Last updated 8/30/2010 .f4m file. pauses.f4x Understanding how the Live Packager works About live events Important: Flash Media Server installs with an application called “livepkg”.meta • livestream#Seg#. The Live Packager creates the following files in each folder: • livestream#. request a . MzgyODc4OTAyMg=.stream file is encoded. Like a Flash Media Server application. The Live Packager creates these files when the server ingests a live stream. and Flash Access encryption to a set of incoming streams. In the Stream text box. You can have multiple live events within one application. In the rootinstall\applications\livepkgr\events\_definst_\liveevent folder. The livepkgr application contains a live event called “liveevent”. To stream live media over HTTP. Flash Media Server introduces the concept of live events. livestream2.f4f • livestream#Seg#. live stream you don’t have to use a live event. You must create a live event to use any of the following features: • Multi-bitrate streaming • DVR • Flash Access protection Note: To serve a single. Use a live event to add metadata about multi-bitrate streaming. Flash Media Server includes an application called “livepkgr”. and plays media. choose a single stream Preset. The following is the location of the live event: rootinstall/applications/applicationname/events/applicationinstancename/liveeventname By default.control • livestream#.stream. Open the file in a text editor to see the content.0 DEVELOPER’S GUIDE Streaming services 27 http://<server-name>/<location-tag-alias>/events/<fms-app-name>/events/<fms-app-instname>/<live-stream-name>.f4m To publish a single stream. for example. enter livestream%i.stream file for each live stream published to the livepkgr application. the Live Packager creates a . a live event is a folder on the server. unencrypted. but you may want to know where they’re located on the server. In the rootinstall\applications\livepkgr\streams\_definst_ folder. in Flash Media Live Encoder. To see the configuration. OSMF Sample Player contains logic that requests additional files when a user seeks. DVR. and livestream3. You don’t need to do anything with these files. The name of the .

To publish a stream to the Live Packager.xml file.xml file. Note: To serve a single. You can associate a live stream with only one live event. specify f4f: before the stream name. Save the file to the live event folder (in this example. open a text editor and create a Manifest.asc in a text editor. A player can access the content after the source stream has stopped publishing. You can also configure virtual directory mappings for the “streams” folder. and DRM additional header metadata. The livepkgr application contains a main. the server creates a stream record file (. See “Event. See “Manifest.xml file” on page 33. see “Stream record files” on page 40. open rootinstall/applications/livepkgr/main. a stream published to an application is not associated with a live event by default. you cannot configure virtual directory mappings for the “events” folders.FLASH MEDIA SERVER 4. To see the code. live stream published from a custom client (not from Flash Media Live Encoder).asc file that publishes streams to the Live Packager and associates streams with a live event. unencrypted. Use a server-side script or the Flash Media Server Authorization Plug-in (not both) to associate a live stream with a live event.xml file contains DVR and multi-bitrate settings. 3 To create a DVR or multi-bitrate live event. The HTTP Origin Module uses this information to generate an . When using HTTP Dynamic Streaming. For that reason.stream) for the stream in the event directory: applications/appname/events/appinstancename/liveeventname/livestream.stream The stream record file contains information about the location of the packaged stream files. like a DVR. A live event (the stream content and the metadata) exists until you delete it.0 DEVELOPER’S GUIDE Streaming services 28 Note: The “events” folder is a sibling to the “streams” folder that the server uses by default for on-demand content and recorded live content. the live event “liveevent” lives inside the default instance of the livepkgr application: rootinstall/applications/livepkgr/events/_definst_/liveevent 2 Open a text editor and create an Events. The Manifest. Flash Media Live Encoder doesn’t support the f4f: prefix so add it to the stream name in a server-side script or in a Flash Media Server Authorization Plug-in. For more information. Last updated 8/30/2010 . liveevent).f4m manifest file.xml file to specify fragment and segment length. An application can contain more than one live event.xml file” on page 35. However. Save the file to the live event folder. Publish a stream to the Live Packager and associate the stream with a live event Important: Flash Media Server installs with an application called “livepkg”. Streams in a live event are packaged as fragments and written to disk. Edit the Events. When the stream is published and associated. you don’t have to associate the live stream with a live event. you can configure the location of the “applications” folder. Associate a stream during the publish event. Create a live event 1 Create the following “events” folder structure in the application folder: rootinstall/applications/applicationname/events/applicationinstancename/liveeventname For example.

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Streaming services

29

Use Flash Media Live Encoder and Server-Side ActionScript 1 Publish a stream from Flash Media Live Encoder. Do not specify the “f4f:” prefix in the Stream name. Flash Media Live Encoder does not support the “f4f:” prefix. Do not use the Record button, the DVR Auto Record setting, or the Save to File setting. To record the stream on the server, you must use the Server-Side ActionScript Stream class.
2 In the Server-Side ActionScript code, use the application.onPublish event to do the following:

• Use the Stream.liveEvent property to associate a live stream with live event.
Associate the livestream with an event before the server starts recording.

• Add the f4f: prefix to the stream name. This tells the server to package the stream. • Call Stream.record() to record the stream.
Use Flash Media Live Encoder and the Flash Media Server Authorization Plug-in 1 Publish a stream from Flash Media Live Encoder. Do not specify the “f4f:” prefix in the Stream name. Flash Media Live Encoder does not support the “f4f:” prefix. Do not use the Record button, the DVR Auto Record setting, or the Save to File setting. To record the stream on the server, you must use the Server-Side ActionScript Stream class.
2 In the Authorization Plug-in code, use the E_PUBLISH event to do the following:

• Set the F_STREAM_TYPE field to "f4f". • Set the F_STREAM_LIVE_EVENT field to "liveeventname". This example uses “liveevent”. • Set the F_STREAM_PUBLISH_TYPE field to 0 which means "record".
The following is sample C++ code that handles the E_PUBLISH event:
case IFmsAuthEvent::E_PUBLISH: { // The name of the FMS app to which the live stream is published. char* pLiveApp = "livepkgr"; // The stream type used for HTTP Dynamic Streaming. char* pStreamType = "f4f"; // The name of the live event defined in the livepkgr app. char* pLiveEvent = "liveevent"; // The Auth Plug-in affects all apps on the server. // We only want to process streams published to the livehttp app. char* pAppName = getStringField(m_pAev, IFmsAuthEvent::F_APP_NAME); if (pAppName && !strncmp(pAppName, pLiveApp, strlen(pLiveApp))) { // Set the stream type. setStringField(m_pAev, IFmsAuthEvent::F_STREAM_TYPE, pStreamType); // Set the publish type to record. //0 record, 1 append, -1 live setI32Field(m_pAev, IFmsAuthEvent::F_STREAM_PUBLISH_TYPE, 0); // Associate the stream with a live event. setStringField(m_pAev, IFmsAuthEvent::F_STREAM_LIVE_EVENT, pLiveEvent); } }

Last updated 8/30/2010

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Streaming services

30

Use a custom publishing client When you publish a stream from a custom client, you can add the “f4f:” prefix and tell the server to record the stream in the call to NetStream.publish(). For example, the following code publishes a stream called “livestream” and tells the server to fragment it and record it:
myNetStream.publish("f4f:livestream", "record");

Use a server-side script or the Authorization Plug-in to associate the stream with a live event. In a server-side script, use the Stream.liveEvent property. In the Authorization Plug-in, use the F_STREAM_LIVE_EVENT field. Match fragment duration and keyframe interval The server records the ingested stream into fragments. On the server, the fragment duration is set in the Event.xml file. The default fragment duration is 4000 milliseconds (4 seconds). The server’s fragment duration and the encoder’s keyframe interval must be the same. For example, to use the default fragment duration, configure the encoder to use a 4 second keyframe interval. To use a different keyframe interval, change the FragmentDuration value in the Event.xml file to match the encoder setting. To set keyframe intervals in Flash Media Live Encoder, click the wrench beside the Format in the Encoding Options panel. In the Advanced Encoding Options window, select 4 seconds from the Keyframe Frequency pop-up menu. To set keyframe intervals in a custom Flash Player client, call Camera.setKeyFrameInterval(). Configure absolute time for the live encoder To publish multiple streams encoded at different bit rates (called dynamic streaming, adaptive streaming, and multibitrate streaming), the timeline of the live streams must use absolute time. Each live encoder supports absolute time differently. Refer to the documentation for your live encoder. To configure absolute time for Flash Media Live Encoder, do the following:
1 Close Flash Media Live Encoder. 2 Open the Flash Media Live Encoder the rootinstall\Conf\config.xml file in a text editor. 3 Set the tag //flashmedialiveencoder_config/mbrconfig/streamsynchronization/enable to true:
<flashmedialiveencoder_config> <mbrconfig> <streamsynchronization> <!-- "true" to enable this feature, "false" to disable.--> <enable>true</enable>

4 Save the file.

Requesting live streams
To play content in a media player, request a manifest file (.f4m). The OSMF media players contain logic that requests additional files when a user seeks, pauses, and so on. Important: For live use cases, the manifest file (.f4m) is not physically present on the disk. The HTTP Origin Module generates the manifest file when the file is requested. In the Apache httpd.conf file, there are two locations configured for physical files, HttpStreamingContentPath and HttpStreamingLiveEventPath. To request a file, a video player appends the Location path with “/streams” or “/events” so the HTTP Origin Module knows which location to use. Requests to the Location path + “/streams” map to the HttpStreamingContentPath folder.

Last updated 8/30/2010

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Streaming services

31

Requests to the Location path + “/events” map to the HttpStreamingLiveEventPath folder. The following is the default Location configuration:
<Location /live> HttpStreamingEnabled true HttpStreamingLiveEventPath "../applications" HttpStreamingContentPath "../applications" </Location>

This configuration processes any request that contains the path /live/events or /live/streams, for example:
Request URL Physical file served to client

http://example.com/live/events/livepkgr/events/_d C:\Program Files\Adobe\Flash Media Server efinst_/liveevent/livestream.f4m 3.8\applications\livepkgr\events\_definst_\liveevent\livest ream.f4m http://example.com/live/streams/livepkgr/streams/ C:\Program Files\Adobe\Flash Media Server _definst_/livestreamSeg1-Frag1 3.8\applications\livepkgr\streams\_definst_\livestreamSeg 1.f4f http://example.com/livestream.f4m Not processed.

To use the NetStream.appendBytes() API to build an HTTP Dynamic Streaming player, you need to request additional files. The following are the URL request formats when Apache is configured for HTTP Dynamic Streaming:
Request type Manifest file (.f4m) URL Form http://<host>/<location-tag-alias>/events/<app-name>/event/<appinstance>/<event-name>.f4m The <location-tag-alias> is the path in the Location directive in the httpd.conf file. Fragment http://<host>/<location-tag-alias>/streams/<appname>/streams/<app-instance>/<stream name>Seg<segment #>Frag<fragment #> Note:You cannot request an F4F file directly. Request a Fragment. Bootstrap (.bootstrap) http://<host>/<location-tag-alias>/streams/<appname>/streams/<app-instance>/<stream name>.bootstrap http://<host>/<location-tag-alias>/events/defevent.f4m

Manifest file (.f4m) when an Event.xml file is not configured. Retrieves a default manifest for playback of a single stream not associated with an event.

Configure absolute time on the server
Important: Flash Media Server installs with an application called “livepkgr” that is configured for absolute time. To see the configuration, open rootinstall/applications/livepkgr/Application.xml in a text editor. To publish live, multi-bitrate streams, configure the live encoder to publish the streams using absolute time.

Last updated 8/30/2010

0 DEVELOPER’S GUIDE Streaming services 32 When you publish a stream that uses absolute time.. <ResourceLimits> <RecBuffer> <MaxFlushTime> 3 Set the value of <MaxFlushTime> to 1. Important: Set <AssumeAbsoluteTime> to true only when all streams published to the application use absolute time. but at the cost of higher disk usage. if you’re publishing streams to the application “livehttp”.. Adobe recommends setting <MaxFlushTime> to 1 second (the minimum) for HTTP Dynamic Streaming.. Configure the recording buffer on the server 1 Open the Server. 2 Locate the <MaxFlushTime> element: <Root> <Server> . the server assumes that all live streams published to the application use absolute time. you may see warnings in the server logs about time going backwards when streams are stopped and re-published. copy an Application. See Starting and stopping the server. If this value is set to true and the application ingests a stream that does not use absolute time. 2 Open the Application.xml configuration file in a text editor. The default value is 5 seconds. Lower values enable users to watch the recording with a lower latency relative to live.xml file is longer than <FragmentDuration> set in the Event.xml file from the conf\_defaultRoot_\_defaultVHost_ folder to the applications/livehttp folder.xml file is located at rootinstall/conf. <Live> . configure the ingesting application on the server to use absolute time. Last updated 8/30/2010 . 5 Restart the server. With this configuration. The Server. it can introduce latency writing F4F fragments to the disk. <AssumeAbsoluteTime>true</AssumeAbsoluteTime> 4 Save the file..FLASH MEDIA SERVER 4.. For example. 3 Set the tag //Application/StreamManager/Live/AssumeAbsoluteTime to true: <Application> . 5 Restart Flash Media Server.xml file. See Starting and stopping the server. 1 Copy an Application. The minimum value is 1 second If <MaxFlushTime> in the Server. <StreamManager> ... 4 Save the Server.xml file in a text editor. The <MaxFlushTime> is the maximum number of seconds the server waits before flushing the record buffer.xml file to the application folder..xml file.

Contains the bootstrap information for the stream. Each segment contains the fragmented (and optionally protected) content.xml file to specify the size of content fragments.drmmeta (if the stream is configured for encryption) Important: The HTTP Origin Module generates the . Create an Event.meta • livestream.xml file Use the Event.f4f file. To specify fragment size based on frames: Use the following elements: KeyframeIntervalsPerFragment. Contains internal metadata that the Live Packager uses to manage stream state.drmmeta . and so on). Output file types When you publish in F4F file format.f4x . The Live Packager outputs one or more F4F files. Contains the stream metadata (bitrate.0 DEVELOPER’S GUIDE Streaming services 33 Live Packager reference Input codecs The Live Packager for HTTP Dynamic Streaming ingests live streams and writes them to F4F files. FramesPerKeyframeInterval.f4f • livestream.f4f Description A segment. You can specify the size of content fragments based on frames or based on time.bootstrap • livestream. FrameRate.meta . However.bootstrap . except Speex audio. The following Event. The file is not physically present on the disk. An index file listing the fragment offsets in each .f4x • livestream.control Suppose you publish a stream called “livestream” to the default instance of the livepkgr application. FramePrecision. Contains the DRM additional header information when a stream is encrypted for use with Flash Access. . Each file contains a segment of the source file. The Live Packager outputs one or more F4X files.f4m file when it is requested.FLASH MEDIA SERVER 4.xml file fragments content based on frames: Last updated 8/30/2010 . the server creates the following files in the applicationname/streams/instancename folder: File . The HTTP Origin Module uses this file to deliver fragments. screen size. More Help topics “Publish a stream to the Live Packager and associate the stream with a live event” on page 28 Event. you can request the file even when a live stream has stopped publishing.xml file and copy it to the live event folder. The Live Packager supports all the codecs that Flash Player supports. The server creates the following files in the folder applications/livepkgr/streams/_definst_/livestream: • livestreamSeg#.

adobe.bin</CommonKeyFile> <LicenseServerURL>http://dill.pol</PolicyFile> </FlashAccessV2> </ContentProtection> </Recording> </Event> The following table lists all the possible elements of an Event.xml file fragments content based on time: <Event> <EventID>liveevent</EventID> <Recording> <FragmentDuration>4000</FragmentDuration> <SegmentDuration>10000</SegmentDuration> </Recording> </Event> Use the frame-based option when the source media contains video encoded at a constant frame rate. the Live Packager uses the default FragmentDuration. which is 4 seconds. The frame-based option lets you carefully match the fragment size to the video's keyframe interval.corp.pfx</PackagerCredentialFile> <PackagerCredentialPassword>hbXX5omIhzI=</PackagerCredentialPassword> <PolicyFile>policy01. Use the time-based option for media that contains audio or data but not video. To package the content for protection with Flash Access: Use the ContentProtection element and its subelements.com:8090</LicenseServerURL> <TransportCertFile>production_transport. the Live Packager uses the FragmentDuration element.FLASH MEDIA SERVER 4. If you don't provide values for either.der</TransportCertFile> <LicenseServerCertFile>license_server. SegmentDuration.xml file: Last updated 8/30/2010 . The following Event. as in the following: <Event> <EventID>liveevent</EventID> <Recording> <FragmentDuration>4000</FragmentDuration> <SegmentDuration>10000</SegmentDuration> <ContentProtection enabled="true"> <ProtectionScheme>FlashAccessV2</ProtectionScheme> <FlashAccessV2> <ContentID>foo</ContentID> <CommonKeyFile>common-key.97</FrameRate> <FramesPerKeyframeInterval>60</FramesPerKeyframeInterval> <KeyframeIntervalsPerFragment>1</KeyframeIntervalsPerFragment> <FramePrecision>1</FramePrecision> </Recording> </Event> To specify fragment size based on time: Use the following elements: FragmentDuration. The frame-based option overrides the time-based option. If you don't provide a KeyframeIntervalsPerFragment element.0 DEVELOPER’S GUIDE Streaming services 34 <Event> <EventID>liveevent</EventID> <Recording> <FrameRate>29.der</LicenseServerCertFile> <PackagerCredentialFile>production_packager.

The PFX file containing the packager's protection credentials.liveEvent property. The section that configures how the file is written to disk. The file containing the policy for this content. Each . The default is 1. for NTSC. The DER encoded license server certificate file used for content protection. To stream multi-bitrate content. in frame units. Last updated 8/30/2010 .xml file with a <media> element for each stream. 30 fps video with a keyframe every 2 seconds contains 60 frames per keyframe interval. A container for settings used by Flash Access to protect content. For example. create a Manifest. in milliseconds. create a Manifest. which means that the fragment size is the same as the keyframe interval. The content ID used with the common key to generate the content encryption key. The base key used with the content ID to generate the content encryption key. Frame units are derived from the specified frame rate (1/rate). in frames per second (fps).xml configuration file. The value is floating point. The length of each fragment.f4f file contains one segment. The number of frames between each keyframe. TransportCertFile LicenseServerCertFile PackagerCredentialFile PackagerCredentialPassword PolicyFile Manifest.FLASH MEDIA SERVER 4. The default value is 1.xml file To add DVR functionality to a live stream. The DER encoded transport certificate file. Currently only a single policy can be applied to content packaged with this tool. The length of each segment.0 DEVELOPER’S GUIDE Streaming services 35 Element Event EventID Attributes Description The root element for an Event. CommonKeyFile LicenseServerURL The URL of the license server that handles license acquisition for this content. use the value 29. in milliseconds. This is a binary file containing a 128 byte binary key. Recording FragmentDuration SegmentDuration FrameRate FramesPerKeyframeInterval KeyframeIntervalsPerFragmen t FramePrecision ContentProtectionEnabled ProtectionScheme FlashAccessV2 ContentID enabled Whether to enable content for protection with Flash Access. use the same common key and content ID for an entire set of content.97. This value is always “FlashAccessV2”. This is the same as the name of the event folder and the value of the Server-Side ActionScript Stream. Using the same key and id allows a single license to decrypt a set of content. The protection scheme. The number of keyframe intervals per fragment. The password string used to secure the packager credentials. The rounding precision for the fragment run table. The name of the event.xml file with a <dvrInfo> element. Each segment can contain one or more fragments. The frame rate of the original content. For adaptive streaming. which rounds to within 1 frame.

behind the current duration of the recorded stream. in seconds. it generates the following .f4m) from OSMF Sample Player. To use multi-bitrate streaming without DVR. media streamId bitrate Represents one stream. the start time is the beginning of the content.com/f4m/1. from the beginning of the recorded stream.adobe.xml file. Copy the Manifest. The default value is 0. the start time is the beginning of the content.0"> <dvrInfo beginOffset="30" endOffset="60"></dvrInfo> <media streamId="test1" bitrate="1000"> </media> <media streamId="test2" bitrate="2000"> </media> <media streamId="test3" bitrate="3000"> </media> </manifest> Element dvrInfo beginOffset An offset. To play a stream. include the <dvrInfo> in the Manifest. Negative values are treated as 0.f4m). Attributes Description When the HTTP Origin Module parses the previous sample Manifest.FLASH MEDIA SERVER 4. remove the <dvrInfo> tag.xml file to the live event folder.xml file to generate a manifest file (. Clients cannot view the stream behind this location. request the manifest file (. The name of the publishing stream.xml file and remove the <media> tags. The default value is 0. endOffset An offset. Negative values are treated as 0. If neither endOffset nor beginOffset is set. in seconds.f4m manifest file: Last updated 8/30/2010 . The following Manifest. Ifneither endOffset nor beginOffset is set. The HTTP Origin Module uses the Manfest. Clients can begin viewing the stream at this location. The bitrate at which the stream was encoded.xml file demonstrates the DVR and multi-bitrate use cases: <manifest xmlns="http://ns.0 DEVELOPER’S GUIDE Streaming services 36 To use DVR for a single stream.

/..FLASH MEDIA SERVER 4.././.adobe....../.0" encoding="UTF-8" ?> <manifest xmlns="http://ns./../.0 DEVELOPER’S GUIDE Streaming services 37 <?xml version="1./streams/Apps/live/streams/definst/test1/test1" bootstrapInfoId="bootstrap7536"> <metadata> AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgAAAAAAAAAAAAAFd2lkdGgAAAAAAAAAAAAABmhlaWdodAAAAAAAAAAA AAAMdmlkZW9jb2RlY2lkAgAESDI2MwAMYXVkaW9jb2RlY2lkAgAEbm1vcwAOdmlkZW9mcmFtZXJhdGUA//gAAAAAAAAA D2F1ZGlvc2FtcGxlcmF0ZQBAs4gAAAAAAAANYXVkaW9jaGFubmVscwA/8[AAAA AAAAAAJdHJhY2tpbmZvCgAAAAMDAAZsZW5ndGgAAAAAAAAAAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCA ANlbmcAAAkDAAZsZW5ndGgAAAAAAAAAAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZ W5ndGgAAAAAAAAAAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkAAAk]= </metadata> </media> <media streamId="test2" bitrate="2000" url="....././././../streams/Apps/live/streams/definst/test3/test3" bootstrapInfoId="bootstrap7538"> <metadata> AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgAAAAAAAAAAAAAFd2lkdGgAAAAAAAAAAAAABmhlaWdodAAAAAAAAAAA Last updated 8/30/2010 ./streams/Apps/live/streams/definst/test2/test2" bootstrapInfoId="bootstrap7537"> <metadata> AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgAAAAAAAAAAAAAFd2lkdGgAAAAAAAAAAAAABmhlaWdodAAAAAAAAAAA AAAMdmlkZW9jb2RlY2lkAgAESDI2MwAMYXVkaW9jb2RlY2lkAgAEbm1vcwAOdmlkZW9mcmFtZXJhdGUA//gAAAAAAAAA D2F1ZGlvc2FtcGxlcmF0ZQBAs4gAAAAAAAANYXVkaW9jaGFubmVscwA/8[AAAAAAAAAAJdHJhY2tpbmZvCgAAAAMDAAZ sZW5ndGgAAAAAAAAAAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAAAAAAAA AAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAAAAAAAAAAAAACXRpbWVzY2F sZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkAAAk]= </metadata> </media> <media streamId="test3" bitrate="3000" url=".com/f4m/1./..0"> <id>Apps/live/events/definst/myTestEvent</id> <mimeType/> <streamType>live</streamType> <duration>0</duration> <dvrInfo beginOffset="30" endOffset="60"></dvrInfo> <media streamId="test1" bitrate="1000" url="./..

the Manifest. 5 Retrieve metadata from the . Sample manifest file for a live. In the live use cases.xml file and the Manifest././streams/Apps/live/streams/definst/test2/test2. adaptive streaming bitrates. However./.bootstrap. 2 Retrieve metadata about the event from the Event.stream file./. 3 Scan the event directory for stream record files (.../.f4f..f4x. OSMF Sample Player has abstracted this logic. a player can request the manifest file.. .xml file.bootstrap" id="bootstrap7537" /> <bootstrapInfo profile="named" url=". Each .. multi-bitrate. and ../streams/Apps/live/streams/definst/test3/test3.. media bootstrap information./.f4m).. the OSMF Sample Player requests a Flash Media Manifest file (. The manifest file contains information about a Flash media asset. protected event The following is a sample manifest file: Last updated 8/30/2010 ./. the files must not be moved from their original locations./. the HTTP Origin Module uses metadata from the Event.bootstrap" id="bootstrap7538" /> </manifest Manifest files To stream media over HTTP.meta. For the state of the recording to be intact./.xml file (if it exists)././. When the player requests the manifest file. the HTTP Origin Module generates it.drmmeta files.f4m URL.bootstrap" id="bootstrap7536" /> <bootstrapInfo profile="named" url=". Note: The HTTP Origin Module uses the HttpStreamingContentPath to map the physical path of the content (..0 DEVELOPER’S GUIDE Streaming services 38 AAAMdmlkZW9jb2RlY2lkAgAESDI2MwAMYXVkaW9jb2RlY2lkAgAEbm1vcwAOdmlkZW9mcmFtZXJhdGUA//gAAAAAAAAA D2F1ZGlvc2FtcGxlcmF0ZQBAs4gAAAAAAAANYXVkaW9jaGFubmVscwA/8[AAAAAAAAAAJdHJhY2tpbmZvCgAAAAMDAAZ sZW5ndGgAAAAAAAAAAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAAAAAAAA AAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAAAAAAAAAAAAACXRpbWVzY2F sZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkAAAk]= </metadata> </media> <bootstrapInfo profile="named" url=".meta file. .. 7 Return the generated manifest document (. To use OSMF Sample Player.stream).f4m)./. To generate the manifest file. 4 Retrieve the path to the corresponding content from each . This information includes the location of the media. and data from the . ...xml file./streams/Apps/live/streams/definst/test1/test1.stream file becomes a <media> element in the manifest file. 6 Create links to the bootstrap information and DRM additional header data (if the content is protected).f4f) into an absolute URL path for the video player. the HTTP Origin Module creates the manifest file as the live stream is packaged and written to disk. the HTTP Origin Module follows these steps: 1 Combine the request URL and the HttpStreamingLiveEventPath directive to locate the live event... The manifest file contains information about each stream in a multiple stream event./. if the state of the recording is intact. DRM additional header data. pass only an ..FLASH MEDIA SERVER 4. To create the manifest file. and so on. The manifest file is not written to disk.

The <media> elements provide the absolute URL path to the content location with the prefix “/live/streams”. Both myStream and myStream1 refer to the same .bootstrap" id="bootstrap2267" /> <drmAdditionalHeader url="/live/streams/myStream.0 DEVELOPER’S GUIDE Streaming services 39 <?xml version="1. therefore there is only one <drmAdditionalHeader> element in the sample manifest file.FLASH MEDIA SERVER 4. The .drmmeta are found in the same location as the .f4f file. In this example.drmmeta file can be shared across multiple streams.0"> <id>live_mbr_event</id> <streamType>live</streamType> <duration>0</duration> <bootstrapInfo profile="named" url="/live/streams/myStream.drmmeta" drmContentId="live_mbr_event" id="drmMetadata9996" /> <media> url="/live/streams/myStream" bitrate="408" bootstrapInfoId="bootstrap2267" drmAdditionalHeaderId="drmMetadata9996"> <metadata> AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgBARo9cKPXCjwAFd2lkdGgAQJQAAAAAAAAABmhlaWdodABAhoAAAAAA AAAMdmlkZW9jb2RlY2lkAgAEYXZjMQAMYXVkaW9jb2RlY2lkAgAEbXA0YQAKYXZjcHJvZmlsZQBAWQAAAAAAAAAIYXZj bGV2ZWwAQEAAAAAAAAAABmFhY2FvdAAAAAAAAAAAAAAOdmlkZW9mcmFtZXJhdGUAQD34U+JVaygAD2F1ZGlvc2FtcGxl cmF0ZQBA53AAAAAAAAANYXVkaW9jaGFubmVscwBAAAAAAAAAAAAJdHJhY2tpbmZvCgAAAAIDAAZsZW5ndGgAQTSinwAA AAAACXRpbWVzY2FsZQBA3UwAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAQUCGAAAAAAAACXRpbWVzY2Fs ZQBA53AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkAAAk= </metadata> </media> <bootstrapInfo profile="named" url="/live/streams/myStream1.drmmeta file through the drmAdditionalHeaderId attribute. If .bootstrap" id="bootstrap7975" /> <media> url="/live/streams/myStream1" bitrate="1108" bootstrapInfoId="bootstrap7975" drmAdditionalHeaderId="drmMetadata9996"> <metadata> AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgBARo9cKPXCjwAFd2lkdGgAQJQAAAAAAAAABmhlaWdodABAhoAAAAAA AAAMdmlkZW9jb2RlY2lkAgAEYXZjMQAMYXVkaW9jb2RlY2lkAgAEbXA0YQAKYXZjcHJvZmlsZQBAWQAAAAAAAAAIYXZj bGV2ZWwAQEAAAAAAAAAABmFhY2FvdAAAAAAAAAAAAAAOdmlkZW9mcmFtZXJhdGUAQD34U+JVaygAD2F1ZGlvc2FtcGxl cmF0ZQBA53AAAAAAAAANYXVkaW9jaGFubmVscwBAAAAAAAAAAAAJdHJhY2tpbmZvCgAAAAIDAAZsZW5ndGgAQTSinwAA AAAACXRpbWVzY2FsZQBA3UwAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAQUCGAAAAAAAACXRpbWVzY2Fs ZQBA53AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkAAAk= </metadata> </media> </manifest> The player uses the manifest file to request a content fragment.0" encoding="UTF-8" ?> <manifest xmlns="http://ns. Last updated 8/30/2010 .adobe.bootstrap and . “myStream” and “myStream1”. <bootstrap> and <drmAdditionalHeader> elements are included in the manifest file.com/f4m/1. there are two streams associated with the live event.

and publishes the live video to the multicast service on the Flash Media Server.0"> <type> f4f </type> <name> livestream </name> <path> C:\Program Files\Adobe\Flash Media Server 3. corporate.0 DEVELOPER’S GUIDE Streaming services 40 The metadata element contains the metadata for one piece of media in Base64 encoding.stream) is an XML document that contains the physical location of the stream. The server creates the file with an encoded name in the following location: applications/appname/events/appinstancename/eventname/MTg1ODAyNjgwNg=. encodes. Generates a live stream name to copy and paste into Flash Media Live Encoder that embeds required multicast event settings as parameters within the stream name's query string.stream file: <?xml version="1. live stream to Flash Player clients over IP multicast.8\applications\myapp\streams\_definst_\livestream </path> </stream> Using the multicast service About the multicast service Flash Media Server 4. The multicast solution consists of the following components: • The multicast config tool (rootinstall/tools/multicast/configurator) Collects information to describe and configure a multicast event. see the F4M File Format Specification at adobe. The multicast solution is an end-toend solution for live. Flash Player 10. The following is the format of the .onMetaData() event. The multicast service is part of the Adobe Flash Media Server multicast solution.0" encoding="UTF-8"?> <stream xmlns="http://www.com. Stream record files A stream record file (.0. The service does not run on Flash Media Streaming Server. multicast events.com/liveevent/1. P2P multicast. Generates a manifest. The server creates the stream record file when an incoming stream is associated with a live event.FLASH MEDIA SERVER 4. The metadata is the same information dispatched in the ActionScript NetStream.f4m file that you copy to the same folder as the multicast player. • The multicast service (rootinstall/applications/multicast) Last updated 8/30/2010 . The multicast solution delivers a single. For more information. • Flash Media Live Encoder Captures.stream The HTTP Origin Module reads the stream record file to locate the content for the stream. and the combination of both (called fusion multicast).adobe.1 Important: The Multicast service (rootinstall/applications/multicast) is not signed by Adobe.

for example.html and multicastplayer. The multicast solution does not support multi-bitrate streaming.f4m file to the same location as the multicastplayer. enter an IP multicast address and port to use for the live event. and plays the live stream. • An F4M file to use with the client multicast player. select a single stream preset. 3 For Fusion and Peer to Peer. CorpAllHandsQ2_2010. To view the F4M file. 7 For IP Multicast and Fusion. To publish a stream. you’ll click Copy and paste this value into the Flash Media Live Encoder Stream field.0 DEVELOPER’S GUIDE Streaming services 41 A server-side Flash Media Server application that republishes the live stream as a multicast stream into a target RTMFP Group. specify the port. The password ensures that only the multicast server can publish a multicast stream into the group. Note: Get the IP multicast address from your IT department. cooperative IP and P2P multicast) • IP Multicast • Peer to Peer Multicast Note: The tool contains descriptions of each type. select Make Unique. IP Multicast events use the URI rtmfp: which puts the NetConnection object in “connectionless” mode. • The multicast player (rootinstall/tools/multicast/multicastplayer) A client-side Flash Player application that connects to the multicast service.example. The multicast config tool generates the following: • A name for the live stream.example. 9 Click Save Manifest File and save the manifest. To make the group name unique. Last updated 8/30/2010 . joins the group. click View Manifest File. 2 Select one of the following multicast types: • Fusion (simultaneous. The multicast address delivers data to all members of the group on the network. Publish a stream from Flash Media Live Encoder 1 Launch Flash Media Live Encoder 3.com:1940/multicast. rtmfp://fms. This is the address and port to which the live stream is broadcast. Configure the multicast event Do the following to configure the multicast event: 1 Open rootinstall/tools/multicast/configurator/configurator. for example. 8 Click Generate.FLASH MEDIA SERVER 4.html in a browser.1 or later and do the following: 2 From the Preset menu. 6 Enter a name for the group. Other peers do not have the publish password and can only play the stream. for example. If the server is configured to use a port other than 1935. this location is rootinstall/tools/multicast/multicastplayer.swf files. The IT department sets up the multicast router and multicast address. Note: IP Multicast events do not require a connection URI.com/multicast. enter the server name (or IP address) and the full path to the multicast application. not publish a stream. 5 Enter a publish password. 4 Enter the name of the live stream. rtmfp://fms. or livestream. By default.

Play a multicast stream 1 Open rootinstall/tools/multicast/multicastplayer/multicastplayer. choose Global Security Settings panel.html in a browser. The multicastplayer plays the stream that Flash Media Live Encoder is publishing. c Click Edit locations > Add location > Browse for folder. 4 Paste the Publisher Stream Name you copied from the Multicast Config Tool to the Stream field. The Adobe Flash Player Settings manager displays a Peer Assisted Networking dialog. Select the Flash Media Server rootinstall folder.0 DEVELOPER’S GUIDE Streaming services 42 3 For FMS URL. The RTMFP client is a server-side peer established by the multicast service to republish the live stream into the target RTMFP Group. (On Windows.FLASH MEDIA SERVER 4. 2 To run Flash Player from the local file system. Last updated 8/30/2010 . enter the URL of the multicast service. Note: Flash Media Live Encoder connects to Flash Media Server over the RTMP protocol. Click Allow to allow the peer-to-peer connection. b On the Flash Player Help page. do the following to add the folder containing the multicastplayer. The RTMP client is the connection from FMLE to the server. If you’re testing on the same computer that Flash Media Server is running on. 6 Launch the Flash Media Server Administration Console and click on View Applications > Clients. the location is C:\Program Files\Adobe\Flash Media Server 4 by default.swf file to a list of trusted locations: a Right-click on the screen and choose Global Settings.) 3 Reload the multicastplayer.html file in the browser. not over the RTMFP protocol. enter rtmp://localhost/multicast. from the list in the top left. 5 Click Start to connect to the multicast service and start streaming.

To connect. A stream can carry more than one type of content (audio. a connection is available to both the client and the server. encode. Flash Player. Single stream of data C. sports events. Flash Media Server B. video.connect("rtmp://localhost/HelloServer"). NetConnection D. The server sends back a NetStatusEvent that tells the client whether it has connected successfully.43 Chapter 3: Developing streaming media applications Adobe® Flash® Media Server can stream live video and recorded video to and from Flash Player and AIR. nc. The NetConnection class connects a client to an application instance on the server. create an instance of the NetConnection class and call the connect() method. or from server to client. you can attach one or more streams to it. Live video is typically used for events such as corporate meetings. A B C D Many streams can use one NetConnection object between client and server. Live applications capture. and data over a network connection. Pass an application instance URI to the connect() method: var nc:NetConnection = new NetConnection(). and stream live media. Once you create the NetConnection object. A. Recorded video is called on-demand. a stream flows in only one direction. However. A NetConnection object is like a pipe that streams audio. and data from client to server. from server to client or client to server. The connection request is accepted or rejected by an application instance on the server. and data). Adobe AIR. Connecting to the server About the NetConnection class Before a client can play or publish audio and video. Once the application accepts the connection request. video. or Flash Lite 3 client More Help topics “Managing connections” on page 48 About the application URI The application instance URI can be absolute or relative and has the following syntax (items in brackets are optional): Last updated 8/30/2010 . education. and concerts. Streams handle the flow of audio. it must connect to the server. or VOD (video on demand). video. The server sends information messages back to the client.

as in any of the following: rtmp://www. a chat room application can have many chat rooms: chatroom/room1.html in a browser.FLASH MEDIA SERVER 4. choose View Applications > Live Log to see the connection. see the NetConnection. To connect to a server on the same host computer as the client.ini).com/vod/mediaplayer2 Example: Hello Server application Note: Flash Media Streaming Server does not support this example. and click Play Stream. For RTMP and its variations.0. This simple Flash application displays two buttons that enable you to connect to the server and close the connection.1/vod To test these connections. Part protocol: Example rtmp: Description The protocol used to connect to Flash Media Server.0. If you do not specify an instance name. The port number to connect to on the server. //host //www.com/vod/mediaplayer1 rtmp://www. Specify the port number only to connect to a port not configured as the default.0 DEVELOPER’S GUIDE Developing streaming media applications 44 protocol:[//host][:port]/appname/[instanceName] The parts of the URI are described in the following table. as they often are while developing an application. For HTTP and its variations. instanceName room1 An instance of the application to which the client connects. Real-Time Messaging Protocol and its variations. the default port is 80.0. chatroom/room2.fmsserver. The host name of a local or remote computer.fmsserver. the only parts of the URI that are required are the protocol and the application name.connect() entry in the ActionScript 3. named _definst_. /appname/ /sudoku/ The name of a subdirectory of the rootinstall/applications folder. You can specify another location for the “applications” directory in the fms. and so on.fmsserver. When the client and the application aren’t on the same server. specify a host domain name or IP address.ini configuration file (at rootinstall/conf/fms.1 for the domain name: rtmp:/vod/ rtmp://localhost/vod rtmp://127. In the sample video player. the client connects to the default application instance. In the Flash Media Administration Console. You can also use //localhost or 127. the default port is 1935. Last updated 8/30/2010 . For possible values. enter each URL in the Stream URL box.0 Reference.example. You can find the HelloServer application in the rootinstall/documentation/samples/HelloServer folder.com //localhost :port :8080 If the client and the application are on the same server.0.com/vod rtmp://www. use //localhost or omit the //host identifier.htm) in a browser. do not specify the port number. Open the Flash Media Administration Console (rootinstall/tools/fms_adminConsole. To connect over the default port. For example. open rootinstall/samples/videoPlayer/videoplayer.

connect("rtmp://localhost/HelloServer"). 6 Drag a second button component to the Stage. and enter the instance name connectBtn. Enter Connect as the button label.as and edit this line to add the URL to your server: nc.as. Select MovieClip as the instance behavior. Click the Flash tab.0). open HelloServer.fla. Last updated 8/30/2010 .FLASH MEDIA SERVER 4. then Label. 1 In Flash Professional. and click OK.0 DEVELOPER’S GUIDE Developing streaming media applications 45 The Output window displays messages about the connection status Run the application The easiest way to run the sample is to install it on the same computer as the server. and click OK. Choose File > Publish Settings. these instructions show you how to recreate it. 1 Register the application by creating a folder in the server’s applications folder: rootinstall/applications/HelloServer 2 (Optional) To run the sample on a server installed on a different computer. 4 In the Properties Inspector. 7 Give the second button the instance name closeBtn and the label Close. then Settings. 3 Double-click the Button component to add it to the Stage. Write the client-side code 1 In Flash Professional. click the Properties tab. naming it HelloServer. 3 Return to the FLA file. However. choose File > New > ActionScript File. 2 Save the ActionScript file as HelloServer. 8 Save the FLA file. 2 Choose Window > Components to open the Components panel. 5 Click the Parameters tab. choose File > New > Flash File (ActionScript 3. Design the Flash user interface The sample is already built and included in the samples folder. so that you can build it on your own and add to it.

net. If you saved the file to the same directory as the FLA file.CLICK.MouseEvent. if you saved the file to a subdirectory below the FLA file. Click the green check mark to make sure the class file can be located. define a variable of type NetConnection: public class HelloServer extends MovieClip { private var nc:NetConnection. the package name must match the directory path to your ActionScript file. call closeHandler() when a click MouseEvent occurs on the Close button. } In connectHandler(). registering an event listener on each button: public function HelloServer() { // register listeners for mouse clicks on the two buttons connectBtn.FLASH MEDIA SERVER 4.events. closeHandler). 10 Write the closeHandler() function to define what happens when a user clicks the Close button: public function closeHandler(event:MouseEvent):void { trace("Now we're disconnecting"). nc = new NetConnection().CLICK. 8 Write the class constructor. Click OK. 9 Write the connectHandler() function to connect to the server when a user clicks the Connect button: public function connectHandler(event:MouseEvent):void { trace("Okay. nc. for example: package samples { } 6 Within the package. flash. 7 After the import statements.MovieClip. connect to the application instance on the server by calling NetConnection. netStatusHandler).addEventListener(MouseEvent. flash. } It’s a best practice to explicitly call close() to close the connection to the server.addEventListener(NetStatusEvent.0 DEVELOPER’S GUIDE Developing streaming media applications 46 4 In the Document Class box. it inherits all the properties and methods of the MovieClip class. then OK again. enter HelloServer. for example: package { } However. } Use addEventListener() to call an event handler named connectHandler() when a click MouseEvent occurs on the Connect button.display. connectHandler). 5 In the ActionScript file.NetConnection.events.NET_STATUS. Last updated 8/30/2010 . where the server runs on the same computer as the client.addEventListener(MouseEvent.connect() with the correct URI. do not use a package name. Then. } Because the class extends the MovieClip class. add an event listener to listen for a netStatus event returned by the NetConnection object.connect("rtmp://localhost/HelloServer"). enter a package declaration. create a class declaration. This URI connects to an application instance named HelloServer. Likewise.close().NetStatusEvent. let's connect now"). import the ActionScript classes you’ll use in the script: import import import import flash. nc. nc. flash. Within the class. closeBtn.

connected).info. status or error.level: status event.Success The level property can have two values. The next two lines describe the netStatus event the NetConnection object sends to report its connection status: event. meaning whether Flash Player is connected to the server over RTMP.info.Connect.info. } } A netStatus object contains an info object.code). Always check for a successful connection before you create streams or do other work in your application.info. trace("event.info.Connect. case "NetConnection. which in turn contains a level and a code that describes the connection status.Rejected": trace ("Oops! the connection was rejected" + "\n").info. switch (event.info.Closed": trace("Thanks! the connection has been closed" + "\n").Connect. Understand the connection messages When you run the sample and click the Connect button. The code property describes the status of the connection.code) { case "NetConnection.info.Success Congratulations! you're connected The line connected is: true shows the value of the NetConnection.code: " + event.level: " + event. break. let's connect now connected is: true event. You can check for various code values in your netStatusHandler function and take action. case "NetConnection. Likewise.Connect.Connect.level: status event.level: status event.level). you see messages like this.Closed Thanks! the connection has been closed Last updated 8/30/2010 .0 DEVELOPER’S GUIDE Developing streaming media applications 47 11 Write the netStatusHandler() function to handle netStatus objects returned by the NetConnection object: public function netStatusHandler(event:NetStatusEvent):void { trace("connected is: " + nc.Success": trace("Congratulations! you're connected" + "\n"). break.code: NetConnection.info.code: NetConnection.code: NetConnection. when you click the Close button.info.connected property.FLASH MEDIA SERVER 4. trace("event. as long as the connection is successful: Okay. break.Connect.info. you see the following: Now we're disconnecting connected is: false event.

Connect. all streams from server to client or client to server are shut down. you use Server-Side ActionScript and the server-side information objects (see the Server-Side ActionScript Language Reference). the server might stop.onDisconnect() in Server-Side ActionScript. which has both a code and a level property describing the change.FLASH MEDIA SERVER 4. and a single application object.onConnect event. Likewise. More Help topics “Writing server-side code” on page 6 Example: Managing connections This example shows how to manage connections from both the application client and the server-side code.Success Level status Meaning A connection has been established successfully. Write the client code In the client code. See NetStatus.0 DEVELOPER’S GUIDE Developing streaming media applications 48 Managing connections Connection status codes After the connection between client and server is made.onDisconnect event. Last updated 8/30/2010 .onConnect() and application. start with application. When a client connects. In the server code. you need to check for specific connection codes and handle them.info in the ActionScript 3. the application receives an application. This is one code and level combination: Code NetConnection. Create live streams or play recorded streams only when the client receives NetConnection. In that case.code and event.Connect.Connect. The server-side code has access to Client objects. When the event is returned. If the connection can’t be made or becomes unavailable. you need to take some action from the application client. Managing connections in server-side code An application can have server-side code in a main. the application receives an application. shut down the application.Success. which enables you to manage the application instance.asc file that manages clients trying to connect. the application can accept or reject connections from clients. To manage the connection from the server. it can break for various reasons. In the server-side code. which represent individual clients on the server side. or the connection might be closed from the server or the client. You can also check the NetConnection.connected property (which has a value of true or false) to see if the connection still exists.level. When the client receives NetConnection. when the client disconnects.info. The network might go down. Any change in the connection status creates a netStatus event.asc or applicationName. and perform other tasks to manage the connection.0 Reference for a complete list of all code and level values that can be returned in a netStatus event. close the connection to the server.AppShutDown.info. you can access the connection code and level with event.

Connect. // try to connect again break. 4 In Flash Builder.goodbye").level: " + event.info.0 example without a Flash user interface.level). and take an action for each: public function netStatusHandler(event:NetStatusEvent):void { trace("connected is: " + nc.Success": trace("Congratulations! you're connected").AppShutDown": trace("The application is shutting down").close(). } } Run the code Note: These instructions apply to any ActionScript 3. create an ActionScript project named SimpleConnectManage (choose File > New > ActionScript Project.Rejected": trace ("Oops! the connection was rejected"). 1 Create a NetConnection object and call the connect() method to connect to the server.code: " + event. SimpleConnectManage. check for specific connection codes. 5 Add the SimpleConnectManage sample files to the project. In it. // display a reconnect button break. trace("event. switch (event. The ActionScript 3. // create live streams // play recorded streams break. to use an application you have registered with the server. case "NetConnection. case "NetConnection. Last updated 8/30/2010 . 2 Write a netStatus event handler. for example: RootInstall/applications/HelloServer 3 (Optional) Or.Connect.Connect.0. case "NetConnection.FLASH MEDIA SERVER 4. break.Failed": trace("The server may be down or unreachable").info.info. written in ActionScript 3. // display a message for the user break. // this method disconnects all stream objects nc.connected ). 2 Register the application on the server by creating an application instance directory for it in the applications directory.connect("rtmp://localhost/HelloServer").Connect.info. case "NetConnection.connect("rtmp://localhost/MyApplication"). change the URI used in the call to connect(): nc. 1 Check the client-side code to see which application it connects to: nc.Connect.code) { case "NetConnection.as.info.0 examples are provided for your convenience. trace("event.0 DEVELOPER’S GUIDE Developing streaming media applications 49 Note: See the SimpleConnectManage sample.Closed": trace("The connection was closed successfully .code). and follow the wizard).

If the connection is successful.data. trace(event.events. netStatusHandler). Check the messages in the Console window..version). import flash.data..addEventListener(AsyncErrorEvent.AsyncErrorEvent. Click Debug.data.events. you should see output like this: connected is: true event.info.info.NetStatusEvent. The server version number is in the event. use the NetStream class. function netStatusHandler(event:NetStatusEvent):void{ trace("Flash Media Server version: " + event.377 bytes after decompression Get the server version number Use the ActionScript 3. nc. Call the NetStream. 7 Close the empty application window that opens and return to Flash Builder.0 NetStatusEvent to get the server version number.client = this. } nc.addEventListener(NetStatusEvent.code: NetConnection.info.info.as for Application file.version property. asyncErrorHandler).0 DEVELOPER’S GUIDE Developing streaming media applications 50 6 Choose Run > Debug.connect("rtmp://localhost/vod"). Streaming media files Playing media files To play a stream.swf .info.NET_STATUS.ASYNC_ERROR. The following code connects to the vod service and outputs the server version number: import flash. import flash. In the Debug window. } // The vod applicatin expects this function to check bandwidth.net. nc.NetConnection.play() method or the NetStream. function onBWDone(.Connect.level: status event. Create a NetStream object and pass the contructor a NetConnection object: ns:NetStream = new NetStream(nc). enter SimpleConnectManage for Project and SimpleConnectManage.version).FLASH MEDIA SERVER 4.data):Number{ return 0.code).play2() method and pass the URI of the media file: Last updated 8/30/2010 . var nc:NetConnection = new NetConnection(). nc. You can also add the following line of code inside the netStatusHandler() function in the HelloServer example application: trace("Flash Media Server version: " + event.info. } function asyncErrorHandler(event:AsyncErrorEvent):void{ trace(event).Success Congratulations! you're connected [SWF] C:\samples\SimpleConnectManage\bin\SimpleConnectManage-debug.2.

play("mp3:final/sample". • When playing a stream.-1) // FLV files Naming streams Stream names cannot contain any of the following characters: \ / : * ? " < > |.0. • Server-side streams do not play if the file size is less than either the configured buffer time (MinBufferTime tag in the Application. Set the value larger (3-5 seconds) for on-demand applications.264 video requires 64 messages before it begins playback.f4v”. Suppose you’re using the default vod application.0.play("mp4:final/sample.-1). ns.bufferTime to at least . For detailed information about play() and play2(). Managing the client buffer • Very low frame rate H. This code plays the recorded stream named “bikes. the server and the player wait for over 4 seconds for the 64 images to arrive. but F4V/MP4 files. For example. Suppose a stream called “sample” is nested in the applications/vod/media/final folder.play("raw:final/sample". For example. Mapping URIs to local and network drives Use virtual directories to simplify mapping URIs to local and network drives.play("mp4:bikes.-1) //MP3 files ns.xml file. which can help you organize your media files.f4v". ns. and RAW files do. the vod application is configured to look for streams in the applications/vod/media folder. specify the codec before you specify the path to the stream.0. In this case. the following code plays the file “bikes.f4v").0.0.0 Reference.-1) // MP3 files myStream.play("bikes").flv” within the application to which you are connected with NetConnection. MP3 files. By default.0 DEVELOPER’S GUIDE Developing streaming media applications 51 ns. The following examples are for the client-side NetStream.play("mp4:final/sample. // FLV files The following are examples for the Server-Side ActionScript Stream.-1) // RAW files myStream.-1) // F4V/MP4 files ns. 2 seconds of buffer holds 30 samples.f4v".xml configuration file).-1) // RAW files ns.0.1.-1) // F4V/MP4 files myStream.play("final/sample". Set the value smaller for live applications. their parameters. H. see the NetStream class in the ActionScript 3.0.play("mp3:final/sample". set NetStream.connect(). predetermined locations. Configure virtual directories in the VirtualDirectory/Streams tag of the Vhost. FLV streams don’t require a codec prefix. at 15 fps.play() method: ns.0.FLASH MEDIA SERVER 4. Virtual directories let you publish and store media files in different. and when to use each method. Playing streams nested in subfolders To play a stream. Last updated 8/30/2010 .play("raw:final/sample".play() method: myStream.play("final/sample". Different file types require prefixes and file extensions.264 videos can take a long time to start if the buffer is too short.play2("bikes"). even if they're small. or 2 seconds.

e:\fmsstreams low. for display purposes. frame rate. Similarly.computeSpectrum() on the client—see “Accessing raw sound data” in Programming ActionScript 3.play("low/sample"). The NetStream object that plays the stream on the client dispatches an onMetaData event when the stream encounters the metadata. a call to ns. and how the configurations determine the directory to which a recorded stream is published.e:\fmsstreams low.draw() and SoundMixer.play("high/sample") tells the server to look for the sample. Mapping in Vhost. your application could allow users to view either high-bandwidth video or low-bandwidth video. and all streams that start with high are stored in a different directory: <VirtualDirectory> <Streams>low.\\mynetworkDrive\share\fmsstreams "myStream" "low/myStream" "low/myStream" c:\.flv e:\fmsstreams\myStream. Flash Player clients are permitted to access data from streams in the directories specified by the Client.0 DEVELOPER’S GUIDE Developing streaming media applications 52 One way you can use directory mapping is to separate storage of different kinds of resources. and other information into the video file itself.0. This call tells the server to look for the sample. the client calls ns. the server publishes the stream to the default streams directory. For example.audioSampleAccess and Client. The following table shows three examples of different virtual directory configurations. and you might want to store high-bandwidth and low-bandwidth video in separate folders. See the ActionScript 3. including sound. To access data. call BitmapData.. In the first case.0 Reference.\RootInstall\applications\yourApp\streams\_definst_\myStream.flv URI in NetStream call Location of published stream More Help topics “Streaming on-demand media” on page 15 Capturing video snapshots This feature enables you to get a thumbnail snapshot of a given video. For example.FLASH MEDIA SERVER 4.c:\low_bandwidth</Streams> <Streams>high. you must handle the event and extract the info object that contains the metadata. or you can explicitly add your own metadata. the info object contains these properties: Last updated 8/30/2010 . because the URI specified ("myStream") does not match the virtual directory name that is specified ("low").. Other video encoders embed different sets of metadata.videoSampleAccess properties. To read the metadata. Handling metadata in streams A recorded media file often has metadata encoded in it by the server or a tool. if a file is encoded with Flash Video Exporter.flv file in the c:\high_bandwidth folder. You can create a mapping wherein all streams that start with low are stored in a specific directory. C:\low_bandwidth. The Flash Video Exporter utility (version 1.1 or later) is a tool that embeds a video’s duration.flv \\mynetworkDrive\share\fmsstreams\myStream.c:\high_bandwidth</Streams> </VirtualDirectory> When the client wants to access low-bandwidth video.xml <VirtualDirectory><Streams> tag low. including mapping to a local drive and a network drive.flv file in the c:\low_bandwidth folder.

The height of the video display.as.adobe. you could create a trailer in Adobe® Premiere® and transfer the metadata to the FLV file. Flash Media Server supports XMP metadata embedded in FLV and MP4/F4V formats. The frame rate at which the video was encoded.com/go/learn_fms_video_en.0 Developer’s Guide at www. When NetStream plays the content. For detailed information about XMP. For more information about working with video. XMP metadata can be internal information about the file or information for end users.fla file from the RootInstall/documentation/samples/MediaPlayer folder. see the “Working with Video” chapter in ActionScript 3. The data field contains the entire XMP message from the media file. 2 Copy the rootinstall/documentation/samples/MediaPlayer/streams folder to the rootinstall/applications/mediaplayer folder so you have the following: rootinstall/applications/mediaplayer/streams/_definst_/bikes. speech-to-text metadata embedded within files and encoded from Adobe encoding tools such as Flash Media Live Encoder can be delivered.com/go/learn_fms_xmp_en. Flash Media Server 3. Last updated 8/30/2010 . open the MediaPlayer. AMF0 and AMF3 connections are supported. More Help topics “Example: Add metadata to live video” on page 101 Using XMP metadata You can deliver Adobe Extensible Metadata Platform (XMP) metadata embedded video streaming through Flash Media Server to Flash Player.5 supports one XMP metadata packet per MP4/F4V file. In addition. The width of the video display. from the rootinstall/documentation/samples folder. an onXMPData message with the single field data is sent as a callback. they can use Flash Player 10 search to look for metadata and jump to a specific location in the file. XMP information you add during the production process can add to the interactive experience of the media. see the Open Source Media Framework. The video plays without sound and the Output window displays messages. MediaPlayer.0 DEVELOPER’S GUIDE Developing streaming media applications 53 duration width height framerate The duration of the video. When users view the file.FLASH MEDIA SERVER 4. With XMP metadata. see www. Example: Media player This tutorial uses ActionScript 3. Run the example in Flash 1 Create a rootinstall/applications/mediaplayer folder. This tutorial provides the simplest example of displaying video for learning. you have a communication system that provides critical media information from media creation to the point where media is viewed. To build a more robust video player. For example. 4 Select Control > Test Movie.adobe.0 to add a Video object to the Stage to display video. Note: This example uses the MediaPlayer sample.flv 3 In Flash.

like this: metadata: duration=30 width=292 height=292 framerate=30 Run the example in Flash Builder 1 Open MediaPlayer.NetStatusEvent. } flash.net. flash.play() triggers the call to onMetaData.display. flash..Video. The call to NetStream.as in Flash Builder. The video runs in an application window. and any other classes you need: package { import import import import import . Import NetConnection.Sprite.0 class.net.as. flash..events. Write the main client class 1 Create an ActionScript 3. Click the Flash Builder window to see the output messages. NetStream. For Application file. 2 Create a new class.0 DEVELOPER’S GUIDE Developing streaming media applications 54 The Output window and the video in test-movie mode You can watch the output as the stream plays and the connection status changes.FLASH MEDIA SERVER 4. which displays metadata in the console window.media. choose MediaPlayer.NetConnection. 2 Choose Run > Debug. MediaPlayer. and declare the variables you’ll need within it: Last updated 8/30/2010 . choose MediaPlayer. For Project. 3 Click Debug.NetStream. flash.

code: " + event. case "NetStream.NET_STATUS. nc. case "NetStream. break.info. case "NetConnection.Stop": // Handle this case here. ns.connect("rtmp://localhost/mediaplayer"). } 3 Define the constructor: create a NetConnection object and add an event listener to it. Notice that you set the client property to an instance of the CustomClient class. break.. see NetStatusEvent.StreamNotFound": // Handle this case here.code){ case "NetConnection.Publish..level: " + event. case "NetStream.Connect.code).BadName": trace("The stream name is already used").. CustomClient is a separate class that defines some special event handlers. 2 Create a Video object and attach the stream to it: Last updated 8/30/2010 . switch (event. 1 Create a NetStream object and register a netStatus event listener: private function connectStream(nc:NetConnection):void { ns = new NetStream(nc). "event.info. . netStatusHandler). .Connect. doPlaylist(nc).info.Success": // Call doPlaylist() or doVideo() here.Failed": // Handle this case here.client = new CustomClient(). break.info.0 DEVELOPER’S GUIDE Developing streaming media applications 55 public class MediaPlayer extends Sprite { var nc:NetConnection. and connect to the server: public function MediaPlayer() { nc = new NetConnection(). nc.FLASH MEDIA SERVER 4. // Handle this case here.info. break. } 4 Create a netStatusHandler function that handles both NetConnection and NetStream events: private function netStatusHandler(event:NetStatusEvent):void{ trace("event.Play.NET_STATUS.info in the ActionScript 3. var video:Video.addEventListener(NetStatusEvent. break.. case "NetConnection. } } Note: To see the full list of event codes that are available. break.Connect.level + "\n".0 Reference. netStatusHandler). var ns:NetStream.Rejected": // Handle this case here. ns.addEventListener(NetStatusEvent.Play.

attachVideo() as in ActionScript 2. but some of the tools create files that do not comply with the FLV and F4V standards. call Video.0. invalid onMetaData messages. The tool does fix metadata by scanning the Duration and Can Seek To End metadata fields.play() is relative to the URI of the application you pass to NetConnection.. Common problems include bad timestamps.client = new CustomClient().play("bikes".play().0 DEVELOPER’S GUIDE Developing streaming media applications 56 video = new Video(). In ActionScript 3. In addition. 2 Create the new client class: class CustomClient { } 3 Write a function named onMetaData() to handle the onMetaData event: public function onMetaData(info:Object):void { trace("metadata: duration=" + info. 0). but you cannot use the addEventListener() method to register the event handlers. You must handle these events when you call NetStream. Note: The FLVCheck tool does not correct file content corruption. 3 Call NetStream..FLASH MEDIA SERVER 4. The FLVCheck tool can be used to analyze FLV and F4V files before they are deployed on the server. attach the new class to the NetStream.play() to play the stream and addChild() to add it to the Stage: . ns. bad message headers.attachNetStream(ns).connect(). The tool verifies that metadata is readable. and corrupted audio and video. } The URI of the stream you pass to NetStream. the tool can also add or update metadata to reflect file duration correctly. The tool can then merge the server metadata with the data present in the file.width + " height=" + info.0—to attach the stream to the Video object. video.duration + " width=" + info. } Checking video files Checking video files created or modified with third-party tools Third-party tools are available to create and modify FLV and F4V files. } 4 Write a function named onPlayStatus() to handle the onPlayStatus event: public function onPlayStatus(info:Object):void { trace("handling playstatus here").height + " framerate=" + info. addChild(video).attachNetStream()—not Video. and checks that the file is seekable by the server. The tool supports unicode filenames.framerate). Write the client event handler class You also need to write the CustomClient class. specifies an accurate duration. Last updated 8/30/2010 . 1 In your main client class. which contains the onMetaData and onPlayStatus event handlers.client property: ns.

Turns off header. 2 Use the following syntax to run the FLVCheck tool: flvcheck [-option] <file .0 DEVELOPER’S GUIDE Developing streaming media applications 57 Checking other video files Flash Media Server supports playback and recording of H. Description Specifies the path to the video file(s) being checked. the server logs a warning that the metadata duration is incorrect. If the margin has not been exceeded. Display warnings. Fix a stall in video playback (FLV only).> For example. be returned.flv . Prints version information. 1 Open your operating system’s command prompt and change directories to RootInstall/tools. the absolute difference between metadata_duration and actual_duration is calculated and compared against the margin specified in this command. For MPEG-4–based container formats.) When validating metadata. (If the file contains no errors. specify -d 0.. Note: The FLVCheck tool does not correct corrupted H./test/123. try the “/” character instead. Option -f [ --file ] file . nothing will be logged.264-encoded files or make any other fixes to MP4/F4V files. A subset of the MPEG-4 standards are supported... in seconds. All MP4 files and Adobe F4V files are part of the supported subset. Provides a description of options and an example. (FLV files only) If a metadata tag is corrupted. Relative paths may be used. Check a video file with the FLVCheck tool The FLVCheck tool is a command line program.) Sets the verbose flag.FLASH MEDIA SERVER 4. with corrected metadata. -v [--verbose] -V [ --version ] -n [ --nobanner ] -h [ --help ] -d [ --duration ] -q [ --quiet ] Specifies that only the status code. use the FLVCheck tool to verify that the server can play back your files.) Only the Duration and Can Seek To End metadata fields are corrected. creates a new copy of the original FLV file in the same directory as the original. to check two files: flvcheck -f abc. The --help option overrides this option. Specifies the margin of error.264-encoded video and HE-AAC-encoded audio within an MPEG-4–based container format. that FLVCheck reports.. -w [ --warnings] -W [--warnings_as_errors] -s [ --fixvideostall ] -u [ --usage ] -m [ --fixmeta ] Last updated 8/30/2010 . (The default is 2 seconds. If the margin is exceeded. not the text output..flv The following table describes the command line options available. (Avoid using the “\\xd3 character. To get the exact duration. Displays an example and information about command-line parameters. a backup file is not created. the executable is named flvcheck. Treat warnings as errors.

This error occurs if you run the tool with the -m option set. This error occurs if the MP4 file is empty. Flash Media Server cannot read the file. The possible error numbers. File not found. flvcheck -f abc. indicating that the encoding of part or all of the file is not compatible with the codecs that are supported. If there are one or more errors. Try the following: a Use the -m option to try to fix the metadata in the file: flvcheck -m <file> [-quiet] [-help] b Use the -d option to change the duration field margin of error.FLASH MEDIA SERVER 4. This error could occur if the MP4 file contains audio or video encoded with unsupported codecs. Errors and warnings are logged in a log file (stdout). types of errors. ErrorMessage. and FileName. Time.0 DEVELOPER’S GUIDE Developing streaming media applications 58 3 If the FLVCheck tool finds no errors in the FLV file. and messages are as follows. If a return code of -1 is returned. but the tool cannot create a file with corrected metadata. File does not contain a movie box. 4 (FLV files only) If an error is returned from an FLV file due to a metadata error. Unparsable data message. the error is logged to the stdout file in the following format: Date. Cannot open file.flv -d 5 would allow the metadata duration to be inaccurate +/. Last updated 8/30/2010 . FLVCheck errors If an error is found. -7 -8 -9 -10 -11 -12 -13 FLV FLV FLV FLV FLV FLV MP4 Invalid FLV signature. Invalid FLV message footer. Other types of errors cannot be fixed using the FLVCheck tool. Unrecognized message type. Found backward timestamp. a positive number indicating the total number of invalid files found is returned. -6 General Cannot create corrected file. the status code returned is 0. For example.5 seconds. ErrorNumber. MP4/F4V files cannot be fixed using the FLVCheck tool. Maximum allowed is 64. File read error. -15 MP4 Too many tracks. Invalid FLV data offset. an invalid command-line parameter was specified. -14 MP4 File does not contain any valid tracks. The duration field in the metadata may be inaccurate by a few seconds. Error numbers -2 -3 -4 -5 Error type General General General General Error messages Invalid file system path specified. you can use the tool to try to correct the problem.

Max is 64. File appears to be FLV with wrong extension. Unsupported DRM scheme. Invalid chapter time. Warning Message. Truncated box. but you may experience problems with playback.0 DEVELOPER’S GUIDE Developing streaming media applications 59 Error numbers -16 -17 -18 Error type MP4 MP4 MP4 Error messages Only one sample type allowed per track. Warning number -100 -101 -102 -103 -104 Warning type General FLV MP4 MP4 MP4 Message Metadata duration is missing or is incorrect. Invalid sample size. Index File Version %x Not Supported. -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -32 -33 -34 -35 -36 -37 -38 MP4 MP4 MP4 MP4 MP4 MP4 MP4 General MP4 MP4 MP4 MP4 RAW RAW RAW RAW RAW RAW RAW FLVCheck warnings Generally. FMS Requires Version %x. Unrecognized box. Time. Invalid movie time scale. Box is too large. warnings are informative and are not fatal errors. The file may have been truncated. Index or Contexts file missing or corrupted. Found incomplete track. Invalid number of data entries in box. Last updated 8/30/2010 . Warnings are logged to the stdout file in the following format: Date. Unrecognized message type in segment file %s. Warning Number. Flash Media Server will ignore the error that caused the warning and continue to load and play back the video or audio file.. or the reported box length may be invalid. File missing or corrupted. The reported length of a box is longer than the remaining length of the file. Found duplicate video track.. Invalid box version. File contains out-of-order movie fragments. canSeekToEnd is false.FLASH MEDIA SERVER 4. Segment file %s does not match index file. Too many tag boxes. Ignoring. Truncated message in segment file %s. File contains unexpected movie fragments. Error reading MP4 tables. Invalid message footer in segment file %s. Failed read in segment file %s. and File Name. Duplicate box.

.FLASH MEDIA SERVER 4.. Missing FLV metadata. -108 MP4 Invalid video codec. a connection attempt might fail for any of these reasons: • Any section of the network between client and server might be down. Video messages found but video flag not set. Video flag set but no video messages found. Found duplicate data track. • The URI to which the client attempts to connect is incorrect. Last updated 8/30/2010 . This warning indicates that a track has an invalid audio codec. Ignoring. Will only be partially playable. Bad NellyMoser Frequency.. File has unsupported metadata format. it is important to learn the art of managing connections and streams. Handling errors About error handling As you build video applications. Flash Media Server ignores (will not play back) tracks that are encoded with unsupported codecs. Invalid Track Extends Box. This warning indicates that a track has an invalid video codec. Sample(s) skipped. Track has unsupported sample type. Box has extraneous bytes at end. Flash Media Server cannot play back the track. File is truncated..0 DEVELOPER’S GUIDE Developing streaming media applications 60 Warning number -105 -106 -107 Warning type MP4 MP4 MP4 Message Found duplicate audio track. Audio messages found but audio flag not set. In a networked environment. Audio flag set but no audio messages found. Flash Media Server cannot play back the track. • The server is down or busy. Found backward timestamp in segment file %s. Track contains unsupported edit list. Track contains unsupported sample flags. -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -126 FLV MP4 MP4 FLV FLV FLV FLV MP4 MP4 FLV and RAW MP4 MP4 MP4 RAW Video may appear stalled due to lack of audio data. -109 MP4 Invalid audio codec. • The maximum number of clients or maximum bandwidth threshold may have been exceeded. Ignoring. • The application instance does not exist on the server.

Inform customers of errors that occur during playback: • The network connection fails during playback. The event codes to watch for and sample actions to take are as follows: Event NetConnection. written in ActionScript 3. write a netStatus event handler in which you detect each event and handle it appropriately for your application. As you test and run your application. the stream might encounter problems. To be resilient. You may need to retry connecting to the server’s URI.Connect. or take some other action. Try to connect again. ask the user to reenter a user name or password. your application needs to listen for and handle netStatus events that affect connections and streams.as. handle the netStatus event before you create a NetStream object or any other objects. downsample video and seek to the point of failure. • The buffer empties before playback is complete.0.0 DEVELOPER’S GUIDE Developing streaming media applications 61 If a connection is established successfully. Write client code to handle NetStatus events ❖ Create a NetConnection object and connect to the server.AppShutDown Action Display a message for the user that the server is down. you can also use the Administration Console to troubleshoot various connection and stream events. Then.FLASH MEDIA SERVER 4. You might need to monitor the current frame rate. Handle a failed connection If a connection cannot be made. for example: Last updated 8/30/2010 . you can then create a NetStream object and stream video. SimpleConnectManage.Connect. However. or handle a stream that is not found.Failed NetConnection.Rejected NetConnection.Connect. watch for buffer empty messages. Disconnect all stream objects and close the connection. Note: Use the SimpleConnectManage sample.

level).. case "NetConnection.Failed": trace("The server may be down or unreachable").info. trace("event. break.close(). trace("event.Connect. Your netStatus event handler should detect this code and take some action. .. ns.. Last updated 8/30/2010 .AppShutDown": trace("The application is shutting down").play( "public/welcome"). The server handles the list of streams as a continuous stream and provides buffering..code) { .. a netStatus event is triggered with a code of NetStream.Connect.info.Play.level: " + event.code: " + event. You can use both clientside ActionScript and Server-Side ActionScript to create playlists.code).Connect. Adobe Evangelist Jens Loeffler has written an Adobe DevNet article that uses client-side and server-side playlists to edit live streams into a highlight reel. case "NetConnection. switch (event.Play. .0 DEVELOPER’S GUIDE Developing streaming media applications 62 public function netStatusHandler(event:NetStatusEvent):void { trace("connected is: " + nc. Write the client code ❖ In your netStatus event handler. so that the viewer experiences no interruption when the stream changes. such as displaying a message for the user or playing a standard stream in a default location..FLASH MEDIA SERVER 4.code) { case "NetStream. break. // try to connect again break.info. check for the StreamNotFound code and take some action: private function onNetStatus(event:NetStatusEvent):void { switch (event.info. } } Handle a stream not found If a stream your application attempts to play is not found. break. } Working with playlists About playlists A playlist is a list of streams to play in a sequence.info. // this method disconnects all stream objects nc.connected ). case "NetConnection.Rejected": trace ("Oops! the connection was rejected").StreamNotFound": trace("The server could not find the stream you specified").info.StreamNotFound.

play( "bikes".play( "myvideo".NET_STATUS. until it ends • The recorded stream bikes. } 3 Attach the NetStream object to a Video object: video = new Video().as. false ). 30 ). connect to the server. stream. case "NetStream.client = new CustomClient(). 120.flv.Play. 5 Listen for NetStream event codes in your netStatus event handler: private function netStatusHandler(event:NetStatusEvent):void { . and add a netStatus event handler. Every subsequent time a user plays the playlist. MediaPlayer. stream. 1 Create a NetConnection object.. for 30 seconds • The recorded stream myvideo. 4 Define a series of play() methods on the NetStream object: stream.addEventListener(NetStatusEvent. starting 10 seconds in. -1..play( "parade". the playlist skips the item and plays. 2 Create a NetStream object and listen for netStatus events: private function createPlayList(nc:NetConnection):void { stream = new NetStream(nc). written in ActionScript 3.flv. -1. video. 10.play( "advertisement". To change the playlist. stream. 30.. netStatusHandler). from start to end • The recorded stream parade. . 0.0 DEVELOPER’S GUIDE Developing streaming media applications 63 Create a client-side playlist Important: There is a bug that impacts client-side playlists that are missing their first item. This playlist uses the names of streams that are stored on the server.0. addChild(video). case "NetStream. the playlist does not play.flv.StreamNotFound": trace("The server could not find the stream"). false). break.attachNetStream(stream). you need to change the code in your application client. false ). 0. break.Stop": trace("The stream has finished playing"). stream. } This playlist plays these streams: • A recorded stream named advertisement. from the beginning..Play.FLASH MEDIA SERVER 4. Note: Use the MediaPlayer sample.flv. The first time a user plays such a playlist. stream. starting 30 seconds in and continuing for 2 minutes Last updated 8/30/2010 .

SWAP ns. you can swap one advertisement for another. param. false). A server-side playlist plays over a live stream (the Stream object). and streamZ play.0 DEVELOPER’S GUIDE Developing streaming media applications 64 Swap streams in a playlist Flash Player 10 and Flash Media Server 3. -1. ns.play2() method with the transition mode SWAP to swap streams in a playlist. param. the client application resets the buffer. The result is that streamA. The NetStream.. use code like the following sample: var param:NetStreamPlayOptions = new NetStreamPlayOptions(). -1. you determine that you want to play Stream Z instead of Stream C. and Stream C. swapping streams occurs at the stream boundary.SWAP. 0. If the server has not yet delivered streamC. In the NetStreamPlayOptions object. 0. For example. suppose a playlist is set to play Stream A.play("streamB". While stream switching occurs at keyframes. NetStreamPlayTransitions. in that order. specify the old stream. While Stream A plays.FLASH MEDIA SERVER 4. you can record it as an FLV file or as an F4V file. the stream to switch to. To perform this transition.play2(param). One use case is with playlists that contain content with advertising segments. record it as an F4V file. Stream B. After collecting statistics about usage patterns. and before the server begins sending Stream C. 0. The call to swap streams must occur before the server delivers the old stream (in this example. the server does not swap the content and sends a NetStream.. The server swaps the stream at the start of the new stream.play2()method takes a NetStreamPlayOptions object as a parameter. false). When the server swaps to a stream with different content. the server swaps the content. The SWAP transition differs from the SWITCH transition. . streamC).streamName = "streamZ". true).transition = NetStreamPlayTransitions.oldStreamName = "streamC". therefore. A playlist can contain both live and recorded media.Failed event. Swapping streams is.5 Swapping streams means to exchange one stream for another. Use the NetStream. If a playlist contains only FLV files. If streamC is already in play. Otherwise . Create a server-side playlist A server-side playlist is a list of media played in sequence over a Server-Side ActionScript Stream object.Play. ns. ensuring an uninterrupted experience.play("streamA". -1. useful with playlists. The following code creates a server-side playlist of two live streams and one recorded stream: Last updated 8/30/2010 . You can record the stream as an FLV or F4V file as it plays. and the kind of transition to use—in this case. param. ns.play("streamC". streamB.

The following server-side code plays two recorded media files consecutively and records them to the file “playlist.f4v".myStream. 0.get("serverplaylist"). application.) To add media to a playlist. and record it as an . false).1 seconds.com.f4v file.mp4". if (application. // Play a recorded stream in full after liveStream1 plays. application. -1. Use a server-side playlist to export a highlight clips during a DVR-enabled live event.bufferTime property to at least 1 second.f4v").f4v”. this.play("serverplaylist") on the client. it is not recorded.myStream. 0. call Stream. 0. this.bufferTime property to at least 1 second. // Play another live stream for 30 seconds after recordedStream1 plays.play("mp4:british.play("liveStream2". 30).1 seconds.play("mp4:playlist. When you pass false. false). } }.5 and later and Flash Player 10 and later. -1. The following example was provided by Jens Loeffler on his blog flashstreamworks. To play this example.play("liveStream1". false).onAppStart = function(){ this. -1.get("mp4. the media doesn’t start playing until the media currently playing has stopped. To play the playlist smoothly. this.mp4". To play a server-side playlist.) Dynamic streaming About dynamic streaming Note: The dynamic streaming API discussed is supported in Flash Media Server 3. 0. set the client-side NetStream.myStream.myStream.play("mp4:smitharchive. application. the client calls NetStream. call NetStream. application. (The default value is 0.f4v").highlights. // Play a live stream for 30 seconds.myStream = Stream.myStream. 0.f4v". // This is a live playlist. this.play("mp4:titles.mp4". this. application.record(). this.f4v". 15).f4v") on the client.play("mp4:recordedStream1. 30. 30.play("mp4:shadows.0 DEVELOPER’S GUIDE Developing streaming media applications 65 // Start the playlist when the application loads. 0.f4v"). Each media file plays in its entirety. -1. To play the playlist.clientStream. Build the playlist (for example.f4v file. then a section of an archived clip).myStream = Stream.record().myStream. 15. application.clientStream.play("livesmith". }.onAppStart = function(){ this. then a selected part of the live event.get("mp4:playlist. application.play("mp4:closing. set the client-side NetStream. false).myStream. -1.play("mp4:highlights. an opening clip. To play the highlight reel. false). -1). just point your streaming player to the exported .myStream.clientStream. (The default value is 0.play() and pass false for the reset parameter. false) } To play the playlist.clientStream = Stream. Last updated 8/30/2010 . call NetStream. 30.myStream){ application.FLASH MEDIA SERVER 4.

The streams must have timestamps that are synchronized closely enough. dynamic streaming requires the following: • The different versions or pieces of content are synchronized: the video timelines must match. For example. Ensure that. • Audio-only streams.0 DEVELOPER’S GUIDE Developing streaming media applications 66 Flash Media Server can receive commands to switch between versions of a content stream that are encoded at different bit rates. The audio timelines of the initial and target streams must match. suppose the server is streaming high-definition video to a client application but encounters poor network conditions. • Video and audio streams. after initial playback. within 3-5 milliseconds.offset property to perform fast switching between streams. the video streaming to the client is uninterrupted.bufferTime) is set to at least the default value of 10 seconds or more.play2() method and the associated NetStreamPlayOptions class offer the ability to change to different streams in mid-play. (Similar APIs are also available in ActionScript 2.0. Transitions occur at the nearest keyframe in the target timeline. Using ActionScript to switch streams Stream transitions occur on the server. • Audio or other data in each content stream is synchronized with the video data in that stream. Developers can use the ActionScript 3. It also lets your application adapt to clients with different capabilities. Use the NetStreamPlayOptions.FLASH MEDIA SERVER 4. The transitions occur seamlessly in the client. but the command to switch streams and the determination to do so comes from the client application. so that the server can select accurate transition points. such as mobile devices with lower processing power and smaller screens. The server can switch to a standard-definition stream at a lower bit rate. the client buffer (the value of NetStream. This feature lets your media application adapt to changing network conditions. a 2-second buffer cannot accommodate a 3second transition delay. For example. Two factors that can cause a delay are the keyframe interval of the live stream and if the two streams being switched are not synchronized. The application developer includes logic to monitor download and playback statistics and to switch from the old stream to the new stream when appropriate. Last updated 8/30/2010 . The NetStream.5 Mbps 700 kbps 500 kbps 150 kbps 0 kbps 0 min 2 min Time 4 min Bandwidth 6 min 8 min The server delivers streams that match bandwidth changes to maintain QoS For optimal user experience.0 NetStream. Transitions occur at the audio sample that immediately precedes the nearest keyframe in the timeline of the target stream. Transitions occur at the nearest possible sample.) The application developer must also ensure that the client application has a playback buffer that is large enough to absorb any delay caused by the transition. or an audio artifact results. Although network conditions have changed. The server implements a transition between two pieces of recorded content in three possible ways. the server can switch back to HD video. Implementing transitions between live video content is slightly more complicated. Content Stream User Bandwidth 1.info property and NetStreamInfo class to monitor download and playback statistics. depending on the type of content that is being streamed: • Video-only streams. If network conditions improve.

0 library. A shorter keyframe interval lets the server switch streams more quickly. which means that the client can have a smaller playback buffer. buffer usage. and dropped frames. • Ensure that the video timelines of the streams are related and compatible.adobe. it is helpful if the keyframe interval (keyframe frequency) and frame rate (fps) are consistent across the different versions of content. keep the audio bit rates the same.FLASH MEDIA SERVER 4. such as full screen video • Content distributed to users who are more susceptible to bandwidth issues. If you don’t. • While not required.0 DEVELOPER’S GUIDE Developing streaming media applications 67 Adobe developed a new class called DynamicStream that extends the NetStream class. Note: These classes are not part of the ActionScript 3. encode the audio with a single channel (mono). The class switches streams based on that information. • Use the same codecs and audio bitrates in all streams. The following table shows various bit rates that you could use to encode a single piece of content: Bit rate 150 kbps 300 kbps Last updated 8/30/2010 . The DynamicStream class contains event listeners that monitor bandwidth. when you encode the content. such as home users. or you can use the DynamicStream class as a reference to write your own dynamic streaming algorithms. follow the recommendations in this DevNet article and in Will Law's presentation at Adobe MAX 2008. you may hear small audio pops when the streams switch. You can use the DynamicStream class to implement dynamic streaming. • To encode streams for lower bandwidth usage. rather than corporate users Encoding recommendations To provide users with the best experience. If you’re migrating legacy code. it’s a good idea to use the DynamicStream class. encode audio with AAC. • For streams with MP3 audio.com/go/fms_dynamicstreaming. Determining when to use dynamic streaming Adobe recommends that you use dynamic streaming for content that meets some or all of the following criteria: • Video with long duration • Video with large file size • HD video • Video with larger dimensions. The following is a summary of the recommendations: • For the smoothest switching. These are custom classes developed by Adobe for Flash Media Server users. • Use the same audio sample rate when possible. Download the ActionScript class files and documentation for these classes from www.

info. such as 30-60 seconds. you can check additional statistics. If the buffer begins to empty.info property.maxBytesPerSecond) and buffer size (NetStream. 3 Once playback begins. If the bandwidth begins to drop. such as the number of dropped frames (NetStream. When client bandwidth is low. Upgrade only when the reported bandwidth exceeds stream requirements by a solid margin. 5 If the client bandwidth exceeds the requirements of the stream and the buffer is filling or is full. The DynamicStream and DynamicStreamItem classes. and data bytes of the stream. an appropriate stream for initial playback is 300 kbps at 320 x 240. 6 After each transition to higher-resolution content. 2 To start playback quickly. Verify that client bandwidth is sufficient before switching. the client application can request the server to switch to a higher video bit rate.com. the buffer starts to empty. select the lowest bit rate that is appropriate for the screen or device. To measure bandwidth. and number of frames dropped.5 Mbps (full web HD) Determining when to switch streams You can consider many factors when determining when to switch streams. video. Last updated 8/30/2010 . you can deduce the quality of the bandwidth.droppedFrames). When current bandwidth is sufficient. using a timer.FLASH MEDIA SERVER 4. In addition to client bandwidth and buffer length. are built with these factors in mind and contain the logic required for a dynamic streaming application.info returns a NetStreamInfo object with properties that reflect the rate of incoming audio. you can switch to higher-resolution content.info. For example. be conservative. select a small buffer length. With information about the incoming data rate. use the NetStream. If you prefer to develop your own application logic. such as after every 2 seconds. When client bandwidth is good. which you can download from adobe. the client application can request the server to switch to a lower bit rate. it may be helpful to use the following strategy for streaming video: 1 For initial playback. 7 Continue to upgrade while bandwidth is plentiful and the buffer is filling or full. increase the buffer length to a larger value.bufferLength) as it fills. if the video plays in the web browser on a standard computer. the buffer fills quickly and stays steady. switch to lower-resolution content and monitor the buffer more frequently.0 DEVELOPER’S GUIDE Developing streaming media applications 68 Bit rate 500 kbps 700 kbps 1. More Help topics Using the DynamicStream classes ActionScript Guide to Dynamic Streaming Check client bandwidth Monitor the client bandwidth to help determine when switching streams is desirable. A call to NetStream. For the best user experience. continue to monitor the buffer every 5 seconds. number of bytes downloaded. 4 Begin monitoring the client bandwidth (NetStream. such as the buffer length.

the stream to switch to. Last updated 8/30/2010 . the object returned by NetStream. If a live stream of that name is not found. switch to a lower bit rate.byteCount property over a period of time to get the value of bytes per second and when a NetStream. which indicates how the server switches streams. The one most applicable to switching between the same content at different bit rates is SWITCH. If droppedFPS exceeds 20% of the value of currentFPS. the client application uses the NetStream. For most dynamic streaming purposes.getInfo()). Switch streams To request a transition between streams with the same content encoded at different bit rates. It tells the application to play the live stream specified in streamName. One strategy to determine the rate of dropped frames is as follows: using a timer.0 DEVELOPER’S GUIDE Developing streaming media applications 69 Specifically.Buffer.0 Language Reference.0.play() method. in ActionScript 2. even though no one is publishing on it. Check for dropped frames In addition to monitoring the buffer. use the *byteCount and *bytesPerSecond properties in the NetStreamInfo class (or. For information on other modes.play2() method extends the NetStream. transition The transition mode. When someone does begin publishing on that stream. Use the NetStreamInfo. Monitor the current number of incoming frames per second in another variable.play2() method. This value means that the application plays a live stream until it is no longer available or plays a recorded stream until it ends. droppedFPS. The name of the new stream to play. The byteCount property is a Quality of Service designed to provide data that can help you decide when to switch streams. Possible values are constants in the NetStreamPlayTransition class. calculate the difference between the current value of dropped frames and a previous value. the default value of -2 is appropriate. len The duration (length) of the playback. Flash Player plays the recorded stream specified in streamName. One way to measure the client bandwidth is to measure the NetStreamInfo. currentFPS. This value approximates the maximum bandwidth available. This read-only property is a number and returns the number of video frames dropped in the current NetStream playback session. For most dynamic streaming purposes. see the NetStreamPlayTransition class in the ActionScript 3. Switch to a stream with a lower bit rate if too many frames are being dropped. Note: The NetStream. the default value of -1 is appropriate.FLASH MEDIA SERVER 4. The start time of the new stream to play. Do not use the byteCount property for billing. Then compare the available bandwidth to the available bit rates and implement transitions as needed. Flash Player opens a live stream named streamName. Store that difference in a variable. check for dropped frames. Note: The byteCount property does not return the same value as sc-stream-bytes in the server Access log.Full status event is received. see the ActionScript Language References. For details on these properties. This method takes as a parameter a NetStreamPlayOptions object. The NetStreamPlayOptions object contains the following properties: Property oldStreamName streamName start Description The name of the stream currently being played (the old stream). the application begins playing it. If a live or a recorded stream is not found.droppedFrames property.

transition = NetStreamPlayTransitions. If a client seeks after Flash Player sends a NetStream. video. (In ActionScript 2. When the client requests a transition. you can keep the default values of start and len. and therefore the server cannot select a time to perform the switch.Transition.Play. param. stream. the server sends an onPlayStatus message with the code NetStream.NET_STATUS. This situation can occur under the following circumstances: • The two streams being switched don't have the same timeline. but Flash Player does not send a NetStream. stream.type).client = new CustomClient(). stream. This technique provides the smoothest viewing experience.SWITCH.streamName = streamA_700kpbs. This event lets the client know exactly when the new stream has started to render.Play.addEventListener(NetStatusEvent. When switching between live streams.. the server sends a NetStatusEvent.play("streamA_150kbps"). the server forces a transition to occur at an arbitrary frame and the reason field contains the code "NetStream. var video:Video = new Video().Play.. as in the example.time + " name=" + info. netStatusHandler). addChild(video).TransitionComplete. //Handler function for the Transition event class CustomClient{ public function onPlayStatus(info:Object):void { trace("switch time: time=" + info. //Set up the transition to 700 kpbs content var param:NetStreamPlayOptions = new NetStreamPlayOptions().Success". The player behaves the same way for other callback methods such as onMetaData().Transition status event contains a reason field. Use this field to get additional information about the state of a transition request. stream. The following example handles a stream transition: var stream:NetStream = new NetStream(connection). .attachNetStream(stream).play2(param). pass a value for oldStreamName.FLASH MEDIA SERVER 4. it is possible that the server could not find a synchronization point between the two streams.0. which is the maximum amount of time the server will wait for a transition.) The server sends this event to the client almost immediately.TransitionComplete message.name + " type=" + info.Transition. the streams switch successfully. which tells the server to switch to the new stream at the next logical keyframe. In this case. param. The reason field usually contains the code "NetStream. Since the server did not see a keyframe. it cannot select a frame for the switch. meaning the transition request succeeded and was processed normally. (When using playlists. see “Swap streams in a playlist” on page 64.Transition message.Transition. it sends an onStatus event with the same code. When the first frames of the new stream render.) In most dynamic stream-switching cases with a recorded video+audio stream.Play. • The keyframe interval of the new stream is longer than the client's playback buffer.Forced".NET_STATUS event with the code NetStream. which indicates that the operation has succeeded. The player doesn’t send the message because after the seek it enters a new state and cannot send status events about the old state.0 DEVELOPER’S GUIDE Developing streaming media applications 70 The following code example uses the SWITCH option to tell the server to switch to a higher bit rate stream. } } The NetStream. Last updated 8/30/2010 . The example does not pass a value for oldStreamName.Play.

Empty. see the NetStream. The properties that deal with the buffer are the BufferLength and BufferByteLength properties.TransitionComplete status event. One choice is to measure client bandwidth and set an initial buffer size based on it. The right size for the buffer varies depending on user bandwidth.FLASH MEDIA SERVER 4. Consider setting different buffer sizes for different users. all data keyframes associated with the stream are transmitted. After playback starts.Buffer. set the buffer to a small value initially. the NetStream.Buffer. The client can request the server to switch to a higher video bit rate. You could buffer data while viewers are watching a commercial. A smaller value lets the stream begin playing relatively quickly. Setting the client buffer Buffering manages fluctuations in bandwidth while a video is playing.bufferTime(10). You can listen for these events and set the buffer size smaller when empty and larger when full. When switching to a new stream. the onMetadata message for the new stream is sent immediately following the NetStream. see the ActionScript 3. for example. the amount of data in the buffer grows or the buffer is full. A larger value ensures that the stream plays more smoothly regardless of noise or interruptions on the network. to ensure the best playback experience. When the data has finished streaming. and then unpause the stream when the main video starts. To create the best experience for users.Flush event is dispatched. the amount of data in the buffer shrinks or the buffer empties. and the following values are only suggestions. You can also use NetStream. you can also detect and handle netStatus events. When client bandwidth is good.Play. set the NetStream. When the buffer is empty.pause() in code to buffer data. The client can request the server to switch to a lower bit rate. Monitor the buffer size in the client to determine when to switch streams. in seconds.code value of NetStream. Call NetStream. 30-60 seconds is a good buffer size. monitor the progress of a video and manage buffering as the video downloads. For more information. This feature allows viewers to resume playback without experiencing any hesitation. increase the buffer to a larger value.pause().bufferTime property: ns. To create a good experience for users. For example. which creates a delay similar to a long keyframe interval. Note: Flash Player 9 Update 3 and later no longer clear the buffer when a stream is paused.0 DEVELOPER’S GUIDE Developing streaming media applications 71 • The live queue delay for the live streams is longer than the client's playback buffer.Buffer. When client bandwidth is low.info() to get a NetStreamInfoObject with properties that reflect the current statistics of the stream. While the stream is playing. Last updated 8/30/2010 . Set buffer time To change the buffer time. 5-10 seconds is a good initial buffer size for fast connections. Once playback begins. another event fires with a code value of NetStream. Listen for the TransitionComplete event before capturing the metadata. For details on these properties.0 Reference. If the stream is live. Handling metadata during stream transitions Flash Media Server sends a NetStream.TransitionComplete status event when the bits of a stream transition render to the client.Full.Play. 10 seconds is a good initial buffer size for slow connections. when the buffer is full. the netStatus event returns an info.

create a NetConnection object and connect to the server (see Buffer.addEventListener(NetStatusEvent.Rejected": trace("The connection was rejected").bufferTime = 8.Full": ns. 2 Write a netStatus event handler. see the Buffer. Highlights of the code are shown here. addChild(video). connectStream(nc).0 DEVELOPER’S GUIDE Developing streaming media applications 72 Handle buffer events This example shows how to detect buffer events and adjust the buffer time dynamically.NET_STATUS.connect("rtmp://localhost/Buffer").Empty": ns.bufferTime = 30. } } 3 Write a custom method to play a stream. to see the complete sample.play( "bikes". for example. break. netStatusHandler). In the method. } 4 Create the onMetaData() and onPlayStatus() event handlers: Last updated 8/30/2010 . trace("Set an initial buffer time of 8 seconds"). ns.as in the documentation/samples/Buffer directory in the Flash Media Server root install directory): nc = new NetConnection().code) { case "NetConnection.Connect.NET_STATUS.bufferTime = 8. failure.Buffer.addEventListener(NetStatusEvent. break.Buffer. 2 seconds: private function connectStream(nc:NetConnection):void { ns:NetStream = new NetStream(nc).Failed": trace("The connection failed").attachNetStream(ns).FLASH MEDIA SERVER 4. ns. trace("Reduced buffer to 8").Connect.Success": trace("The connection was successful"). case "NetConnection. checking for success. ns.client = new CustomClient(). nc. ns. set an initial buffer time. and full buffer and empty buffer events and changing buffer size accordingly: private function netStatusHandler(event:NetStatusEvent):void { switch (event. case "NetConnection.info.Connect. video = new Video(). netStatusHandler). break. nc. case "NetStream. video. 0 ). trace("Expanded buffer to 30"). break. case "NetStream. break.as sample file. as events occur. 1 In the constructor function of your main client class.

Look at both values to recognize that a transition occurred on a single logical stream.Complete": trace("The stream has completed"). This ID is unique for the client session but not across sessions The name of the stream that the server is transitioning from (the original stream) The query stream portion of the stream name for the stream that the server is transitioning from The filename extension portion of the stream name for the stream that the server is transitioning from If you use a log processor. Your log processor can track stream transitions by recognizing stop events that have a 210 status code followed by play events with a 210 status code on the same stream. The access logs provide the following additional information: Field x-sid x-trans-sname x-trans-sname-query x-trans-file-ext Description The ID of a stream. Reconnecting streams when a connection drops Flash Media Server 3.height + " framerate=" + info. For an example of reconnecting streams. Use the logs to differentiate a single stream play with transitions from multiple plays of a stream or different streams.0 DEVELOPER’S GUIDE Developing streaming media applications 73 public function onMetaData(info:Object):void { trace("Metadata: duration=" + info. Stream transitions have a status code of 210. ensure that it looks at both the status codes and the x-sid values. a stop or play without a transition) have a status code of 200.FLASH MEDIA SERVER 4. stream transitions occur in play/stop pairs. You can also use this feature for load balancing. As with normal streams.width + " height=" + info.duration + " width=" + info. Recognizing transitions in log files You can track stream events through access logs.0 NetStream.3. break. Normal stop and play events (that is.attach() method to attach the same NetStream object to a reconnected NetConnection object.code) { case "NetStream.5.play(). } public function onPlayStatus(info:Object):void { switch (info. see the Stream Reconnect and Smart Seek example hosted by Adobe. } } These event handlers are needed when you call NetStream. The server logs a stop event for the original stream and a play event for the new stream. Last updated 8/30/2010 . To provide seamless playback.1 About reconnecting streams You can build applications that support seamless playback when a connection is dropped or when a client switches from a wired to a wireless network connection. When a transition for a single content stream occurs. use the ActionScript 3. By looking at the status code.Play. the server tracks the status of the stream as a transition. Flash Player 10. the log processor can also differentiate a stream transition from a play or stop event without a transition.framerate).

the stream closes as soon as the network connection is lost. Use this mode to rebuild a playlist after losing a connection and establishing a new connection. • NetStreamPlayTransitions. see the ActionScript 3. • NetConnection. the stream closes when the connection drops.attach(connection:NetConnection) method to attach the NetStream to the new connection. client-side ActionScript code reconnects to the server and resumes playing the stream.connect() to connect to server A.1 and greater to request data from a new connection at the same location where it dropped the previous connection.0 Language Reference. NetConnection.play2() and use NetStreamPlayTransitions.NetworkChange Notifies the client that a network connection has changed. Last updated 8/30/2010 .Connect.1 or the Flash Media Server version is less than 3. Using the Stream Reconnect ActionScript API When a NetConnection closes due to a network change.5. the stream keeps playing using the existing buffer. Set NetStream.3.5.Closed.0. Reconnect to server A if the connection drops.RESUME to play the stream “myStream”. The following ActionScript 3.APPEND_AND_WAIT The APPEND_AND_WAIT mode tells the server to build the playlist but not to stream it.0. Flash Player aligns the stream across the two connections so no artifacts or jumps are observed in the video playback.Closed.RESUME The RESUME mode causes Flash Player 10. Stream Reconnect ActionScript API Note: The Stream Reconnect ActionScript API is ActionScript 3.bufferTime to at least a few seconds so there is enough data to play while the connection is down. • NetStreamPlayTransitions.FLASH MEDIA SERVER 4. For detailed information about these APIs. 4 Monitor the NetConnection for the "NetConnection.Connect.3. Note: If the Flash Player version is less than 10.RESET to play a stream called “myStream”. 2 Create a NetStream.Connect.Closed Use this event to reconnect a stream. 6 Call NetStream. Meanwhile.attach(connection:NetConnection) Attaches a stream to a NetConnection object.Connect. use NetConnection. 3 Call NetStream.play2() and use NetStreamPlayTransitions.Connect.0 DEVELOPER’S GUIDE Developing streaming media applications 74 Note: If the Flash Player version is less than 10. Don’t use this event to reconnect a stream. Use this mode when you reconnect a stream that was dropped due to server issues or other connection problems.Closed" event. • NetConnection. These APIs are not supported in ActionScript 2.0 APIs enable you to reconnect a stream: • NetStream. Reconnecting a single stream The following workflow reconnects a single stream: 1 Call NetConnection.1 or the Flash Media Server version is less than 3. 5 Call the NetStream.

Connect.play2() to start the stream. connecting to a wireless network.play2() and use NetStreamPlayTransitions.Connect.FLASH MEDIA SERVER 4. 2 Create a NetStream. This event detects a network change (for example. 3 Call NetStream. 5 Monitor the NetConnection for the "NetConnection. call NetConnection. and so on).close() or NetStream. Reconnecting a playlist The following workflow reconnects a playlist: 1 Call NetConnection.attach(connection:NetConnection) method to attach the NetStream to the new connection. so it will stop playback right away and future reconnects will not be possible. 4 Call NetStream.Connect. Last updated 8/30/2010 .RESET to play a stream called “myStream1”.play2()and use NetStreamPlayTransitions. Balancing a server load The following workflow uses the smart reconnect API to balance a load: 1 Call NetStream.play2() and use NetStreamPlayTransitions.connect() to connect to server A.NetworkChange" event.APPEND_AND_WAIT to add “myStream1” to the playlist.transition to RESUME.attach(connection:NetConnection) to attach a stream to a NetConnection object on another server.Closed" event. disconnecting from a wireless network. Reconnect to server A if the connection drops. Use "NetConnection. 7 Do not call NetConnection. After a attach is done to the new NetConnection. 2 After the stream is successfully attached to the new connection. Set the rest of the NetStreamPlayOptions properties to the same values you used when you originally called NetStream.0 DEVELOPER’S GUIDE Developing streaming media applications 75 Flash Player tells the server where to resume playing the stream.APPEND to play a second stream called “myStream2”. disconnecting a network cable.bufferTime to at least a few seconds so there is enough data to play while the connection is down. 3 Call NetStream. a close on the older NetConnection can be called.play2() and use NetStreamPlayTransitions.Closed".play2() and use NetStreamPlayOptions.close() on the prior connection to prevent data leaks. Flash Player tells the server where to resume playing the stream. Note: Do not use this event to monitor a dropped NetConnection or to write logic for to reconnect a stream. 8 Call NetStream.RESUME to add “myStream2” to the playlist and resume the stream. Monitoring a network interface change To monitor changes to the network interface.play() or NetStream.close() if you intend to reconnect it. monitor the NetConnection for the "NetConnection. 7 Call NetStream. Set NetStream. 6 Call the NetStream. Calling close closes and cleans up the connection or the stream.

} lastByteCount = netstream. in seconds.info.attach(netconnection2). and NetStreamInfo. The F_STREAM_OFFSET property indicates where to resume streaming after a reconnection.addEventListener(TimerEvent.Success: netStream.start().info.byteCount.info.Connect.byteCount. lastByteCount = 0.Connect.bufferTime && netstream.Connect. ///on NetConnection.bufferLength < netstream.bufferLength and NetStreamInfo.. monitor the NetStream.5.TIMER. there are probably network issues.start(). In this case. netStreamMonitorTimer. Last updated 8/30/2010 .info. you can monitor the NetStream. netStreamMonitorTimer.Success: netStream. In this case.byteCount is not increasing. The following table summarizes the events and properties for the Stream Reconnect feature: Property Server version E_PLAY Notification and Authorization F_STREAM_OFFSET F_STREAM_TRANSITION 3.bufferLength and NetStreamInfo.FLASH MEDIA SERVER 4.5 Read-only. When NetStream.byteCount is not increasing. private function timerHandler(e:TimerEvent):void{ if(netstream. when you call NetStream.bufferTime.3 3.. netStreamMonitorTimer. timerHandler).byteCount == lastByteCount) { // Network has issues.Closed" message. there are probably network issues. } lastByteCount = netstream. } Monitoring an RTMPS or RTMPT connection For RTMPS and RTMPT connections.bufferLength is less than NetStream. ///on NetConnection.attach(netconnection2). When NetStream.byteCount == lastByteCount) { // Network has issues. timerHandler). lastByteCount = 0.bufferLength < netstream.Closed" event may arrive late or may never arrive.TIMER.bufferLength is less than NetStream. reconnect to a new NetConnection netconnection2 = new NetConnection().0 DEVELOPER’S GUIDE Developing streaming media applications 76 Monitoring a connection on a mobile device Some mobile devices cannot receive a "NetConnection.byteCount properties in a timer to discover network issues.bufferTime. Read and write.byteCount properties in a timer to discover network issues. } Authorization plug-in events and properties Use the E_PLAY event of the Authorization plug-in to control streaming that occurs after a reconnection.addEventListener(TimerEvent. reconnect to a new NetConnection netconnection2 = new NetConnection().bufferTime && netstream. There is one new property: F_STREAM_OFFSET. netStreamMonitorTimer.Connect. private function timerHandler(e:TimerEvent):void{ if(netstream.attach(). and NetStreamInfo. the "NetConnection.

When you specify the offset property. For Stream Reconnect. any data buffered from a previous stream is flushed.time). the transition modes are “resume” and “appendAndWait”. The values for Stream Reconnect are “resume” and “appendAndWait”. A stream has stopped playing.play2() call. Last updated 8/30/2010 .1 About fast switching Use the NetStreamPlayOptions. Flash Player 10. For more information about More Help topics “Developing an Authorization plug-in” on page 147 Server logging The following events are written to the Flash Media Server access log for the Stream Reconnect feature: Event connect Category session Description A client has connected to a Flash Media Server application. Users don’t have to wait for buffered data to play. In this mode. and users can experience a delay before the new stream starts playing.time + NetStream. The server does not wait to find a keyframe.0 DEVELOPER’S GUIDE Developing streaming media applications 77 The F_STREAM_TRANSITION property indicates the transition mode sent by the client in the NetStream.FLASH MEDIA SERVER 4. The default value of offset is -1.bufferLength). A stream has resumed playing. Data from the old stream can build up in Flash Player. You can optionally display these fields in the authEvent. x-soffset These fields are disabled by default. The offset value indicates where to resume streaming after you attach a NetStream. it continues sending the old stream until it finds a keyframe in the new stream. This event is logged when you reestablish a connection after it drops. Fast switching between streams Flash Media Server 4. when the server receives a SWITCH command. the server starts streaming the new stream from the specified index position. The server ignores the offset parameter and uses standard switching in the following scenarios: • The offset value is greater than the current playback time (NetStream.offset property to tell the server when to switch between streams of different bitrates.play2() call.log. in seconds. • The offset value is greater than the buffer (offset > NetStream.log and in the access. which is the standard switching mode. at which the streams switch. The offset is the time. Also.0. play stop stream stream The following fields are new for the Stream Reconnect feature: Field x-trans-mode Description The transition mode sent by the client in the NetStream.

NetStream.offset property to specify where the switch occurs.1 work together to support smart seeking in VOD streams and in live streams that have a buffer.Play. In this case.time when the switch call was made. var nso:NetStreamPlayOptions = new NetStreamPlayOptions(). Seek a live stream within the client-side buffer instead of going to the server for delivery of new video. The stream cannot switch.3 and Flash Player 10. You can step forward and backward a specified number of frames. Smart seeking uses back and forward buffers to seek without requesting data from the server.start = 10.3.Play. nso.streamName = streamName. Flash Player ignores data for the new stream until it finds a keyframe in the new stream that is ahead of its playback time.Play.transition = NetStreamPlayTransitions.len = -1. Use smart seeking to create: • Client-side DVR functionality.FLASH MEDIA SERVER 4. Writing the fast switching code Use the NetStreamPlayTransitions.Play.Play. NetStatus events for fast switching NetStatus Event NetStream. This condition can happen in high latency environments and when the offset parameter is too close to NetStream.Failed Description The value of offset is less than the current playhead time. when the data from the server arrives for the new stream. Flash Player 10.Transition A SWITCH call was made successfully and the server starts streaming data for the new stream. This value causes the server to switch the stream 3 seconds into the buffer. Last updated 8/30/2010 . ns.play2(nso). nso.5.TransitionComplete event is much shorter than in standard switching mode.time + 3.1 About Smart Seek Flash Media Server 3. NetStream.Transition event and the NetStream. Note: If the application does not specify an offset value.time. // play until the end of the file nso.TransitionComplete Smart Seeking Flash Media Server 3. nso.time. nso. Use the NetStreamPlayOptions. the default value of offset is netStream. (Standard seeking flushes buffered data and asks the server to send new data based on the seek time. the time between the NetStream.5.) Smart seeking reduces server load and improves seeking performance.0 DEVELOPER’S GUIDE Developing streaming media applications 78 • The offset value is greater than NetStream. A new stream starts playing.offset = 30.SWITCH. In fast switching mode.SWITCH constant to trigger stream switches. the offset value is less than NetStream. However.

see the ActionScript 3. • NetStream.step() Steps the playhead forward or back the specified number of frames.1. Smart seeking retrieves data from within these buffers. Using the Smart Seek ActionScript API Smart Seek is supported in Flash Player 10. use the following events: • NetStatusEvent.1 and greater. Note: Smart seeking is not supported in peer-assisted networking applications or with progressive download.0 DEVELOPER’S GUIDE Developing streaming media applications 79 • Trick modes. relative to the currently displayed frame. The forward buffer is a cache of data that hasn’t been displayed. To seek and step within the buffers. and advance in slow-motion. in seconds.description contains the string "client-inBufferSeek". For detailed information about these APIs. The back buffer is a cache of data that has been displayed. fast-rewind. The default value is 30 on the desktop and 3 on mobile. use the following APIs: • NetStream. see the Stream Reconnect and Smart Seek example hosted by Adobe. fast-forward. Flash Player maintains a back buffer and a forward buffer.bufferTime Specifies how long to buffer messages before starting to display the stream.0 Language Reference. For example. use the following APIs: • NetStream.0.seek() Moves the playhead to the time specified in the call.inBufferSeek to true. • NetStream. To control the buffers.seek() is successful.backBufferLength [read-only] The number of seconds of previously displayed data cached for rewinding and playback.info. Dispatched when a call to NetStream.1 and greater: Last updated 8/30/2010 .backBufferTime Specifies how much previously displayed data is cached for rewinding and playback. Before running code. These APIs are not supported in ActionScript 2.step() is successful. To turn on Smart Seek set NetStream.0. Create players that step through frames. test for Flash Player version. • NetStream. Smart Seek ActionScript API Note: The Smart Seek ActionScript API is ActionScript 3. • NetStream.Step. • NetStream. in seconds. The default value is 0. To detect a smart seek.bufferLength [read-only] The number of seconds of data currently in the buffer. For an example of smart seek. you could expose step back and forward buttons only to clients with Flash Player 10. The following code tests for Flash Player version and returns true for 10.Notify Dispatched when a call to NetStream. This is the bufferLength property for the back buffer.1 and greater.FLASH MEDIA SERVER 4.

seek(Number(seekText. calls to NetStream. } if(int(va[1]) < 1) { return false. When a call to NetStream. ns. } if(int(va[1]) > 1) { return true. // Set the forward buffer.inBufferSeek is true.").split(". in seconds.split(" ")[1].seek() use the buffer. debug("fp10..1: // Call this function when you catch NetConnection. set the NetStream.inBufferSeek = true.. The cache is stored in memory.) The following function can seek forward or backward to a number specified in a text field called seekText: public function seekHandler():void { if(ns != null) { ns. adjust the number you pass to the step() and seek() functions. if(int(va[0]) > 10) { return true. ns. try { if(fp10_1) { // If Flash Player is greater than 10. to allow users to rewind 30 minutes before live. For example. fp10_1 = isFP10_1(). turn on smart seeking // and set the size of the back buffer.1. } } catch(e:Error) {} When Smart Seek is turned on. Last updated 8/30/2010 . public function onStart():void{ debug("Flash Player Version: " + Capabilities. } public function isFP10_1():Boolean { var va:Array = Capabilities. } } To create players that step through frames. } if(int(va[0]) < 10) { return false.text)). fast-forward. set backBufferTime to 1800 (60 seconds x 30 minutes). } return true. Set the buffer properties to lower values if the content is intended for netbooks or mobile devices.backBufferTime and NetStream. fast-rewind.seek() is successful.. //.1: "+fp10_1).0 DEVELOPER’S GUIDE Developing streaming media applications 80 public var fp10_1:Boolean.toString().Success public function createNetStream():void{ // Write code to create a NetStream object and a Video object. and advance in slow-motion.description property contains the string "client-inBufferSeek". in seconds.backBufferTime = 30.FLASH MEDIA SERVER 4..version).bufferTime properties. } The following code sets NetStream. (Standard seeking flushes the buffer and sends a request for data to the server.step() when NetStream. These properties specify the amount of data Flash Player stores in the client-side buffer.Connect.inBufferSeek to true to turn on Smart Seek if the Flash Player version is greater than 10. ns. the NetStatusEvent info.seek() or a call to NetStream. To create client-side DVR functionality.version. Testing for a Smart Seek A Smart Seek is a call to NetStream.bufferTime = 10.

break.inBufferSeek = true The default value of inBufferSeek is false. Get the "NetStream.description). } } Smart Seek requires the following: • NetStream. case "NetStream.5.indexOf("client-inBufferSeek") >= 0) trace("A smart seek occured").info.log: Last updated 8/30/2010 .3 • Flash Player 10.0 • The value of the buffers (backBufferLength and bufferLength) must be large enough to fulfill the seek request. else trace("A standard seek occured"). another call to step may return without executing.Notify": var desc:String = new String(event. Flash Player uses standard seeking but throws no compile-time or runtime errors.Notify": trace("Successful NetStream.code) { case "NetStream. More Help topics “Smart seeking” on page 152 Server logging The following events are written to the Flash Media Server access.Step.Step. the NetStatusEvent info. break. Authorization plug-in events and properties Use Authorization plug-in events and properties to log information about smart seeking and to block clients from sending Smart Seek commands to the server.seek() and a call to NetStream. If a step has not completed.info. • Flash Media Server 3. If any of the previous requirements are not met.Notify".step() is successful.0 DEVELOPER’S GUIDE Developing streaming media applications 81 When a call to NetStream.step() call").Seek. if(desc.Step. The following code tests for a call to NetStream.1 • ActionScript 3.step(): private function netStatusHandler(event:NetStatusEvent):void { switch (event.Notify" for the previous call before you call step again.FLASH MEDIA SERVER 4.code property contains the string "NetStream.

You can edit the Application.FLASH MEDIA SERVER 4.0 native bandwidth detection Flash Media Server 3. In addition to enabling and disabling bandwidth detection. call NetConnection. start-transmit stream The server received a startTransmit command.Step. If a client seeks outside the buffer.0 and later support native bandwidth detection from the server to the client. This command asks the server to transmit more data because the buffer is running low. Note: This example is based on the rootinstall/documentation/samples/bandwidthcheck/Bandwidth.0 class that handles events and calls bandwidth detection on the server.Notify" NetStatusEvent. the rate at which the data is sent. Enable bandwidth detection in the Application. Write the client event handler class ❖ Create an ActionScript 3. The server received a stopTransmit command.xml file ❖ Verify that bandwidth detection is enabled in the Application.xml file at the application level or at the vhost level.seek() and NetStream.xml file: <BandwidthDetection enabled="true"> <MaxRate>-1</MaxRate> <DataSize>16384</DataSize> <MaxWait>2</MaxWait> </BandwidthDetection> Bandwidth detection is enabled by default. the client sends a “seek” event. the server does not write these calls to the log file. there could be thousands of calls to NetStream. Detecting bandwidth ActionScript 3.0 DEVELOPER’S GUIDE Developing streaming media applications 82 Event client-seek Category stream Description The seek position when the client calls NetStream. stop-transmit stream Note: If a user interface lets users step through frames. You do not need to write any server-side code.inBufferSeek = true which sends a seekRaw command to the server. you can configure the size of the data chunks the server sends to the client. and the amount of time the server waits between data chunks. null) to intiate bandwidth detection. After the client connects to the server. The server sends chunks of data to the client and waits for a return value from the client.step(). This command asks the server to suspend transmission until the client sends a startTransmit event because there is enough data in the buffer. It must implement the onBWCheck and onBWDone functions: Last updated 8/30/2010 . These calls do trigger a client-side "NetStream. For performance reasons.as sample. The client sends a seekRaw command only for seeks inside the buffer.call("checkBandwidth".

call NetConnection. rest):Number { return 0.display.NET_STATUS.0 DEVELOPER’S GUIDE Developing streaming media applications 83 class Client { public function onBWCheck(. nc. } public function onBWDone(..call() if the connection is successful.NetStatusEvent. and connect to the server: private var nc:NetConnection.addEventListener(NetStatusEvent..length > 0){ bandwidthTotal = rest[0]. like the Bandwidth.. } } } The onBWCheck() function is required by native bandwidth detection.Sprite.AsyncErrorEvent. if (rest. create a NetConnection object. The server calls the onBWDone() function when it finishes measuring the bandwidth. You can call onBWCheck() multiple times. flash. even if the value is 0.connect("rtmp://localhost/bandwidthcheck"). nc.events. It takes an argument.ASYNC_ERROR.FLASH MEDIA SERVER 4. flash. It takes four arguments. rest):void { var bandwidthTotal:Number. This class is a client to the main ActionScript 3. nc...NetConnection.as example file.client = new Client(). netStatusHandler). passing checkBandwidth as the command to execute and null for the response object: Last updated 8/30/2010 . to indicate to the server that the client has received the data. giving it a package and class name of your choice: package { import import import import flash. } 3 In the netStatus event handler. // This code runs // when the bandwidth check is complete. public function Bandwidth() { nc = new NetConnection(). The second and third arguments are not used. .0 class. flash.rest..events.0 class. nc.client property to an instance of the client class. set the NetConnection. asyncErrorHandler). public class Bandwidth extends Sprite { } } You can create the main and client classes in the same file. The first argument it returns is the bandwidth measured in Kbps. The fourth argument is the latency in milliseconds.net.addEventListener(AsyncErrorEvent. trace("bandwidth = " + bandwidthTotal + " Kbps. 2 In the constructor of the main class."). Write the main class 1 Create a main ActionScript 3. The function must return a value.

FLASH MEDIA SERVER 4. Run the sample ❖ Test the main class from Flash or Flash Builder.0.0 native bandwidth detection You can also use native bandwidth detection from ActionScript 2. you can take some action.call("checkBandwidth".code). the Client class displays the bandwidth value.0 file.Connect.0. choose File > New > ActionScript 2.info. Note: This example uses the rootinstall/documentation/samples/bandwidthcheck/BandwidthAS2. ActionScript 2. 2 Do one of the following to verify that native bandwidth detection is enabled: • Open the rootinstall/conf/_defaultRoot_/_defaultVHost_/Application.137 bytes after decompression The connection was made successfully Bandwidth from server to client is 17287 Kpbs In this example.0 to create a new ActionScript 2.Success": // Calls native bandwidth detection code on the server.0 DEVELOPER’S GUIDE Developing streaming media applications 84 public function netStatusHandler(event:NetStatusEvent):void { trace(event.xml file and verify that <BandwidthDetection enabled="true">.code) { case "NetConnection. Just as in ActionScript 3.2. 1 On the server. create a rootinstall/applications/bandwidthcheck folder. call to NetConnection. In your client.xml with the following code and copy it to the rootinstall/applications/bandwidthcheck folder: <Application> <Client> <BandwidthDetection enabled="true"> </BandwidthDetection> </Client> </Application> 3 In Flash Professional. null). nc. switch (event. define functions named onBWCheck() and onBWDone(). When the client connects to the server . // You don't need to write any server-side code. 4 Open the Actions panel and paste the following code into frame 1: Last updated 8/30/2010 . } } Note: The checkBandwidth() method belongs to the Client class on the server. • Create an Application.call("checkBandwidth").info.swf .fla sample. such as choosing a video to stream to the client based on the client’s bandwidth. The following is the Flash Builder output showing the client’s bandwidth: [SWF] C:\samples\Bandwidth\bin\Bandwidth-debug. break.

A B C Latency between the origin server and the edge server can affect the bandwidth measurement. Script-based bandwidth detection determines the bandwidth from the origin server to the client. Edge server C. Script-based bandwidth detection is not as reliable as native bandwidth detection. } function checkBandwidth(){ nc. it might affect the bandwidth calculation.onBWDone = function(bandwidth){ trace("Bandwidth from server to client is: " + bandwidth + " Kbps").code). Origin server B. If latency exists between the origin server and the edge server. If you use edge servers.FLASH MEDIA SERVER 4. the server-side code calls the native checkBandwidth() function on the server: application. } When initiating bandwidth detection from the server. } } nc.asc. nc. To see an example. A. Initiate native bandwidth detection from a server-side script You can initiate native bandwidth detection from a server-side script. open rootinstall/samples/applications/vod/main. disable native bandwidth detection. In this case.call("checkBandwidth"). not from the edge server to the client.onBWCheck = function(dataChunk){ return 0. For example.connect("rtmp://localhost/bandwidthcheck"). Client Last updated 8/30/2010 . Server-side script-based bandwidth detection You can disable native bandwidth detection and use a server-side script that defines the checkBandwidth function. if(info.onStatus = function(info){ trace(info. You can disable native bandwidth detection at the application level or at the vhost level.checkBandwidth(). if you have a legacy application that uses a server-side script to perform bandwidth detection.Success"){ checkBandwidth(). clientObj.acceptConnection(clientObj). The onStatus messages and the bandwidth measurement are traced to the Output panel. 5 Choose Control > Test Movie. } nc.asc server-side script that Adobe provides with the vod application calls the checkBandwidth function. do not call checkBandwidth() from the client.onConnect = function (clientObj){ this. } nc. native bandwidth detection is performed at the outermost edge server to reduce the load on the origin servers.code == "NetConnection.0 DEVELOPER’S GUIDE Developing streaming media applications 85 nc = new NetConnection().Connect. The main.

.length() method to get the length.. and save it as Application. an MP3 file = Stream. <Client> . create a new file. Detecting stream length About detecting stream length Call the server-side Stream.. Note: This path is for the default vhost...mp3").0 DEVELOPER’S GUIDE Developing streaming media applications 86 To disable native bandwidth detection at the application level: 1 Open a text editor. the following code gets the length of a stream located in the streams/_definst_ folder of an application: // for length // for length // for length an FLV file = Stream..xml file in a text editor. which is set by a user or a tool. an MP4 file = Stream. You can edit the Application. as in the following: <Application> . Restart the server or vhost. 2 Locate the BandwidthDetection tag and set the enabled attribute to false. </Client> .xml file for any vhost.length("mp4:parade.length() method. You do not need to restart the server.mp4"). in seconds. To disable native bandwidth detection at the vhost level: 1 Open the rootinstall\conf\_defaultRoot_\_defaultVHost_\Application.length("parade").. The length is measured by Flash Media Server and differs from the duration that onMetaData returns.length("mp3:parade. <BandwidthDetection enabled="false"> </BandwidthDetection> . of an audio or video stream.FLASH MEDIA SERVER 4.xml to the rootinstall/applications/applicationname folder. For example. Last updated 8/30/2010 . You can pass a virtual stream name or a stream name in a URI relative to the application instance.. 2 Copy the following XML into the file: <Application> <Client> <BandwidthDetection enabled="false"> </BandwidthDetection> </Client> </Application> 3 Save the file. Pass the stream name to the Stream. </Application> 3 Save the file.

import classes. for example..length().length( streamName ). Do this within the onConnect handler: application.asc (Server-Side ActionScript) and StreamLength.Sprite. define a function on the client object that calls Stream. var stream:NetStream.connect() to connect to the server: Last updated 8/30/2010 . define a method in server-side code that calls Stream.NetConnection.Video. Write the server-side code A client might need to retrieve the length of a stream stored on the server.length(). .asc. } application. as shown in the following steps. ❖ In main.0 DEVELOPER’S GUIDE Developing streaming media applications 87 Get the length of a stream This example uses Server-Side ActionScript to get the length of a stream. and define variables as usual: package { import flash. } Write the main client class From the main client class. 1 In your client code. var video:Video.media.onConnect = function( client ) { client. import flash..acceptConnection( client ). call NetConnection. and then have the client call it using NetConnection.. 2 Create a new class. import flash. create a package. Note: Use the StreamLength sample. 3 In the constructor for the StreamLength class. if a Flash presentation displays the length of a video to let the user decide whether to play it. } . This line specifies that the onResult() function will handle the result.Responder.events. You also need to write onResult().NetStream.getStreamLength = function( streamName ) { trace("length is " + Stream. import flash.length( streamName )).0).display. import flash. You need to create a Responder object to hold the response: var responder:Responder = new Responder(onResult).net..NetStatusEvent.net.net. see “Deploy an application” on page 10. main. import flash. To do this. var responder:Responder. you call getStreamLength() in the server-side code.as (ActionScript 3. return Stream. To run the sample.FLASH MEDIA SERVER 4. StreamLength: public class StreamLength extends Sprite { var nc:NetConnection.call().

} 6 Write the onResult() function to handle the stream length returned by getStreamLength() on the server: private function onResult(result:Object):void { trace("The stream length is " + result + " seconds"). break. the Responder object. responder = new Responder(onResult).connect("rtmp://localhost/StreamLength"). responder.Connect. switch (event. nc.call().0 DEVELOPER’S GUIDE Developing streaming media applications 88 public function StreamLength() { nc = new NetConnection().code) { case "NetConnection.level: " + event.level). case "NetConnection. create a Responder object that handles its response in a function named onResult().info.text = "The stream length is " + result + " seconds". and failed connection: private function netStatusHandler(event:NetStatusEvent):void { trace("connected is: " + nc. netStatusHandler). netStatusHandler). trace("event.info.NET_STATUS. In it.addEventListener(NetStatusEvent.NET_STATUS. and the name of the stream: // play a recorded stream on the server private function connectStream(nc:NetConnection):void { stream = new NetStream(nc). trace("event. Then call NetConnection.connected ). nc. stream.FLASH MEDIA SERVER 4. "bikes" ).info. stream. } Write the client event handler class ❖ Write a separate class to handle the onMetaData and onPlayStatus events: Last updated 8/30/2010 .Connect.code).code: " + event. rejected connection. } } 5 Write a function to play the stream when a successful connection is made.info.Connect.client = new CustomClient(). break. specifying getStreamLength as the function to call on the server. } 4 Add a netStatus event handler to handle a successful connection.info.Rejected": case "NetConnection.Success": trace("Congratulations! you're connected").Failed": trace ("Oops! the connection was rejected"). nc.addEventListener(NetStatusEvent. connectStream(nc).call("getStreamLength". output.

height + " framerate=" + info.FLASH MEDIA SERVER 4. } public function onPlayStatus(info:Object):void { trace("handling playstatus here").0 DEVELOPER’S GUIDE Developing streaming media applications 89 class CustomClient { public function onMetaData(info:Object):void { trace("metadata: duration=" + info. } } Last updated 8/30/2010 .framerate).width + " height=" + info.duration + " width=" + info.

In a new . To capture and encode live content and stream it to Flash Media Server. • Displays the video as it’s captured. and Flash Lite clients. you can access the video player from the Start Screen at http://localhost. For more information about Flash Media Live Encoder.org. and streams it to Flash Media Server. Flash Media Server installs with a sample video player that can play streams from the live service. AIR. Note: To test this code.adobe. By default. You can capture live events in real time and stream them to large audiences or create social media applications that include live audio and video.as file.connect() method. see Beginner’s guide to streaming live video with Flash Media Server 3 at www.adobe. see www. To connect to the server. More Help topics “Streaming live media” on page 13 Example: Custom video capture application The following steps build an application in ActionScript 3. The video player is installed to the folder rootinstall\samples\videoPlayer. To learn how. you can use Adobe Flash Media Live Encoder or build a custom Flash Player or AIR application. 1.swf file to connect to the application. • Streams video from Flash Media Server back to the client. For example. Open the rootinstall/documentation/samples/publishlive/PublishLive. • Streams video from the client to Flash Media Server. encodes it. You can also use the FLVPlayback component in Flash as a video player. Flash Media Live Encoder is configured to stream video to the live service at rtmp://localhost/live.0 that: • Captures and encodes video. Capturing live video Using Flash Media Live Encoder to capture video Flash Media Live Encoder is a free application that captures live video. pass the URI of the application to the NetConnection. see osmf. create a NetConnection object.com/go/learn_fms_livestream_en. create a rootinstall/applications/publishlive folder on the server. Adobe® Acrobat® Connect™ Pro is a web conferencing application that uses Flash Media Server to capture and broadcast live audio and video. For more information. • Displays the video streamed from the server.90 Chapter 4: Working with live video Adobe Flash Media Server can broadcast live audio and video content to Flash Player.com/go/fme. Last updated 8/30/2010 . The sample video player is based on Strobe Media Playback built on Open Source Media Framework. If you installed the Apache web server.

vid.x = 10.attachCamera(cam) to attach the camera video feed to the video object. Finally. onNetStatus). ns:NetStream. "live"). function onNetStatus(event:NetStatusEvent):void{ trace(event.code). the code calls functions that run the application. Call Video. displayPlaybackVideo().info. if(event.attachCamera(cam). cam:Camera.attachCamera() to attach the captured video to the NetStream object. 2.attachAudio() to attach the live audio. vidPlayer:Video.NET_STATUS.attachAudio(mic). Last updated 8/30/2010 . Create a Video object.publish("streamName". get references to the camera and microphone data. call NetStream.0 DEVELOPER’S GUIDE Working with live video 91 var var var var var var var nc:NetConnection. mic = Microphone. Define a function to handle NetStatusEvent events.getMicrophone(). Display the video the client is streaming to the server. ns. Call addChild(vid) to add the Video object to the display list so that it appears in Flash Player. mic:Microphone.FLASH MEDIA SERVER 4. while a client playing a stream is subscribing.Connect. Call NetStream. function displayPublishingVideo():void { vid = new Video(). ns. Create a NetStream object on the NetConnection you made to the server.publish("myCamera". ns.getCamera(). Publish the video being captured by the camera and the audio being captured by the microphone. displayPublishingVideo(). an outgoing (publishing) stream and an incoming (subscribing) stream. Display the video the server is streaming to the client. vid:Video. The client must create two streams. nc. } 5. In this example.code == "NetConnection.addEventListener(NetStatusEvent. If the client makes a successful connect to the server. addChild(vid). vid. A client that creates a stream to send to a server is publishing.Success"){ publishCamera(). Then call NetStream. First. } 4.info. the outgoing stream is ns and the incoming stream is nsPlayer.connect("rtmp://localhost/publishlive"). The Video object is a display object. nsPlayer:NetStream. } } 3. function publishCamera() { cam = Camera. You can use the same NetConnection object for both streams. vid. nc. The client in this example publishes a stream and subscribes to a stream. nc = new NetConnection(). ns = new NetStream(nc).y = 10. "live")to send the audio and video to the server.attachCamera(cam).

com/go/fms_featureexplorer. browse in the FMS Feature Explorer to the AVControl > Publish Live Video application. This example was built in Flash.attachNetStream(nsPlayer). and seek to the live section again. Viewers can also rewind a live event.0.x = cam. and use metadata. vidPlayer. vidPlayer = new Video(). multi-bitrate streams synchronized at the server.FLASH MEDIA SERVER 4. The encoder must use absolute time code. play the recorded section.5 supports DVR. To display the incoming video.play() and pass it the name of the stream you published.5 Note: Flash Media Streaming Server does not support DVR functionality. Examples of DVR applications are instant replay and “catch-up” services. } Use ActionScript to allow users to control playback. Contact your encoder vendor to learn how to enable absoulte time code for your encoder. display video fullscreen. Important: The streams must be in sync. Note: The FLVPlayback component version 2. the server does not sync the streams.width + 20. You can view the source code in a viewer built in to the application.0 Developer’s Guide at www. vidPlayer. Third-party encoders also use absolute time code.0 DEVELOPER’S GUIDE Working with live video 92 To play the audio and video as it returns from the server.play("myCamera").y = 10. Follow the instructions to download a ZIP file of the sample applications and extract them to the applications folder on your server. Last updated 8/30/2010 .attachNetStream(): function displayPlaybackVideo():void{ nsPlayer = new NetStream(nc). To see an example built in Flex.adobe. nsPlayer. see the “Working with video” chapter in ActionScript 3. Flash Player does not. Adding DVR features to live video About DVR support Flash Media Server 3. For more information. Flash Player 10. Flash Media Server 3. Absolute time code keeps DVR-enabled.1 To use DVR with a dynamic streaming application. Absolute time code ensures that the server captures all the information required to keep encoder-synchronized streams in sync. call Video. A DVR (digital video recorder) lets viewers pause live video and resumes playback from the paused location. Once the applications are registered with the server.adobe. enable absolute time code on the server. addChild(vidPlayer). Download the component from the Flash Media Server Tools Using DVR with dynamic streaming Flash Media Server 4. use cuepoints. vidPlayer. download the FMS Feature Explorer AIR application at www. Flash Media Live Encoder supports absolute time code. Just write a few lines of code and a video player can act like a DVR.5 adds support for DVR features. call NetStream.com/go/learn_fms_video_en.

Publishing. they’re really viewing the recorded stream just after it was recorded. playing.play("myvideo". 0. use "record" or "append" flags. maxDuration and maxSize. the server assumes that incoming live streams have timestamps that are based on an absolute clock. When a client views the stream “live”. open rootinstall/applications/vod/Application.publish() or Stream. they play a recorded stream.xml file. To subscribe to a stream published for a DVR video player. and seeking DVR video To publish a stream for a DVR video player from a client. The following code publishes a stream with a maximum recording length of 10 mins (600 seconds) and an unlimited file size: Stream.seek(0) Last updated 8/30/2010 . that let you specify the maximum length and file size of a stream. "record") NetStream.record() method has two new parameters. the recorded stream preserves gaps created when a stream stops and restarts. When enabled. see Configuring a single application. When you publish or record a stream in "appendWithGap" mode.record() methods.FLASH MEDIA SERVER 4. -1) When a client plays a stream published for a DVR video player.publish("myvideo". In "append" mode. 2 Add the following to the XML file: <Application> <StreamManager> <Live> <AssumeAbsoluteTime>true</AssumeAbsoluteTime> </Live> </StreamManager> </Application 3 Save the file. 1 Create a new text or XML file and save it to the application’s folder as “Application. such as a SMPTE time signal contained within the encoder's input source. The Stream.xml”. For more information about working with configuration files. -1) The previous code allows viewers joining an event late to view from the beginning. Note: For an example of an application-level Application. The default value is false. as in the following: NetStream. 600. use the following code: NetStream. they don’t play a live stream.record("record".xml configuration file at the application level. call the following: NetStream. To return to the beginning of a stream at any time. pass "appendWithGap" to the NetStream. Gaps are visible to the client when a recorded file is played. "append") To publish a stream for a DVR video player from the server. the server eliminates the gaps which can cause streams to lose sync.publish("myvideo". Gaps can occur when an encoder goes offline and comes back online.0 DEVELOPER’S GUIDE Working with live video 93 Enable absolute time code Enable absolute time code in the Application.record(). Publish and record streams for DVR with dynamic streaming To publish and record DVR streams with dynamic streaming.xml in a text editor. call Stream.

duration. To calculate a stream's duration. Example: Custom capture. set a time stamp in the onMetaData callback function.currentTarget){ case rewindBtn: nsPlayer.seek(nsPlayer. seekVal = (currentDuration . seek to the duration of the stream (the length of the data recorded on the server) minus the value of NetStream.adobe.2.com/go/fme.bufferLength) . Flash Player doesn’t resume playback until the buffer is full.nsPlayer. duration = info. • Displays the video as it’s captured.duration). } To seek to “live”. Using Flash Media Live Encoder to capture video for DVR playback You can use Flash Media Live Encoder 3 to capture video for DVR playback. Last updated 8/30/2010 . trace("currentDuration: " + currentDuration). publish.0 DEVELOPER’S GUIDE Working with live video 94 To start recording in the middle of an event. • Streams video from Flash Media Server back to the client.5).record() method.seek(getSeekToLiveValue()). return seekVal. public function onMetaData(info:Object):void{ trace("metadata:duration=" + info. Earlier versions of Flash Media Live Encoder do not support recording to the server.FLASH MEDIA SERVER 4. break. stamp = getTimer(). see http://www.bufferTime. To create a button that seeks to the latest available part of the recording (which is considered “live”). Calling this method lets you start and stop recording at any time. } } Note: The previous code is in the DVR sample in the rootinstall/documentation/samples/dvr folder on the server. calculate the current duration. nsPlayer. and DVR playback This example is a client application that does the following: • Captures and encodes video. Subtract bufferTime to make playback as close to instanteous as possible. call the Server-Side ActionScript Stream. call the getSeekToLiveValue() function on the playback NetStream object: private function onClick(event:MouseEvent):void { switch(event. For more information. break. and subtract the bufferTime minus an additional 2 seconds for safety.time . private function getSeekToLiveValue():uint{ currentDuration = Number((getTimer()-stamp)/1000) + duration. • Streams video from the client to Flash Media Server. } To calculate the value to pass to the seek() method. case seekBtn: trace("seekToEndValue " + getSeekToEndValue()). trace("stamp: " + stamp).

display.uint. private var ns:NetStream.net. private var mic:Microphone. import flash. private var playBtn:Button. private var seekBtn:Button. private var pauseBtn:Button. onNetStatus). create a RootInstall/applications/dvr folder on the server.controls.swf file to connect to the application. private var cam:Camera. create a RootInstall/applications/dvr folder. dvrFlag = true. private var seekVal.Video.getTimer. displayPlaybackVideo().code){ case "NetConnection. Note: To test this code. import flash.media. private var vidPlayer:Video.code).info. private var rewindBtn:Button.Microphone. import fl.NET_STATUS. 1 On Flash Media Server.as.addEventListener(NetStatusEvent.Start": trace("dvrFlag " + dvrFlag). private var vid:Video. import flash. switch(event. create an ActionScript file and save it as DVR. 3 Copy and paste the following code into the Script window: package { import flash. } private function onNetStatus(event:NetStatusEvent):void{ trace(event. private var stamp:uint. if(dvrFlag){ nsPlayer.info. 2 In Flash. nc. public class DVR extends MovieClip { private var nc:NetConnection. import flash.*. break. public function DVR() { nc = new NetConnection().Camera.0 DEVELOPER’S GUIDE Working with live video 95 • Displays the video streamed from the server in a player that lets you rewind and pause live video.net. private var duration:uint.FLASH MEDIA SERVER 4.media.media. Last updated 8/30/2010 . import flash. displayPublishingVideo(). case "NetStream. import flash.Connect.NetStream.Button.connect("rtmp://localhost/dvr").Play. private var dvrFlag:Boolean.NetConnection.utils. import flash.Success": publishCamera(). Open the RootInstall/documentation/samples/dvr/DVR. nc.seek(getSeekToLiveValue()). private var currentDuration:uint.events.MovieClip. private var nsPlayer:NetStream. setupButtons().

play("video".addEventListener(NetStatusEvent.time . vid. } private function onClick(event:MouseEvent):void { switch(event. nsPlayer. onAsyncError). nsPlayer. case seekBtn: nsPlayer. vid. cam.resume().pause().addEventListener(NetStatusEvent. break.x = cam.FLASH MEDIA SERVER 4. ns. case pauseBtn: nsPlayer.width + 20.getCamera(). } private function displayPlaybackVideo():void{ nsPlayer = new NetStream(nc).attachAudio(mic).x = 10. nsPlayer. onNetStatus). break. ns. ns. ns. Last updated 8/30/2010 .NET_STATUS. break. case playBtn: nsPlayer. vidPlayer. vidPlayer.seek(nsPlayer.addEventListener(AsyncErrorEvent. } break.client = this.0 DEVELOPER’S GUIDE Working with live video 96 dvrFlag = false.height). } } private function onAsyncError(event:AsyncErrorEvent):void{ trace(event. cam. mic = Microphone.client = this.attachCamera(cam). vid.5).attachCamera(cam).addEventListener(AsyncErrorEvent.currentTarget){ case rewindBtn: nsPlayer. } private function displayPublishingVideo():void { vid = new Video(cam. vidPlayer = new Video(cam. 0.width.seek(getSeekToLiveValue()). onAsyncError). addChild(vid). addChild(vidPlayer).ASYNC_ERROR.text). onNetStatus).NET_STATUS. break. } } private function publishCamera() { cam = Camera. ns.getMicrophone(). vidPlayer. ns = new NetStream(nc). nsPlayer. "record").publish("video".y = 10.attachNetStream(nsPlayer).y = 10. ns. } private function getSeekToLiveValue():uint{ currentDuration = Number((getTimer()-stamp)/1000) + duration. -1).width.height).ASYNC_ERROR.

seekBtn. drag a Button to the Stage. trace("seekVal: " + seekVal). playBtn.move(345. trace("stamp: " + stamp).label = "Seek to Live". pauseBtn = new Button().nsPlayer.move(290. This action adds the button to the Library.0) and click OK.move(235. pauseBtn. } public function onMetaData(info:Object):void { trace("metadata:duration = " + info. Click the Flash tab. Last updated 8/30/2010 . onClick). addChild(playBtn).2. 150). onClick). addChild(seekBtn).CLICK.addEventListener(MouseEvent. 5 Choose File > New > Flash File (ActionScript 3.addEventListener(MouseEvent. addChild(pauseBtn). seekVal = (currentDuration . } } } 4 Save the DVR. playBtn. seekBtn. Click the checkmark to validate the path.fla in the same folder as the DVR. rewindBtn. onClick). rewindBtn. playBtn.label = "Pause". rewindBtn. 6 Save the file as DVR. duration = info. seekBtn.150). playBtn. } private function setupButtons():void { rewindBtn = new Button().150). seekBtn = new Button().0 DEVELOPER’S GUIDE Working with live video 97 trace("currentDuration: " + currentDuration).duration).width = 52. Click Script Settings and enter DVR as the Document class. 7 Open the Components Panel. pauseBtn. and delete it.width = 100.as file. playBtn = new Button().label = "Play".width = 52. pauseBtn. The button is added to the application at runtime.CLICK. addChild(rewindBtn).150).as file.addEventListener(MouseEvent. onClick).CLICK.duration.move(180. return seekVal.FLASH MEDIA SERVER 4.label = "Rew 5s". rewindBtn.width = 52.CLICK. 8 Choose File > Publish Settings.addEventListener(MouseEvent. 9 Save the file and choose Control > Test Movie to run the application. seekBtn. stamp = getTimer().bufferTime) . pauseBtn.

The Authorization plug-in can override this value. which enforces no cap on maximum size. in the Application. The Authorization plug-in can override this value. use the server-side NetConnection class to chain multiple servers together. and the Authorization plug-in. Specifies whether to separate the cache subdirectories by application.FLASH MEDIA SERVER 4. The default value is -1. The server-side Stream. The default value is -1. a client can request a stream that does not reside on the server to which it is connected. Server-Side ActionScript.xml file.xml file you can set maximum cap values.record() and pass values for the maxDuration and maxSize parameters.record() method cannot override this value. The following code limits the recording to 5 minutes and sets an unlimited maximum file size (up to the value of MaxSizeCap): s. -1). in kilobytes. which enforces no maximum size. in seconds.xml configuration file. Set these values to prevent using excessive disk space. which enforces no maximum duration. Application/StreamManager/Recording/MaxSizeCap In addition to setting maximum values. which enforces no cap on maximum duration. in kilobytes.record("record". The maximum size of a recording cap.0 DEVELOPER’S GUIDE Working with live video 98 Limiting the size and duration of recordings You can limit the maximum size and duration of recordings using parameters in the Application.xml configuration file to configure the disk cache that holds the streams: XML element VirtualHost/Proxy/CacheDir Attribute enabled useAppDir Description Determines whether the disk cache is enabled. The default value is -1. The default value is -1. You can set values in the Vhost. The maximum duration of a recording cap. The server-side Stream. Use the server-side ProxyStream class to create a look-up mechanism for finding streams in the server chain. The server truncates recordings greater than MaxCapSize and MaxCapDuration. Server-side scripts cannot override these caps. in seconds. CDNs can use these caps to set a limit that clients cannot override. In this scenario.xml file parameters: XML element Application/StreamManager/Recording/MaxDuration Description The maximum duration of a recording. call Stream. Application/StreamManager/Recording/MaxDurationCap Application/StreamManager/Recording/MaxSize The maximum size of a recording. Last updated 8/30/2010 .record() method cannot override this value. Note: The Authorization plug-in can override any values set in the Application. 300. The following are the Application. More Help topics “Developing an Authorization plug-in” on page 147 Scaling DVR applications To build large-scale applications. To set values in Server-Side ActionScript.

it logs the following warning message in the core. You can write code that tells Flash Media Server to send metadata to clients whenever they connect to a live stream.log for each segment that fails to write to disk:I/O Failed on cached stream file C:\Program Files\Adobe\Flash Media Server 3.5_361\applications\primaryapp\streams\_definst_\sample1_1500kbps. In a recorded stream. a special data message is inserted at the beginning of the media file that provides metadata. copyright information. However. Last updated 8/30/2010 . such as title.192.0 DEVELOPER’S GUIDE Working with live video 99 XML element VirtualHost/Proxy/CacheDir/Path VirtualHost/Proxy/CacheDir/MaxSize Attribute Description The root directory of the disk cache. In DVR applications (and in all recorded video applications) the onMetaData() method is called at the beginning of the stream and during events such as seek and pause. Any client connecting to the server. The default value is 2 seconds.5\cache\streams\00\proxyapp\10. point each virtual host to its own cache directory. You can also use this feature to add metadata to a live stream at any time during a broadcast. The maximum amount of time to wait for a response to a request (for metadata. receives the metadata when it plays the live video. content. If the server runs out of disk space on an intermediate or edge server while writing to the CacheDir. Logging Streams played in a DVR video player are played as recorded streams. or creation date.f4v\0000000000000000 during write: 28 No space left on device. Metadata can contain information about the video. they miss receiving the data keyframe. even if they connect late. These streams log the same events in the log files as every recorded stream. The default value is 32. VirtualHost/Proxy/RequestTimeout If a server has multiple virtual hosts. when a client connects to a live stream during the broadcast. and so on) from an upstream server.125\C\Program Files\Adobe\Flash Media Server 3. The value -1 specifies no maximum value. Note: Because DVR applications use recorded streams.FLASH MEDIA SERVER 4. The value 0 disables the disk cache.16. More Help topics “Dynamic streaming” on page 65 Adding metadata to a live stream About metadata Metadata in streaming media gives subscribers the opportunity to get information about the media they are viewing. A client can use the metadata to set the width and height of the video player.. you do not need to use data keyframes to push metadata to the client. in seconds. duration of the video.xx. Any client that connects to Flash Media Server receives the metadata when it plays the recorded stream. The maximum size of the disk in gigabytes.

@setDataFrame.client property to an object. for (key in info) { trace(key + ": " + info[key]). "onMetaData"). pass a special command. handle the data on the client the same way you would handle any message from the send() method.send() method: NetStream. To clear metadata from a live stream in a client-side script. call the NetStream. metaData = new Object().height = 200.send(@setDataFrame.send()method or to the server-side Stream. function onMetaData(info:Object):void { var key:String.send("@clearDataFrame".0 DEVELOPER’S GUIDE Working with live video 100 Sending metadata to a live stream To send metadata to clients when they connect to a live stream.send("@setDataFrame".get("myStream"). onMetaData2. metaData).width = 400. metaData. assign the NetStream.title = "myStream". To send the command from the client. Each metadata item is a property with a name and a value set in the metadata object. You can create multiple data keyframes. "onMetaData". To add metadata to a live stream in a client-side script. Even if you send the @setDataFrame message from the server. To add metadata to a live stream in a server-side script. To clear metadata from a live stream in a server-side script. onMetaData [. so that the metadata you set can be easily read. use client-side code to retrieve it. and so on). Define an onMetaData function on that object.title = "myStream".send() method.metadata ]) The onMetaData parameter specifies a function that handles the metadata when it’s received. metaData).send("@setDataFrame". } } This function outputs the metadata added by the server and the metadata sent with @setDataFrame. "onMetaData"). To retrieve metadata. "onMetaData".width = 400. metaData.height = 200. You can use any name. use the following code: s. as in the following: netstream. s.send("@clearDataFrame". to the client-side NetStream. You cannot retreive metadata from server-side code. Whether the command is sent from the client or the server.FLASH MEDIA SERVER 4. metaData. onMetaData1. metaData. Retrieving metadata You can retrieve metadata from client-side code only. Last updated 8/30/2010 . but Adobe recommends that you use common names. metaData. ns. use the following code: var metaData:Object = new Object(). metaData. The metadata parameter is an Object or Array (or any subclass) that contains the metadata to set in the stream. Each data keyframe must use a unique handler (for example. use the following code: ns.client = this. Pass a handler name to the send() method and define a function with that name to handle the data. use the following code: s = Stream.

• Sends metadata to the server that the server sends to clients when they play the live stream. • Streams video from Flash Media Server back to the client when you click a button. If the server doesn’t find a recorded stream. "append"). Open the RootInstall/documentation/samples/metadata/Metadata.0 DEVELOPER’S GUIDE Working with live video 101 To have the server add metadata in addition to any messages you send with the @setDataFrame message. 3 Copy and paste the following code into the Script window: Last updated 8/30/2010 .as. 0). the server does not add standard metadata to the file. netstream. Note: If you publish a live video to the server with the "live" flag or without a type parameter. create a RootInstall/applications/publishlive folder.play() and pass a value for the start parameter to indicate that the stream is a recorded live stream: netstream. 2 In Flash.swf file to connect to the application. • Displays the video streamed from the server. publish the video with the "record" flag or the "append" flag.publish("mycamera". the client plays the recorded stream starting from the time given. the server does not record the video. • Streams video from the client to Flash Media Server. 1 On Flash Media Server. create an ActionScript file and save it as Metadata.play("mycamera". The recorded stream includes the standard metadata added by the server. it ignores the play() method. To play the stream.publish("mycamera". // Plays a live stream. Note: To test this code.FLASH MEDIA SERVER 4. -2). netstream. If you pass -2 or -1 for the start parameter. // Plays a recorded live stream. • Displays the metadata sent from the server in a TextArea component. If you pass 0 or greater for the start parameter. "record"). as in the following: netstream. In this case.play("mycamera". call NetStream. // Looks for a live stream first. -1). • Displays the video as it’s captured.play("mycamera". the client plays the live video and does not receive the standard metadata: netstream. Example: Add metadata to live video This example is a client application that does the following: • Captures and encodes video. create a RootInstall/applications/publishlive folder on the server.

target + ": " + event. private var mic:Microphone. break. private var outputWindow:TextArea.info.AsyncErrorEvent. import fl. import flash. } } private function startHandler(event:MouseEvent):void { displayPlaybackVideo(). nc = new NetConnection(). nc. private var incomingLbl:Label. private var cam:Camera.NetStatusEvent. Last updated 8/30/2010 .addEventListener(NetStatusEvent. displayPublishingVideo(). } private function onNetStatus(event:NetStatusEvent):void { trace(event.FLASH MEDIA SERVER 4.media. private var ns:NetStream. public class Metadata extends MovieClip { private var nc:NetConnection.media. import flash. } /* * Clear the MetaData associated with the stream */ private function clearHandler(event:MouseEvent):void { if (ns){ trace("Clearing MetaData"). import flash.events. private var outgoingLbl:Label. import flash.NetStream. import flash.send("@clearDataFrame". private var vidPlayer:Video.code). private var startPlaybackBtn:Button. "onMetaData").connect("rtmp://localhost/publishlive").NetConnection. nc.0 DEVELOPER’S GUIDE Working with live video 102 package { import flash.net.events.TextArea. onNetStatus).controls.media.events. private var clearBtn:Button. public function Metadata(){ setupUI().code) { case "NetConnection. import fl. private var myMetadata:Object.Label.MouseEvent.display.Connect. switch (event.Success": publishCamera(). private var nsPlayer:NetStream.info. import flash.controls. import flash.Microphone.MovieClip.controls.Video.net.NET_STATUS.Button. import flash.Camera. private var vid:Video. ns. import fl.

vidPlayer. } private function displayPlaybackVideo():void { nsPlayer = new NetStream(nc).addEventListener(AsyncErrorEvent.client = this. asyncErrorHandler).".move(250.NET_STATUS.ASYNC_ERROR. outgoingLbl. } private function sendMetadata():void { trace("sendMetaData() called") myMetadata = new Object(). vid. outgoingLbl. } private function publishCamera():void { cam = Camera.getCamera(). } private function displayPublishingVideo():void { vid = new Video(cam. onNetStatus). mic = Microphone. break. ns. 175). ns = new NetStream(nc). myMetadata. ns. nsPlayer.height). incomingLbl. } } private function asyncErrorHandler(event:AsyncErrorEvent):void { trace(event.send("@setDataFrame".width.ASYNC_ERROR. vid.addEventListener(NetStatusEvent.text).x = cam. incomingLbl = new Label().Start": sendMetadata(). onNetStatus).width.Publish.y = 10.attachCamera(cam). nsPlayer.0 DEVELOPER’S GUIDE Working with live video 103 case "NetStream.x = 10.height).width = 150. addChild(vid). asyncErrorHandler). } private function setupUI():void { outputWindow = new TextArea().height = 150. ns. vid.addEventListener(NetStatusEvent. outputWindow. Last updated 8/30/2010 .FLASH MEDIA SERVER 4. ns. cam.width = 150. "record"). outputWindow.y = 10. vidPlayer = new Video(cam. addChild(vidPlayer).NET_STATUS. outputWindow. ns.width + 100.getMicrophone().customProp = "Welcome to the Live feed of YOUR LIFE.attachAudio(mic).attachCamera(cam).addEventListener(AsyncErrorEvent. already in progress.play("myCamera". ns. 0). nsPlayer.text = "Publishing Stream". "onMetaData". nsPlayer. myMetadata). vidPlayer. ns. outgoingLbl = new Label(). cam.attachNetStream(nsPlayer).publish("myCamera". vidPlayer.client = this.width = 250.

clearBtn.addEventListener(MouseEvent.0 DEVELOPER’S GUIDE Working with live video 104 incomingLbl.fla in the same folder as the Metadata.move(300. 150).FLASH MEDIA SERVER 4. The components are added to the application at runtime. 5 Choose File > New > Flash File (ActionScript 3. incomingLbl. 9 Save the file and choose Control > Test Movie to run the application.move(250. The width of the video.CLICK. Last updated 8/30/2010 .width = 100. startPlaybackBtn. clearBtn. 6 Save the file as Metadata.345).as file. clearBtn = new Button(). 8 Choose File > Publish Settings. addChild(startPlaybackBtn). addChild(clearBtn).label = "Clear Metadata". startPlaybackBtn. 345) startPlaybackBtn. outgoingLbl. clearHandler). You do not need to add this metadata to live streams: Metadata property name lastkeyframetimestamp width height Data type Number Number Number Description The timestamp of the last video keyframe recorded. startHandler).move(30. in pixels.0) and click OK.move(135. addChild(outputWindow).appendText(key + ": " + info[key] + "\n").CLICK.addEventListener(MouseEvent. Flash Media Live Encoder metadata properties Flash Media Live Encoder sets the following metadata properties and values. and delete them. } public function onMetaData(info:Object):void { var key:String. clearBtn. } } } } 4 Save the file. The height of the video. clearBtn.width = 150. in pixels. 150).text = "Playback Stream". startPlaybackBtn. addChild(incomingLbl).label = "View Live Event". addChild(outgoingLbl). for (key in info){ outputWindow. 7 Open the Components Panel. Click the checkmark to validate the path. This action adds the components to the Library. Click Script Settings and enter Metadata as the Document class. drag a Button and a TextArea component to the Stage. Click the Flash tab. startPlaybackBtn = new Button().

The creator of the file. The frames per second at which the video was recorded. Values are: 0 Uncompressed 1 ADPCM 2 MP3 5 Nellymoser 8kHz Mono 6 Nellymoser 10 HE-AAC 11 Speex canSeekToEnd createdby Boolean String Whether the last video frame is a keyframe (true if yes. To record a file as you publish it to the server. The creation date of the file.263 3 Screen video 4 On2 VP6 5 On2 VP6 with transparency 7 H.0 DEVELOPER’S GUIDE Working with live video 105 Metadata property name videodatarate audiodatarate framerate creationdate createdby audiocodecid Data type Number Number Number String String Number Description The video bit rate. Metadata property name audiocodecid Data type Number Description The audio codec ID used in the file. Values are: 2 Sorenson H. in seconds. Metadata properties for recorded live streams If you record the file as you stream it. false if no). Values are: 0 Uncompressed 1 ADPCM 2 MP3 5 Nellymoser 8 kHz Mono 6 Nellymoser 10 HE-AAC 11 Speex videocodecid Number The video codec ID used in the file. use the "record" parameter.publish("myCamera". as in the following: ns.264 audiodelay Number The delay introduced by the audio codec. The audio codec ID used in the file. "record"). The audio bit rate. Last updated 8/30/2010 . Flash Media Server adds the metadata listed in the following table. The name of the file creator.FLASH MEDIA SERVER 4.

Capturing timecode sent from Flash Media Live Encoder Flash Media Live Encoder can embed SMPTE timecode. are also saved in the file. Publishing live video in RAW file format Flash Media Server 3.FLASH MEDIA SERVER 4. If there is a conflict between the two. Recordings stop immediately on keyframes or I-frames. creationdate. see www.0 DEVELOPER’S GUIDE Working with live video 106 Metadata property name duration creationdate videocodecid Data type Number String Number Description The length of the file. in seconds. suppose you add these metadata properties: duration=5 x=200 y=300 When the server starts to record the video. The other properties the server sets. any version of Flash Player can publish or play a RAW stream. including H. such as audiocodecid.264 When you use the "record" flag with the NetStream. and Visual Timecode (BITC) in a stream and pass to Flash Media Server. However. The video codec ID used in the file. and so on. the server uses the standard metadata properties.3 About the RAW file format The RAW (Record and Watch) file format records media into configurable chunks that stream to any version of Flash Player. and so on. the server attempts to merge your metadata properties with the standard metadata properties. it begins to write its own metadata properties to the file. Vertical Interval Timecode (VITC). overwriting the value you specified. Use the RAW file format to serve long-length. the recording starts at a keyframe. multi-bitrate DVR streams without running into performance issues. audio-only. The RAW file format records and plays back all streams that Flash Media Server supports. data-only. The date the file was created. To capture the timecode.264 video. Last updated 8/30/2010 . However.5. the server adds duration=20 to the metadata.com/go/learn_fms_timecode_en. videocodecid. x=200 and y=300 are still saved as metadata. Values are: 2 Sorenson H. For more information. including duration. implement the OnFI method on the NetStream object. The RAW file format is a server feature. When a stream is recorded.adobe. multi-bitrate stream support (also called dynamic streaming) requires Flash Player 10 and higher. because they create no conflict. If the recording is 20 seconds long. For example.publish() call.263 3 Screen video 4 On2 VP6 5 On2 VP6 with transparency 7 H.

The files are stored in a folder whose name is the name of the stream. Suppose the stream “foo” is stored in a folder named “foo”. The first segment name is always 0. ns. and so on. "record"). More Help topics “Dynamic streaming” on page 65 Streaming RAW files Note: Both ActionScript 2. the file system may not be able to access the directory fast enough for recording or playback to keep up. There is one file for each segment of the stream. If the first segment contains 234 messages. The “foo” folder contains the following files: index. and so on.0 and ActionScript 3. 00000000000001C3. nc.FLASH MEDIA SERVER 4. context. test for a successful NetConnection here ns:NetStream = new NetStream(nc). // You can use the "record" or the "append" flag.connect("rtmp://fms.264 and AAC 4 hours (x 2 Mbit = 7 GB size) Depends on origin-edge configuration.example. Note: Raw streams with long durations create many files in a single directory. use the prefix raw: in the NetStream.publish("raw:livestream". 0000000000000000.get() call.0 does not support the RAW file format. // In production code. The following Server-Side ActionScript records a live stream as a RAW stream: Last updated 8/30/2010 .com/live").publish() call or in the Stream. The number of files is the stream index of the first message in the segment. 0000000000000386. Contains all the “context messages” for the stream. At this time. you cannot edit these files with thirdparty tools or convert the files to FLV format or MP4 format. Flash Media Live Encoder 3. the next segment name is EA.0 support the RAW file format. The following client-side ActionScript uses the RAW file format to publish a live stream: nc:NetConnection = new NetConnection(). The RAW file format is an FLV file fragmented into the following files: Filename index context A 16-digit hexadecimal number Description Contains the list of segment files and their timestamp ranges. Depending on system resources. To record a live stream as a RAW stream.0 DEVELOPER’S GUIDE Working with live video 107 Important: The RAW file format is internal to Flash Media Server. The RAW file format enables Flash Media Server to handle up to the following scenario: Parameter Simultaneous DVR streams Bit rate of each stream Codecs Stream duration Number of clients Value 25 2 Mbit H.

b In the Output section. Validating RAW files and reading error messages To check if a RAW stream is valid. 6 To view playback.record(). -1) To use Flash Media Live Encoder.html in a browser.adobe. The RAW format supports all the codecs that Flash Player supports. The raw files are generated in this folder.play("raw:livestream". do the following: a Open rootinstall/samples/videoPlayer/videoplayer.0 and written to the log files: Last updated 8/30/2010 .com/go/fms_tools and do the following: a Unzip the package. enter rtmp://localhost/dvrcast_origin/raw:livestream. enter raw:livestream. You can use the server-side script in the DVRCast application. c To verify that the application is registered with the server. use the prefix raw: in the Stream field.0 DEVELOPER’S GUIDE Working with live video 108 s = Stream. The following example uses Flash Media Live Encoder and the DVRCast application. Click View Applications and select dvrcast_origin from the New Instance menu at the bottom of the screen. Use a server-side script to record the stream. d Click Play Stream. s. 0. if you have a RAW stream named “foo” in the folder “C:\media\foo”.com/go/fms_tools. -1). Download the DVRCast application from www.play("livestream". c For stream. b Copy the dvrcast1_1\DVRCast1. open the Flash Media Server Administration Console.com/go/fmle. 4 Open Flash Media Live Encoder and do the following: a Choose a preset. s.1\adobe\fms\samples\applications\dvrcast_origin folder and its contents to the Flash Media Server rootinstall/applications folder.adobe. b For Stream URL. -1.get("raw:recordedStream"). pass a folder to the FLVCheck tool. c Select VOD. For example. d Select DVR Auto Record e Click Start 5 Browse to rootinstall\applications\dvrcast_origin\streams\_definst_\livetream. for the FMS URL.FLASH MEDIA SERVER 4. The following client-side ActionScript plays the RAW stream: ns.adobe. Example: Publish and play a RAW stream 1 Download and install Flash Media Live Encoder from www. 3 Connect a camera to your computer. enter rtmp://localhost/dvrcast_origin. 2 Download the DVRCast application from www. pass the following command to the FLVCheck tool: flvcheck -f C:\media\foo -v -w The following errors are reported by the FLVCheck tool version 2.

onPublish() handler creates a NetStream object and calls NetStream. A B C D Using multipoint publishing to publish content from server to server. Server 2 (Chicago) and Server 3 (Los Angeles) D. Live Video B. FMS Requires Version %x. even with servers or subscribers in different geographic locations.publish() to publish a live stream. Truncated message in segment file %s.onPublish() event with the name of the published stream. even across geographic boundaries A. This feature enables you to build large-scale live broadcasting applications. Server 1 (New York City) C. Users The application flow that corresponds to this illustration works like as follows: 1 A client connects to an application on Server 1 in New York City and calls NetStream. -34 -35 -36 -37 -38 -119 Segment file missing or corrupted Truncated message in segment file Bad message type Message backtag does not match length Segment data does not match segment bounds Error Error Error Error Error Contexts file contains no onMetadata message (and there Warning is at least one segment file) Timestamp decreases from one message to the next Warning -126 Found backward timestamp in segment file %s. Publishing from server to server About multipoint publishing Multipoint publishing allows clients to publish to servers with only one client-to-server connection. Failed read in segment file %s.publish() to republish the live stream to Server 2 (Chicago) and Server 3 (Los Angeles). This client can be a custom Flash Player or AIR application or Flash Media Live Encoder. File missing or corrupted. 2 The server-side script on Server 1 receives an application. Missing FLV metadata. 3 The application. Segment file %s does not match index file. Index File Version %x Not Supported.0 DEVELOPER’S GUIDE Working with live video 109 Code -32 -33 Error Missing/Corrupted Index or Context file Raw file index version doesn't match FMS version Level Error Error Message Index or Contexts file missing or corrupted. Unrecognized message type in segment file %s. Invalid message footer in segment file %s. Last updated 8/30/2010 .FLASH MEDIA SERVER 4.

publish( myStream. // called when the server NetStream object has a status ns.name == "livestreams/_definst_"){ trace("Republishing the stream into livestreams/anotherinstance"). "live"). handle events that occur on the NetStream object you used to publish from your server to the remote server: ns. enter the FMS URL rtmp://localhost/livestreams and the Stream localnews.name). myStream) { trace(myStream.onStatus = function(info) { trace("Stream Status: " + info.name. nc = new NetConnection(). if (application. define an application. Example: Multipoint publishing In this example.0 DEVELOPER’S GUIDE Working with live video 110 4 Subscribers connecting to Server 2 and Server 3 receive the same live stream. Open the RootInstall/documentation/samples/livestreams/LiveStreams.onPublish = function(client.setBufferTime(2). 3 In the main.Publish. ns. encodes.asc file.onStatus = function(info) { trace("Stream Status: " + info. the remove server is another instance of the same application). the client captures. // This is an example of using the multi-point publish feature to republish // streams to another application instance on the local server.swf file to connect to the application.publish() method to publish a live stream: ns.name + " is publishing into application " + application. and republishes the stream to the remote server. // Called when the client publishes application. Click Live Logs to see the server-side trace() statements as the application runs.asc file.onUnpublish() events when the clients stops publishing.FLASH MEDIA SERVER 4. You can also use Flash Media Live Encoder for the same purpose.attach(myStream). Open the Administration Console and create an instance of the livestreams application. "live" ). 2 In the server-side main. } } ns.Publish.Start") { trace("The stream is now publishing"). This handler accepts the stream name that was published from the client. connects to the remote server. } } Calling NetStream. } } Last updated 8/30/2010 . create a RootInstall/applications/livestreams folder on the server. ns. Note: To test this code.publish() publishes the stream from your server to the remote server. (In this example. 1 In a client-side script.publish("localnews". Note: To use Flash Media Live Encoder as a publishing client. ns = new NetStream(nc).Start") { trace("The stream is now publishing"). 5 The applications receive application. nc.connect( "rtmp://localhost/livestreams/anotherinstance" ).code == "NetStream. and publishes the stream to the server.code == "NetStream.code) if (info.code) if (info.onPublish() event handler. call the NetStream.

} Last updated 8/30/2010 .Start code.publish() method.FLASH MEDIA SERVER 4.Publish.onUnpublish = function( client.0 DEVELOPER’S GUIDE Working with live video 111 The server-side NetStream.name + " is unpublishing" ). myStream ) { trace(myStream. just like the client-side NetStream. 4 Define what happens when the client stops publishing: application.publish() method triggers a NetStatus event with a NetStream.

videoReliable. broadcast. When you use an RTMFP connection. and multi-point publishing over RTMFP Although RTMFP is often used for peer-assisted networking applications. Simply replace the RTMP protocol in the NetConnection.0 Reference for Flash Platform. The publisher must accept a peer request before a connection is made. Do not pass a GroupSpecifier to the NetStream constructor as you would with a peer-assisted networking application.audioReliable. and data transfer. create a NetStream just as you would with an RTMP connection. Unicast.dataReliable in the ActionScript 3.5. and multi-point publishing applications as well. Flash Media Server 3. you can use RTMFP in unicast.connect("rtmfp://fms. along with excellent retransmission and congestion handling. and NetStream. You can substitute RTMFP for RTMP in traditional unicast (one-to-many or one-to-one) applications to take advantage of the lower latency and lower bandwidth costs.112 Chapter 5: Building peer-assisted networking applications Real-Time Media Flow Protocol (RTMFP) Flash Player 10. It also enables end-to-end peering—that is. The peer ID is a 256-bit value associated with the publisher's identity. IP address mobility. create a server-side NetConnection and use an RTMFP URL to connect to the target server (for example. RTMFP provides the following features: NAT/firewall traversal. and partial reliability. RTMFP network traffic is encrypted with a 128-bit cipher. Adobe Computer Scientist Nigel Pegg explains the differences between TCP and UDP and the impact on streaming media. "rtmfp://localhost/myapp"). a client must know the name of the stream and know the peer ID of the publisher. and data. To stream audio.5 Flash Player 10 and AIR 1. RTMFP is built on User Datagram Protocol (UDP). On the blog Collaborative Methods. To use RTMFP with multi-point publishing.connect() call with the RTMFP protocol: netconnection. RTMP is built on Transmission Control Protocol (TCP). video. Flash Media Server developer Brian Lesser explains RTMFP in the article Adobe's Real-Time Media Flow Protocol.com/vod"). UDP provides lower latency than TCP.example. updates to shared objects are sent over the RTMP chunk stream data channel within the RTMFP connection with full reliability. To play a stream over RTMFP. See NetStream. broadcast. NetStream. direct data transmission between two clients. The RTMFP protocol supports a wide range of reliability settings (from zero to full) for audio. Last updated 8/30/2010 .5 support Real-Time Media Flow Protocol (RTMFP). congestion control and prioritization. Adobe Computer Scientist Jozsef Vass explains RTMFP in an Adobe DevNet article. video. AIR 1.

Data does not need to be sent to the server to be distributed to each client.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 113 RTMFP groups Flash Player 10. Peers can share data such as audio.1. • “Route messages directly to a peer” on page 121 Use directed routing to send a message through the overlay routing structure to one peer. for example “G:01010b. Groupspecs are Strings that start with “G:” followed by hexadecimal digits. also called a “node”.1. AIR 2. Once peers are fully meshed into a group. but there is a always a path through other peers. Use the NetGroup class to manage a group and send ActionScript data within a group. Flash Media Server 4 For detailed information about RTMFP groups. Bootstrapping Connecting to at least one member of a group in order to join the group. see Adobe Computer Scientist Matthew Kaufman’s presentations from Adobe MAX 2009 and Adobe MAX 2008. Clients make an RTMFP connection to Flash Media Server and join a group. Use the ActionScript 3. • “Replicate an object within a group” on page 122 Use object replication to synchronize everyone in a group on a (potentially large) number of objects. and Flash Media Server 4 support RTMFP groups. organizing and optimizing a group for latency. The group maintains the connections between peers automatically. and maintaining the full-connectedness of a group. Last updated 8/30/2010 . If a peer changes any permissions or properties of the group. AIR 2. There is a path between every peer in a group that forms a peer-to-peer mesh. RTMFP and groups allow you to build peer-to-peer applications that can scale to millions of clients. then they can pass data within the group. You can write application logic to bootstrap a client to a group. Flash Player 10. To multicast streams and post messages.0 GroupSpecifier class to define the parameters and capabilities of a group in a string called a “groupspec”. Flash Player handles peer communication within a group. call ActionScript methods and pass them the data to send.”. Use the NetStream class to multicast audio and video data within a group. they start a new group. Groups allow you to do the following things: • “Multicasting” on page 116 streams Use multicasting for one sender or a few senders to deliver a streams of data to everyone in a group. There is no random probing for peers and the server does not flood the network looking for peers. A peer is a Flash Player or AIR client that connects to Flash Media Server over RTMFP and joins a group. • “Post messages to a group” on page 120 Use posting for lots of senders to deliver a small amount of data to everyone in a group. or you can ask Flash Media Server to bootstrap clients automatically. The data arrives at the other nodes in the group. video..FLASH MEDIA SERVER 4. Flash Media Server handles introducing a client to a group. and ActionScript objects. Peer A member of a group. There may not be a direct connection between two peers. The first part of the string is the unchangeable identity of the group and contains the group permissions.. The string is case-sensitive. Group A group is a collection of one or more RTMFP nodes who agree on certain parameters and capabilities. A group is also called a “peer group” an “RTMFP group” and a “NetGroup”. Pass the groupspec to the NetGroup and NetStream constructors.

// The GroupSpecifier determines the properties of the group var groupSpecifier:GroupSpecifier. There are several additional options for bootstrapping described in the next section. Even if they learned the peer ID of a peer from the other group. they merge into a single larger group. NetStatusHandler). Additional information Tom Krcha has written an in-depth article about the GroupSpecifier class on his blog Flash Realtime.groupspecWithAuthorizations()).connect("rtmfp://fms. you must write ActionScript code to help deliver the data. but each group is on a different server run by a different organization. and never touch. a client must know the GroupSpecifier that defines the group.Success" case in the NetStatusEvent handler. they are in separate groups.NET_STATUS.example.multicastEnabled = true. To prevent this delay. // Called in the "NetConnection. netGroup.postingEnabled = true. use the GroupSpecifier class to create a groupspec. it can take up to 2 minutes for the client to receive the "NetConnection.Connect. Bootstrap a peer to a group After the initial connection to the server.Success". groupSpecifier. NetConnection.addEventListener(NetStatusEvent. Pass the groupspec to the NetGroup constructor. Pass an “rtmfp” URL to the NetConnection. this technique is called “bootstrapping”. Create a group 1 Connect to Flash Media Server. } 3 On "NetGroup. Each peer has a peerID. If two sets of clients use the same GroupSpecifier.Connect. To join a group. the peer self-organizes into the group and meshes with the other members. a peer must be introduced to one or more peers of the same group. groupSpecifier. 2 On "NetConnection. groupSpecifier = new GroupSpecifier("com. groupSpecifier. // Create a GroupSpecifier object to pass to the NetGroup constructor. verify that <RTMFP enable="true"> in the Adpator. netGroup = new NetGroup(netConnection.serverChannelEnabled = true. // The serverChannel lets the server do auto-bootstrapping groupSpecifier. After bootstrapping.Success". and the peerID space is server-specific. private function OnConnect():void{ connected = true. If two sets of clients use the same GroupSpecifier.xml file.Connect.com/p2pexample/test1") Note: If RTMFP is disabled in the Adaptor.xml file.p2papp"). there is no way for the two groups to touch. It is enabled by default.example.Connect. The example enables the server channel to perform automatic bootstrapping. If the two groups touch. Bootstrapping allows members of the same group to see each another. they don't share an introducing server.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 114 To route messages directly to a peer and replicate an object within a group. you can manually bootstrap or automatically bootstrap peers to the group.FLASH MEDIA SERVER 4.Failed" status.connect() method:. Last updated 8/30/2010 .

If a user does not allow peer-assisted networking..0 DEVELOPER’S GUIDE Building peer-assisted networking applications 115 Peers within an RTMFP group can be bootstrapped in the following ways: • Server channel automatic bootstrapping. gs. Server-side RTMFP groups Use Server-Side ActionScript to create an RTMFP NetConnection. Note: Call the Administration API getServerStats() command to get RTMFP peer lookup statistics.FLASH MEDIA SERVER 4. and multicast) are disabled. and object replication.addIPMulticastAddress("224. directed routing. this property is false (peer-assisted connections are enabled).connect("rtmfp://fms. var ns = new NetStream(nc.. Once connected. If peers with matching groupspecs are on different subnets. Note: Server-Side ActionScript doesn't support creating a connection directly between peers. The server application joins a group and becomes a peer in the group mesh. Peers cannot discover each other unless they’re in the same group on the same subnet of the LAN. use a GroupSpecifier to create a NetGroup and a NetStream. no error or other event is dispatched if they fail to discover each other. the server bootstraps them with peers who are members of the same NetGroup.example. If the user clicks “Allow for this domain”. • Manual bootstrapping. Last updated 8/30/2010 . The dialog asks users if Flash Player can use their connection to share data with their peers. the security dialog does not appear. // Must be enabled for LAN peer discovery to work gs. Flash Player displays a “Peer-assisted Networking” dialog. A single client can join into multiple groups.serverChannelEnabled to true.peerToPeerDisabled property to true. call the NetGroup.com/appname/appinstance"). In this case. the dialog is not displayed the next time the user connects to this application. The following code shows how to enable LAN peer discovery: var nc = new NetConnection().toString()). When clients connect over an RTMFP connection.discovery-test").addNeighbor() method. LAN peer discovery allows an RTMFP NetConnection and its NetStream and NetGroup objects to automatically locate peers and join a group on the current subnet.example. // Multicast address over which to exchange peer discovery. When peerToPeerDisabled is true. the dialog is not displayed. Flash Player peer-assisted networking security dialog When a NetStream or NetGroup object is constructed with a groupspec. gs. var gs = new GroupSpecifier("com. set GroupSpecifier.0. // Additional GroupSpecifier configuration. you can interact with other peers in an RTMFP group. You can connect to the current application or to an application on another Flash Media Server acting as an introducer. You can use RTMFP to subscribe to a pure native-IP multicast stream. To manually bootstrap peers into a mesh. // Protocol must be RTMFP nc. When using IP multicast with no peer-assisted functionality.255:30000"). By default. you can disable the security dialog.ipMulticastMemberUpdatesEnabled = true. To enable automatic bootstrapping. all peer features within the group (posting. • LAN peer discovery Use the GroupSpecifier class to enable LAN peer discovery. Set the GroupSpecifier. After you create an RTMFP NetConnection.0.

and groupSpecWithoutAuthorizations(). you can pass the GroupSpecifier object or a groupspec string. • NetStreamMulticastInfo The NetStreamMulticastInfo class specifies Quality of Service (QoS) statistics about a NetStream object's RTMFP peer-to-peer and IP multicast stream transport.multicastInfo property returns a NetStreamMulticastInfo object which is a snapshot of the current QoS state.publish() or NetStream. Multicasting allows few publishers to send a large amount of data.0 classes and Server-Side ActionScript classes to create applications that use RTMFP groups: • NetConnection Use the NetConnection class to create a two-way RTMFP connection between a Flash Player or AIR application and a Flash Media Server application. call one of the following methods: toString(). In client-side code. The NetStream.play() to multicast the data. AIR 2. restrictions. A groupspec is an opaque string that you pass to the NetStream and NetGroup constructors. pass a groupspec string or a GroupSpecifier object to the NetStream and NetGroup constructors.FLASH MEDIA SERVER 4.connect() method. In server-side code. pass a groupspec to the NetStream constructor. Last updated 8/30/2010 . pass a GroupSpecifier object to the NetGroup constructor. Call NetStream. The class properties provide information about group members. • GroupSpecifier Use the GroupSpecifier class to define the capabilities. The NetGroup. groupSpecWithAuthorizations(). To multicast media.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 116 ActionScript classes for working with RTMFP groups Use the following ActionScript 3. Use the RTMFP protocol in the URL you pass to the NetConnection. After you define the capabilities. Call the class methods to post messages to the group. • NetGroup Use the NetGroup class to manage an RTMFP group. To create a NetGroup. route messages to a group member. Multicasting Flash Player 10.1. • NetStream Use the NetStream class to multicast audio and video data over a group. Flash Media Server 4 Multicasting is distributing audio and video data among members of a group. The server doesn’t send data to each client—the data is distributed among peers. and to replicate objects among the group. you can only pass a groupspec string.info property returns a NetGroupInfo object which is a snapshot of the current QoS state. and authorizations of an RTMFP peer-to-peer group. To generate a groupspec string. • NetGroupInfo The NetGroupInfo class specifies Quality of Service (QoS) statistics about a NetGroup object's RTMFP peer-topeer data transport. You can use the client-side NetStream class and the server-side NetStream class to multicast data. Pass a groupspec to the NetStream constructor and use the standard publish() and play() methods.

FMS 4 Hosting Multicast Sample FMLE Publishing Live Stream Multicast Router Legend: RTMP P2P RTMFP IP Multicast RTMFP In a multicast fusion topology. Last updated 8/30/2010 . use IP multicast. Understand the following about multicast: • Any number of streams can be published into a group. clients can receive data from peers and from an IP multicast router. or on networks that don’t support IP multicast. this use case is called multicast fusion.FLASH MEDIA SERVER 4. use application-level multicast. Multicast fusion combines both broadcast techniques to support higher quality of service. • Streams of the same name can be published into a group. For example. Outside the firewall. Multicast fusion lets your neighbor outside the firewall receive fragments of video that it cannot receive via IP multicast. Within a firewall. Flash Media Live Encoder can deliver a stream to Flash Media Server over RTMP and Flash Media Server can multicast it to groups over RTMFP. You can also use application-level multicast and IP multicast cooperatively for a single stream. Flash Media Server can multicast streams delivered to it over RTMP connections. However. this practice is not recommended because each group member consumes and relays all streams. even if the streams aren’t playing at that specific client.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 117 Flash Media Server supports both application-level multicast and IP multicast.

1. Within an RTMFP group. The routers send the data to any client registered to an IP multicast group.) This is a significant reason for the improved scalability of multicast streams. work with your IT department.multicastPushNeighborLimit property. the peer-to-peer mesh distributes streams published into an RTMFP group. Pass a groupspec without authorization to all other clients to prevent them from publishing competing streams under the same name.addIPMulticastAddress()when you create a groupspec. By default. To set up IP multicast. consider the expected average client uplink capacity when selecting the bitrate for the multicast stream you publish. call the Server-Side ActionScript NetStream.addIPMulticastAddress() Last updated 8/30/2010 . can be used for higher bitrate. an article on Tom Krcha’s Flash Realtime blog. Call GroupSpecifier. The default value is to 4. This technology is known as “application-level multicast”. Flash Media Server is aware of stream state. • GroupSpecifier. it plays the first stream with that name that it can find. If the publisher for that instance of the named stream stops. IP multicast IP multicast uses routers to send data to a specified IP address. Ask them to set up an address to publish to and to configure the enterprise multicast routers to forward the traffic appropriately.FLASH MEDIA SERVER 4. to protect against stream name collisions or hijacking. which can be used simultaneously with P2P multicast.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 118 When a client requests to play the stream name. there is no single arbiter of stream state that prevents multiple clients from publishing streams with the same name. a video tutorial by Adobe Evangelist Tom Krcha. define a publish password for the group and providing the groupspec with authorizations to trusted publishers only.1. Adding a IP multicast address allows a client to listen for and receive the IP multicast traffic. For this reason. application-level multicast runs concurrently with IP multicast. (In traditional.send() to inject data into a group. live multicast streams in a local area network. Note: This requirement is specific to P2P multicast. • Publishers can call NetStream. To control this number. use the NetStream.Reset" event is dispatched. • When a client is in an RTMFP group in which a live multicast stream is playing.peerToPeerDisabled=true This setting turns off peer-to-peer multicast. set up the following in the GroupSpecifier: • GroupSpecifier.multicastEnabled=true • Call GroupSpecifier. All subscribing (playing) peers in the group must add the IP multicast address to their GroupSpecifier.MulticastStream. All the peers within a group work co-operatively to get the stream to each other. Application-level multicast By default. unicast stream publishing. To publish streams to a IP multicast address. Each client is not pulling the stream from the server independently. This technology is called “fusion multicast”. However. To run IP multicast without application-level multicast.setIPMulticastPublishAddress() method before you start publishing. Choosing a bitrate that's too high may result in peers not being able to relay the stream smoothly. the playing client resets to another instance of the named stream and a "NetStream. Additional information Multicast Streaming in Flash Player 10. Multicast explained in Flash Player 10. the client may act as a relay point for that stream to some number of direct neighbors. IP multicast.

groupspecWithAuthorizations()).255.multicastEnabled = true. gs.play(streamName). In no server mode.1:30000"). Use severless mode to receive a pure IP multicast stream from a publisher without requiring clients to connect to a server or bootstrap into the peer-to-peer mesh. var ng:NetGroup = new NetGroup(nc.setIPMulticastPublishAddress()method. Wait for NetStream.255. gs.addIPMulticastAddress("239. After they discover each other.255. peers must be configured to discover each other on a LAN using IP multicast. The NetConnection instance nc is a serverless RTMFP NetConnection. nc.Connect.Connect. var ns:NetStream = new NetStream(nc. // Receive multicast stream on 239. the stream publishes to the address you passed to the Server-Side ActionScript NetStream. gs. you can publish or play a peer-to-peer multicast stream on the NetStream. Because clients don’t connect to a server.11 port 30001 gs. as in the following: var gs:GroupSpecifier = new GroupSpecifier("com. Last updated 8/30/2010 .myAdHocGroup").pureIPMulticastGroup"). you are also running application-level multicast.peerToPeerDisabled = true. you can create an group on your LAN for any of the RTMFP group modes (including peer-to-peer multicast).0 DEVELOPER’S GUIDE Building peer-assisted networking applications 119 Call this method in the client-side application only. // Peers find each other on 239. and post on the NetGroup. gs. when you run IP multicast.ipMulticastMemberUpdatesEnabled = true. • Send and receive streams in a NetGroup. This technique is called “fusion multicast”.multicastEnabled = true. Wait for the NetStream.Success. // Prevents the P2P permission dialog from appearing. In no server mode.addIPMulticastAddress("239. That address is the same address the clients are using.255.Success and NetGroup. This mode is called “serverless mode”. gs.adobe.groupspecWithAuthorizations()). To publish from the server. gs. clients can do the following: • Use IP multicast to discover peers on the LAN.255.255. Fusion multicast By default. gs. The application-level multicast runs slightly behind the IP multicast to take advantage of the greater efficiency of IP multicast. (The NetGroup consists only of peers discovered over IP multicast on the LAN. gs.FLASH MEDIA SERVER 4. The following code uses the NetConnection to make a NetStream that can receive a pure IP multicast.connect("rtmfp:"). After receiving them.Success message.Connect. there is no automatic bootstrapping. Both IP and application-level multicast run coordinated and concurrently. but the functionality is limited. which is required before you can use a group NetStream. Attach the NetStream to a video display object and call ns.) The following code creates a connection in serverless mode: var nc:NetConnection = new NetConnection. • Receive streams over IP multicast. It also suppresses the peer-assisted networking permission dialog var gs:GroupSpecifier = new GroupSpecifier("com. Or.255. Creating a peer-assisted application without connecting to a server You can create a network endpoint for RTMFP group and IP multicast communication without connecting to a server.1 port 30000 gs. they can communicate within the group.postingEnabled = true.groupspecWithAuthorizations()). var ns:NetStream = new NetStream(nc.11:30001").adobe.255.

Use the post() method to broadcast non-stateful data. • Messages are serialized in AMF. AIR 2.FLASH MEDIA SERVER 4.bytesReceivedFromIPMulticast property tells much data a client is receiving over pure IP multicast (as opposed to application-level multicast). For example.multicastInfo property.Posting. or null on error.0 NetGroup. Unlike shared objects.0 Reference contains a chat application example.Notify" in the info.Neighbor. Flash Media Server 4 Call the NetGroup.Notify" code to do something when a post has been received. Use a sequence number to make messages unique. the NetStreamMulticastInfo. • The post() method returns the messageID for this message. The messageID is the hexadecimal of the SHA256 of the raw bytes of the serialization of the message. For example.1. posting does not manage changes. Understand the following about posting messages: • The GroupSpecifier. • Message delivery is not ordered. and to check on quality of service.post() entry in the ActionScript 3.postingEnabled property must be true in the groupspec passed to the NetGroup constructor. Use the "NetGroup. The NetGroup. Posting is not similar to using shared objects. This property is an instance of the NetStreamMulticastInfo class which specifies various QoS metrics for statistics when multicasting.Connect event before you call post(). Use posting to allow many clients to send small amounts of data.0 NetStream.post() method to broadcast an ActionScript message to all members of a NetGroup (also called a “group”).post() method or from the ServerSide ActionScript NetGroup. The following is an excerpt from that example: Last updated 8/30/2010 .code property. • Receive a NetGroup.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 120 Checking multicast quality of service To check whether a client is multicasting. You can post messages to a group from the client-side ActionScript 3. A message cannot be a MovieClip. Post messages to a group Flash Player 10. • The post() method sends a NetStatusEvent to the NetGroup's event listener with "NetGroup. use the NetStreamMulticastInfo class. use posting for text chat. use the ActionScript 3. In Server-Side ActionScript. opinion polls.post() method.Posting. A message can be any AMF object.broadcastMsg() method. • Messages must be unique to be considered new. Message delivery is not guaranteed. This method is similar to the Server-Side ActionScript Application. and sensor reporting. but the post() method propagates messages from node to node in a group.

sequence = sequenceNumber++. groupSpecifier. NetStatusHandler). it is not concentrated at the server.serverChannelEnabled = true.aslrexample/" + groupNameText.text = chatText. } Route messages directly to a peer A client can send short ActionScript messages directly to a member of a peer-to-peer group without having a direct connection to that member. StatusMessage("==> " + chatText. Directed routing leverages the full transitive connectivity and the geometric properties of the Group's self-organized structure to route messages through the group. This feature is called directed routing. } // Called when you the chatText field has focus and you press Enter.addEventListener(NetStatusEvent. Flash Realtime: Directed routing explained.sendToAllNeighbors() NetGroup. or to construct a DHT (distributed hash table). Successful routing of the message requires the direct participation of all peers along the dynamic path between the sender and intended recipient. } ClearChatText(). // Post the message to the group.NET_STATUS. message.post(message).user = userNameText. groupSpecifier.postingEnabled = true. Use ActionScript to handle the receipt and local processing or forwarding of a message. Adobe Evangelist Tom Krcha explains directed routing in an article on his blog.text). Each peer acts as a relay point for the message. message. // The GroupSpecifier determines the properties of the group var groupSpecifier:GroupSpecifier. The bandwidth load of message routing is distributed among the members of the group. connected = true. private function DoPost(e:ComponentEvent):void{ if(joinedGroup){ // Build the message to post. The following are the Server-Side ActionScript directed routing APIs: • • NetGroup.nearID. groupSpecifier.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 121 private function OnConnect():void{ StatusMessage("Connected\n"). Message delivery is not guaranteed.text. message. netGroup. Peers do not automatically relay received messages. var message:Object = new Object. Use directed routing to send a message to a specific client. StatusMessage("Join \"" + groupSpecifier. netGroup = new NetGroup(netConnection. netGroup. // Create a GroupSpecifier object to pass to the NetGroup constructor.FLASH MEDIA SERVER 4.sendToNearest() Last updated 8/30/2010 . message.groupspecWithAuthorizations()).groupspecWithAuthorizations() + "\"\n"). groupSpecifier = new GroupSpecifier("com.sender = netConnection.text + "\n") } else { StatusMessage("Click Connect before sending a chat message").text.

and so on. length) File. synchronize nodes with a log of operations.0 APIs to replicate an object within a group: • • • • • • NetGroup.writeRequestedObject() Additional ActionScript APIs to support peer-assisted networking Server-Side ActionScript supports new APIs to supplement object replication and other RTMFP group features.sendToNeighbor() The following are the client-side ActionScript 3. length) Last updated 8/30/2010 .deflate() Use the SHA256 class for hashing.removeHaveObjects() NetGroup.1 with Object Replication.sendToNeighbor() Replicate an object within a group Clients can send ActionScript objects through the peer group reliably.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 122 • NetGroup. create whiteboards.FLASH MEDIA SERVER 4.0 directed routing APIs: • • • NetGroup.sendToAllNeighbors() NetGroup. This feature is called object replication.inflate() ByteArray.addHaveObjects() NetGroup. offset. Each object is indexed by a number that must be unique across the entire group.removeWantObjects() NetGroup. Use it to replicate workspaces.addWantObjects() NetGroup. see Adobe Evangelist Tom Krcha’s blog post File Sharing over P2P in Flash Player 10. The ByteArray class contains the same methods as the ActionScript 3. and transfer files. Use the following client-side ActionScript 3. The objects must remain immutable.writeBytes(byteArray. offset. Object replication allows all members of an RTMFP group to have a consistent view of a set of objects.readBytes(byteArray.computeDigest(byteArray) Use two new methods of the File class to read bytes from and write bytes to byte arrays: File.sendToNearest() NetGroup. including a sample application. Use the ByteArray class to replicate objects between peers.denyRequestedObject() NetGroup. The SHA256 class contains one static method: SHA256. Object replication uses the full transitive connectivity of the group’s self-organized structure. For a detailed explanation of object replication.0 ByteArray class except for the following: • • ByteArray. It replicates objects through the group from nodes that have the objects to nodes that need the objects.

Prevent the server from unloading an application Flash Media Server considers an application with no inbound connections idle. Tips for developing peer-assisted networking applications Creating a fallback mechanism for users without a peer connection When a NetStream or NetGroup object is constructed with a groupspec and the groupspec has peerToPeerDisabled = false. To use Flash Pro instead of Flash Builder. The application on server B has outbound connections to server A. To create an application that never relays media through the server (even though some clients may not see the media). define an Application. the server unloads the application. create a protocol fallback to client-server RTMP and/or RTMPT. Server A acts as the peer introducer and ingests live streams. NAT and firewall traversal NAT (network address translation) and firewall filtering can block peer-to-peer connections. the server considers the application idle and unloads it.FLASH MEDIA SERVER 4. If an application contains peers connected to a group.play() to publish it to an RTMFP group. To create an application that works for connections that aren’t peer-to-peer. don’t create a protocol fallback. For example. Flash Player presents the user with the “Peer-assisted Networking” dialog in the settings manager. the application is considered idle. see Peer-to-peer chat with NetGroup. In an intranet application. consider the following scenario involving two Flash Media Server installations. The AS file is a text-only chat. In an Internet application. To prevent the server from unloading the application. When an application doesn’t have incoming client connections. but doesn’t have client connections. server A and server B.post() entry example which is an AS file. do the following to ensure that clients can create peerto-peer connections: • Allow UDP traffic through any firewalls • Use a NAT or firewall that complies with the NAT implementation recommendations of the IETF BEHAVE working group. the application developer must choose how to handle cases in which a firewall or NAT blocks a direct peer-to-peer connection. by Adobe Evangelist Tom Krcha. in which you have control over the entire network.onAppStop() handler that returns false.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 123 Example: P2P video and text chat The NetGroup entry in ActionScript 3. An application on server B pulls a stream from server A and calls Stream. If the user doesn’t allow Flash Player to share their bandwidth. Last updated 8/30/2010 . see the NetGroup. Eventually.0 Reference contains a P2P video and text chat example. The dialog asks the user to allow Flash Player to share their bandwidth with other users of the application. functionality that relies on peer-assisted networking doesn’t work. See Firewall traversal. For a video tutorial of P2P video chat. The example is in an MXML file. • Use the TURN proxy support in Flash Player to send traffic to a proxy in a DMZ that can comply with the previous recommendations. but it doesn’t have inbound client connections.

net saw when the connection came in. symmetric Uses the same address but a new port when talking to a new peer. When it runs out of resources.rtmfp. Address and port-restricted The peer is restricted to talking only to addresses and ports it has talked to already. The following are the RTMFP Connectivity Checker tests: Test Knows public IP address of self Description Flash Player has a local address that matches the address that cc. RTMFP Connectivity checker Adobe Computer Scientist Matthew Kaufman hosts a website called RTMFP Connectivity Checker at http://cc. the client connection must have the same properties as the client you’re testing.rtmfp. two peers in the same organization behind the same firewall can have different properties between each other than they each have to http://cc. It’s also important to understand the filtering behaviors of NATs and firewalls: None A cone NAT with no filtering is called “full cone”. If the connection to cc. different UDP port number This value is always “Yes”. because if a client couldn't complete this test.rtmfp. It could act as a different type of NAT for the second client that tried to connect to the same server. there is no port translation.net/. some NAT and firewall behaviors aren't easily defined. If this answer and the previous answer are “Yes”. Last updated 8/30/2010 . a simple analysis can fail to predict whether a client can make a peer-to-peer connection. The results are not always definitive because.rtmfp.net saw when the connection came in. a NAT could act as a symmetric NAT that preserves port numbers. Multiple IP address. Can receive from same IP address.rtmfp. To test a connection. A port restricted firewall requires an outbound connection to the same address and port number before inbound traffic is permitted from that address and port number. In another example.net. use the results to determine whether a peer-to-peer connection can be formed. In addition. A firewall may block UDP completely. Use this site to try to determine whether a client on a particular network can create a peer-to-peer connection. Note: A firewall can filter and not be a NAT. a NAT could act as one type of NAT for the first client that connected to a server. and the NAT or firewall must have predictable behavior. there probably isn’t a NAT (but there may be a firewall). it couldn't establish the initial connection. in some cases.net has the same properties as the connection to and from the peer. This requirement is true even when previous traffic was sent to the same address but different port number. For example.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 124 Understanding types of NAT It’s important to understand the different types of NAT behavior: Cone Reuses the same address and port when talking to all peers. Indicates whether your firewall is “port restricted”. Public UDP port number same as local UDP Flash Player's idea of which UDP port number it is using matches port number what http://cc. Address-restricted The peer is restricted to talking only to addresses it has talked to already. In this case. symmetric Picks a new address and port when talking to a new peer. A NAT can act as a firewall and have filtering. For example. In this case. it could switch and act as a cone NAT.FLASH MEDIA SERVER 4. there is no address translation. In this case. Single IP address. the connection does not have the same properties. same UDP port number Can receive from same IP address.

If repeated tests cause the value to change. symmetric NAT in combination with certain firewall or NAT cases at the other end blocks the ability to establish a peer-to-peer connection. If this test fails. If one end is a symmetric NAT with a single IP address.) However. Last updated 8/30/2010 . (There are some issues with multiple layers of NAT and lack of “hairpinning” support. This test is like opening a new RTMFP connection. different UDP port number Description Indicates whether your firewall is “address restricted”. An address restricted firewall requires that an outbound connection is made to a new IP address before inbound traffic is permitted from that IP address. there's a problem with how Flash Player received or treated the introduction request. a symmetric NAT with only one IP address. or a symmetric NAT with multiple IP addresses but the same address happened to be used this time. Flash Player can work with most cone NAT configurations and many firewall configurations. or the firewall is unpredictable. The hole that was created is no longer applicable. the other end moves to a new address and/or port number that doesn't match. connections to peers behind other symmetric NATs or behind address-restricted (and probably port-restricted) cone NATs (or address-restricted or port-restricted firewalls) are impossible. you have a symmetric NAT with multiple IP addresses. This test means that you have one of the following: a cone NAT. This test means that you have a cone NAT. symmetric NATs break peer-to-peer connectivity. and sometimes you happen to use the same address. you have a symmetric NAT.FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Building peer-assisted networking applications 125 Test Can receive from different IP address. This value is always be “Yes” if the initial connection can be made. Flash Player cannot connect to peers behind other symmetric NATs or behind port-restricted cone NATs (or port-restricted firewalls). Can send to different IP address after server introduction Source IP address is preserved from original connection Source UDP port number is preserved from original connection Understanding the RTMFP Connectivity test In some cases. No matter what Flash Player tries to do to “punch a hole” through the restricted cone NAT or restricted firewall to let the other peer through. If one end of a connection is a symmetric NAT with multiple IP addresses. If the value is "No".

and e-mail. You can use Server-Side ActionScript to connect to other systems. Shared objects let you keep track of what users are doing in real time. They maintain state between application sessions. About shared objects Use shared objects to synchronize users and store data. pass a value of true for the persistence parameter in the client-side SharedObject. When the last client disconnects and the server-side script is no longer using the shared object.sol. all users see it move.126 Chapter 6: Developing social applications About social applications Important: Flash Media Streaming Server does not support server-side scripting and therefore does not support social applications. In the section “SharedBall example” on page 128. Adobe Flash Media Interactive Server. Persistent shared objects are available on the server for the next time the application instance starts. Local shared objects are stored on the client computer and don’t require a server. which share data between multiple client applications. web services. • Persistent shared objects retain data after all clients disconnect and even after the application instance stops running.get() method. When one user makes a change that updates the shared object on the server.getLocal() command. it is deleted. In addition to streaming video applications. the shared object sends the change to all other users.NET servers. when any user moves the ball. Shared objects. Persistent local shared objects To create persistent local shared objects. and share them with others. By specifying a partial path for the location of a locally persistent remote shared object. The remote shared object acts as a hub to synchronize many users. Users can capture live audio and video. These shared objects are named with the extension . These server editions also provide access to remote shared objects that synchronize data between many users. and Microsoft . Create and use remote shared objects. Persistent objects are stored in files on the server or client. call the client-side SharedObject.getLocal() method. can also be temporary or persistent: • A temporary shared object is created by a server-side script or by a client connecting to the shared object. Adobe Flash Media Enterprise Server. which are similar to browser cookies. real-time updates from web services.fso and are stored on the Last updated 8/30/2010 . and Adobe Flash Media Development Server can host social and other real-time communication applications. you can let several applications from the same domain access the same shared objects. whether local or remote. and so is ideal for developing online games. You can specify a storage directory for the object by passing a value for the localPath parameter of the SharedObject. Note: Flash Media Streaming Server does not support remote shared objects. All editions of the server support local shared objects. upload them to the server.getRemote() method or in the serverside SharedObject. record them. Remotely persistent shared objects To create remote shared objects that are persistent on the server. This connectivity allows applications to take advantage of services such as database authentication. Persistent local shared objects have the extension . Shared objects can do anything from holding the position of pieces on a game board to broadcasting chat text messages. including Java 2 Enterprise servers.

For more information. This is the simplest way to connect to the server.fso file is stored on the server in a subdirectory of the application that created the shared object. a To update the remote shared object when a client makes a change. sharedBall.getRemote() command. call SharedObject. update all other clients from the remote shared object.connect(nc). you need to update the remote shared object. nc. Flash Media Server creates these directories automatically.getRemote() to create a remote shared object on the server: so = SharedObject.FLASH MEDIA SERVER 4. The locally persistent shared object is named with the extension . you don’t have to create a directory for each instance name. The remote shared object has a data property that contains attributes and values. The remotely persistent . Synchronizing the remote shared object requires two steps. The easiest way to specify it is with the nc.uri property. nc. Remote shared objects Before you create a remote shared object.x. connect the client to the shared object using the NetConnection object you just created: so.x). 2 Create the remote shared object. 4 Synchronize the remote shared object with clients. see “SharedBall example” on page 128. false). Next. Remotely and locally persistent shared objects You create remote shared objects that are persistent on the client and the server by passing a local path for the persistence parameter in your client-side SharedObject. create a NetConnection object and connect to the server. as in: so. Once you have the connection. The second is the URI of the application you are connecting to and must be identical to the URI used in the NetConnection. The general sequence of steps for using a remote shared object is outlined below: 1 Create a NetConnection object and connect to the server: nc = new NetConnection().getRemote("ballPosition". false is used to make the shared object temporary. you would add event listeners on the NetConnection object and define event handler methods. // you can't do this Last updated 8/30/2010 .connect("rtmp://localhost/SharedBall").0. The first parameter is the name of the remote shared object. when an individual client makes a change or sets a data value. First.setProperty("x".0 DEVELOPER’S GUIDE Developing social applications 127 server in a subdirectory of the application that created the shared object.connect() method. you cannot write values directly to it. The third parameter specifies whether the remote shared object is persistent.x = sharedBall.data. use setProperty(): so. syncHandler). in ActionScript 3. 3 Connect to the remote shared object. You also need to add an event listener for sync events dispatched by the shared object: so.sor and is stored on the client in the specified path. You must use setProperty() to update values in the shared object. use the methods in the SharedObject class to create and update the remote shared object. When the connection is successful. Once the shared object is created. However.SYNC.uri.addEventListener(SyncEvent. In this case. In a real application.

This is usually done in a sync event handler. select the Rectangle tool. choose File > New > Flash File (ActionScript 3. When one user moves the ball. 3 Open SharedBall. It’s similar to a multiplayer game.swf in a second browser window. 5 In the Convert to Symbol dialog box.swf) in the documentation/samples/SharedBall directory in the Flash Media Server root install directory. 2 From the toolbox. SharedBall example The SharedBall sample creates a temporary remote shared object. 4 Double-click the circle and choose Modify > Convert to Symbol. then select the Oval tool. Give it any fill color you like.FLASH MEDIA SERVER 4.fla.0 DEVELOPER’S GUIDE Developing social applications 128 b When the shared object is updated. 4 Open a second instance of SharedBall. Design the user interface 1 In Flash. Drag to the lower-right corner.as. The SharedBall application running in Flash Player Run the application 1 Register the application with your server by creating an application directory named SharedBall: RootInstall/applications/SharedBall 2 Open the SharedBall samples files from the documentation/samples/SharedBall directory in the Flash Media Server root install directory.swf in a web browser. Synchronize the change to the remaining clients by reading the value of the shared object’s data property: sharedBall.0) and click OK. it dispatches a sync event. Note: Use the SharedBall sample files (SharedBall. name the symbol ball. Last updated 8/30/2010 .x. 5 Move the ball in one window and watch it move in the other. as shown in “SharedBall example” on page 128. and SharedBall.data. check that Movie Clip is selected. and click OK.x = so. SharedBall. 3 Draw a circle on the Stage. it moves for all other users.

connect("rtmp://localhost/SharedBall").setProperty("x".} The class must extend MovieClip. nc.y). nc. . shown in the sample AS file.code) { case "NetConnection.. sharedBall.addEventListener(SyncEvent. 3 Create the constructor.connect(nc). so. } 6 As a user moves the mouse. } 4 Add event listeners for netStatus. moveIt).addEventListener(MouseEvent.FLASH MEDIA SERVER 4.fla.getRemote("ballPosition"...setProperty("y". netStatusHandler). 7 Save the file as SharedBall.as sample file. } } When the remote shared object is updated. so = SharedObject.NET_STATUS.SYNC. break. so. because the sharedBall symbol in the FLA file is a Movie Clip symbol. place). 2 Create the class. in which you add event listeners and connect to the server: public function SharedBall() { nc = new NetConnection().addEventListener(NetStatusEvent. pickup). so. it dispatches a sync event. syncHandler).) Connect to the shared object and add a sync event listener: switch (event. mouseUp. mouseDown. sharedBall. use setProperty() to set the changing ball location in the remote shared object: function moveIt( event:MouseEvent ):void { if( so != null ) { so. create a new ActionScript file.MOUSE_DOWN. } 5 In your netStatus handler. addEventListeners(). 1 In Flash Professional.uri.x). extending MovieClip: public class SharedBall extends MovieClip {. // sharedBall is defined in the FLA file sharedBall.MOUSE_MOVE. sharedBall.. (You’ll also want to create error handlers for rejected and failed connections. and mouseMove events: private function addEventListeners() { nc. create a remote shared object when a connection is successful.info.0 DEVELOPER’S GUIDE Developing social applications 129 6 Select the ball symbol on the Stage and in the Property Inspector (Window > Properties) give it the instance name sharedBall.Success": trace("Congratulations! you're connected").MOUSE_UP.Connect. sharedBall. false).addEventListener(MouseEvent. Write the client-side code Be sure to look at the SharedBall. Last updated 8/30/2010 .addEventListener(MouseEvent. These steps present only highlights.

false).send() to all clients connected to the shared object. } You can read the value of so.0 DEVELOPER’S GUIDE Developing social applications 130 7 Write a sync event handler that updates all clients with the new ball position: private function syncHandler(event:SyncEvent):void { sharedBall. so.getRemote("position". as broadcaster.send("doSomething". also receive a copy of the message. The send() method can be used for text chat applications. so.data. where all users subscribed to your shared object receive your message.data.FLASH MEDIA SERVER 4. msg).x. even though you can’t write to it. for example. sharedBall. Broadcast messages to many users A remote shared object allows either a client or server to send a message using SharedObject.connect(nc). you.data.send().y = so. 1 Write a method that SharedObject.send() will call: private function doSomething(msg:String):void { trace("Here's the message: " + msg).x = so.uri. Last updated 8/30/2010 .y. When you use SharedObject. } 2 Call send() to broadcast the message: so = SharedObject. nc.

However. add an onConnect() function that specifies a null value for client.readAccess = "appStreams. Hardening Guide for Flash Media Server. you can use Server-Side ActionScript to create a dynamic access control list (ACL) for shared objects and streams.onConnect = function(client.asc. } This main.appSO/public/". Allow or deny access to assets About access control When users access the server./appSO/". By default.asc) is passed a Client object. the server-side script (main.asc file grants access to all URIs that start with appStreams/public. // give write access client. see the “Developer Guidelines” section in the Adobe DevNet article. they have full access to all streams and shared objects. securing communication with the server. writing Server-Side ActionScript.acceptConnection(client).name = name.asc file: application. You can also authenticate clients that connect to an application. and performing authentication.131 Chapter 7: Securing applications You can configure the server and your application to allow and deny access to assets such as streams and shared objects. For more information about securing applications. or update shared objects or streams. Allow access to streams ❖ In main. like this: client. You can use these properties to control access for each connection. These values can contain multiple strings separated by semicolons. Deny access to streams ❖ In main.writeAccess properties take string values. client. Implement dynamic access control The Client. readAccess and writeAccess are set to /.asc or yourApplicationName. read. which means the client can access every stream and shared object on the server.asc.readAccess and Client. Each Client object has readAccess and writeAccess properties.writeAccess: Last updated 8/30/2010 . by default.writeAccess = "appStreams/public/. The guidelines include modifying the Application. // accept the new client's connection application. add an onConnect() function that specifies a directory name on the server in your main. You can control who has access to create.xml file. name) { // give this new client the same name as passed in client. When a client connects to the server.writeAccess = "appStreams/public/".

rejectConnection(client.writeAccess = "".ip and. {"Access Denied"} ).onConnect = function(client. check the value of client. Authenticate clients Use properties of the Client object When a client connects to an application. } } Check the client’s IP address ❖ In main.. reject the client’s connection to the application: if (client. if (!referrerList[client. referrerList["http://www. } Define access to shared objects ❖ In main.com"] = true.rejectConnection(client.onConnect = function(client. referrerList["http://www.com"] = true.120") !=0) { application..referrer against a list of URLs that should be denied access.asc. name) { . add an onConnect() function that specifies shared object names. You can write server-side code to access the properties of the Client object and use the values to verify the validity of the connecting client: application.. client. the server creates a Client object that contains information about the client and passes it to the application. check the value of client.onConnect = function( pClient ) { for (var i in pClient) { trace( "key: " + i + ". Make sure that SWF files that are connecting to your application are coming from a location you expect.onConnect() handler in Server-Side ActionScript.example.asc..FLASH MEDIA SERVER 4. } Check an originating URL ❖ In main.ip. using the same URI naming conventions: application. } Last updated 8/30/2010 .indexOf("60. {"Access Denied"} ). If you find a match.writeAccess = "appSO/public/". // deny write access to the server client.asc.0 DEVELOPER’S GUIDE Securing applications 132 application. value: " + pClient[i] ). reject the client’s connection: referrerList = {}. } This gives the client write access to all shared objects whose URIs begin with appSO/public/. name) { .referrer]) { application.abc. if needed.

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Securing applications

133

Use a unique key
1 In client-side ActionScript, create a unique key, as in the following code, which concatenates the local computer

time with a random number:
var keyDate = String(new Date().getTime()); var keyNum = String(Math.random()); var uniqueKey = keyDate + keyNum;

2 Send the key to the server in the connection request:
nc.connect("rtmp://www.example.com/someApplication", uniqueKey);

3 The following code in the main.asc file looks for the unique key in the connection request. If the key is missing or

has already been used, the connection is rejected. This way, if a connection is replayed by an imposter, the replay attempt fails.
clientKeyList = new Object(); // holds the list of clients by key

application.onConnect = function( pClient, uniqueKey ) { if ( uniqueKey != undefined ) { // require a unique key with connection request if ( clientKeyList[uniqueKey] == undefined ) { // first time -- allow connection pClient.uniqueKey = uniqueKey; clientKeyList[uniqueKey] = pClient; this.acceptConnection(pClient); } else { trace( "Connection rejected" ); this.rejectConnection(pClient); } } } application.onDisconnect = function( pClient ) { delete clientKeyList[pClient.uniqueKey]; }

Use an Access plug-in
An Access plug-in intercepts incoming requests before passing them to the application. You can program an Access plug-in to use any form of authentication.

More Help topics
“Developing an Access plug-in” on page 144

Use Flash Player version
You can protect your content from clients that aren’t running in Flash Player, based on the user agent string received from the connection. The user agent string identifies the platform and Flash Player version, for example:
WIN 8,0,0,0 MAC 9,0,45,0

There are two ways to access these strings:
Virtual keys Configure the server to remap the stream based on the Flash Player client. Client.agent Challenge the connection using Server-Side ActionScript:

Last updated 8/30/2010

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Securing applications

134

application.onConnect = function( pClient ) { var platform = pClient.agent.split(" "); var versionMajor = platform[1].split(",")[0]; var versionMinor = platform[1].split(",")[1]; var versionBuild = platform[1].split(",")[2]; } // // // // // // output example Client.agent: platform[0]: versionMajor: versionMinor: versionBuild:

WIN 9,0,45,0 "WIN" 9 0 45

Verify connecting SWF files
You can configure the server to verify the authenticity of client SWF files before allowing them to connect to an application. Verifying SWF files prevents someone from creating their own SWF files that attempt to stream your resources. SWF verification is supported in Flash Player 9 Update 3 and later.

Allow or deny connections from specific domains
If you know the domains from which the legitimate clients will be connecting, you can whitelist those domains. Conversely, you can blacklist known bad domains. You can enter a static list of domain names in the Adaptor.xml file. You can also maintain these lists in your own server-side code and files. In the following example, a file named bannedIPList.txt contains a list of excluded IP addresses, which can be edited on the fly:

Last updated 8/30/2010

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE
Securing applications

135

// bannedIPList.txt file contents: // 192.168.0.1 // 128.493.33.0 function getBannedIPList() { var bannedIPFile = new File ("bannedIPList.txt") ; bannedIPFile.open("text","read"); application.bannedIPList = bannedIPFile.readAll(); bannedIPFile.close(); delete bannedIPFile; } application.onConnect = function(pClient) { var isIPOK = true; getBannedIPList(); for (var index=0; index<this.bannedIPList.length; index++) { var currentIP = this.bannedIPList[index]; if (pClient.ip == currentIP) { isIPOK = false; trace("ip was rejected"); break; } } if (isIPOK) { this.acceptConnection(pClient); } else { this.rejectConnection(pClient); } }

In addition, you can create server-side code to check if requests are coming in too quickly from a particular domain:

Last updated 8/30/2010

call("verifyClient".$verifyTimeOut). or other access-granting service. The client provides a token or username/password using client-side ActionScript: Last updated 8/30/2010 .key) { trace("Connection Passed"). } } } application. // send the key to the client pClient. then clear timer if (pClientRet. LDAP server. pClient. } function VerifyClientHandler(pClient) { this. } application.$verifyTimeOut). $verifyTimeOut. application. pClient).random()}). // set a wait timer pClient.$verifyTimeOut = setInterval(pClient.prototype. this.onDisconnect = function(pClient) { clearInterval(pClient.key == pClient. 1 The SWF supplies the user credentials in the connection request. clearInterval(pClient.verifyTimeOut = function() { trace (">>>> Closing Connection") clearInterval(this.0 DEVELOPER’S GUIDE Securing applications 136 application. } Authenticate users Authenticate using an external resource For a limited audience.acceptConnection(pClient).VERIFY_TIMEOUT_VALUE = 2000.onResult = function (pClientRet) { // if the client returns the correct key.onConnect = function(pClient) { this.FLASH MEDIA SERVER 4.disconnect(this).VERIFY_TIMEOUT_VALUE.verifyKey.verifyKey). new VerifyClientHandler(pClient). Client.$verifyTimeOut). it is feasible to request credentials (login and password) and challenge them using an external resource.verifyKey = ({key: Math. // create a random key and package within an Object pClient. such as a database.

adobe. sUsername. sPassword). If the credentials are valid.authenticate(FMSid.com/go/learn_fms_flashremoting_en. NetServices (connects to a Flash Remoting gateway). } } // the result handler (sample only. 2 Flash Media Server validates the credentials against a third-party system. you will have to customize this) // this command will return a true/false and the FMS client id Authenticate.FMSid++.authenticate(FMSid.connect("rtmp://server/secure1/".asc"). For more information about Flash Remoting. } else { application. netService. delete pendingConnections[FMSid]. XML classes. pUsername. rejectConnection ( pendingConnections[FMSid] ). Last updated 8/30/2010 . nc.cfm"). LoadVars.onResult = { } 3 Flash Media Server accepts or rejects the connection. webService. see www. load("WebServices.asc"). if (pUsername!= undefined && pPassword !=undefined) { // issue the external call (3 examples below) loadVars. pPassword). application. where the token can be granted based on a property of the client. load("NetServices. You can use the following classes to make calls from Server-Side ActionScript to external sources: WebService.FMSid = application. pPassword ) { // create a unique ID for the client pClient.send("http://xyz.0 DEVELOPER’S GUIDE Securing applications 137 var sUsername = "someUsername".FLASH MEDIA SERVER 4.onConnect = function( pClient. pData ) { if (pData) { application.acceptConnection( pendingConnections[FMSid] ). delete pendingConnections[FMSid].com/auth.onData = function ( FMSid. // for Flash remoting // for SOAP web services pendingConnections = new Object(). Flash Media Server accepts the connection: loadVars. pPassword). var sPassword = "somePassword". // place the client into a pending array pendingConnections[FMSid] = pClient. pUsername. pUsername. } } Authenticate using a token This technique is an alternative to a username/password style of authentication.

0 DEVELOPER’S GUIDE Securing applications 138 The control flow is as follows: 1 The client SWF requests an authentication token from a third party. 5 Flash Media Server accepts the connection. Last updated 8/30/2010 . 3 The client sends the token with its connection request.FLASH MEDIA SERVER 4. 4 Flash Media Server verifies the token with the third party system. 2 The third party returns the token to the client.

Authorization.139 Chapter 8: Developing Plug-ins Adobe® Flash® Media Server provides a plug-in architecture written in C++ that lets you extend the functionality of the server. reject. See “Specify a reason string for an authorization failure” on page 151. control access to streams and server events (Authorization plug-in). see Adobe Flash Media Server plug-in API Reference. The server uses a new StatusCode enum to send a NetStatus code to the client. Versioning. See “Publish and record streams for DVR with dynamic streaming” on page 93 and “Accessing events and fields” on page 153. you can use the plug-ins to accept. • The Authorization plug-in added a value for the F_STREAM_PUBLISH_TYPE field: 2. and File plug-ins to build unique deployments with expanded access.0 includes the following updates to the plug-ins: • Flash Media Streaming Server supports the Access plug-in. See “Accessing events and fields” on page 153. upgrading. For example. This value supports the absolute time code feature and preserves gaps in a recording when an encoder goes offline. or redirect clients before they reach your application-level code (Access plug-in). Flash Media Interactive Server. use FmsCreateAuthAdaptor3() to provide a reason string for an authorization failure. Use the Access. and create a file I/O mechanism (File plug-in). authorization. What’s new with plug-ins in Flash Media Server 4. and file management solutions. • In the Authorization plug-in. For detailed information about each plug-in’s API.0 Flash Media Server 4. and Flash Media Development Server support the following plug-ins: • Access plug-in • Authorization plug-in • File plug-in Flash Media Streaming Server supports the following plug-in: • Access plug-in Last updated 8/30/2010 . • The Authorization plug-in added the following fields: F_CLIENT_SWF_RESULT and F_CLIENT_FORWARDED_FOR. and server editions Server edition support Flash Media Enterprise Server.

use the FmsCreateFileAdaptor2() and FmsDestroyFileAdaptor2() methods and return version 1.0 1. or Microsoft Visual C++ 2008. including new APIs.5.x plug-ins work on 32-bit Flash Media Server 4. GCC 4. To use Flash Media Server 3. you can continue to use your existing plug-in code.0 features with the Authorization plug-in. For more information on the versioning APIs. Microsoft® Visual C++ 2005.0.0 DEVELOPER’S GUIDE Developing Plug-ins 140 About versioning The Authorization plug-in and the File plug-in have versioning and accompanying create and destroy methods. to use Flash Media Server 4.0 and earlier Plug-in version 0.5 1.0 Create and Destroy method FmsCreateFileAdaptor() FmsDestroyFileAdaptor() Flash Media Server 3.0 and earlier Plug-in version 0. see Adobe Flash Media Server plug-in API Reference.5. for example. Recompile 32-bit plug-ins for a 32-bit server 1 Recompile the plug-in with Microsoft® Visual C++ 2003. call FmsCreateAuthAdaptor3() and return 2. On Linux.1 which installs with CentOS. recompile the plug-ins with a 64-bit Flash Media Server library.0 from a call to FmsCreateXXXAdaptor2(). The server detects the plug-in version number for the File and Authorization plug-ins based on the value returned by the create and destroy methods.x.0.0 Create and Destroy method FmsCreateAuthAdaptor() FmsDestroyAuthAdaptor() Flash Media Server 3.FLASH MEDIA SERVER 4. Note: To limit a plug-in to Flash Media Server 3. If you do not intend to use the new features. 2 For the File plug-in. To use new features in Flash Media Server 4. The Access plug-in does not have versioning.0 FmsCreateFileAdaptor2() FmsDestroyFileAdaptor2() The Authorization plug-in has the following versioning: Server version Flash Media Server 3.x plug-ins on 64-bit Flash Media Server 4. The File plug-in has the following versioning: Server version Flash Media Server 3.0 FmsCreateAuthAdaptor3() FmsDestroyAuthAdaptor3() Upgrading a plug-in All Flash Media Server 3.0 2. upgrade your plug-in. recompile the plug-in with GNU Compiler Collection 4. return version 0. To use the methods of a certain server version.5 1. For example.0 FmsCreateFileAdaptor2() FmsDestroyFileAdaptor2() Flash Media Server 4.0 FmsCreateAuthAdaptor2() FmsDestroyAuthAdaptor2() Flash Media Server 4.0 features. Last updated 8/30/2010 . use the correct create or destroy method and return the correct version number.

See “Compile a plug-in” on page 142. see “Upgrading a plug-in” on page 140. Note: To build the default plug-ins. Sample files The server includes sample files for each plug-in. Recompile 32-bit plug-ins for a 64-bit server • When porting 32-bit plug-in code to 64-bit code. See “Sample files” on page 141.AuthModule64 and MakeFile.FLASH MEDIA SERVER 4. Use these samples to learn how to use the API or use them as starting points for your own plug-ins. use MakeFile. Working with plug-ins Workflow for developing and deploying a plug-in Note: For information about upgrading a plug-in. To compile for 64-bit.cpp adaptor. See the Adobe Flash Media Server plug-in API Reference. Filename adaptor. 2 Build and compile the plug-in for your platform. there are two makefiles: MakeFile. Build the 64-bit installation. • Use the include files and libraries in the rootinstall/samples/plugins/include folder to compile the plug-ins.0 DEVELOPER’S GUIDE Developing Plug-ins 141 3 For the Authorization plug-in. be aware that the data types of some fields have changed. 1 Modify the sample plug-in to meet your organization’s needs or write your own plug-in. Choose Build > Configuration Manager and select Release x64.cpp sample. Last updated 8/30/2010 . 3 Deploy the plug-in.AuthModule64. Use the make command with the -f option to run the make file. use the FmsCreateAuthAdaptor3() and FmsDestroyAuthAdaptor3() methods and return version 2.AuthModule. Access plug-in The following sample files are installed to rootinstall\samples\plugins\access.h Description Sample Access plug-in C++ files and header file. • On Linux. use the make files. • On Windows. install the 64-bit compiler for Visual C++ in Visual Studio 2008 or later.0. See “Deploy a plug-in” on page 143.

Use GNU Compiler Collection 3.cpp A header file that defines create and destroy functions for the plug-in. FmsAuthActions.vcproj Makefile.vcproj Makefile.4.sln AuthModule.h FileModule. You can modify the files’ values to reflect the practices in your environment.sln FileModule. Use this file to build the default Authorization plug-in on Linux. FmsMedia.h StdAfx. Work files used with Microsoft Visual C++ for building an Authorization plug-in in a Windows environment.cpp FileModule. Sample includes file declaration files. Sample includes file declaration files. Header files The following header files define the plug-in API and are installed to rootinstall\samples\plugins\include: FmsAdaptor.x to compile plug-ins in Linux. You can modify the files’ values to reflect the practices in your environment. Description Sample File plug-in C++ file and header file. File plug-in The following sample files are installed to rootinstall\samples\plugins\file. Filename AuthModule.cpp Description Sample Authorization plug-in C++ file.h.h. and IFCAccessAdaptor. Filename SimpleFileAdaptor.access StdAfx.cpp Description Work files used with Microsoft Visual C++ for building an Access plug-in in a Windows environment.NET 2003.h. Utility functions for working with files and directories. FmsFileAdaptor. or Microsoft Visual Studio .h.h.vcproj Makefile. You can modify the files’ values to reflect the practices in your environment. Work files used with Microsoft Visual C++ for building a File plug-in in a Windows environment. Use this file to build the default File plug-in on Linux. Sample includes file declaration files.NET 2008 to compile plug-ins in Windows.h StdAfx. Authorization plug-in The following sample files are installed to rootinstall\samples\plugins\auth.h.h FileUtil.FileModule StdAfx.h.AuthModule StdAfx.FLASH MEDIA SERVER 4.sln AccessModuleSample. FmsAuthEvents. Use this file to build the default Access plug-in on Linux. Last updated 8/30/2010 .0 DEVELOPER’S GUIDE Developing Plug-ins 142 Filename AccessModuleSample.cpp AuthModule.cpp SimpleFileAdaptor. FmsAuthAdaptor. Compile a plug-in Use Microsoft® Visual Studio . Microsoft Visual C++ 2005.h StdAfx.

Plug-ins are implemented as shared library (DLL) files in Windows systems and as shared object (SO) files in Linux systems. and FileModule. Build the plug-in as a Release. Ignore the warnings as you compile. Select Flash Media Server (FMS) from the Services list and click Start.NN. 1 Do one of the following to stop the server: • In Windows. Last updated 8/30/2010 .dll/libconnect. • In Linux./server stop.log.so. choose Start > Control Panel > Administrative Tools > Services. Enter the following: . choose Start > Control Panel > Administrative Tools > Services. • In Linux. To build on a 64-bit version of a linux GCC compiler. open a shell window and go to the directory where the server is installed: cd /opt/adobe/fms. when a vhost is restarted a new core process starts up and loads a copy of an Authorization plug-in. General development tasks Sending data from a plug-in to a log file Call the log() function of the IFmsServerContext class in a plug-in to send custom messages to log files from the Authorization and File plug-ins. Deploy a plug-in Once deployed.so.so. The filenames are: libconnect.dll/FileModule. use the -m32 switch and -B option for GCC./server start.0 DEVELOPER’S GUIDE Developing Plug-ins 143 Note: The Authorization plug-in and the Access plug-in have compilation warnings that are harmless. Plug-in log files are located in the RootInstall/logs directory and are named fileio. If you build the plug-in as Debug the modules don’t load with the server process. a plug-in plugs into a server process. open a shell window and go to the directory where the server is installed: cd /opt/adobe/fms.NN. 2 Copy the compiled plug-in DLL or SO files to one of the following folders: • rootinstall/modules/access • rootinstall/modules/auth • rootinstall/modules/fileio Note: Do not change the folder names. Authorization plug-ins and File plug-ins can have any name. Select Flash Media Server (FMS) from the Services list and click Stop. When the vhost stops. AuthModule.so.log and authMessage. copy all the plug-ins into the /auth folder. An Access plug-in must have the name libconnect. by default. For example.dll/AuthModule. 3 Do one of the following to start the server: • In Windows.FLASH MEDIA SERVER 4. The plug-in is loaded during the process start-up and unloaded during process shutdown. Enter the following: . If you’re deploying multiple Authorization plug-ins. Point the -B switch to the /usr/lib32 libraries. the core process unloads the Authorization plug-in.dll/libconenct.

therefore plug-in developers cannot rely on these to log messages. including the location and name of the log files. The log() function has an argument that specifies whether the log message should also be logged to the system log (Windows Event Viewer or Linux syslog). If processing the call is time consuming and requires a wait or sleep operation. or redirected before the requests reach the server’s script layer. Calls to the method cannot get values added as attributes to elements.0. Edit the Logging section of the Server. An Access plug-in adds another layer of security to the server.cpp file. the Access plug-in is not supported over RTMFP connections. You can only use one Access plug-in. Verify the XML and restart the server. depending on the server configuration. The Access plug-in is hosted by a process that closes standard out and standard error.xml file (located in RootInstall/conf) to add or change the configuration information. Handling time-critical calls Every call from the server to a File or Authorization plug-in—for example.log files and in the authEvent. Retrieving data from a configuration file Call the getConfig() function of the IFmsServerContext class in an Authorization plug-in or a File plug-in to retrieve custom data stored in the Server.cpp file. log messages explicitly to a file. Excessive logging to the system log can cause performance problems. Edit the Logger. because the server remains in a pending state until the call is returned. Calls to getConfig() can get only text node values. The sample Access plug-in demonstrates a workaround. A call should be processed and returned back to the server as fast as possible. reject.xml configuration file (located in RootInstall/conf) to enable or disable each log file. for the Access plug-in.log".0 DEVELOPER’S GUIDE Developing Plug-ins 144 Note: In addition to client connections. multiple elements. Plug-ins can retrieve data stored in the Plugins XML element. see the comments in the XML files. see the FileModule sample. or nested elements. You can analyze this data in the plug-in to activate different functionality in the plug-in. Developing an Access plug-in Access plug-in overview Important: Every edition of the server supports Access plug-ins. These connections are distinguished by the IP address 127. "a").xml file (located in the RootInstall\conf folder) in a text editor and add data. To add custom data.1 in the access. For detailed information. Last updated 8/30/2010 . However.xml configuration file. rejected. in the RootInstall/samples/plugins/access/adaptor. open the Server.0.play() method is called.FLASH MEDIA SERVER 4. authorize() in the Authorization plug-in—is time-critical. Search for the line FILE* logFile = fopen("SampleAdaptor. The default value is false.log files. it intercepts connection requests and lets you examine the client and the server to determine whether requests should be accepted. or redirect requests based on criteria like how many users are connected to the server and the amount of bandwidth being consumed. You can code the plug-in to accept. For an example of a call to IFmsServerContext->getConfig(). the passed arguments should be preserved and passed to a thread pool that is created by the plug-in. the Authorization plug-in logs the connections made when a server-side Stream. For an example. Instead. see the AuthModule.

5. You must use the Access plug-in to force incoming connections to a different vhost. the originating URL of the SWF file.FLASH MEDIA SERVER 4. Call getValue() to query client fields. rejects. or redirects the connection. If the Access plug-in is available. was added in Flash Media Server 3. even if you don’t need to rewrite the connection URI. Redirecting a client sends a redirection message containing a new URI back to the client and terminates the current connection. you can update the database with a record of the user’s access to the server. and the data in the connection message is sent to the Access plug-in (which runs in the edge process). The plug-in can’t rewrite a connection to a different adaptor because the socket-level connection to the adaptor has already been made. The Authorization plug-in runs in the core process (fmscore) after the connection has been forwarded to the application. A client connection request triggers the onAccess() callback function in the Access plug-in. it is initialized with a context pointer when the server starts. If you want authorization to be as lightweight as possible. Rewriting the target URI forces the connection to a different vhost. Note: Redirecting a connection is different than rewriting a connection URI. Note: There can only be one Access plug-in per server installation. it examines the connection request and either authorizes. or application instance. If an Access plug-in is not available. The context pointer and plug-in pointer provide two-way communication between the Access plug-in and the server. or rewrite the target URI. or redirect attempts by clients to connect to applications. reject. since the Access plug-in runs early in the connection process. The field x-page-url. Writing the code in an Access plug-in You can either modify the code in the sample Access plug-in file provided by Adobe. reject. set permissions to access audio and video bitmap data. Call setValue() to modify client fields. application. or redirects the requests in the onAccess() callback function. Using this information.0 DEVELOPER’S GUIDE Developing Plug-ins 145 You can query your organization’s database of users and passwords to determine which connection requests should be allowed. the server determines whether or not an Access plug-in exists. Last updated 8/30/2010 . Once the plug-in accepts the connection. Also. The Authorization plug-in can accept. At this stage. However. connection requests proceed as usual. or you can write your own plug-in. modifies client properties. the plug-ins run at different places and are active in different stages of the connection process. it is too late to rewrite the target URI by the time the Authorization plug-in is notified. user agent. application. and so on. and inspect client properties. use the Access plug-in. When a client attempts to connect to the server. it is the most efficient way to screen connections. but it cannot rewrite connections to different URIs. the Access plug-in can accept. New connections arrive at the edge process (fmsedge). Write the code that examines connection requests. the URL of the SWF file or the server in which a connection originated. Rewriting connections to the server Both the Access and Authorization plug-ins let you authorize connections to the server. or application instance. and accepts. rejects. see the fms_access namespace in the Adobe Flash Media Server plug-in API Reference. the plug-in has information about the client such as IP address. or redirect the connection. For a list of fields. Access plug-in connection flow Once you’ve installed an Access plug-in. You can set read and write access for files and folders on the server. the connection (or target) URI. The client then attempts to connect to the new URI.

Different core processes handle the connections to the application. The server uses the following formula to determine which core process to use: core_number % number_of_ cores. For example.xml. Three core processes are reserved for the top clients. fprintf(pFile. You can also use this feature to provide a higher quality of service (QoS) to certain customers. coreId)) { FILE * pFile = fopen ("error. CPU consumption and the size of the recorded media cache. You can develop an Access plug-in that distributes an application among six core processes and monitors the statistics for each process. if(!setValue("coreIdNum". coreId). After you’ve queried the fields and written your connection logic. The plug-in monitors statistics for each process. the plug-in code determines the core ID of a different process (one that isn't overloaded) and sends the new connection to that process. Use the Administration APIs: getFileCacheStats(). Last updated 8/30/2010 . and eBYTES_OUT. getAppStats(). For example. each application gets three core processes to handle incoming connections. "Core id = %s". If a core process is overloaded. 2 Whenever a new client connects. or redirect() to allow a client to connect to an application on the server or not. Distribution of applications across core processes is defined by numprocs and scope elements in Application. } You can call getValue() to find out which core process a client connection is assigned to. the plug-in ensures that the overloaded process does not handle any new connections. One strategy is to write plug-in code to do the following: 1 Track statistics for each core process.txt". for example. if numprocs is 3 and scope is set to application. Assigning an application to a core process You can dynamically assign an application to a core process. such as CPU usage and the size of the recorded media cache. call accept(). FILE * pFile = fopen ("output.FLASH MEDIA SERVER 4. fprintf(pFile. eBYTES_IN. If a particular process becomes overloaded. suppose you want to provide the best possible performance to certain clients that are paying a premium subscription fee to access content. Load balancing You can code the Access plug-in to monitor performance metrics.0 DEVELOPER’S GUIDE Developing Plug-ins 146 Call getStats() to query the following server statistics: eTOTAL_CONNECTED. and balance loads accordingly. the remaining three are available to all other clients. the plug-in code must determine if the core process is overloaded. "Core id = %s". as in the following: const char* coreId = getValue("coreIdNum").log". depending on the client."a")."a"). If it is. the following code assigns a core number of 3: char* coreId = "3". you can develop an Access plug-in that ensures new incoming connections are not sent to the overloaded core process. The plug-in can route new connections to processes that can handle them. For example. To specify which core process handles an application. coreId). getInstanceStats(). you can use certain core processes exclusively for certain clients. The core number can be any positive integer. Quality of Service (QoS) To provide higher QoS to certain clients. pass the field "coreIdNum" and a core number to the setValue()function. Use this feature to balance a load across core processes based on real-time performance counters. reject().

. as in the following: <!-.. The Authorization plug-in lets you remap this to a different physical location.Controls libconnect.0 DEVELOPER’S GUIDE Developing Plug-ins 147 Configuring folder permissions on the server The Access section of the Application.play("myvideos/foo")— when the request is processed by the server.. this virtual name could map to c:\apps\vidapp\myvideos\.. c:\myvideos\. which lets you set permissions for individual files. • Authorize playing a stream or seeking in a stream • Authorize a dynamic stream transition • Authorize publishing a stream or recording a stream • Map logical URLs to physical locations For example.. Use the Authorization plug-in to do the following: • Authorize connections to the server Note: The Access plug-in can also authorize connections and is more lightweight. for example. For more information. if the video player plays a stream “foo” —ns. </Application> Developing an Authorization plug-in Authorization plug-in overview The Authorization plug-in authorizes client access to server events and fields associated with those events.. • Disconnect clients from the server • Call a method in Server-Side ActionScript • Access client statistics • Identify when a new codec is discovered in a publishing stream • Restrict the size of a recording by size or duration Use the Authorization plug-in to deliver content to clients according to one or more of the following criteria: • Geographic location • Subscription level Last updated 8/30/2010 ..dll access configurations --> <Application> . If the FolderAccess element is set to true. The default value is false.xml configuration file (located in each virtual host directory and possibly in application directories) lets you configure folder-level permissions for the Access plug-in.FLASH MEDIA SERVER 4.. <Client> . <Access> <FolderAccess>false</FolderAccess> </Access> .. you cannot use the readAccess and writeAccess fields in the Access plug-in to set permissions for individual files. you can only set permissions at the folder level. see “Access plug-in overview” on page 144.

The server suspends operations until the plug-in calls the onAuthorize() function of the IFmsAuthServerContext class. FmsDestroyAuthAdaptor2() // Destroys an Authorization plug-in with versioning.FLASH MEDIA SERVER 4. The server loads the plug-ins in alphabetical order. the plug-in scans all messages to detect a codec change. it expects one of the following entry points: FmsCreateAuthAdaptor() // Creates an Authorization plug-in. the server calls the getEvents() function to find out which events the plug-in wants to process. and so on. Writing the code in an Authorization plug-in When the server loads an Authorization plug-in. Last updated 8/30/2010 . The server calls getEvents() once. other events only require the plug-in to notify the server that the plug-in received notification of the event.0 DEVELOPER’S GUIDE Developing Plug-ins 148 • Stream origin • Time and duration of a user’s access to specific streams You can also use the Authorization plug-in to monitor stream quality of service (QoS). it follows alphabetical order. and getEvents(). Subscribe to this event only as needed. the server calls the notify() function on the plug-in. Call onAuthorize() in the last line of the authorize() function. There are two ways to process events: assign an action to an event.so) could authorize playing a stream. and the events are good for the lifetime of the plug-in. Allocate specific types of events to individual plug-ins: for example. Call onNotify() in the last line of the notify() function. use lowercase naming. Note: For cross-platform compatibility. When notification events occur. FmsCreateAuthAdaptor3() // Creates an Authorization plug-in with versioning information. FmsDestroyAuthAdaptor3() // Destroys an Authorization plug-in with versioning. This call completes any pending operations on the server. The server continues operating when it calls the notify() function of the IFmsAuthServerContext class. Pass it a pointer to the event. Using multiple Authorization plug-ins You can use a chain of plug-ins to sequentially perform actions on the incoming event. You write code in these functions that runs when the events occur. Once the plug-in is created. auth1. notify().so) could authorize publishing a stream. This event is disabled in the Authorization plug-in sample code installed with the server. When the server processes client requests for events. Pass it a pointer to the event and a boolean value indicating whether the event is authorized or not. and write code in the authorize() and notify() functions that processes the event.dll (or auth1. Each plug-in filters the incoming requests. Use the correct method for the version of the server you’re using. When authorization events occur. Some events must be authorized by the plug-in before the server executes them. Important: If the E_CODEC_CHANGE event is not excluded. which could then be read to another custom built tool. Implement the IFmsAuthAdaptor interface to process events as they occur. This call notifies the server that notification is complete and the event is no longer needed. For more information. the server calls the authorize() function on the plug-in. FmsDestroyAuthAdaptor() // Destroys an Authorization plug-in. see “About versioning” on page 140. FmsCreateAuthAdaptor2() // Creates an Authorization plug-in with versioning information. This class includes the functions authorize(). auth2. The plug-in reports live stream QoS information to an external log file.dll (or auth2.

if client 1 and client 2 both request to play the stream foo. the actions execute in the order in which they were attached. pAction->addParam(field).i64. For example.onConnect = function(client){ client.FLASH MEDIA SERVER 4. if the URL is "rtmp://ipaddr/clientid/filename?foo=Smith:Joe". client 1 could remap stream foo to c:\yourpath1\foo.someMethod = function(msg){ trace("inside someMethod"). ///script does not work with I64 and returns invalid type //should be preset to double or string //field. field.setString(reinterpret_cast<I8*>(const_cast<char*>(mtd))). } } Mapping stream paths Important: Use the characters “%3A” to escape a colon in a URL parameter. The action calls method() in a server-side script and passes it the parameter 12345. the following Server-Side ActionScript code defines someMethod() on the Client object: application. field) == IFmsAuthEvent::S_SUCCESS) { I64 clientId = field. For example. To assign an action to an event. IFmsNotifyAction* pAction = m_pAev->addNotifyAction("Notified by adaptor").flv and client 2 could remap stream foo to c:\yourpath2\foo. pAction->setMethodName(field). Actions are executed in the order they are assigned right before the event is disposed. FmsVariant field. //action to notify SSAS by calling "method" with U16 variable = 12345 //and I64 variable client id if (m_pAev->getField(IFmsAuthEvent::F_CLIENT_ID. To map a logical stream to a different physical path.0 DEVELOPER’S GUIDE Developing Plug-ins 149 Assigning actions to events There are two actions you can assign to an event: IFmsDisconnectAction and IFmsNotifyAction. set a parameter in the Application. field. The IFmsDisconnectAction disconnects one or more clients when the event occurs and the IFmsNotifyAction calls a function on the Client object or the application object in a server-side script when the event occurs. Use the authorize() function to remap virtual stream paths to different physical locations. If you don’t pass a value to setClientId(). The following code adds the IFmsNotifyAction instance pAction to the IFmsAuthEvent instance m_pAev. and you can remap the stream differently for each client. change it to "rtmp://ip-addr/clientid/filename?foo=Smith%3AJoe". //wrong!!! field.flv.setDouble((double)clientId). If you pass a value to setClientId(). the method is called on the server-side application object.setU16(12345).setI64(clientId). For example.xml file.flv. call addDisconnectAction() or addNotifyAction() from an IFmsAuthEvent instance. If multiple actions are attached to an event. pAction->setClientId(field). You can call addParam() on a IFmsNotifyAction instance to pass parameters to a method. } Note: The previous sample code is excerpted from the AuthModule. as follows: Last updated 8/30/2010 . For example. Actions execute right before the event is disposed.cpp file in the rootinstall/samples/plugins/auth folder. the method is called on the server-side Client object. const char mtd[] = "method". You can add as many actions as needed. two E_FILENAME_TRANSFORM events are called. You must define the method in a server-side script.

For example.5. For example..0 The behavior of the E_FILENAME_TRANSFORM event was improved to handle playlists.3 The E_FILENAME_TRANSFORM event is called for each client every time they play or publish a stream. the E_FILENAME_TRANSFORM event is called with the physical path to foo. as in the following sequence: play("clip0") play("clip1") play("clip0") play("clip0") play("clip1") / / / / / E_FILENAME_TRANSFORM / stop() E_FILENAME_TRANSFORM / stop() stop() stop() stop() Last updated 8/30/2010 . The path to the physical location of a stream that you specify in this event is passed to the File plug-in for use in certain file operations.0 DEVELOPER’S GUIDE Developing Plug-ins 150 <Application> .FLASH MEDIA SERVER 4. 3 Playback occurs. In the case of a playlist. The E_FILENAME_TRANSFORM for the application streamtest/inst1 foo. if client1 plays the file foo.5. Two E_FILENAME_TRANSFORM events are called and you can remap them for each client. Version2. <StreamManager> . Suppose you remap the physical path to c:\yourpath\yourfoo. The E_FILENAME_TRANSFORM event is a link between the Authorization plug-in and the File plug-in. a client plays many clips in a row. The E_FILENAME_TRANSFORM event lets you modify the F_STREAM_PATH property to change the path to a stream’s physical location. an E_FILENAME_TRANSFORM event occurs. <QualifiedStreamsMapping enable="true" /> Every time a client plays or publishes a stream or executes a Stream call in Server-Side ActionScript. is used for all clients. as in the following sequence: play("clip0") / E_FILENAME_TRANSFORM / stop() play("clip1") / E_FILENAME_TRANSFORM / stop() The E_FILENAME_TRANSFORM event is not called when a client plays the same clip multiple times in row in a playlist. c:\yourpath\yourfoo.. Client fields are not available..flv is not called again and the new path. suppose client1 and client2 both play the file foo.flv.2 the E_FILENAME_TRANSFORM event is called once for each stream in a application instance. Client fields are available.flv from the application streamtest/inst1. Events occur in the following order: 1 E_PLAY or E_PUBLISH The logical stream name may be changed here.flv. The E_FILENAME_TRANSFORM event is called every time a clip is played. as in the following sequence: play("clip0") / E_FILENAME_TRANSFORM / stop() play("clip1") / E_FILENAME_TRANSFORM / stop() play("clip0") / E_FILENAME_TRANSFORM / stop() play("clip0") / stop() play("clip1")/ E_FILENAME_TRANSFORM / stop() Version 3.flv). 4 E_STOP or E_UNPUBLISH About the E_FILENAME_TRANSFORM event The behavior of the E_FILENAME_TRANSFORM event has improved with each release of Flash Media Server.flv. Version 3. Version 2.5 The E_FILENAME_TRANSFORM event is called every time a client plays a new clip in a playlist.flv (c:\defaultpath\foo. 2 E_FILENAME_TRANSFORM The resulting physical stream name may be changed here..

see the IFmsAuthServerContext2 class in the Flash Media Server Plug-in API Reference.0 In the Authorization plug-in. the Interface IFmsAuthServerContext has been extended to IFmsAuthServerContext2. The following client statistics are defined in the FmsClientStats struct in the FmsAuthAdaptor. Specify a reason string for an authorization failure Flash Media Server 4. The Authorization plug-in aggregates requests before sending them to the server. Use the AuthFailureDesc structure to specify a reason string for the authorization failure.0 DEVELOPER’S GUIDE Developing Plug-ins 151 To use the E_FILENAME_TRANSFORM event to remap a path when a client plays the same clip multiple times in a playlist. Handling errors Authorization plug-ins are loaded by the FMSCore process. specify a reason string for the authorization failure.xml file. Differences between edge and origin deployments Authorization plug-ins can be deployed on origin servers and edge servers. the E_PLAY (for a live stream) or E_LOADSEGMENT (for recorded stream) event is called to play the clip. Accessing client statistics Accessing client statistics through the Authorization plug-in in the C++ layer can provide better server performance than accessing client statistics in a server-side script. The server uses the IFmsAuthServerContext2::StatusCode enum to send the client a NetStatus message about the failure. so the NOTIFY action cannot be used and should always return a failure status. For more information. This interface overrides the IFmsAuthServerContext::OnAuthorize method to include the AuthFailureDesc structure. Exceptions inside a plug-in crash FMSCore. the E_FILENAME_TRANSFORM event is called only the first time a clip plays. error code. process the E_LOADSEGMENT event rather than E_PLAY. the functionality is different in each case. To block play for a recorded stream. Edge (Core) Server-Side ActionScript is not executed on edge servers. and status code.FLASH MEDIA SERVER 4. set <QualifiedStreamsMapping enable="true"/> in the Application. The following is an example of the sequence: play("clip0") play("clip1") play("clip0") play("clip0") play("clip1") / / / / / E_FILENAME_TRANSFORM E_FILENAME_TRANSFORM E_FILENAME_TRANSFORM E_FILENAME_TRANSFORM E_FILENAME_TRANSFORM Path Path Path Path Path 1/ 1/ 2/ 3/ 2/ stop() stop() stop() stop() stop() When <QualifiedStreamsMapping enable="false"/>.h file: Last updated 8/30/2010 . Important: Authorization plug-ins must handle exceptions to prevent FMSCore from crashing. To use this feature use FmsCreateAuthAdaptor3() and pass it IFmsAuthServerContext2 as the parameter. Origin When an Authorization plug-in is installed on an origin server. In the Authorization plug-in.

if plug-in A subscribes to the E_CONNECT event and plug-in B subscribes to the E_DISCONNECT event.seek(). This command asks the server to suspend transmission because there is enough data in the buffer. Last updated 8/30/2010 . see the AuthModule. the adaptor A does not receive the E_DISCONNECT message. This read-only property is the position to which the client wants to seek.0 DEVELOPER’S GUIDE Developing Plug-ins 152 Statistic bytes_in bytes_out msg_in msg_out msg_dropped Description Total number of bytes received. Smart seek lets Flash Player seek within a back buffer and a foward buffer. For an example. The F_STREAM_TRANSMIT_POSITION property is available during this event. To verify that a client is connected.3 When the client NetStream. When the server receives a disconnect message from the client. To access client statistics. check the return status of the call to getClientStats(). The F_STREAM_TRANSMIT_POSITION property is available for this event. Total number of messages received.5. When the client disconnects from the server. This command asks the server to transmit more data because the buffer is running low. The commands are “seekRaw”.FLASH MEDIA SERVER 4. and “stopTransmit”. contains a field called F_CLIENT_STATS_HANDLE. “startTransmit”. implement the FmsCreateAuthAdaptor2() function. This read-only property is the position (in milliseconds) from which the client wants the server to start transmission. the Authorization plug-in receives an E_CLIENT_SEEK event. Use the E_START_TRANSMIT event to block the client from asking the server to start or stop sending data. The F_STREAM_SEEK_POSITION property is available for this event. The player sends commands to Flash Media Server to manage the buffer. such as E_PLAY and E_STOP. Every event. you do not need to save the handle. “smart seek” is enabled. When smart seek is enabled and a client calls NetStream.inBufferSeek property is true. the server sends an E_CONNECT event to the Authorization plug-in. it notifies the Authorization plug-in with an E_DISCONNECT event. Total number of messages sent. The E_STOP_TRANSMIT event is a notification event. This check is especially necessary if you are using multiple Authorization plug-ins. You cannot use it to prevent the client from seeking within the client-side buffer. Total number of dropped messages. When a client connects to the server. If you use F_CLIENT_STATS_HANDLE during any notification event (except E_CONNECT and E_DISCONNECT). Smart seeking Flash Media Server 3. you can call IFmsAuthServerContext::getClientStats() to get statistics. Note: The E_CLIENT_SEEK event is a notification event.The Authorization plug-in receives an E_STOP_TRANSMIT event when the Flash Player buffer is above a threshold. This read-only property is the position (in milliseconds) of the data at the end of the client buffer when the client sends a stopTransmit command. Pass this client stats handle back to the server in the getClientStats() call. For example. Use this event to write seek events to a log. The E_START_TRANSMIT event is a notification and authorization event. Total number of bytes sent. The Authorization plug-in receives an E_START_TRANSMIT event when the Flash Player buffer falls below a threshold.cpp file installed to RootInstall\samples\plugins\auth. The F_CLIENT_STATS_HANDLE field is invalid after the E_DISCONNECT event. After the plug-in receives the E_CONNECT event.

Pause delivery of a stream.5 2. IFmsAuthEvent.5 2. the authorize() function. For example. Stop an application. the play() method invokes the E_FILENAME_TRANSFORM event. authorize Start an application. Stop a stream.5 notify E_FILENAME_TRANS FORM E_PLAY E_STOP E_SEEK E_PAUSE 2. Play a stream. Fields can pertain to an application. authorize Last updated 8/30/2010 . the value of fields with a name in the form F_CLIENT_*. or a stream. authorize 2. The plug-in has access to certain fields during each event.The F_STREAM_TRANSITION property (read/write) indicates the transition mode sent by the client in the NetStream.5 2.5 notify. such as F_CLIENT_URI and F_CLIENT_REDIRECT_URI. in seconds. the server-side script call must be invoked by a method attached to a Client object.FLASH MEDIA SERVER 4.3 Flash Media Server 3. A client established a TCP control connection to the server. authorize notify.5.5 notify. More Help topics “Reconnecting streams when a connection drops” on page 73 Accessing events and fields The server provides an interface to an event object.5 2. An event object associated with a client event contains values for these fields. a client.5. The server has requested permission to map the logical filename requested by a client.play2() call. If it is necessary to have values for the F_CLIENT_* fields from server-side script calls. Authorization plug-in events The following table lists the Authorization plug-in events and whether the event is available in the notify() function. For example. or both: Event name Server availability 2.3 and Flash Player 10. that gives the plug-in access to events. and therefore do not always contain values for F_CLIENT_* fields. The F_STREAM_OFFSET property (read-only) indicates where to resume streaming after a reconnection. Seek a stream.0 DEVELOPER’S GUIDE Developing Plug-ins 153 Stream reconnecting Flash Media Server 3. Use the E_PLAY event to capture information from the F_STREAM_OFFSET property and the F_STREAM_TRANSITION property.5 2. authorize notify notify. Not all fields are accessible during all events and each field is either read-only or read/write. E_DISCONNECT 2. come from a client.5 Notify or Authorize Description E_APPSTART E_APPSTOP E_CONNECT notify notify notify. The TCP connection between the client and the server is broken. The values for Stream Reconnect are "resume" and "appendAndWait". Events associated with server-side scripts aren’t necessarily associated with a client.1 allow you to build applications that reconnect streams seamlessly when a connection is dropped or when a client switches from a wired to a wireless network connection.

authorize N/A notify notify.5 String Gives the client access to raw. authorize Publish a stream.5 I32 2. authorize notify notify. An action attached to an event was executed.5 Data type Description F_APP_INST F_APP_NAME F_APP_URI String String String The application instance name. Stop recording a stream.5 3. Load a segment. The URI of the application to which the client connected. SWF Verification has completed successfully for this client. authorize 3.5.5 3.5 3.5.3 3. authorize notify N/A Authorization plug-in fields The following table lists the Authorization plug-in fields: Field Server version 2.3 notify. Start stream transmission.5 I8 2.3 3. Last updated 8/30/2010 .5 3. The total number of events in the enum field. Unpublish a stream.5 2. Use this event to disallow the verification which terminates the connection. This event is called multiple times if the SWF is large enough to require partial matching.FLASH MEDIA SERVER 4. Client smart-pauses a stream.3 Notify or Authorize Description E_PUBLISH E_UNPUBLISH E_LOADSEGMENT E_ACTION E_CODEC_CHANGE E_RECORD E_RECORD_STOP E_CLIENT_PAUSE E_SWF_VERIFY notify.5. A list of audio codecs supported on the client.5 2.0 DEVELOPER’S GUIDE Developing Plug-ins 154 Event name Server availability 2. authorize notify notify notify. Stop stream transmission. F_CLIENT_AMF_ENCODI NG F_CLIENT_AUDIO_CODE CS F_CLIENT_AUDIO_SAMP LE_ACCESS 2. Use this mechanism to manage an inventory of SWFs that sit outside the server and aren't cached and managed by the server. The application name. Client smart-seeks a stream. Called before the SWF Verification process begins. A new codec is discovered in the stream. E_SWF_VERIFY_COM PLETE E_CLIENT_SEEK E_START_TRANSMIT E_STOP_TRANSMIT E_MAXEVENT 3.5 3.3 2. Record a stream. You can also use this event to provide a digest for the calling SWF.5 2.5 2. The AMF (Action Message Format) encoding of the client.5 2.5. uncompressed audio data from streams in the specified folders.5 notify notify. The value does not include the server name or port information.5.

The protocol the client used to connect to the server. The version of the protocol that the client used to connect to the server. the 32-byte hash digest. 1970.3 I64 F_CLIENT_DIFFSERV_B ITS F_CLIENT_DIFFSERV_M ASK F_CLIENT_FAR_ID F_CLIENT_FAR_NONCE F_CLIENT_FORWARDED_ FOR F_CLIENT_ID 3.5 2. The getField() function returns S_SUCCESS if this field is successfully retrieved.5.5 String String String String F_CLIENT_PROTO F_CLIENT_PROTO_VER 2.5 I64 3. in seconds since Jan 1. During SWF Verification.audioSampleAccess property (true).5 3.5 Data type Description F_CLIENT_AUDIO_SAMP LE_ACCESS_LOCK I8 A Boolean value preventing a server-side script from setting the Client.2 U8 3.5 String F_CLIENT_READ_ACCES S_LOCK 2.3 I64 F_CLIENT_SWFV_DIGES T 3. The client IP address.0 String 2.5 I8 F_CLIENT_STATS_HAND LE F_CLIENT_SWFV_DEPTH 3. The near ID of the client The near nonce of the client.readAccess property (true).5.3 U8* Last updated 8/30/2010 . F_CLIENT_CONNECT_TI ME 3. or not (false). You can retrieve this value from any event that has an associated client. During SWF Verification.FLASH MEDIA SERVER 4.5 I64 F_CLIENT_IP F_CLIENT_NEAR_ID F_CLIENT_NEAR_NONCE F_CLIENT_PAGE_URL 2.0 String String String The far ID of the client The far nonce of the client. F_CLIENT_SECURE 2.5 3. A string that uniquely identifies the client stats handle. or not (false). A 64-bit integer value that uniquely identifies the client (this value is not unique across processes). 2.0 DEVELOPER’S GUIDE Developing Plug-ins 155 Field Server version 2. Any x-forwarded-for header included by an HTTP Proxy on an RTMPT session. The URL of the client SWF file.5 I8 F_CLIENT_REDIRECT_U RI F_CLIENT_REFERRER 3. A string of directories containing application resources (shared objects and streams) to which the client has read access.5 3. DSCP mask to be used in setsockopt.5 String String F_CLIENT_READ_ACCES S 2.5 3.5. DSCP bits to be used in setsockopt for a particular NetConnection.5 4. the 64-bit size of the original SWF that corresponds with the digest. as a byte buffer.2 U8 3. A Boolean value preventing a server-side script from setting the Client.5. The time the client connected to the server.5 String The URL of the SWF file or server where this connection originated. (This field is set only when clients use Flash Player 8 or above). A Boolean value indicating whether a connection is secure (true) or not (false). A URI to redirect the connection to.5.

Service. The virtual host of the application the client is connected to.3 String U8* F_CLIENT_VHOST 2.5 I8 Last updated 8/30/2010 .5.5 3. During SWF Verification.5 String F_CLIENT_WRITE_ACCE SS_LOCK 2. without the query string. F_CLIENT_URI 2. the time to live (in seconds) of each SWF hash in the cache. This field is similar to the UserAgentExceptions function in the Application. Use this field to associate some user data with a client. The stem of the URI the client specified to connect to the server. The getField() and setField() functions return S_SUCCESS if user data is successfully get or set. The completed result of a SWF Verification attempt.5 I32 2.writeAccess property (true). Retrieve this field in any subsequent event associated with the client. Possible values are in the eSWFMatch enum. The URI the client specified to connect to the server. When getting data." 2. The value does not include the application name or instance name. Set this value to true if you want a client who would normally be subject to SWF Verification to be excepted from that requirement.5. uncompressed video data from streams in the specified folders. When setting data.5 String F_CLIENT_URI_STEM 2.5 I8 F_CLIENT_WRITE_ACCE SS 2.5 String F_CLIENT_VIDEO_CODE CS F_CLIENT_VIDEO_SAMP LE_ACCESS F_CLIENT_VIDEO_SAMP LE_ACCESS_LOCK 2.5 String F_CLIENT_USER_AGENT F_CLIENT_USERDATA 2.videoSampleAccess property (true). A Boolean value preventing a server-side script from setting the Client. All.3 Data type Description F_CLIENT_SWFV_EXCEP TION I8 A Boolean value indicating whether this client is an exception to SWF Verification (true) or not (false).3 I32 F_CLIENT_SWFV_VERSI ON F_CLIENT_TYPE 3.FLASH MEDIA SERVER 4. or not (false). Set this field from any authoization event that has an associated client. the server makes a copy before saving.5 I32 The client type. the plug-in should make a copy if the data needs to remain valid past the lifetime of the event. You can set anything that can be stored in an FmsVariant. F_CLIENT_SWFV_RESUL T F_CLIENT_SWFV_TTL 4. Possible values are Normal. A Boolean value preventing a server-side script from setting the Client. During SWF Verification. the version of the protocol.5 String Gives the client access to raw.5.3 I8 2. GroupElement (a client connected through an edge server). A string of directories containing application resources (shared objects and streams) to which the client has write access. The client user-agent.0 DEVELOPER’S GUIDE Developing Plug-ins 156 Field Server version 3. or not (false).xml configuration file but in this case you except a single client.0 None 3. Group. A list of video codecs supported on the client.5.

0 I8 2.0 Float F_STREAM_PAUSE_TOGG LE F_STREAM_POSITION 3.0 I8 F_STREAM_PAUSE_TIME 3. Use this field to assign a stream to a live event. for stream events other than E_PLAY. available in E_CODEC only. use the F_STREAM_SEEK_POSITION.FLASH MEDIA SERVER 4.5 3. The physical path of the stream on the server. A Boolean value indicating whether to pause or unpause. The codec type discovered in the stream. The segment start boundary in bytes. Last updated 8/30/2010 . The length of the stream. available in E_PAUSE only. available in E_LOADSEGMENT only. available in E_PAUSE only.Play.0 Data type Description F_MAXFIELD F_OLD_STREAM_NAME F_OLD_STREAM_QUERY F_OLD_STREAM_TYPE F_SEGMENT_END None String String String I64 The total number of fields in the enum field.8 String Float F_STREAM_PATH 2. and F_SEGMENT_END fields. The segment end boundary in bytes.2 I32 F_STREAM_NAME F_STREAM_OFFSET 2.5 2. A Boolean value indicating whether to ignore timestamps (true).5.5 3. or not (false).5 3. When the plug-in is deployed on an edge server. The old stream type for a switch or a swap. The stream name.5 String F_STREAM_PAUSE 3. The old stream query string for a switch or a swap. If false. The old stream for a switch or a swap.liveEvent property. This field is the same as the Server-Side ActionScript Stream. The stream ID.StreamNotFound message. the client does not receive the message because the server waits for the stream to publish. F_SEGMENT_START and F_SEGMENT_END fields. the physical path of the cache. The time at which a stream is paused.0 DEVELOPER’S GUIDE Developing Plug-ins 157 Field Server version 3. A Boolean value.5 Float F_STREAM_LIVE_EVENT 3. F_SEGMENT_START. when a client plays a stream and issues a SWITCH transition and the stream is not yet published the client receives a NetStream.5 U16 F_STREAM_CODEC_TYPE 3. The codec value discovered in the stream. The stream pause toggle.5 Float The position of the stream. available in E_PAUSE only.0 I64 F_STREAM_CODEC 3. If true. available in E_CODEC only. The offset value when F_STREAM_TRANSITION is offset.0 None F_STREAM_LIVE_PUBLI SH_PENDING 3.5 3. use the F_STREAM_SEEK_POSITION. F_STREAM_PAUSE_TIME. For stream events other than E_PLAY.5 I32 I8 F_STREAM_LENGTH 2.5 U16 F_STREAM_ID F_STREAM_IGNORE 3. The server uses the live event to place the stream into the HTTP Dynamic Streaming manifest file.5 3. available in E_LOADSEGMENT only. F_SEGMENT_START 3.

use F_STREAM_PUBLISH_TYPE. for example. 1 for record and append to existing stream. Therefore. A query appended to a stream.0 I8 F_STREAM_SEEK_POSIT ION F_STREAM_TRANSITION F_STREAM_TRANSMIT_P OSITION 3. E_APPSTART F_APP_INST F_APP_NAME F_APP_URI E_APPSTOP Read-only Read-only Read-only N/A E_CONNECT Read-only Read-only Read-only Read-only E_DISCONNECT Read-only Read-only Read-only Read-only Read-only Read-only Read-only F_CLIENT_AMF_ENCO N/A DING F_CLIENT_AUDIO_CO N/A DECS F_CLIENT_AUDIO_SA N/A MPLE_ACCESS F_CLIENT_AUDIO_SA N/A MPLE_ACCESS_LOCK F_CLIENT_CONNECT_ N/A TIME F_CLIENT_DIFFSERV N/A _BITS N/A Read-only Read-only N/A Read/Write Read-only N/A Read/Write Read-only N/A Read-only Read-only N/A Read/Write N/A Last updated 8/30/2010 . The maximum size (in kb) of a stream recording.5 String F_STREAM_RECORD_MAX DURATION F_STREAM_RECORD_MAX SIZE F_STREAM_RESET 3. Each table lists all the fields and some events. A Boolean value indicating whether to allow adding a stream to a playlist (true).0 String Float F_STREAM_TYPE 2. available in E_RECORD only.5 3. 2 for record and append to existing stream while preserving gaps in the recording. F_STREAM_QUERY 2. for stream events other than E_PLAY.0 I32 The stream publishing type (available for E_PUBLISH only): 0 for record. available in E_SEEK only. available in E_RECORD only. the matrix is divided into mulitple tables. streamName?streamQuery.0 DEVELOPER’S GUIDE Developing Plug-ins 158 Field Server version 3. currently not supported. -1 for live. The maximum duration (in seconds) of a stream recording.0 Data type Description F_STREAM_PUBLISH_BR OADCAST F_STREAM_PUBLISH_TY PE I32 Broadcast or multicast.FLASH MEDIA SERVER 4. The transition mode string for a switch or a swap. A single table is too wide to display because there are too many events. The file type of the stream.5 Float 3.0 I8 3. available in E_START_TRANSMIT and E_STOP_TRANSMIT only.5 Float 3. or not (false). The position to which the stream should start/stop.5 String Authorization plug-in events and fields support matrix The following tables shows the fields you can access from each event. 3. The position to which the stream should seek.

0 DEVELOPER’S GUIDE Developing Plug-ins 159 E_APPSTART F_CLIENT_DIFFSERV N/A _MASK F_CLIENT_FAR_ID E_APPSTOP N/A E_CONNECT Read/Write E_DISCONNECT N/A N/A N/A N/A Read-only Read-only Read-only Read-only F_CLIENT_FAR_NONC N/A E F_CLIENT_FORWARDE N/A D_FOR F_CLIENT_ID F_CLIENT_IP F_CLIENT_NEAR_ID N/A Read-only Read-only N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only F_CLIENT_NEAR_NON N/A CE F_CLIENT_PAGE_URL N/A F_CLIENT_PROTO N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only N/A F_CLIENT_PROTO_VE N/A R F_CLIENT_READ_ACC N/A ESS F_CLIENT_READ_ACC N/A ESS_LOCK F_CLIENT_REDIRECT N/A _URI F_CLIENT_REFERRER N/A F_CLIENT_SECURE N/A Read/Write Read-only N/A Read/Write Read-only N/A Read/Write Read-only N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only N/A F_CLIENT_STATS_HA N/A NDLE F_CLIENT_SWFV_DEP N/A TH F_CLIENT_SWFV_DIG N/A EST F_CLIENT_SWFV_EXC N/A EPTION F_CLIENT_SWFV_RES N/A ULT F_CLIENT_SWFV_TTL N/A F_CLIENT_SWFV_VER N/A SION F_CLIENT_TYPE F_CLIENT_URI N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only F_CLIENT_URI_STEM N/A Last updated 8/30/2010 .FLASH MEDIA SERVER 4.

0 DEVELOPER’S GUIDE Developing Plug-ins 160 E_APPSTART F_CLIENT_USER_AGE N/A NT F_CLIENT_USERDATA N/A F_CLIENT_VHOST E_APPSTOP N/A E_CONNECT Read-write E_DISCONNECT Read-only N/A N/A N/A Read-write Read-only Read-only Read-only Read-only Read-only N/A F_CLIENT_VIDEO_CO N/A DECS F_CLIENT_VIDEO_SA N/A MPLE_ACCESS F_CLIENT_VIDEO_SA N/A MPLE_ACCESS_LOCK F_CLIENT_WRITE_AC N/A CESS F_CLIENT_WRITE_AC N/A CESS_LOCK F_MAXFIELD N/A Read/Write Read-only N/A Read/Write Read-only N/A Read/Write Read-only N/A Read/Write Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A F_OLD_STREAM_NAME N/A F_OLD_STREAM_QUER N/A Y F_OLD_STREAM_TYPE N/A F_SEGMENT_END F_SEGMENT_START F_STREAM_CODEC N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A F_STREAM_CODEC_TY N/A PE F_STREAM_ID F_STREAM_IGNORE F_STREAM_LENGTH N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A F_STREAM_LIVE_EVE N/A NT F_STREAM_LIVE_PUB N/A LISH_PENDING F_STREAM_NAME F_STREAM_OFFSET F_STREAM_PATH F_STREAM_PAUSE N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A F_STREAM_PAUSE_TI N/A ME F_STREAM_PAUSE_TO N/A GGLE F_STREAM_POSITION N/A N/A N/A N/A N/A N/A N/A Last updated 8/30/2010 .FLASH MEDIA SERVER 4.

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 161 E_APPSTART F_STREAM_PUBLISH_ N/A BROADCAST F_STREAM_PUBLISH_ N/A TYPE F_STREAM_QUERY E_APPSTOP N/A E_CONNECT N/A E_DISCONNECT N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A F_STREAM_RECORD_M N/A AXDURATION F_STREAM_RECORD_M N/A AXSIZE F_STREAM_RESET N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A F_STREAM_SEEK_POS N/A ITION F_STREAM_TRANSITI N/A ON F_STREAM_TRANSMIT N/A _POSITION F_STREAM_TYPE N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A The following table displays all the fields and more events: E_FILENAME_TRAN E_PLAY SFORM F_APP_INST F_APP_NAME F_APP_URI F_CLIENT_AMF_ENCODI NG F_CLIENT_AUDIO_CODE CS F_CLIENT_AUDIO_SAMP LE_ACCESS F_CLIENT_AUDIO_SAMP LE_ACCESS_LOCK F_CLIENT_CONNECT_TI ME F_CLIENT_DIFFSERV_B ITS F_CLIENT_DIFFSERV_M ASK F_CLIENT_FAR_ID F_CLIENT_FAR_NONCE F_CLIENT_FORWARDED_ FOR E_STOP Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A Read/Write Read-only N/A Read/Write Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Last updated 8/30/2010 .

0 DEVELOPER’S GUIDE Developing Plug-ins 162 E_FILENAME_TRAN E_PLAY SFORM F_CLIENT_ID F_CLIENT_IP F_CLIENT_NEAR_ID F_CLIENT_NEAR_NONCE F_CLIENT_PAGE_URL F_CLIENT_PROTO F_CLIENT_PROTO_VER F_CLIENT_READ_ACCES S F_CLIENT_READ_ACCES S_LOCK F_CLIENT_REDIRECT_U RI F_CLIENT_REFERRER F_CLIENT_SECURE F_CLIENT_STATS_HAND LE F_CLIENT_SWFV_DEPTH F_CLIENT_SWFV_DIGES T F_CLIENT_SWFV_EXCEP TION F_CLIENT_SWFV_RESUL T F_CLIENT_SWFV_TTL F_CLIENT_SWFV_VERSI ON F_CLIENT_TYPE F_CLIENT_URI F_CLIENT_URI_STEM F_CLIENT_USER_AGENT F_CLIENT_USERDATA F_CLIENT_VHOST F_CLIENT_VIDEO_CODE CS F_CLIENT_VIDEO_SAMP LE_ACCESS F_CLIENT_VIDEO_SAMP LE_ACCESS_LOCK E_STOP Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-write Read-write Read-only Read-only Read-only Read-only Read-only Read-write Read-write Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Last updated 8/30/2010 .FLASH MEDIA SERVER 4.

0 DEVELOPER’S GUIDE Developing Plug-ins 163 E_FILENAME_TRAN E_PLAY SFORM F_CLIENT_WRITE_ACCE SS F_CLIENT_WRITE_ACCE SS_LOCK F_MAXFIELD F_OLD_STREAM_NAME F_OLD_STREAM_QUERY F_OLD_STREAM_TYPE F_SEGMENT_END F_SEGMENT_START F_STREAM_CODEC F_STREAM_CODEC_TYPE F_STREAM_ID F_STREAM_IGNORE F_STREAM_LENGTH F_STREAM_LIVE_EVENT F_STREAM_LIVE_PUBLI SH_PENDING F_STREAM_NAME F_STREAM_OFFSET F_STREAM_PATH F_STREAM_PAUSE F_STREAM_PAUSE_TIME F_STREAM_PAUSE_TOGG LE F_STREAM_POSITION F_STREAM_PUBLISH_BR OADCAST F_STREAM_PUBLISH_TY PE F_STREAM_QUERY F_STREAM_RECORD_MAX DURATION F_STREAM_RECORD_MAX SIZE F_STREAM_RESET F_STREAM_SEEK_POSIT ION E_STOP Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only N/A N/A N/A Read-write Read-write Read-write N/A N/A N/A N/A Read-only Read-write Read-write N/A Read-write N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only N/A N/A N/A N/A Read-write N/A N/A N/A Read-write Read-only Read-only N/A N/A N/A N/A N/A Read-only N/A N/A N/A Read-only N/A Read-write N/A Read-only N/A N/A N/A N/A Read-only N/A Read-write N/A Read-only N/A N/A N/A N/A Read-only N/A Read-write N/A Read-only N/A Last updated 8/30/2010 .FLASH MEDIA SERVER 4.

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 164 E_FILENAME_TRAN E_PLAY SFORM F_STREAM_TRANSITION F_STREAM_TRANSMIT_P OSITION F_STREAM_TYPE E_STOP N/A N/A Read-write N/A N/A N/A Read-write Read-write Read-only The following table displays all the fields and more events: E_CLIENT_SEEK F_APP_INST F_APP_NAME F_APP_URI F_CLIENT_AMF_ENCODI NG F_CLIENT_AUDIO_CODE CS F_CLIENT_AUDIO_SAMP LE_ACCESS F_CLIENT_AUDIO_SAMP LE_ACCESS_LOCK F_CLIENT_CONNECT_TI ME F_CLIENT_DIFFSERV_B ITS F_CLIENT_DIFFSERV_M ASK F_CLIENT_FAR_ID F_CLIENT_FAR_NONCE F_CLIENT_FORWARDED_ FOR F_CLIENT_ID F_CLIENT_IP F_CLIENT_NEAR_ID F_CLIENT_NEAR_NONCE F_CLIENT_PAGE_URL F_CLIENT_PROTO F_CLIENT_PROTO_VER F_CLIENT_READ_ACCES S F_CLIENT_READ_ACCES S_LOCK E_SEEK Read-only Read-only Read-only Read-only E_CLIENT_PAUSE N/A N/A N/A N/A E_PAUSE Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A Read-only Read-only Read-only N/A Read-only Read-only Read-only N/A Read-only Read-only Read-only N/A Read-only N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A Read-only Last updated 8/30/2010 .

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 165 E_CLIENT_SEEK F_CLIENT_REDIRECT_U RI F_CLIENT_REFERRER F_CLIENT_SECURE F_CLIENT_STATS_HAND LE F_CLIENT_SWFV_DEPTH F_CLIENT_SWFV_DIGES T F_CLIENT_SWFV_EXCEP TION F_CLIENT_SWFV_RESUL T F_CLIENT_SWFV_TTL F_CLIENT_SWFV_VERSI ON F_CLIENT_TYPE F_CLIENT_URI F_CLIENT_URI_STEM F_CLIENT_USER_AGENT F_CLIENT_USERDATA F_CLIENT_VHOST F_CLIENT_VIDEO_CODE CS F_CLIENT_VIDEO_SAMP LE_ACCESS F_CLIENT_VIDEO_SAMP LE_ACCESS_LOCK F_CLIENT_WRITE_ACCE SS F_CLIENT_WRITE_ACCE SS_LOCK F_MAXFIELD F_OLD_STREAM_NAME F_OLD_STREAM_QUERY F_OLD_STREAM_TYPE F_SEGMENT_END F_SEGMENT_START F_STREAM_CODEC E_SEEK Read-only E_CLIENT_PAUSE N/A E_PAUSE Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-write Read-only Read-only N/A Read-only N/A Read-only N/A Read-only N/A Read-only N/A Read-only N/A Read-only N/A Read-only N/A Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Last updated 8/30/2010 .

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 166 E_CLIENT_SEEK F_STREAM_CODEC_TYPE F_STREAM_ID F_STREAM_IGNORE F_STREAM_LENGTH F_STREAM_LIVE_EVENT F_STREAM_LIVE_PUBLI SH_PENDING F_STREAM_NAME F_STREAM_OFFSET F_STREAM_PATH F_STREAM_PAUSE F_STREAM_PAUSE_TIME F_STREAM_PAUSE_TOGG LE F_STREAM_POSITION F_STREAM_PUBLISH_BR OADCAST F_STREAM_PUBLISH_TY PE F_STREAM_QUERY F_STREAM_RECORD_MAX DURATION F_STREAM_RECORD_MAX SIZE F_STREAM_RESET F_STREAM_SEEK_POSIT ION F_STREAM_TRANSITION F_STREAM_TRANSMIT_P OSITION F_STREAM_TYPE E_SEEK N/A Read-only Read-only Read-write N/A N/A E_CLIENT_PAUSE N/A N/A Read-only Read-only N/A N/A E_PAUSE N/A Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only N/A N/A N/A Read-only N/A N/A Read-only Read-only Read-only N/A N/A Read-only Read-only Read-only Read-only N/A N/A Read-only N/A Read-only N/A Read-only N/A N/A N/A N/A N/A N/A N/A Read-only N/A Read-only N/A Read-only N/A N/A N/A N/A N/A N/A Read-only Read-only N/A Read-only N/A Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only The following table displays all the fields and more events: E_PUBLISH F_APP_INST F_APP_NAME F_APP_URI F_CLIENT_AMF_ENCODI NG E_UNPUBLISH Read-only Read-only Read-only Read-only E_LOADSEGMENT Read-only Read-only Read-only Read-only E_CODEC_CHANGE Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Last updated 8/30/2010 .

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 167 E_PUBLISH F_CLIENT_AUDIO_CODE CS F_CLIENT_AUDIO_SAMP LE_ACCESS F_CLIENT_AUDIO_SAMP LE_ACCESS_LOCK F_CLIENT_CONNECT_TI ME F_CLIENT_DIFFSERV_B ITS F_CLIENT_DIFFSERV_M ASK F_CLIENT_FAR_ID F_CLIENT_FAR_NONCE F_CLIENT_FORWARDED_ FOR F_CLIENT_ID F_CLIENT_IP F_CLIENT_NEAR_ID F_CLIENT_NEAR_NONCE F_CLIENT_PAGE_URL F_CLIENT_PROTO F_CLIENT_PROTO_VER F_CLIENT_READ_ACCES S F_CLIENT_READ_ACCES S_LOCK F_CLIENT_REDIRECT_U RI F_CLIENT_REFERRER F_CLIENT_SECURE F_CLIENT_STATS_HAND LE F_CLIENT_SWFV_DEPTH F_CLIENT_SWFV_DIGES T F_CLIENT_SWFV_EXCEP TION F_CLIENT_SWFV_RESUL T F_CLIENT_SWFV_TTL E_UNPUBLISH Read-only E_LOADSEGMENT Read-only E_CODEC_CHANGE Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Last updated 8/30/2010 .

0 DEVELOPER’S GUIDE Developing Plug-ins 168 E_PUBLISH F_CLIENT_SWFV_VERSI ON F_CLIENT_TYPE F_CLIENT_URI F_CLIENT_URI_STEM F_CLIENT_USER_AGENT F_CLIENT_USERDATA F_CLIENT_VHOST F_CLIENT_VIDEO_CODE CS F_CLIENT_VIDEO_SAMP LE_ACCESS F_CLIENT_VIDEO_SAMP LE_ACCESS_LOCK F_CLIENT_WRITE_ACCE SS F_CLIENT_WRITE_ACCE SS_LOCK F_MAXFIELD F_OLD_STREAM_NAME F_OLD_STREAM_QUERY F_OLD_STREAM_TYPE F_SEGMENT_END F_SEGMENT_START F_STREAM_CODEC F_STREAM_CODEC_TYPE F_STREAM_ID F_STREAM_IGNORE F_STREAM_LENGTH F_STREAM_LIVE_EVENT F_STREAM_LIVE_PUBLI SH_PENDING F_STREAM_NAME F_STREAM_OFFSET F_STREAM_PATH F_STREAM_PAUSE F_STREAM_PAUSE_TIME E_UNPUBLISH N/A E_LOADSEGMENT N/A E_CODEC_CHANGE N/A N/A Read-only Read-only Read-only Read-only Read-write Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-write Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-write Read-write N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A Read-only Read-only N/A N/A Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A Read-only N/A N/A N/A N/A Read-only N/A N/A N/A N/A Read-only N/A N/A N/A N/A Read-only N/A N/A Last updated 8/30/2010 .FLASH MEDIA SERVER 4.

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 169 E_PUBLISH F_STREAM_PAUSE_TOGG LE F_STREAM_POSITION F_STREAM_PUBLISH_BR OADCAST F_STREAM_PUBLISH_TY PE F_STREAM_QUERY F_STREAM_RECORD_MAX DURATION F_STREAM_RECORD_MAX SIZE F_STREAM_RESET F_STREAM_SEEK_POSIT ION F_STREAM_TRANSITION F_STREAM_TRANSMIT_P OSITION F_STREAM_TYPE E_UNPUBLISH N/A E_LOADSEGMENT N/A E_CODEC_CHANGE N/A N/A Read-only Read-write Read-only Read-only Read-only N/A Read-only Read-only Read-write Read-only N/A Read-only Read-write N/A Read-only N/A Read-only N/A Read-only N/A N/A N/A N/A N/A Read-only N/A Read-only N/A Read-only N/A Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-write Read-only Read-only Read-only The following table displays all the fields and more events: E_RECORD F_APP_INST F_APP_NAME F_APP_URI F_CLIENT_AMF_ENCODING F_CLIENT_AUDIO_CODECS F_CLIENT_AUDIO_SAMPLE_ACC ESS F_CLIENT_AUDIO_SAMPLE_ACC ESS_LOCK F_CLIENT_CONNECT_TIME F_CLIENT_DIFFSERV_BITS F_CLIENT_DIFFSERV_MASK F_CLIENT_FAR_ID F_CLIENT_FAR_NONCE F_CLIENT_FORWARDED_FOR F_CLIENT_ID F_CLIENT_IP E_RECORD_STOP Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A Read-only Read-only Read-only Read-only Read-only Last updated 8/30/2010 .

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 170 E_RECORD F_CLIENT_NEAR_ID F_CLIENT_NEAR_NONCE F_CLIENT_PAGE_URL F_CLIENT_PROTO F_CLIENT_PROTO_VER F_CLIENT_READ_ACCESS F_CLIENT_READ_ACCESS_LOCK F_CLIENT_REDIRECT_URI F_CLIENT_REFERRER F_CLIENT_SECURE F_CLIENT_STATS_HANDLE F_CLIENT_SWFV_DEPTH F_CLIENT_SWFV_DIGEST F_CLIENT_SWFV_EXCEPTION F_CLIENT_SWFV_RESULT F_CLIENT_SWFV_TTL F_CLIENT_SWFV_VERSION F_CLIENT_TYPE F_CLIENT_URI F_CLIENT_URI_STEM F_CLIENT_USER_AGENT F_CLIENT_USERDATA F_CLIENT_VHOST F_CLIENT_VIDEO_CODECS F_CLIENT_VIDEO_SAMPLE_ACC ESS F_CLIENT_VIDEO_SAMPLE_ACC ESS_LOCK F_CLIENT_WRITE_ACCESS F_CLIENT_WRITE_ACCESS_LOC K F_MAXFIELD F_OLD_STREAM_NAME F_OLD_STREAM_QUERY F_OLD_STREAM_TYPE F_SEGMENT_END E_RECORD_STOP Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-write Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A Read-only N/A N/A N/A N/A N/A Last updated 8/30/2010 .

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 171 E_RECORD F_SEGMENT_START F_STREAM_CODEC F_STREAM_CODEC_TYPE F_STREAM_ID F_STREAM_IGNORE F_STREAM_LENGTH F_STREAM_LIVE_EVENT F_STREAM_LIVE_PUBLISH_PEN DING F_STREAM_NAME F_STREAM_OFFSET F_STREAM_PATH F_STREAM_PAUSE F_STREAM_PAUSE_TIME F_STREAM_PAUSE_TOGGLE F_STREAM_POSITION F_STREAM_PUBLISH_BROADCAS T F_STREAM_PUBLISH_TYPE F_STREAM_QUERY F_STREAM_RECORD_MAXDURATI ON F_STREAM_RECORD_MAXSIZE F_STREAM_RESET F_STREAM_SEEK_POSITION F_STREAM_TRANSITION F_STREAM_TRANSMIT_POSITIO N F_STREAM_TYPE E_RECORD_STOP N/A N/A N/A Read-only Read-only Read-only N/A N/A N/A N/A N/A Read-only Read-only Read-only N/A N/A N/A N/A Read-only N/A N/A N/A Read-only N/A N/A N/A Read-only N/A N/A N/A Read-only N/A N/A Read-only Read-write N/A Read-only Read-only Read-write Read-only N/A N/A N/A Read-only Read-only N/A N/A N/A Read-only Read-only The following table displays all the fields and more events: E_SWF_VERIFY E_SWF_VERIFY_CO MPLETE Read-only Read-only Read-only E_START_TRANSMI T N/A N/A N/A E_STOP_TRANSMIT F_APP_INST F_APP_NAME F_APP_URI Read-only Read-only Read-only N/A N/A N/A Last updated 8/30/2010 .

FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 172 E_SWF_VERIFY E_SWF_VERIFY_CO MPLETE Read-only E_START_TRANSMI T N/A E_STOP_TRANSMIT F_CLIENT_AMF_ENCODI NG F_CLIENT_AUDIO_CODE CS F_CLIENT_AUDIO_SAMP LE_ACCESS F_CLIENT_AUDIO_SAMP LE_ACCESS_LOCK F_CLIENT_CONNECT_TI ME F_CLIENT_DIFFSERV_B ITS F_CLIENT_DIFFSERV_M ASK F_CLIENT_FAR_ID F_CLIENT_FAR_NONCE F_CLIENT_FORWARDED_ FOR F_CLIENT_ID F_CLIENT_IP F_CLIENT_NEAR_ID F_CLIENT_NEAR_NONCE F_CLIENT_PAGE_URL F_CLIENT_PROTO F_CLIENT_PROTO_VER F_CLIENT_READ_ACCES S F_CLIENT_READ_ACCES S_LOCK F_CLIENT_REDIRECT_U RI F_CLIENT_REFERRER F_CLIENT_SECURE F_CLIENT_STATS_HAND LE F_CLIENT_SWFV_DEPTH F_CLIENT_SWFV_DIGES T F_CLIENT_SWFV_EXCEP TION Read-only N/A Read-only Read-only N/A N/A Read-only Read-only N/A N/A Read-only Read-only N/A N/A Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only N/A N/A Read-only Read-only N/A N/A Read-only Read-only N/A Read-only Read-only N/A N/A N/A N/A N/A N/A N/A Read-only Read/Write Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A Last updated 8/30/2010 .

0 DEVELOPER’S GUIDE Developing Plug-ins 173 E_SWF_VERIFY E_SWF_VERIFY_CO MPLETE N/A E_START_TRANSMI T N/A E_STOP_TRANSMIT F_CLIENT_SWFV_RESUL T F_CLIENT_SWFV_TTL F_CLIENT_SWFV_VERSI ON F_CLIENT_TYPE F_CLIENT_URI F_CLIENT_URI_STEM F_CLIENT_USER_AGENT F_CLIENT_USERDATA F_CLIENT_VHOST F_CLIENT_VIDEO_CODE CS F_CLIENT_VIDEO_SAMP LE_ACCESS F_CLIENT_VIDEO_SAMP LE_ACCESS_LOCK F_CLIENT_WRITE_ACCE SS F_CLIENT_WRITE_ACCE SS_LOCK F_MAXFIELD F_OLD_STREAM_NAME F_OLD_STREAM_QUERY F_OLD_STREAM_TYPE F_SEGMENT_END F_SEGMENT_START F_STREAM_CODEC F_STREAM_CODEC_TYPE F_STREAM_ID F_STREAM_IGNORE F_STREAM_LENGTH F_STREAM_LIVE_EVENT F_STREAM_LIVE_PUBLI SH_PENDING F_STREAM_NAME F_STREAM_OFFSET N/A N/A Read/Write Read-only Read-only Read-only N/A N/A N/A N/A Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only Read-only N/A N/A Read-only Read-only N/A N/A Read-only Read-only N/A N/A Read-only Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Last updated 8/30/2010 .FLASH MEDIA SERVER 4.

• Retrieve external SWF files for verification.FLASH MEDIA SERVER 4. You can configure or modify the sample file to create an alternative to the default operating-system-based file system I/O. Each request for a read operation on a file had to wait for the previous requests in the queue to be completed. You can code the File plug-in to do the following: • Grab files from a remote location over HTTP and serve them to clients through the core server process to off-load content management duties. Note: The File plug-in works with stream files and SWF files. • Remap files to a different physical location. The plug-in provides an interface between the operating system’s file I/O mechanism and the server. Last updated 8/30/2010 .0 DEVELOPER’S GUIDE Developing Plug-ins 174 E_SWF_VERIFY E_SWF_VERIFY_CO MPLETE Read-only N/A N/A N/A E_START_TRANSMI T N/A N/A N/A N/A E_STOP_TRANSMIT F_STREAM_PATH F_STREAM_PAUSE F_STREAM_PAUSE_TIME F_STREAM_PAUSE_TOGG LE F_STREAM_POSITION F_STREAM_PUBLISH_BR OADCAST F_STREAM_PUBLISH_TY PE F_STREAM_QUERY F_STREAM_RECORD_MAX DURATION F_STREAM_RECORD_MAX SIZE F_STREAM_RESET F_STREAM_SEEK_POSIT ION F_STREAM_TRANSITION F_STREAM_TRANSMIT_P OSITION F_STREAM_TYPE Read-only N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A Read-only N/A Read-only N/A N/A N/A N/A Developing a File plug-in File plug-in overview The File plug-in gives you control over where and how the server reads content from the file system. Previous versions of the server supported synchronous access to the file system. making it easier to implement network-based file I/O. The File plug-in supports asynchronous access.

Enable SWF verification in Application. To free resources associated with the request before the callback occurs. follow this workflow: • Enable SWF verification in Application. Note: The ability to retrieve SWF files using the File plug-in is only available in version 1. 2 Set the enabled attribute in the SWFVerification tag to true. then it is not necessary to call the server back. You can use the File plug-in to retrieve SWF files that are stored in external locations so that the server can verify them. the plug-in should not call the server back. 3 Leave the SWFFolder tag empty. Responding to server calls The File plug-in is asynchronous—when the server calls the plug-in. regardless of the application. The close() and remove() calls are an exception to this rule. When the server calls the close() and remove() functions on the plug-in.xml. applications/application_name/SWFs. the plug-in doesn’t respond immediately. Developers can update SWF files frequently without impacting the server. Last updated 8/30/2010 . If the context is NULL. If a call to the plug-in returns successfully (returns 0). the server verifies SWF files at the file level. In Content Distribution Networks.0 of the plug-in (Flash Media Server 3.xml 1 In an XML editor. and the plug-in calls the server back on the response interface.xml.FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 175 If a custom File plug-in is not present or is inactive. If the function returns an error. By using the File plug-in. open Application. When using the File plug-in. • Implement the File plug-in. For example. the plug-in should call the server back and pass the context received from the server. the plug-in interface can return an error code (-1) indicating that the operation failed. By doing so. <SWFVerification enabled="true"> This tag enables verification for all applications. • Enable SWF verification in Server. The server calls the plug-in. Your File plug-in must redirect this value to your external content repository. To verify SWF files through the File plug-in. regardless of whether this file is the vhost-level or application-level XML file. the server ignores it. When the server calls a function on the plug-in.5 or later). The default value is the application’s folder appended with SWFs. the server sometimes passes NULL as the pCtx pointer. You cannot enable SWF verification through the File plug-in on a per-application basis. Using the File plug-in facilitates and simplifies content management by developers. the server uses the standard operating system file system for backwards compatibility. You can only use one File plug-in. This feature prevents third parties from creating their own applications that attempt to stream your resources. the server passes the default SWFFolder value to the plug-in.xml. the server is not interested in the response. SWF files do not have to reside locally on Flash Media Server. Retrieving external SWF files for verification Verifying SWF files ensures that only legitimate applications can access this instance of Flash Media Server. the SWF files that you want to verify reside in an external content repository or on another server in a cluster. If the plug-in calls the server back with the NULL context.

See the File plug-in sample included with the server. open Server. After calling the open() function. Through the plug-in's close() method. Your File plug-in must redirect this value to your external content repository. Implement the File plug-in The File plug-in can open directories or files in external locations and pass a list of directories and files to the server. Directories are opened and written to a temporary file. MaxNumberofRequests. The server performs verification like it does when SWF files are stored on the server. 0 for a directory. The value of sFileName is passed to the File plug-in by the server. If the directory contains any subdirectories or SWF files. 2 In the Plugins tag. the server closes the file when fully read. The File plug-in does not contain a specific attribute to distinguish stream files from SWF files. The sample uses the new attribute FMSFileAttribute::kMode to determine if sFileName is a file or directory (1 for a stream. the sample includes code that determines if the value of sFileName is a file or a directory. 4 (optional) To configure global verification. the server opens the directory or file.xml. set the enabled attribute in the FilePlugin tag to true: <Plugins> <FilePlugin enabled="true"> <Content type="Streams">true</Content> <Content type="SWF">false</Content> </FilePlugin> </Plugins> 3 To enable verification of SWF files. the server passes the default SWFFolder value to the plug-in. Last updated 8/30/2010 . you can configure verification for a group of SWF files that are common to all applications.FLASH MEDIA SERVER 4.0 DEVELOPER’S GUIDE Developing Plug-ins 176 4 (optional) Configure additional verification tags. it is the default value of the SWFFolder tag in either Application. and any desired user-defined keys in the UserDefined element. The File plug-in sample file includes a function that calls IFmsFileAdaptor::open. 5 (optional) Configure additional verification settings: DirLevelSWFScan.xml 1 In an XML editor. With global verification. leave the SWFFolder tag empty. The sample creates a handle to that repository and passes it back to the server. By doing so.) The File plug-in returns a handle to this temporary file to the server. set the <Content type="SWF"> attribute to true. The open() function includes a parameter. Through the plug-in's read() method.xml or Server. See the XML reference in the Configuration and Administration Guide. Some highlights of the code are presented here. the server reads the file and performs verification. Enable SWF verification in Server. The plug-in redirects the SWFFolder value to the external content repository. Files are opened. and continues the process until all the subdirectories and files are read.xml. sFileName. The getAttributes() function also takes sFileName as a parameter.

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.