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

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

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

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

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

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

For example. 4 Copy the code from the TextArea at the bottom of the page. The file is located at rootinstall\samples\videoPlayer\videoplayer.html. change this: serverURL=rtmp:/vod/mp4:sample1_150kbps. 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. If you are using dynamic streaming. to point to a video called “mySampleVideo”. 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. 5 Paste this code into your HTML file. The code begins and ends with <object> tags. and other video assets. For more information about OSMF. change the value of the serverURL parameters to point to your FLV file. 3 Find the section on the page labelled “Embed Code”.html Otherwise.f4v To this: serverURL=rtmp:/vod/myvideos/mp4:mySampleVideo. It adds the URL of the video file to the code. This updates the code that you will be copying. To serve a different video. For more information. 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.org.f4v 6 Place the HTML page in the rootinstall/webroot folder.osmf. 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.FLASH MEDIA SERVER 4. see Building streaming video players in Flash with the Adobe Open Source Media Framework. be sure to also add an appropriate SMIL file. you can browse to the file in your Flash Media Server installation and open it in a browser. 7 Deploy your video file to the specified location. 8 Open your HTML file in a browser. 2 Select a video to play. Note that the serverURL parameter appears twice in the code block. see www. If you are running the Flash Media Server web server. or in a location recognized by your Flash Media Server web server.

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

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

Use the Administration Console to restart the application. you can observe its live log. When a client connects to an application on the server.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.FLASH MEDIA SERVER 4. Last updated 8/30/2010 . then connect to the application again. Test and debug a server-side script To test a server-side script. View the output of trace() statements in the Live Log in the Administration Console. clients. You can also stop an application or reload it—in either case. choose Start > All Programs > Adobe > Flash Media Server 3.5 > Flash Media Administration Console. if any. and so forth.asc file. use trace() statements to monitor each processing point. select from the New Instance list of available application names. streams in use. To open the Administration Console. use the Debug menu in Flash to set breakpoints. shared objects. the changes do not take effect until the application is restarted. all clients are disconnected. For each application instance. use trace() statements to monitor each processing point. You can inspect the state of the script with Windows > Debug Panels. Note: When you edit and save an . step into functions. and performance statistics. the application is loaded and can be seen in the Administration Console. To load an application directly from the Administration Console. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SegmentDuration. The frame-based option overrides the time-based option. If you don't provide values for either.pfx</PackagerCredentialFile> <PackagerCredentialPassword>hbXX5omIhzI=</PackagerCredentialPassword> <PolicyFile>policy01. The following Event. If you don't provide a KeyframeIntervalsPerFragment element.corp.bin</CommonKeyFile> <LicenseServerURL>http://dill.com:8090</LicenseServerURL> <TransportCertFile>production_transport. the Live Packager uses the default FragmentDuration.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. which is 4 seconds. the Live Packager uses the FragmentDuration element.xml file: Last updated 8/30/2010 .adobe.pol</PolicyFile> </FlashAccessV2> </ContentProtection> </Recording> </Event> The following table lists all the possible elements of an Event.der</TransportCertFile> <LicenseServerCertFile>license_server.FLASH MEDIA SERVER 4. Use the time-based option for media that contains audio or data but not video.0 DEVELOPER’S GUIDE Streaming services 34 <Event> <EventID>liveevent</EventID> <Recording> <FrameRate>29.der</LicenseServerCertFile> <PackagerCredentialFile>production_packager. The frame-based option lets you carefully match the fragment size to the video's keyframe interval. To package the content for protection with Flash Access: Use the ContentProtection element and its subelements. 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.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.

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

