mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 09:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,64 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
public class DynamicStreamingItem
|
||||
{
|
||||
|
||||
private var _bitrate:Number;
|
||||
|
||||
private var _stream:String;
|
||||
|
||||
private var _width:int;
|
||||
|
||||
private var _height:int;
|
||||
|
||||
public function DynamicStreamingItem(param1:String, param2:Number, param3:int = -1, param4:int = -1)
|
||||
{
|
||||
super();
|
||||
this._stream = param1;
|
||||
this._bitrate = param2;
|
||||
this._width = param3;
|
||||
this._height = param4;
|
||||
}
|
||||
|
||||
public function get streamName() : String
|
||||
{
|
||||
return this._stream;
|
||||
}
|
||||
|
||||
public function set streamName(param1:String) : void
|
||||
{
|
||||
this._stream = param1;
|
||||
}
|
||||
|
||||
public function get bitrate() : Number
|
||||
{
|
||||
return this._bitrate;
|
||||
}
|
||||
|
||||
public function set bitrate(param1:Number) : void
|
||||
{
|
||||
this._bitrate = param1;
|
||||
}
|
||||
|
||||
public function get width() : int
|
||||
{
|
||||
return this._width;
|
||||
}
|
||||
|
||||
public function set width(param1:int) : void
|
||||
{
|
||||
this._width = param1;
|
||||
}
|
||||
|
||||
public function get height() : int
|
||||
{
|
||||
return this._height;
|
||||
}
|
||||
|
||||
public function set height(param1:int) : void
|
||||
{
|
||||
this._height = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class DynamicStreamingResource extends StreamingURLResource
|
||||
{
|
||||
|
||||
private var _streamItems:Vector.<DynamicStreamingItem>;
|
||||
|
||||
private var _initialIndex:int;
|
||||
|
||||
public function DynamicStreamingResource(param1:String, param2:String = null)
|
||||
{
|
||||
super(param1,param2);
|
||||
this._initialIndex = 0;
|
||||
}
|
||||
|
||||
public function get host() : String
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
public function get streamItems() : Vector.<DynamicStreamingItem>
|
||||
{
|
||||
if(this._streamItems == null)
|
||||
{
|
||||
this._streamItems = new Vector.<DynamicStreamingItem>();
|
||||
}
|
||||
return this._streamItems;
|
||||
}
|
||||
|
||||
public function set streamItems(param1:Vector.<DynamicStreamingItem>) : void
|
||||
{
|
||||
this._streamItems = param1;
|
||||
if(param1 != null)
|
||||
{
|
||||
param1.sort(this.compareStreamItems);
|
||||
}
|
||||
}
|
||||
|
||||
public function get initialIndex() : int
|
||||
{
|
||||
return this._initialIndex;
|
||||
}
|
||||
|
||||
public function set initialIndex(param1:int) : void
|
||||
{
|
||||
if(this._streamItems == null || param1 >= this._streamItems.length)
|
||||
{
|
||||
throw new RangeError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
this._initialIndex = param1;
|
||||
}
|
||||
|
||||
internal function indexFromName(param1:String) : int
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < this._streamItems.length)
|
||||
{
|
||||
if(this._streamItems[_loc2_].streamName.indexOf(param1) == 0 || this._streamItems[_loc2_].streamName.indexOf("mp4:" + param1) == 0)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private function compareStreamItems(param1:DynamicStreamingItem, param2:DynamicStreamingItem) : Number
|
||||
{
|
||||
var _loc3_:Number = -1;
|
||||
if(param1.bitrate == param2.bitrate)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
}
|
||||
else if(param1.bitrate > param2.bitrate)
|
||||
{
|
||||
_loc3_ = 1;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
internal class FMSHost
|
||||
{
|
||||
|
||||
private var _host:String;
|
||||
|
||||
private var _port:String;
|
||||
|
||||
public function FMSHost(param1:String, param2:String = "1935")
|
||||
{
|
||||
super();
|
||||
this._host = param1;
|
||||
this._port = param2;
|
||||
}
|
||||
|
||||
public function get host() : String
|
||||
{
|
||||
return this._host;
|
||||
}
|
||||
|
||||
public function set host(param1:String) : void
|
||||
{
|
||||
this._host = param1;
|
||||
}
|
||||
|
||||
public function get port() : String
|
||||
{
|
||||
return this._port;
|
||||
}
|
||||
|
||||
public function set port(param1:String) : void
|
||||
{
|
||||
this._port = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import org.osmf.utils.URL;
|
||||
|
||||
public class FMSURL extends URL
|
||||
{
|
||||
|
||||
private static const APPNAME_START_INDEX:uint = 0;
|
||||
|
||||
private static const INSTANCENAME_START_INDEX:uint = 2;
|
||||
|
||||
private static const STREAMNAME_START_INDEX:uint = 4;
|
||||
|
||||
private static const DEFAULT_INSTANCE_NAME:String = "_definst_";
|
||||
|
||||
public static const MP4_STREAM:String = "mp4";
|
||||
|
||||
public static const MP3_STREAM:String = "mp3";
|
||||
|
||||
public static const ID3_STREAM:String = "id3";
|
||||
|
||||
public static const QUERY_STRING_STREAM:String = "streamName";
|
||||
|
||||
public static const QUERY_STRING_STREAMTYPE:String = "streamType";
|
||||
|
||||
private var _useInstance:Boolean;
|
||||
|
||||
private var _appName:String;
|
||||
|
||||
private var _instanceName:String;
|
||||
|
||||
private var _streamName:String;
|
||||
|
||||
private var _fileFormat:String;
|
||||
|
||||
private var _origins:Vector.<FMSHost>;
|
||||
|
||||
private var _edges:Vector.<FMSHost>;
|
||||
|
||||
public function FMSURL(param1:String, param2:Boolean = false)
|
||||
{
|
||||
super(param1);
|
||||
this._useInstance = param2;
|
||||
this._appName = "";
|
||||
this._instanceName = "";
|
||||
this._streamName = "";
|
||||
this._fileFormat = "";
|
||||
this.parsePath();
|
||||
this.parseQuery();
|
||||
}
|
||||
|
||||
public function get useInstance() : Boolean
|
||||
{
|
||||
return this._useInstance;
|
||||
}
|
||||
|
||||
public function get appName() : String
|
||||
{
|
||||
return this._appName;
|
||||
}
|
||||
|
||||
public function get instanceName() : String
|
||||
{
|
||||
return this._instanceName;
|
||||
}
|
||||
|
||||
public function get streamName() : String
|
||||
{
|
||||
return this._streamName;
|
||||
}
|
||||
|
||||
public function get fileFormat() : String
|
||||
{
|
||||
return this._fileFormat;
|
||||
}
|
||||
|
||||
public function get edges() : Vector.<FMSHost>
|
||||
{
|
||||
return this._edges;
|
||||
}
|
||||
|
||||
public function get origins() : Vector.<FMSHost>
|
||||
{
|
||||
return this._origins;
|
||||
}
|
||||
|
||||
private function parsePath() : void
|
||||
{
|
||||
var _loc7_:RegExp = null;
|
||||
var _loc8_:uint = 0;
|
||||
var _loc9_:int = 0;
|
||||
if(path == null || path.length == 0)
|
||||
{
|
||||
this._streamName = getParamValue(QUERY_STRING_STREAM);
|
||||
this._fileFormat = getParamValue(QUERY_STRING_STREAMTYPE);
|
||||
return;
|
||||
}
|
||||
var _loc1_:RegExp = /(\/)/;
|
||||
var _loc2_:Array = path.split(_loc1_);
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
this._appName = _loc2_[APPNAME_START_INDEX];
|
||||
this._instanceName = "";
|
||||
this._streamName = "";
|
||||
_loc7_ = new RegExp("^.*/" + DEFAULT_INSTANCE_NAME,"i");
|
||||
if(path.search(_loc7_) > -1)
|
||||
{
|
||||
this._useInstance = true;
|
||||
}
|
||||
_loc8_ = STREAMNAME_START_INDEX;
|
||||
if(this._useInstance)
|
||||
{
|
||||
this._instanceName = _loc2_[INSTANCENAME_START_INDEX];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = INSTANCENAME_START_INDEX;
|
||||
}
|
||||
_loc9_ = int(_loc8_);
|
||||
while(_loc9_ < _loc2_.length)
|
||||
{
|
||||
this._streamName += _loc2_[_loc9_];
|
||||
_loc9_++;
|
||||
}
|
||||
if(this._streamName == null || this._streamName == "")
|
||||
{
|
||||
this._streamName = getParamValue(QUERY_STRING_STREAM);
|
||||
}
|
||||
if(this._streamName.search(/^mp4:/i) > -1)
|
||||
{
|
||||
this._fileFormat = MP4_STREAM;
|
||||
}
|
||||
else if(this._streamName.search(/^mp3:/i) > -1)
|
||||
{
|
||||
this._fileFormat = MP3_STREAM;
|
||||
}
|
||||
else if(this._streamName.search(/^id3:/i) > -1)
|
||||
{
|
||||
this._fileFormat = ID3_STREAM;
|
||||
}
|
||||
if(this._fileFormat == null || this._fileFormat == "")
|
||||
{
|
||||
this._fileFormat = getParamValue(QUERY_STRING_STREAMTYPE);
|
||||
}
|
||||
}
|
||||
var _loc3_:int = this._streamName.indexOf("/mp4:");
|
||||
var _loc4_:int = this._streamName.indexOf("/mp3:");
|
||||
var _loc5_:int = this._streamName.indexOf("/id3:");
|
||||
var _loc6_:int = -1;
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
_loc6_ = _loc3_;
|
||||
}
|
||||
else if(_loc4_ > 0)
|
||||
{
|
||||
_loc6_ = _loc4_;
|
||||
}
|
||||
else if(_loc5_ > 0)
|
||||
{
|
||||
_loc6_ = _loc5_;
|
||||
}
|
||||
if(this.useInstance && _loc6_ > 0)
|
||||
{
|
||||
this._instanceName += "/";
|
||||
this._instanceName += this._streamName.substr(0,_loc6_);
|
||||
this._streamName = this.streamName.substr(_loc6_ + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private function parseQuery() : void
|
||||
{
|
||||
var _loc12_:int = 0;
|
||||
var _loc13_:int = 0;
|
||||
var _loc14_:FMSURL = null;
|
||||
if(query == null || query.length == 0 || query.search(/:\//) == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc1_:Array = query.split("?");
|
||||
var _loc2_:int = 0;
|
||||
while(_loc2_ < _loc1_.length)
|
||||
{
|
||||
_loc12_ = int(_loc1_[_loc2_].toString().search(/:\//));
|
||||
if(_loc12_ == -1)
|
||||
{
|
||||
_loc1_.splice(_loc2_,1);
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
var _loc3_:Boolean = false;
|
||||
var _loc4_:int = 0;
|
||||
if(_loc1_.length >= 2)
|
||||
{
|
||||
_loc3_ = true;
|
||||
_loc4_ = _loc1_.length - 1;
|
||||
}
|
||||
var _loc5_:String = "";
|
||||
var _loc6_:String = "";
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc11_:int = 0;
|
||||
while(_loc11_ < _loc1_.length)
|
||||
{
|
||||
_loc13_ = int(_loc1_[_loc11_].toString().search(/:\//));
|
||||
_loc9_ = _loc13_ + 2;
|
||||
if(_loc1_[_loc11_].charAt(_loc9_) == "/")
|
||||
{
|
||||
_loc9_++;
|
||||
}
|
||||
_loc7_ = int(_loc1_[_loc11_].indexOf(":",_loc9_));
|
||||
_loc8_ = int(_loc1_[_loc11_].indexOf("/",_loc9_));
|
||||
if(_loc8_ < 0 && _loc7_ < 0)
|
||||
{
|
||||
_loc5_ = _loc1_[_loc11_].slice(_loc9_);
|
||||
}
|
||||
else if(_loc7_ >= 0 && _loc7_ < _loc8_)
|
||||
{
|
||||
_loc10_ = _loc7_;
|
||||
_loc5_ = _loc1_[_loc11_].slice(_loc9_,_loc10_);
|
||||
_loc9_ = _loc10_ + 1;
|
||||
_loc10_ = _loc8_;
|
||||
_loc6_ = _loc1_[_loc11_].slice(_loc9_,_loc10_);
|
||||
}
|
||||
else if(_loc1_[_loc11_].indexOf("://") != -1)
|
||||
{
|
||||
_loc10_ = _loc8_;
|
||||
_loc5_ = _loc1_[_loc11_].slice(_loc9_,_loc10_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_ = int(_loc1_[_loc11_].indexOf("/"));
|
||||
_loc5_ = "localhost";
|
||||
}
|
||||
if(_loc11_ == _loc4_)
|
||||
{
|
||||
if(this._origins == null)
|
||||
{
|
||||
this._origins = new Vector.<FMSHost>();
|
||||
}
|
||||
this._origins.push(new FMSHost(_loc5_,_loc6_));
|
||||
_loc14_ = new FMSURL(_loc1_[_loc11_],this._useInstance);
|
||||
if(this._appName == "")
|
||||
{
|
||||
this._appName = _loc14_.appName;
|
||||
}
|
||||
if(this._useInstance && this._instanceName == "")
|
||||
{
|
||||
this._instanceName = _loc14_.instanceName;
|
||||
}
|
||||
if(this._streamName == "")
|
||||
{
|
||||
this._streamName = _loc14_.streamName;
|
||||
}
|
||||
}
|
||||
else if(_loc1_[_loc11_] != query && _loc3_)
|
||||
{
|
||||
if(this._edges == null)
|
||||
{
|
||||
this._edges = new Vector.<FMSHost>();
|
||||
}
|
||||
this._edges.push(new FMSHost(_loc5_,_loc6_));
|
||||
}
|
||||
_loc11_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class ModifiableTimeTrait extends TimeTrait
|
||||
{
|
||||
|
||||
public function ModifiableTimeTrait(param1:Number = NaN)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function set duration(param1:Number) : void
|
||||
{
|
||||
super.setDuration(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetGroup;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
|
||||
public class MulticastNetLoader extends NetLoader
|
||||
{
|
||||
|
||||
public function MulticastNetLoader(param1:NetConnectionFactoryBase = null)
|
||||
{
|
||||
var _loc2_:NetConnectionFactory = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
_loc2_ = new NetConnectionFactory();
|
||||
_loc2_.timeout = 60000;
|
||||
}
|
||||
super(param1 != null ? param1 : _loc2_);
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc2_:MulticastResource = param1 as MulticastResource;
|
||||
return _loc2_ != null && _loc2_.groupspec != null && _loc2_.groupspec.length > 0 && _loc2_.streamName != null && _loc2_.streamName.length > 0;
|
||||
}
|
||||
|
||||
override protected function createNetStream(param1:NetConnection, param2:URLResource) : NetStream
|
||||
{
|
||||
var _loc3_:MulticastResource = param2 as MulticastResource;
|
||||
return new NetStream(param1,_loc3_.groupspec);
|
||||
}
|
||||
|
||||
private function doProcessCreationComplete(param1:NetConnection, param2:LoadTrait, param3:NetConnectionFactoryBase = null) : void
|
||||
{
|
||||
super.processCreationComplete(param1,param2,param3);
|
||||
}
|
||||
|
||||
override protected function processCreationComplete(param1:NetConnection, param2:LoadTrait, param3:NetConnectionFactoryBase = null) : void
|
||||
{
|
||||
var netLoadTrait:NetStreamLoadTrait = null;
|
||||
var netGroup:NetGroup = null;
|
||||
var onNetStatus:Function = null;
|
||||
var connection:NetConnection = param1;
|
||||
var loadTrait:LoadTrait = param2;
|
||||
var factory:NetConnectionFactoryBase = param3;
|
||||
onNetStatus = function(param1:NetStatusEvent):void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case "NetGroup.Connect.Success":
|
||||
connection.removeEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
|
||||
netLoadTrait.netGroup = netGroup;
|
||||
doProcessCreationComplete(connection,loadTrait,factory);
|
||||
break;
|
||||
case "NetGroup.Connect.Failed":
|
||||
case "NetGroup.Connect.Rejected":
|
||||
connection.removeEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
|
||||
updateLoadTrait(loadTrait,LoadState.LOAD_ERROR);
|
||||
}
|
||||
};
|
||||
netLoadTrait = loadTrait as NetStreamLoadTrait;
|
||||
var multicastResource:MulticastResource = netLoadTrait.resource as MulticastResource;
|
||||
connection.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
|
||||
netGroup = new NetGroup(connection,multicastResource.groupspec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class MulticastResource extends StreamingURLResource
|
||||
{
|
||||
|
||||
private var _groupspec:String;
|
||||
|
||||
private var _streamName:String;
|
||||
|
||||
public function MulticastResource(param1:String, param2:String = null, param3:String = null, param4:Vector.<Object> = null, param5:Boolean = false, param6:ByteArray = null)
|
||||
{
|
||||
super(param1,StreamType.LIVE,NaN,NaN,param4,param5,param6);
|
||||
this._groupspec = param2;
|
||||
this._streamName = param3;
|
||||
}
|
||||
|
||||
public function get groupspec() : String
|
||||
{
|
||||
return this._groupspec;
|
||||
}
|
||||
|
||||
public function set groupspec(param1:String) : void
|
||||
{
|
||||
this._groupspec = param1;
|
||||
}
|
||||
|
||||
public function get streamName() : String
|
||||
{
|
||||
return this._streamName;
|
||||
}
|
||||
|
||||
public function set streamName(param1:String) : void
|
||||
{
|
||||
this._streamName = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
import flash.utils.Proxy;
|
||||
import flash.utils.flash_proxy;
|
||||
|
||||
use namespace flash_proxy;
|
||||
|
||||
public dynamic class NetClient extends Proxy
|
||||
{
|
||||
|
||||
private var handlers:Dictionary = new Dictionary();
|
||||
|
||||
public function NetClient()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function addHandler(param1:String, param2:Function, param3:int = 0) : void
|
||||
{
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:Object = null;
|
||||
var _loc4_:Array = this.handlers.hasOwnProperty(param1) ? this.handlers[param1] : (this.handlers[param1] = []);
|
||||
if(_loc4_.indexOf(param2) == -1)
|
||||
{
|
||||
_loc5_ = false;
|
||||
param3 = Math.max(0,param3);
|
||||
if(param3 > 0)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc4_.length)
|
||||
{
|
||||
_loc7_ = _loc4_[_loc6_];
|
||||
if(_loc7_.priority < param3)
|
||||
{
|
||||
_loc4_.splice(_loc6_,0,{
|
||||
"handler":param2,
|
||||
"priority":param3
|
||||
});
|
||||
_loc5_ = true;
|
||||
break;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
if(!_loc5_)
|
||||
{
|
||||
_loc4_.push({
|
||||
"handler":param2,
|
||||
"priority":param3
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeHandler(param1:String, param2:Function) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
if(this.handlers.hasOwnProperty(param1))
|
||||
{
|
||||
_loc3_ = this.handlers[param1];
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc3_.length)
|
||||
{
|
||||
_loc5_ = _loc3_[_loc4_];
|
||||
if(_loc5_.handler == param2)
|
||||
{
|
||||
_loc3_.splice(_loc4_,1);
|
||||
break;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override flash_proxy function callProperty(param1:*, ... rest) : *
|
||||
{
|
||||
return this.invokeHandlers(param1,rest);
|
||||
}
|
||||
|
||||
override flash_proxy function getProperty(param1:*) : *
|
||||
{
|
||||
var result:* = undefined;
|
||||
var name:* = param1;
|
||||
if(this.handlers.hasOwnProperty(name))
|
||||
{
|
||||
result = function():*
|
||||
{
|
||||
return invokeHandlers(arguments.callee.name,arguments);
|
||||
};
|
||||
result.name = name;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
override flash_proxy function hasProperty(param1:*) : Boolean
|
||||
{
|
||||
return this.handlers.hasOwnProperty(param1);
|
||||
}
|
||||
|
||||
private function invokeHandlers(param1:String, param2:Array) : *
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
var _loc4_:Array = null;
|
||||
var _loc5_:Object = null;
|
||||
if(this.handlers.hasOwnProperty(param1))
|
||||
{
|
||||
_loc3_ = [];
|
||||
_loc4_ = this.handlers[param1];
|
||||
for each(_loc5_ in _loc4_)
|
||||
{
|
||||
_loc3_.push(_loc5_.handler.apply(null,param2));
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
public final class NetConnectionCodes
|
||||
{
|
||||
|
||||
public static const CONNECT_CLOSED:String = "NetConnection.Connect.Closed";
|
||||
|
||||
public static const CONNECT_FAILED:String = "NetConnection.Connect.Failed";
|
||||
|
||||
public static const CONNECT_SUCCESS:String = "NetConnection.Connect.Success";
|
||||
|
||||
public static const CONNECT_REJECTED:String = "NetConnection.Connect.Rejected";
|
||||
|
||||
public static const CONNECT_INVALIDAPP:String = "NetConnection.Connect.InvalidApp";
|
||||
|
||||
public static const CONNECT_IDLE_TIME_OUT:String = "NetConnection.Connect.IdleTimeOut";
|
||||
|
||||
public function NetConnectionCodes()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.events.NetConnectionFactoryEvent;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.utils.URL;
|
||||
|
||||
public class NetConnectionFactory extends NetConnectionFactoryBase
|
||||
{
|
||||
|
||||
private static const DEFAULT_TIMEOUT:Number = 10000;
|
||||
|
||||
private static const DEFAULT_PORTS:String = "1935,443,80";
|
||||
|
||||
private static const DEFAULT_PROTOCOLS_FOR_RTMP:String = "rtmp,rtmpt,rtmps";
|
||||
|
||||
private static const DEFAULT_PROTOCOLS_FOR_RTMPE:String = "rtmpe,rtmpte";
|
||||
|
||||
private static const DEFAULT_CONNECTION_ATTEMPT_INTERVAL:Number = 200;
|
||||
|
||||
private static const PROTOCOL_RTMP:String = "rtmp";
|
||||
|
||||
private static const PROTOCOL_RTMPS:String = "rtmps";
|
||||
|
||||
private static const PROTOCOL_RTMPT:String = "rtmpt";
|
||||
|
||||
private static const PROTOCOL_RTMPE:String = "rtmpe";
|
||||
|
||||
private static const PROTOCOL_RTMPTE:String = "rtmpte";
|
||||
|
||||
private static const PROTOCOL_HTTP:String = "http";
|
||||
|
||||
private static const PROTOCOL_HTTPS:String = "https";
|
||||
|
||||
private static const PROTOCOL_FILE:String = "file";
|
||||
|
||||
private static const PROTOCOL_EMPTY:String = "";
|
||||
|
||||
private static const MP3_EXTENSION:String = ".mp3";
|
||||
|
||||
private var shareNetConnections:Boolean;
|
||||
|
||||
private var negotiator:NetNegotiator;
|
||||
|
||||
private var connectionDictionary:Dictionary;
|
||||
|
||||
private var keyDictionary:Dictionary;
|
||||
|
||||
private var pendingDictionary:Dictionary;
|
||||
|
||||
private var _connectionAttemptInterval:Number = 200;
|
||||
|
||||
private var _timeout:Number = 10000;
|
||||
|
||||
public function NetConnectionFactory(param1:Boolean = true)
|
||||
{
|
||||
super();
|
||||
this.shareNetConnections = param1;
|
||||
}
|
||||
|
||||
public function get timeout() : Number
|
||||
{
|
||||
return this._timeout;
|
||||
}
|
||||
|
||||
public function set timeout(param1:Number) : void
|
||||
{
|
||||
this._timeout = param1;
|
||||
}
|
||||
|
||||
public function get connectionAttemptInterval() : Number
|
||||
{
|
||||
return this._connectionAttemptInterval;
|
||||
}
|
||||
|
||||
public function set connectionAttemptInterval(param1:Number) : void
|
||||
{
|
||||
this._connectionAttemptInterval = param1;
|
||||
}
|
||||
|
||||
override public function create(param1:URLResource) : void
|
||||
{
|
||||
var sharedConnection:SharedConnection;
|
||||
var connectionsUnderway:Vector.<URLResource>;
|
||||
var key:String = null;
|
||||
var pendingConnections:Vector.<URLResource> = null;
|
||||
var urlIncludesFMSApplicationInstance:Boolean = false;
|
||||
var netConnectionURLs:Vector.<String> = null;
|
||||
var netConnections:Vector.<NetConnection> = null;
|
||||
var j:int = 0;
|
||||
var negotiator:NetNegotiator = null;
|
||||
var onConnected:Function = null;
|
||||
var onConnectionFailed:Function = null;
|
||||
var resource:URLResource = param1;
|
||||
key = this.createNetConnectionKey(resource);
|
||||
if(this.connectionDictionary == null)
|
||||
{
|
||||
this.connectionDictionary = new Dictionary();
|
||||
this.keyDictionary = new Dictionary();
|
||||
this.pendingDictionary = new Dictionary();
|
||||
}
|
||||
sharedConnection = this.connectionDictionary[key] as SharedConnection;
|
||||
connectionsUnderway = this.pendingDictionary[key] as Vector.<URLResource>;
|
||||
if(sharedConnection != null && this.shareNetConnections)
|
||||
{
|
||||
++sharedConnection.count;
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_COMPLETE,false,false,sharedConnection.netConnection,resource));
|
||||
}
|
||||
else if(connectionsUnderway != null)
|
||||
{
|
||||
connectionsUnderway.push(resource);
|
||||
}
|
||||
else
|
||||
{
|
||||
onConnected = function(param1:NetConnectionFactoryEvent):void
|
||||
{
|
||||
var _loc5_:NetConnectionFactoryEvent = null;
|
||||
var _loc6_:URLResource = null;
|
||||
var _loc7_:SharedConnection = null;
|
||||
var _loc8_:SharedConnection = null;
|
||||
negotiator.removeEventListener(NetConnectionFactoryEvent.CREATION_COMPLETE,onConnected);
|
||||
negotiator.removeEventListener(NetConnectionFactoryEvent.CREATION_ERROR,onConnectionFailed);
|
||||
var _loc2_:Vector.<NetConnectionFactoryEvent> = new Vector.<NetConnectionFactoryEvent>();
|
||||
var _loc3_:Vector.<URLResource> = pendingDictionary[key];
|
||||
var _loc4_:Number = 0;
|
||||
while(_loc4_ < _loc3_.length)
|
||||
{
|
||||
_loc6_ = _loc3_[_loc4_] as URLResource;
|
||||
if(shareNetConnections)
|
||||
{
|
||||
_loc7_ = connectionDictionary[key] as SharedConnection;
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
++_loc7_.count;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = new SharedConnection();
|
||||
_loc8_.count = 1;
|
||||
_loc8_.netConnection = param1.netConnection;
|
||||
connectionDictionary[key] = _loc8_;
|
||||
keyDictionary[_loc8_.netConnection] = key;
|
||||
}
|
||||
}
|
||||
_loc2_.push(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_COMPLETE,false,false,param1.netConnection,_loc6_));
|
||||
_loc4_++;
|
||||
}
|
||||
delete pendingDictionary[key];
|
||||
for each(_loc5_ in _loc2_)
|
||||
{
|
||||
dispatchEvent(_loc5_);
|
||||
}
|
||||
};
|
||||
onConnectionFailed = function(param1:NetConnectionFactoryEvent):void
|
||||
{
|
||||
var _loc3_:URLResource = null;
|
||||
negotiator.removeEventListener(NetConnectionFactoryEvent.CREATION_COMPLETE,onConnected);
|
||||
negotiator.removeEventListener(NetConnectionFactoryEvent.CREATION_ERROR,onConnectionFailed);
|
||||
var _loc2_:Vector.<URLResource> = pendingDictionary[key];
|
||||
for each(_loc3_ in _loc2_)
|
||||
{
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_ERROR,false,false,null,_loc3_,param1.mediaError));
|
||||
}
|
||||
delete pendingDictionary[key];
|
||||
};
|
||||
pendingConnections = new Vector.<URLResource>();
|
||||
pendingConnections.push(resource);
|
||||
this.pendingDictionary[key] = pendingConnections;
|
||||
urlIncludesFMSApplicationInstance = resource is StreamingURLResource ? StreamingURLResource(resource).urlIncludesFMSApplicationInstance : false;
|
||||
netConnectionURLs = this.createNetConnectionURLs(resource.url,urlIncludesFMSApplicationInstance);
|
||||
netConnections = new Vector.<NetConnection>();
|
||||
j = 0;
|
||||
while(j < netConnectionURLs.length)
|
||||
{
|
||||
netConnections.push(this.createNetConnection());
|
||||
j++;
|
||||
}
|
||||
negotiator = new NetNegotiator(this._connectionAttemptInterval,this._timeout);
|
||||
negotiator.addEventListener(NetConnectionFactoryEvent.CREATION_COMPLETE,onConnected);
|
||||
negotiator.addEventListener(NetConnectionFactoryEvent.CREATION_ERROR,onConnectionFailed);
|
||||
negotiator.createNetConnection(resource,netConnectionURLs,netConnections);
|
||||
}
|
||||
}
|
||||
|
||||
override public function closeNetConnection(param1:NetConnection) : void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:SharedConnection = null;
|
||||
if(this.shareNetConnections)
|
||||
{
|
||||
_loc2_ = this.keyDictionary[param1] as String;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ = this.connectionDictionary[_loc2_] as SharedConnection;
|
||||
--_loc3_.count;
|
||||
if(_loc3_.count == 0)
|
||||
{
|
||||
param1.close();
|
||||
delete this.connectionDictionary[_loc2_];
|
||||
delete this.keyDictionary[param1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.closeNetConnection(param1);
|
||||
}
|
||||
}
|
||||
|
||||
protected function createNetConnectionKey(param1:URLResource) : String
|
||||
{
|
||||
var _loc2_:FMSURL = new FMSURL(param1.url);
|
||||
return _loc2_.protocol + _loc2_.host + _loc2_.port + _loc2_.appName + _loc2_.instanceName;
|
||||
}
|
||||
|
||||
protected function createNetConnection() : NetConnection
|
||||
{
|
||||
return new NetConnection();
|
||||
}
|
||||
|
||||
protected function createNetConnectionURLs(param1:String, param2:Boolean = false) : Vector.<String>
|
||||
{
|
||||
var _loc5_:PortProtocol = null;
|
||||
var _loc3_:Vector.<String> = new Vector.<String>();
|
||||
var _loc4_:Vector.<PortProtocol> = this.buildPortProtocolSequence(param1);
|
||||
for each(_loc5_ in _loc4_)
|
||||
{
|
||||
_loc3_.push(this.buildConnectionAddress(param1,param2,_loc5_));
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function buildPortProtocolSequence(param1:String) : Vector.<PortProtocol>
|
||||
{
|
||||
var _loc9_:int = 0;
|
||||
var _loc10_:PortProtocol = null;
|
||||
var _loc2_:Vector.<PortProtocol> = new Vector.<PortProtocol>();
|
||||
var _loc3_:URL = new URL(param1);
|
||||
var _loc4_:String = _loc3_.port == "" ? DEFAULT_PORTS : _loc3_.port;
|
||||
var _loc5_:String = "";
|
||||
switch(_loc3_.protocol)
|
||||
{
|
||||
case PROTOCOL_RTMP:
|
||||
_loc5_ = DEFAULT_PROTOCOLS_FOR_RTMP;
|
||||
break;
|
||||
case PROTOCOL_RTMPE:
|
||||
_loc5_ = DEFAULT_PROTOCOLS_FOR_RTMPE;
|
||||
break;
|
||||
case PROTOCOL_RTMPS:
|
||||
case PROTOCOL_RTMPT:
|
||||
case PROTOCOL_RTMPTE:
|
||||
_loc5_ = _loc3_.protocol;
|
||||
}
|
||||
var _loc6_:Array = _loc4_.split(",");
|
||||
var _loc7_:Array = _loc5_.split(",");
|
||||
var _loc8_:int = 0;
|
||||
while(_loc8_ < _loc7_.length)
|
||||
{
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc6_.length)
|
||||
{
|
||||
_loc10_ = new PortProtocol();
|
||||
_loc10_.protocol = _loc7_[_loc8_];
|
||||
_loc10_.port = _loc6_[_loc9_];
|
||||
_loc2_.push(_loc10_);
|
||||
_loc9_++;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function buildConnectionAddress(param1:String, param2:Boolean, param3:PortProtocol) : String
|
||||
{
|
||||
var _loc4_:FMSURL = new FMSURL(param1,param2);
|
||||
var _loc5_:String = param3.protocol + "://" + _loc4_.host + ":" + param3.port + "/" + _loc4_.appName + (_loc4_.useInstance ? "/" + _loc4_.instanceName : "");
|
||||
if(_loc4_.query != null && _loc4_.query != "")
|
||||
{
|
||||
_loc5_ += "?" + _loc4_.query;
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import flash.net.NetConnection;
|
||||
|
||||
class SharedConnection
|
||||
{
|
||||
|
||||
public var count:Number;
|
||||
|
||||
public var netConnection:NetConnection;
|
||||
|
||||
public function SharedConnection()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.net.NetConnection;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class NetConnectionFactoryBase extends EventDispatcher
|
||||
{
|
||||
|
||||
public function NetConnectionFactoryBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function create(param1:URLResource) : void
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.FUNCTION_MUST_BE_OVERRIDDEN));
|
||||
}
|
||||
|
||||
public function closeNetConnection(param1:NetConnection) : void
|
||||
{
|
||||
param1.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,529 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.net.NetStreamPlayOptions;
|
||||
import flash.net.NetStreamPlayTransitions;
|
||||
import flash.utils.Dictionary;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.events.NetConnectionFactoryEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.MediaType;
|
||||
import org.osmf.media.MediaTypeUtil;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.MetadataNamespaces;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
import org.osmf.utils.URL;
|
||||
|
||||
public class NetLoader extends LoaderBase
|
||||
{
|
||||
|
||||
private static const PROTOCOL_RTMP:String = "rtmp";
|
||||
|
||||
private static const PROTOCOL_RTMPS:String = "rtmps";
|
||||
|
||||
private static const PROTOCOL_RTMPT:String = "rtmpt";
|
||||
|
||||
private static const PROTOCOL_RTMPE:String = "rtmpe";
|
||||
|
||||
private static const PROTOCOL_RTMPTE:String = "rtmpte";
|
||||
|
||||
private static const PROTOCOL_RTMFP:String = "rtmfp";
|
||||
|
||||
private static const PROTOCOL_HTTP:String = "http";
|
||||
|
||||
private static const PROTOCOL_HTTPS:String = "https";
|
||||
|
||||
private static const PROTOCOL_FILE:String = "file";
|
||||
|
||||
private static const PROTOCOL_EMPTY:String = "";
|
||||
|
||||
private static const MEDIA_TYPES_SUPPORTED:Vector.<String> = Vector.<String>([MediaType.VIDEO]);
|
||||
|
||||
private static const MIME_TYPES_SUPPORTED:Vector.<String> = Vector.<String>(["video/x-flv","video/x-f4v","video/mp4","video/mp4v-es","video/x-m4v","video/3gpp","video/3gpp2","video/quicktime"]);
|
||||
|
||||
private static const STREAM_RECONNECT_TIMEOUT:Number = 120000;
|
||||
|
||||
private static const STREAM_RECONNECT_TIMER_INTERVAL:int = 1000;
|
||||
|
||||
private var netConnectionFactory:NetConnectionFactoryBase;
|
||||
|
||||
private var pendingLoads:Dictionary = new Dictionary();
|
||||
|
||||
private var oldConnectionURLs:Dictionary = new Dictionary();
|
||||
|
||||
private var _reconnectStreams:Boolean = true;
|
||||
|
||||
private var _reconnectTimeout:Number;
|
||||
|
||||
public function NetLoader(param1:NetConnectionFactoryBase = null)
|
||||
{
|
||||
super();
|
||||
this._reconnectTimeout = STREAM_RECONNECT_TIMEOUT;
|
||||
this.netConnectionFactory = param1 || new NetConnectionFactory();
|
||||
this.netConnectionFactory.addEventListener(NetConnectionFactoryEvent.CREATION_COMPLETE,this.onCreationComplete);
|
||||
this.netConnectionFactory.addEventListener(NetConnectionFactoryEvent.CREATION_ERROR,this.onCreationError);
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc2_:int = MediaTypeUtil.checkMetadataMatchWithResource(param1,MEDIA_TYPES_SUPPORTED,MIME_TYPES_SUPPORTED);
|
||||
if(_loc2_ != MediaTypeUtil.METADATA_MATCH_UNKNOWN)
|
||||
{
|
||||
return _loc2_ == MediaTypeUtil.METADATA_MATCH_FOUND;
|
||||
}
|
||||
var _loc3_:URLResource = param1 as URLResource;
|
||||
var _loc4_:RegExp = /.flv$|.f4v$|.mov$|.mp4$|.mp4v$|.m4v$|.3gp$|.3gpp2$|.3g2$/i;
|
||||
var _loc5_:URL = _loc3_ != null ? new URL(_loc3_.url) : null;
|
||||
if(_loc5_ == null || _loc5_.rawUrl == null || _loc5_.rawUrl.length <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(_loc5_.protocol == "")
|
||||
{
|
||||
return _loc4_.test(_loc5_.path);
|
||||
}
|
||||
if(NetStreamUtils.isRTMPStream(_loc5_.rawUrl))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(_loc5_.protocol.search(/file$|http$|https$/i) != -1)
|
||||
{
|
||||
return _loc5_.path == null || _loc5_.path.length <= 0 || _loc5_.path.indexOf(".") == -1 || _loc4_.test(_loc5_.path);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function createNetStream(param1:NetConnection, param2:URLResource) : NetStream
|
||||
{
|
||||
var _loc3_:NetStream = new NetStream(param1);
|
||||
var _loc4_:StreamingURLResource = param2 as StreamingURLResource;
|
||||
if(_loc4_ != null && _loc4_.streamType == StreamType.LIVE && _loc3_.bufferTime == 0)
|
||||
{
|
||||
_loc3_.bufferTime = 0.1;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
protected function createNetStreamSwitchManager(param1:NetConnection, param2:NetStream, param3:DynamicStreamingResource) : NetStreamSwitchManagerBase
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function processFinishLoading(param1:NetStreamLoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(param1,LoadState.READY);
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(param1,LoadState.LOADING);
|
||||
var _loc2_:URL = new URL((param1.resource as URLResource).url);
|
||||
switch(_loc2_.protocol)
|
||||
{
|
||||
case PROTOCOL_RTMP:
|
||||
case PROTOCOL_RTMPS:
|
||||
case PROTOCOL_RTMPT:
|
||||
case PROTOCOL_RTMPE:
|
||||
case PROTOCOL_RTMPTE:
|
||||
case PROTOCOL_RTMFP:
|
||||
this.startLoadingRTMP(param1);
|
||||
break;
|
||||
case PROTOCOL_HTTP:
|
||||
case PROTOCOL_HTTPS:
|
||||
case PROTOCOL_FILE:
|
||||
case PROTOCOL_EMPTY:
|
||||
this.startLoadingHTTP(param1);
|
||||
break;
|
||||
default:
|
||||
updateLoadTrait(param1,LoadState.LOAD_ERROR);
|
||||
param1.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.URL_SCHEME_INVALID)));
|
||||
}
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
var _loc2_:NetStreamLoadTrait = param1 as NetStreamLoadTrait;
|
||||
updateLoadTrait(param1,LoadState.UNLOADING);
|
||||
_loc2_.netStream.close();
|
||||
if(_loc2_.netConnectionFactory != null)
|
||||
{
|
||||
_loc2_.netConnectionFactory.closeNetConnection(_loc2_.connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.connection.close();
|
||||
}
|
||||
delete this.oldConnectionURLs[param1.resource];
|
||||
updateLoadTrait(param1,LoadState.UNINITIALIZED);
|
||||
}
|
||||
|
||||
private function finishLoading(param1:NetConnection, param2:LoadTrait, param3:NetConnectionFactoryBase = null) : void
|
||||
{
|
||||
var _loc5_:NetStream = null;
|
||||
var _loc4_:NetStreamLoadTrait = param2 as NetStreamLoadTrait;
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc4_.connection = param1;
|
||||
_loc5_ = this.createNetStream(param1,_loc4_.resource as URLResource);
|
||||
_loc5_.client = new NetClient();
|
||||
_loc4_.netStream = _loc5_;
|
||||
_loc4_.switchManager = this.createNetStreamSwitchManager(param1,_loc5_,_loc4_.resource as DynamicStreamingResource);
|
||||
_loc4_.netConnectionFactory = param3;
|
||||
if(this._reconnectStreams && _loc4_.resource is URLResource && this.supportsStreamReconnect(_loc4_.resource as URLResource))
|
||||
{
|
||||
this.setupStreamReconnect(_loc4_);
|
||||
}
|
||||
this.processFinishLoading(param2 as NetStreamLoadTrait);
|
||||
}
|
||||
}
|
||||
|
||||
private function supportsStreamReconnect(param1:URLResource) : Boolean
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:Array = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc2_:Boolean = true;
|
||||
if(NetStreamUtils.isRTMPStream(param1.url))
|
||||
{
|
||||
_loc3_ = param1.getMetadataValue(MetadataNamespaces.FMS_SERVER_VERSION_METADATA) as String;
|
||||
if(_loc3_ != null && _loc3_.length > 0)
|
||||
{
|
||||
_loc4_ = _loc3_.split(",");
|
||||
if(_loc4_.length >= 3)
|
||||
{
|
||||
_loc5_ = int(_loc4_[0]);
|
||||
_loc6_ = int(_loc4_[1]);
|
||||
_loc7_ = int(_loc4_[2]);
|
||||
if(_loc5_ < 3 || _loc5_ == 3 && _loc6_ < 5 || _loc5_ == 3 && _loc6_ == 5 && _loc7_ < 3)
|
||||
{
|
||||
_loc2_ = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = false;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function startLoadingRTMP(param1:LoadTrait) : void
|
||||
{
|
||||
this.addPendingLoad(param1);
|
||||
this.netConnectionFactory.create(param1.resource as URLResource);
|
||||
}
|
||||
|
||||
private function onCreationComplete(param1:NetConnectionFactoryEvent) : void
|
||||
{
|
||||
this.processCreationComplete(param1.netConnection,this.findAndRemovePendingLoad(param1.resource),param1.currentTarget as NetConnectionFactoryBase);
|
||||
}
|
||||
|
||||
protected function processCreationComplete(param1:NetConnection, param2:LoadTrait, param3:NetConnectionFactoryBase = null) : void
|
||||
{
|
||||
this.finishLoading(param1,param2,param3);
|
||||
}
|
||||
|
||||
private function onCreationError(param1:NetConnectionFactoryEvent) : void
|
||||
{
|
||||
var _loc2_:LoadTrait = this.findAndRemovePendingLoad(param1.resource);
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc2_.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,param1.mediaError));
|
||||
updateLoadTrait(_loc2_,LoadState.LOAD_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private function startLoadingHTTP(param1:LoadTrait) : void
|
||||
{
|
||||
var _loc2_:NetConnection = new NetConnection();
|
||||
_loc2_.client = new NetClient();
|
||||
_loc2_.connect(null);
|
||||
this.finishLoading(_loc2_,param1);
|
||||
}
|
||||
|
||||
private function addPendingLoad(param1:LoadTrait) : void
|
||||
{
|
||||
if(this.pendingLoads[param1.resource] == null)
|
||||
{
|
||||
this.pendingLoads[param1.resource] = [param1];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pendingLoads[param1.resource].push(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function findAndRemovePendingLoad(param1:URLResource) : LoadTrait
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:LoadTrait = null;
|
||||
var _loc3_:Array = this.pendingLoads[param1];
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
if(_loc3_.length == 1)
|
||||
{
|
||||
_loc2_ = _loc3_[0] as LoadTrait;
|
||||
delete this.pendingLoads[param1];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc3_.length)
|
||||
{
|
||||
_loc2_ = _loc3_[_loc4_];
|
||||
if(_loc2_.resource == param1)
|
||||
{
|
||||
_loc3_.splice(_loc4_,1);
|
||||
break;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function get reconnectTimeout() : Number
|
||||
{
|
||||
return this._reconnectTimeout;
|
||||
}
|
||||
|
||||
public function set reconnectTimeout(param1:Number) : void
|
||||
{
|
||||
if(param1 < 0)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
this._reconnectTimeout = param1;
|
||||
}
|
||||
|
||||
protected function setReconnectStreams(param1:Boolean) : void
|
||||
{
|
||||
this._reconnectStreams = param1;
|
||||
}
|
||||
|
||||
public function get reconnectStreams() : Boolean
|
||||
{
|
||||
return this._reconnectStreams;
|
||||
}
|
||||
|
||||
protected function createReconnectNetConnection() : NetConnection
|
||||
{
|
||||
return new NetConnection();
|
||||
}
|
||||
|
||||
protected function reconnect(param1:NetConnection, param2:URLResource) : void
|
||||
{
|
||||
var _loc3_:String = this.oldConnectionURLs[param2] as String;
|
||||
if(_loc3_ != null && _loc3_.length > 0 && param1 != null)
|
||||
{
|
||||
param1.connect(_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
protected function reconnectStream(param1:NetStreamLoadTrait) : void
|
||||
{
|
||||
var _loc2_:NetStreamPlayOptions = new NetStreamPlayOptions();
|
||||
param1.netStream.attach(param1.connection);
|
||||
_loc2_.transition = NetStreamPlayTransitions.RESUME;
|
||||
var _loc3_:URLResource = param1.resource as URLResource;
|
||||
var _loc4_:Boolean = _loc3_ as StreamingURLResource != null ? (_loc3_ as StreamingURLResource).urlIncludesFMSApplicationInstance : false;
|
||||
var _loc5_:String = NetStreamUtils.getStreamNameFromURL(_loc3_.url,_loc4_);
|
||||
_loc2_.streamName = _loc5_;
|
||||
param1.netStream.play2(_loc2_);
|
||||
}
|
||||
|
||||
private function setupStreamReconnect(param1:NetStreamLoadTrait) : void
|
||||
{
|
||||
var netConnection:NetConnection = null;
|
||||
var reconnectTimer:Timer = null;
|
||||
var timeoutTimer:Timer = null;
|
||||
var streamIsPaused:Boolean = false;
|
||||
var bufferIsEmpty:Boolean = false;
|
||||
var reconnectHasTimedOut:Boolean = false;
|
||||
var fmsIdleTimeoutReached:Boolean = false;
|
||||
var onNetStatus:Function = null;
|
||||
var onTimeoutTimer:Function = null;
|
||||
var onReconnectTimer:Function = null;
|
||||
var loadTrait:NetStreamLoadTrait = param1;
|
||||
var setupReconnectTimer:Function = function(param1:Boolean = true):void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
reconnectTimer.addEventListener(TimerEvent.TIMER_COMPLETE,onReconnectTimer);
|
||||
}
|
||||
else
|
||||
{
|
||||
reconnectTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,onReconnectTimer);
|
||||
reconnectTimer = null;
|
||||
}
|
||||
};
|
||||
var setupTimeoutTimer:Function = function(param1:Boolean = true):void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
if(_reconnectTimeout > 0)
|
||||
{
|
||||
timeoutTimer = new Timer(_reconnectTimeout,1);
|
||||
timeoutTimer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimeoutTimer);
|
||||
}
|
||||
}
|
||||
else if(timeoutTimer != null)
|
||||
{
|
||||
timeoutTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,onTimeoutTimer);
|
||||
timeoutTimer = null;
|
||||
}
|
||||
};
|
||||
var setupNetConnectionListeners:Function = function(param1:Boolean = true):void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
netConnection.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
netConnection.removeEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
|
||||
}
|
||||
};
|
||||
var setupNetStreamListeners:Function = function(param1:Boolean = true):void
|
||||
{
|
||||
if(loadTrait.netStream != null)
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
loadTrait.netStream.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadTrait.netStream.removeEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
|
||||
}
|
||||
}
|
||||
};
|
||||
onNetStatus = function(param1:NetStatusEvent):void
|
||||
{
|
||||
var _loc2_:NetConnection = null;
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetConnectionCodes.CONNECT_SUCCESS:
|
||||
_loc2_ = loadTrait.connection;
|
||||
loadTrait.connection = netConnection;
|
||||
oldConnectionURLs[loadTrait.resource] = netConnection.uri;
|
||||
if(timeoutTimer != null)
|
||||
{
|
||||
timeoutTimer.stop();
|
||||
}
|
||||
reconnectStream(loadTrait);
|
||||
if(loadTrait.netConnectionFactory != null)
|
||||
{
|
||||
loadTrait.netConnectionFactory.closeNetConnection(_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.close();
|
||||
}
|
||||
break;
|
||||
case NetConnectionCodes.CONNECT_IDLE_TIME_OUT:
|
||||
fmsIdleTimeoutReached = true;
|
||||
break;
|
||||
case NetConnectionCodes.CONNECT_CLOSED:
|
||||
case NetConnectionCodes.CONNECT_FAILED:
|
||||
if(loadTrait.loadState == LoadState.READY && !reconnectHasTimedOut && !fmsIdleTimeoutReached)
|
||||
{
|
||||
reconnectTimer.start();
|
||||
if(bufferIsEmpty || loadTrait.netStream.bufferLength == 0 || streamIsPaused)
|
||||
{
|
||||
if(timeoutTimer != null)
|
||||
{
|
||||
timeoutTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
reconnectHasTimedOut = true;
|
||||
setupReconnectTimer(false);
|
||||
setupNetConnectionListeners(false);
|
||||
setupNetStreamListeners(false);
|
||||
setupTimeoutTimer(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setupReconnectTimer(false);
|
||||
setupNetConnectionListeners(false);
|
||||
setupNetStreamListeners(false);
|
||||
setupTimeoutTimer(false);
|
||||
}
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PAUSE_NOTIFY:
|
||||
streamIsPaused = true;
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_UNPAUSE_NOTIFY:
|
||||
streamIsPaused = false;
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_BUFFER_EMPTY:
|
||||
if(!netConnection.connected)
|
||||
{
|
||||
if(timeoutTimer != null)
|
||||
{
|
||||
timeoutTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
reconnectHasTimedOut = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bufferIsEmpty = true;
|
||||
}
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_BUFFER_FULL:
|
||||
bufferIsEmpty = false;
|
||||
}
|
||||
};
|
||||
onTimeoutTimer = function(param1:TimerEvent):void
|
||||
{
|
||||
reconnectHasTimedOut = true;
|
||||
};
|
||||
onReconnectTimer = function(param1:TimerEvent):void
|
||||
{
|
||||
if(reconnectHasTimedOut)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(netConnection === loadTrait.connection)
|
||||
{
|
||||
setupNetConnectionListeners(false);
|
||||
netConnection = createReconnectNetConnection();
|
||||
netConnection.client = new NetClient();
|
||||
setupNetConnectionListeners();
|
||||
}
|
||||
reconnect(netConnection,loadTrait.resource as URLResource);
|
||||
};
|
||||
netConnection = loadTrait.connection;
|
||||
reconnectTimer = new Timer(STREAM_RECONNECT_TIMER_INTERVAL,1);
|
||||
this.oldConnectionURLs[loadTrait.resource] = netConnection.uri;
|
||||
streamIsPaused = false;
|
||||
bufferIsEmpty = false;
|
||||
reconnectHasTimedOut = false;
|
||||
fmsIdleTimeoutReached = false;
|
||||
setupNetConnectionListeners();
|
||||
setupNetStreamListeners();
|
||||
setupReconnectTimer();
|
||||
setupTimeoutTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.errors.IOError;
|
||||
import flash.events.AsyncErrorEvent;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.NetConnectionFactoryEvent;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.MetadataNamespaces;
|
||||
|
||||
internal class NetNegotiator extends EventDispatcher
|
||||
{
|
||||
|
||||
private var resource:URLResource;
|
||||
|
||||
private var netConnectionURLs:Vector.<String>;
|
||||
|
||||
private var netConnections:Vector.<NetConnection>;
|
||||
|
||||
private var netConnectionArguments:Vector.<Object>;
|
||||
|
||||
private var failedConnectionCount:int;
|
||||
|
||||
private var timeOutTimer:Timer;
|
||||
|
||||
private var connectionTimer:Timer;
|
||||
|
||||
private var attemptIndex:int;
|
||||
|
||||
private var mediaError:MediaError;
|
||||
|
||||
private var connectionAttemptInterval:Number;
|
||||
|
||||
private var _timeout:Number;
|
||||
|
||||
public function NetNegotiator(param1:Number, param2:Number = 10000)
|
||||
{
|
||||
super();
|
||||
this.connectionAttemptInterval = param1;
|
||||
this._timeout = param2;
|
||||
}
|
||||
|
||||
public function get timeout() : Number
|
||||
{
|
||||
return this._timeout;
|
||||
}
|
||||
|
||||
public function set timeout(param1:Number) : void
|
||||
{
|
||||
this._timeout = param1;
|
||||
}
|
||||
|
||||
public function createNetConnection(param1:URLResource, param2:Vector.<String>, param3:Vector.<NetConnection>) : void
|
||||
{
|
||||
this.resource = param1;
|
||||
this.netConnectionURLs = param2;
|
||||
this.netConnections = param3;
|
||||
var _loc4_:StreamingURLResource = param1 as StreamingURLResource;
|
||||
if(_loc4_ != null && _loc4_.connectionArguments != null && _loc4_.connectionArguments.length > 0)
|
||||
{
|
||||
this.netConnectionArguments = _loc4_.connectionArguments;
|
||||
}
|
||||
this.initializeConnectionAttempts();
|
||||
this.tryToConnect(null);
|
||||
}
|
||||
|
||||
private function initializeConnectionAttempts() : void
|
||||
{
|
||||
this.timeOutTimer = new Timer(this._timeout,1);
|
||||
this.timeOutTimer.addEventListener(TimerEvent.TIMER_COMPLETE,this.masterTimeout);
|
||||
this.timeOutTimer.start();
|
||||
this.connectionTimer = new Timer(this.connectionAttemptInterval);
|
||||
this.connectionTimer.addEventListener(TimerEvent.TIMER,this.tryToConnect);
|
||||
this.connectionTimer.start();
|
||||
this.failedConnectionCount = 0;
|
||||
this.attemptIndex = 0;
|
||||
}
|
||||
|
||||
private function tryToConnect(param1:TimerEvent) : void
|
||||
{
|
||||
var rs:MulticastResource = null;
|
||||
var host:String = null;
|
||||
var args:Array = null;
|
||||
var arg:Object = null;
|
||||
var evt:TimerEvent = param1;
|
||||
this.netConnections[this.attemptIndex].addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus,false,0,true);
|
||||
this.netConnections[this.attemptIndex].addEventListener(SecurityErrorEvent.SECURITY_ERROR,this.onNetSecurityError,false,0,true);
|
||||
this.netConnections[this.attemptIndex].addEventListener(AsyncErrorEvent.ASYNC_ERROR,this.onAsyncError,false,0,true);
|
||||
this.netConnections[this.attemptIndex].client = new NetClient();
|
||||
try
|
||||
{
|
||||
rs = this.resource as MulticastResource;
|
||||
if(rs != null && rs.groupspec != null && rs.groupspec.length > 0)
|
||||
{
|
||||
NetConnection(this.netConnections[this.attemptIndex]).connect(rs.url);
|
||||
}
|
||||
else
|
||||
{
|
||||
host = this.netConnectionURLs[this.attemptIndex];
|
||||
args = [host];
|
||||
if(this.netConnectionArguments != null)
|
||||
{
|
||||
for each(arg in this.netConnectionArguments)
|
||||
{
|
||||
args.push(arg);
|
||||
}
|
||||
}
|
||||
NetConnection(this.netConnections[this.attemptIndex]).connect.apply(this.netConnections[this.attemptIndex],args);
|
||||
}
|
||||
++this.attemptIndex;
|
||||
if(this.attemptIndex >= this.netConnectionURLs.length)
|
||||
{
|
||||
this.connectionTimer.stop();
|
||||
}
|
||||
}
|
||||
catch(ioError:IOError)
|
||||
{
|
||||
handleFailedConnectionSession(new MediaError(MediaErrorCodes.IO_ERROR,ioError.message),netConnectionURLs[attemptIndex]);
|
||||
}
|
||||
catch(argumentError:ArgumentError)
|
||||
{
|
||||
handleFailedConnectionSession(new MediaError(MediaErrorCodes.ARGUMENT_ERROR,argumentError.message),netConnectionURLs[attemptIndex]);
|
||||
}
|
||||
catch(securityError:SecurityError)
|
||||
{
|
||||
handleFailedConnectionSession(new MediaError(MediaErrorCodes.SECURITY_ERROR,securityError.message),netConnectionURLs[attemptIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
var index:int = 0;
|
||||
var tempTimer:Timer = null;
|
||||
var onTempTimer:Function = null;
|
||||
var event:NetStatusEvent = param1;
|
||||
switch(event.info.code)
|
||||
{
|
||||
case NetConnectionCodes.CONNECT_INVALIDAPP:
|
||||
this.handleFailedConnectionSession(new MediaError(MediaErrorCodes.NETCONNECTION_APPLICATION_INVALID,event.info.description),NetConnection(event.target).uri);
|
||||
break;
|
||||
case NetConnectionCodes.CONNECT_REJECTED:
|
||||
if(event.info.hasOwnProperty("ex") && event.info.ex.code == 302)
|
||||
{
|
||||
onTempTimer = function(param1:TimerEvent):void
|
||||
{
|
||||
tempTimer.removeEventListener(TimerEvent.TIMER,onTempTimer);
|
||||
tempTimer.stop();
|
||||
tryToConnect(null);
|
||||
};
|
||||
index = this.netConnections.indexOf(event.target as NetConnection);
|
||||
this.netConnectionURLs[index] = event.info.ex.redirect;
|
||||
this.attemptIndex = index;
|
||||
tempTimer = new Timer(100,1);
|
||||
tempTimer.addEventListener(TimerEvent.TIMER,onTempTimer);
|
||||
tempTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.handleFailedConnectionSession(new MediaError(MediaErrorCodes.NETCONNECTION_REJECTED,event.info.description),NetConnection(event.target).uri);
|
||||
}
|
||||
break;
|
||||
case NetConnectionCodes.CONNECT_FAILED:
|
||||
++this.failedConnectionCount;
|
||||
if(this.failedConnectionCount >= this.netConnectionURLs.length)
|
||||
{
|
||||
this.handleFailedConnectionSession(new MediaError(MediaErrorCodes.NETCONNECTION_FAILED),NetConnection(event.target).uri);
|
||||
}
|
||||
break;
|
||||
case NetConnectionCodes.CONNECT_SUCCESS:
|
||||
if(event.info.hasOwnProperty("data") && Boolean(event.info.data.hasOwnProperty("version")))
|
||||
{
|
||||
this.resource.addMetadataValue(MetadataNamespaces.FMS_SERVER_VERSION_METADATA,event.info.data.version);
|
||||
}
|
||||
this.shutDownUnsuccessfulConnections();
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_COMPLETE,false,false,event.currentTarget as NetConnection,this.resource));
|
||||
break;
|
||||
case "NetStream.Publish.Start":
|
||||
}
|
||||
}
|
||||
|
||||
private function shutDownUnsuccessfulConnections() : void
|
||||
{
|
||||
var _loc2_:NetConnection = null;
|
||||
this.timeOutTimer.stop();
|
||||
this.connectionTimer.stop();
|
||||
var _loc1_:int = 0;
|
||||
while(_loc1_ < this.netConnections.length)
|
||||
{
|
||||
_loc2_ = this.netConnections[_loc1_];
|
||||
if(!_loc2_.connected)
|
||||
{
|
||||
_loc2_.removeEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
_loc2_.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,this.onNetSecurityError);
|
||||
_loc2_.removeEventListener(AsyncErrorEvent.ASYNC_ERROR,this.onAsyncError);
|
||||
_loc2_.close();
|
||||
delete this.netConnections[_loc1_];
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function handleFailedConnectionSession(param1:MediaError, param2:String) : void
|
||||
{
|
||||
this.shutDownUnsuccessfulConnections();
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_ERROR,false,false,null,this.resource,param1));
|
||||
}
|
||||
|
||||
private function onNetSecurityError(param1:SecurityErrorEvent) : void
|
||||
{
|
||||
this.handleFailedConnectionSession(new MediaError(MediaErrorCodes.SECURITY_ERROR,param1.text),NetConnection(param1.target).uri);
|
||||
}
|
||||
|
||||
private function onAsyncError(param1:AsyncErrorEvent) : void
|
||||
{
|
||||
this.handleFailedConnectionSession(new MediaError(MediaErrorCodes.ASYNC_ERROR,param1.text),NetConnection(param1.target).uri);
|
||||
}
|
||||
|
||||
private function masterTimeout(param1:TimerEvent) : void
|
||||
{
|
||||
this.handleFailedConnectionSession(new MediaError(MediaErrorCodes.NETCONNECTION_TIMEOUT,"" + this._timeout),"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.media.SoundTransform;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.traits.AudioTrait;
|
||||
|
||||
public class NetStreamAudioTrait extends AudioTrait
|
||||
{
|
||||
|
||||
private var netStream:NetStream;
|
||||
|
||||
public function NetStreamAudioTrait(param1:NetStream)
|
||||
{
|
||||
super();
|
||||
this.netStream = param1;
|
||||
}
|
||||
|
||||
override protected function volumeChangeStart(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.netStream.soundTransform;
|
||||
_loc2_.volume = muted ? 0 : param1;
|
||||
this.netStream.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function mutedChangeStart(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.netStream.soundTransform;
|
||||
_loc2_.volume = param1 ? 0 : volume;
|
||||
this.netStream.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function panChangeStart(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.netStream.soundTransform;
|
||||
_loc2_.pan = param1;
|
||||
this.netStream.soundTransform = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetStream;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.traits.BufferTrait;
|
||||
|
||||
public class NetStreamBufferTrait extends BufferTrait
|
||||
{
|
||||
|
||||
private var netStream:NetStream;
|
||||
|
||||
private var changeBufferLengthTimer:Timer;
|
||||
|
||||
public function NetStreamBufferTrait(param1:NetStream)
|
||||
{
|
||||
super();
|
||||
this.netStream = param1;
|
||||
bufferTime = param1.bufferTime;
|
||||
param1.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus,false,0,true);
|
||||
this.changeBufferLengthTimer = new Timer(250);
|
||||
this.changeBufferLengthTimer.addEventListener(TimerEvent.TIMER,this.onChangeBufferLength,false,0,true);
|
||||
this.changeBufferLengthTimer.start();
|
||||
}
|
||||
|
||||
override public function get bufferLength() : Number
|
||||
{
|
||||
return this.netStream.bufferLength;
|
||||
}
|
||||
|
||||
override protected function bufferTimeChangeStart(param1:Number) : void
|
||||
{
|
||||
this.netStream.bufferTime = param1;
|
||||
}
|
||||
|
||||
private function onChangeBufferLength(param1:TimerEvent) : void
|
||||
{
|
||||
setBufferLength(this.netStream.bufferLength);
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_START:
|
||||
case NetStreamCodes.NETSTREAM_BUFFER_EMPTY:
|
||||
bufferTime = this.netStream.bufferTime;
|
||||
setBuffering(true);
|
||||
if(this.netStream.bufferTime == 0)
|
||||
{
|
||||
setBuffering(false);
|
||||
}
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_BUFFER_FLUSH:
|
||||
case NetStreamCodes.NETSTREAM_BUFFER_FULL:
|
||||
setBuffering(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
public final class NetStreamCodes
|
||||
{
|
||||
|
||||
public static const NETSTREAM_BUFFER_EMPTY:String = "NetStream.Buffer.Empty";
|
||||
|
||||
public static const NETSTREAM_BUFFER_FULL:String = "NetStream.Buffer.Full";
|
||||
|
||||
public static const NETSTREAM_BUFFER_FLUSH:String = "NetStream.Buffer.Flush";
|
||||
|
||||
public static const NETSTREAM_FAILED:String = "NetStream.Failed";
|
||||
|
||||
public static const NETSTREAM_PLAY_START:String = "NetStream.Play.Start";
|
||||
|
||||
public static const NETSTREAM_PLAY_STOP:String = "NetStream.Play.Stop";
|
||||
|
||||
public static const NETSTREAM_PLAY_FAILED:String = "NetStream.Play.Failed";
|
||||
|
||||
public static const NETSTREAM_PLAY_STREAMNOTFOUND:String = "NetStream.Play.StreamNotFound";
|
||||
|
||||
public static const NETSTREAM_PLAY_RESET:String = "NetStream.Play.Reset";
|
||||
|
||||
public static const NETSTREAM_PLAY_INSUFFICIENTBW:String = "NetStream.Play.InsufficientBW";
|
||||
|
||||
public static const NETSTREAM_PLAY_FILESTRUCTUREINVALID:String = "NetStream.Play.FileStructureInvalid";
|
||||
|
||||
public static const NETSTREAM_PLAY_NOSUPPORTEDTRACKFOUND:String = "NetStream.Play.NoSupportedTrackFound";
|
||||
|
||||
public static const NETSTREAM_PLAY_TRANSITION:String = "NetStream.Play.Transition";
|
||||
|
||||
public static const NETSTREAM_PAUSE_NOTIFY:String = "NetStream.Pause.Notify";
|
||||
|
||||
public static const NETSTREAM_PLAY_PUBLISH_NOTIFY:String = "NetStream.Play.PublishNotify";
|
||||
|
||||
public static const NETSTREAM_PLAY_UNPUBLISH_NOTIFY:String = "NetStream.Play.UnpublishNotify";
|
||||
|
||||
public static const NETSTREAM_UNPAUSE_NOTIFY:String = "NetStream.Unpause.Notify";
|
||||
|
||||
public static const NETSTREAM_SEEK_FAILED:String = "NetStream.Seek.Failed";
|
||||
|
||||
public static const NETSTREAM_SEEK_INVALIDTIME:String = "NetStream.Seek.InvalidTime";
|
||||
|
||||
public static const NETSTREAM_SEEK_NOTIFY:String = "NetStream.Seek.Notify";
|
||||
|
||||
public static const NETSTREAM_PLAY_COMPLETE:String = "NetStream.Play.Complete";
|
||||
|
||||
public static const NETSTREAM_PLAY_TRANSITION_COMPLETE:String = "NetStream.Play.TransitionComplete";
|
||||
|
||||
public static const ON_META_DATA:String = "onMetaData";
|
||||
|
||||
public static const ON_CUE_POINT:String = "onCuePoint";
|
||||
|
||||
public static const ON_PLAY_STATUS:String = "onPlayStatus";
|
||||
|
||||
public static const NETSTREAM_DRM_UPDATE:String = "DRM.UpdateNeeded";
|
||||
|
||||
public function NetStreamCodes()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.events.Event;
|
||||
import flash.media.Video;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.traits.DisplayObjectTrait;
|
||||
|
||||
public class NetStreamDisplayObjectTrait extends DisplayObjectTrait
|
||||
{
|
||||
|
||||
private var netStream:NetStream;
|
||||
|
||||
public function NetStreamDisplayObjectTrait(param1:NetStream, param2:DisplayObject, param3:Number = 0, param4:Number = 0)
|
||||
{
|
||||
super(param2,param3,param4);
|
||||
this.netStream = param1;
|
||||
NetClient(param1.client).addHandler(NetStreamCodes.ON_META_DATA,this.onMetaData);
|
||||
if(param2 is Video)
|
||||
{
|
||||
param2.addEventListener(Event.ADDED_TO_STAGE,this.onStage);
|
||||
}
|
||||
}
|
||||
|
||||
private function onStage(param1:Event) : void
|
||||
{
|
||||
displayObject.removeEventListener(Event.ADDED_TO_STAGE,this.onStage);
|
||||
displayObject.addEventListener(Event.ENTER_FRAME,this.onFrame);
|
||||
}
|
||||
|
||||
private function onFrame(param1:Event) : void
|
||||
{
|
||||
if(Video(displayObject).videoWidth != 0 && Video(displayObject).videoHeight != 0)
|
||||
{
|
||||
if(Video(displayObject).videoWidth != mediaWidth && Video(displayObject).videoHeight != mediaHeight)
|
||||
{
|
||||
this.newMediaSize(Video(displayObject).videoWidth,Video(displayObject).videoHeight);
|
||||
}
|
||||
displayObject.removeEventListener(Event.ENTER_FRAME,this.onFrame);
|
||||
}
|
||||
}
|
||||
|
||||
private function onMetaData(param1:Object) : void
|
||||
{
|
||||
if(!isNaN(param1.width) && !isNaN(param1.height) && (param1.width != mediaWidth || param1.height != mediaHeight))
|
||||
{
|
||||
this.newMediaSize(param1.width,param1.height);
|
||||
}
|
||||
}
|
||||
|
||||
private function newMediaSize(param1:Number, param2:Number) : void
|
||||
{
|
||||
if(displayObject.width == 0 && displayObject.height == 0)
|
||||
{
|
||||
displayObject.width = param1;
|
||||
displayObject.height = param2;
|
||||
}
|
||||
setMediaSize(param1,param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.traits.DynamicStreamTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class NetStreamDynamicStreamTrait extends DynamicStreamTrait
|
||||
{
|
||||
|
||||
private var netStream:NetStream;
|
||||
|
||||
private var switchManager:NetStreamSwitchManagerBase;
|
||||
|
||||
private var inSetSwitching:Boolean;
|
||||
|
||||
private var dsResource:DynamicStreamingResource;
|
||||
|
||||
private var indexToSwitchTo:int;
|
||||
|
||||
public function NetStreamDynamicStreamTrait(param1:NetStream, param2:NetStreamSwitchManagerBase, param3:DynamicStreamingResource)
|
||||
{
|
||||
super(param2.autoSwitch,param2.currentIndex,param3.streamItems.length);
|
||||
this.netStream = param1;
|
||||
this.switchManager = param2;
|
||||
this.dsResource = param3;
|
||||
param1.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
NetClient(param1.client).addHandler(NetStreamCodes.ON_PLAY_STATUS,this.onPlayStatus);
|
||||
}
|
||||
|
||||
override public function dispose() : void
|
||||
{
|
||||
this.netStream = null;
|
||||
this.switchManager = null;
|
||||
}
|
||||
|
||||
override public function getBitrateForIndex(param1:int) : Number
|
||||
{
|
||||
if(param1 > numDynamicStreams - 1 || param1 < 0)
|
||||
{
|
||||
throw new RangeError(OSMFStrings.getString(OSMFStrings.STREAMSWITCH_INVALID_INDEX));
|
||||
}
|
||||
return this.dsResource.streamItems[param1].bitrate;
|
||||
}
|
||||
|
||||
override protected function switchingChangeStart(param1:Boolean, param2:int) : void
|
||||
{
|
||||
if(param1 && !this.inSetSwitching)
|
||||
{
|
||||
this.indexToSwitchTo = param2;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function switchingChangeEnd(param1:int) : void
|
||||
{
|
||||
super.switchingChangeEnd(param1);
|
||||
if(switching && !this.inSetSwitching)
|
||||
{
|
||||
this.switchManager.switchTo(this.indexToSwitchTo);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function autoSwitchChangeStart(param1:Boolean) : void
|
||||
{
|
||||
this.switchManager.autoSwitch = param1;
|
||||
}
|
||||
|
||||
override protected function maxAllowedIndexChangeStart(param1:int) : void
|
||||
{
|
||||
this.switchManager.maxAllowedIndex = param1;
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_TRANSITION:
|
||||
this.inSetSwitching = true;
|
||||
setSwitching(true,this.dsResource.indexFromName(param1.info.details));
|
||||
this.inSetSwitching = false;
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_FAILED:
|
||||
setSwitching(false,currentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private function onPlayStatus(param1:Object) : void
|
||||
{
|
||||
switch(param1.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_TRANSITION_COMPLETE:
|
||||
setSwitching(false,this.switchManager.currentIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetGroup;
|
||||
import flash.net.NetStream;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class NetStreamLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var _connection:NetConnection;
|
||||
|
||||
private var _switchManager:NetStreamSwitchManagerBase;
|
||||
|
||||
private var traits:Dictionary = new Dictionary();
|
||||
|
||||
private var _netConnectionFactory:NetConnectionFactoryBase;
|
||||
|
||||
private var isStreamingResource:Boolean;
|
||||
|
||||
private var _netStream:NetStream;
|
||||
|
||||
private var _netGroup:NetGroup;
|
||||
|
||||
public function NetStreamLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1,param2);
|
||||
this.isStreamingResource = NetStreamUtils.isStreamingResource(param2);
|
||||
}
|
||||
|
||||
public function get connection() : NetConnection
|
||||
{
|
||||
return this._connection;
|
||||
}
|
||||
|
||||
public function set connection(param1:NetConnection) : void
|
||||
{
|
||||
this._connection = param1;
|
||||
}
|
||||
|
||||
public function get netStream() : NetStream
|
||||
{
|
||||
return this._netStream;
|
||||
}
|
||||
|
||||
public function set netStream(param1:NetStream) : void
|
||||
{
|
||||
this._netStream = param1;
|
||||
}
|
||||
|
||||
public function get switchManager() : NetStreamSwitchManagerBase
|
||||
{
|
||||
return this._switchManager;
|
||||
}
|
||||
|
||||
public function set switchManager(param1:NetStreamSwitchManagerBase) : void
|
||||
{
|
||||
this._switchManager = param1;
|
||||
}
|
||||
|
||||
public function setTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
this.traits[param1.traitType] = param1;
|
||||
}
|
||||
|
||||
public function getTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
return this.traits[param1];
|
||||
}
|
||||
|
||||
public function get netConnectionFactory() : NetConnectionFactoryBase
|
||||
{
|
||||
return this._netConnectionFactory;
|
||||
}
|
||||
|
||||
public function set netConnectionFactory(param1:NetConnectionFactoryBase) : void
|
||||
{
|
||||
this._netConnectionFactory = param1;
|
||||
}
|
||||
|
||||
override protected function loadStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == LoadState.READY)
|
||||
{
|
||||
if(!this.isStreamingResource && (this.netStream.bytesTotal <= 0 || this.netStream.bytesTotal == uint.MAX_VALUE))
|
||||
{
|
||||
this.netStream.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
}
|
||||
}
|
||||
else if(param1 == LoadState.UNINITIALIZED)
|
||||
{
|
||||
this.netStream = null;
|
||||
dispatchEvent(new LoadEvent(LoadEvent.BYTES_LOADED_CHANGE,false,false,null,this.bytesLoaded));
|
||||
dispatchEvent(new LoadEvent(LoadEvent.BYTES_TOTAL_CHANGE,false,false,null,this.bytesTotal));
|
||||
}
|
||||
}
|
||||
|
||||
override public function get bytesLoaded() : Number
|
||||
{
|
||||
return this.isStreamingResource ? NaN : (this.netStream != null ? this.netStream.bytesLoaded : NaN);
|
||||
}
|
||||
|
||||
override public function get bytesTotal() : Number
|
||||
{
|
||||
return this.isStreamingResource ? NaN : (this.netStream != null ? this.netStream.bytesTotal : NaN);
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
if(this.netStream != null && this.netStream.bytesTotal > 0)
|
||||
{
|
||||
dispatchEvent(new LoadEvent(LoadEvent.BYTES_TOTAL_CHANGE,false,false,null,this.netStream.bytesTotal));
|
||||
this.netStream.removeEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
}
|
||||
}
|
||||
|
||||
public function get netGroup() : NetGroup
|
||||
{
|
||||
return this._netGroup;
|
||||
}
|
||||
|
||||
public function set netGroup(param1:NetGroup) : void
|
||||
{
|
||||
this._netGroup = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetStream;
|
||||
import flash.utils.Timer;
|
||||
|
||||
public class NetStreamMetricsBase extends EventDispatcher
|
||||
{
|
||||
|
||||
private static const DEFAULT_UPDATE_INTERVAL:Number = 100;
|
||||
|
||||
private static const DEFAULT_AVG_FRAMERATE_SAMPLE_SIZE:Number = 50;
|
||||
|
||||
private var _netStream:NetStream;
|
||||
|
||||
private var _resource:DynamicStreamingResource;
|
||||
|
||||
private var _currentIndex:int;
|
||||
|
||||
private var _maxAllowedIndex:int;
|
||||
|
||||
private var _timer:Timer;
|
||||
|
||||
private var _averageDroppedFPSArray:Array;
|
||||
|
||||
private var _averageDroppedFPS:Number;
|
||||
|
||||
private var _droppedFPS:Number;
|
||||
|
||||
private var _lastFrameDropValue:Number;
|
||||
|
||||
private var _lastFrameDropCounter:Number;
|
||||
|
||||
private var _maxFPS:Number;
|
||||
|
||||
public function NetStreamMetricsBase(param1:NetStream)
|
||||
{
|
||||
super();
|
||||
this._netStream = param1;
|
||||
this._droppedFPS = 0;
|
||||
this._lastFrameDropCounter = 0;
|
||||
this._lastFrameDropValue = 0;
|
||||
this._maxFPS = 0;
|
||||
this._averageDroppedFPSArray = new Array();
|
||||
this._timer = new Timer(DEFAULT_UPDATE_INTERVAL);
|
||||
this._timer.addEventListener(TimerEvent.TIMER,this.onTimerEvent);
|
||||
param1.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent);
|
||||
}
|
||||
|
||||
public function get resource() : DynamicStreamingResource
|
||||
{
|
||||
return this._resource;
|
||||
}
|
||||
|
||||
public function set resource(param1:DynamicStreamingResource) : void
|
||||
{
|
||||
this._resource = param1;
|
||||
this._maxAllowedIndex = param1 != null ? int(param1.streamItems.length - 1) : 0;
|
||||
}
|
||||
|
||||
public function get netStream() : NetStream
|
||||
{
|
||||
return this._netStream;
|
||||
}
|
||||
|
||||
public function get currentIndex() : int
|
||||
{
|
||||
return this._currentIndex;
|
||||
}
|
||||
|
||||
public function set currentIndex(param1:int) : void
|
||||
{
|
||||
this._currentIndex = param1;
|
||||
}
|
||||
|
||||
public function get maxAllowedIndex() : int
|
||||
{
|
||||
return this._maxAllowedIndex;
|
||||
}
|
||||
|
||||
public function set maxAllowedIndex(param1:int) : void
|
||||
{
|
||||
this._maxAllowedIndex = param1;
|
||||
}
|
||||
|
||||
public function get updateInterval() : Number
|
||||
{
|
||||
return this._timer.delay;
|
||||
}
|
||||
|
||||
public function set updateInterval(param1:Number) : void
|
||||
{
|
||||
this._timer.delay = param1;
|
||||
if(param1 <= 0)
|
||||
{
|
||||
this._timer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public function get maxFPS() : Number
|
||||
{
|
||||
return this._maxFPS;
|
||||
}
|
||||
|
||||
public function get droppedFPS() : Number
|
||||
{
|
||||
return this._droppedFPS;
|
||||
}
|
||||
|
||||
public function get averageDroppedFPS() : Number
|
||||
{
|
||||
return this._averageDroppedFPS;
|
||||
}
|
||||
|
||||
protected function calculateMetrics() : void
|
||||
{
|
||||
var totalDroppedFrameRate:Number = NaN;
|
||||
var f:uint = 0;
|
||||
try
|
||||
{
|
||||
this._maxFPS = this.netStream.currentFPS > this._maxFPS ? this.netStream.currentFPS : this._maxFPS;
|
||||
if(this._timer.currentCount - this._lastFrameDropCounter > 1000 / this._timer.delay)
|
||||
{
|
||||
this._droppedFPS = (this.netStream.info.droppedFrames - this._lastFrameDropValue) / ((this._timer.currentCount - this._lastFrameDropCounter) * this._timer.delay / 1000);
|
||||
this._lastFrameDropCounter = this._timer.currentCount;
|
||||
this._lastFrameDropValue = this.netStream.info.droppedFrames;
|
||||
}
|
||||
this._averageDroppedFPSArray.unshift(this._droppedFPS);
|
||||
if(this._averageDroppedFPSArray.length > DEFAULT_AVG_FRAMERATE_SAMPLE_SIZE)
|
||||
{
|
||||
this._averageDroppedFPSArray.pop();
|
||||
}
|
||||
totalDroppedFrameRate = 0;
|
||||
f = 0;
|
||||
while(f < this._averageDroppedFPSArray.length)
|
||||
{
|
||||
totalDroppedFrameRate += this._averageDroppedFPSArray[f];
|
||||
f++;
|
||||
}
|
||||
this._averageDroppedFPS = this._averageDroppedFPSArray.length < DEFAULT_AVG_FRAMERATE_SAMPLE_SIZE ? 0 : totalDroppedFrameRate / this._averageDroppedFPSArray.length;
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private function onNetStatusEvent(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_START:
|
||||
if(!this._timer.running && this.updateInterval > 0)
|
||||
{
|
||||
this._timer.start();
|
||||
}
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_STOP:
|
||||
this._timer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private function onTimerEvent(param1:TimerEvent) : void
|
||||
{
|
||||
if(isNaN(this.netStream.time))
|
||||
{
|
||||
this._timer.stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.calculateMetrics();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.net.NetStreamPlayOptions;
|
||||
import flash.net.NetStreamPlayTransitions;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.PlayState;
|
||||
import org.osmf.traits.PlayTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class NetStreamPlayTrait extends PlayTrait
|
||||
{
|
||||
|
||||
private static const NETCONNECTION_FAILURE_ERROR_CODE:int = 2154;
|
||||
|
||||
private var streamStarted:Boolean;
|
||||
|
||||
private var netStream:NetStream;
|
||||
|
||||
private var netConnection:NetConnection;
|
||||
|
||||
private var urlResource:URLResource;
|
||||
|
||||
private var multicastResource:MulticastResource;
|
||||
|
||||
private var reconnectStreams:Boolean;
|
||||
|
||||
public function NetStreamPlayTrait(param1:NetStream, param2:MediaResourceBase, param3:Boolean, param4:NetConnection)
|
||||
{
|
||||
super();
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
this.netStream = param1;
|
||||
this.netConnection = param4;
|
||||
this.urlResource = param2 as URLResource;
|
||||
this.multicastResource = param2 as MulticastResource;
|
||||
this.reconnectStreams = param3;
|
||||
param1.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus,false,1,true);
|
||||
NetClient(param1.client).addHandler(NetStreamCodes.ON_PLAY_STATUS,this.onPlayStatus,1);
|
||||
}
|
||||
|
||||
override protected function playStateChangeStart(param1:String) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc3_:StreamingURLResource = null;
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc5_:String = null;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:DynamicStreamingResource = null;
|
||||
var _loc9_:NetStreamPlayOptions = null;
|
||||
if(param1 == PlayState.PLAYING)
|
||||
{
|
||||
if(this.streamStarted)
|
||||
{
|
||||
if(this.multicastResource != null)
|
||||
{
|
||||
this.netStream.play(this.multicastResource.streamName,-1,-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.netStream.resume();
|
||||
}
|
||||
}
|
||||
else if(this.urlResource != null)
|
||||
{
|
||||
_loc3_ = this.urlResource as StreamingURLResource;
|
||||
_loc4_ = _loc3_ ? _loc3_.urlIncludesFMSApplicationInstance : false;
|
||||
_loc5_ = NetStreamUtils.getStreamNameFromURL(this.urlResource.url,_loc4_);
|
||||
_loc2_ = NetStreamUtils.getPlayArgsForResource(this.urlResource);
|
||||
_loc6_ = Number(_loc2_.start);
|
||||
_loc7_ = Number(_loc2_.len);
|
||||
_loc8_ = this.urlResource as DynamicStreamingResource;
|
||||
if(_loc8_ != null)
|
||||
{
|
||||
_loc9_ = new NetStreamPlayOptions();
|
||||
_loc9_.start = _loc6_;
|
||||
_loc9_.len = _loc7_;
|
||||
_loc9_.streamName = _loc8_.streamItems[_loc8_.initialIndex].streamName;
|
||||
_loc9_.transition = NetStreamPlayTransitions.RESET;
|
||||
this.doPlay2(_loc9_);
|
||||
}
|
||||
else if(this.reconnectStreams && _loc3_ != null && NetStreamUtils.isRTMPStream(_loc3_.url))
|
||||
{
|
||||
_loc9_ = new NetStreamPlayOptions();
|
||||
_loc9_.start = _loc6_;
|
||||
_loc9_.len = _loc7_;
|
||||
_loc9_.transition = NetStreamPlayTransitions.RESET;
|
||||
_loc9_.streamName = _loc5_;
|
||||
this.doPlay2(_loc9_);
|
||||
}
|
||||
else if(this.multicastResource != null && this.multicastResource.groupspec != null && this.multicastResource.groupspec.length > 0)
|
||||
{
|
||||
this.doPlay(this.multicastResource.streamName,_loc6_,_loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.doPlay(_loc5_,_loc6_,_loc7_);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this.multicastResource != null)
|
||||
{
|
||||
this.netStream.play(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.netStream.pause();
|
||||
}
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_FAILED:
|
||||
case NetStreamCodes.NETSTREAM_PLAY_FILESTRUCTUREINVALID:
|
||||
case NetStreamCodes.NETSTREAM_PLAY_STREAMNOTFOUND:
|
||||
case NetStreamCodes.NETSTREAM_PLAY_NOSUPPORTEDTRACKFOUND:
|
||||
case NetStreamCodes.NETSTREAM_FAILED:
|
||||
this.netStream.pause();
|
||||
this.streamStarted = false;
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_STOP:
|
||||
if(this.urlResource != null && NetStreamUtils.isStreamingResource(this.urlResource) == false)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onPlayStatus(param1:Object) : void
|
||||
{
|
||||
switch(param1.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_COMPLETE:
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
private function doPlay(... rest) : void
|
||||
{
|
||||
var args:Array = rest;
|
||||
try
|
||||
{
|
||||
this.netStream.play.apply(this,args);
|
||||
this.streamStarted = true;
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
streamStarted = false;
|
||||
stop();
|
||||
dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.NETSTREAM_PLAY_FAILED)));
|
||||
}
|
||||
}
|
||||
|
||||
private function doPlay2(param1:NetStreamPlayOptions) : void
|
||||
{
|
||||
this.netStream.play2(param1);
|
||||
this.streamStarted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.media.Video;
|
||||
import flash.net.NetStream;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.SeekTrait;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class NetStreamSeekTrait extends SeekTrait
|
||||
{
|
||||
|
||||
private var video:Video;
|
||||
|
||||
private var loadTrait:LoadTrait;
|
||||
|
||||
private var audioDelay:Number = 0;
|
||||
|
||||
private var seekBugTimer:Timer;
|
||||
|
||||
private var netStream:NetStream;
|
||||
|
||||
private var expectedTime:Number;
|
||||
|
||||
private var previousTime:Number;
|
||||
|
||||
private var suppressSeekNotifyEvent:Boolean = false;
|
||||
|
||||
public function NetStreamSeekTrait(param1:TimeTrait, param2:LoadTrait, param3:NetStream, param4:Video = null)
|
||||
{
|
||||
super(param1);
|
||||
this.netStream = param3;
|
||||
this.video = param4;
|
||||
this.loadTrait = param2;
|
||||
NetClient(param3.client).addHandler(NetStreamCodes.ON_META_DATA,this.onMetaData);
|
||||
param3.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
this.seekBugTimer = new Timer(10,100);
|
||||
this.seekBugTimer.addEventListener(TimerEvent.TIMER,this.onSeekBugTimer,false,0,true);
|
||||
this.seekBugTimer.addEventListener(TimerEvent.TIMER_COMPLETE,this.onSeekBugTimerDone,false,0,true);
|
||||
}
|
||||
|
||||
override public function canSeekTo(param1:Number) : Boolean
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc2_:Boolean = super.canSeekTo(param1);
|
||||
if(_loc2_ && !isNaN(this.loadTrait.bytesTotal) && this.loadTrait.bytesTotal > 0)
|
||||
{
|
||||
_loc3_ = timeTrait.duration * Number(this.loadTrait.bytesLoaded / this.loadTrait.bytesTotal);
|
||||
_loc2_ = param1 <= _loc3_;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override protected function seekingChangeStart(param1:Boolean, param2:Number) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this.suppressSeekNotifyEvent = false;
|
||||
this.previousTime = this.netStream.time - this.audioDelay;
|
||||
this.expectedTime = param2;
|
||||
this.netStream.seek(param2 + this.audioDelay);
|
||||
if(this.previousTime == this.expectedTime)
|
||||
{
|
||||
this.seekBugTimer.start();
|
||||
this.suppressSeekNotifyEvent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function seekingChangeEnd(param1:Number) : void
|
||||
{
|
||||
var _loc2_:NetStreamTimeTrait = null;
|
||||
super.seekingChangeEnd(param1);
|
||||
if(seeking == true && this.video != null)
|
||||
{
|
||||
_loc2_ = timeTrait as NetStreamTimeTrait;
|
||||
if(_loc2_ != null && _loc2_.currentTime + _loc2_.audioDelay >= _loc2_.duration)
|
||||
{
|
||||
this.video.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onMetaData(param1:Object) : void
|
||||
{
|
||||
this.audioDelay = param1.hasOwnProperty("audiodelay") ? Number(param1.audiodelay) : 0;
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_SEEK_NOTIFY:
|
||||
this.runSeekBugTimer();
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_SEEK_INVALIDTIME:
|
||||
case NetStreamCodes.NETSTREAM_SEEK_FAILED:
|
||||
setSeeking(false,this.previousTime);
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_START:
|
||||
case NetStreamCodes.NETSTREAM_PLAY_RESET:
|
||||
case NetStreamCodes.NETSTREAM_PAUSE_NOTIFY:
|
||||
case NetStreamCodes.NETSTREAM_PLAY_STOP:
|
||||
case NetStreamCodes.NETSTREAM_UNPAUSE_NOTIFY:
|
||||
if(seeking && this.seekBugTimer.running == false)
|
||||
{
|
||||
this.runSeekBugTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function runSeekBugTimer() : void
|
||||
{
|
||||
if(this.suppressSeekNotifyEvent == false)
|
||||
{
|
||||
this.seekBugTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.suppressSeekNotifyEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function onSeekBugTimer(param1:TimerEvent) : void
|
||||
{
|
||||
if(this.previousTime != this.netStream.time - this.audioDelay || this.previousTime == this.expectedTime)
|
||||
{
|
||||
this.onSeekBugTimerDone(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onSeekBugTimerDone(param1:TimerEvent) : void
|
||||
{
|
||||
this.seekBugTimer.reset();
|
||||
setSeeking(false,this.expectedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.net.NetStreamPlayOptions;
|
||||
import flash.net.NetStreamPlayTransitions;
|
||||
import flash.utils.Dictionary;
|
||||
import flash.utils.Timer;
|
||||
import flash.utils.getTimer;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class NetStreamSwitchManager extends NetStreamSwitchManagerBase
|
||||
{
|
||||
|
||||
private static const RULE_CHECK_INTERVAL:Number = 500;
|
||||
|
||||
private static const DEFAULT_MAX_UP_SWITCHES_PER_STREAM_ITEM:int = 3;
|
||||
|
||||
private static const DEFAULT_WAIT_DURATION_AFTER_DOWN_SWITCH:int = 30000;
|
||||
|
||||
private static const DEFAULT_CLEAR_FAILED_COUNTS_INTERVAL:Number = 300000;
|
||||
|
||||
private var netStream:NetStream;
|
||||
|
||||
private var dsResource:DynamicStreamingResource;
|
||||
|
||||
private var switchingRules:Vector.<SwitchingRuleBase>;
|
||||
|
||||
private var metrics:NetStreamMetricsBase;
|
||||
|
||||
private var checkRulesTimer:Timer;
|
||||
|
||||
private var clearFailedCountsTimer:Timer;
|
||||
|
||||
private var actualIndex:int = -1;
|
||||
|
||||
private var oldStreamName:String;
|
||||
|
||||
private var switching:Boolean;
|
||||
|
||||
private var _currentIndex:int;
|
||||
|
||||
private var lastTransitionIndex:int = -1;
|
||||
|
||||
private var connection:NetConnection;
|
||||
|
||||
private var dsiFailedCounts:Vector.<int>;
|
||||
|
||||
private var failedDSI:Dictionary;
|
||||
|
||||
private var _bandwidthLimit:Number = 0;
|
||||
|
||||
public function NetStreamSwitchManager(param1:NetConnection, param2:NetStream, param3:DynamicStreamingResource, param4:NetStreamMetricsBase, param5:Vector.<SwitchingRuleBase>)
|
||||
{
|
||||
super();
|
||||
this.connection = param1;
|
||||
this.netStream = param2;
|
||||
this.dsResource = param3;
|
||||
this.metrics = param4;
|
||||
this.switchingRules = param5 || new Vector.<SwitchingRuleBase>();
|
||||
this._currentIndex = Math.max(0,Math.min(this.maxAllowedIndex,this.dsResource.initialIndex));
|
||||
this.checkRulesTimer = new Timer(RULE_CHECK_INTERVAL);
|
||||
this.checkRulesTimer.addEventListener(TimerEvent.TIMER,this.checkRules);
|
||||
this.failedDSI = new Dictionary();
|
||||
this._bandwidthLimit = 1.4 * param3.streamItems[param3.streamItems.length - 1].bitrate * 1000 / 8;
|
||||
param2.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
NetClient(param2.client).addHandler(NetStreamCodes.ON_PLAY_STATUS,this.onPlayStatus,int.MAX_VALUE);
|
||||
}
|
||||
|
||||
override public function set autoSwitch(param1:Boolean) : void
|
||||
{
|
||||
super.autoSwitch = param1;
|
||||
if(autoSwitch)
|
||||
{
|
||||
this.checkRulesTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.checkRulesTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
override public function get currentIndex() : uint
|
||||
{
|
||||
return this._currentIndex;
|
||||
}
|
||||
|
||||
override public function get maxAllowedIndex() : int
|
||||
{
|
||||
var _loc1_:int = this.dsResource.streamItems.length - 1;
|
||||
return _loc1_ < super.maxAllowedIndex ? _loc1_ : super.maxAllowedIndex;
|
||||
}
|
||||
|
||||
override public function set maxAllowedIndex(param1:int) : void
|
||||
{
|
||||
if(param1 > this.dsResource.streamItems.length)
|
||||
{
|
||||
throw new RangeError(OSMFStrings.getString(OSMFStrings.STREAMSWITCH_INVALID_INDEX));
|
||||
}
|
||||
super.maxAllowedIndex = param1;
|
||||
this.metrics.maxAllowedIndex = param1;
|
||||
}
|
||||
|
||||
override public function switchTo(param1:int) : void
|
||||
{
|
||||
if(!autoSwitch)
|
||||
{
|
||||
if(param1 < 0 || param1 > this.maxAllowedIndex)
|
||||
{
|
||||
throw new RangeError(OSMFStrings.getString(OSMFStrings.STREAMSWITCH_INVALID_INDEX));
|
||||
}
|
||||
if(this.actualIndex == -1)
|
||||
{
|
||||
this.prepareForSwitching();
|
||||
}
|
||||
this.executeSwitch(param1);
|
||||
return;
|
||||
}
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.STREAMSWITCH_STREAM_NOT_IN_MANUAL_MODE));
|
||||
}
|
||||
|
||||
protected function canAutoSwitchNow(param1:int) : Boolean
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(this.dsiFailedCounts[param1] >= 1)
|
||||
{
|
||||
_loc2_ = getTimer();
|
||||
if(_loc2_ - this.failedDSI[param1] < DEFAULT_WAIT_DURATION_AFTER_DOWN_SWITCH)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(this.dsiFailedCounts[param1] > DEFAULT_MAX_UP_SWITCHES_PER_STREAM_ITEM)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
final protected function get bandwidthLimit() : Number
|
||||
{
|
||||
return this._bandwidthLimit;
|
||||
}
|
||||
|
||||
final protected function set bandwidthLimit(param1:Number) : void
|
||||
{
|
||||
this._bandwidthLimit = param1;
|
||||
}
|
||||
|
||||
private function executeSwitch(param1:int) : void
|
||||
{
|
||||
var _loc2_:NetStreamPlayOptions = new NetStreamPlayOptions();
|
||||
var _loc3_:Object = NetStreamUtils.getPlayArgsForResource(this.dsResource);
|
||||
_loc2_.start = _loc3_.start;
|
||||
_loc2_.len = _loc3_.len;
|
||||
_loc2_.streamName = this.dsResource.streamItems[param1].streamName;
|
||||
var _loc4_:String = this.oldStreamName;
|
||||
if(_loc4_ != null && _loc4_.indexOf("?") >= 0)
|
||||
{
|
||||
_loc2_.oldStreamName = _loc4_.substr(0,_loc4_.indexOf("?"));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.oldStreamName = this.oldStreamName;
|
||||
}
|
||||
_loc2_.transition = NetStreamPlayTransitions.SWITCH;
|
||||
this.switching = true;
|
||||
this.netStream.play2(_loc2_);
|
||||
this.oldStreamName = this.dsResource.streamItems[param1].streamName;
|
||||
if(param1 < this.actualIndex && autoSwitch)
|
||||
{
|
||||
this.incrementDSIFailedCount(this.actualIndex);
|
||||
this.failedDSI[this.actualIndex] = getTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private function checkRules(param1:TimerEvent) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
if(this.switchingRules == null || this.switching)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc2_:int = int.MAX_VALUE;
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < this.switchingRules.length)
|
||||
{
|
||||
_loc4_ = this.switchingRules[_loc3_].getNewIndex();
|
||||
if(_loc4_ != -1 && _loc4_ < _loc2_)
|
||||
{
|
||||
_loc2_ = _loc4_;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(_loc2_ != -1 && _loc2_ != int.MAX_VALUE && _loc2_ != this.actualIndex)
|
||||
{
|
||||
_loc2_ = Math.min(_loc2_,this.maxAllowedIndex);
|
||||
}
|
||||
if(_loc2_ != -1 && _loc2_ != int.MAX_VALUE && _loc2_ != this.actualIndex && !this.switching && _loc2_ <= this.maxAllowedIndex && this.canAutoSwitchNow(_loc2_))
|
||||
{
|
||||
this.executeSwitch(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_START:
|
||||
if(this.actualIndex == -1)
|
||||
{
|
||||
this.prepareForSwitching();
|
||||
}
|
||||
else if(autoSwitch && this.checkRulesTimer.running == false)
|
||||
{
|
||||
this.checkRulesTimer.start();
|
||||
}
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_TRANSITION:
|
||||
this.switching = false;
|
||||
this.actualIndex = this.dsResource.indexFromName(param1.info.details);
|
||||
this.metrics.currentIndex = this.actualIndex;
|
||||
this.lastTransitionIndex = this.actualIndex;
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_FAILED:
|
||||
this.switching = false;
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_SEEK_NOTIFY:
|
||||
this.switching = false;
|
||||
if(this.lastTransitionIndex >= 0)
|
||||
{
|
||||
this._currentIndex = this.lastTransitionIndex;
|
||||
}
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_STOP:
|
||||
this.checkRulesTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private function onPlayStatus(param1:Object) : void
|
||||
{
|
||||
switch(param1.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_TRANSITION_COMPLETE:
|
||||
if(this.lastTransitionIndex >= 0)
|
||||
{
|
||||
this._currentIndex = this.lastTransitionIndex;
|
||||
this.lastTransitionIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function prepareForSwitching() : void
|
||||
{
|
||||
this.initDSIFailedCounts();
|
||||
this.metrics.resource = this.dsResource;
|
||||
this.actualIndex = 0;
|
||||
this.lastTransitionIndex = -1;
|
||||
if(this.dsResource.initialIndex >= 0 && this.dsResource.initialIndex < this.dsResource.streamItems.length)
|
||||
{
|
||||
this.actualIndex = this.dsResource.initialIndex;
|
||||
}
|
||||
if(autoSwitch)
|
||||
{
|
||||
this.checkRulesTimer.start();
|
||||
}
|
||||
this.setThrottleLimits(this.dsResource.streamItems.length - 1);
|
||||
this.metrics.currentIndex = this.actualIndex;
|
||||
}
|
||||
|
||||
private function initDSIFailedCounts() : void
|
||||
{
|
||||
if(this.dsiFailedCounts != null)
|
||||
{
|
||||
this.dsiFailedCounts.length = 0;
|
||||
this.dsiFailedCounts = null;
|
||||
}
|
||||
this.dsiFailedCounts = new Vector.<int>();
|
||||
var _loc1_:int = 0;
|
||||
while(_loc1_ < this.dsResource.streamItems.length)
|
||||
{
|
||||
this.dsiFailedCounts.push(0);
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function incrementDSIFailedCount(param1:int) : void
|
||||
{
|
||||
++this.dsiFailedCounts[param1];
|
||||
if(this.dsiFailedCounts[param1] > DEFAULT_MAX_UP_SWITCHES_PER_STREAM_ITEM)
|
||||
{
|
||||
if(this.clearFailedCountsTimer == null)
|
||||
{
|
||||
this.clearFailedCountsTimer = new Timer(DEFAULT_CLEAR_FAILED_COUNTS_INTERVAL,1);
|
||||
this.clearFailedCountsTimer.addEventListener(TimerEvent.TIMER,this.clearFailedCounts);
|
||||
}
|
||||
this.clearFailedCountsTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
private function clearFailedCounts(param1:TimerEvent) : void
|
||||
{
|
||||
this.clearFailedCountsTimer.removeEventListener(TimerEvent.TIMER,this.clearFailedCounts);
|
||||
this.clearFailedCountsTimer = null;
|
||||
this.initDSIFailedCounts();
|
||||
}
|
||||
|
||||
private function setThrottleLimits(param1:int) : void
|
||||
{
|
||||
this.connection.call("setBandwidthLimit",null,this._bandwidthLimit,this._bandwidthLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.EventDispatcher;
|
||||
|
||||
public class NetStreamSwitchManagerBase extends EventDispatcher
|
||||
{
|
||||
|
||||
private var _autoSwitch:Boolean;
|
||||
|
||||
private var _maxAllowedIndex:int;
|
||||
|
||||
public function NetStreamSwitchManagerBase()
|
||||
{
|
||||
super();
|
||||
this._autoSwitch = true;
|
||||
this._maxAllowedIndex = int.MAX_VALUE;
|
||||
}
|
||||
|
||||
public function get autoSwitch() : Boolean
|
||||
{
|
||||
return this._autoSwitch;
|
||||
}
|
||||
|
||||
public function set autoSwitch(param1:Boolean) : void
|
||||
{
|
||||
this._autoSwitch = param1;
|
||||
}
|
||||
|
||||
public function get currentIndex() : uint
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function get maxAllowedIndex() : int
|
||||
{
|
||||
return this._maxAllowedIndex;
|
||||
}
|
||||
|
||||
public function set maxAllowedIndex(param1:int) : void
|
||||
{
|
||||
this._maxAllowedIndex = param1;
|
||||
}
|
||||
|
||||
public function switchTo(param1:int) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class NetStreamTimeTrait extends TimeTrait
|
||||
{
|
||||
|
||||
private var durationOffset:Number = 0;
|
||||
|
||||
private var _audioDelay:Number = 0;
|
||||
|
||||
private var netStream:NetStream;
|
||||
|
||||
private var resource:MediaResourceBase;
|
||||
|
||||
private var multicast:Boolean = false;
|
||||
|
||||
public function NetStreamTimeTrait(param1:NetStream, param2:MediaResourceBase, param3:Number = NaN)
|
||||
{
|
||||
super();
|
||||
this.netStream = param1;
|
||||
NetClient(param1.client).addHandler(NetStreamCodes.ON_META_DATA,this.onMetaData);
|
||||
NetClient(param1.client).addHandler(NetStreamCodes.ON_PLAY_STATUS,this.onPlayStatus);
|
||||
param1.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus,false,0,true);
|
||||
this.resource = param2;
|
||||
if(isNaN(param3) == false)
|
||||
{
|
||||
setDuration(param3);
|
||||
}
|
||||
var _loc4_:MulticastResource = param2 as MulticastResource;
|
||||
if(_loc4_ != null && _loc4_.groupspec != null && _loc4_.groupspec.length > 0)
|
||||
{
|
||||
this.multicast = true;
|
||||
setDuration(Number.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
if(this.multicast)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(this.durationOffset == duration - (this.netStream.time - this._audioDelay))
|
||||
{
|
||||
return this.netStream.time - this._audioDelay + this.durationOffset;
|
||||
}
|
||||
return this.netStream.time - this._audioDelay;
|
||||
}
|
||||
|
||||
private function onMetaData(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Object = NetStreamUtils.getPlayArgsForResource(this.resource);
|
||||
this._audioDelay = param1.hasOwnProperty("audiodelay") ? Number(param1.audiodelay) : 0;
|
||||
var _loc3_:Number = Math.max(0,_loc2_.start);
|
||||
var _loc4_:Number = Number(_loc2_.len);
|
||||
if(_loc4_ == NetStreamUtils.PLAY_LEN_ARG_ALL)
|
||||
{
|
||||
_loc4_ = Number.MAX_VALUE;
|
||||
}
|
||||
setDuration(Math.min(param1.duration - this._audioDelay - _loc3_,_loc4_));
|
||||
}
|
||||
|
||||
private function onPlayStatus(param1:Object) : void
|
||||
{
|
||||
switch(param1.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_COMPLETE:
|
||||
this.signalComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_STOP:
|
||||
if(NetStreamUtils.isStreamingResource(this.resource) == false)
|
||||
{
|
||||
this.signalComplete();
|
||||
}
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_UNPUBLISH_NOTIFY:
|
||||
this.signalComplete();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function signalComplete() : void
|
||||
{
|
||||
if(this.netStream.time - this._audioDelay != duration)
|
||||
{
|
||||
this.durationOffset = duration - (this.netStream.time - this._audioDelay);
|
||||
}
|
||||
super.signalComplete();
|
||||
}
|
||||
|
||||
internal function get audioDelay() : Number
|
||||
{
|
||||
return this._audioDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.MetadataNamespaces;
|
||||
import org.osmf.utils.URL;
|
||||
|
||||
public class NetStreamUtils
|
||||
{
|
||||
|
||||
public static const PLAY_START_ARG_ANY:int = -2;
|
||||
|
||||
public static const PLAY_START_ARG_LIVE:int = -1;
|
||||
|
||||
public static const PLAY_START_ARG_RECORDED:int = 0;
|
||||
|
||||
public static const PLAY_LEN_ARG_ALL:int = -1;
|
||||
|
||||
public function NetStreamUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getStreamNameFromURL(param1:String, param2:Boolean = false) : String
|
||||
{
|
||||
var _loc4_:FMSURL = null;
|
||||
var _loc3_:String = "";
|
||||
if(param1 != null)
|
||||
{
|
||||
if(isRTMPStream(param1))
|
||||
{
|
||||
_loc4_ = new FMSURL(param1,param2);
|
||||
_loc3_ = _loc4_.streamName;
|
||||
if(_loc4_.query != null && _loc4_.query != "")
|
||||
{
|
||||
_loc3_ += "?" + _loc4_.query;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = param1;
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function isStreamingResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc3_:URLResource = null;
|
||||
var _loc2_:Boolean = false;
|
||||
if(param1 != null)
|
||||
{
|
||||
_loc3_ = param1 as URLResource;
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc2_ = NetStreamUtils.isRTMPStream(_loc3_.url);
|
||||
if(_loc2_ == false)
|
||||
{
|
||||
_loc2_ = _loc3_.getMetadataValue(MetadataNamespaces.HTTP_STREAMING_METADATA) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function isRTMPStream(param1:String) : Boolean
|
||||
{
|
||||
var _loc3_:URL = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc2_:Boolean = false;
|
||||
if(param1 != null)
|
||||
{
|
||||
_loc3_ = new URL(param1);
|
||||
_loc4_ = _loc3_.protocol;
|
||||
if(_loc4_ != null && _loc4_.length > 0)
|
||||
{
|
||||
_loc2_ = _loc4_.search(/^rtmp$|rtmp[tse]$|rtmpte$/i) != -1;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function getStreamType(param1:MediaResourceBase) : String
|
||||
{
|
||||
var _loc2_:String = StreamType.RECORDED;
|
||||
var _loc3_:StreamingURLResource = param1 as StreamingURLResource;
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc2_ = _loc3_.streamType;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function getPlayArgsForResource(param1:MediaResourceBase) : Object
|
||||
{
|
||||
var _loc4_:StreamingURLResource = null;
|
||||
var _loc2_:Number = PLAY_START_ARG_ANY;
|
||||
var _loc3_:Number = PLAY_LEN_ARG_ALL;
|
||||
switch(getStreamType(param1))
|
||||
{
|
||||
case StreamType.LIVE_OR_RECORDED:
|
||||
_loc2_ = PLAY_START_ARG_ANY;
|
||||
break;
|
||||
case StreamType.LIVE:
|
||||
_loc2_ = PLAY_START_ARG_LIVE;
|
||||
break;
|
||||
case StreamType.RECORDED:
|
||||
_loc2_ = PLAY_START_ARG_RECORDED;
|
||||
}
|
||||
if(_loc2_ != PLAY_START_ARG_LIVE && param1 != null)
|
||||
{
|
||||
_loc4_ = param1 as StreamingURLResource;
|
||||
if(_loc4_ != null && isStreamingResource(_loc4_))
|
||||
{
|
||||
if(!isNaN(_loc4_.clipStartTime))
|
||||
{
|
||||
_loc2_ = _loc4_.clipStartTime;
|
||||
}
|
||||
if(!isNaN(_loc4_.clipEndTime))
|
||||
{
|
||||
_loc2_ = Math.max(0,_loc2_);
|
||||
_loc3_ = Math.max(0,_loc4_.clipEndTime - _loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
"start":_loc2_,
|
||||
"len":_loc3_
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
public class PortProtocol
|
||||
{
|
||||
|
||||
private var _port:int;
|
||||
|
||||
private var _protocol:String;
|
||||
|
||||
public function PortProtocol()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get port() : int
|
||||
{
|
||||
return this._port;
|
||||
}
|
||||
|
||||
public function set port(param1:int) : void
|
||||
{
|
||||
this._port = param1;
|
||||
}
|
||||
|
||||
public function get protocol() : String
|
||||
{
|
||||
return this._protocol;
|
||||
}
|
||||
|
||||
public function set protocol(param1:String) : void
|
||||
{
|
||||
this._protocol = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
public final class StreamType
|
||||
{
|
||||
|
||||
public static const LIVE:String = "live";
|
||||
|
||||
public static const RECORDED:String = "recorded";
|
||||
|
||||
public static const LIVE_OR_RECORDED:String = "liveOrRecorded";
|
||||
|
||||
public static const DVR:String = "dvr";
|
||||
|
||||
public function StreamType()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.media.URLResource;
|
||||
|
||||
public class StreamingURLResource extends URLResource
|
||||
{
|
||||
|
||||
private var _streamType:String;
|
||||
|
||||
private var _clipStartTime:Number;
|
||||
|
||||
private var _clipEndTime:Number;
|
||||
|
||||
private var _connectionArguments:Vector.<Object>;
|
||||
|
||||
private var _drmContentData:ByteArray;
|
||||
|
||||
private var _urlIncludesFMSApplicationInstance:Boolean = false;
|
||||
|
||||
public function StreamingURLResource(param1:String, param2:String = null, param3:Number = NaN, param4:Number = NaN, param5:Vector.<Object> = null, param6:Boolean = false, param7:ByteArray = null)
|
||||
{
|
||||
this._streamType = param2 || StreamType.RECORDED;
|
||||
this._clipStartTime = param3;
|
||||
this._clipEndTime = param4;
|
||||
this._urlIncludesFMSApplicationInstance = param6;
|
||||
this._drmContentData = param7;
|
||||
this._connectionArguments = param5;
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get streamType() : String
|
||||
{
|
||||
return this._streamType;
|
||||
}
|
||||
|
||||
public function set streamType(param1:String) : void
|
||||
{
|
||||
this._streamType = param1;
|
||||
}
|
||||
|
||||
public function get clipStartTime() : Number
|
||||
{
|
||||
return this._clipStartTime;
|
||||
}
|
||||
|
||||
public function set clipStartTime(param1:Number) : void
|
||||
{
|
||||
this._clipStartTime = param1;
|
||||
}
|
||||
|
||||
public function get clipEndTime() : Number
|
||||
{
|
||||
return this._clipEndTime;
|
||||
}
|
||||
|
||||
public function set clipEndTime(param1:Number) : void
|
||||
{
|
||||
this._clipEndTime = param1;
|
||||
}
|
||||
|
||||
public function get connectionArguments() : Vector.<Object>
|
||||
{
|
||||
return this._connectionArguments;
|
||||
}
|
||||
|
||||
public function set connectionArguments(param1:Vector.<Object>) : void
|
||||
{
|
||||
this._connectionArguments = param1;
|
||||
}
|
||||
|
||||
public function get drmContentData() : ByteArray
|
||||
{
|
||||
return this._drmContentData;
|
||||
}
|
||||
|
||||
public function set drmContentData(param1:ByteArray) : void
|
||||
{
|
||||
this._drmContentData = param1;
|
||||
}
|
||||
|
||||
public function get urlIncludesFMSApplicationInstance() : Boolean
|
||||
{
|
||||
return this._urlIncludesFMSApplicationInstance;
|
||||
}
|
||||
|
||||
public function set urlIncludesFMSApplicationInstance(param1:Boolean) : void
|
||||
{
|
||||
this._urlIncludesFMSApplicationInstance = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.osmf.net
|
||||
{
|
||||
public class SwitchingRuleBase
|
||||
{
|
||||
|
||||
private var _metrics:NetStreamMetricsBase;
|
||||
|
||||
public function SwitchingRuleBase(param1:NetStreamMetricsBase)
|
||||
{
|
||||
super();
|
||||
this._metrics = param1;
|
||||
}
|
||||
|
||||
public function getNewIndex() : int
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected function get metrics() : NetStreamMetricsBase
|
||||
{
|
||||
return this._metrics;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
package org.osmf.net.drm
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.DRMAuthenticationCompleteEvent;
|
||||
import flash.events.DRMAuthenticationErrorEvent;
|
||||
import flash.events.DRMErrorEvent;
|
||||
import flash.events.DRMStatusEvent;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.events.StatusEvent;
|
||||
import flash.net.drm.DRMContentData;
|
||||
import flash.net.drm.DRMManager;
|
||||
import flash.net.drm.DRMVoucher;
|
||||
import flash.net.drm.LoadVoucherSetting;
|
||||
import flash.system.SystemUpdater;
|
||||
import flash.system.SystemUpdaterType;
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.events.DRMEvent;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.traits.DRMState;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class DRMServices extends EventDispatcher
|
||||
{
|
||||
|
||||
private static var updater:SystemUpdater;
|
||||
|
||||
private static const DRM_AUTHENTICATION_FAILED:int = 3301;
|
||||
|
||||
private static const DRM_NEEDS_AUTHENTICATION:int = 3330;
|
||||
|
||||
private static const DRM_CONTENT_NOT_YET_VALID:int = 3331;
|
||||
|
||||
private var _drmState:String = "uninitialized";
|
||||
|
||||
private var lastToken:ByteArray;
|
||||
|
||||
private var drmContentData:DRMContentData;
|
||||
|
||||
private var voucher:DRMVoucher;
|
||||
|
||||
private var drmManager:DRMManager;
|
||||
|
||||
public function DRMServices()
|
||||
{
|
||||
super();
|
||||
this.drmManager = DRMManager.getDRMManager();
|
||||
}
|
||||
|
||||
public function get drmState() : String
|
||||
{
|
||||
return this._drmState;
|
||||
}
|
||||
|
||||
public function set drmMetadata(param1:Object) : void
|
||||
{
|
||||
var onComplete:Function = null;
|
||||
var value:Object = param1;
|
||||
this.lastToken = null;
|
||||
if(value is DRMContentData)
|
||||
{
|
||||
this.drmContentData = value as DRMContentData;
|
||||
this.retrieveVoucher();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
this.drmContentData = new DRMContentData(value as ByteArray);
|
||||
this.retrieveVoucher();
|
||||
}
|
||||
catch(argError:ArgumentError)
|
||||
{
|
||||
updateDRMState(DRMState.AUTHENTICATION_ERROR,new MediaError(argError.errorID,"DRMContentData invalid"));
|
||||
}
|
||||
catch(error:IllegalOperationError)
|
||||
{
|
||||
onComplete = function(param1:Event):void
|
||||
{
|
||||
updater.removeEventListener(Event.COMPLETE,onComplete);
|
||||
drmMetadata = value;
|
||||
};
|
||||
update(SystemUpdaterType.DRM);
|
||||
updater.addEventListener(Event.COMPLETE,onComplete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get drmMetadata() : Object
|
||||
{
|
||||
return this.drmContentData;
|
||||
}
|
||||
|
||||
public function authenticate(param1:String = null, param2:String = null) : void
|
||||
{
|
||||
if(this.drmContentData == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.DRM_METADATA_NOT_SET));
|
||||
}
|
||||
this.drmManager.addEventListener(DRMAuthenticationErrorEvent.AUTHENTICATION_ERROR,this.authError);
|
||||
this.drmManager.addEventListener(DRMAuthenticationCompleteEvent.AUTHENTICATION_COMPLETE,this.authComplete);
|
||||
if(param2 == null && param1 == null)
|
||||
{
|
||||
this.retrieveVoucher();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drmManager.authenticate(this.drmContentData.serverURL,this.drmContentData.domain,param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function authenticateWithToken(param1:Object) : void
|
||||
{
|
||||
if(this.drmContentData == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.DRM_METADATA_NOT_SET));
|
||||
}
|
||||
this.drmManager.setAuthenticationToken(this.drmContentData.serverURL,this.drmContentData.domain,param1 as ByteArray);
|
||||
this.retrieveVoucher();
|
||||
}
|
||||
|
||||
public function get startDate() : Date
|
||||
{
|
||||
if(this.voucher != null)
|
||||
{
|
||||
return this.voucher.playbackTimeWindow ? this.voucher.playbackTimeWindow.startDate : this.voucher.voucherStartDate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get endDate() : Date
|
||||
{
|
||||
if(this.voucher != null)
|
||||
{
|
||||
return this.voucher.playbackTimeWindow ? this.voucher.playbackTimeWindow.endDate : this.voucher.voucherEndDate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get period() : Number
|
||||
{
|
||||
if(this.voucher != null)
|
||||
{
|
||||
return this.voucher.playbackTimeWindow ? this.voucher.playbackTimeWindow.period : (Boolean(this.voucher.voucherEndDate) && Boolean(this.voucher.voucherStartDate) ? (this.voucher.voucherEndDate.time - this.voucher.voucherStartDate.time) / 1000 : 0);
|
||||
}
|
||||
return NaN;
|
||||
}
|
||||
|
||||
public function inlineDRMFailed(param1:MediaError) : void
|
||||
{
|
||||
this.updateDRMState(DRMState.AUTHENTICATION_ERROR,param1);
|
||||
}
|
||||
|
||||
public function inlineOnVoucher(param1:DRMStatusEvent) : void
|
||||
{
|
||||
this.drmContentData = param1.contentData;
|
||||
this.onVoucherLoaded(param1);
|
||||
}
|
||||
|
||||
public function update(param1:String) : SystemUpdater
|
||||
{
|
||||
this.updateDRMState(DRMState.DRM_SYSTEM_UPDATING);
|
||||
if(updater == null)
|
||||
{
|
||||
updater = new SystemUpdater();
|
||||
this.toggleErrorListeners(updater,true);
|
||||
updater.update(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.toggleErrorListeners(updater,true);
|
||||
}
|
||||
return updater;
|
||||
}
|
||||
|
||||
private function retrieveVoucher() : void
|
||||
{
|
||||
this.updateDRMState(DRMState.AUTHENTICATING);
|
||||
this.drmManager.addEventListener(DRMErrorEvent.DRM_ERROR,this.onDRMError);
|
||||
this.drmManager.addEventListener(DRMStatusEvent.DRM_STATUS,this.onVoucherLoaded);
|
||||
this.drmManager.loadVoucher(this.drmContentData,LoadVoucherSetting.ALLOW_SERVER);
|
||||
}
|
||||
|
||||
private function onVoucherLoaded(param1:DRMStatusEvent) : void
|
||||
{
|
||||
var _loc2_:Date = null;
|
||||
if(param1.contentData == this.drmContentData)
|
||||
{
|
||||
_loc2_ = new Date();
|
||||
if(Boolean(param1.voucher) && ((param1.voucher.voucherEndDate == null || param1.voucher.voucherEndDate.time >= _loc2_.time) && (param1.voucher.voucherStartDate == null || param1.voucher.voucherStartDate.time <= _loc2_.time)))
|
||||
{
|
||||
this.voucher = param1.voucher;
|
||||
this.removeEventListeners();
|
||||
if(this.voucher.playbackTimeWindow == null)
|
||||
{
|
||||
this.updateDRMState(DRMState.AUTHENTICATION_COMPLETE,null,this.voucher.voucherStartDate,this.voucher.voucherEndDate,this.period,this.lastToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateDRMState(DRMState.AUTHENTICATION_COMPLETE,null,this.voucher.playbackTimeWindow.startDate,this.voucher.playbackTimeWindow.endDate,this.voucher.playbackTimeWindow.period,this.lastToken);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.forceRefreshVoucher();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function forceRefreshVoucher() : void
|
||||
{
|
||||
this.drmManager.loadVoucher(this.drmContentData,LoadVoucherSetting.FORCE_REFRESH);
|
||||
}
|
||||
|
||||
private function onDRMError(param1:DRMErrorEvent) : void
|
||||
{
|
||||
if(param1.contentData == this.drmContentData)
|
||||
{
|
||||
switch(param1.errorID)
|
||||
{
|
||||
case DRM_CONTENT_NOT_YET_VALID:
|
||||
this.forceRefreshVoucher();
|
||||
break;
|
||||
case DRM_NEEDS_AUTHENTICATION:
|
||||
this.updateDRMState(DRMState.AUTHENTICATION_NEEDED,null,null,null,0,null,param1.contentData.serverURL);
|
||||
break;
|
||||
default:
|
||||
this.removeEventListeners();
|
||||
this.updateDRMState(DRMState.AUTHENTICATION_ERROR,new MediaError(param1.errorID,param1.text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function removeEventListeners() : void
|
||||
{
|
||||
this.drmManager.removeEventListener(DRMErrorEvent.DRM_ERROR,this.onDRMError);
|
||||
this.drmManager.removeEventListener(DRMStatusEvent.DRM_STATUS,this.onVoucherLoaded);
|
||||
}
|
||||
|
||||
private function authComplete(param1:DRMAuthenticationCompleteEvent) : void
|
||||
{
|
||||
this.drmManager.removeEventListener(DRMAuthenticationErrorEvent.AUTHENTICATION_ERROR,this.authError);
|
||||
this.drmManager.removeEventListener(DRMAuthenticationCompleteEvent.AUTHENTICATION_COMPLETE,this.authComplete);
|
||||
this.lastToken = param1.token;
|
||||
this.retrieveVoucher();
|
||||
}
|
||||
|
||||
private function authError(param1:DRMAuthenticationErrorEvent) : void
|
||||
{
|
||||
this.drmManager.removeEventListener(DRMAuthenticationErrorEvent.AUTHENTICATION_ERROR,this.authError);
|
||||
this.drmManager.removeEventListener(DRMAuthenticationCompleteEvent.AUTHENTICATION_COMPLETE,this.authComplete);
|
||||
this.updateDRMState(DRMState.AUTHENTICATION_ERROR,new MediaError(param1.errorID,param1.toString()));
|
||||
}
|
||||
|
||||
private function toggleErrorListeners(param1:SystemUpdater, param2:Boolean) : void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
param1.addEventListener(Event.COMPLETE,this.onUpdateComplete);
|
||||
param1.addEventListener(Event.CANCEL,this.onUpdateComplete);
|
||||
param1.addEventListener(IOErrorEvent.IO_ERROR,this.onUpdateError);
|
||||
param1.addEventListener(SecurityErrorEvent.SECURITY_ERROR,this.onUpdateError);
|
||||
param1.addEventListener(StatusEvent.STATUS,this.onUpdateError);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.removeEventListener(Event.COMPLETE,this.onUpdateComplete);
|
||||
param1.removeEventListener(Event.CANCEL,this.onUpdateComplete);
|
||||
param1.removeEventListener(IOErrorEvent.IO_ERROR,this.onUpdateError);
|
||||
param1.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,this.onUpdateError);
|
||||
param1.removeEventListener(StatusEvent.STATUS,this.onUpdateError);
|
||||
}
|
||||
}
|
||||
|
||||
private function onUpdateComplete(param1:Event) : void
|
||||
{
|
||||
this.toggleErrorListeners(updater,false);
|
||||
}
|
||||
|
||||
private function onUpdateError(param1:Event) : void
|
||||
{
|
||||
this.toggleErrorListeners(updater,false);
|
||||
this.updateDRMState(DRMState.AUTHENTICATION_ERROR,new MediaError(MediaErrorCodes.DRM_SYSTEM_UPDATE_ERROR,param1.toString()));
|
||||
}
|
||||
|
||||
private function updateDRMState(param1:String, param2:MediaError = null, param3:Date = null, param4:Date = null, param5:Number = 0, param6:Object = null, param7:String = null) : void
|
||||
{
|
||||
this._drmState = param1;
|
||||
dispatchEvent(new DRMEvent(DRMEvent.DRM_STATE_CHANGE,param1,false,false,param3,param4,param5,param7,param6,param2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.osmf.net.drm
|
||||
{
|
||||
import flash.events.DRMStatusEvent;
|
||||
import flash.system.SystemUpdater;
|
||||
import org.osmf.events.DRMEvent;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.traits.DRMTrait;
|
||||
|
||||
public class NetStreamDRMTrait extends DRMTrait
|
||||
{
|
||||
|
||||
private var drmServices:DRMServices = new DRMServices();
|
||||
|
||||
public function NetStreamDRMTrait()
|
||||
{
|
||||
super();
|
||||
this.drmServices.addEventListener(DRMEvent.DRM_STATE_CHANGE,this.onStateChange);
|
||||
}
|
||||
|
||||
public function set drmMetadata(param1:Object) : void
|
||||
{
|
||||
if(param1 != this.drmServices.drmMetadata)
|
||||
{
|
||||
this.drmServices.drmMetadata = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get drmMetadata() : Object
|
||||
{
|
||||
return this.drmServices.drmMetadata;
|
||||
}
|
||||
|
||||
public function update(param1:String) : SystemUpdater
|
||||
{
|
||||
return this.drmServices.update(param1);
|
||||
}
|
||||
|
||||
override public function authenticate(param1:String = null, param2:String = null) : void
|
||||
{
|
||||
this.drmServices.authenticate(param1,param2);
|
||||
}
|
||||
|
||||
override public function authenticateWithToken(param1:Object) : void
|
||||
{
|
||||
this.drmServices.authenticateWithToken(param1);
|
||||
}
|
||||
|
||||
public function inlineDRMFailed(param1:MediaError) : void
|
||||
{
|
||||
this.drmServices.inlineDRMFailed(param1);
|
||||
}
|
||||
|
||||
public function inlineOnVoucher(param1:DRMStatusEvent) : void
|
||||
{
|
||||
this.drmServices.inlineOnVoucher(param1);
|
||||
}
|
||||
|
||||
private function onStateChange(param1:DRMEvent) : void
|
||||
{
|
||||
setPeriod(param1.period);
|
||||
setStartDate(param1.startDate);
|
||||
setEndDate(param1.endDate);
|
||||
setDrmState(param1.drmState);
|
||||
dispatchEvent(new DRMEvent(DRMEvent.DRM_STATE_CHANGE,drmState,false,false,startDate,endDate,period,param1.serverURL,param1.token,param1.mediaError));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
public class DVRCastConstants
|
||||
{
|
||||
|
||||
public static const RPC_GET_STREAM_INFO:String = "DVRGetStreamInfo";
|
||||
|
||||
public static const RPC_SUBSCRIBE:String = "DVRSubscribe";
|
||||
|
||||
public static const RPC_UNSUBSCRIBE:String = "DVRUnsubscribe";
|
||||
|
||||
public static const RESULT_GET_STREAM_INFO_SUCCESS:String = "NetStream.DVRStreamInfo.Success";
|
||||
|
||||
public static const RESULT_GET_STREAM_INFO_RETRY:String = "NetStream.DVRStreamInfo.Retry";
|
||||
|
||||
public static const STREAM_INFO_KEY:String = "http://www.osmf.org/dvrCast/1.0/streamInfo";
|
||||
|
||||
public static const RECORDING_INFO_KEY:String = "http://www.osmf.org/dvrCast/1.0/recordingInfo";
|
||||
|
||||
public static const STREAM_INFO_UPDATE_DELAY:Number = 3000;
|
||||
|
||||
public static const LOCAL_DURATION_UPDATE_INTERVAL:Number = 500;
|
||||
|
||||
public static const LIVE_POSITION_SEEK_DELAY:Number = 1.5;
|
||||
|
||||
public function DVRCastConstants()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.Event;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.DVRTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class DVRCastDVRTrait extends DVRTrait
|
||||
{
|
||||
|
||||
private var connection:NetConnection;
|
||||
|
||||
private var stream:NetStream;
|
||||
|
||||
private var streamInfo:DVRCastStreamInfo;
|
||||
|
||||
private var recordingInfo:DVRCastRecordingInfo;
|
||||
|
||||
private var streamInfoUpdateTimer:Timer;
|
||||
|
||||
private var streamInfoRetriever:DVRCastStreamInfoRetriever;
|
||||
|
||||
private var offset:Number;
|
||||
|
||||
public function DVRCastDVRTrait(param1:NetConnection, param2:NetStream, param3:MediaResourceBase)
|
||||
{
|
||||
if(param1 != null && param2 != null)
|
||||
{
|
||||
this.stream = param2;
|
||||
this.streamInfo = param3.getMetadataValue(DVRCastConstants.STREAM_INFO_KEY) as DVRCastStreamInfo;
|
||||
this.recordingInfo = param3.getMetadataValue(DVRCastConstants.RECORDING_INFO_KEY) as DVRCastRecordingInfo;
|
||||
this.streamInfoRetriever = new DVRCastStreamInfoRetriever(param1,this.streamInfo.streamName);
|
||||
this.streamInfoRetriever.addEventListener(Event.COMPLETE,this.onStreamInfoRetrieverComplete);
|
||||
this.streamInfoUpdateTimer = new Timer(DVRCastConstants.STREAM_INFO_UPDATE_DELAY);
|
||||
this.streamInfoUpdateTimer.addEventListener(TimerEvent.TIMER,this.onStreamInfoUpdateTimer);
|
||||
this.streamInfoUpdateTimer.start();
|
||||
super(this.streamInfo.isRecording);
|
||||
this.updateProperties();
|
||||
return;
|
||||
}
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
|
||||
override protected function isRecordingChangeStart(param1:Boolean) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this.recordingInfo.startDuration = this.streamInfo.currentLength;
|
||||
this.recordingInfo.startTime = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
private function updateProperties() : void
|
||||
{
|
||||
setIsRecording(this.streamInfo.isRecording);
|
||||
}
|
||||
|
||||
private function onStreamInfoUpdateTimer(param1:TimerEvent) : void
|
||||
{
|
||||
this.streamInfoRetriever.retrieve();
|
||||
}
|
||||
|
||||
private function onStreamInfoRetrieverComplete(param1:Event) : void
|
||||
{
|
||||
if(this.streamInfoRetriever.streamInfo != null)
|
||||
{
|
||||
this.streamInfo.readFromDVRCastStreamInfo(this.streamInfoRetriever.streamInfo);
|
||||
this.updateProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.DVRCAST_STREAM_INFO_RETRIEVAL_FAILED)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.Responder;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.NetConnectionFactoryEvent;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.net.DynamicStreamingItem;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.NetConnectionFactory;
|
||||
import org.osmf.net.NetConnectionFactoryBase;
|
||||
import org.osmf.net.NetStreamUtils;
|
||||
import org.osmf.net.StreamingURLResource;
|
||||
|
||||
public class DVRCastNetConnectionFactory extends NetConnectionFactoryBase
|
||||
{
|
||||
|
||||
private var innerFactory:NetConnectionFactoryBase;
|
||||
|
||||
private var subscribedStreams:Dictionary = new Dictionary();
|
||||
|
||||
public function DVRCastNetConnectionFactory(param1:NetConnectionFactoryBase = null)
|
||||
{
|
||||
this.innerFactory = param1 || new NetConnectionFactory();
|
||||
this.innerFactory.addEventListener(NetConnectionFactoryEvent.CREATION_COMPLETE,this.onCreationComplete);
|
||||
this.innerFactory.addEventListener(NetConnectionFactoryEvent.CREATION_ERROR,this.onCreationError);
|
||||
super();
|
||||
}
|
||||
|
||||
override public function create(param1:URLResource) : void
|
||||
{
|
||||
this.innerFactory.create(param1);
|
||||
}
|
||||
|
||||
override public function closeNetConnection(param1:NetConnection) : void
|
||||
{
|
||||
var _loc2_:String = this.subscribedStreams[param1];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
param1.call(DVRCastConstants.RPC_UNSUBSCRIBE,null,_loc2_);
|
||||
delete this.subscribedStreams[param1];
|
||||
}
|
||||
this.innerFactory.closeNetConnection(param1);
|
||||
}
|
||||
|
||||
private function onCreationComplete(param1:NetConnectionFactoryEvent) : void
|
||||
{
|
||||
var urlIncludesFMSApplicationInstance:Boolean;
|
||||
var dynamicResource:DynamicStreamingResource;
|
||||
var responder:Responder;
|
||||
var urlResource:URLResource = null;
|
||||
var netConnection:NetConnection = null;
|
||||
var streamNames:Vector.<String> = null;
|
||||
var totalRpcSubscribeInvocation:int = 0;
|
||||
var streamingResource:StreamingURLResource = null;
|
||||
var onStreamSubscriptionResult:Function = null;
|
||||
var onStreamInfoRetrieverComplete:Function = null;
|
||||
var onServerCallError:Function = null;
|
||||
var items:Vector.<DynamicStreamingItem> = null;
|
||||
var i:int = 0;
|
||||
var event:NetConnectionFactoryEvent = param1;
|
||||
onStreamSubscriptionResult = function(param1:Object):void
|
||||
{
|
||||
var _loc2_:DVRCastStreamInfoRetriever = null;
|
||||
--totalRpcSubscribeInvocation;
|
||||
if(totalRpcSubscribeInvocation <= 0)
|
||||
{
|
||||
_loc2_ = new DVRCastStreamInfoRetriever(netConnection,streamNames[0]);
|
||||
_loc2_.addEventListener(Event.COMPLETE,onStreamInfoRetrieverComplete);
|
||||
_loc2_.retrieve();
|
||||
}
|
||||
};
|
||||
onStreamInfoRetrieverComplete = function(param1:Event):void
|
||||
{
|
||||
var _loc3_:DVRCastRecordingInfo = null;
|
||||
var _loc2_:DVRCastStreamInfoRetriever = param1.target as DVRCastStreamInfoRetriever;
|
||||
removeEventListener(NetConnectionFactoryEvent.CREATION_COMPLETE,onCreationComplete);
|
||||
if(_loc2_.streamInfo != null)
|
||||
{
|
||||
if(_loc2_.streamInfo.offline == true)
|
||||
{
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_ERROR,false,false,netConnection,urlResource,new MediaError(MediaErrorCodes.DVRCAST_CONTENT_OFFLINE)));
|
||||
i = 0;
|
||||
while(i < streamNames.length)
|
||||
{
|
||||
netConnection.call(DVRCastConstants.RPC_UNSUBSCRIBE,null,streamNames[i]);
|
||||
++i;
|
||||
}
|
||||
netConnection = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new DVRCastRecordingInfo();
|
||||
_loc3_.startDuration = _loc2_.streamInfo.currentLength;
|
||||
_loc3_.startOffset = calculateOffset(_loc2_.streamInfo);
|
||||
_loc3_.startTime = new Date();
|
||||
streamingResource.addMetadataValue(DVRCastConstants.STREAM_INFO_KEY,_loc2_.streamInfo);
|
||||
streamingResource.addMetadataValue(DVRCastConstants.RECORDING_INFO_KEY,_loc3_);
|
||||
subscribedStreams[netConnection] = streamNames[0];
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_COMPLETE,false,false,netConnection,urlResource));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onServerCallError(_loc2_.error);
|
||||
}
|
||||
};
|
||||
onServerCallError = function(param1:Object):void
|
||||
{
|
||||
dispatchEvent(new NetConnectionFactoryEvent(NetConnectionFactoryEvent.CREATION_ERROR,false,false,netConnection,urlResource,new MediaError(MediaErrorCodes.DVRCAST_SUBSCRIBE_FAILED,param1 ? param1.message : "")));
|
||||
};
|
||||
urlResource = event.resource as URLResource;
|
||||
netConnection = event.netConnection;
|
||||
streamNames = new Vector.<String>();
|
||||
totalRpcSubscribeInvocation = 0;
|
||||
event.stopImmediatePropagation();
|
||||
streamingResource = urlResource as StreamingURLResource;
|
||||
urlIncludesFMSApplicationInstance = streamingResource ? streamingResource.urlIncludesFMSApplicationInstance : false;
|
||||
dynamicResource = streamingResource as DynamicStreamingResource;
|
||||
if(dynamicResource != null)
|
||||
{
|
||||
items = dynamicResource.streamItems;
|
||||
totalRpcSubscribeInvocation = int(items.length);
|
||||
i = 0;
|
||||
while(i < items.length)
|
||||
{
|
||||
streamNames.push(items[i].streamName);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
totalRpcSubscribeInvocation = 1;
|
||||
streamNames.push(NetStreamUtils.getStreamNameFromURL(urlResource.url,urlIncludesFMSApplicationInstance));
|
||||
}
|
||||
responder = new TestableResponder(onStreamSubscriptionResult,onServerCallError);
|
||||
i = 0;
|
||||
while(i < streamNames.length)
|
||||
{
|
||||
event.netConnection.call(DVRCastConstants.RPC_SUBSCRIBE,responder,streamNames[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private function onCreationError(param1:NetConnectionFactoryEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function calculateOffset(param1:DVRCastStreamInfo) : Number
|
||||
{
|
||||
return DVRUtils.calculateOffset(param1.beginOffset,param1.endOffset,param1.currentLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.net.NetStreamLoadTrait;
|
||||
import org.osmf.net.NetStreamUtils;
|
||||
import org.osmf.net.StreamType;
|
||||
import org.osmf.net.StreamingURLResource;
|
||||
import org.osmf.net.rtmpstreaming.RTMPDynamicStreamingNetLoader;
|
||||
import org.osmf.traits.LoadState;
|
||||
|
||||
public class DVRCastNetLoader extends RTMPDynamicStreamingNetLoader
|
||||
{
|
||||
|
||||
public function DVRCastNetLoader(param1:DVRCastNetConnectionFactory = null)
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
param1 = new DVRCastNetConnectionFactory();
|
||||
}
|
||||
super(param1);
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc2_:Boolean = false;
|
||||
var _loc3_:StreamingURLResource = null;
|
||||
if(super.canHandleResource(param1))
|
||||
{
|
||||
_loc3_ = param1 as StreamingURLResource;
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc2_ = _loc3_.streamType == StreamType.DVR && NetStreamUtils.isRTMPStream(_loc3_.url);
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override protected function createNetStream(param1:NetConnection, param2:URLResource) : NetStream
|
||||
{
|
||||
return new DVRCastNetStream(param1,param2);
|
||||
}
|
||||
|
||||
override protected function processFinishLoading(param1:NetStreamLoadTrait) : void
|
||||
{
|
||||
param1.setTrait(new DVRCastDVRTrait(param1.connection,param1.netStream,param1.resource));
|
||||
param1.setTrait(new DVRCastTimeTrait(param1.connection,param1.netStream,param1.resource));
|
||||
updateLoadTrait(param1,LoadState.READY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.net.NetStreamPlayOptions;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
|
||||
public class DVRCastNetStream extends NetStream
|
||||
{
|
||||
|
||||
private var recordingInfo:DVRCastRecordingInfo;
|
||||
|
||||
public function DVRCastNetStream(param1:NetConnection, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1);
|
||||
this.recordingInfo = param2.getMetadataValue(DVRCastConstants.RECORDING_INFO_KEY) as DVRCastRecordingInfo;
|
||||
}
|
||||
|
||||
override public function play(... rest) : void
|
||||
{
|
||||
super.play(rest[0],this.recordingInfo.startOffset,-1);
|
||||
}
|
||||
|
||||
override public function play2(param1:NetStreamPlayOptions) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
param1.start = this.recordingInfo.startOffset;
|
||||
param1.len = -1;
|
||||
}
|
||||
super.play2(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
public class DVRCastRecordingInfo
|
||||
{
|
||||
|
||||
public var startTime:Date = null;
|
||||
|
||||
public var startDuration:Number;
|
||||
|
||||
public var startOffset:Number;
|
||||
|
||||
public function DVRCastRecordingInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class DVRCastStreamInfo
|
||||
{
|
||||
|
||||
public var callTime:Date;
|
||||
|
||||
public var offline:Boolean;
|
||||
|
||||
public var beginOffset:Number;
|
||||
|
||||
public var endOffset:Number;
|
||||
|
||||
public var recordingStart:Date;
|
||||
|
||||
public var recordingEnd:Date;
|
||||
|
||||
public var isRecording:Boolean;
|
||||
|
||||
public var streamName:String;
|
||||
|
||||
public var lastUpdate:Date;
|
||||
|
||||
public var currentLength:Number;
|
||||
|
||||
public var maxLength:Number;
|
||||
|
||||
public function DVRCastStreamInfo(param1:Object)
|
||||
{
|
||||
super();
|
||||
this.readFromDynamicObject(param1);
|
||||
}
|
||||
|
||||
public function readFromDynamicObject(param1:Object) : void
|
||||
{
|
||||
var value:Object = param1;
|
||||
try
|
||||
{
|
||||
this.callTime = value.callTime;
|
||||
this.offline = value.offline;
|
||||
this.beginOffset = value.begOffset;
|
||||
this.endOffset = value.endOffset;
|
||||
this.recordingStart = value.startRec;
|
||||
this.recordingEnd = value.stopRec;
|
||||
this.isRecording = value.isRec;
|
||||
this.streamName = value.streamName;
|
||||
this.lastUpdate = value.lastUpdate;
|
||||
this.currentLength = value.currLen;
|
||||
this.maxLength = value.maxLen;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
}
|
||||
|
||||
public function readFromDVRCastStreamInfo(param1:DVRCastStreamInfo) : void
|
||||
{
|
||||
var value:DVRCastStreamInfo = param1;
|
||||
try
|
||||
{
|
||||
this.callTime = value.callTime;
|
||||
this.offline = value.offline;
|
||||
this.beginOffset = value.beginOffset;
|
||||
this.endOffset = value.endOffset;
|
||||
this.recordingStart = value.recordingStart;
|
||||
this.recordingEnd = value.recordingEnd;
|
||||
this.isRecording = value.isRecording;
|
||||
this.streamName = value.streamName;
|
||||
this.lastUpdate = value.lastUpdate;
|
||||
this.currentLength = value.currentLength;
|
||||
this.maxLength = value.maxLength;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "callTime: " + this.callTime + "\noffline: " + this.offline + "\nbeginOffset: " + this.beginOffset + "\nendOffset: " + this.endOffset + "\nrecordingStart: " + this.recordingStart + "\nrecordingEnd: " + this.recordingEnd + "\nisRecording: " + this.isRecording + "\nstreamName: " + this.streamName + "\nlastUpdate: " + this.lastUpdate + "\ncurrentLength: " + this.currentLength + "\nmaxLength: " + this.maxLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.Responder;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class DVRCastStreamInfoRetriever extends EventDispatcher
|
||||
{
|
||||
|
||||
private var connection:NetConnection;
|
||||
|
||||
private var streamName:String;
|
||||
|
||||
private var retries:Number;
|
||||
|
||||
private var timer:Timer;
|
||||
|
||||
private var _streamInfo:DVRCastStreamInfo;
|
||||
|
||||
private var _error:Object;
|
||||
|
||||
public function DVRCastStreamInfoRetriever(param1:NetConnection, param2:String)
|
||||
{
|
||||
super();
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
this.connection = param1;
|
||||
this.streamName = param2;
|
||||
}
|
||||
|
||||
public function get streamInfo() : DVRCastStreamInfo
|
||||
{
|
||||
return this._streamInfo;
|
||||
}
|
||||
|
||||
public function get error() : Object
|
||||
{
|
||||
return this._error;
|
||||
}
|
||||
|
||||
public function retrieve(param1:int = 5, param2:Number = 3) : void
|
||||
{
|
||||
if(isNaN(this.retries))
|
||||
{
|
||||
param1 ||= 1;
|
||||
this._streamInfo = null;
|
||||
this._error = this._error = {"message":OSMFStrings.getString(OSMFStrings.DVR_MAXIMUM_RPC_ATTEMPTS).replace("%i",param1)};
|
||||
this.retries = param1;
|
||||
this.timer = new Timer(param2 * 1000,1);
|
||||
this.getStreamInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private function getStreamInfo() : void
|
||||
{
|
||||
var _loc1_:Responder = new TestableResponder(this.onGetStreamInfoResult,this.onServerCallError);
|
||||
--this.retries;
|
||||
this.connection.call(DVRCastConstants.RPC_GET_STREAM_INFO,_loc1_,this.streamName);
|
||||
}
|
||||
|
||||
private function onGetStreamInfoResult(param1:Object) : void
|
||||
{
|
||||
if(Boolean(param1) && param1.code == DVRCastConstants.RESULT_GET_STREAM_INFO_SUCCESS)
|
||||
{
|
||||
this._error = null;
|
||||
this._streamInfo = new DVRCastStreamInfo(param1.data);
|
||||
this.complete();
|
||||
}
|
||||
else if(Boolean(param1) && param1.code == DVRCastConstants.RESULT_GET_STREAM_INFO_RETRY)
|
||||
{
|
||||
if(this.retries != 0)
|
||||
{
|
||||
this.timer.addEventListener(TimerEvent.TIMER_COMPLETE,this.onTimerComplete);
|
||||
this.timer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._error = {"message":OSMFStrings.getString(OSMFStrings.DVR_UNEXPECTED_SERVER_RESPONSE) + param1.code};
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
|
||||
private function onServerCallError(param1:Object) : void
|
||||
{
|
||||
this._error = param1;
|
||||
this.complete();
|
||||
}
|
||||
|
||||
private function onTimerComplete(param1:TimerEvent) : void
|
||||
{
|
||||
this.timer.removeEventListener(TimerEvent.TIMER_COMPLETE,this.onTimerComplete);
|
||||
this.getStreamInfo();
|
||||
}
|
||||
|
||||
private function complete() : void
|
||||
{
|
||||
this.retries = NaN;
|
||||
this.timer = null;
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.events.TimeEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class DVRCastTimeTrait extends TimeTrait
|
||||
{
|
||||
|
||||
private var durationUpdateTimer:Timer;
|
||||
|
||||
private var oldDuration:Number;
|
||||
|
||||
private var stream:NetStream;
|
||||
|
||||
private var streamInfo:DVRCastStreamInfo;
|
||||
|
||||
private var recordingInfo:DVRCastRecordingInfo;
|
||||
|
||||
public function DVRCastTimeTrait(param1:NetConnection, param2:NetStream, param3:MediaResourceBase)
|
||||
{
|
||||
super(NaN);
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
this.stream = param2;
|
||||
param2.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
this.durationUpdateTimer = new Timer(DVRCastConstants.LOCAL_DURATION_UPDATE_INTERVAL);
|
||||
this.durationUpdateTimer.addEventListener(TimerEvent.TIMER,this.onDurationUpdateTimer);
|
||||
this.durationUpdateTimer.start();
|
||||
this.streamInfo = param3.getMetadataValue(DVRCastConstants.STREAM_INFO_KEY) as DVRCastStreamInfo;
|
||||
this.recordingInfo = param3.getMetadataValue(DVRCastConstants.RECORDING_INFO_KEY) as DVRCastRecordingInfo;
|
||||
}
|
||||
|
||||
override public function get duration() : Number
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
if(this.streamInfo.isRecording)
|
||||
{
|
||||
_loc1_ = this.recordingInfo.startDuration - this.recordingInfo.startOffset + (new Date().time - this.recordingInfo.startTime.time) / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = this.streamInfo.currentLength - this.recordingInfo.startOffset;
|
||||
}
|
||||
return isNaN(_loc1_) ? NaN : Math.max(0,_loc1_);
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return this.stream.time;
|
||||
}
|
||||
|
||||
private function onDurationUpdateTimer(param1:TimerEvent) : void
|
||||
{
|
||||
var _loc2_:Number = this.duration;
|
||||
if(_loc2_ != this.oldDuration)
|
||||
{
|
||||
this.oldDuration = _loc2_;
|
||||
dispatchEvent(new TimeEvent(TimeEvent.DURATION_CHANGE,false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
if(param1.info.code == "NetStream.Play.Stop")
|
||||
{
|
||||
if(this.durationUpdateTimer)
|
||||
{
|
||||
this.durationUpdateTimer.stop();
|
||||
}
|
||||
signalComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
public class DVRUtils
|
||||
{
|
||||
|
||||
public function DVRUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function calculateOffset(param1:Number, param2:Number, param3:Number) : Number
|
||||
{
|
||||
var _loc4_:Number = 0;
|
||||
if(param2 != 0)
|
||||
{
|
||||
if(param3 > param2)
|
||||
{
|
||||
_loc4_ = param3 - param2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = Math.min(param1,param3);
|
||||
}
|
||||
}
|
||||
else if(param1 != 0)
|
||||
{
|
||||
_loc4_ = Math.min(param1,param3);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.osmf.net.dvr
|
||||
{
|
||||
import flash.net.Responder;
|
||||
|
||||
internal class TestableResponder extends Responder
|
||||
{
|
||||
|
||||
private var _result:Function;
|
||||
|
||||
private var _status:Function;
|
||||
|
||||
public function TestableResponder(param1:Function, param2:Function = null)
|
||||
{
|
||||
this._result = param1;
|
||||
this._status = param2;
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
internal function get result() : Function
|
||||
{
|
||||
return this._result;
|
||||
}
|
||||
|
||||
internal function get status() : Function
|
||||
{
|
||||
return this._status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
|
||||
public class DownloadRatioRule extends SwitchingRuleBase
|
||||
{
|
||||
|
||||
private var aggressiveUpswitch:Boolean = false;
|
||||
|
||||
public function DownloadRatioRule(param1:HTTPNetStreamMetrics, param2:Boolean = true)
|
||||
{
|
||||
super(param1);
|
||||
this.aggressiveUpswitch = param2;
|
||||
}
|
||||
|
||||
override public function getNewIndex() : int
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc1_:* = -1;
|
||||
if(this.httpMetrics.downloadRatio < 1)
|
||||
{
|
||||
if(this.httpMetrics.currentIndex > 0)
|
||||
{
|
||||
_loc2_ = this.getSwitchRatio(this.httpMetrics.currentIndex - 1);
|
||||
if(this.httpMetrics.downloadRatio < _loc2_)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = int(this.httpMetrics.currentIndex - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this.httpMetrics.currentIndex < this.httpMetrics.maxAllowedIndex)
|
||||
{
|
||||
_loc2_ = this.getSwitchRatio(this.httpMetrics.currentIndex + 1);
|
||||
if(this.httpMetrics.downloadRatio >= _loc2_)
|
||||
{
|
||||
if(this.httpMetrics.downloadRatio > 100 || !this.aggressiveUpswitch)
|
||||
{
|
||||
_loc1_ = int(this.httpMetrics.currentIndex + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(++_loc1_ < this.httpMetrics.maxAllowedIndex + 1)
|
||||
{
|
||||
_loc2_ = this.getSwitchRatio(_loc1_);
|
||||
if(this.httpMetrics.downloadRatio < _loc2_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
_loc1_--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function getSwitchRatio(param1:int) : Number
|
||||
{
|
||||
return this.httpMetrics.getBitrateForIndex(param1) / this.httpMetrics.getBitrateForIndex(metrics.currentIndex);
|
||||
}
|
||||
|
||||
private function get httpMetrics() : HTTPNetStreamMetrics
|
||||
{
|
||||
return metrics as HTTPNetStreamMetrics;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import org.osmf.net.NetStreamMetricsBase;
|
||||
|
||||
public class HTTPNetStreamMetrics extends NetStreamMetricsBase
|
||||
{
|
||||
|
||||
private var httpNetStream:HTTPNetStream;
|
||||
|
||||
public function HTTPNetStreamMetrics(param1:HTTPNetStream)
|
||||
{
|
||||
super(param1);
|
||||
this.httpNetStream = param1;
|
||||
}
|
||||
|
||||
public function get downloadRatio() : Number
|
||||
{
|
||||
return this.httpNetStream.downloadRatio;
|
||||
}
|
||||
|
||||
public function getBitrateForIndex(param1:int) : Number
|
||||
{
|
||||
return this.resource.streamItems[param1].bitrate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.net.URLRequest;
|
||||
|
||||
public class HTTPStreamRequest
|
||||
{
|
||||
|
||||
private var _urlRequest:URLRequest;
|
||||
|
||||
private var _quality:int;
|
||||
|
||||
private var _truncateAt:Number;
|
||||
|
||||
private var _retryAfter:Number;
|
||||
|
||||
private var _unpublishNotify:Boolean;
|
||||
|
||||
public function HTTPStreamRequest(param1:String = null, param2:int = -1, param3:Number = -1, param4:Number = -1, param5:Boolean = false)
|
||||
{
|
||||
super();
|
||||
if(param1)
|
||||
{
|
||||
this._urlRequest = new URLRequest(HTTPStreamingUtils.normalizeURL(param1));
|
||||
}
|
||||
else
|
||||
{
|
||||
this._urlRequest = null;
|
||||
}
|
||||
this._quality = param2;
|
||||
this._truncateAt = param3;
|
||||
this._retryAfter = param4;
|
||||
this._unpublishNotify = param5;
|
||||
}
|
||||
|
||||
public function get urlRequest() : URLRequest
|
||||
{
|
||||
return this._urlRequest;
|
||||
}
|
||||
|
||||
public function get retryAfter() : Number
|
||||
{
|
||||
return this._retryAfter;
|
||||
}
|
||||
|
||||
public function get unpublishNotify() : Boolean
|
||||
{
|
||||
return this._unpublishNotify;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
|
||||
public class HTTPStreamingFileHandlerBase extends EventDispatcher
|
||||
{
|
||||
|
||||
public function HTTPStreamingFileHandlerBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function beginProcessFile(param1:Boolean, param2:Number) : void
|
||||
{
|
||||
throw new IllegalOperationError("The beginProcessFile() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
|
||||
public function get inputBytesNeeded() : Number
|
||||
{
|
||||
throw new IllegalOperationError("The inputBytesNeeded() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
|
||||
public function processFileSegment(param1:IDataInput) : ByteArray
|
||||
{
|
||||
throw new IllegalOperationError("The processFileSegment() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
|
||||
public function endProcessFile(param1:IDataInput) : ByteArray
|
||||
{
|
||||
throw new IllegalOperationError("The endProcessFile() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
|
||||
public function flushFileSegment(param1:IDataInput) : ByteArray
|
||||
{
|
||||
throw new IllegalOperationError("The flushFileSegment() method must be overridden by HttpStreamingFileHandlerBase\'s derived class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
|
||||
public class HTTPStreamingIndexHandlerBase extends EventDispatcher
|
||||
{
|
||||
|
||||
public function HTTPStreamingIndexHandlerBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function initialize(param1:Object) : void
|
||||
{
|
||||
throw new IllegalOperationError("The initialize() method must be overridden by the derived class.");
|
||||
}
|
||||
|
||||
public function processIndexData(param1:*, param2:Object) : void
|
||||
{
|
||||
throw new IllegalOperationError("The processIndexData() method must be overridden by the derived class.");
|
||||
}
|
||||
|
||||
public function getFileForTime(param1:Number, param2:int) : HTTPStreamRequest
|
||||
{
|
||||
throw new IllegalOperationError("The getFileForTime() method must be overridden by the derived class.");
|
||||
}
|
||||
|
||||
public function getNextFile(param1:int) : HTTPStreamRequest
|
||||
{
|
||||
throw new IllegalOperationError("The getNextFile() method must be overridden by the derived class.");
|
||||
}
|
||||
|
||||
public function dvrGetStreamInfo(param1:Object) : void
|
||||
{
|
||||
throw new IllegalOperationError("The dvrGetStreamInfo() method must be overridden by the derived class.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
public class HTTPStreamingIndexInfoBase
|
||||
{
|
||||
|
||||
public function HTTPStreamingIndexInfoBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.events.DVRStreamInfoEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.metadata.MetadataNamespaces;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.NetLoader;
|
||||
import org.osmf.net.NetStreamLoadTrait;
|
||||
import org.osmf.net.NetStreamSwitchManager;
|
||||
import org.osmf.net.NetStreamSwitchManagerBase;
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
import org.osmf.net.httpstreaming.dvr.DVRInfo;
|
||||
import org.osmf.net.httpstreaming.dvr.HTTPStreamingDVRCastDVRTrait;
|
||||
import org.osmf.net.httpstreaming.dvr.HTTPStreamingDVRCastTimeTrait;
|
||||
import org.osmf.net.httpstreaming.f4f.HTTPStreamingF4FFileHandler;
|
||||
import org.osmf.net.httpstreaming.f4f.HTTPStreamingF4FIndexHandler;
|
||||
import org.osmf.net.rtmpstreaming.DroppedFramesRule;
|
||||
import org.osmf.traits.LoadState;
|
||||
|
||||
public class HTTPStreamingNetLoader extends NetLoader
|
||||
{
|
||||
|
||||
public function HTTPStreamingNetLoader()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
return param1.getMetadataValue(MetadataNamespaces.HTTP_STREAMING_METADATA) as Metadata != null;
|
||||
}
|
||||
|
||||
override protected function createNetStream(param1:NetConnection, param2:URLResource) : NetStream
|
||||
{
|
||||
var _loc3_:HTTPStreamingFileHandlerBase = new HTTPStreamingF4FFileHandler();
|
||||
var _loc4_:HTTPStreamingIndexHandlerBase = new HTTPStreamingF4FIndexHandler(_loc3_);
|
||||
var _loc5_:HTTPNetStream = new HTTPNetStream(param1,_loc4_,_loc3_);
|
||||
_loc5_.manualSwitchMode = true;
|
||||
_loc5_.indexInfo = HTTPStreamingUtils.createF4FIndexInfo(param2);
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
override protected function createNetStreamSwitchManager(param1:NetConnection, param2:NetStream, param3:DynamicStreamingResource) : NetStreamSwitchManagerBase
|
||||
{
|
||||
var _loc4_:HTTPNetStreamMetrics = null;
|
||||
if(param3 != null)
|
||||
{
|
||||
_loc4_ = new HTTPNetStreamMetrics(param2 as HTTPNetStream);
|
||||
return new NetStreamSwitchManager(param1,param2,param3,_loc4_,this.getDefaultSwitchingRules(_loc4_));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
override protected function processFinishLoading(param1:NetStreamLoadTrait) : void
|
||||
{
|
||||
var netStream:HTTPNetStream = null;
|
||||
var onDVRStreamInfo:Function = null;
|
||||
var loadTrait:NetStreamLoadTrait = param1;
|
||||
onDVRStreamInfo = function(param1:DVRStreamInfoEvent):void
|
||||
{
|
||||
netStream.removeEventListener(DVRStreamInfoEvent.DVRSTREAMINFO,onDVRStreamInfo);
|
||||
loadTrait.setTrait(new HTTPStreamingDVRCastDVRTrait(loadTrait.connection,netStream,param1.info as DVRInfo));
|
||||
loadTrait.setTrait(new HTTPStreamingDVRCastTimeTrait(loadTrait.connection,netStream,param1.info as DVRInfo));
|
||||
updateLoadTrait(loadTrait,LoadState.READY);
|
||||
};
|
||||
var resource:URLResource = loadTrait.resource as URLResource;
|
||||
if(!this.dvrMetadataPresent(resource))
|
||||
{
|
||||
updateLoadTrait(loadTrait,LoadState.READY);
|
||||
return;
|
||||
}
|
||||
netStream = loadTrait.netStream as HTTPNetStream;
|
||||
netStream.addEventListener(DVRStreamInfoEvent.DVRSTREAMINFO,onDVRStreamInfo);
|
||||
netStream.DVRGetStreamInfo(null);
|
||||
}
|
||||
|
||||
private function dvrMetadataPresent(param1:URLResource) : Boolean
|
||||
{
|
||||
var _loc2_:Metadata = param1.getMetadataValue(MetadataNamespaces.DVR_METADATA) as Metadata;
|
||||
return _loc2_ != null;
|
||||
}
|
||||
|
||||
private function getDefaultSwitchingRules(param1:HTTPNetStreamMetrics) : Vector.<SwitchingRuleBase>
|
||||
{
|
||||
var _loc2_:Vector.<SwitchingRuleBase> = new Vector.<SwitchingRuleBase>();
|
||||
_loc2_.push(new DownloadRatioRule(param1));
|
||||
_loc2_.push(new DroppedFramesRule(param1));
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
internal class HTTPStreamingState
|
||||
{
|
||||
|
||||
internal static const INIT:String = "init";
|
||||
|
||||
internal static const LOAD_SEEK:String = "loadSeek";
|
||||
|
||||
internal static const LOAD_SEEK_RETRY_WAIT:String = "loadSeekRetryWait";
|
||||
|
||||
internal static const LOAD:String = "load";
|
||||
|
||||
internal static const LOAD_WAIT:String = "loadWait";
|
||||
|
||||
internal static const LOAD_NEXT:String = "loadNext";
|
||||
|
||||
internal static const LOAD_NEXT_RETRY_WAIT:String = "loadNextRetryWait";
|
||||
|
||||
internal static const PLAY_START_SEEK:String = "playStartSeek";
|
||||
|
||||
internal static const PLAY_START_NEXT:String = "playStartNext";
|
||||
|
||||
internal static const PLAY_START_COMMON:String = "playStartCommon";
|
||||
|
||||
internal static const PLAY:String = "play";
|
||||
|
||||
internal static const END_SEGMENT:String = "endSegment";
|
||||
|
||||
internal static const SEEK:String = "seek";
|
||||
|
||||
internal static const STOP:String = "stop";
|
||||
|
||||
internal static const HALT:String = "halt";
|
||||
|
||||
public function HTTPStreamingState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
package org.osmf.net.httpstreaming
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.elements.f4mClasses.BootstrapInfo;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.metadata.MetadataNamespaces;
|
||||
import org.osmf.net.DynamicStreamingItem;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.httpstreaming.dvr.DVRInfo;
|
||||
import org.osmf.net.httpstreaming.f4f.HTTPStreamingF4FIndexInfo;
|
||||
import org.osmf.net.httpstreaming.f4f.HTTPStreamingF4FStreamInfo;
|
||||
|
||||
public class HTTPStreamingUtils
|
||||
{
|
||||
|
||||
public function HTTPStreamingUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function createHTTPStreamingMetadata(param1:String, param2:ByteArray, param3:Vector.<String>) : Metadata
|
||||
{
|
||||
var _loc4_:Metadata = new Metadata();
|
||||
var _loc5_:BootstrapInfo = new BootstrapInfo();
|
||||
if(param1 != null && param1.length > 0)
|
||||
{
|
||||
_loc5_.url = param1;
|
||||
}
|
||||
_loc5_.data = param2;
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_BOOTSTRAP_KEY,_loc5_);
|
||||
if(param3 != null && param3.length > 0)
|
||||
{
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_SERVER_BASE_URLS_KEY,param3);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public static function createF4FIndexInfo(param1:URLResource) : HTTPStreamingF4FIndexInfo
|
||||
{
|
||||
var _loc5_:Vector.<String> = null;
|
||||
var _loc6_:Vector.<HTTPStreamingF4FStreamInfo> = null;
|
||||
var _loc7_:DVRInfo = null;
|
||||
var _loc2_:HTTPStreamingF4FIndexInfo = null;
|
||||
var _loc3_:Metadata = param1.getMetadataValue(MetadataNamespaces.HTTP_STREAMING_METADATA) as Metadata;
|
||||
var _loc4_:Metadata = param1.getMetadataValue(MetadataNamespaces.DVR_METADATA) as Metadata;
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc5_ = _loc3_.getValue(MetadataNamespaces.HTTP_STREAMING_SERVER_BASE_URLS_KEY) as Vector.<String>;
|
||||
_loc6_ = generateStreamInfos(param1);
|
||||
_loc7_ = generateDVRInfo(_loc4_);
|
||||
_loc2_ = new HTTPStreamingF4FIndexInfo(_loc5_ != null && _loc5_.length > 0 ? _loc5_[0] : null,_loc6_,_loc7_);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function normalizeURL(param1:String) : String
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc2_:String = "";
|
||||
var _loc3_:String = "";
|
||||
if(param1.indexOf("http://") == 0)
|
||||
{
|
||||
_loc3_ = "http://";
|
||||
}
|
||||
else if(param1.indexOf("https://") == 0)
|
||||
{
|
||||
_loc3_ = "https://";
|
||||
}
|
||||
if(_loc3_.length > 0)
|
||||
{
|
||||
_loc4_ = param1.substr(_loc3_.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = param1;
|
||||
}
|
||||
var _loc5_:Array = _loc4_.split("/");
|
||||
var _loc6_:int = _loc5_.indexOf("..");
|
||||
while(_loc6_ >= 0)
|
||||
{
|
||||
_loc5_.splice(_loc6_ - 1,2);
|
||||
_loc6_ = _loc5_.indexOf("..");
|
||||
}
|
||||
_loc2_ = _loc3_;
|
||||
if(_loc5_.length > 0)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc5_.length)
|
||||
{
|
||||
if(_loc7_ != 0)
|
||||
{
|
||||
_loc2_ += "/";
|
||||
}
|
||||
_loc2_ += _loc5_[_loc7_] as String;
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private static function generateDVRInfo(param1:Metadata) : DVRInfo
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc2_:DVRInfo = new DVRInfo();
|
||||
_loc2_.id = "";
|
||||
_loc2_.beginOffset = NaN;
|
||||
_loc2_.endOffset = NaN;
|
||||
_loc2_.offline = false;
|
||||
if(param1.getValue(MetadataNamespaces.HTTP_STREAMING_DVR_ID_KEY) != null)
|
||||
{
|
||||
_loc2_.id = param1.getValue(MetadataNamespaces.HTTP_STREAMING_DVR_ID_KEY) as String;
|
||||
}
|
||||
if(param1.getValue(MetadataNamespaces.HTTP_STREAMING_DVR_BEGIN_OFFSET_KEY) != null)
|
||||
{
|
||||
_loc2_.beginOffset = param1.getValue(MetadataNamespaces.HTTP_STREAMING_DVR_BEGIN_OFFSET_KEY) as uint;
|
||||
}
|
||||
if(param1.getValue(MetadataNamespaces.HTTP_STREAMING_DVR_END_OFFSET_KEY) != null)
|
||||
{
|
||||
_loc2_.endOffset = param1.getValue(MetadataNamespaces.HTTP_STREAMING_DVR_END_OFFSET_KEY) as uint;
|
||||
}
|
||||
if(param1.getValue(MetadataNamespaces.HTTP_STREAMING_DVR_OFFLINE_KEY) != null)
|
||||
{
|
||||
_loc2_.offline = param1.getValue(MetadataNamespaces.HTTP_STREAMING_DVR_OFFLINE_KEY) as Boolean;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private static function generateStreamInfos(param1:URLResource) : Vector.<HTTPStreamingF4FStreamInfo>
|
||||
{
|
||||
var _loc8_:Object = null;
|
||||
var _loc9_:ByteArray = null;
|
||||
var _loc10_:DynamicStreamingItem = null;
|
||||
var _loc11_:String = null;
|
||||
var _loc2_:Vector.<HTTPStreamingF4FStreamInfo> = new Vector.<HTTPStreamingF4FStreamInfo>();
|
||||
var _loc3_:Metadata = param1.getMetadataValue(MetadataNamespaces.DRM_METADATA) as Metadata;
|
||||
var _loc4_:Metadata = param1.getMetadataValue(MetadataNamespaces.HTTP_STREAMING_METADATA) as Metadata;
|
||||
var _loc5_:ByteArray = null;
|
||||
var _loc6_:BootstrapInfo = null;
|
||||
var _loc7_:DynamicStreamingResource = param1 as DynamicStreamingResource;
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
for each(_loc10_ in _loc7_.streamItems)
|
||||
{
|
||||
_loc5_ = null;
|
||||
_loc6_ = null;
|
||||
_loc8_ = null;
|
||||
_loc9_ = null;
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc5_ = _loc3_.getValue(MetadataNamespaces.DRM_ADDITIONAL_HEADER_KEY + _loc10_.streamName) as ByteArray;
|
||||
}
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc6_ = _loc4_.getValue(MetadataNamespaces.HTTP_STREAMING_BOOTSTRAP_KEY + _loc10_.streamName) as BootstrapInfo;
|
||||
_loc8_ = _loc4_.getValue(MetadataNamespaces.HTTP_STREAMING_STREAM_METADATA_KEY + _loc10_.streamName);
|
||||
_loc9_ = _loc4_.getValue(MetadataNamespaces.HTTP_STREAMING_XMP_METADATA_KEY + _loc10_.streamName) as ByteArray;
|
||||
}
|
||||
_loc2_.push(new HTTPStreamingF4FStreamInfo(_loc6_,_loc10_.streamName,_loc10_.bitrate,_loc5_,_loc8_,_loc9_));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc5_ = _loc3_.getValue(MetadataNamespaces.DRM_ADDITIONAL_HEADER_KEY) as ByteArray;
|
||||
}
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc6_ = _loc4_.getValue(MetadataNamespaces.HTTP_STREAMING_BOOTSTRAP_KEY) as BootstrapInfo;
|
||||
_loc8_ = _loc4_.getValue(MetadataNamespaces.HTTP_STREAMING_STREAM_METADATA_KEY);
|
||||
_loc9_ = _loc4_.getValue(MetadataNamespaces.HTTP_STREAMING_XMP_METADATA_KEY) as ByteArray;
|
||||
}
|
||||
_loc11_ = param1.url;
|
||||
_loc2_.push(new HTTPStreamingF4FStreamInfo(_loc6_,_loc11_,NaN,_loc5_,_loc8_,_loc9_));
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.osmf.net.httpstreaming.dvr
|
||||
{
|
||||
public class DVRInfo
|
||||
{
|
||||
|
||||
public var id:String;
|
||||
|
||||
public var url:String;
|
||||
|
||||
public var beginOffset:uint = 0;
|
||||
|
||||
public var endOffset:uint = 0;
|
||||
|
||||
public var offline:Boolean;
|
||||
|
||||
public var isRecording:Boolean;
|
||||
|
||||
public var curLength:Number;
|
||||
|
||||
public var startTime:Number = NaN;
|
||||
|
||||
public function DVRInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package org.osmf.net.httpstreaming.dvr
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import org.osmf.events.DVRStreamInfoEvent;
|
||||
import org.osmf.net.httpstreaming.HTTPNetStream;
|
||||
import org.osmf.traits.DVRTrait;
|
||||
|
||||
public class HTTPStreamingDVRCastDVRTrait extends DVRTrait
|
||||
{
|
||||
|
||||
private var _connection:NetConnection;
|
||||
|
||||
private var _stream:HTTPNetStream;
|
||||
|
||||
private var _dvrInfo:DVRInfo;
|
||||
|
||||
public function HTTPStreamingDVRCastDVRTrait(param1:NetConnection, param2:HTTPNetStream, param3:DVRInfo)
|
||||
{
|
||||
this._connection = param1;
|
||||
this._stream = param2;
|
||||
this._dvrInfo = param3;
|
||||
this._stream.addEventListener(DVRStreamInfoEvent.DVRSTREAMINFO,this.onDVRStreamInfo);
|
||||
super(param3.isRecording);
|
||||
}
|
||||
|
||||
private function onDVRStreamInfo(param1:DVRStreamInfoEvent) : void
|
||||
{
|
||||
this._dvrInfo = param1.info as DVRInfo;
|
||||
setIsRecording(this._dvrInfo == null ? false : this._dvrInfo.isRecording);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package org.osmf.net.httpstreaming.dvr
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.NetConnection;
|
||||
import org.osmf.events.DVRStreamInfoEvent;
|
||||
import org.osmf.net.NetStreamCodes;
|
||||
import org.osmf.net.httpstreaming.HTTPNetStream;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class HTTPStreamingDVRCastTimeTrait extends TimeTrait
|
||||
{
|
||||
|
||||
private var _connection:NetConnection;
|
||||
|
||||
private var _stream:HTTPNetStream;
|
||||
|
||||
private var _dvrInfo:DVRInfo;
|
||||
|
||||
public function HTTPStreamingDVRCastTimeTrait(param1:NetConnection, param2:HTTPNetStream, param3:DVRInfo)
|
||||
{
|
||||
super(NaN);
|
||||
this._connection = param1;
|
||||
this._stream = param2;
|
||||
this._dvrInfo = param3;
|
||||
this._stream.addEventListener(DVRStreamInfoEvent.DVRSTREAMINFO,this.onDVRStreamInfo);
|
||||
this._stream.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatus);
|
||||
}
|
||||
|
||||
override public function get duration() : Number
|
||||
{
|
||||
if(this._dvrInfo == null)
|
||||
{
|
||||
return NaN;
|
||||
}
|
||||
return this._dvrInfo.curLength;
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return this._stream.time;
|
||||
}
|
||||
|
||||
private function onDVRStreamInfo(param1:DVRStreamInfoEvent) : void
|
||||
{
|
||||
this._dvrInfo = param1.info as DVRInfo;
|
||||
setDuration(this._dvrInfo.curLength);
|
||||
}
|
||||
|
||||
private function onNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_UNPUBLISH_NOTIFY:
|
||||
signalComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
public class AdobeBootstrapBox extends FullBox
|
||||
{
|
||||
|
||||
private var _bootstrapVersion:uint;
|
||||
|
||||
private var _profile:uint;
|
||||
|
||||
private var _live:Boolean;
|
||||
|
||||
private var _update:Boolean;
|
||||
|
||||
private var _timeScale:uint;
|
||||
|
||||
private var _currentMediaTime:Number;
|
||||
|
||||
private var _smpteTimeCodeOffset:Number;
|
||||
|
||||
private var _movieIdentifier:String;
|
||||
|
||||
private var _serverEntryCount:uint;
|
||||
|
||||
private var _serverBaseURLs:Vector.<String>;
|
||||
|
||||
private var _qualitySegmentURLModifiers:Vector.<String>;
|
||||
|
||||
private var _drmData:String;
|
||||
|
||||
private var _metadata:String;
|
||||
|
||||
private var _segmentRunTables:Vector.<AdobeSegmentRunTable>;
|
||||
|
||||
private var _fragmentRunTables:Vector.<AdobeFragmentRunTable>;
|
||||
|
||||
public function AdobeBootstrapBox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get bootstrapVersion() : uint
|
||||
{
|
||||
return this._bootstrapVersion;
|
||||
}
|
||||
|
||||
public function set bootstrapVersion(param1:uint) : void
|
||||
{
|
||||
this._bootstrapVersion = param1;
|
||||
}
|
||||
|
||||
public function get profile() : uint
|
||||
{
|
||||
return this._profile;
|
||||
}
|
||||
|
||||
public function set profile(param1:uint) : void
|
||||
{
|
||||
this._profile = param1;
|
||||
}
|
||||
|
||||
public function get live() : Boolean
|
||||
{
|
||||
return this._live;
|
||||
}
|
||||
|
||||
public function set live(param1:Boolean) : void
|
||||
{
|
||||
this._live = param1;
|
||||
}
|
||||
|
||||
public function get update() : Boolean
|
||||
{
|
||||
return this._update;
|
||||
}
|
||||
|
||||
public function set update(param1:Boolean) : void
|
||||
{
|
||||
this._update = param1;
|
||||
}
|
||||
|
||||
public function get timeScale() : uint
|
||||
{
|
||||
return this._timeScale;
|
||||
}
|
||||
|
||||
public function set timeScale(param1:uint) : void
|
||||
{
|
||||
this._timeScale = param1;
|
||||
}
|
||||
|
||||
public function get currentMediaTime() : Number
|
||||
{
|
||||
return this._currentMediaTime;
|
||||
}
|
||||
|
||||
public function set currentMediaTime(param1:Number) : void
|
||||
{
|
||||
this._currentMediaTime = param1;
|
||||
}
|
||||
|
||||
public function get smpteTimeCodeOffset() : Number
|
||||
{
|
||||
return this._smpteTimeCodeOffset;
|
||||
}
|
||||
|
||||
public function set smpteTimeCodeOffset(param1:Number) : void
|
||||
{
|
||||
this._smpteTimeCodeOffset = param1;
|
||||
}
|
||||
|
||||
public function get movieIdentifier() : String
|
||||
{
|
||||
return this._movieIdentifier;
|
||||
}
|
||||
|
||||
public function set movieIdentifier(param1:String) : void
|
||||
{
|
||||
this._movieIdentifier = param1;
|
||||
}
|
||||
|
||||
public function get serverBaseURLs() : Vector.<String>
|
||||
{
|
||||
return this._serverBaseURLs;
|
||||
}
|
||||
|
||||
public function set serverBaseURLs(param1:Vector.<String>) : void
|
||||
{
|
||||
this._serverBaseURLs = param1;
|
||||
}
|
||||
|
||||
public function get qualitySegmentURLModifiers() : Vector.<String>
|
||||
{
|
||||
return this._qualitySegmentURLModifiers;
|
||||
}
|
||||
|
||||
public function set qualitySegmentURLModifiers(param1:Vector.<String>) : void
|
||||
{
|
||||
this._qualitySegmentURLModifiers = param1;
|
||||
}
|
||||
|
||||
public function get drmData() : String
|
||||
{
|
||||
return this._drmData;
|
||||
}
|
||||
|
||||
public function set drmData(param1:String) : void
|
||||
{
|
||||
this._drmData = param1;
|
||||
}
|
||||
|
||||
public function get metadata() : String
|
||||
{
|
||||
return this._metadata;
|
||||
}
|
||||
|
||||
public function set metadata(param1:String) : void
|
||||
{
|
||||
this._metadata = param1;
|
||||
}
|
||||
|
||||
public function get segmentRunTables() : Vector.<AdobeSegmentRunTable>
|
||||
{
|
||||
return this._segmentRunTables;
|
||||
}
|
||||
|
||||
public function set segmentRunTables(param1:Vector.<AdobeSegmentRunTable>) : void
|
||||
{
|
||||
this._segmentRunTables = param1;
|
||||
}
|
||||
|
||||
public function get fragmentRunTables() : Vector.<AdobeFragmentRunTable>
|
||||
{
|
||||
return this._fragmentRunTables;
|
||||
}
|
||||
|
||||
public function set fragmentRunTables(param1:Vector.<AdobeFragmentRunTable>) : void
|
||||
{
|
||||
var _loc2_:AdobeFragmentRunTable = null;
|
||||
this._fragmentRunTables = param1;
|
||||
if(param1 != null && param1.length > 0)
|
||||
{
|
||||
_loc2_ = param1[param1.length - 1];
|
||||
_loc2_.adjustEndEntryDurationAccrued(this._currentMediaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public function findSegmentId(param1:uint) : uint
|
||||
{
|
||||
return this._segmentRunTables[0].findSegmentIdByFragmentId(param1);
|
||||
}
|
||||
|
||||
public function get totalFragments() : uint
|
||||
{
|
||||
var _loc1_:AdobeFragmentRunTable = this._fragmentRunTables[this._fragmentRunTables.length - 1];
|
||||
var _loc2_:Vector.<FragmentDurationPair> = _loc1_.fragmentDurationPairs;
|
||||
var _loc3_:FragmentDurationPair = _loc2_[_loc2_.length - 1];
|
||||
if(_loc3_.duration == 0)
|
||||
{
|
||||
_loc3_ = _loc2_[_loc2_.length - 2];
|
||||
}
|
||||
var _loc4_:Number = this._currentMediaTime - _loc3_.durationAccrued;
|
||||
var _loc5_:uint = _loc4_ <= 0 ? 0 : uint(_loc4_ / _loc3_.duration);
|
||||
return _loc3_.firstFragment + _loc5_ - 1;
|
||||
}
|
||||
|
||||
public function get totalDuration() : uint
|
||||
{
|
||||
if(this._fragmentRunTables == null || this._fragmentRunTables.length < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc1_:AdobeFragmentRunTable = this._fragmentRunTables[0];
|
||||
return this._currentMediaTime - _loc1_.fragmentDurationPairs[0].durationAccrued;
|
||||
}
|
||||
|
||||
public function contentComplete() : Boolean
|
||||
{
|
||||
var _loc1_:AdobeFragmentRunTable = this._fragmentRunTables[this._fragmentRunTables.length - 1];
|
||||
return _loc1_.tableComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class AdobeFragmentRandomAccessBox extends FullBox
|
||||
{
|
||||
|
||||
private var _timeScale:uint;
|
||||
|
||||
private var _localRandomAccessEntries:Vector.<LocalRandomAccessEntry>;
|
||||
|
||||
private var _globalRandomAccessEntries:Vector.<GlobalRandomAccessEntry>;
|
||||
|
||||
public function AdobeFragmentRandomAccessBox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get timeScale() : uint
|
||||
{
|
||||
return this._timeScale;
|
||||
}
|
||||
|
||||
public function set timeScale(param1:uint) : void
|
||||
{
|
||||
this._timeScale = param1;
|
||||
}
|
||||
|
||||
public function get localRandomAccessEntries() : Vector.<LocalRandomAccessEntry>
|
||||
{
|
||||
return this._localRandomAccessEntries;
|
||||
}
|
||||
|
||||
public function set localRandomAccessEntries(param1:Vector.<LocalRandomAccessEntry>) : void
|
||||
{
|
||||
this._localRandomAccessEntries = param1;
|
||||
}
|
||||
|
||||
public function get globalRandomAccessEntries() : Vector.<GlobalRandomAccessEntry>
|
||||
{
|
||||
return this._globalRandomAccessEntries;
|
||||
}
|
||||
|
||||
public function set globalRandomAccessEntries(param1:Vector.<GlobalRandomAccessEntry>) : void
|
||||
{
|
||||
this._globalRandomAccessEntries = param1;
|
||||
}
|
||||
|
||||
public function findNearestKeyFrameOffset(param1:Number) : LocalRandomAccessEntry
|
||||
{
|
||||
var _loc3_:LocalRandomAccessEntry = null;
|
||||
var _loc2_:* = int(this._localRandomAccessEntries.length - 1);
|
||||
while(_loc2_ >= 0)
|
||||
{
|
||||
_loc3_ = this._localRandomAccessEntries[_loc2_];
|
||||
if(_loc3_.time <= param1)
|
||||
{
|
||||
return _loc3_;
|
||||
}
|
||||
_loc2_--;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class AdobeFragmentRunTable extends FullBox
|
||||
{
|
||||
|
||||
private var _timeScale:uint;
|
||||
|
||||
private var _qualitySegmentURLModifiers:Vector.<String>;
|
||||
|
||||
private var _fragmentDurationPairs:Vector.<FragmentDurationPair>;
|
||||
|
||||
public function AdobeFragmentRunTable()
|
||||
{
|
||||
super();
|
||||
this._fragmentDurationPairs = new Vector.<FragmentDurationPair>();
|
||||
}
|
||||
|
||||
public function get timeScale() : uint
|
||||
{
|
||||
return this._timeScale;
|
||||
}
|
||||
|
||||
public function set timeScale(param1:uint) : void
|
||||
{
|
||||
this._timeScale = param1;
|
||||
}
|
||||
|
||||
public function get qualitySegmentURLModifiers() : Vector.<String>
|
||||
{
|
||||
return this._qualitySegmentURLModifiers;
|
||||
}
|
||||
|
||||
public function set qualitySegmentURLModifiers(param1:Vector.<String>) : void
|
||||
{
|
||||
this._qualitySegmentURLModifiers = param1;
|
||||
}
|
||||
|
||||
public function get fragmentDurationPairs() : Vector.<FragmentDurationPair>
|
||||
{
|
||||
return this._fragmentDurationPairs;
|
||||
}
|
||||
|
||||
public function addFragmentDurationPair(param1:FragmentDurationPair) : void
|
||||
{
|
||||
this._fragmentDurationPairs.push(param1);
|
||||
}
|
||||
|
||||
public function findFragmentIdByTime(param1:Number, param2:Number, param3:Boolean = false) : FragmentAccessInformation
|
||||
{
|
||||
if(this._fragmentDurationPairs.length <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc4_:FragmentDurationPair = null;
|
||||
var _loc5_:uint = 1;
|
||||
while(_loc5_ < this._fragmentDurationPairs.length)
|
||||
{
|
||||
_loc4_ = this._fragmentDurationPairs[_loc5_];
|
||||
if(_loc4_.durationAccrued >= param1)
|
||||
{
|
||||
return this.validateFragment(this.calculateFragmentId(this._fragmentDurationPairs[_loc5_ - 1],param1),param2,param3);
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return this.validateFragment(this.calculateFragmentId(this._fragmentDurationPairs[this._fragmentDurationPairs.length - 1],param1),param2,param3);
|
||||
}
|
||||
|
||||
public function validateFragment(param1:uint, param2:Number, param3:Boolean = false) : FragmentAccessInformation
|
||||
{
|
||||
var _loc7_:FragmentDurationPair = null;
|
||||
var _loc8_:FragmentDurationPair = null;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc12_:FragmentDurationPair = null;
|
||||
var _loc4_:uint = this._fragmentDurationPairs.length - 1;
|
||||
var _loc5_:FragmentAccessInformation = null;
|
||||
var _loc6_:uint = 0;
|
||||
while(_loc6_ < _loc4_)
|
||||
{
|
||||
_loc7_ = this._fragmentDurationPairs[_loc6_];
|
||||
_loc8_ = this._fragmentDurationPairs[_loc6_ + 1];
|
||||
if(_loc7_.firstFragment <= param1 && param1 < _loc8_.firstFragment)
|
||||
{
|
||||
if(_loc7_.duration <= 0)
|
||||
{
|
||||
_loc5_ = this.getNextValidFragment(_loc6_ + 1,param2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = new FragmentAccessInformation();
|
||||
_loc5_.fragId = param1;
|
||||
_loc5_.fragDuration = _loc7_.duration;
|
||||
_loc5_.fragmentEndTime = _loc7_.durationAccrued + _loc7_.duration * (param1 - _loc7_.firstFragment + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(_loc7_.firstFragment <= param1 && this.endOfStreamEntry(_loc8_))
|
||||
{
|
||||
if(_loc7_.duration > 0)
|
||||
{
|
||||
_loc9_ = param2 - _loc7_.durationAccrued;
|
||||
_loc10_ = (param1 - _loc7_.firstFragment + 1) * _loc7_.duration;
|
||||
_loc11_ = (param1 - _loc7_.firstFragment) * _loc7_.duration;
|
||||
if(_loc9_ > _loc11_)
|
||||
{
|
||||
if(!param3 || _loc11_ + _loc7_.duration + _loc7_.durationAccrued <= param2)
|
||||
{
|
||||
_loc5_ = new FragmentAccessInformation();
|
||||
_loc5_.fragId = param1;
|
||||
_loc5_.fragDuration = _loc7_.duration;
|
||||
if(_loc9_ >= _loc10_)
|
||||
{
|
||||
_loc5_.fragmentEndTime = _loc7_.durationAccrued + _loc10_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.fragmentEndTime = _loc7_.durationAccrued + _loc9_;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
if(_loc5_ == null)
|
||||
{
|
||||
_loc12_ = this._fragmentDurationPairs[_loc4_];
|
||||
if(_loc12_.duration > 0 && param1 >= _loc12_.firstFragment)
|
||||
{
|
||||
_loc9_ = param2 - _loc12_.durationAccrued;
|
||||
_loc10_ = (param1 - _loc12_.firstFragment + 1) * _loc12_.duration;
|
||||
_loc11_ = (param1 - _loc12_.firstFragment) * _loc12_.duration;
|
||||
if(_loc9_ > _loc11_)
|
||||
{
|
||||
if(!param3 || _loc11_ + _loc12_.duration + _loc12_.durationAccrued <= param2)
|
||||
{
|
||||
_loc5_ = new FragmentAccessInformation();
|
||||
_loc5_.fragId = param1;
|
||||
_loc5_.fragDuration = _loc12_.duration;
|
||||
if(_loc9_ >= _loc10_)
|
||||
{
|
||||
_loc5_.fragmentEndTime = _loc12_.durationAccrued + _loc10_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.fragmentEndTime = _loc12_.durationAccrued + _loc9_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function getNextValidFragment(param1:uint, param2:Number) : FragmentAccessInformation
|
||||
{
|
||||
var _loc5_:FragmentDurationPair = null;
|
||||
var _loc3_:FragmentAccessInformation = null;
|
||||
var _loc4_:uint = param1;
|
||||
while(_loc4_ < this._fragmentDurationPairs.length)
|
||||
{
|
||||
_loc5_ = this._fragmentDurationPairs[_loc4_];
|
||||
if(_loc5_.duration > 0)
|
||||
{
|
||||
_loc3_ = new FragmentAccessInformation();
|
||||
_loc3_.fragId = _loc5_.firstFragment;
|
||||
_loc3_.fragDuration = _loc5_.duration;
|
||||
_loc3_.fragmentEndTime = _loc5_.durationAccrued + _loc5_.duration;
|
||||
break;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function endOfStreamEntry(param1:FragmentDurationPair) : Boolean
|
||||
{
|
||||
return param1.duration == 0 && param1.discontinuityIndicator == 0;
|
||||
}
|
||||
|
||||
public function fragmentsLeft(param1:uint, param2:Number) : uint
|
||||
{
|
||||
if(this._fragmentDurationPairs == null || this._fragmentDurationPairs.length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc3_:FragmentDurationPair = this._fragmentDurationPairs[this.fragmentDurationPairs.length - 1] as FragmentDurationPair;
|
||||
return uint((param2 - _loc3_.durationAccrued) / _loc3_.duration + _loc3_.firstFragment - param1 - 1);
|
||||
}
|
||||
|
||||
public function tableComplete() : Boolean
|
||||
{
|
||||
if(this._fragmentDurationPairs == null || this._fragmentDurationPairs.length <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc1_:FragmentDurationPair = this._fragmentDurationPairs[this.fragmentDurationPairs.length - 1] as FragmentDurationPair;
|
||||
return _loc1_.duration == 0 && _loc1_.discontinuityIndicator == 0;
|
||||
}
|
||||
|
||||
public function adjustEndEntryDurationAccrued(param1:Number) : void
|
||||
{
|
||||
var _loc2_:FragmentDurationPair = this._fragmentDurationPairs[this._fragmentDurationPairs.length - 1];
|
||||
if(_loc2_.duration == 0)
|
||||
{
|
||||
_loc2_.durationAccrued = param1;
|
||||
}
|
||||
}
|
||||
|
||||
private function findValidFragmentDurationPair(param1:uint) : FragmentDurationPair
|
||||
{
|
||||
var _loc3_:FragmentDurationPair = null;
|
||||
var _loc2_:uint = param1;
|
||||
while(param1 < this._fragmentDurationPairs.length)
|
||||
{
|
||||
_loc3_ = this._fragmentDurationPairs[_loc2_];
|
||||
if(_loc3_.duration > 0)
|
||||
{
|
||||
return _loc3_;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function calculateFragmentId(param1:FragmentDurationPair, param2:Number) : uint
|
||||
{
|
||||
if(param1.duration <= 0)
|
||||
{
|
||||
return param1.firstFragment;
|
||||
}
|
||||
var _loc3_:Number = param2 - param1.durationAccrued;
|
||||
var _loc4_:uint = _loc3_ > 0 ? uint(_loc3_ / param1.duration) : 1;
|
||||
if(_loc3_ % param1.duration > 0)
|
||||
{
|
||||
_loc4_++;
|
||||
}
|
||||
return param1.firstFragment + _loc4_ - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class AdobeSegmentRunTable extends FullBox
|
||||
{
|
||||
|
||||
private var _qualitySegmentURLModifiers:Vector.<String>;
|
||||
|
||||
private var _segmentFragmentPairs:Vector.<SegmentFragmentPair>;
|
||||
|
||||
public function AdobeSegmentRunTable()
|
||||
{
|
||||
super();
|
||||
this._segmentFragmentPairs = new Vector.<SegmentFragmentPair>();
|
||||
}
|
||||
|
||||
public function get qualitySegmentURLModifiers() : Vector.<String>
|
||||
{
|
||||
return this._qualitySegmentURLModifiers;
|
||||
}
|
||||
|
||||
public function set qualitySegmentURLModifiers(param1:Vector.<String>) : void
|
||||
{
|
||||
this._qualitySegmentURLModifiers = param1;
|
||||
}
|
||||
|
||||
public function get segmentFragmentPairs() : Vector.<SegmentFragmentPair>
|
||||
{
|
||||
return this._segmentFragmentPairs;
|
||||
}
|
||||
|
||||
public function addSegmentFragmentPair(param1:SegmentFragmentPair) : void
|
||||
{
|
||||
var _loc2_:SegmentFragmentPair = this._segmentFragmentPairs.length <= 0 ? null : this._segmentFragmentPairs[this._segmentFragmentPairs.length - 1];
|
||||
var _loc3_:uint = 0;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ = _loc2_.fragmentsAccrued + (param1.firstSegment - _loc2_.firstSegment) * _loc2_.fragmentsPerSegment;
|
||||
}
|
||||
param1.fragmentsAccrued = _loc3_;
|
||||
this._segmentFragmentPairs.push(param1);
|
||||
}
|
||||
|
||||
public function findSegmentIdByFragmentId(param1:uint) : uint
|
||||
{
|
||||
var _loc2_:SegmentFragmentPair = null;
|
||||
if(param1 < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc3_:uint = 1;
|
||||
while(_loc3_ < this._segmentFragmentPairs.length)
|
||||
{
|
||||
_loc2_ = this._segmentFragmentPairs[_loc3_];
|
||||
if(_loc2_.fragmentsAccrued >= param1)
|
||||
{
|
||||
return this.calculateSegmentId(this._segmentFragmentPairs[_loc3_ - 1],param1);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return this.calculateSegmentId(this._segmentFragmentPairs[this._segmentFragmentPairs.length - 1],param1);
|
||||
}
|
||||
|
||||
public function get totalFragments() : uint
|
||||
{
|
||||
return this._segmentFragmentPairs[this._segmentFragmentPairs.length - 1].fragmentsPerSegment + this._segmentFragmentPairs[this._segmentFragmentPairs.length - 1].fragmentsAccrued;
|
||||
}
|
||||
|
||||
private function calculateSegmentId(param1:SegmentFragmentPair, param2:uint) : uint
|
||||
{
|
||||
return param1.firstSegment + int((param2 - param1.fragmentsAccrued - 1) / param1.fragmentsPerSegment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class Box
|
||||
{
|
||||
|
||||
private var _size:Number;
|
||||
|
||||
private var _type:String;
|
||||
|
||||
private var _boxLength:uint;
|
||||
|
||||
public function Box()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get size() : Number
|
||||
{
|
||||
return this._size;
|
||||
}
|
||||
|
||||
public function set size(param1:Number) : void
|
||||
{
|
||||
this._size = param1;
|
||||
}
|
||||
|
||||
public function get type() : String
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public function set type(param1:String) : void
|
||||
{
|
||||
this._type = param1;
|
||||
}
|
||||
|
||||
public function get boxLength() : uint
|
||||
{
|
||||
return this._boxLength;
|
||||
}
|
||||
|
||||
public function set boxLength(param1:uint) : void
|
||||
{
|
||||
this._boxLength = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class BoxInfo
|
||||
{
|
||||
|
||||
private var _size:Number;
|
||||
|
||||
private var _type:String;
|
||||
|
||||
public function BoxInfo(param1:Number, param2:String)
|
||||
{
|
||||
super();
|
||||
this._size = param1;
|
||||
this._type = param2;
|
||||
}
|
||||
|
||||
public function get size() : Number
|
||||
{
|
||||
return this._size;
|
||||
}
|
||||
|
||||
public function set size(param1:Number) : void
|
||||
{
|
||||
this._size = param1;
|
||||
}
|
||||
|
||||
public function get type() : String
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,412 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
internal class BoxParser extends EventDispatcher
|
||||
{
|
||||
|
||||
private static const FULL_BOX_FIELD_FLAGS_LENGTH:uint = 3;
|
||||
|
||||
private static const AFRA_MASK_LONG_ID:uint = 128;
|
||||
|
||||
private static const AFRA_MASK_LONG_OFFSET:uint = 64;
|
||||
|
||||
private static const AFRA_MASK_GLOBAL_ENTRIES:uint = 32;
|
||||
|
||||
private var _ba:ByteArray;
|
||||
|
||||
public function BoxParser()
|
||||
{
|
||||
super();
|
||||
this._ba = null;
|
||||
}
|
||||
|
||||
public function init(param1:ByteArray) : void
|
||||
{
|
||||
this._ba = param1;
|
||||
this._ba.position = 0;
|
||||
}
|
||||
|
||||
public function getNextBoxInfo() : BoxInfo
|
||||
{
|
||||
if(this._ba == null || this._ba.bytesAvailable < F4FConstants.FIELD_SIZE_LENGTH + F4FConstants.FIELD_TYPE_LENGTH)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc1_:Number = this._ba.readUnsignedInt();
|
||||
var _loc2_:String = this._ba.readUTFBytes(F4FConstants.FIELD_TYPE_LENGTH);
|
||||
return new BoxInfo(_loc1_,_loc2_);
|
||||
}
|
||||
|
||||
public function getBoxes() : Vector.<Box>
|
||||
{
|
||||
var _loc3_:AdobeBootstrapBox = null;
|
||||
var _loc4_:AdobeFragmentRandomAccessBox = null;
|
||||
var _loc5_:MediaDataBox = null;
|
||||
var _loc1_:Vector.<Box> = new Vector.<Box>();
|
||||
var _loc2_:BoxInfo = this.getNextBoxInfo();
|
||||
while(_loc2_ != null)
|
||||
{
|
||||
if(_loc2_.type == F4FConstants.BOX_TYPE_ABST)
|
||||
{
|
||||
_loc3_ = new AdobeBootstrapBox();
|
||||
this.parseAdobeBootstrapBox(_loc2_,_loc3_);
|
||||
_loc1_.push(_loc3_);
|
||||
}
|
||||
else if(_loc2_.type == F4FConstants.BOX_TYPE_AFRA)
|
||||
{
|
||||
_loc4_ = new AdobeFragmentRandomAccessBox();
|
||||
this.parseAdobeFragmentRandomAccessBox(_loc2_,_loc4_);
|
||||
_loc1_.push(_loc4_);
|
||||
}
|
||||
else if(_loc2_.type == F4FConstants.BOX_TYPE_MDAT)
|
||||
{
|
||||
_loc5_ = new MediaDataBox();
|
||||
this.parseMediaDataBox(_loc2_,_loc5_);
|
||||
_loc1_.push(_loc5_);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._ba.position = this._ba.position + _loc2_.size - (F4FConstants.FIELD_SIZE_LENGTH + F4FConstants.FIELD_TYPE_LENGTH);
|
||||
}
|
||||
_loc2_ = this.getNextBoxInfo();
|
||||
if(_loc2_ != null && _loc2_.size <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function readFragmentRandomAccessBox(param1:BoxInfo) : AdobeFragmentRandomAccessBox
|
||||
{
|
||||
var _loc2_:AdobeFragmentRandomAccessBox = new AdobeFragmentRandomAccessBox();
|
||||
this.parseAdobeFragmentRandomAccessBox(param1,_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function readAdobeBootstrapBox(param1:BoxInfo) : AdobeBootstrapBox
|
||||
{
|
||||
var _loc2_:AdobeBootstrapBox = new AdobeBootstrapBox();
|
||||
this.parseAdobeBootstrapBox(param1,_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
internal function readLongUIntToNumber() : Number
|
||||
{
|
||||
if(this._ba == null || this._ba.bytesAvailable < 8)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readLongUIntToNumer");
|
||||
}
|
||||
var _loc1_:Number = this._ba.readUnsignedInt();
|
||||
_loc1_ *= 4294967296;
|
||||
return _loc1_ + this._ba.readUnsignedInt();
|
||||
}
|
||||
|
||||
private function readUnsignedInt() : uint
|
||||
{
|
||||
if(this._ba == null || this._ba.bytesAvailable < 4)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readUnsignedInt");
|
||||
}
|
||||
return this._ba.readUnsignedInt();
|
||||
}
|
||||
|
||||
private function readBytes(param1:ByteArray, param2:uint = 0, param3:uint = 0) : void
|
||||
{
|
||||
if(this._ba == null || this._ba.bytesAvailable < param3)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readBytes: " + param3);
|
||||
}
|
||||
return this._ba.readBytes(param1,param2,param3);
|
||||
}
|
||||
|
||||
private function readUnsignedByte() : uint
|
||||
{
|
||||
if(this._ba == null || this._ba.bytesAvailable < 1)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readUnsingedByte");
|
||||
}
|
||||
return this._ba.readUnsignedByte();
|
||||
}
|
||||
|
||||
private function readBytesToUint(param1:uint) : uint
|
||||
{
|
||||
var _loc4_:uint = 0;
|
||||
if(this._ba == null || this._ba.bytesAvailable < param1)
|
||||
{
|
||||
throw new IllegalOperationError("not enough length for readUnsingedByte");
|
||||
}
|
||||
if(param1 > 4)
|
||||
{
|
||||
throw new IllegalOperationError("number of bytes to read must be equal or less than 4");
|
||||
}
|
||||
var _loc2_:uint = 0;
|
||||
var _loc3_:uint = 0;
|
||||
while(_loc3_ < param1)
|
||||
{
|
||||
_loc2_ <<= 8;
|
||||
_loc4_ = this._ba.readUnsignedByte();
|
||||
_loc2_ += _loc4_;
|
||||
_loc3_++;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function readString() : String
|
||||
{
|
||||
var _loc3_:uint = 0;
|
||||
var _loc1_:uint = this._ba.position;
|
||||
while(this._ba.position < this._ba.length)
|
||||
{
|
||||
_loc3_ = uint(this._ba.readByte());
|
||||
if(_loc3_ == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
var _loc2_:uint = this._ba.position - _loc1_;
|
||||
this._ba.position = _loc1_;
|
||||
return this._ba.readUTFBytes(_loc2_);
|
||||
}
|
||||
|
||||
private function parseBox(param1:BoxInfo, param2:Box) : void
|
||||
{
|
||||
var _loc5_:ByteArray = null;
|
||||
var _loc3_:Number = param1.size;
|
||||
var _loc4_:uint = F4FConstants.FIELD_SIZE_LENGTH + F4FConstants.FIELD_TYPE_LENGTH;
|
||||
if(param1.size == F4FConstants.FLAG_USE_LARGE_SIZE)
|
||||
{
|
||||
_loc3_ = this.readLongUIntToNumber();
|
||||
_loc4_ += F4FConstants.FIELD_LARGE_SIZE_LENGTH;
|
||||
}
|
||||
if(param1.type == F4FConstants.EXTENDED_TYPE)
|
||||
{
|
||||
_loc5_ = new ByteArray();
|
||||
this.readBytes(_loc5_,0,F4FConstants.FIELD_EXTENDED_TYPE_LENGTH);
|
||||
_loc4_ += F4FConstants.FIELD_EXTENDED_TYPE_LENGTH;
|
||||
}
|
||||
param2.size = _loc3_;
|
||||
param2.type = param1.type;
|
||||
param2.boxLength = _loc4_;
|
||||
}
|
||||
|
||||
private function parseFullBox(param1:BoxInfo, param2:FullBox) : void
|
||||
{
|
||||
this.parseBox(param1,param2);
|
||||
param2.version = this.readUnsignedByte();
|
||||
param2.flags = this.readBytesToUint(FULL_BOX_FIELD_FLAGS_LENGTH);
|
||||
}
|
||||
|
||||
private function parseAdobeBootstrapBox(param1:BoxInfo, param2:AdobeBootstrapBox) : void
|
||||
{
|
||||
var _loc13_:AdobeSegmentRunTable = null;
|
||||
var _loc14_:AdobeFragmentRunTable = null;
|
||||
this.parseFullBox(param1,param2);
|
||||
param2.bootstrapVersion = this.readUnsignedInt();
|
||||
var _loc3_:uint = this.readUnsignedByte();
|
||||
param2.profile = _loc3_ >> 6;
|
||||
param2.live = (_loc3_ & 0x20) == 32;
|
||||
param2.update = (_loc3_ & 1) == 1;
|
||||
param2.timeScale = this.readUnsignedInt();
|
||||
param2.currentMediaTime = this.readLongUIntToNumber();
|
||||
param2.smpteTimeCodeOffset = this.readLongUIntToNumber();
|
||||
param2.movieIdentifier = this.readString();
|
||||
var _loc4_:uint = this.readUnsignedByte();
|
||||
var _loc5_:Vector.<String> = new Vector.<String>();
|
||||
var _loc6_:int = 0;
|
||||
while(_loc6_ < _loc4_)
|
||||
{
|
||||
_loc5_.push(this.readString());
|
||||
_loc6_++;
|
||||
}
|
||||
param2.serverBaseURLs = _loc5_;
|
||||
var _loc7_:uint = this.readUnsignedByte();
|
||||
var _loc8_:Vector.<String> = new Vector.<String>();
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc7_)
|
||||
{
|
||||
_loc8_.push(this.readString());
|
||||
_loc6_++;
|
||||
}
|
||||
param2.qualitySegmentURLModifiers = _loc8_;
|
||||
param2.drmData = this.readString();
|
||||
param2.metadata = this.readString();
|
||||
var _loc9_:uint = this.readUnsignedByte();
|
||||
var _loc10_:Vector.<AdobeSegmentRunTable> = new Vector.<AdobeSegmentRunTable>();
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc9_)
|
||||
{
|
||||
param1 = this.getNextBoxInfo();
|
||||
if(param1.type != F4FConstants.BOX_TYPE_ASRT)
|
||||
{
|
||||
throw new IllegalOperationError("Unexpected data structure: " + param1.type);
|
||||
}
|
||||
_loc13_ = new AdobeSegmentRunTable();
|
||||
this.parseAdobeSegmentRunTable(param1,_loc13_);
|
||||
_loc10_.push(_loc13_);
|
||||
_loc6_++;
|
||||
}
|
||||
param2.segmentRunTables = _loc10_;
|
||||
var _loc11_:uint = this.readUnsignedByte();
|
||||
var _loc12_:Vector.<AdobeFragmentRunTable> = new Vector.<AdobeFragmentRunTable>();
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc11_)
|
||||
{
|
||||
param1 = this.getNextBoxInfo();
|
||||
if(param1.type != F4FConstants.BOX_TYPE_AFRT)
|
||||
{
|
||||
throw new IllegalOperationError("Unexpected data structure: " + param1.type);
|
||||
}
|
||||
_loc14_ = new AdobeFragmentRunTable();
|
||||
this.parseAdobeFragmentRunTable(param1,_loc14_);
|
||||
_loc12_.push(_loc14_);
|
||||
_loc6_++;
|
||||
}
|
||||
param2.fragmentRunTables = _loc12_;
|
||||
}
|
||||
|
||||
private function parseAdobeSegmentRunTable(param1:BoxInfo, param2:AdobeSegmentRunTable) : void
|
||||
{
|
||||
this.parseFullBox(param1,param2);
|
||||
var _loc3_:uint = this.readUnsignedByte();
|
||||
var _loc4_:Vector.<String> = new Vector.<String>();
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc4_.push(this.readString());
|
||||
_loc5_++;
|
||||
}
|
||||
param2.qualitySegmentURLModifiers = _loc4_;
|
||||
var _loc6_:uint = this.readUnsignedInt();
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc6_)
|
||||
{
|
||||
param2.addSegmentFragmentPair(new SegmentFragmentPair(this.readUnsignedInt(),this.readUnsignedInt()));
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function parseAdobeFragmentRunTable(param1:BoxInfo, param2:AdobeFragmentRunTable) : void
|
||||
{
|
||||
var _loc7_:FragmentDurationPair = null;
|
||||
this.parseFullBox(param1,param2);
|
||||
param2.timeScale = this.readUnsignedInt();
|
||||
var _loc3_:uint = this.readUnsignedByte();
|
||||
var _loc4_:Vector.<String> = new Vector.<String>();
|
||||
var _loc5_:uint = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc4_.push(this.readString());
|
||||
_loc5_++;
|
||||
}
|
||||
param2.qualitySegmentURLModifiers = _loc4_;
|
||||
var _loc6_:uint = this.readUnsignedInt();
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc6_)
|
||||
{
|
||||
_loc7_ = new FragmentDurationPair();
|
||||
this.parseFragmentDurationPair(_loc7_);
|
||||
param2.addFragmentDurationPair(_loc7_);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function parseFragmentDurationPair(param1:FragmentDurationPair) : void
|
||||
{
|
||||
param1.firstFragment = this.readUnsignedInt();
|
||||
param1.durationAccrued = this.readLongUIntToNumber();
|
||||
param1.duration = this.readUnsignedInt();
|
||||
if(param1.duration == 0)
|
||||
{
|
||||
param1.discontinuityIndicator = this.readUnsignedByte();
|
||||
}
|
||||
}
|
||||
|
||||
private function parseAdobeFragmentRandomAccessBox(param1:BoxInfo, param2:AdobeFragmentRandomAccessBox) : void
|
||||
{
|
||||
var _loc11_:LocalRandomAccessEntry = null;
|
||||
var _loc12_:GlobalRandomAccessEntry = null;
|
||||
this.parseFullBox(param1,param2);
|
||||
var _loc3_:uint = this.readBytesToUint(1);
|
||||
var _loc4_:Boolean = (_loc3_ & AFRA_MASK_LONG_ID) > 0;
|
||||
var _loc5_:Boolean = (_loc3_ & AFRA_MASK_LONG_OFFSET) > 0;
|
||||
var _loc6_:Boolean = (_loc3_ & AFRA_MASK_GLOBAL_ENTRIES) > 0;
|
||||
param2.timeScale = this.readUnsignedInt();
|
||||
var _loc7_:uint = this.readUnsignedInt();
|
||||
var _loc8_:Vector.<LocalRandomAccessEntry> = new Vector.<LocalRandomAccessEntry>();
|
||||
var _loc9_:uint = 0;
|
||||
while(_loc9_ < _loc7_)
|
||||
{
|
||||
_loc11_ = new LocalRandomAccessEntry();
|
||||
this.parseLocalRandomAccessEntry(_loc11_,_loc5_);
|
||||
_loc8_.push(_loc11_);
|
||||
_loc9_++;
|
||||
}
|
||||
param2.localRandomAccessEntries = _loc8_;
|
||||
var _loc10_:Vector.<GlobalRandomAccessEntry> = new Vector.<GlobalRandomAccessEntry>();
|
||||
if(_loc6_)
|
||||
{
|
||||
_loc7_ = this.readUnsignedInt();
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc7_)
|
||||
{
|
||||
_loc12_ = new GlobalRandomAccessEntry();
|
||||
this.parseGlobalRandomAccessEntry(_loc12_,_loc4_,_loc5_);
|
||||
_loc10_.push(_loc12_);
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
param2.globalRandomAccessEntries = _loc10_;
|
||||
}
|
||||
|
||||
private function parseLocalRandomAccessEntry(param1:LocalRandomAccessEntry, param2:Boolean) : void
|
||||
{
|
||||
param1.time = this.readLongUIntToNumber();
|
||||
if(param2)
|
||||
{
|
||||
param1.offset = this.readLongUIntToNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.offset = this.readUnsignedInt();
|
||||
}
|
||||
}
|
||||
|
||||
private function parseGlobalRandomAccessEntry(param1:GlobalRandomAccessEntry, param2:Boolean, param3:Boolean) : void
|
||||
{
|
||||
param1.time = this.readLongUIntToNumber();
|
||||
if(param2)
|
||||
{
|
||||
param1.segment = this.readUnsignedInt();
|
||||
param1.fragment = this.readUnsignedInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.segment = this.readBytesToUint(2);
|
||||
param1.fragment = this.readBytesToUint(2);
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
param1.afraOffset = this.readLongUIntToNumber();
|
||||
param1.offsetFromAfra = this.readLongUIntToNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.afraOffset = this.readUnsignedInt();
|
||||
param1.offsetFromAfra = this.readUnsignedInt();
|
||||
}
|
||||
}
|
||||
|
||||
private function parseMediaDataBox(param1:BoxInfo, param2:MediaDataBox) : void
|
||||
{
|
||||
this.parseBox(param1,param2);
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
this.readBytes(_loc3_,0,param2.size - param2.boxLength);
|
||||
param2.data = _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class F4FConstants
|
||||
{
|
||||
|
||||
internal static const BOX_TYPE_UUID:String = "uuid";
|
||||
|
||||
internal static const BOX_TYPE_ABST:String = "abst";
|
||||
|
||||
internal static const BOX_TYPE_ASRT:String = "asrt";
|
||||
|
||||
internal static const BOX_TYPE_AFRT:String = "afrt";
|
||||
|
||||
internal static const BOX_TYPE_AFRA:String = "afra";
|
||||
|
||||
internal static const BOX_TYPE_MDAT:String = "mdat";
|
||||
|
||||
internal static const BOX_TYPE_MOOF:String = "moof";
|
||||
|
||||
internal static const EXTENDED_TYPE:String = "uuid";
|
||||
|
||||
internal static const FIELD_SIZE_LENGTH:uint = 4;
|
||||
|
||||
internal static const FIELD_TYPE_LENGTH:uint = 4;
|
||||
|
||||
internal static const FIELD_LARGE_SIZE_LENGTH:uint = 8;
|
||||
|
||||
internal static const FIELD_EXTENDED_TYPE_LENGTH:uint = 16;
|
||||
|
||||
internal static const FLAG_USE_LARGE_SIZE:uint = 1;
|
||||
|
||||
public function F4FConstants()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class FragmentAccessInformation
|
||||
{
|
||||
|
||||
public var fragId:uint;
|
||||
|
||||
public var fragmentEndTime:Number;
|
||||
|
||||
public var fragDuration:uint;
|
||||
|
||||
public function FragmentAccessInformation()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class FragmentDurationPair
|
||||
{
|
||||
|
||||
private var _firstFragment:uint;
|
||||
|
||||
private var _duration:uint;
|
||||
|
||||
private var _durationAccrued:Number;
|
||||
|
||||
private var _discontinuityIndicator:uint = 0;
|
||||
|
||||
public function FragmentDurationPair()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get firstFragment() : uint
|
||||
{
|
||||
return this._firstFragment;
|
||||
}
|
||||
|
||||
public function set firstFragment(param1:uint) : void
|
||||
{
|
||||
this._firstFragment = param1;
|
||||
}
|
||||
|
||||
public function get duration() : uint
|
||||
{
|
||||
return this._duration;
|
||||
}
|
||||
|
||||
public function set duration(param1:uint) : void
|
||||
{
|
||||
this._duration = param1;
|
||||
}
|
||||
|
||||
public function get durationAccrued() : Number
|
||||
{
|
||||
return this._durationAccrued;
|
||||
}
|
||||
|
||||
public function set durationAccrued(param1:Number) : void
|
||||
{
|
||||
this._durationAccrued = param1;
|
||||
}
|
||||
|
||||
public function get discontinuityIndicator() : uint
|
||||
{
|
||||
return this._discontinuityIndicator;
|
||||
}
|
||||
|
||||
public function set discontinuityIndicator(param1:uint) : void
|
||||
{
|
||||
this._discontinuityIndicator = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class FullBox extends Box
|
||||
{
|
||||
|
||||
private var _version:uint;
|
||||
|
||||
private var _flags:uint;
|
||||
|
||||
public function FullBox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get version() : uint
|
||||
{
|
||||
return this._version;
|
||||
}
|
||||
|
||||
public function set version(param1:uint) : void
|
||||
{
|
||||
this._version = param1;
|
||||
}
|
||||
|
||||
public function get flags() : uint
|
||||
{
|
||||
return this._flags;
|
||||
}
|
||||
|
||||
public function set flags(param1:uint) : void
|
||||
{
|
||||
this._flags = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class GlobalRandomAccessEntry
|
||||
{
|
||||
|
||||
private var _time:Number;
|
||||
|
||||
private var _segment:uint;
|
||||
|
||||
private var _fragment:uint;
|
||||
|
||||
private var _afraOffset:Number;
|
||||
|
||||
private var _offsetFromAfra:Number;
|
||||
|
||||
public function GlobalRandomAccessEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get time() : Number
|
||||
{
|
||||
return this._time;
|
||||
}
|
||||
|
||||
public function set time(param1:Number) : void
|
||||
{
|
||||
this._time = param1;
|
||||
}
|
||||
|
||||
public function get segment() : uint
|
||||
{
|
||||
return this._segment;
|
||||
}
|
||||
|
||||
public function set segment(param1:uint) : void
|
||||
{
|
||||
this._segment = param1;
|
||||
}
|
||||
|
||||
public function get fragment() : uint
|
||||
{
|
||||
return this._fragment;
|
||||
}
|
||||
|
||||
public function set fragment(param1:uint) : void
|
||||
{
|
||||
this._fragment = param1;
|
||||
}
|
||||
|
||||
public function get afraOffset() : Number
|
||||
{
|
||||
return this._afraOffset;
|
||||
}
|
||||
|
||||
public function set afraOffset(param1:Number) : void
|
||||
{
|
||||
this._afraOffset = param1;
|
||||
}
|
||||
|
||||
public function get offsetFromAfra() : Number
|
||||
{
|
||||
return this._offsetFromAfra;
|
||||
}
|
||||
|
||||
public function set offsetFromAfra(param1:Number) : void
|
||||
{
|
||||
this._offsetFromAfra = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import org.osmf.events.HTTPStreamingFileHandlerEvent;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingFileHandlerBase;
|
||||
|
||||
public class HTTPStreamingF4FFileHandler extends HTTPStreamingFileHandlerBase
|
||||
{
|
||||
|
||||
private static const MAX_BYTES_PER_MDAT_READ:uint = 5 * 1024;
|
||||
|
||||
private var _afra:AdobeFragmentRandomAccessBox;
|
||||
|
||||
private var _ba:ByteArray;
|
||||
|
||||
private var _boxInfoPending:Boolean;
|
||||
|
||||
private var _bytesNeeded:uint;
|
||||
|
||||
private var _bytesReadSinceAfraStart:uint;
|
||||
|
||||
private var _countingReadBytes:Boolean;
|
||||
|
||||
private var _mdatBytesPending:uint;
|
||||
|
||||
private var _nextBox:BoxInfo;
|
||||
|
||||
private var _parser:BoxParser = new BoxParser();
|
||||
|
||||
private var _seekToTime:Number;
|
||||
|
||||
private var _mdatBytesOffset:Number;
|
||||
|
||||
private var _processRequestWasSeek:Boolean = false;
|
||||
|
||||
public function HTTPStreamingF4FFileHandler()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function beginProcessFile(param1:Boolean, param2:Number) : void
|
||||
{
|
||||
this._processRequestWasSeek = param1;
|
||||
this._seekToTime = param1 ? param2 : 0;
|
||||
this._bytesNeeded = F4FConstants.FIELD_SIZE_LENGTH + F4FConstants.FIELD_TYPE_LENGTH + F4FConstants.FIELD_LARGE_SIZE_LENGTH + F4FConstants.FIELD_EXTENDED_TYPE_LENGTH;
|
||||
this._bytesReadSinceAfraStart = 0;
|
||||
this._countingReadBytes = false;
|
||||
this._boxInfoPending = true;
|
||||
this._nextBox = null;
|
||||
}
|
||||
|
||||
override public function get inputBytesNeeded() : Number
|
||||
{
|
||||
return this._bytesNeeded;
|
||||
}
|
||||
|
||||
override public function processFileSegment(param1:IDataInput) : ByteArray
|
||||
{
|
||||
var _loc4_:uint = 0;
|
||||
var _loc5_:AdobeBootstrapBox = null;
|
||||
if(param1.bytesAvailable < this._bytesNeeded)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc2_:ByteArray = null;
|
||||
var _loc3_:Number = F4FConstants.FIELD_SIZE_LENGTH + F4FConstants.FIELD_TYPE_LENGTH;
|
||||
if(this._boxInfoPending)
|
||||
{
|
||||
this._ba = new ByteArray();
|
||||
param1.readBytes(this._ba,0,_loc3_);
|
||||
if(this._countingReadBytes)
|
||||
{
|
||||
this._bytesReadSinceAfraStart += _loc3_;
|
||||
}
|
||||
this._parser.init(this._ba);
|
||||
this._nextBox = this._parser.getNextBoxInfo();
|
||||
if(this._nextBox.size == F4FConstants.FLAG_USE_LARGE_SIZE)
|
||||
{
|
||||
_loc3_ += F4FConstants.FIELD_LARGE_SIZE_LENGTH;
|
||||
this._ba.position = 0;
|
||||
param1.readBytes(this._ba,0,F4FConstants.FIELD_LARGE_SIZE_LENGTH);
|
||||
if(this._countingReadBytes)
|
||||
{
|
||||
this._bytesReadSinceAfraStart += F4FConstants.FIELD_LARGE_SIZE_LENGTH;
|
||||
}
|
||||
this._nextBox.size = this._parser.readLongUIntToNumber();
|
||||
}
|
||||
this._boxInfoPending = false;
|
||||
if(this._nextBox.type == F4FConstants.BOX_TYPE_MDAT)
|
||||
{
|
||||
this._bytesNeeded = 0;
|
||||
this._mdatBytesPending = this._nextBox.size - _loc3_;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._bytesNeeded = this._nextBox.size - _loc3_;
|
||||
this._mdatBytesPending = 0;
|
||||
if(this._nextBox.type == F4FConstants.BOX_TYPE_AFRA)
|
||||
{
|
||||
this._bytesReadSinceAfraStart = _loc3_;
|
||||
this._countingReadBytes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this._bytesNeeded > 0)
|
||||
{
|
||||
_loc4_ = this._ba.position;
|
||||
param1.readBytes(this._ba,this._ba.length,this._nextBox.size - _loc3_);
|
||||
if(this._countingReadBytes)
|
||||
{
|
||||
this._bytesReadSinceAfraStart += this._nextBox.size - _loc3_;
|
||||
}
|
||||
this._ba.position = _loc4_;
|
||||
if(this._nextBox.type == F4FConstants.BOX_TYPE_ABST)
|
||||
{
|
||||
_loc5_ = this._parser.readAdobeBootstrapBox(this._nextBox);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingFileHandlerEvent(HTTPStreamingFileHandlerEvent.NOTIFY_BOOTSTRAP_BOX,false,false,0,null,false,false,_loc5_));
|
||||
}
|
||||
}
|
||||
else if(this._nextBox.type == F4FConstants.BOX_TYPE_AFRA)
|
||||
{
|
||||
this._afra = this._parser.readFragmentRandomAccessBox(this._nextBox);
|
||||
this.processSeekToTime();
|
||||
}
|
||||
else if(this._nextBox.type == F4FConstants.BOX_TYPE_MOOF)
|
||||
{
|
||||
}
|
||||
this._bytesNeeded = F4FConstants.FIELD_SIZE_LENGTH + F4FConstants.FIELD_TYPE_LENGTH + F4FConstants.FIELD_LARGE_SIZE_LENGTH + F4FConstants.FIELD_EXTENDED_TYPE_LENGTH;
|
||||
this._boxInfoPending = true;
|
||||
this._nextBox = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = this.getMDATBytes(param1,false);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override public function endProcessFile(param1:IDataInput) : ByteArray
|
||||
{
|
||||
if(this._bytesNeeded > 0)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingFileHandlerEvent(HTTPStreamingFileHandlerEvent.NOTIFY_ERROR,false,false,0,null,false,false,null,true));
|
||||
}
|
||||
return this.getMDATBytes(param1,true);
|
||||
}
|
||||
|
||||
override public function flushFileSegment(param1:IDataInput) : ByteArray
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getMDATBytes(param1:IDataInput, param2:Boolean) : ByteArray
|
||||
{
|
||||
var _loc3_:ByteArray = null;
|
||||
var _loc4_:uint = 0;
|
||||
if(param1 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
this.skipSeekBytes(param1);
|
||||
if(this._mdatBytesPending > 0)
|
||||
{
|
||||
_loc4_ = this._mdatBytesPending < param1.bytesAvailable ? this._mdatBytesPending : param1.bytesAvailable;
|
||||
if(!param2 && _loc4_ > MAX_BYTES_PER_MDAT_READ)
|
||||
{
|
||||
_loc4_ = MAX_BYTES_PER_MDAT_READ;
|
||||
}
|
||||
_loc3_ = new ByteArray();
|
||||
this._mdatBytesPending -= _loc4_;
|
||||
param1.readBytes(_loc3_,0,_loc4_);
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function skipSeekBytes(param1:IDataInput) : void
|
||||
{
|
||||
var _loc2_:uint = 0;
|
||||
var _loc3_:ByteArray = null;
|
||||
if(this._bytesReadSinceAfraStart < this._mdatBytesOffset)
|
||||
{
|
||||
_loc2_ = this._mdatBytesOffset - this._bytesReadSinceAfraStart;
|
||||
if(param1.bytesAvailable < _loc2_)
|
||||
{
|
||||
_loc2_ = param1.bytesAvailable;
|
||||
}
|
||||
_loc3_ = new ByteArray();
|
||||
param1.readBytes(_loc3_,0,_loc2_);
|
||||
this._bytesReadSinceAfraStart += _loc2_;
|
||||
this._mdatBytesPending -= _loc2_;
|
||||
}
|
||||
}
|
||||
|
||||
private function processSeekToTime() : void
|
||||
{
|
||||
var _loc1_:Number = 0;
|
||||
var _loc2_:LocalRandomAccessEntry = null;
|
||||
if(this._seekToTime <= 0)
|
||||
{
|
||||
this._mdatBytesOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = this.getMDATBytesOffset(this._seekToTime);
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
this._mdatBytesOffset = _loc2_.offset;
|
||||
_loc1_ = _loc2_.time;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._mdatBytesOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getMDATBytesOffset(param1:Number) : LocalRandomAccessEntry
|
||||
{
|
||||
return !isNaN(param1) ? this._afra.findNearestKeyFrameOffset(param1 * this._afra.timeScale) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+496
@@ -0,0 +1,496 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.net.URLRequest;
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.elements.f4mClasses.BootstrapInfo;
|
||||
import org.osmf.events.DVRStreamInfoEvent;
|
||||
import org.osmf.events.HTTPStreamingFileHandlerEvent;
|
||||
import org.osmf.events.HTTPStreamingIndexHandlerEvent;
|
||||
import org.osmf.net.dvr.DVRUtils;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamRequest;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingFileHandlerBase;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingIndexHandlerBase;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingUtils;
|
||||
import org.osmf.net.httpstreaming.flv.FLVTagScriptDataObject;
|
||||
|
||||
public class HTTPStreamingF4FIndexHandler extends HTTPStreamingIndexHandlerBase
|
||||
{
|
||||
|
||||
public static const DEFAULT_FRAGMENTS_THRESHOLD:uint = 5;
|
||||
|
||||
private var pendingIndexLoads:int;
|
||||
|
||||
private var pendingIndexUpdates:int;
|
||||
|
||||
private var bootstrapBoxes:Vector.<AdobeBootstrapBox>;
|
||||
|
||||
private var serverBaseURL:String;
|
||||
|
||||
private var streamInfos:Vector.<HTTPStreamingF4FStreamInfo>;
|
||||
|
||||
private var currentQuality:int;
|
||||
|
||||
private var currentFAI:FragmentAccessInformation;
|
||||
|
||||
private var fragmentsThreshold:uint;
|
||||
|
||||
private var fragmentRunTablesUpdating:Boolean;
|
||||
|
||||
private var f4fIndexInfo:HTTPStreamingF4FIndexInfo;
|
||||
|
||||
private var fileHandler:HTTPStreamingFileHandlerBase;
|
||||
|
||||
private var dvrGetStreamInfoCall:Boolean;
|
||||
|
||||
private var playInProgress:Boolean;
|
||||
|
||||
private var offsetFromCurrent:Number = 5;
|
||||
|
||||
private var delay:Number = 0.05;
|
||||
|
||||
private var pureLiveOffset:Number = NaN;
|
||||
|
||||
public function HTTPStreamingF4FIndexHandler(param1:HTTPStreamingFileHandlerBase, param2:uint = 5)
|
||||
{
|
||||
super();
|
||||
this.currentQuality = -1;
|
||||
this.currentFAI = null;
|
||||
this.fragmentRunTablesUpdating = false;
|
||||
this.fileHandler = param1;
|
||||
this.fragmentsThreshold = param2;
|
||||
this.dvrGetStreamInfoCall = false;
|
||||
param1.addEventListener(HTTPStreamingFileHandlerEvent.NOTIFY_BOOTSTRAP_BOX,this.onNewBootstrapBox);
|
||||
}
|
||||
|
||||
public function get bootstrapInfo() : AdobeBootstrapBox
|
||||
{
|
||||
return this.currentQuality < 0 ? null : this.bootstrapBoxes[this.currentQuality];
|
||||
}
|
||||
|
||||
override public function dvrGetStreamInfo(param1:Object) : void
|
||||
{
|
||||
this.dvrGetStreamInfoCall = true;
|
||||
this.playInProgress = false;
|
||||
this.initialize(param1);
|
||||
}
|
||||
|
||||
override public function initialize(param1:Object) : void
|
||||
{
|
||||
var _loc2_:AdobeBootstrapBox = null;
|
||||
var _loc4_:BootstrapInfo = null;
|
||||
this.f4fIndexInfo = param1 as HTTPStreamingF4FIndexInfo;
|
||||
if(this.f4fIndexInfo == null || this.f4fIndexInfo.streamInfos == null || this.f4fIndexInfo.streamInfos.length <= 0)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_ERROR));
|
||||
return;
|
||||
}
|
||||
this.bootstrapBoxes = new Vector.<AdobeBootstrapBox>(this.f4fIndexInfo.streamInfos.length);
|
||||
this.fragmentRunTablesUpdating = false;
|
||||
this.playInProgress = false;
|
||||
this.pendingIndexLoads = 0;
|
||||
this.pureLiveOffset = NaN;
|
||||
this.serverBaseURL = this.f4fIndexInfo.serverBaseURL;
|
||||
this.streamInfos = this.f4fIndexInfo.streamInfos;
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < this.streamInfos.length)
|
||||
{
|
||||
_loc4_ = this.streamInfos[_loc3_].bootstrapInfo;
|
||||
if(_loc4_ == null || _loc4_.url == null && _loc4_.data == null)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_ERROR));
|
||||
return;
|
||||
}
|
||||
if(_loc4_.data != null)
|
||||
{
|
||||
_loc2_ = this.processBootstrapData(_loc4_.data,null);
|
||||
if(_loc2_ == null)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_ERROR));
|
||||
return;
|
||||
}
|
||||
this.bootstrapBoxes[_loc3_] = _loc2_;
|
||||
}
|
||||
else
|
||||
{
|
||||
++this.pendingIndexLoads;
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.REQUEST_LOAD_INDEX,false,false,false,NaN,null,null,new URLRequest(HTTPStreamingUtils.normalizeURL(_loc4_.url)),_loc3_,true));
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(this.pendingIndexLoads == 0)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_RATES,false,false,false,NaN,this.getStreamNames(this.streamInfos),this.getQualityRates(this.streamInfos)));
|
||||
this.notifyIndexReady(0);
|
||||
}
|
||||
}
|
||||
|
||||
override public function processIndexData(param1:*, param2:Object) : void
|
||||
{
|
||||
var _loc3_:int = param2 as int;
|
||||
var _loc4_:AdobeBootstrapBox = this.processBootstrapData(param1,_loc3_);
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_ERROR));
|
||||
return;
|
||||
}
|
||||
if(!this.fragmentRunTablesUpdating)
|
||||
{
|
||||
--this.pendingIndexLoads;
|
||||
}
|
||||
else
|
||||
{
|
||||
--this.pendingIndexUpdates;
|
||||
if(this.pendingIndexUpdates == 0)
|
||||
{
|
||||
this.fragmentRunTablesUpdating = false;
|
||||
this.dispatchDVRStreamInfo(_loc4_);
|
||||
}
|
||||
}
|
||||
if(this.bootstrapBoxes[_loc3_] == null || this.bootstrapBoxes[_loc3_].bootstrapVersion < _loc4_.bootstrapVersion || this.bootstrapBoxes[_loc3_].currentMediaTime < _loc4_.currentMediaTime)
|
||||
{
|
||||
this.delay = 0.05;
|
||||
this.bootstrapBoxes[_loc3_] = _loc4_;
|
||||
}
|
||||
if(this.pendingIndexLoads == 0 && !this.fragmentRunTablesUpdating)
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_RATES,false,false,false,NaN,this.getStreamNames(this.streamInfos),this.getQualityRates(this.streamInfos)));
|
||||
this.notifyIndexReady(_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
override public function getFileForTime(param1:Number, param2:int) : HTTPStreamRequest
|
||||
{
|
||||
var _loc6_:FragmentDurationPair = null;
|
||||
var _loc7_:uint = 0;
|
||||
var _loc8_:String = null;
|
||||
var _loc3_:AdobeBootstrapBox = this.bootstrapBoxes[param2];
|
||||
var _loc4_:HTTPStreamRequest = null;
|
||||
if(!this.playInProgress && this.stopPlaying(_loc3_))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
this.checkMetadata(param2,_loc3_);
|
||||
var _loc5_:AdobeFragmentRunTable = this.getFragmentRunTable(_loc3_);
|
||||
if(param1 >= 0 && param1 * _loc3_.timeScale <= _loc3_.currentMediaTime && param2 >= 0 && param2 < this.streamInfos.length)
|
||||
{
|
||||
this.currentFAI = _loc5_.findFragmentIdByTime(param1 * _loc3_.timeScale,_loc3_.currentMediaTime,_loc3_.contentComplete() ? false : _loc3_.live);
|
||||
if(this.currentFAI == null || this.fragmentOverflow(_loc3_,this.currentFAI.fragId))
|
||||
{
|
||||
if(_loc3_.contentComplete())
|
||||
{
|
||||
if(_loc3_.live)
|
||||
{
|
||||
return new HTTPStreamRequest(null,param2,-1,-1,true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
this.adjustDelay();
|
||||
this.refreshBootstrapInfo(param2);
|
||||
return new HTTPStreamRequest(null,param2,0,this.delay);
|
||||
}
|
||||
this.playInProgress = true;
|
||||
_loc6_ = _loc5_.fragmentDurationPairs[0];
|
||||
_loc7_ = _loc3_.findSegmentId(this.currentFAI.fragId - _loc6_.firstFragment + 1);
|
||||
_loc8_ = "";
|
||||
if((this.streamInfos[param2].streamName as String).indexOf("http") != 0)
|
||||
{
|
||||
_loc8_ = this.serverBaseURL + "/" + this.streamInfos[param2].streamName + "Seg" + _loc7_ + "-Frag" + this.currentFAI.fragId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = this.streamInfos[param2].streamName + "Seg" + _loc7_ + "-Frag" + this.currentFAI.fragId;
|
||||
}
|
||||
_loc4_ = new HTTPStreamRequest(_loc8_);
|
||||
this.checkQuality(param2);
|
||||
this.notifyFragmentDuration(this.currentFAI.fragDuration / _loc3_.timeScale);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
override public function getNextFile(param1:int) : HTTPStreamRequest
|
||||
{
|
||||
var _loc4_:AdobeFragmentRunTable = null;
|
||||
var _loc5_:FragmentAccessInformation = null;
|
||||
var _loc6_:FragmentDurationPair = null;
|
||||
var _loc7_:uint = 0;
|
||||
var _loc8_:String = null;
|
||||
var _loc2_:AdobeBootstrapBox = this.bootstrapBoxes[param1];
|
||||
var _loc3_:HTTPStreamRequest = null;
|
||||
if(!this.playInProgress && this.stopPlaying(_loc2_))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
this.checkMetadata(param1,_loc2_);
|
||||
if(param1 >= 0 && param1 < this.streamInfos.length)
|
||||
{
|
||||
_loc4_ = this.getFragmentRunTable(_loc2_);
|
||||
_loc5_ = this.currentFAI;
|
||||
this.currentFAI = _loc4_.validateFragment(this.currentFAI.fragId + 1,_loc2_.currentMediaTime,_loc2_.contentComplete() ? false : _loc2_.live);
|
||||
if(this.currentFAI == null || this.fragmentOverflow(_loc2_,this.currentFAI.fragId))
|
||||
{
|
||||
if(!_loc2_.live || _loc2_.contentComplete())
|
||||
{
|
||||
if(_loc2_.live)
|
||||
{
|
||||
return new HTTPStreamRequest(null,param1,-1,-1,true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
this.adjustDelay();
|
||||
this.currentFAI = _loc5_;
|
||||
this.refreshBootstrapInfo(param1);
|
||||
return new HTTPStreamRequest(null,param1,0,this.delay);
|
||||
}
|
||||
this.playInProgress = true;
|
||||
_loc6_ = _loc4_.fragmentDurationPairs[0];
|
||||
_loc7_ = _loc2_.findSegmentId(this.currentFAI.fragId - _loc6_.firstFragment + 1);
|
||||
_loc8_ = "";
|
||||
if((this.streamInfos[param1].streamName as String).indexOf("http") != 0)
|
||||
{
|
||||
_loc8_ = this.serverBaseURL + "/" + this.streamInfos[param1].streamName + "Seg" + _loc7_ + "-Frag" + this.currentFAI.fragId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = this.streamInfos[param1].streamName + "Seg" + _loc7_ + "-Frag" + this.currentFAI.fragId;
|
||||
}
|
||||
_loc3_ = new HTTPStreamRequest(_loc8_);
|
||||
this.checkQuality(param1);
|
||||
this.notifyFragmentDuration(this.currentFAI.fragDuration / _loc2_.timeScale);
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
internal function calculateSegmentDuration(param1:AdobeBootstrapBox, param2:Number) : Number
|
||||
{
|
||||
var _loc6_:FragmentDurationPair = null;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc3_:Vector.<FragmentDurationPair> = param1.fragmentRunTables[0].fragmentDurationPairs;
|
||||
var _loc4_:uint = this.currentFAI.fragId;
|
||||
var _loc5_:* = int(_loc3_.length - 1);
|
||||
while(_loc5_ >= 0)
|
||||
{
|
||||
_loc6_ = _loc3_[_loc5_];
|
||||
if(_loc6_.firstFragment <= _loc4_)
|
||||
{
|
||||
_loc7_ = _loc6_.duration;
|
||||
_loc8_ = _loc6_.durationAccrued;
|
||||
_loc8_ = _loc8_ + (_loc4_ - _loc6_.firstFragment) * _loc6_.duration;
|
||||
if(param2 > 0)
|
||||
{
|
||||
_loc7_ -= param2 - _loc8_;
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
_loc5_--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function checkQuality(param1:int) : void
|
||||
{
|
||||
var _loc2_:ByteArray = null;
|
||||
var _loc3_:ByteArray = null;
|
||||
var _loc4_:FLVTagScriptDataObject = null;
|
||||
if(this.currentQuality != param1)
|
||||
{
|
||||
_loc2_ = this.currentQuality < 0 ? null : this.streamInfos[this.currentQuality].additionalHeader;
|
||||
this.currentQuality = param1;
|
||||
_loc3_ = this.streamInfos[this.currentQuality].additionalHeader;
|
||||
if(_loc3_ != _loc2_ && _loc3_ != null)
|
||||
{
|
||||
_loc4_ = new FLVTagScriptDataObject();
|
||||
_loc4_.data = _loc3_;
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_SCRIPT_DATA,false,false,false,NaN,null,null,null,null,true,0,_loc4_,true,false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function checkMetadata(param1:int, param2:AdobeBootstrapBox) : void
|
||||
{
|
||||
if(this.currentQuality != param1)
|
||||
{
|
||||
this.notifyTotalDuration(param2.totalDuration / param2.timeScale,param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function refreshBootstrapInfo(param1:uint) : void
|
||||
{
|
||||
++this.pendingIndexUpdates;
|
||||
this.fragmentRunTablesUpdating = true;
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.REQUEST_LOAD_INDEX,false,false,false,NaN,null,null,new URLRequest(HTTPStreamingUtils.normalizeURL((this.streamInfos[param1] as HTTPStreamingF4FStreamInfo).bootstrapInfo.url)),param1,true));
|
||||
}
|
||||
|
||||
private function processBootstrapData(param1:*, param2:Object) : AdobeBootstrapBox
|
||||
{
|
||||
var boxes:Vector.<Box> = null;
|
||||
var data:* = param1;
|
||||
var indexContext:Object = param2;
|
||||
var bootstrapBox:AdobeBootstrapBox = null;
|
||||
var parser:BoxParser = new BoxParser();
|
||||
data.position = 0;
|
||||
parser.init(data);
|
||||
try
|
||||
{
|
||||
boxes = parser.getBoxes();
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
boxes = null;
|
||||
}
|
||||
if(boxes == null || boxes.length < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
bootstrapBox = boxes[0] as AdobeBootstrapBox;
|
||||
if(bootstrapBox == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(this.serverBaseURL == null || this.serverBaseURL.length <= 0)
|
||||
{
|
||||
if(bootstrapBox.serverBaseURLs == null || bootstrapBox.serverBaseURLs.length <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return bootstrapBox;
|
||||
}
|
||||
|
||||
private function getQualityRates(param1:Vector.<HTTPStreamingF4FStreamInfo>) : Array
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:HTTPStreamingF4FStreamInfo = null;
|
||||
var _loc2_:Array = [];
|
||||
if(param1.length >= 1)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc4_ = param1[_loc3_] as HTTPStreamingF4FStreamInfo;
|
||||
_loc2_.push(_loc4_.bitrate);
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function getStreamNames(param1:Vector.<HTTPStreamingF4FStreamInfo>) : Array
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:HTTPStreamingF4FStreamInfo = null;
|
||||
var _loc2_:Array = [];
|
||||
if(param1.length >= 1)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc4_ = param1[_loc3_] as HTTPStreamingF4FStreamInfo;
|
||||
_loc2_.push(_loc4_.streamName);
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function getFragmentRunTable(param1:AdobeBootstrapBox) : AdobeFragmentRunTable
|
||||
{
|
||||
return param1.fragmentRunTables[0];
|
||||
}
|
||||
|
||||
private function notifyTotalDuration(param1:Number, param2:int) : void
|
||||
{
|
||||
var _loc3_:FLVTagScriptDataObject = new FLVTagScriptDataObject();
|
||||
var _loc4_:Object = this.f4fIndexInfo.streamInfos[param2].streamMetadata;
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
_loc4_ = new Object();
|
||||
}
|
||||
_loc4_.duration = param1;
|
||||
_loc3_.objects = ["onMetaData",_loc4_];
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_SCRIPT_DATA,false,false,false,NaN,null,null,null,null,false,0,_loc3_,false,true));
|
||||
}
|
||||
|
||||
private function notifyFragmentDuration(param1:Number) : void
|
||||
{
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_SEGMENT_DURATION,false,false,false,NaN,null,null,null,null,true,param1));
|
||||
}
|
||||
|
||||
private function notifyIndexReady(param1:int) : void
|
||||
{
|
||||
var _loc2_:AdobeBootstrapBox = this.bootstrapBoxes[param1];
|
||||
var _loc3_:AdobeFragmentRunTable = this.getFragmentRunTable(_loc2_);
|
||||
this.dispatchDVRStreamInfo(_loc2_);
|
||||
if(!this.dvrGetStreamInfoCall)
|
||||
{
|
||||
if(_loc2_.live && this.f4fIndexInfo.dvrInfo == null && isNaN(this.pureLiveOffset))
|
||||
{
|
||||
this.pureLiveOffset = _loc2_.currentMediaTime - this.offsetFromCurrent * _loc2_.timeScale > 0 ? _loc2_.currentMediaTime / _loc2_.timeScale - this.offsetFromCurrent : NaN;
|
||||
}
|
||||
dispatchEvent(new HTTPStreamingIndexHandlerEvent(HTTPStreamingIndexHandlerEvent.NOTIFY_INDEX_READY,false,false,_loc2_.live,this.pureLiveOffset));
|
||||
}
|
||||
this.dvrGetStreamInfoCall = false;
|
||||
}
|
||||
|
||||
private function stopPlaying(param1:AdobeBootstrapBox) : Boolean
|
||||
{
|
||||
var _loc2_:AdobeFragmentRunTable = this.getFragmentRunTable(param1);
|
||||
if(this.f4fIndexInfo.dvrInfo == null && param1.live && _loc2_.tableComplete() || this.f4fIndexInfo.dvrInfo != null && this.f4fIndexInfo.dvrInfo.offline)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function onNewBootstrapBox(param1:HTTPStreamingFileHandlerEvent) : void
|
||||
{
|
||||
var _loc2_:AdobeBootstrapBox = this.bootstrapBoxes[this.currentQuality];
|
||||
if(_loc2_.bootstrapVersion < param1.bootstrapBox.bootstrapVersion || _loc2_.currentMediaTime < param1.bootstrapBox.currentMediaTime)
|
||||
{
|
||||
this.bootstrapBoxes[this.currentQuality] = param1.bootstrapBox;
|
||||
this.dispatchDVRStreamInfo(param1.bootstrapBox);
|
||||
}
|
||||
}
|
||||
|
||||
private function dispatchDVRStreamInfo(param1:AdobeBootstrapBox) : void
|
||||
{
|
||||
var _loc2_:AdobeFragmentRunTable = this.getFragmentRunTable(param1);
|
||||
if(this.f4fIndexInfo.dvrInfo != null)
|
||||
{
|
||||
this.f4fIndexInfo.dvrInfo.isRecording = !_loc2_.tableComplete();
|
||||
if(isNaN(this.f4fIndexInfo.dvrInfo.startTime))
|
||||
{
|
||||
this.f4fIndexInfo.dvrInfo.startTime = _loc2_.tableComplete() ? 0 : DVRUtils.calculateOffset(this.f4fIndexInfo.dvrInfo.beginOffset < 0 || isNaN(this.f4fIndexInfo.dvrInfo.beginOffset) ? 0 : this.f4fIndexInfo.dvrInfo.beginOffset,this.f4fIndexInfo.dvrInfo.endOffset < 0 || isNaN(this.f4fIndexInfo.dvrInfo.endOffset) ? 0 : this.f4fIndexInfo.dvrInfo.endOffset,param1.totalDuration / param1.timeScale);
|
||||
this.f4fIndexInfo.dvrInfo.startTime += _loc2_.fragmentDurationPairs[0].durationAccrued / param1.timeScale;
|
||||
if(this.f4fIndexInfo.dvrInfo.startTime > param1.currentMediaTime)
|
||||
{
|
||||
this.f4fIndexInfo.dvrInfo.startTime = param1.currentMediaTime;
|
||||
}
|
||||
}
|
||||
this.f4fIndexInfo.dvrInfo.curLength = param1.currentMediaTime / param1.timeScale - this.f4fIndexInfo.dvrInfo.startTime;
|
||||
dispatchEvent(new DVRStreamInfoEvent(DVRStreamInfoEvent.DVRSTREAMINFO,false,false,this.f4fIndexInfo.dvrInfo));
|
||||
}
|
||||
}
|
||||
|
||||
private function fragmentOverflow(param1:AdobeBootstrapBox, param2:uint) : Boolean
|
||||
{
|
||||
var _loc3_:AdobeFragmentRunTable = param1.fragmentRunTables[0];
|
||||
var _loc4_:FragmentDurationPair = _loc3_.fragmentDurationPairs[0];
|
||||
var _loc5_:AdobeSegmentRunTable = param1.segmentRunTables[0];
|
||||
return _loc5_ == null || _loc5_.totalFragments + _loc4_.firstFragment - 1 < param2;
|
||||
}
|
||||
|
||||
private function adjustDelay() : void
|
||||
{
|
||||
if(this.delay < 1)
|
||||
{
|
||||
this.delay *= 2;
|
||||
if(this.delay > 1)
|
||||
{
|
||||
this.delay = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingIndexInfoBase;
|
||||
import org.osmf.net.httpstreaming.dvr.DVRInfo;
|
||||
|
||||
public class HTTPStreamingF4FIndexInfo extends HTTPStreamingIndexInfoBase
|
||||
{
|
||||
|
||||
private var _serverBaseURL:String;
|
||||
|
||||
private var _dvrInfo:DVRInfo;
|
||||
|
||||
private var _streamInfos:Vector.<HTTPStreamingF4FStreamInfo>;
|
||||
|
||||
public function HTTPStreamingF4FIndexInfo(param1:String = null, param2:Vector.<HTTPStreamingF4FStreamInfo> = null, param3:DVRInfo = null)
|
||||
{
|
||||
super();
|
||||
this._serverBaseURL = param1;
|
||||
this._streamInfos = param2;
|
||||
this._dvrInfo = param3;
|
||||
}
|
||||
|
||||
public function get serverBaseURL() : String
|
||||
{
|
||||
return this._serverBaseURL;
|
||||
}
|
||||
|
||||
public function get streamInfos() : Vector.<HTTPStreamingF4FStreamInfo>
|
||||
{
|
||||
return this._streamInfos;
|
||||
}
|
||||
|
||||
public function get dvrInfo() : DVRInfo
|
||||
{
|
||||
return this._dvrInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.elements.f4mClasses.BootstrapInfo;
|
||||
|
||||
public class HTTPStreamingF4FStreamInfo
|
||||
{
|
||||
|
||||
private var _streamName:String;
|
||||
|
||||
private var _bitrate:Number;
|
||||
|
||||
private var _bootstrap:BootstrapInfo;
|
||||
|
||||
private var _additionalHeader:ByteArray;
|
||||
|
||||
private var _streamMetadata:Object;
|
||||
|
||||
private var _xmpMetadata:ByteArray;
|
||||
|
||||
public function HTTPStreamingF4FStreamInfo(param1:BootstrapInfo, param2:String, param3:Number, param4:ByteArray, param5:Object, param6:ByteArray)
|
||||
{
|
||||
super();
|
||||
this._streamName = param2;
|
||||
this._bitrate = param3;
|
||||
this._additionalHeader = param4;
|
||||
this._bootstrap = param1;
|
||||
this._streamMetadata = param5;
|
||||
this._xmpMetadata = param6;
|
||||
}
|
||||
|
||||
public function get streamName() : String
|
||||
{
|
||||
return this._streamName;
|
||||
}
|
||||
|
||||
public function get bitrate() : Number
|
||||
{
|
||||
return this._bitrate;
|
||||
}
|
||||
|
||||
public function get additionalHeader() : ByteArray
|
||||
{
|
||||
return this._additionalHeader;
|
||||
}
|
||||
|
||||
public function get bootstrapInfo() : BootstrapInfo
|
||||
{
|
||||
return this._bootstrap;
|
||||
}
|
||||
|
||||
public function get streamMetadata() : Object
|
||||
{
|
||||
return this._streamMetadata;
|
||||
}
|
||||
|
||||
public function get xmpMetadata() : ByteArray
|
||||
{
|
||||
return this._xmpMetadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class LocalRandomAccessEntry
|
||||
{
|
||||
|
||||
private var _time:Number;
|
||||
|
||||
private var _offset:Number;
|
||||
|
||||
public function LocalRandomAccessEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get time() : Number
|
||||
{
|
||||
return this._time;
|
||||
}
|
||||
|
||||
public function set time(param1:Number) : void
|
||||
{
|
||||
this._time = param1;
|
||||
}
|
||||
|
||||
public function get offset() : Number
|
||||
{
|
||||
return this._offset;
|
||||
}
|
||||
|
||||
public function set offset(param1:Number) : void
|
||||
{
|
||||
this._offset = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
internal class MediaDataBox extends Box
|
||||
{
|
||||
|
||||
private var _data:ByteArray;
|
||||
|
||||
public function MediaDataBox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get data() : ByteArray
|
||||
{
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public function set data(param1:ByteArray) : void
|
||||
{
|
||||
this._data = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package org.osmf.net.httpstreaming.f4f
|
||||
{
|
||||
internal class SegmentFragmentPair
|
||||
{
|
||||
|
||||
private var _firstSegment:uint;
|
||||
|
||||
private var _fragmentsPerSegment:uint;
|
||||
|
||||
private var _fragmentsAccrued:uint;
|
||||
|
||||
public function SegmentFragmentPair(param1:uint, param2:uint)
|
||||
{
|
||||
super();
|
||||
this._firstSegment = param1;
|
||||
this._fragmentsPerSegment = param2;
|
||||
}
|
||||
|
||||
public function get firstSegment() : uint
|
||||
{
|
||||
return this._firstSegment;
|
||||
}
|
||||
|
||||
public function get fragmentsPerSegment() : uint
|
||||
{
|
||||
return this._fragmentsPerSegment;
|
||||
}
|
||||
|
||||
public function set fragmentsAccrued(param1:uint) : void
|
||||
{
|
||||
this._fragmentsAccrued = param1;
|
||||
}
|
||||
|
||||
public function get fragmentsAccrued() : uint
|
||||
{
|
||||
return this._fragmentsAccrued;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVHeader
|
||||
{
|
||||
|
||||
public static const MIN_FILE_HEADER_BYTE_COUNT:int = 9;
|
||||
|
||||
private var _hasVideoTags:Boolean = true;
|
||||
|
||||
private var _hasAudioTags:Boolean = true;
|
||||
|
||||
private var offset:uint;
|
||||
|
||||
public function FLVHeader(param1:IDataInput = null)
|
||||
{
|
||||
super();
|
||||
if(param1 != null)
|
||||
{
|
||||
this.readHeader(param1);
|
||||
this.readRest(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function get hasAudioTags() : Boolean
|
||||
{
|
||||
return this._hasAudioTags;
|
||||
}
|
||||
|
||||
public function set hasAudioTags(param1:Boolean) : void
|
||||
{
|
||||
this._hasAudioTags = param1;
|
||||
}
|
||||
|
||||
public function get hasVideoTags() : Boolean
|
||||
{
|
||||
return this._hasVideoTags;
|
||||
}
|
||||
|
||||
public function set hasVideoTags(param1:Boolean) : void
|
||||
{
|
||||
this._hasVideoTags = param1;
|
||||
}
|
||||
|
||||
public function write(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeByte(70);
|
||||
param1.writeByte(76);
|
||||
param1.writeByte(86);
|
||||
param1.writeByte(1);
|
||||
var _loc2_:uint = 0;
|
||||
if(this._hasAudioTags)
|
||||
{
|
||||
_loc2_ |= 4;
|
||||
}
|
||||
if(this._hasVideoTags)
|
||||
{
|
||||
_loc2_ |= 1;
|
||||
}
|
||||
param1.writeByte(_loc2_);
|
||||
var _loc3_:uint = uint(MIN_FILE_HEADER_BYTE_COUNT);
|
||||
param1.writeUnsignedInt(_loc3_);
|
||||
var _loc4_:uint = 0;
|
||||
param1.writeUnsignedInt(_loc4_);
|
||||
}
|
||||
|
||||
internal function readHeader(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < MIN_FILE_HEADER_BYTE_COUNT)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short");
|
||||
}
|
||||
if(param1.readByte() != 70)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[0] not \'F\'");
|
||||
}
|
||||
if(param1.readByte() != 76)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[1] not \'L\'");
|
||||
}
|
||||
if(param1.readByte() != 86)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[2] not \'V\'");
|
||||
}
|
||||
if(param1.readByte() != 1)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Version not 0x01");
|
||||
}
|
||||
var _loc2_:int = param1.readByte();
|
||||
this._hasAudioTags = _loc2_ & 4 ? true : false;
|
||||
this._hasVideoTags = _loc2_ & 1 ? true : false;
|
||||
this.offset = param1.readUnsignedInt();
|
||||
if(this.offset < MIN_FILE_HEADER_BYTE_COUNT)
|
||||
{
|
||||
throw new Error("FLVHeader() offset smaller than minimum");
|
||||
}
|
||||
}
|
||||
|
||||
internal function readRest(param1:IDataInput) : void
|
||||
{
|
||||
var _loc2_:ByteArray = null;
|
||||
if(this.offset > MIN_FILE_HEADER_BYTE_COUNT)
|
||||
{
|
||||
if(this.offset - MIN_FILE_HEADER_BYTE_COUNT < param1.bytesAvailable - FLVTag.PREV_TAG_BYTE_COUNT)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short for nonstandard offset");
|
||||
}
|
||||
_loc2_ = new ByteArray();
|
||||
param1.readBytes(_loc2_,0,this.offset - MIN_FILE_HEADER_BYTE_COUNT);
|
||||
}
|
||||
if(param1.bytesAvailable < FLVTag.PREV_TAG_BYTE_COUNT)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short for previousTagSize0");
|
||||
}
|
||||
param1.readUnsignedInt();
|
||||
}
|
||||
|
||||
internal function get restBytesNeeded() : int
|
||||
{
|
||||
return FLVTag.PREV_TAG_BYTE_COUNT + (this.offset - MIN_FILE_HEADER_BYTE_COUNT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVParser
|
||||
{
|
||||
|
||||
private var state:String;
|
||||
|
||||
private var savedBytes:ByteArray;
|
||||
|
||||
private var currentTag:FLVTag = null;
|
||||
|
||||
private var flvHeader:FLVHeader;
|
||||
|
||||
public function FLVParser(param1:Boolean)
|
||||
{
|
||||
super();
|
||||
this.savedBytes = new ByteArray();
|
||||
if(param1)
|
||||
{
|
||||
this.state = FLVParserState.FILE_HEADER;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.state = FLVParserState.TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
public function flush(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeBytes(this.savedBytes);
|
||||
}
|
||||
|
||||
public function parse(param1:IDataInput, param2:Boolean, param3:Function) : void
|
||||
{
|
||||
var _loc5_:IDataInput = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Boolean = true;
|
||||
while(_loc4_)
|
||||
{
|
||||
switch(this.state)
|
||||
{
|
||||
case FLVParserState.FILE_HEADER:
|
||||
_loc5_ = this.byteSource(param1,FLVHeader.MIN_FILE_HEADER_BYTE_COUNT);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
this.flvHeader = new FLVHeader();
|
||||
this.flvHeader.readHeader(_loc5_);
|
||||
this.state = FLVParserState.FILE_HEADER_REST;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case FLVParserState.FILE_HEADER_REST:
|
||||
_loc5_ = this.byteSource(param1,this.flvHeader.restBytesNeeded);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
this.flvHeader.readRest(_loc5_);
|
||||
this.state = FLVParserState.TYPE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case FLVParserState.TYPE:
|
||||
_loc5_ = this.byteSource(param1,1);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
_loc6_ = _loc5_.readByte();
|
||||
switch(_loc6_)
|
||||
{
|
||||
case FLVTag.TAG_TYPE_AUDIO:
|
||||
case FLVTag.TAG_TYPE_ENCRYPTED_AUDIO:
|
||||
this.currentTag = new FLVTagAudio(_loc6_);
|
||||
break;
|
||||
case FLVTag.TAG_TYPE_VIDEO:
|
||||
case FLVTag.TAG_TYPE_ENCRYPTED_VIDEO:
|
||||
this.currentTag = new FLVTagVideo(_loc6_);
|
||||
break;
|
||||
case FLVTag.TAG_TYPE_SCRIPTDATAOBJECT:
|
||||
case FLVTag.TAG_TYPE_ENCRYPTED_SCRIPTDATAOBJECT:
|
||||
this.currentTag = new FLVTagScriptDataObject(_loc6_);
|
||||
break;
|
||||
default:
|
||||
this.currentTag = new FLVTag(_loc6_);
|
||||
}
|
||||
this.state = FLVParserState.HEADER;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case FLVParserState.HEADER:
|
||||
_loc5_ = this.byteSource(param1,FLVTag.TAG_HEADER_BYTE_COUNT - 1);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
this.currentTag.readRemainingHeader(_loc5_);
|
||||
if(this.currentTag.dataSize)
|
||||
{
|
||||
this.state = FLVParserState.DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.state = FLVParserState.PREV_TAG;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case FLVParserState.DATA:
|
||||
_loc5_ = this.byteSource(param1,this.currentTag.dataSize);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
this.currentTag.readData(_loc5_);
|
||||
this.state = FLVParserState.PREV_TAG;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case FLVParserState.PREV_TAG:
|
||||
_loc5_ = this.byteSource(param1,FLVTag.PREV_TAG_BYTE_COUNT);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
this.currentTag.readPrevTag(_loc5_);
|
||||
this.state = FLVParserState.TYPE;
|
||||
_loc4_ = param3(this.currentTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("FLVParser state machine in unknown state");
|
||||
}
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
param1.readBytes(this.savedBytes,this.savedBytes.length);
|
||||
}
|
||||
}
|
||||
|
||||
private function byteSource(param1:IDataInput, param2:int) : IDataInput
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(this.savedBytes.bytesAvailable + param1.bytesAvailable < param2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(this.savedBytes.bytesAvailable)
|
||||
{
|
||||
_loc3_ = param2 - this.savedBytes.bytesAvailable;
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
param1.readBytes(this.savedBytes,this.savedBytes.length,_loc3_);
|
||||
}
|
||||
return this.savedBytes;
|
||||
}
|
||||
this.savedBytes.length = 0;
|
||||
return param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
internal class FLVParserState
|
||||
{
|
||||
|
||||
internal static const FILE_HEADER:String = "fileHeader";
|
||||
|
||||
internal static const FILE_HEADER_REST:String = "fileHeaderRest";
|
||||
|
||||
internal static const TYPE:String = "type";
|
||||
|
||||
internal static const HEADER:String = "header";
|
||||
|
||||
internal static const DATA:String = "data";
|
||||
|
||||
internal static const PREV_TAG:String = "prevTag";
|
||||
|
||||
public function FLVParserState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVTag
|
||||
{
|
||||
|
||||
public static const TAG_TYPE_AUDIO:int = 8;
|
||||
|
||||
public static const TAG_TYPE_VIDEO:int = 9;
|
||||
|
||||
public static const TAG_TYPE_SCRIPTDATAOBJECT:int = 18;
|
||||
|
||||
public static const TAG_FLAG_ENCRYPTED:int = 32;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_AUDIO:int = TAG_TYPE_AUDIO + TAG_FLAG_ENCRYPTED;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_VIDEO:int = TAG_TYPE_VIDEO + TAG_FLAG_ENCRYPTED;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_SCRIPTDATAOBJECT:int = TAG_TYPE_SCRIPTDATAOBJECT + TAG_FLAG_ENCRYPTED;
|
||||
|
||||
internal static const TAG_HEADER_BYTE_COUNT:int = 11;
|
||||
|
||||
internal static const PREV_TAG_BYTE_COUNT:int = 4;
|
||||
|
||||
protected var bytes:ByteArray = null;
|
||||
|
||||
public function FLVTag(param1:int)
|
||||
{
|
||||
super();
|
||||
this.bytes = new ByteArray();
|
||||
this.bytes.length = TAG_HEADER_BYTE_COUNT;
|
||||
this.bytes[0] = param1;
|
||||
}
|
||||
|
||||
public function read(param1:IDataInput) : void
|
||||
{
|
||||
this.readType(param1);
|
||||
this.readRemainingHeader(param1);
|
||||
this.readData(param1);
|
||||
this.readPrevTag(param1);
|
||||
}
|
||||
|
||||
public function readType(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 1)
|
||||
{
|
||||
throw new Error("FLVTag.readType() input too short");
|
||||
}
|
||||
param1.readBytes(this.bytes,0,1);
|
||||
}
|
||||
|
||||
public function readRemaining(param1:IDataInput) : void
|
||||
{
|
||||
this.readRemainingHeader(param1);
|
||||
this.readData(param1);
|
||||
this.readPrevTag(param1);
|
||||
}
|
||||
|
||||
public function readRemainingHeader(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 10)
|
||||
{
|
||||
throw new Error("FLVTag.readHeader() input too short");
|
||||
}
|
||||
param1.readBytes(this.bytes,1,TAG_HEADER_BYTE_COUNT - 1);
|
||||
}
|
||||
|
||||
public function readData(param1:IDataInput) : void
|
||||
{
|
||||
if(this.dataSize > 0)
|
||||
{
|
||||
if(param1.bytesAvailable < this.dataSize)
|
||||
{
|
||||
throw new Error("FLVTag().readData input shorter than dataSize");
|
||||
}
|
||||
param1.readBytes(this.bytes,TAG_HEADER_BYTE_COUNT,this.dataSize);
|
||||
}
|
||||
}
|
||||
|
||||
public function readPrevTag(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 4)
|
||||
{
|
||||
throw new Error("FLVTag.readPrevTag() input too short");
|
||||
}
|
||||
param1.readUnsignedInt();
|
||||
}
|
||||
|
||||
public function write(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeBytes(this.bytes,0,TAG_HEADER_BYTE_COUNT + this.dataSize);
|
||||
param1.writeUnsignedInt(TAG_HEADER_BYTE_COUNT + this.dataSize);
|
||||
}
|
||||
|
||||
public function get tagType() : uint
|
||||
{
|
||||
return this.bytes[0];
|
||||
}
|
||||
|
||||
public function set tagType(param1:uint) : void
|
||||
{
|
||||
this.bytes[0] = param1;
|
||||
}
|
||||
|
||||
public function get isEncrpted() : Boolean
|
||||
{
|
||||
return this.bytes[0] & TAG_FLAG_ENCRYPTED ? true : false;
|
||||
}
|
||||
|
||||
public function get dataSize() : uint
|
||||
{
|
||||
return this.bytes[1] << 16 | this.bytes[2] << 8 | this.bytes[3];
|
||||
}
|
||||
|
||||
public function set dataSize(param1:uint) : void
|
||||
{
|
||||
this.bytes[1] = param1 >> 16 & 0xFF;
|
||||
this.bytes[2] = param1 >> 8 & 0xFF;
|
||||
this.bytes[3] = param1 & 0xFF;
|
||||
this.bytes.length = TAG_HEADER_BYTE_COUNT + param1;
|
||||
}
|
||||
|
||||
public function get timestamp() : uint
|
||||
{
|
||||
return this.bytes[7] << 24 | this.bytes[4] << 16 | this.bytes[5] << 8 | this.bytes[6];
|
||||
}
|
||||
|
||||
public function set timestamp(param1:uint) : void
|
||||
{
|
||||
this.bytes[7] = param1 >> 24 & 0xFF;
|
||||
this.bytes[4] = param1 >> 16 & 0xFF;
|
||||
this.bytes[5] = param1 >> 8 & 0xFF;
|
||||
this.bytes[6] = param1 & 0xFF;
|
||||
}
|
||||
|
||||
public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
_loc1_.writeBytes(this.bytes,TAG_HEADER_BYTE_COUNT,this.dataSize);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set data(param1:ByteArray) : void
|
||||
{
|
||||
this.bytes.length = TAG_HEADER_BYTE_COUNT + param1.length;
|
||||
this.bytes.position = TAG_HEADER_BYTE_COUNT;
|
||||
this.bytes.writeBytes(param1,0,param1.length);
|
||||
this.dataSize = param1.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class FLVTagAudio extends FLVTag
|
||||
{
|
||||
|
||||
public static const SOUND_FORMAT_LINEAR:int = 0;
|
||||
|
||||
public static const SOUND_FORMAT_ADPCM:int = 1;
|
||||
|
||||
public static const SOUND_FORMAT_MP3:int = 2;
|
||||
|
||||
public static const SOUND_FORMAT_LINEAR_LE:int = 3;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER_16K:int = 4;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER_8K:int = 5;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER:int = 6;
|
||||
|
||||
public static const SOUND_FORMAT_G711A:int = 7;
|
||||
|
||||
public static const SOUND_FORMAT_G711U:int = 8;
|
||||
|
||||
public static const SOUND_FORMAT_AAC:int = 10;
|
||||
|
||||
public static const SOUND_FORMAT_SPEEX:int = 11;
|
||||
|
||||
public static const SOUND_FORMAT_MP3_8K:int = 14;
|
||||
|
||||
public static const SOUND_FORMAT_DEVICE_SPECIFIC:int = 15;
|
||||
|
||||
public static const SOUND_RATE_5K:Number = 5512.5;
|
||||
|
||||
public static const SOUND_RATE_11K:Number = 11025;
|
||||
|
||||
public static const SOUND_RATE_22K:Number = 22050;
|
||||
|
||||
public static const SOUND_RATE_44K:Number = 44100;
|
||||
|
||||
public static const SOUND_SIZE_8BITS:int = 8;
|
||||
|
||||
public static const SOUND_SIZE_16BITS:int = 16;
|
||||
|
||||
public static const SOUND_CHANNELS_MONO:int = 1;
|
||||
|
||||
public static const SOUND_CHANNELS_STEREO:int = 2;
|
||||
|
||||
public function FLVTagAudio(param1:int = 8)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get soundFormatByte() : int
|
||||
{
|
||||
return bytes[TAG_HEADER_BYTE_COUNT + 0];
|
||||
}
|
||||
|
||||
public function set soundFormatByte(param1:int) : void
|
||||
{
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] = param1;
|
||||
}
|
||||
|
||||
public function get soundFormat() : int
|
||||
{
|
||||
return bytes[TAG_HEADER_BYTE_COUNT + 0] >> 4 & 0x0F;
|
||||
}
|
||||
|
||||
public function set soundFormat(param1:int) : void
|
||||
{
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] &= 15;
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] |= param1 << 4 & 0xF0;
|
||||
if(param1 == SOUND_FORMAT_AAC)
|
||||
{
|
||||
this.soundRate = SOUND_RATE_44K;
|
||||
this.soundChannels = SOUND_CHANNELS_STEREO;
|
||||
this.isAACSequenceHeader = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function get soundRate() : Number
|
||||
{
|
||||
switch(bytes[TAG_HEADER_BYTE_COUNT + 0] >> 2 & 3)
|
||||
{
|
||||
case 0:
|
||||
return SOUND_RATE_5K;
|
||||
case 1:
|
||||
return SOUND_RATE_11K;
|
||||
case 2:
|
||||
return SOUND_RATE_22K;
|
||||
case 3:
|
||||
return SOUND_RATE_44K;
|
||||
default:
|
||||
throw new Error("get soundRate() a two-bit number wasn\'t 0, 1, 2, or 3. impossible.");
|
||||
}
|
||||
}
|
||||
|
||||
public function set soundRate(param1:Number) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
switch(param1)
|
||||
{
|
||||
case SOUND_RATE_5K:
|
||||
_loc2_ = 0;
|
||||
break;
|
||||
case SOUND_RATE_11K:
|
||||
_loc2_ = 1;
|
||||
break;
|
||||
case SOUND_RATE_22K:
|
||||
_loc2_ = 2;
|
||||
break;
|
||||
case SOUND_RATE_44K:
|
||||
_loc2_ = 3;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundRate valid values 5512.5, 11025, 22050, 44100");
|
||||
}
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] &= 243;
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] |= _loc2_ << 2;
|
||||
}
|
||||
|
||||
public function get soundSize() : int
|
||||
{
|
||||
if(bytes[TAG_HEADER_BYTE_COUNT + 0] >> 1 & 1)
|
||||
{
|
||||
return SOUND_SIZE_16BITS;
|
||||
}
|
||||
return SOUND_SIZE_8BITS;
|
||||
}
|
||||
|
||||
public function set soundSize(param1:int) : void
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case SOUND_SIZE_8BITS:
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] &= 253;
|
||||
break;
|
||||
case SOUND_SIZE_16BITS:
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] |= 2;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundSize valid values 8, 16");
|
||||
}
|
||||
}
|
||||
|
||||
public function get soundChannels() : int
|
||||
{
|
||||
if(bytes[TAG_HEADER_BYTE_COUNT + 0] & 1)
|
||||
{
|
||||
return SOUND_CHANNELS_STEREO;
|
||||
}
|
||||
return SOUND_CHANNELS_MONO;
|
||||
}
|
||||
|
||||
public function set soundChannels(param1:int) : void
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case SOUND_CHANNELS_MONO:
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] &= 254;
|
||||
break;
|
||||
case SOUND_CHANNELS_STEREO:
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] |= 1;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundChannels valid values 1, 2");
|
||||
}
|
||||
}
|
||||
|
||||
public function get isAACSequenceHeader() : Boolean
|
||||
{
|
||||
if(this.soundFormat != SOUND_FORMAT_AAC)
|
||||
{
|
||||
throw new Error("get isAACSequenceHeader not valid if soundFormat != SOUND_FORMAT_AAC");
|
||||
}
|
||||
if(bytes[TAG_HEADER_BYTE_COUNT + 1] == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function set isAACSequenceHeader(param1:Boolean) : void
|
||||
{
|
||||
if(this.soundFormat != SOUND_FORMAT_AAC)
|
||||
{
|
||||
throw new Error("set isAACSequenceHeader not valid if soundFormat != SOUND_FORMAT_AAC");
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 1] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get isCodecConfiguration() : Boolean
|
||||
{
|
||||
switch(this.soundFormat)
|
||||
{
|
||||
case FLVTagAudio.SOUND_FORMAT_AAC:
|
||||
if(this.isAACSequenceHeader)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(this.soundFormat == SOUND_FORMAT_AAC)
|
||||
{
|
||||
_loc1_.writeBytes(bytes,TAG_HEADER_BYTE_COUNT + 2,dataSize - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.writeBytes(bytes,TAG_HEADER_BYTE_COUNT + 1,dataSize - 1);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function set data(param1:ByteArray) : void
|
||||
{
|
||||
if(this.soundFormat == SOUND_FORMAT_AAC)
|
||||
{
|
||||
bytes.length = TAG_HEADER_BYTE_COUNT + param1.length + 2;
|
||||
bytes.position = TAG_HEADER_BYTE_COUNT + 2;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes.length = TAG_HEADER_BYTE_COUNT + param1.length + 1;
|
||||
bytes.position = TAG_HEADER_BYTE_COUNT + 1;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.net.ObjectEncoding;
|
||||
|
||||
public class FLVTagScriptDataObject extends FLVTag
|
||||
{
|
||||
|
||||
public function FLVTagScriptDataObject(param1:int = 18)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get objects() : Array
|
||||
{
|
||||
var _loc1_:Array = new Array();
|
||||
bytes.position = TAG_HEADER_BYTE_COUNT;
|
||||
while(bytes.bytesAvailable)
|
||||
{
|
||||
_loc1_.push(bytes.readObject());
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set objects(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
bytes.objectEncoding = ObjectEncoding.AMF0;
|
||||
bytes.length = TAG_HEADER_BYTE_COUNT;
|
||||
bytes.position = TAG_HEADER_BYTE_COUNT;
|
||||
for each(_loc2_ in param1)
|
||||
{
|
||||
bytes.writeObject(_loc2_);
|
||||
}
|
||||
dataSize = bytes.length - TAG_HEADER_BYTE_COUNT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class FLVTagVideo extends FLVTag
|
||||
{
|
||||
|
||||
public static const FRAME_TYPE_KEYFRAME:int = 1;
|
||||
|
||||
public static const FRAME_TYPE_INTER:int = 2;
|
||||
|
||||
public static const FRAME_TYPE_DISPOSABLE_INTER:int = 3;
|
||||
|
||||
public static const FRAME_TYPE_GENERATED_KEYFRAME:int = 4;
|
||||
|
||||
public static const FRAME_TYPE_INFO:int = 5;
|
||||
|
||||
public static const CODEC_ID_JPEG:int = 1;
|
||||
|
||||
public static const CODEC_ID_SORENSON:int = 2;
|
||||
|
||||
public static const CODEC_ID_SCREEN:int = 3;
|
||||
|
||||
public static const CODEC_ID_VP6:int = 4;
|
||||
|
||||
public static const CODEC_ID_VP6_ALPHA:int = 5;
|
||||
|
||||
public static const CODEC_ID_SCREEN_V2:int = 6;
|
||||
|
||||
public static const CODEC_ID_AVC:int = 7;
|
||||
|
||||
public static const AVC_PACKET_TYPE_SEQUENCE_HEADER:int = 0;
|
||||
|
||||
public static const AVC_PACKET_TYPE_NALU:int = 1;
|
||||
|
||||
public static const AVC_PACKET_TYPE_END_OF_SEQUENCE:int = 2;
|
||||
|
||||
public static const INFO_PACKET_SEEK_START:int = 0;
|
||||
|
||||
public static const INFO_PACKET_SEEK_END:int = 1;
|
||||
|
||||
public function FLVTagVideo(param1:int = 9)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get frameType() : int
|
||||
{
|
||||
return bytes[TAG_HEADER_BYTE_COUNT + 0] >> 4 & 0x0F;
|
||||
}
|
||||
|
||||
public function set frameType(param1:int) : void
|
||||
{
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] &= 15;
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] |= (param1 & 0x0F) << 4;
|
||||
}
|
||||
|
||||
public function get codecID() : int
|
||||
{
|
||||
return bytes[TAG_HEADER_BYTE_COUNT + 0] & 0x0F;
|
||||
}
|
||||
|
||||
public function set codecID(param1:int) : void
|
||||
{
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] &= 240;
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 0] |= param1 & 0x0F;
|
||||
}
|
||||
|
||||
public function get infoPacketValue() : int
|
||||
{
|
||||
if(this.frameType != FRAME_TYPE_INFO)
|
||||
{
|
||||
throw new Error("get infoPacketValue() not permitted unless frameType is FRAME_TYPE_INFO");
|
||||
}
|
||||
return bytes[TAG_HEADER_BYTE_COUNT + 1];
|
||||
}
|
||||
|
||||
public function set infoPacketValue(param1:int) : void
|
||||
{
|
||||
if(this.frameType != FRAME_TYPE_INFO)
|
||||
{
|
||||
throw new Error("get infoPacketValue() not permitted unless frameType is FRAME_TYPE_INFO");
|
||||
}
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 1] = param1;
|
||||
bytes.length = TAG_HEADER_BYTE_COUNT + 2;
|
||||
dataSize = 2;
|
||||
}
|
||||
|
||||
public function get avcPacketType() : int
|
||||
{
|
||||
if(this.codecID != CODEC_ID_AVC)
|
||||
{
|
||||
throw new Error("get avcPacketType() not permitted unless codecID is CODEC_ID_AVC");
|
||||
}
|
||||
return bytes[TAG_HEADER_BYTE_COUNT + 1];
|
||||
}
|
||||
|
||||
public function set avcPacketType(param1:int) : void
|
||||
{
|
||||
if(this.codecID != CODEC_ID_AVC)
|
||||
{
|
||||
throw new Error("set avcPacketType() not permitted unless codecID is CODEC_ID_AVC");
|
||||
}
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 1] = param1;
|
||||
if(this.avcPacketType != AVC_PACKET_TYPE_NALU)
|
||||
{
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 2] = 0;
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 3] = 0;
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 4] = 0;
|
||||
bytes.length = TAG_HEADER_BYTE_COUNT + 5;
|
||||
dataSize = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public function get avcCompositionTimeOffset() : int
|
||||
{
|
||||
if(this.codecID != CODEC_ID_AVC || this.avcPacketType != AVC_PACKET_TYPE_NALU)
|
||||
{
|
||||
throw new Error("get avcCompositionTimeOffset() not permitted unless codecID is CODEC_ID_AVC and avcPacketType is AVC NALU");
|
||||
}
|
||||
var _loc1_:int = bytes[TAG_HEADER_BYTE_COUNT + 2] << 16;
|
||||
_loc1_ |= bytes[TAG_HEADER_BYTE_COUNT + 3] << 8;
|
||||
_loc1_ |= bytes[TAG_HEADER_BYTE_COUNT + 4];
|
||||
if(_loc1_ & 0x800000)
|
||||
{
|
||||
_loc1_ |= 4278190080;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set avcCompositionTimeOffset(param1:int) : void
|
||||
{
|
||||
if(this.codecID != CODEC_ID_AVC || this.avcPacketType != AVC_PACKET_TYPE_NALU)
|
||||
{
|
||||
throw new Error("set avcCompositionTimeOffset() not permitted unless codecID is CODEC_ID_AVC and avcPacketType is AVC NALU");
|
||||
}
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 2] = param1 >> 16 & 0xFF;
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 3] = param1 >> 8 & 0xFF;
|
||||
bytes[TAG_HEADER_BYTE_COUNT + 4] = param1 & 0xFF;
|
||||
}
|
||||
|
||||
override public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(this.codecID == CODEC_ID_AVC)
|
||||
{
|
||||
_loc1_.writeBytes(bytes,TAG_HEADER_BYTE_COUNT + 5,dataSize - 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.writeBytes(bytes,TAG_HEADER_BYTE_COUNT + 1,dataSize - 1);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function set data(param1:ByteArray) : void
|
||||
{
|
||||
if(this.codecID == CODEC_ID_AVC)
|
||||
{
|
||||
bytes.length = TAG_HEADER_BYTE_COUNT + param1.length + 5;
|
||||
bytes.position = TAG_HEADER_BYTE_COUNT + 5;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes.length = TAG_HEADER_BYTE_COUNT + param1.length + 1;
|
||||
bytes.position = TAG_HEADER_BYTE_COUNT + 1;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package org.osmf.net.rtmpstreaming
|
||||
{
|
||||
import flash.utils.getTimer;
|
||||
import org.osmf.net.NetStreamMetricsBase;
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
|
||||
public class DroppedFramesRule extends SwitchingRuleBase
|
||||
{
|
||||
|
||||
private static const LOCK_INTERVAL:Number = 30000;
|
||||
|
||||
private var downSwitchByOne:int;
|
||||
|
||||
private var downSwitchByTwo:int;
|
||||
|
||||
private var downSwitchToZero:int;
|
||||
|
||||
private var lockLevel:Number;
|
||||
|
||||
private var lastLockTime:Number;
|
||||
|
||||
public function DroppedFramesRule(param1:NetStreamMetricsBase, param2:int = 10, param3:int = 20, param4:int = 24)
|
||||
{
|
||||
super(param1);
|
||||
this.downSwitchByOne = param2;
|
||||
this.downSwitchByTwo = param3;
|
||||
this.downSwitchToZero = param4;
|
||||
this.lastLockTime = 0;
|
||||
this.lockLevel = int.MAX_VALUE;
|
||||
}
|
||||
|
||||
override public function getNewIndex() : int
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc1_:int = -1;
|
||||
if(metrics.averageDroppedFPS > this.downSwitchToZero)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
_loc2_ = "Average droppedFPS of " + Math.round(metrics.averageDroppedFPS) + " > " + this.downSwitchToZero;
|
||||
}
|
||||
else if(metrics.averageDroppedFPS > this.downSwitchByTwo)
|
||||
{
|
||||
_loc1_ = metrics.currentIndex - 2 < 0 ? 0 : int(metrics.currentIndex - 2);
|
||||
_loc2_ = "Average droppedFPS of " + Math.round(metrics.averageDroppedFPS) + " > " + this.downSwitchByTwo;
|
||||
}
|
||||
else if(metrics.averageDroppedFPS > this.downSwitchByOne)
|
||||
{
|
||||
_loc1_ = metrics.currentIndex - 1 < 0 ? 0 : int(metrics.currentIndex - 1);
|
||||
_loc2_ = "Average droppedFPS of " + Math.round(metrics.averageDroppedFPS) + " > " + this.downSwitchByOne;
|
||||
}
|
||||
if(_loc1_ != -1 && _loc1_ < metrics.currentIndex)
|
||||
{
|
||||
this.lockIndex(_loc1_);
|
||||
}
|
||||
if(_loc1_ == -1 && this.isLocked(metrics.currentIndex))
|
||||
{
|
||||
_loc1_ = metrics.currentIndex;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function lockIndex(param1:int) : void
|
||||
{
|
||||
if(!this.isLocked(param1))
|
||||
{
|
||||
this.lockLevel = param1;
|
||||
this.lastLockTime = getTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private function isLocked(param1:int) : Boolean
|
||||
{
|
||||
return param1 >= this.lockLevel && getTimer() - this.lastLockTime < LOCK_INTERVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package org.osmf.net.rtmpstreaming
|
||||
{
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
|
||||
public class InsufficientBandwidthRule extends SwitchingRuleBase
|
||||
{
|
||||
|
||||
private var bitrateMultiplier:Number;
|
||||
|
||||
public function InsufficientBandwidthRule(param1:RTMPNetStreamMetrics, param2:Number = 1.15)
|
||||
{
|
||||
super(param1);
|
||||
this.bitrateMultiplier = param2;
|
||||
}
|
||||
|
||||
override public function getNewIndex() : int
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:* = 0;
|
||||
var _loc1_:int = -1;
|
||||
if(this.rtmpMetrics.averageMaxBytesPerSecond != 0)
|
||||
{
|
||||
_loc3_ = this.rtmpMetrics.currentIndex;
|
||||
while(_loc3_ >= 0)
|
||||
{
|
||||
if(this.rtmpMetrics.averageMaxBytesPerSecond * 8 / 1024 > this.rtmpMetrics.resource.streamItems[_loc3_].bitrate * this.bitrateMultiplier)
|
||||
{
|
||||
_loc1_ = _loc3_;
|
||||
break;
|
||||
}
|
||||
_loc3_--;
|
||||
}
|
||||
_loc1_ = _loc1_ == this.rtmpMetrics.currentIndex ? -1 : _loc1_;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function get rtmpMetrics() : RTMPNetStreamMetrics
|
||||
{
|
||||
return metrics as RTMPNetStreamMetrics;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package org.osmf.net.rtmpstreaming
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import org.osmf.net.NetStreamCodes;
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
|
||||
public class InsufficientBufferRule extends SwitchingRuleBase
|
||||
{
|
||||
|
||||
private var _panic:Boolean;
|
||||
|
||||
private var _moreDetail:String;
|
||||
|
||||
private var minBufferLength:Number;
|
||||
|
||||
public function InsufficientBufferRule(param1:RTMPNetStreamMetrics, param2:Number = 2)
|
||||
{
|
||||
super(param1);
|
||||
this._panic = false;
|
||||
this.minBufferLength = param2;
|
||||
param1.netStream.addEventListener(NetStatusEvent.NET_STATUS,this.monitorNetStatus,false,0,true);
|
||||
}
|
||||
|
||||
override public function getNewIndex() : int
|
||||
{
|
||||
var _loc1_:int = -1;
|
||||
if(this._panic || this.rtmpMetrics.netStream.bufferLength < this.minBufferLength && this.rtmpMetrics.netStream.bufferLength > this.rtmpMetrics.netStream.bufferTime)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function monitorNetStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_BUFFER_FULL:
|
||||
this._panic = false;
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_BUFFER_EMPTY:
|
||||
if(Math.round(this.rtmpMetrics.netStream.time) != 0)
|
||||
{
|
||||
this._panic = true;
|
||||
this._moreDetail = "Buffer was empty";
|
||||
}
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_INSUFFICIENTBW:
|
||||
this._panic = true;
|
||||
this._moreDetail = "Stream had insufficient bandwidth";
|
||||
}
|
||||
}
|
||||
|
||||
private function get rtmpMetrics() : RTMPNetStreamMetrics
|
||||
{
|
||||
return metrics as RTMPNetStreamMetrics;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package org.osmf.net.rtmpstreaming
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.net.NetStreamPlayOptions;
|
||||
import flash.net.NetStreamPlayTransitions;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.net.DynamicStreamingItem;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.NetConnectionFactoryBase;
|
||||
import org.osmf.net.NetLoader;
|
||||
import org.osmf.net.NetStreamLoadTrait;
|
||||
import org.osmf.net.NetStreamSwitchManager;
|
||||
import org.osmf.net.NetStreamSwitchManagerBase;
|
||||
import org.osmf.net.NetStreamUtils;
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
|
||||
public class RTMPDynamicStreamingNetLoader extends NetLoader
|
||||
{
|
||||
|
||||
public function RTMPDynamicStreamingNetLoader(param1:NetConnectionFactoryBase = null)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc2_:DynamicStreamingResource = param1 as DynamicStreamingResource;
|
||||
return _loc2_ != null && NetStreamUtils.isRTMPStream(_loc2_.host) || Boolean(super.canHandleResource(param1));
|
||||
}
|
||||
|
||||
override protected function createNetStreamSwitchManager(param1:NetConnection, param2:NetStream, param3:DynamicStreamingResource) : NetStreamSwitchManagerBase
|
||||
{
|
||||
var _loc4_:RTMPNetStreamMetrics = null;
|
||||
if(param3 != null)
|
||||
{
|
||||
_loc4_ = new RTMPNetStreamMetrics(param2);
|
||||
return new NetStreamSwitchManager(param1,param2,param3,_loc4_,this.getDefaultSwitchingRules(_loc4_));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getDefaultSwitchingRules(param1:RTMPNetStreamMetrics) : Vector.<SwitchingRuleBase>
|
||||
{
|
||||
var _loc2_:Vector.<SwitchingRuleBase> = new Vector.<SwitchingRuleBase>();
|
||||
_loc2_.push(new SufficientBandwidthRule(param1));
|
||||
_loc2_.push(new InsufficientBandwidthRule(param1));
|
||||
_loc2_.push(new DroppedFramesRule(param1));
|
||||
_loc2_.push(new InsufficientBufferRule(param1));
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override protected function reconnectStream(param1:NetStreamLoadTrait) : void
|
||||
{
|
||||
var _loc3_:NetStreamPlayOptions = null;
|
||||
var _loc4_:DynamicStreamingItem = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc2_:DynamicStreamingResource = param1.resource as DynamicStreamingResource;
|
||||
if(_loc2_ == null)
|
||||
{
|
||||
super.reconnectStream(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new NetStreamPlayOptions();
|
||||
param1.netStream.attach(param1.connection);
|
||||
_loc3_.transition = NetStreamPlayTransitions.RESUME;
|
||||
_loc4_ = _loc2_.streamItems[param1.switchManager.currentIndex];
|
||||
_loc5_ = _loc4_.streamName;
|
||||
_loc3_.streamName = _loc5_;
|
||||
param1.netStream.play2(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.osmf.net.rtmpstreaming
|
||||
{
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.net.NetStreamMetricsBase;
|
||||
import org.osmf.net.StreamType;
|
||||
|
||||
public class RTMPNetStreamMetrics extends NetStreamMetricsBase
|
||||
{
|
||||
|
||||
private static const DEFAULT_AVG_MAX_BYTES_SAMPLE_SIZE:Number = 50;
|
||||
|
||||
private var _averageMaxBytesPerSecondArray:Array;
|
||||
|
||||
private var _averageMaxBytesPerSecond:Number;
|
||||
|
||||
public function RTMPNetStreamMetrics(param1:NetStream)
|
||||
{
|
||||
super(param1);
|
||||
this._averageMaxBytesPerSecondArray = new Array();
|
||||
}
|
||||
|
||||
public function get averageMaxBytesPerSecond() : Number
|
||||
{
|
||||
return this._averageMaxBytesPerSecond;
|
||||
}
|
||||
|
||||
override protected function calculateMetrics() : void
|
||||
{
|
||||
var maxBytesPerSecond:Number = NaN;
|
||||
var totalMaxBytesPerSecond:Number = NaN;
|
||||
var peakMaxBytesPerSecond:Number = NaN;
|
||||
var b:uint = 0;
|
||||
super.calculateMetrics();
|
||||
try
|
||||
{
|
||||
maxBytesPerSecond = netStream.info.maxBytesPerSecond;
|
||||
this._averageMaxBytesPerSecondArray.unshift(maxBytesPerSecond);
|
||||
if(this._averageMaxBytesPerSecondArray.length > DEFAULT_AVG_MAX_BYTES_SAMPLE_SIZE)
|
||||
{
|
||||
this._averageMaxBytesPerSecondArray.pop();
|
||||
}
|
||||
totalMaxBytesPerSecond = 0;
|
||||
peakMaxBytesPerSecond = 0;
|
||||
b = 0;
|
||||
while(b < this._averageMaxBytesPerSecondArray.length)
|
||||
{
|
||||
totalMaxBytesPerSecond += this._averageMaxBytesPerSecondArray[b];
|
||||
peakMaxBytesPerSecond = this._averageMaxBytesPerSecondArray[b] > peakMaxBytesPerSecond ? Number(this._averageMaxBytesPerSecondArray[b]) : peakMaxBytesPerSecond;
|
||||
b++;
|
||||
}
|
||||
this._averageMaxBytesPerSecond = this._averageMaxBytesPerSecondArray.length < DEFAULT_AVG_MAX_BYTES_SAMPLE_SIZE ? 0 : (this.isLive ? peakMaxBytesPerSecond : totalMaxBytesPerSecond / this._averageMaxBytesPerSecondArray.length);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private function get isLive() : Boolean
|
||||
{
|
||||
return Boolean(resource) && resource.streamType == StreamType.LIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package org.osmf.net.rtmpstreaming
|
||||
{
|
||||
import org.osmf.net.SwitchingRuleBase;
|
||||
|
||||
public class SufficientBandwidthRule extends SwitchingRuleBase
|
||||
{
|
||||
|
||||
private static const BANDWIDTH_SAFETY_MULTIPLE:Number = 1.15;
|
||||
|
||||
private static const MIN_DROPPED_FPS:int = 2;
|
||||
|
||||
public function SufficientBandwidthRule(param1:RTMPNetStreamMetrics)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
override public function getNewIndex() : int
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:* = 0;
|
||||
var _loc1_:int = -1;
|
||||
if(this.rtmpMetrics.averageMaxBytesPerSecond != 0)
|
||||
{
|
||||
_loc3_ = int(this.rtmpMetrics.resource.streamItems.length - 1);
|
||||
while(_loc3_ >= 0)
|
||||
{
|
||||
if(this.rtmpMetrics.averageMaxBytesPerSecond * 8 / 1024 > this.rtmpMetrics.resource.streamItems[_loc3_].bitrate * BANDWIDTH_SAFETY_MULTIPLE)
|
||||
{
|
||||
_loc1_ = _loc3_;
|
||||
break;
|
||||
}
|
||||
_loc3_--;
|
||||
}
|
||||
if(_loc1_ > this.rtmpMetrics.currentIndex)
|
||||
{
|
||||
_loc1_ = this.rtmpMetrics.droppedFPS < MIN_DROPPED_FPS && this.rtmpMetrics.netStream.bufferLength > this.rtmpMetrics.netStream.bufferTime ? _loc1_ : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ = -1;
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function get rtmpMetrics() : RTMPNetStreamMetrics
|
||||
{
|
||||
return metrics as RTMPNetStreamMetrics;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user