Preview only show first 10 pages with watermark. For full document please download

1827os_04_1stdraft

OS

   EMBED


Share

Transcript

  4  Audio and Video in Depth It could certainly be said that streaming media makes up the majority of what goes on, on the Internet. From your favorite video portal to internet radio, the things we watch or listen to are almost all streamed using a media server of some sort. Although many of these providers use a commercial product like FMS or Apples !arwin streaming server, a few of them stream with ed#. As an aside, the ed# development team is aware that Facebook and $ahoo labs have used ed# and may have it deployed in their datacenters.In this chapter we will cover% ã Managing streams ã Stream listeners ã Supported codecs ã Supported file types ã &ypassing firewalls Managing streams 'he act of managing streams on a media server means to publish, play, pause, stop, and delete in most cases. Since ed# is completely open to whatever we can create, management of our streams may take on a multitude of variations based on these concepts. Stream management is handled via different classes depending upon where the management function is performed. (n the client)side when using Flash, management of streams is handled in ActionScript via the *etStream class. 'he *etStream class is very well documented across the Internet and in Adobe literature, so herein we will only cover the features applicable to ed# streaming. ed# provides several classes for stream management on the server)side, two very important classes are the +lient&roadcastStream and laylistSubscriberStream both of which descend from the IStream interface.  'he diagram above shows the relationship with the IStream interface for publishers. As a  point for reference, most classes with an -I prefi/ will consist of an interface in the ed# codebase.'his diagram shows the relationship with the IStream interface for subscribers. What's in a name? A stream name is used as a locator for data either currently being streamed or which will  be streamed at a future time. !ata streaming in this instance means any digital information, whether it be audio, video, te/t, images, or anything else which can be encoded into bytes and sent over the network. Stream names must be uni0ue per scope, we cannot have two streams with the name of -mystream for instance. 'he name selected for our live stream can pretty much be anything which has a string representation and may be a valid file name on the servers operating system. 'his essentially means 2  letters, numbers, and a small set of punctuation characters1 the underscore -2 and dash -) are usually safe in terms of cross)platform support. For prerecorded streams which are often referred to as video on demand 34(!5, the stream name would be the name used for the recorded file 3i.e. mystream.flv5. *aming collisions may be prevented in several ways, such as 0uerying the application for the current list of stream names, by adding a time value suffi/, or using a sever controlled se0uence number. 'o return a list of stream names for a given scope name, we can utili6e this method. public ArrayCollection<String> getScopeStreamList(String scopeName) {ArrayCollection<String> streams = new ArrayCollection<String>();IScope target = null;i (scopeName == null) {target = !e #$getConnectionLocal()$getScope();scopeName = target$getName();% else {target = Scope&tils$resol'eScope(scope scopeName);%List<String> streamNames = getroa castStreamNames(target);or (String name * streamNames) {streams$a (name);%return streams;% 'he method returns a collection of all the stream names for a scope and it also contains a little bit of error prevention as well. 'he getScopeStream7ist method would be best  placed within our scope handler or application adapter class. +lient)side ActionScript used to re0uest the stream list may look like this% nc$call(+getScopeStreamList+ new !espon er(onStreamList) +streams+); 'his *et+onnection call uses a esponder to handle the callback from the server which will contain the list of streams currently broadcasting live in the -streams scope. 'he client handler method may be implemented as shown below. public unction onStreamList(list*ArrayCollection)*'oi {trace(+Streams* + , list$lengt-);i (list$lengt- > .) { 3  'ar stream*String = list$remo'eItemAt(.) as String;trace(+/etting + , stream , + rom list+);%% 8hen working with streams in ed#, it is important to remember that some methods do not return what we might e/pect. 'he +lient&roadcastStream class is the default stream implementation and it e/poses two methods for working with stream names.9.getublished*ame : eturns what would normally be e/pected as the stream name, a name such as -live or -mystream.;.get*ame : 'his method on the other hand, returns an internal name which resembles an identifier more than it would a regular stream name. An e/ample return from this method looks like this% 9#ccb<f;);a=>)?@>a)a=;a)ff?>@fba<#. Publishing in detail ublishing, is the act of sending our content to a server for subscribers to consume or to record to a file. (f course by content we mean pretty much anything that can be converted into bytes using codecs, as covered later on in this +hapter. ed# supports several different types of publishing by default% ã 7ive : Analogous to e/periencing something in real)time, this stream is not  pre)recorded. An e/ample of live stream would be a video teleconference  between to office locations or a video phone call. ã 4ideo on demand : Similar to watching a television show or movie from a !4!. 'his media occurred in the past and is stored in a compatible digital format which may be played back upon re0uest. 4(! content may be fast forwarded, rewound, or played from any available position in the file. ã laylist ) A list of streams or video files that have been grouped together as one stream. 'he ne/t item in the group is played after the previous one is complete. 'his may be set to repeat without client input. Publishing a live stream 7ive stream publishing is a very important capability for a media server to support. 'his feature allows us to broadcast anything in near real)time to as many viewers as we can support with our installation. Since Flash layer version @, it has been incredibly simple to publish content. Following these five steps gives us the ability to stream to the world. 9.Simply select our audio and video sources 4