Ifneither endOffset nor beginOffset is set. Attributes Description When the HTTP Origin Module parses the previous sample Manifest.f4m manifest file: Last updated 8/30/2010 . To play a stream. If neither endOffset nor beginOffset is set. the start time is the beginning of the content.com/f4m/1. from the beginning of the recorded stream. Clients can begin viewing the stream at this location. include the <dvrInfo> in the Manifest. endOffset An offset. remove the <dvrInfo> tag. in seconds. behind the current duration of the recorded stream. The name of the publishing stream. Negative values are treated as 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.xml file to the live event folder. The following Manifest. Clients cannot view the stream behind this location. The default value is 0. Negative values are treated as 0. The bitrate at which the stream was encoded. The HTTP Origin Module uses the Manfest.xml file.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. To use multi-bitrate streaming without DVR.xml file and remove the <media> tags. media streamId bitrate Represents one stream.f4m) from OSMF Sample Player. in seconds. it generates the following . request the manifest file (. The default value is 0.adobe.xml file to generate a manifest file (. Copy the Manifest.f4m).FLASH MEDIA SERVER 4.

/../././streams/Apps/live/streams/definst/test3/test3" bootstrapInfoId="bootstrap7538"> <metadata> AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgAAAAAAAAAAAAAFd2lkdGgAAAAAAAAAAAAABmhlaWdodAAAAAAAAAAA Last updated 8/30/2010 ././...FLASH MEDIA SERVER 4./.com/f4m/1...0" encoding="UTF-8" ?> <manifest xmlns="http://ns.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="../.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/test2/test2" bootstrapInfoId="bootstrap7537"> <metadata> AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgAAAAAAAAAAAAAFd2lkdGgAAAAAAAAAAAAABmhlaWdodAAAAAAAAAAA AAAMdmlkZW9jb2RlY2lkAgAESDI2MwAMYXVkaW9jb2RlY2lkAgAEbm1vcwAOdmlkZW9mcmFtZXJhdGUA//gAAAAAAAAA D2F1ZGlvc2FtcGxlcmF0ZQBAs4gAAAAAAAANYXVkaW9jaGFubmVscwA/8[AAAAAAAAAAJdHJhY2tpbmZvCgAAAAMDAAZ sZW5ndGgAAAAAAAAAAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAAAAAAAA AAAAACXRpbWVzY2FsZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAAAAAAAAAAAAACXRpbWVzY2F sZQBAj0AAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkAAAk]= </metadata> </media> <media streamId="test3" bitrate="3000" url=".....adobe...././././.../.

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

drmmeta are found in the same location as the .f4f file.com/f4m/1. In this example. “myStream” and “myStream1”.FLASH MEDIA SERVER 4.bootstrap and .adobe. The <media> elements provide the absolute URL path to the content location with the prefix “/live/streams”.drmmeta file through the drmAdditionalHeaderId attribute.0 DEVELOPER’S GUIDE Streaming services 39 <?xml version="1. Last updated 8/30/2010 .bootstrap" id="bootstrap2267" /> <drmAdditionalHeader url="/live/streams/myStream. there are two streams associated with the live event. therefore there is only one <drmAdditionalHeader> element in the sample manifest file.drmmeta file can be shared across multiple streams.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. If . The .0" encoding="UTF-8" ?> <manifest xmlns="http://ns.0"> <id>live_mbr_event</id> <streamType>live</streamType> <duration>0</duration> <bootstrapInfo profile="named" url="/live/streams/myStream. <bootstrap> and <drmAdditionalHeader> elements are included in the manifest file.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. Both myStream and myStream1 refer to the same .

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

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

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

Single stream of data C. and data). A NetConnection object is like a pipe that streams audio. Flash Media Server B. a stream flows in only one direction. A B C D Many streams can use one NetConnection object between client and server. a connection is available to both the client and the server. Live applications capture. video. To connect.connect("rtmp://localhost/HelloServer"). video. you can attach one or more streams to it. 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 . it must connect to the server. education. The server sends back a NetStatusEvent that tells the client whether it has connected successfully. nc. from server to client or client to server. The server sends information messages back to the client. Pass an application instance URI to the connect() method: var nc:NetConnection = new NetConnection(). and data from client to server. Live video is typically used for events such as corporate meetings. Adobe AIR. and concerts. and stream live media. A stream can carry more than one type of content (audio. and data over a network connection. Connecting to the server About the NetConnection class Before a client can play or publish audio and video. video.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. NetConnection D. or from server to client. Streams handle the flow of audio. Flash Player. Once you create the NetConnection object. Once the application accepts the connection request. create an instance of the NetConnection class and call the connect() method. However. encode. or VOD (video on demand). The NetConnection class connects a client to an application instance on the server. sports events. A. The connection request is accepted or rejected by an application instance on the server. Recorded video is called on-demand.

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

and click OK. 1 In Flash Professional. and enter the instance name connectBtn. However.as and edit this line to add the URL to your server: nc. Choose File > Publish Settings. 7 Give the second button the instance name closeBtn and the label Close. open HelloServer.as. Enter Connect as the button label. 2 Choose Window > Components to open the Components panel. 3 Return to the FLA file. 3 Double-click the Button component to add it to the Stage. Last updated 8/30/2010 . choose File > New > Flash File (ActionScript 3. choose File > New > ActionScript File. 4 In the Properties Inspector.fla. these instructions show you how to recreate it.connect("rtmp://localhost/HelloServer"). Design the Flash user interface The sample is already built and included in the samples folder. 5 Click the Parameters tab.FLASH MEDIA SERVER 4. then Label.0). 8 Save the FLA file. naming it HelloServer. Select MovieClip as the instance behavior. 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. Click the Flash tab.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. click the Properties tab. 6 Drag a second button component to the Stage. then Settings. and click OK. Write the client-side code 1 In Flash Professional. so that you can build it on your own and add to it. 2 Save the ActionScript file as HelloServer.

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

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

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

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

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

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

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

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

which displays metadata in the console window.net.as in Flash Builder. choose MediaPlayer. 2 Create a new class.FLASH MEDIA SERVER 4. } flash. MediaPlayer. flash. The call to NetStream. The video runs in an application window.NetStream. NetStream. Click the Flash Builder window to see the output messages. choose MediaPlayer.Sprite. like this: metadata: duration=30 width=292 height=292 framerate=30 Run the example in Flash Builder 1 Open MediaPlayer.. and declare the variables you’ll need within it: Last updated 8/30/2010 . 3 Click Debug. Write the main client class 1 Create an ActionScript 3.0 class..play() triggers the call to onMetaData. flash. flash. Import NetConnection.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.NetConnection. For Application file.NetStatusEvent.Video.events. and any other classes you need: package { import import import import import .display.net. For Project. 2 Choose Run > Debug.media.as. flash.

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

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

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

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

Too many tag boxes. Warning Message. Invalid box version. Time. Failed read in segment file %s. Index File Version %x Not Supported.. Segment file %s does not match index file. warnings are informative and are not fatal errors. Warnings are logged to the stdout file in the following format: Date. Unsupported DRM scheme. Found incomplete track. FMS Requires Version %x. Warning number -100 -101 -102 -103 -104 Warning type General FLV MP4 MP4 MP4 Message Metadata duration is missing or is incorrect. Max is 64. Ignoring. Error reading MP4 tables. File missing or corrupted. and File Name. File contains out-of-order movie fragments. The file may have been truncated.FLASH MEDIA SERVER 4. File contains unexpected movie fragments. or the reported box length may be invalid. Truncated message in segment file %s. File appears to be FLV with wrong extension. Truncated box. Invalid message footer in segment file %s. canSeekToEnd is false. Index or Contexts file missing or corrupted. Invalid sample size. Invalid movie time scale. Found duplicate video track. Last updated 8/30/2010 . -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. Warning Number. Unrecognized message type in segment file %s.. but you may experience problems with playback. Flash Media Server will ignore the error that caused the warning and continue to load and play back the video or audio file.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. Invalid chapter time. Duplicate box. Box is too large. Unrecognized box. The reported length of a box is longer than the remaining length of the file. Invalid number of data entries in box.

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

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

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

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

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

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

within 3-5 milliseconds.0 NetStream.FLASH MEDIA SERVER 4. the client buffer (the value of NetStream.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. It also lets your application adapt to clients with different capabilities.offset property to perform fast switching between streams. Transitions occur at the nearest keyframe in the target timeline. This feature lets your media application adapt to changing network conditions.0. Transitions occur at the nearest possible sample. after initial playback. depending on the type of content that is being streamed: • Video-only streams. the server can switch back to HD video.info property and NetStreamInfo class to monitor download and playback statistics. Using ActionScript to switch streams Stream transitions occur on the server. 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. If network conditions improve. Content Stream User Bandwidth 1. Last updated 8/30/2010 . The streams must have timestamps that are synchronized closely enough. For example. so that the server can select accurate transition points. • Audio or other data in each content stream is synchronized with the video data in that stream. • Video and audio streams. Transitions occur at the audio sample that immediately precedes the nearest keyframe in the timeline of the target stream. Use the NetStreamPlayOptions. • Audio-only streams. (Similar APIs are also available in ActionScript 2. Developers can use the ActionScript 3.) 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. The audio timelines of the initial and target streams must match. such as mobile devices with lower processing power and smaller screens. dynamic streaming requires the following: • The different versions or pieces of content are synchronized: the video timelines must match. The server implements a transition between two pieces of recorded content in three possible ways. Implementing transitions between live video content is slightly more complicated.bufferTime) is set to at least the default value of 10 seconds or more. Ensure that. suppose the server is streaming high-definition video to a client application but encounters poor network conditions. Although network conditions have changed.play2() method and the associated NetStreamPlayOptions class offer the ability to change to different streams in mid-play. The server can switch to a standard-definition stream at a lower bit rate.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. The transitions occur seamlessly in the client. a 2-second buffer cannot accommodate a 3second transition delay. the video streaming to the client is uninterrupted. The NetStream. For example. The application developer includes logic to monitor download and playback statistics and to switch from the old stream to the new stream when appropriate. or an audio artifact results. but the command to switch streams and the determination to do so comes from the client application.

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

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

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

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

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

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

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. Recognizing transitions in log files You can track stream events through access logs. use the ActionScript 3.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. stream transitions occur in play/stop pairs.0 NetStream.duration + " width=" + info. } public function onPlayStatus(info:Object):void { switch (info.framerate). 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.Complete": trace("The stream has completed"). Use the logs to differentiate a single stream play with transitions from multiple plays of a stream or different streams. 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. For an example of reconnecting streams.0 DEVELOPER’S GUIDE Developing streaming media applications 73 public function onMetaData(info:Object):void { trace("Metadata: duration=" + info. break.attach() method to attach the same NetStream object to a reconnected NetConnection object. ensure that it looks at both the status codes and the x-sid values. You can also use this feature for load balancing. Flash Player 10.height + " framerate=" + info.code) { case "NetStream.Play. To provide seamless playback. The server logs a stop event for the original stream and a play event for the new stream.3. Last updated 8/30/2010 .play(). When a transition for a single content stream occurs.FLASH MEDIA SERVER 4. the log processor can also differentiate a stream transition from a play or stop event without a transition. Normal stop and play events (that is. Stream transitions have a status code of 210. By looking at the status code. see the Stream Reconnect and Smart Seek example hosted by Adobe. As with normal streams. a stop or play without a transition) have a status code of 200.width + " height=" + info. the server tracks the status of the stream as a transition. Look at both values to recognize that a transition occurred on a single logical stream. } } These event handlers are needed when you call NetStream.5. Reconnecting streams when a connection drops Flash Media Server 3.

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

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

} lastByteCount = netstream. Read and write.Success: netStream.bufferLength < netstream. reconnect to a new NetConnection netconnection2 = new NetConnection().Closed" event may arrive late or may never arrive.bufferLength and NetStreamInfo. netStreamMonitorTimer.info.bufferTime && netstream..TIMER.byteCount properties in a timer to discover network issues.start().byteCount is not increasing.bufferTime. netStreamMonitorTimer.Connect. } Monitoring an RTMPS or RTMPT connection For RTMPS and RTMPT connections. timerHandler). ///on NetConnection. 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.Connect. In this case..bufferLength < netstream.byteCount. and NetStreamInfo. There is one new property: F_STREAM_OFFSET.bufferLength is less than NetStream.5.attach(netconnection2). the "NetConnection. ///on NetConnection.addEventListener(TimerEvent.byteCount == lastByteCount) { // Network has issues. The F_STREAM_OFFSET property indicates where to resume streaming after a reconnection. monitor the NetStream.addEventListener(TimerEvent.TIMER. timerHandler).byteCount.byteCount properties in a timer to discover network issues.FLASH MEDIA SERVER 4. When NetStream. in seconds. you can monitor the NetStream. In this case.Closed" message.info. netStreamMonitorTimer.byteCount is not increasing. Last updated 8/30/2010 .bufferLength and NetStreamInfo.3 3. and NetStreamInfo. lastByteCount = 0. private function timerHandler(e:TimerEvent):void{ if(netstream.Success: netStream. there are probably network issues. 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.info. netStreamMonitorTimer.attach().byteCount == lastByteCount) { // Network has issues. lastByteCount = 0.bufferTime.start(). private function timerHandler(e:TimerEvent):void{ if(netstream. there are probably network issues.attach(netconnection2). } lastByteCount = netstream. when you call NetStream.Connect. } Authorization plug-in events and properties Use the E_PLAY event of the Authorization plug-in to control streaming that occurs after a reconnection.bufferTime && netstream.Connect.5 Read-only. When NetStream.info.bufferLength is less than NetStream.

at which the streams switch. The server does not wait to find a keyframe. The offset is the time. any data buffered from a previous stream is flushed. When you specify the offset property.0. the server starts streaming the new stream from the specified index position. • The offset value is greater than the buffer (offset > NetStream. You can optionally display these fields in the authEvent. Data from the old stream can build up in Flash Player. 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. Fast switching between streams Flash Media Server 4. and users can experience a delay before the new stream starts playing. which is the standard switching mode. 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.1 About fast switching Use the NetStreamPlayOptions.log and in the access. The default value of offset is -1.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.offset property to tell the server when to switch between streams of different bitrates. A stream has resumed playing. when the server receives a SWITCH command.FLASH MEDIA SERVER 4. The offset value indicates where to resume streaming after you attach a NetStream. The values for Stream Reconnect are “resume” and “appendAndWait”. the transition modes are “resume” and “appendAndWait”.time + NetStream. A stream has stopped playing. x-soffset These fields are disabled by default. In this mode.play2() call. Last updated 8/30/2010 . 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.bufferLength). 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.log. Flash Player 10. in seconds. Also. For Stream Reconnect.play2() call.time).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

192. and so on) from an upstream server. In a recorded stream. The default value is 32. These streams log the same events in the log files as every recorded stream. a special data message is inserted at the beginning of the media file that provides metadata. content. you do not need to use data keyframes to push metadata to the client. point each virtual host to its own cache directory. 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. The value -1 specifies no maximum value.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.f4v\0000000000000000 during write: 28 No space left on device.. The maximum size of the disk in gigabytes. 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. The maximum amount of time to wait for a response to a request (for metadata. even if they connect late. it logs the following warning message in the core. duration of the video. Last updated 8/30/2010 . You can also use this feature to add metadata to a live stream at any time during a broadcast. such as title. Note: Because DVR applications use recorded streams. or creation date. in seconds. copyright information. The value 0 disables the disk cache. Metadata can contain information about the video.125\C\Program Files\Adobe\Flash Media Server 3. they miss receiving the data keyframe. Logging Streams played in a DVR video player are played as recorded streams. The default value is 2 seconds.xx. VirtualHost/Proxy/RequestTimeout If a server has multiple virtual hosts.16. Any client connecting to the server.5\cache\streams\00\proxyapp\10. If the server runs out of disk space on an intermediate or edge server while writing to the CacheDir.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. A client can use the metadata to set the width and height of the video player.5_361\applications\primaryapp\streams\_definst_\sample1_1500kbps. You can write code that tells Flash Media Server to send metadata to clients whenever they connect to a live stream.FLASH MEDIA SERVER 4. Any client that connects to Flash Media Server receives the metadata when it plays the recorded stream. when a client connects to a live stream during the broadcast. receives the metadata when it plays the live video. However.

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

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

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

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

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

publish("myCamera". as in the following: ns. Values are: 2 Sorenson H. Flash Media Server adds the metadata listed in the following table.264 audiodelay Number The delay introduced by the audio codec. Last updated 8/30/2010 . To record a file as you publish it to the server. false if no). The audio codec ID used in the file. Metadata properties for recorded live streams If you record the file as you stream it. The creation date of the file.FLASH MEDIA SERVER 4. The name of the file creator. use the "record" parameter. The frames per second at which the video was recorded.263 3 Screen video 4 On2 VP6 5 On2 VP6 with transparency 7 H. The audio bit rate. in seconds.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. "record"). The creator of the file. Metadata property name audiocodecid Data type Number Description The audio codec ID used in the file. 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. 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.

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

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

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

Last updated 8/30/2010 . Segment file %s does not match index file.onPublish() event with the name of the published stream. even with servers or subscribers in different geographic locations. Live Video B. 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.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. Truncated message in segment file %s. Failed read in segment file %s.publish() to republish the live stream to Server 2 (Chicago) and Server 3 (Los Angeles). A B C D Using multipoint publishing to publish content from server to server. Index File Version %x Not Supported. FMS Requires Version %x.FLASH MEDIA SERVER 4.onPublish() handler creates a NetStream object and calls NetStream. 3 The application.publish() to publish a live stream. File missing or corrupted. 2 The server-side script on Server 1 receives an application. Unrecognized message type in segment file %s. Server 1 (New York City) C. This client can be a custom Flash Player or AIR application or Flash Media Live Encoder. Server 2 (Chicago) and Server 3 (Los Angeles) D. -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. Missing FLV metadata. even across geographic boundaries A. Invalid message footer 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. This feature enables you to build large-scale live broadcasting applications.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Last updated 8/30/2010 . 4 Flash Media Server verifies the token with the third party system. 3 The client sends the token with its connection request.FLASH MEDIA SERVER 4. 2 The third party returns the token to the client.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.

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

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

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

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

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

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

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

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

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. for example. <Client> ..... which lets you set permissions for individual files. </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.Controls libconnect. c:\myvideos\.FLASH MEDIA SERVER 4..play("myvideos/foo")— when the request is processed by the server. If the FolderAccess element is set to true. ... if the video player plays a stream “foo” —ns. you can only set permissions at the folder level.dll access configurations --> <Application> .. see “Access plug-in overview” on page 144. you cannot use the readAccess and writeAccess fields in the Access plug-in to set permissions for individual files. 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. <Access> <FolderAccess>false</FolderAccess> </Access> . The default value is false. The Authorization plug-in lets you remap this to a different physical location. this virtual name could map to c:\apps\vidapp\myvideos\.0 DEVELOPER’S GUIDE Developing Plug-ins 147 Configuring folder permissions on the server The Access section of the Application. For more information. • 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. as in the following: <!-. • 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 .

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

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

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

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

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

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

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

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

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

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

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

FLASH MEDIA SERVER 4.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.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 .

FLASH MEDIA SERVER 4.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 .

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.

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 .

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.

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.

• Remap files to a different physical location. Note: The File plug-in works with stream files and SWF files. The File plug-in supports asynchronous access. 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. • Retrieve external SWF files for verification. You can configure or modify the sample file to create an alternative to the default operating-system-based file system I/O. The plug-in provides an interface between the operating system’s file I/O mechanism and the server. Previous versions of the server supported synchronous access to the file system.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.FLASH MEDIA SERVER 4. Each request for a read operation on a file had to wait for the previous requests in the queue to be completed. making it easier to implement network-based file I/O. Last updated 8/30/2010 .

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

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

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer: Get 4 months of Scribd and The New York Times for just $1.87 per week!

Master Your Semester with a Special Offer from Scribd & The New York Times